Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define COMBO_DBG _MSG
- {LOG_ATS_DBG ("COMBO: "+{_MSG})}
- #enddef
- [event]
- name=reset combo status
- first_time_only=no
- [set_variables]
- name=combo_status
- mode=replace
- [value]
- [side_a]
- attacker,attack=$null,$null
- [target]
- x,y=0,0
- [/target]
- [/side_a]
- [side_b]
- attacker,attack=$null,$null
- [target]
- x,y=0,0
- [/target]
- [/side_b]
- [/value]
- [/set_variables]
- [/event]
- [event]
- name=prestart
- {COMBO_DBG "initializing"}
- [fire_event]
- name=reset combo status
- [/fire_event]
- [set_variables]
- name=combo_attacks
- mode=replace
- [literal]
- side_a=[REDACTED]
- side_b=[REDACTED]
- symmetric=no
- name=[REDACTED]
- [effect]
- apply_to=damage
- multiply=3.0
- [/effect]
- [/literal]
- [literal]
- side_a=[REDACTED]
- side_b=[REDACTED]
- symmetric=no
- name=[REDACTED]
- [effect]
- apply_to=damage
- multiply=4.0
- [/effect]
- [/literal]
- [literal]
- side_a=[REDACTED]
- side_b=[REDACTED]
- symmetric=yes
- name=[REDACTED]
- [effect]
- apply_to=damage
- multiply=2.0
- [/effect]
- [/literal]
- [literal]
- side_a=[REDACTED]
- side_b=[REDACTED]
- symmetric=yes
- name=[REDACTED]
- [effect]
- apply_to=damage
- multiply=5.0
- [/effect]
- [/literal]
- [/set_variables]
- {COMBO_DBG "$combo_attacks.length combos"}
- [/event]
- [event]
- name=victory
- {CLEAR_VARIABLE combo_attacks,combo_status}
- [/event]
- #
- # NOTE: Only during offense.
- #
- [event]
- name=attack
- first_time_only=no
- [filter]
- id=[REDACTED]
- [or]
- id=[REDACTED]
- [/or]
- [/filter]
- [filter_condition]
- {VARIABLE_NUMERICAL_EQUALS side_number 1}
- [/filter_condition]
- {VARIABLE combo_side $null}
- [if]
- {VARIABLE_LEXICAL_EQUALS combo_status.side_a.attacker $null}
- [then]
- {VARIABLE combo_side a}
- [/then]
- [else]
- {VARIABLE combo_side b}
- [/else]
- [/if]
- {VARIABLE state_ref combo_status.side_$combo_side}
- {BUG_ON ({VARIABLE_LEXICAL_EQUALS state_ref "combo_status.side_"}) ("No combo side set!")}
- [set_variables]
- name=$state_ref
- mode=replace
- [value]
- attacker=$unit.id
- attack=$weapon.name
- [target]
- x,y=$x2,$y2
- [/target]
- [/value]
- [/set_variables]
- {COMBO_DBG "side $combo_side status set (attacker=$unit.id attack=$weapon.name target=$x2,$y2)"}
- [if]
- {VARIABLE_LEXICAL_EQUALS combo_side b}
- {VARIABLE_NUMERICAL_EQUALS combo_status.side_a.target.x $combo_status.side_b.target.x}
- {VARIABLE_NUMERICAL_EQUALS combo_status.side_a.target.y $combo_status.side_b.target.y}
- [then]
- {COMBO_DBG "side a and side b match, running controller"}
- [fire_event]
- name=combo controller
- [primary_unit]
- x,y=$x1,$y1
- [/primary_unit]
- [secondary_unit]
- x,y=$x2,$y2
- [/secondary_unit]
- [/fire_event]
- [/then]
- [/if]
- {CLEAR_VARIABLE combo_side,state_ref}
- [/event]
- [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 = A/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 = A/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]
- {BUG_ON ({VARIABLE_NUMERICAL_NOT_EQUALS $ra_damage|.length 1}) ("Failed to add [damage] special")}
- [set_variables]
- name=$ra_damage
- mode=merge
- [value]
- id=combo_damage_effect
- apply_to=opponent
- active_on=offense
- [/value]
- [/set_variables]
- [unstore_unit]
- variable=unit
- find_vacant=no
- [/unstore_unit]
- [event]
- id=combo_hits_handler
- 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
- 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]
- [event]
- name=side 1 turn end
- first_time_only=no
- {COMBO_DBG "resetting state on side 1 turn end"}
- [fire_event]
- name=reset combo status
- [/fire_event]
- [/event]
- #undef COMBO_DBG
Advertisement
Add Comment
Please, Sign In to add comment