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.
Post Reply
User avatar
Xara
Posts: 263
Joined: December 26th, 2014, 12:23 am
Location: Beijing

How to handle [object]?

Post by 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?
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons

User avatar
Ravana
Moderator
Posts: 1749
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: How to handle [object]?

Post by 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
Xara
Posts: 263
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: How to handle [object]?

Post by 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.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons

User avatar
Xara
Posts: 263
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: How to handle [object]?

Post by Xara » January 24th, 2018, 1:56 am

Ravana wrote:1.12 might not have better solution than rebuilding unit https://wiki.wesnoth.org/Removing_Items.
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.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons

Shiki
Developer
Posts: 185
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: How to handle [object]?

Post by Shiki » January 24th, 2018, 2:19 am

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.
Maintainer of Era of Myths.

User avatar
Xara
Posts: 263
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: How to handle [object]?

Post by Xara » January 24th, 2018, 3:28 am

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.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons

Post Reply