How to handle [object]?
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
How to handle [object]?
So recently I'm trying to make an magic mp mod in v1.12.6. One thing that I wanted to do is to apply a sustained effect, which gives units an modification till the users toggle the spell off. But I found that I can't make it work.
Firstly, I tried to trigger a turn start event with an [object] for which the duration=turn, but it doesn't work. Seems that it's because the same object can't be applied repeatedly. The 2nd time I successfully triggered this event, it doesn't apply the modification to the unit.
Then I tried to trigger an event to delete the objects when user turn off the spell, but it also doesn't work. Even though I checked from inspect that the object was successfully deleted, the effects are still active.
What should I do?
Firstly, I tried to trigger a turn start event with an [object] for which the duration=turn, but it doesn't work. Seems that it's because the same object can't be applied repeatedly. The 2nd time I successfully triggered this event, it doesn't apply the modification to the unit.
Code: Select all
[event]
name="xmm_illuminate_trigger"
first_time_only=no
[object]
[filter]
side=$side_number
canrecruit=yes
[/filter]
duration=turn
silent=yes
xmm_sustain=yes
[effect]
apply_to="new_ability"
[abilities]
{ABILITY_ILLUMINATES}
[/abilities]
[/effect]
[effect]
apply_to="halo"
halo="halo/illuminates-aura.png"
[/effect]
[/object]
[/event]
Code: Select all
[event]
name=xmm_turn_off_sustain_event
first_time_only=no
[store_unit]
[filter]
side=$side_number
[/filter]
variable=xmm_troops
kill=no
[/store_unit]
{FOREACH xmm_troops troop_i}
{FOREACH xmm_troops[$troop_i].modifications.object object_i}
[if]
[variable]
name=xmm_troops[$troop_i].modifications.object[$object_i].xmm_sustain
equals=yes
[/variable]
[then]
{CLEAR_VARIABLE xmm_troops[$troop_i].modifications.object[$object_i]}
[/then]
[/if]
{NEXT object_i}
[unstore_unit]
variable=xmm_troops[$troop_i]
[/unstore_unit]
{NEXT troop_i}
# {CLEAR_VARIABLE xmm_troops}
[/event]
Re: How to handle [object]?
1.12 might not have better solution than rebuilding unit https://wiki.wesnoth.org/Removing_Items.
Re: How to handle [object]?
That looks like a lot of trouble to take.
In second thought, I realized that I don't necessarily have to turn off the effects. So I decided to just change all such spells to a one time modification with a duration=scenario.
In second thought, I realized that I don't necessarily have to turn off the effects. So I decided to just change all such spells to a one time modification with a duration=scenario.
Re: How to handle [object]?
One side effect is that if you update the unit by advancing to the same unit type, it would trigger the custom AMLA that many add-ons use.Ravana wrote:1.12 might not have better solution than rebuilding unit https://wiki.wesnoth.org/Removing_Items.
Re: How to handle [object]?
There exists also TRANSFORM_UNIT macro / tag which changes the unit type without advancing (also doesn't play animations for it)
But, looking at the linked code, it's not clear to me why the advancement to itself is needed for.
But, looking at the linked code, it's not clear to me why the advancement to itself is needed for.
Try out the dark board theme.
Re: How to handle [object]?
It was necessary to advance the unit because in 1.12 deleting the variable in the [unit] would not remove the existing object, so one need to force update.