Difference between revisions of "WML Abilities"
m |
(Added charm) |
||
Line 63: | Line 63: | ||
{CLEAR_VARIABLE target_hex} | {CLEAR_VARIABLE target_hex} | ||
{CLEAR_VARIABLE defender_in_village} | {CLEAR_VARIABLE defender_in_village} | ||
+ | [/event] | ||
+ | #enddef | ||
+ | |||
+ | === Charm {{DevFeature}} === | ||
+ | |||
+ | When a unit is hit with a ''charm'' attack, it instantly jumps to the attacker's side, and returns to it's original side at the beginning of that side's turn. A charmed unit has 1 movement point and can attack. | ||
+ | |||
+ | Example that makes all Troll Whelps have charm on their attack: | ||
+ | |||
+ | {CHARM (type=Troll Whelp) fist} | ||
+ | |||
+ | Note that this uses the macros ''IF'', ''STORE_UNIT_VAR'' and ''MODIFY_UNIT'' from the [[WML Utilities]] page. | ||
+ | |||
+ | #define CHARM FILTER WEAPON | ||
+ | [event] | ||
+ | name=attacker_hits | ||
+ | first_time_only=no | ||
+ | |||
+ | [filter] | ||
+ | {FILTER} | ||
+ | [/filter] | ||
+ | |||
+ | [special_filter] | ||
+ | weapon={WEAPON} | ||
+ | [/special_filter] | ||
+ | |||
+ | {STORE_UNIT_VAR x,y=$x1,$y1 side charmer_side} | ||
+ | {STORE_UNIT_VAR x,y=$x2,$y2 side charmed_side} | ||
+ | |||
+ | {IF charmer_side not_equals $charmed_side ( | ||
+ | [then] | ||
+ | {MODIFY_UNIT x,y=$x2,$y2 variables.real_side $charmed_side} | ||
+ | {MODIFY_UNIT x,y=$x2,$y2 side $charmer_side} | ||
+ | {MODIFY_UNIT x,y=$x2,$y2 resting yes} | ||
+ | {MODIFY_UNIT x,y=$x2,$y2 moves 1} | ||
+ | |||
+ | {VARIABLE_OP varname format "side_$charmed_side|_units_charmed"} | ||
+ | {VARIABLE $varname yes} | ||
+ | |||
+ | {CLEAR_VARIABLE varname} | ||
+ | [/then] | ||
+ | )} | ||
+ | |||
+ | {CLEAR_VARIABLE charmer_side} | ||
+ | {CLEAR_VARIABLE charmed_side} | ||
+ | [/event] | ||
+ | |||
+ | [event] | ||
+ | name=side turn | ||
+ | first_time_only=no | ||
+ | |||
+ | {VARIABLE_OP this_side_charmed to_variable "side_$side_number|_units_charmed"} | ||
+ | |||
+ | {IF this_side_charmed equals yes ( | ||
+ | [then] | ||
+ | [store_unit] | ||
+ | [filter] | ||
+ | [not] | ||
+ | side=$side_number | ||
+ | [/not] | ||
+ | [/filter] | ||
+ | |||
+ | variable=possibly_charmed | ||
+ | kill=no | ||
+ | [/store_unit] | ||
+ | |||
+ | {FOREACH possibly_charmed i} | ||
+ | {VARIABLE_OP real_side format "0$possibly_charmed[$i].variables.real_side"} | ||
+ | |||
+ | {IF real_side not_equals "0" ( | ||
+ | [then] | ||
+ | {IF side_number equals $possibly_charmed[$i].variables.real_side ( | ||
+ | [then] | ||
+ | {CLEAR_VARIABLE possibly_charmed[$i].variables.real_side} | ||
+ | {VARIABLE possibly_charmed[$i].side $side_number} | ||
+ | |||
+ | [unstore_unit] | ||
+ | variable=possibly_charmed[$i] | ||
+ | find_vacant=no | ||
+ | [/unstore_unit] | ||
+ | [/then] | ||
+ | )} | ||
+ | [/then] | ||
+ | )} | ||
+ | {NEXT i} | ||
+ | |||
+ | {CLEAR_VARIABLE possibly_charmed} | ||
+ | [/then] | ||
+ | )} | ||
[/event] | [/event] | ||
#enddef | #enddef |
Revision as of 19:58, 28 February 2006
Remember that you must include the WML ability code in every scenario where you intend them to work.
Knockback Template:DevFeature
When a unit is hit with a knockback attack, it is immediately pushed one hex away from the attacker, at which point the combat ends. Exception: units in villages can't be knocked out of them.
Examples that give knockback for every Drake Glider on their slam attack, and for the Shock Trooper named Jane:
{KNOCKBACK (type=Drake Glider) slam} {KNOCKBACK description=Jane mace}
Note that this uses the macros OPPOSITE_SIDE, IF, IF_HAVE_UNIT and STORE_UNIT_VAR from the WML Utilities page.
#define KNOCKBACK FILTER WEAPON [event] name=attacker_hits first_time_only=no [filter] {FILTER} [/filter] [special_filter] weapon={WEAPON} [/special_filter] [sound] name=ghoul-hit.wav [/sound] {OPPOSITE_SIDE $x2 $y2 $x1 $y1 target_hex} [store_locations] x,y=$x2,$y2 terrain=AaBbDeLptUVvYZ variable=defender_in_village [/store_locations] {IF_HAVE_UNIT x,y=$target_hex.x,$target_hex.y ( [else] {IF defender_in_village.length not_equals 1 ( [then] {STORE_UNIT_VAR x,y=$x2,$y2 side side_of_defender} [teleport] [filter] x,y=$x2,$y2 [/filter] x,y=$target_hex.x,$target_hex.y [/teleport] [capture_village] side=$side_of_defender x,y=$target_hex.x,$target_hex.y [/capture_village] {CLEAR_VARIABLE side_of_defender} [/then] )} [/else] )} {CLEAR_VARIABLE target_hex} {CLEAR_VARIABLE defender_in_village} [/event] #enddef
Charm Template:DevFeature
When a unit is hit with a charm attack, it instantly jumps to the attacker's side, and returns to it's original side at the beginning of that side's turn. A charmed unit has 1 movement point and can attack.
Example that makes all Troll Whelps have charm on their attack:
{CHARM (type=Troll Whelp) fist}
Note that this uses the macros IF, STORE_UNIT_VAR and MODIFY_UNIT from the WML Utilities page.
#define CHARM FILTER WEAPON [event] name=attacker_hits first_time_only=no [filter] {FILTER} [/filter] [special_filter] weapon={WEAPON} [/special_filter] {STORE_UNIT_VAR x,y=$x1,$y1 side charmer_side} {STORE_UNIT_VAR x,y=$x2,$y2 side charmed_side} {IF charmer_side not_equals $charmed_side ( [then] {MODIFY_UNIT x,y=$x2,$y2 variables.real_side $charmed_side} {MODIFY_UNIT x,y=$x2,$y2 side $charmer_side} {MODIFY_UNIT x,y=$x2,$y2 resting yes} {MODIFY_UNIT x,y=$x2,$y2 moves 1} {VARIABLE_OP varname format "side_$charmed_side|_units_charmed"} {VARIABLE $varname yes} {CLEAR_VARIABLE varname} [/then] )} {CLEAR_VARIABLE charmer_side} {CLEAR_VARIABLE charmed_side} [/event] [event] name=side turn first_time_only=no {VARIABLE_OP this_side_charmed to_variable "side_$side_number|_units_charmed"} {IF this_side_charmed equals yes ( [then] [store_unit] [filter] [not] side=$side_number [/not] [/filter] variable=possibly_charmed kill=no [/store_unit] {FOREACH possibly_charmed i} {VARIABLE_OP real_side format "0$possibly_charmed[$i].variables.real_side"} {IF real_side not_equals "0" ( [then] {IF side_number equals $possibly_charmed[$i].variables.real_side ( [then] {CLEAR_VARIABLE possibly_charmed[$i].variables.real_side} {VARIABLE possibly_charmed[$i].side $side_number} [unstore_unit] variable=possibly_charmed[$i] find_vacant=no [/unstore_unit] [/then] )} [/then] )} {NEXT i} {CLEAR_VARIABLE possibly_charmed} [/then] )} [/event] #enddef