Adding step macro for creatures
Posted: Fri Oct 15, 2010 8:15 am
I am looking at adding a feature to the mega-patch that will support a form of creature 'step macros' as has been discussed previously.
Basically, this is how it would work. If the feature is enabled, a creature's 'touch macro' setting would actually be used to select two macros. The touch macro would be TOUCHM, while the 'step macro' would be TOUCHM+1. For example, if you have a creature's touch macro set to 100, the touch macro would be 100 and the step macro would be 101.
The step macro would be called for each creature before the normal creature move and attack sequence. Before the step macro is called, the following variables would be set:
W - set to the creature instance number
X - set to creature's X map location
Y - set to creature's Y map location
There will be additional commands added (using the DRAW hook) that allow various stats of a creature (creature type, HP, MP, anger, motive, etc.) to be read or written using the creature instance number as an index. I will also add a command that retrieves the creature instance number from a creature at a given map location.
When the step macro exits, if the W variable is nonzero, no action is performed. If the macro has set W to zero, then the values of X and Y are checked as follows.
X can be set by the step macro to assign an 'extra move' to the creature. This move would take place in addition to, and before, the normal move/attack sequence. Values for X might be something like:
0 - No extra move
1 - Move N
2 - Move S
3 - Move E
4 - Move W
5 - Move towards player
6 - Move away from player
7 - Move randomly
If a creature's motive is set to MOVE, then it will move twice if the above settings are used. If it is set to STOP, however, then it will only use the extra move (but it will still attack normally if possible). This could be used to implement creatures that follow preprogrammed movement paths, flee from the player, etc. Or it could be used to implement friendly creatures that follow the player.
Y can be set by the step macro to select a 'temporary weapon' for the creature to use that turn. Depending on the type of the weapon selected, either the creature's melee weapon or ranged weapon will be temporarily 'swapped out' for that turn only. This could be used to implement the following types of effects:
o Creatures that have more than two types of attacks.
o Creatures that have a powerful attack that can only be used once (or a certain number of times), and then revert to a weaker unlimited attack.
o Creatures that cast a variety of 'spells' (implemented as a ranged weapon in combination with a touch macro).
Of course, the step macro will have access to the normal map editing commands as well, allowing creatures to teleport themselves, delete themselves from the map, etc.
Basically, this is how it would work. If the feature is enabled, a creature's 'touch macro' setting would actually be used to select two macros. The touch macro would be TOUCHM, while the 'step macro' would be TOUCHM+1. For example, if you have a creature's touch macro set to 100, the touch macro would be 100 and the step macro would be 101.
The step macro would be called for each creature before the normal creature move and attack sequence. Before the step macro is called, the following variables would be set:
W - set to the creature instance number
X - set to creature's X map location
Y - set to creature's Y map location
There will be additional commands added (using the DRAW hook) that allow various stats of a creature (creature type, HP, MP, anger, motive, etc.) to be read or written using the creature instance number as an index. I will also add a command that retrieves the creature instance number from a creature at a given map location.
When the step macro exits, if the W variable is nonzero, no action is performed. If the macro has set W to zero, then the values of X and Y are checked as follows.
X can be set by the step macro to assign an 'extra move' to the creature. This move would take place in addition to, and before, the normal move/attack sequence. Values for X might be something like:
0 - No extra move
1 - Move N
2 - Move S
3 - Move E
4 - Move W
5 - Move towards player
6 - Move away from player
7 - Move randomly
If a creature's motive is set to MOVE, then it will move twice if the above settings are used. If it is set to STOP, however, then it will only use the extra move (but it will still attack normally if possible). This could be used to implement creatures that follow preprogrammed movement paths, flee from the player, etc. Or it could be used to implement friendly creatures that follow the player.
Y can be set by the step macro to select a 'temporary weapon' for the creature to use that turn. Depending on the type of the weapon selected, either the creature's melee weapon or ranged weapon will be temporarily 'swapped out' for that turn only. This could be used to implement the following types of effects:
o Creatures that have more than two types of attacks.
o Creatures that have a powerful attack that can only be used once (or a certain number of times), and then revert to a weaker unlimited attack.
o Creatures that cast a variety of 'spells' (implemented as a ranged weapon in combination with a touch macro).
Of course, the step macro will have access to the normal map editing commands as well, allowing creatures to teleport themselves, delete themselves from the map, etc.