Another fix to the lava damage.

Make the loop not change the benchmark damage value.

Scrap some redundant variables.

Slim down and better indent the code.
This commit is contained in:
Piotr Cychowski 2008-01-31 13:43:42 +00:00
parent b615a67fd0
commit b31859fdb4

View file

@ -1019,122 +1019,83 @@
# on a lava hex take 25 damage. This damage can kill units.
[event]
name=new turn
first_time_only=no
[redraw]
[/redraw]
[store_locations]
x=1-33
y=11-27
terrain=Yl
[filter]
side=1,3,4
[not]
type=Zhul Shyde,Zhul Star,Desert Shyde,Desert Star,Dust Devil
[/not]
[/filter]
variable=locs
[/store_locations]
{FOREACH locs i}
[set_variable]
name=temp_x
to_variable=locs[$i].x
[/set_variable]
[set_variable]
name=temp_y
to_variable=locs[$i].y
[/set_variable]
[store_unit]
[filter]
x,y=$temp_x,$temp_y
[/filter]
variable=unitstats
[/store_unit]
name=new turn
first_time_only=no
[redraw]
side=1
[/redraw]
[store_locations]
terrain=Yl
[filter]
side=1,3,4
[not]
type=Zhul Shyde,Zhul Star,Desert Shyde,Desert Star,Dust Devil
[/not]
[/filter]
variable=lava_hex
[/store_locations]
{VARIABLE i 0}
{FOREACH lava_hex i}
[store_unit]
[filter]
x,y=$lava_hex[$i].x,$lava_hex[$i].y
[/filter]
variable=unit_on_lava
[/store_unit]
# this code makes sure Kaleh stays unslowed
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
[variable]
name=unit_on_lava.description
equals=Kaleh
[/variable]
[then]
[set_variable]
name=unit_on_lava.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
[variable]
name=unitstats.description
equals=Kaleh
[/variable]
{VARIABLE heat_offset $heat_damage}
{VARIABLE_OP heat_offset multiply -1}
{VARIABLE damage_recived $lava_damage}
{VARIABLE_OP damage_recived add $heat_offset}
{CLEAR_VARIABLE heat_offset}
[then]
[set_variable]
name=unitstats.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
{VARIABLE_OP unit_on_lava.hitpoints add $damage_recived}
{VARIABLE damage_msg $damage_recived}
{VARIABLE_OP damage_msg multiply -1}
{CLEAR_VARIABLE damage_recived}
# if unitstats.hitpoints is < 1, unstore unit and kill it,
# else just unstore it
[unstore_unit]
variable=unit_on_lava
text=$damage_msg
{COLOR_HARM}
[/unstore_unit]
[if]
[variable]
name=unit_on_lava.hitpoints
less_than=1
[/variable]
[then]
[kill]
description=$unit_on_lava.description
fire_event=yes
animate=yes
[/kill]
[/then]
[/if]
{CLEAR_VARIABLE unit_on_lava}
{CLEAR_VARIABLE damage_msg}
{NEXT i}
{VARIABLE temp $heat_damage}
{VARIABLE_OP temp multiply -1}
{VARIABLE_OP lava_damage add $temp}
{CLEAR_VARIABLE temp}
{CLEAR_VARIABLE lava_hex}
[set_variable]
name=unitstats.hitpoints
add=$lava_damage
[/set_variable]
[set_variable]
name=damage_msg
format=$lava_damage
[/set_variable]
[set_variable]
name=damage_msg
multiply=-1
[/set_variable]
# if unitstats.hitpoints is < 1, unstore unit and kill it,
# else just unstore it
[if]
[variable]
name=unitstats.hitpoints
less_than=1
[/variable]
[then]
[unstore_unit]
variable=unitstats
text=$damage_msg
{COLOR_HARM}
[/unstore_unit]
[kill]
x,y=$temp_x,$temp_y
fire_event=yes
animate=yes
[/kill]
[/then]
[else]
[unstore_unit]
variable=unitstats
text=$damage_msg
{COLOR_HARM}
[/unstore_unit]
[/else]
[/if]
{CLEAR_VARIABLE unitstats}
{NEXT i}
{CLEAR_VARIABLE locs}
{CLEAR_VARIABLE damage_msg}
[/event]
# At the start of each turn, all units in main cavern standing on a cave