Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WEAPON_SPECIAL_SHRAPNEL_IMPLEMENTATION
- [event]
- id=shrapnel:hit_handler
- name=attacker hits
- first_time_only=no
- #[filter_attack]
- # special=shrapnel
- #[/filter_attack]
- {BUG_ON
- ({VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL unit.variables.shrapnel.count 0})
- ("shrapnel count <= 0 at event start!")}
- [harm_unit]
- [filter]
- [filter_adjacent]
- x,y=$x2,$y2
- adjacent=$second_unit.facing
- [/filter_adjacent]
- [/filter]
- amount=$(0.80*$weapon.damage)
- alignment=$unit.alignment
- damage_type=$weapon.type
- kill=yes
- fire_event=yes
- animate=yes
- [/harm_unit]
- {VARIABLE_DEC unit.variables.shrapnel.count}
- [if]
- {VARIABLE_NUMERICAL_EQUALS unit.variables.shrapnel.count 0}
- #
- # Remove weapon and events.
- #
- [then]
- {VARIABLE k 0}
- [while]
- {VARIABLE_NUMERICAL_LESS_THAN k $unit.event.length}
- {VARIABLE_NUMERICAL_NOT_EQUALS unit.event[$k].id shrapnel:hit_handler}
- [do]
- {VARIABLE_INC k}
- [/do]
- [/while]
- {BUG_ON ({VARIABLE_NUMERICAL_EQUALS k $unit.event.length})
- ("shrapnel unit does not carry the shrapnel controller event!")}
- {CLEAR_VARIABLE unit.event[$k],unit.variables.shrapnel,k}
- # Update unit on map before applying objects.
- [unstore_unit]
- variable=unit
- find_vacant=no
- [/unstore_unit]
- [object]
- silent=yes
- [filter]
- x,y=$x1,$y1
- [/filter]
- [effect]
- apply_to=remove_attacks
- name=shrapnel
- [/effect]
- [/object]
- [event]
- remove=yes
- id=shrapnel:hit_handler
- [/event]
- [/then]
- #
- # Update counter in the attack name.
- #
- [else]
- # Update unit on map before applying objects.
- [unstore_unit]
- variable=unit
- find_vacant=no
- [/unstore_unit]
- [object]
- silent=yes
- [filter]
- x,y=$x1,$y1
- [/filter]
- [effect]
- apply_to=attack
- name=shrapnel
- set_description="$unit.variables.shrapnel.name ($unit.variables.shrapnel.count)"
- [/effect]
- [/object]
- [/else]
- [/if]
- [/event]
- #enddef
Advertisement
Add Comment
Please, Sign In to add comment