Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [event]
- name=combo controller
- first_time_only=no
- # Pseudo-references to keep code tidy.
- {VARIABLE rs_a combo_status.side_a}
- {VARIABLE rs_b combo_status.side_b}
- {BUG_ON (
- [not]
- {VARIABLE_NUMERICAL_EQUALS $rs_a|.target.x $x2}
- {VARIABLE_NUMERICAL_EQUALS $rs_a|.target.y $y2}
- {VARIABLE_NUMERICAL_EQUALS $rs_b|.target.x $x2}
- {VARIABLE_NUMERICAL_EQUALS $rs_b|.target.y $y2}
- [/not]
- ) ("Combo controller invoked with bad target")}
- {FOREACH combo_attacks n}
- # More pseudo-references
- {VARIABLE rc_combo combo_attacks[$n]}
- {BUG_ON ({VARIABLE_NUMERICAL_NOT_EQUALS $rc_combo|.effect.length 1}) ("Combo effect count in config is not 1 ($$rc_combo|.effect.length)")}
- {VARIABLE rc_effect $rc_combo|.effect}
- [if]
- {FALSE}
- # Condition 1: symmetric combos
- [or]
- {VARIABLE_BOOLEAN_EQUALS $rc_combo|.symmetric yes}
- [and] # A is A or B
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_a|.attack}
- [or]
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_b|.attack}
- [/or]
- [/and]
- [and] # B is A or B
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_a|.attack}
- [or]
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_b|.attack}
- [/or]
- [/and]
- [/or]
- # Condition 2: asymmetric combos
- [or]
- {VARIABLE_BOOLEAN_EQUALS $rc_combo|.symmetric no}
- # A = A
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_a $$rs_a|.attack}
- # B = B
- {VARIABLE_LEXICAL_EQUALS $rc_combo|.side_b $$rs_b|.attack}
- [/or]
- [then]
- {COMBO_DBG "selected combo [$n]; side a = $$rs_a|.attack; side b = $$rs_b|.attack"}
- # Apply the combo to the selected attack, then break the loop
- {FOREACH unit.attack m}
- [if]
- {VARIABLE_LEXICAL_EQUALS unit.attack[$m].name $$rs_b|.attack}
- [then]
- {COMBO_DBG "applying combo effects to attack [$m] '$$rs_b|.attack' on $unit.id"}
- [if]
- {VARIABLE_LEXICAL_EQUALS $rc_effect|.apply_to damage}
- [then]
- {VARIABLE ra_damage_ary "unit.attack[$m].specials.damage"}
- {VARIABLE ra_damage "$ra_damage_ary|[$$ra_damage_ary|.length]"}
- [set_variables]
- name=$ra_damage
- mode=insert
- [insert_tag]
- name=value
- variable=$rc_effect
- [/insert_tag]
- [/set_variables]
- [set_variables]
- name=$ra_damage
- mode=merge
- [value]
- id=combo_damage_effect # wmllint: ignore
- apply_to=self
- active_on=offense
- [/value]
- [/set_variables]
- #{COMBO_DBG "$ra_damage|.id = $$ra_damage|.id"}
- #{COMBO_DBG "$ra_damage|.multiply = $$ra_damage|.multiply"}
- #{COMBO_DBG "$ra_damage|.apply_to = $$ra_damage|.apply_to"}
- #{COMBO_DBG "$ra_damage|.active_on = $$ra_damage|.active_on"}
- [unstore_unit]
- variable=unit
- find_vacant=no
- [/unstore_unit]
- [event]
- id=combo_hits_handler # wmllint: ignore
- name=attacker hits
- delayed_variable_substitution=no
- first_time_only=yes
- {UNIT_SPELL_POPUP x,y=$|x1,$|y1 $$rc_combo|.name}
- [/event]
- [event]
- name=attack end
- delayed_variable_substitution=no
- first_time_only=yes
- {COMBO_DBG "removing combo effects"}
- {CLEAR_VARIABLE $ra_damage}
- [unstore_unit]
- variable=unit
- find_vacant=no
- [/unstore_unit]
- [fire_event]
- name=reset combo status
- [/fire_event]
- [event]
- id=combo_hits_handler # wmllint: ignore
- remove=yes
- [/event]
- [/event]
- {CLEAR_VARIABLE ra_damage,ra_damage_ary}
- {BREAK m}
- [/then]
- [else]
- {BUG ("Combo effect not implemented yet: '$$rc_effect|.apply_to'")}
- [/else]
- [/if]
- [/then]
- [/if]
- {NEXT m}
- {BREAK n}
- [/then]
- [/if]
- {CLEAR_VARIABLE rc_combo,rc_effect}
- {NEXT n}
- {CLEAR_VARIABLE rs_a,rs_b}
- [/event]
Advertisement
Add Comment
Please, Sign In to add comment