shadowm

Untitled

Feb 10th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.17 KB | None | 0 0
  1. #define COMBO_DBG _MSG
  2. {LOG_ATS_DBG ("COMBO: "+{_MSG})}
  3. #enddef
  4.  
  5. [event]
  6. name=reset combo status
  7. first_time_only=no
  8.  
  9. [set_variables]
  10. name=combo_status
  11. mode=replace
  12. [value]
  13. [side_a]
  14. attacker,attack=$null,$null
  15. [target]
  16. x,y=0,0
  17. [/target]
  18. [/side_a]
  19. [side_b]
  20. attacker,attack=$null,$null
  21. [target]
  22. x,y=0,0
  23. [/target]
  24. [/side_b]
  25. [/value]
  26. [/set_variables]
  27. [/event]
  28.  
  29. [event]
  30. name=prestart
  31.  
  32. {COMBO_DBG "initializing"}
  33.  
  34. [fire_event]
  35. name=reset combo status
  36. [/fire_event]
  37.  
  38. [set_variables]
  39. name=combo_attacks
  40. mode=replace
  41. [literal]
  42. side_a=[REDACTED]
  43. side_b=[REDACTED]
  44. symmetric=no
  45. name=[REDACTED]
  46. [effect]
  47. apply_to=damage
  48. multiply=3.0
  49. [/effect]
  50. [/literal]
  51. [literal]
  52. side_a=[REDACTED]
  53. side_b=[REDACTED]
  54. symmetric=no
  55. name=[REDACTED]
  56. [effect]
  57. apply_to=damage
  58. multiply=4.0
  59. [/effect]
  60. [/literal]
  61. [literal]
  62. side_a=[REDACTED]
  63. side_b=[REDACTED]
  64. symmetric=yes
  65. name=[REDACTED]
  66. [effect]
  67. apply_to=damage
  68. multiply=2.0
  69. [/effect]
  70. [/literal]
  71. [literal]
  72. side_a=[REDACTED]
  73. side_b=[REDACTED]
  74. symmetric=yes
  75. name=[REDACTED]
  76. [effect]
  77. apply_to=damage
  78. multiply=5.0
  79. [/effect]
  80. [/literal]
  81. [/set_variables]
  82.  
  83. {COMBO_DBG "$combo_attacks.length combos"}
  84. [/event]
  85.  
  86. [event]
  87. name=victory
  88.  
  89. {CLEAR_VARIABLE combo_attacks,combo_status}
  90. [/event]
  91.  
  92. #
  93. # NOTE: Only during offense.
  94. #
  95.  
  96. [event]
  97. name=attack
  98. first_time_only=no
  99. [filter]
  100. id=[REDACTED]
  101. [or]
  102. id=[REDACTED]
  103. [/or]
  104. [/filter]
  105. [filter_condition]
  106. {VARIABLE_NUMERICAL_EQUALS side_number 1}
  107. [/filter_condition]
  108.  
  109. {VARIABLE combo_side $null}
  110.  
  111. [if]
  112. {VARIABLE_LEXICAL_EQUALS combo_status.side_a.attacker $null}
  113. [then]
  114. {VARIABLE combo_side a}
  115. [/then]
  116. [else]
  117. {VARIABLE combo_side b}
  118. [/else]
  119. [/if]
  120.  
  121. {VARIABLE state_ref combo_status.side_$combo_side}
  122.  
  123. {BUG_ON ({VARIABLE_LEXICAL_EQUALS state_ref "combo_status.side_"}) ("No combo side set!")}
  124.  
  125. [set_variables]
  126. name=$state_ref
  127. mode=replace
  128. [value]
  129. attacker=$unit.id
  130. attack=$weapon.name
  131. [target]
  132. x,y=$x2,$y2
  133. [/target]
  134. [/value]
  135. [/set_variables]
  136.  
  137. {COMBO_DBG "side $combo_side status set (attacker=$unit.id attack=$weapon.name target=$x2,$y2)"}
  138.  
  139. [if]
  140. {VARIABLE_LEXICAL_EQUALS combo_side b}
  141.  
  142. {VARIABLE_NUMERICAL_EQUALS combo_status.side_a.target.x $combo_status.side_b.target.x}
  143. {VARIABLE_NUMERICAL_EQUALS combo_status.side_a.target.y $combo_status.side_b.target.y}
  144.  
  145. [then]
  146. {COMBO_DBG "side a and side b match, running controller"}
  147.  
  148. [fire_event]
  149. name=combo controller
  150. [primary_unit]
  151. x,y=$x1,$y1
  152. [/primary_unit]
  153. [secondary_unit]
  154. x,y=$x2,$y2
  155. [/secondary_unit]
  156. [/fire_event]
  157. [/then]
  158. [/if]
  159.  
  160. {CLEAR_VARIABLE combo_side,state_ref}
  161. [/event]
  162.  
  163. [event]
  164. name=combo controller
  165. first_time_only=no
  166.  
  167. # Pseudo-references to keep code tidy.
  168.  
  169. {VARIABLE rs_a combo_status.side_a}
  170. {VARIABLE rs_b combo_status.side_b}
  171.  
  172. {BUG_ON (
  173. [not]
  174. {VARIABLE_NUMERICAL_EQUALS $rs_a|.target.x $x2}
  175. {VARIABLE_NUMERICAL_EQUALS $rs_a|.target.y $y2}
  176. {VARIABLE_NUMERICAL_EQUALS $rs_b|.target.x $x2}
  177. {VARIABLE_NUMERICAL_EQUALS $rs_b|.target.y $y2}
  178. [/not]
  179. ) ("Combo controller invoked with bad target")}
  180.  
  181. {FOREACH combo_attacks n}
  182. # More pseudo-references
  183. {VARIABLE rc_combo combo_attacks[$n]}
  184.  
  185. {BUG_ON ({VARIABLE_NUMERICAL_NOT_EQUALS $rc_combo|.effect.length 1}) ("Combo effect count in config is not 1 ($$rc_combo|.effect.length)")}
  186.  
  187. {VARIABLE rc_effect $rc_combo|.effect}
  188.  
  189. [if]
  190. {FALSE}
  191.  
  192. # Condition 1: symmetric combos
  193. [or]
  194. {VARIABLE_BOOLEAN_EQUALS $rc_combo|.symmetric yes}
  195. [and] # A = A/B
  196. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_a|.attack}
  197. [or]
  198. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_b|.attack}
  199. [/or]
  200. [/and]
  201. [and] # B = A/B
  202. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_a|.attack}
  203. [or]
  204. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_b|.attack}
  205. [/or]
  206. [/and]
  207. [/or]
  208.  
  209. # Condition 2: asymmetric combos
  210. [or]
  211. {VARIABLE_BOOLEAN_EQUALS $rc_combo|.symmetric no}
  212. # A = A
  213. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_a|.attack}
  214. # B = B
  215. {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_b|.attack}
  216. [/or]
  217.  
  218. [then]
  219. {COMBO_DBG "selected combo [$n]; side a = $$rs_a|.attack; side b = $$rs_b|.attack"}
  220.  
  221. # Apply the combo to the selected attack, then break the loop
  222. {FOREACH unit.attack m}
  223. [if]
  224. {VARIABLE_LEXICAL_EQUALS unit.attack[$m].name $$rs_b|.attack}
  225. [then]
  226. {COMBO_DBG "applying combo effects to attack [$m] '$$rs_b|.attack' on $unit.id"}
  227.  
  228. [if]
  229. {VARIABLE_LEXICAL_EQUALS $rc_effect|.apply_to damage}
  230. [then]
  231. {VARIABLE ra_damage_ary "unit.attack[$m].specials.damage"}
  232. {VARIABLE ra_damage "$ra_damage_ary|[$ra_damage_ary|.length]"}
  233.  
  234. [set_variables]
  235. name=$ra_damage
  236. mode=insert
  237. [insert_tag]
  238. name=value
  239. variable=$rc_effect
  240. [/insert_tag]
  241. [/set_variables]
  242.  
  243. {BUG_ON ({VARIABLE_NUMERICAL_NOT_EQUALS $ra_damage|.length 1}) ("Failed to add [damage] special")}
  244.  
  245. [set_variables]
  246. name=$ra_damage
  247. mode=merge
  248. [value]
  249. id=combo_damage_effect
  250. apply_to=opponent
  251. active_on=offense
  252. [/value]
  253. [/set_variables]
  254.  
  255. [unstore_unit]
  256. variable=unit
  257. find_vacant=no
  258. [/unstore_unit]
  259.  
  260. [event]
  261. id=combo_hits_handler
  262. name=attacker hits
  263. delayed_variable_substitution=no
  264. first_time_only=yes
  265.  
  266. {UNIT_SPELL_POPUP x,y=$|x1,$|y1 $$rc_combo|.name}
  267. [/event]
  268.  
  269. [event]
  270. name=attack end
  271. delayed_variable_substitution=no
  272. first_time_only=yes
  273.  
  274. {COMBO_DBG "removing combo effects"}
  275.  
  276. {CLEAR_VARIABLE $ra_damage}
  277.  
  278. [unstore_unit]
  279. variable=unit
  280. find_vacant=no
  281. [/unstore_unit]
  282.  
  283. [fire_event]
  284. name=reset combo status
  285. [/fire_event]
  286.  
  287. [event]
  288. id=combo_hits_handler
  289. remove=yes
  290. [/event]
  291. [/event]
  292.  
  293. {CLEAR_VARIABLE ra_damage,ra_damage_ary}
  294.  
  295. {BREAK m}
  296. [/then]
  297. [else]
  298. {BUG ("Combo effect not implemented yet: '$$rc_effect|.apply_to'")}
  299. [/else]
  300. [/if]
  301. [/then]
  302. [/if]
  303.  
  304. {NEXT m}
  305.  
  306. {BREAK n}
  307. [/then]
  308. [/if]
  309.  
  310. {CLEAR_VARIABLE rc_combo,rc_effect}
  311. {NEXT n}
  312.  
  313. {CLEAR_VARIABLE rs_a,rs_b}
  314. [/event]
  315.  
  316. [event]
  317. name=side 1 turn end
  318. first_time_only=no
  319.  
  320. {COMBO_DBG "resetting state on side 1 turn end"}
  321.  
  322. [fire_event]
  323. name=reset combo status
  324. [/fire_event]
  325. [/event]
  326.  
  327. #undef COMBO_DBG
Advertisement
Add Comment
Please, Sign In to add comment