Fix rare bug in FORCE_CHANCE_TO_HIT

If in attack end in FORCE_CHANCE_TO_HIT macro, unit or second unit doesn't exist anymore because rare case where unit disapear before attack end event was calledthen we have an error message like "Invalid WML found: [unstore_unit]: variable 'second_unit' doesn't exist" because presence of unit not condition of execution of event.
This commit is contained in:
newfrenchy83 2018-10-28 14:11:16 +01:00 committed by Gregory A Lundberg
parent 5fa2ba279e
commit edab243b9d
No known key found for this signature in database
GPG key ID: 149484078AE8AE9E
2 changed files with 49 additions and 0 deletions

View file

@ -514,6 +514,8 @@
#! greater_than=10
#! [/variable]
#! )}
# WARNING : if an unit must disappear in mid-battle before attack end was fired, recreate unit instead to unstore or cth modifications
# persist. Or don't use this macro.
[event]
name=attack
first_time_only=no
@ -564,6 +566,9 @@
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[filter_opponent]
{SECOND_FILTER}
[/filter_opponent]
[/value]
[/set_variables]
[/do]
@ -578,6 +583,12 @@
name=attack end
delayed_variable_substitution=yes
[filter_condition]
[have_unit]
id=$unit.id
[/have_unit]
[/filter_condition]
[foreach]
array=unit.attack
[do]
@ -651,6 +662,9 @@
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[filter_opponent]
{SECOND_FILTER}
[/filter_opponent]
[/value]
[/set_variables]
[/do]
@ -665,6 +679,12 @@
name=attack end
delayed_variable_substitution=yes
[filter_condition]
[have_unit]
id=$second_unit.id
[/have_unit]
[/filter_condition]
[foreach]
array=second_unit.attack
[do]

View file

@ -4063,6 +4063,35 @@ unplagueable: $wml_unit.status.unplagueable"
{CLEAR_VARIABLE x_len}
{CLEAR_VARIABLE xy_len}
[/event]
{FORCE_CHANCE_TO_HIT (type=Silver Mage) (type="Orcish Archer") 50 ()}
[event]
name=attack end
[filter]
type=Silver Mage
[/filter]
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=blink_test
kill=yes
[/store_unit]
[/event]
[event]
name=turn 2
[unstore_unit]
variable=blink_test
x,y=17,3
[/unstore_unit]
[unit]
side=2
x,y=18,3
type="Orcish Archer"
generate_name=yes
jamming=5
[/unit]
[/event]
[/test]
[units]