Wander

From AGI Wiki
Jump to: navigation, search

The wander command sets a screen object's movement mode to 'wander' meaning it will randomly move around the screen.

Syntax

wander(obj oA);

Remarks

The movement mode of screen object oA is set to 'wander'. While wandering, AGI will randomly change the direction and distance the object travels. The distance is set to a random number >=6 and <=50. The screen object will also change to a new random direction if it encounters any obstacle (such as a horizon, screen edge, control line, block, etc.)

Setting the movement mode to 'wander' will automatically enable the object for updating if not currently enabled. The cycling property is not modified by the wander command.

If oA is ego, it automatically switches to program control mode.

If the set.dir command is executed while an object is wandering, it will move in the assigned direction until the random function chooses a new direction.

Possible Errors

AGI does not check that object number oA is a valid screen object. If it is not, this command will overwrite other data on the memory heap, which may cause unexpected results, including possibly crashing AGI.

Example

Code:
#define f68 drunk
if(isset(drunk))
  {
  wander(ego);  [ ego will wander aimlessly
  }

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 84 (0x54 hex)

See Also

follow.ego
move.obj
mov.obj.v
normal.motion
set.dir