Move.obj.v

From AGI Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The move.obj.v command sets an object's movement mode to 'move object' meaning it will move toward an indirectly specified screen coordinate.

Syntax

move.obj.v(obj oA, var vX, var vY, var vSTEP, flg fDONE);

Remarks

Screen object oA begins moving toward the point vX, vY. AGI calculates the best direction based on distance from the point. The screen object will move vSTEP pixels each step. If vSTEP = 0, the screen object's current step size is used. When the screen object is less than vSTEP pixels away from point (vX, vY), the screen object's direction is set to 0, flag fDONE is set to TRUE, and the screen object switches to normal motion. The screen object's original step size is restored.

Flag fDONE is reset to FALSE when the command is executed.

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

If oA is ego, it automatically switches to program control mode. It also returns to player control mode automatically when it reaches its target location. If you use the set.dir command when an screen object's motion is set to move to a point, the screen object will move in that direction for one interpreter cycle, but will begin moving toward the end point again after that.

Possible Errors

AGI does not check that screen 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.

If either vX or vY are off screen (vX >= 160; vY >= 168), the command behaves a bit differently. As soon as the screen object reaches an edge, AGI will set flag fDONE to TRUE, and switch the screen object to normal motion, but the screen object's direction is not set to zero. If the screen object was moving diagonally when it touched the edge, it will continue moving along the edge since its direction was not set to zero. To avoid unintentional results, it is best to avoid using invalid values for vX and vY.

WARNING: If your game relies on the flag fDONE to be set before continuing with something, such as going to the next part of a cut scene, make sure that the screen object will always be able to reach its destination. It is possible that it could get caught behind a barrier or something, and not be able to get where it needs to go, in which case the game will sit there forever doing nothing. This is more of a problem when the screen object being moved is ego - it might work fine from where you test it, but it may be possible for the player to move ego into such a position where they will get “stuck” when being moved.

Example

Code:
v201 = 120;
v202 = 44;
v203 = 2;
move.obj.v(o1, v201, v202, v203, f99);
[ object will move to the point (120, 44),
[ two pixels per step

Technical Information

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

See Also

move.obj
set.dir