How to handle [object]?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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]?

Postby Xara » January 4th, 2018, 2:04 pm

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.

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]


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.

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]


What should I do?
Remember to sleep early, guys.
User avatar
Xara
 
Posts: 212
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: How to handle [object]?

Postby Ravana » January 4th, 2018, 3:16 pm

1.12 might not have better solution than rebuilding unit https://wiki.wesnoth.org/Removing_Items.
User avatar
Ravana
Moderator
 
Posts: 1501
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: How to handle [object]?

Postby Xara » January 4th, 2018, 3:30 pm

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.
Remember to sleep early, guys.
User avatar
Xara
 
Posts: 212
Joined: December 26th, 2014, 12:23 am
Location: Beijing


Return to WML Workshop

Who is online

Users browsing this forum: No registered users and 2 guests