A new macro for invisibly forcing a specific CTH in combat.
This commit is contained in:
parent
dc71c608f5
commit
7a70d97a93
1 changed files with 207 additions and 0 deletions
|
@ -600,3 +600,210 @@
|
|||
|
||||
{CLEAR_VARIABLE unit_type_table,unit_type_table_i,possible_unit_locations}
|
||||
#enddef
|
||||
|
||||
#define FORCE_CHANCE_TO_HIT FILTER FILTER_SECOND CTH EXTRA_CONDITIONS
|
||||
# Invisibly forces certain units to always have a specific chance to hit
|
||||
# when fighting against certain other units.
|
||||
#
|
||||
# Note that the player still only sees the regular damage calculations, so
|
||||
# this is useful if you need to give an invisible helping hand to the player
|
||||
# or AI. For example, if the player is forced to attack with only a couple
|
||||
# of units at the beginning of a scenario, you can use this to ensure that
|
||||
# simply having bad luck cannot ruin their attempt so easily. Also you might
|
||||
# have enemy leaders which the player is not supposed to fight or be able to
|
||||
# defeat due to storyline reasons, but could theoretically still kill with
|
||||
# some clever trick, AI mistake or sheer exceptional luck.
|
||||
#
|
||||
# An example which forces Konrad's attacks to always hit Li'sar, but only
|
||||
# after turn 10:
|
||||
#! {FORCE_CHANCE_TO_HIT id=Konrad id="Li'sar" 100 (
|
||||
#! [variable]
|
||||
#! name=turn_number
|
||||
#! greater_than=10
|
||||
#! [/variable]
|
||||
#! )}
|
||||
[event]
|
||||
name=attack
|
||||
first_time_only=no
|
||||
|
||||
[filter]
|
||||
{FILTER}
|
||||
[/filter]
|
||||
|
||||
[filter_second]
|
||||
{FILTER_SECOND}
|
||||
[/filter_second]
|
||||
|
||||
[if]
|
||||
[and]
|
||||
{EXTRA_CONDITIONS}
|
||||
[/and]
|
||||
|
||||
[then]
|
||||
{FOREACH unit.attack i}
|
||||
[if]
|
||||
[variable]
|
||||
name=unit.attack[$i].specials.chance_to_hit.length
|
||||
greater_than=0
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
[set_variables]
|
||||
name=unit.attack[$i].specials.original_chance_to_hit
|
||||
to_variable=unit.attack[$i].specials.chance_to_hit
|
||||
[/set_variables]
|
||||
|
||||
{CLEAR_VARIABLE unit.attack[$i].specials.chance_to_hit}
|
||||
[/then]
|
||||
[/if]
|
||||
|
||||
[set_variables]
|
||||
name=unit.attack[$i].specials.chance_to_hit
|
||||
|
||||
[value]
|
||||
id=forced_cth
|
||||
value={CTH}
|
||||
cumulative=no
|
||||
[/value]
|
||||
[/set_variables]
|
||||
{NEXT i}
|
||||
|
||||
[unstore_unit]
|
||||
variable=unit
|
||||
find_vacant=no
|
||||
[/unstore_unit]
|
||||
[/then]
|
||||
[/if]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name=attack end
|
||||
first_time_only=no
|
||||
|
||||
[filter]
|
||||
{FILTER}
|
||||
[/filter]
|
||||
|
||||
[filter_second]
|
||||
{FILTER_SECOND}
|
||||
[/filter_second]
|
||||
|
||||
[if]
|
||||
[and]
|
||||
{EXTRA_CONDITIONS}
|
||||
[/and]
|
||||
|
||||
[then]
|
||||
{FOREACH unit.attack i}
|
||||
{CLEAR_VARIABLE unit.attack[$i].specials.chance_to_hit}
|
||||
|
||||
[set_variables]
|
||||
name=unit.attack[$i].specials.chance_to_hit
|
||||
to_variable=unit.attack[$i].specials.original_chance_to_hit
|
||||
[/set_variables]
|
||||
|
||||
{CLEAR_VARIABLE unit.attack[$i].specials.original_chance_to_hit}
|
||||
{NEXT i}
|
||||
|
||||
[unstore_unit]
|
||||
variable=unit
|
||||
find_vacant=no
|
||||
[/unstore_unit]
|
||||
[/then]
|
||||
[/if]
|
||||
[/event]
|
||||
|
||||
# The following two events are simple duplicates of the above ones, with the
|
||||
# primary and secondary units reversed so that the effect is applied both on
|
||||
# offense and defense.
|
||||
[event]
|
||||
name=attack
|
||||
first_time_only=no
|
||||
|
||||
[filter]
|
||||
{FILTER_SECOND}
|
||||
[/filter]
|
||||
|
||||
[filter_second]
|
||||
{FILTER}
|
||||
[/filter_second]
|
||||
|
||||
[if]
|
||||
[and]
|
||||
{EXTRA_CONDITIONS}
|
||||
[/and]
|
||||
|
||||
[then]
|
||||
{FOREACH second_unit.attack i}
|
||||
[if]
|
||||
[variable]
|
||||
name=second_unit.attack[$i].specials.chance_to_hit.length
|
||||
greater_than=0
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
[set_variables]
|
||||
name=second_unit.attack[$i].specials.original_chance_to_hit
|
||||
to_variable=second_unit.attack[$i].specials.chance_to_hit
|
||||
[/set_variables]
|
||||
|
||||
{CLEAR_VARIABLE second_unit.attack[$i].specials.chance_to_hit}
|
||||
[/then]
|
||||
[/if]
|
||||
|
||||
[set_variables]
|
||||
name=second_unit.attack[$i].specials.chance_to_hit
|
||||
|
||||
[value]
|
||||
id=forced_cth
|
||||
value={CTH}
|
||||
cumulative=no
|
||||
[/value]
|
||||
[/set_variables]
|
||||
{NEXT i}
|
||||
|
||||
[unstore_unit]
|
||||
variable=second_unit
|
||||
find_vacant=no
|
||||
[/unstore_unit]
|
||||
[/then]
|
||||
[/if]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name=attack end
|
||||
first_time_only=no
|
||||
|
||||
[filter]
|
||||
{FILTER_SECOND}
|
||||
[/filter]
|
||||
|
||||
[filter_second]
|
||||
{FILTER}
|
||||
[/filter_second]
|
||||
|
||||
[if]
|
||||
[and]
|
||||
{EXTRA_CONDITIONS}
|
||||
[/and]
|
||||
|
||||
[then]
|
||||
{FOREACH second_unit.attack i}
|
||||
{CLEAR_VARIABLE second_unit.attack[$i].specials.chance_to_hit}
|
||||
|
||||
[set_variables]
|
||||
name=second_unit.attack[$i].specials.chance_to_hit
|
||||
to_variable=second_unit.attack[$i].specials.original_chance_to_hit
|
||||
[/set_variables]
|
||||
|
||||
{CLEAR_VARIABLE second_unit.attack[$i].specials.original_chance_to_hit}
|
||||
{NEXT i}
|
||||
|
||||
[unstore_unit]
|
||||
variable=second_unit
|
||||
find_vacant=no
|
||||
[/unstore_unit]
|
||||
[/then]
|
||||
[/if]
|
||||
[/event]
|
||||
#enddef
|
Loading…
Add table
Reference in a new issue