shadowm

Untitled

Sep 12th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. #define WEAPON_SPECIAL_SHRAPNEL_IMPLEMENTATION
  2. [event]
  3. id=shrapnel:hit_handler
  4. name=attacker hits
  5. first_time_only=no
  6. #[filter_attack]
  7. # special=shrapnel
  8. #[/filter_attack]
  9.  
  10. {BUG_ON
  11. ({VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL unit.variables.shrapnel.count 0})
  12. ("shrapnel count <= 0 at event start!")}
  13.  
  14. [harm_unit]
  15. [filter]
  16. [filter_adjacent]
  17. x,y=$x2,$y2
  18. adjacent=$second_unit.facing
  19. [/filter_adjacent]
  20. [/filter]
  21. amount=$(0.80*$weapon.damage)
  22. alignment=$unit.alignment
  23. damage_type=$weapon.type
  24. kill=yes
  25. fire_event=yes
  26. animate=yes
  27. [/harm_unit]
  28.  
  29. {VARIABLE_DEC unit.variables.shrapnel.count}
  30.  
  31. [if]
  32. {VARIABLE_NUMERICAL_EQUALS unit.variables.shrapnel.count 0}
  33.  
  34. #
  35. # Remove weapon and events.
  36. #
  37. [then]
  38. {VARIABLE k 0}
  39. [while]
  40. {VARIABLE_NUMERICAL_LESS_THAN k $unit.event.length}
  41. {VARIABLE_NUMERICAL_NOT_EQUALS unit.event[$k].id shrapnel:hit_handler}
  42. [do]
  43. {VARIABLE_INC k}
  44. [/do]
  45. [/while]
  46.  
  47. {BUG_ON ({VARIABLE_NUMERICAL_EQUALS k $unit.event.length})
  48. ("shrapnel unit does not carry the shrapnel controller event!")}
  49.  
  50. {CLEAR_VARIABLE unit.event[$k],unit.variables.shrapnel,k}
  51.  
  52. # Update unit on map before applying objects.
  53. [unstore_unit]
  54. variable=unit
  55. find_vacant=no
  56. [/unstore_unit]
  57.  
  58. [object]
  59. silent=yes
  60. [filter]
  61. x,y=$x1,$y1
  62. [/filter]
  63. [effect]
  64. apply_to=remove_attacks
  65. name=shrapnel
  66. [/effect]
  67. [/object]
  68.  
  69. [event]
  70. remove=yes
  71. id=shrapnel:hit_handler
  72. [/event]
  73. [/then]
  74. #
  75. # Update counter in the attack name.
  76. #
  77. [else]
  78. # Update unit on map before applying objects.
  79. [unstore_unit]
  80. variable=unit
  81. find_vacant=no
  82. [/unstore_unit]
  83.  
  84. [object]
  85. silent=yes
  86. [filter]
  87. x,y=$x1,$y1
  88. [/filter]
  89. [effect]
  90. apply_to=attack
  91. name=shrapnel
  92. set_description="$unit.variables.shrapnel.name ($unit.variables.shrapnel.count)"
  93. [/effect]
  94. [/object]
  95. [/else]
  96. [/if]
  97. [/event]
  98. #enddef
Advertisement
Add Comment
Please, Sign In to add comment