EI S09: fix minor bugs, code improvements (#9854)

* Remove STARTING_VILLAGES

There are no villages close enough anyway.

* Fix revealing villages

Use the coordinates of the ogre village instead of what probably were
two removed villages.

* Remove capture of non-existent village

There is no village at 32,13. The nearest one is at 36,11, and it is too
far for Mortic too reach in one turn, so they don't even try.

* Simplify human-meets-ogre event

Instead of repeatedly running FIND_NEARBY, use already assigned unit and
second_unit variables.

* Simplify ogre-meets-ogre event

Use already assigned "unit" variable and find another unit adjacent to
it.

* Fix bugs in Grug-meeets-ogre event

There were two bugs. First, calling FIND_NEARBY with $found_unit as an
argument causes a clash with its internal variable and leads to the
wrong (not nearest) unit being selected. Second, the last message used
$unit instead of $found_unit, which made Grug say this line instead of
the wild ogre.

* Use $this_item instead of $unit in foreach

To avoid clashes with $unit automatically assigned in other events.

* Fix clearing variables

Remove clearing variables that are not actually used, clean those which
are used. Remove elixir_drinker variable from the macro as we use the
trait instead.

* Use $x1, $y1 instead of $unit fields

Makes the code a bit shorter.

* Simplify drake sighted event

Replace FIND_NEARBY with simple condition.

* Rename variables

our_id to our_unit_id, their_id to their_unit_id
This commit is contained in:
Thewodoros 2025-02-10 19:58:38 +03:00 committed by GitHub
parent f024347f86
commit c029f6ee48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 88 additions and 55 deletions

View File

@ -62,7 +62,6 @@
# wmllint: recognize Gweddry
{CHARACTER_STATS_GWEDDRY}
[/side]
{STARTING_VILLAGES 1 5}
#---------------------
# DRAKES
@ -601,8 +600,8 @@
[remove_shroud]
side=1
radius=1
x=39,44, 6 # villages
y=29,28, 21
x=42, 6 # villages
y=29, 21
[/remove_shroud]
[remove_shroud]
side=1
@ -740,9 +739,8 @@
[foreach]
array=frostbite_units
variable=unit
[do]
{MODIFY_UNIT (id=$unit.id) status.slowed yes}
{MODIFY_UNIT (id=$this_item.id) status.slowed yes}
[delay]
time=100
[/delay]
@ -751,13 +749,13 @@
# elixir of elements and yetiburger grant immunity to frostbite
# (there's only 2 immunity items and you have 3 heroes, so this isn't abusable to farm infinite gold)
[have_unit]
id=$unit.id
id=$this_item.id
trait=TRAIT_{ID_YETIBURGER},TRAIT_elements
[/have_unit]
[then]
[floating_text]
x,y=$unit.x,$unit.y
x,y=$this_item.x,$this_item.y
#po: other units are taking damage from the cold, but this unit is immune (through the elixir or yetiburger)
text= _ "<span color='#00FF00' size='small'>resist</span>"
[/floating_text]
@ -767,7 +765,7 @@
[if]
# if the unit is about to die, deal the damage after turn refresh, so we have a chance to heal first
[have_unit]
id=$unit.id
id=$this_item.id
formula=(self.hitpoints<=$frostbite_amount)
[/have_unit]
[then]
@ -776,7 +774,7 @@
delayed_variable_substitution=no
[harm_unit]
[filter]
id=$unit.id
id=$this_item.id
[/filter]
amount=$frostbite_amount
animate=yes
@ -790,7 +788,7 @@
[else]
[harm_unit]
[filter]
id=$unit.id
id=$this_item.id
[/filter]
amount=$frostbite_amount
animate=no
@ -801,7 +799,7 @@
[/if]
[/else]
[/if]
{MODIFY_UNIT (id=$unit.id) status.slowed no}
{MODIFY_UNIT (id=$this_item.id) status.slowed no}
[/do]
[/foreach]
[delay]
@ -1052,16 +1050,18 @@ As you command."
time=300
[/delay]
{FIND_NEARBY (
race=drake
canrecruit=yes
[or]
id=Mortic
[/or]
)
$unit.x $unit.y 99} # probably mortic
[if]
{VARIABLE_CONDITIONAL unit.race equals drake}
[then]
{VARIABLE their_unit_id $unit.id}
[/then]
[else]
{VARIABLE their_unit_id Mortic}
[/else]
[/if] # probably mortic
[message]
speaker=$found_unit.id
speaker=$their_unit_id
#po: speaker is a drake, probably Mortic
message= _ "An unknown creature approaches.
Paler than an Orc.
@ -1073,7 +1073,7 @@ Tell me of your kin."
message= _ "We are men, of Wesnoth! We come in peace, seeking magic to help in our war against an undead horde."
[/message]
[message]
speaker=$found_unit.id
speaker=$their_unit_id
message= _ "Dra-Nak warned us.
You men of Wes-Noth speak of peace.
Yet you brandish your spears at our flight.
@ -1085,10 +1085,12 @@ No further tribute can be paid."
message= _ "No, wait, we just want to-"
[/message]
[message]
speaker=$found_unit.id
speaker=$their_unit_id
message= _ "Our Hunt must continue."
[/message]
{CLEAR_VARIABLE their_unit_id}
[modify_side]
side=2
gold={ON_DIFFICULTY 10 30 50}
@ -1097,7 +1099,6 @@ No further tribute can be paid."
side=3
gold={ON_DIFFICULTY 10 30 50}
[/modify_side]
{CAPTURE_VILLAGES 3 32 13 0} # cap the village near Mortic, so he doesn't waste his first turn taking it
{CLEAR_VARIABLE drakes_no_income}
{SCROLL_TO 12 6}
@ -1220,20 +1221,29 @@ I shall not fall here."
{VARIABLE_CONDITIONAL ogres_peaceful not_equals yes}
[/filter_condition]
{FIND_NEARBY side=5 $unit.x $unit.y 99}
[if]
{VARIABLE_CONDITIONAL unit.side equals 1}
[then]
{VARIABLE our_unit_id $unit.id}
{VARIABLE their_unit_id $second_unit.id}
[/then]
[else]
{VARIABLE their_unit_id $unit.id}
{VARIABLE our_unit_id $second_unit.id}
[/else]
[/if]
[message]
speaker=$found_unit.id
speaker=$their_unit_id
#po: speaker is a hostile ogre
message= _ "Guuuh... human?"
[/message]
{FIND_NEARBY side=1 $unit.x $unit.y 99}
[message]
speaker=$found_unit.id
speaker=$our_unit_id
message= _ "Err, hello?"
[/message]
{FIND_NEARBY side=5 $unit.x $unit.y 99}
[message]
speaker=$found_unit.id
speaker=$their_unit_id
message= _ "Human! Human human human!"
[/message]
[message]
@ -1241,6 +1251,8 @@ I shall not fall here."
message= _ "They dont look very friendly..."
[/message]
{CLEAR_VARIABLE our_unit_id,their_unit_id}
{VARIABLE ogres_sighted yes}
[/event]
@ -1262,31 +1274,51 @@ I shall not fall here."
[/have_unit]
[/filter_condition]
{FIND_NEARBY side=1 $unit.x $unit.y 99}
[if]
{VARIABLE_CONDITIONAL unit.side equals 1}
[then]
{VARIABLE our_unit_id $unit.id}
{STORE_UNIT_VAR (
side=5
[filter_adjacent]
id=$our_unit_id
[/filter_adjacent]
) id their_unit_id}
[/then]
[else]
{VARIABLE their_unit_id $unit.id}
{STORE_UNIT_VAR (
side=1
[filter_adjacent]
id=$their_unit_id
[/filter_adjacent]
) id our_unit_id}
[/else]
[/if]
[message]
speaker=$found_unit.id
speaker=$our_unit_id
#po: player's ogre (but not Grug, who gets different lines) to hostile ogre
message= _ "Guuuh... who you?"
[/message]
{FIND_NEARBY side=5 $unit.x $unit.y 99}
[message]
image_pos=right
speaker=$found_unit.id
speaker=$their_unit_id
#po: hostile ogre to player's ogre
message= _ "Uhhhh... who <i><b>you</b></i>?"
[/message]
{FIND_NEARBY side=1 $unit.x $unit.y 99}
[message]
speaker=$found_unit.id
speaker=$our_unit_id
message= _ "Me... friend? New friend?"
[/message]
{FIND_NEARBY side=5 $unit.x $unit.y 99}
[message]
image_pos=right
speaker=$found_unit.id
speaker=$their_unit_id
message= _ "New friend! Me no fight friend."
[/message]
{CLEAR_VARIABLE our_unit_id,their_unit_id}
{VARIABLE ogres_peaceful yes}
[modify_side]
side=5
@ -1303,8 +1335,6 @@ I shall not fall here."
name=moveto
[filter_condition] # works for either side's moves, unlike filter
[have_unit]
side=1
race=ogre
id=Grug
[filter_adjacent]
side=5
@ -1312,8 +1342,12 @@ I shall not fall here."
[/have_unit]
[/filter_condition]
{FIND_NEARBY id=Grug 39 29 99}
{FIND_NEARBY side=5 $found_unit.x $found_unit.y 99}
{STORE_UNIT_VAR (
side=5
[filter_adjacent]
id=Grug
[/filter_adjacent]
) id their_unit_id}
{VARIABLE ogres_sighted yes}
[fire_event]
@ -1322,7 +1356,7 @@ I shall not fall here."
[message]
image_pos=right
x,y=$found_unit.x,$found_unit.y
speaker=$their_unit_id
#po: hostile ogre to Grug
message= _ "Guuuh... who you?"
[/message]
@ -1332,7 +1366,7 @@ I shall not fall here."
[/message]
[message]
image_pos=right
x,y=$found_unit.x,$found_unit.y
speaker=$their_unit_id
message= _ "Uhhhh... friend... human?"
[/message]
[message]
@ -1341,10 +1375,12 @@ I shall not fall here."
[/message]
[message]
image_pos=right
x,y=$unit.x,$unit.y
speaker=$their_unit_id
message= _ "OK, me help human fight! Human good!"
[/message]
{CLEAR_VARIABLE their_unit_id}
{CLEAR_VARIABLE grug_event_active}
{VARIABLE ogres_peaceful yes}
[set_achievement]
@ -1403,7 +1439,8 @@ I shall not fall here."
side=1
amount=$gold
[/gold]
{REMOVE_IMAGE $unit.x $unit.y}
{CLEAR_VARIABLE gold}
{REMOVE_IMAGE $x1 $y1}
[/event]
#---------------------
@ -1434,7 +1471,8 @@ I shall not fall here."
side=1
amount=$gold
[/gold]
{REMOVE_IMAGE $unit.x $unit.y}
{CLEAR_VARIABLE gold}
{REMOVE_IMAGE $x1 $y1}
[/event]
#---------------------
@ -1465,7 +1503,8 @@ I shall not fall here."
side=1
amount=$gold
[/gold]
{REMOVE_IMAGE $unit.x $unit.y}
{CLEAR_VARIABLE gold}
{REMOVE_IMAGE $x1 $y1}
[/event]
#---------------------
@ -1486,7 +1525,7 @@ I shall not fall here."
[filter]
type=Yeti
[/filter]
{PLACE_ITEM_YETIBURGER $unit.x $unit.y}
{PLACE_ITEM_YETIBURGER $x1 $y1}
[message]
speaker=Gweddry
message= _ "Ive never tried Yeti meat. I wonder what it tastes like?"
@ -1494,8 +1533,7 @@ I shall not fall here."
[/event]
[event]
name=victory
{CLEAR_VARIABLE frostbite_animate,frostbite_amount,frostbite_units,frostbite_ogres,unit}
{CLEAR_VARIABLE elixir_drinker}
{CLEAR_VARIABLE frostbite_amount,frostbite_units,frostbite_ogres,ogres_sighted,ogres_peaceful,grug_event_active,drakes_no_income}
[/event]
#---------------------
@ -1516,9 +1554,6 @@ I shall not fall here."
message= _ "This is the place! Let us enter."
[/message]
{CLEAR_VARIABLE ogres_sighted}
{CLEAR_VARIABLE ogres_peaceful}
{CLEAR_VARIABLE grug_event_active}
[endlevel]
result=victory
bonus=no

View File

@ -1197,8 +1197,6 @@ plague_staff #enddef
text= _ "<span color='#E8B923' size='x-small'>elemental resist</span>"
[/floating_text]
{STORE_UNIT_VAR x,y={X},{Y} id elixir_drinker} # used for frostbite immunity
[modify_unit]
[filter]
side=1