Move: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Mblackwell (talk | contribs)
Sangman (talk | contribs)
m Link to movesprite
 
(3 intermediate revisions by 2 users not shown)
Line 21: Line 21:


You '''cannot''' substitute <name> for a number, define, or gamevar. It has to be predefined with the first definition of move.
You '''cannot''' substitute <name> for a number, define, or gamevar. It has to be predefined with the first definition of move.
If your case requires the actor moving clips through sprites and/or walls, you need to pass in a custom clipmask. This command does not support that, see [[movesprite]].


==moveflags==
==moveflags==
Line 63: Line 66:
|jumptoplayer
|jumptoplayer
|[[actor]] will move vertically and then fall as if jumping.
|[[actor]] will move vertically and then fall as if jumping.
|align="right"|'''256'''
|align="right"|'''257'''*
|-
|-
|seekplayer
|seekplayer
Line 77: Line 80:
|align="right"|'''4096'''
|align="right"|'''4096'''
|}
|}
==Making a Useractor move==
A [[useractor]] can be made to move as part of a given [[action]]. The type of the useractor (ie. Enemy/Notenemy) has an impact on how this functions.
Typically one might expect that we can apply the move on each tic of the action but it doesn't work that way for type Enemy. For that type, a move is started with a "momentum". If it is applied on each tic, the actor will not move at all. On each tic it must be checked if the actor is already moving, and only call the move if they aren't.
This behaviour does not occur for a Notenemy useractor type.
In other words, for a Notenemy, this is sufficient:
<pre>
ifaction MYACTION
{
    move mymove // and apply whatever other flags, e.g. geth
}
</pre>
For an Enemy, use this:
<pre>
ifaction MYACTION
{
    ifmove mymove {} // alternatively: ifmove mymove nullop
    else
        move mymove
}
</pre>


[[Category:Duke3D 1.3/1.5 commands]]
[[Category:Duke3D 1.3/1.5 commands]]
[[Category:Sprite manipulation]]
[[Category:Sprite manipulation]]

Latest revision as of 16:49, 3 December 2020

A move command is used to give velocity to an actor.

Define outside an actor as so:

move <name> <horizontal> <vertical>

<name> is the name of the move command.

Warning: You cannot use the same name from a define, or the game will crash.

<horizontal> is the horizontal velocity of the actor. Negative values reverse direction.

<vertical> is the vertical veloctity of the actor. Negative values cause upward motion.


Used inside an actor, a move command is written as:

move <name> <moveflags...>

<moveflags...> is a (possibly empty) sequence of parameters that specify certain hardcoded movement behavior.

You cannot substitute <name> for a number, define, or gamevar. It has to be predefined with the first definition of move.


If your case requires the actor moving clips through sprites and/or walls, you need to pass in a custom clipmask. This command does not support that, see movesprite.

moveflags

Values for each <moveflag> (defined in DEFS.CON) are:

moveflag description internal value
faceplayer actor faces the player. 1
geth use horizontal velocity. 2
getv use vertical velocity. 4
randomangle actor will face random direction. 8
faceplayerslow same as faceplayer, but done gradually. 16
spin spin in a clockwise circle. 32
faceplayersmart same as faceplayer, but with a slight "lead" on position. 64
fleeenemy actor faces away from the player. 128
jumptoplayer actor will move vertically and then fall as if jumping. 257*
seekplayer actor will try to find the best path to the nearest player. 512
furthestdir actor faces the furthest distance from the closest player. 1024
dodgebullet actor attempts to avoid all shots directed at him. The actor will not avoid GROWSPARK. 4096

Making a Useractor move

A useractor can be made to move as part of a given action. The type of the useractor (ie. Enemy/Notenemy) has an impact on how this functions. Typically one might expect that we can apply the move on each tic of the action but it doesn't work that way for type Enemy. For that type, a move is started with a "momentum". If it is applied on each tic, the actor will not move at all. On each tic it must be checked if the actor is already moving, and only call the move if they aren't.

This behaviour does not occur for a Notenemy useractor type.

In other words, for a Notenemy, this is sufficient:

ifaction MYACTION
{
    move mymove // and apply whatever other flags, e.g. geth
}

For an Enemy, use this:

ifaction MYACTION
{
    ifmove mymove {} // alternatively: ifmove mymove nullop
    else 
        move mymove
}