Skip to content

Commit

Permalink
SotA: Fix and improve freeze/thaw unit implementation
Browse files Browse the repository at this point in the history
Bug was that when a unit was thawed, mouse over in unit sidebar would show
incorrect movement costs (all 1's).

New implementation properly uses {UNREACHABLE} and makes use of the now
available [remove_object] tag.
  • Loading branch information
sigurdfdragon committed Nov 22, 2017
1 parent ca03818 commit 64d3aa1
Showing 1 changed file with 21 additions and 53 deletions.
74 changes: 21 additions & 53 deletions data/campaigns/Secrets_of_the_Ancients/utils/sota-utils.cfg
Expand Up @@ -552,73 +552,41 @@

#define FREEZE_UNIT ID
[object]
id=freeze_unit
take_only_once=no
silent=yes
duration=scenario # So this object will not be in the save files forever.
[filter]
id={ID}
[/filter]
[effect]
apply_to=movement_costs
replace=no # So this amount is added to the current number.
replace=yes
[movement_costs]
shallow_water=100
reef=100
swamp_water=100
flat=100
sand=100
forest=100
hills=100
mountains=100
village=100
castle=100
cave=100
frozen=100
unwalkable=100
fungus=100
shallow_water={UNREACHABLE}
reef={UNREACHABLE}
swamp_water={UNREACHABLE}
flat={UNREACHABLE}
sand={UNREACHABLE}
forest={UNREACHABLE}
hills={UNREACHABLE}
mountains={UNREACHABLE}
village={UNREACHABLE}
castle={UNREACHABLE}
cave={UNREACHABLE}
frozen={UNREACHABLE}
unwalkable={UNREACHABLE}
fungus={UNREACHABLE}
[/movement_costs]
[/effect]
[/object]
#enddef

#define THAW_UNIT ID
[store_unit]
[filter]
id={ID}
# This prevents a unit from being thawed that was not frozen first:
movement_cost=100-120
[/filter]
variable=stored_unit
[/store_unit]
[object]
silent=yes
duration=scenario
[filter]
id={ID}
[/filter]
[effect]
apply_to=movement_costs
replace=no # This amount is added to the current number.
[movement_costs]
shallow_water=-100
reef=-100
swamp_water=-100
flat=-100
sand=-100
forest=-100
hills=-100
mountains=-100
village=-100
castle=-100
cave=-100
frozen=-100
unwalkable=-100
fungus=-100
[/movement_costs]
[/effect]
[/object]
[clear_variable]
name=stored_unit
[/clear_variable]
[remove_object]
id={ID}
object_id=freeze_unit
[/remove_object]
#enddef

# Finds the nearest hex to (X,Y) within MAX_DISTANCE that matches the FILTER, and stores
Expand Down

7 comments on commit 64d3aa1

@gfgtdf
Copy link
Contributor

@gfgtdf gfgtdf commented on 64d3aa1 Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test that this work? Iirc id in ojject has a specaial meaning that an on ect with a fixed i id can only be given once per scenario.

@sigurdfdragon
Copy link
Contributor Author

@sigurdfdragon sigurdfdragon commented on 64d3aa1 Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
that's what:
take_only_once=no
is for, so it can be given more than once

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? Where did object_id come from?

@sigurdfdragon
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're asking here.

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object_id in [remove_object].

@sigurdfdragon
Copy link
Contributor Author

@sigurdfdragon sigurdfdragon commented on 64d3aa1 Dec 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same as the [object] id in the FREEZE_UNIT macro above.

https://wiki.wesnoth.org/DirectActionsWML#.5Bobject.5D & [remove_object] below it.
object_id in [remove_object] is equal to the id used in [object]. I would imagine it is object_id and not id in [remove_object] to avoid clashing with SUF's

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... I guess I was confused because the underlying Lua function for [remove_object] actually takes the equivalent of a [filter_wml] tag to apply to each object and determine a match, but I guess the WML tag doesn't expose that.

Please sign in to comment.