how to change a side of an attacked unit

The place to post your WML questions and answers.

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.
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: how to change a side of an attacked unit

Post by Aldarisvet »

Choicerer wrote: May 28th, 2018, 6:48 pm What event are you calling this from? The unit variable is used in unit-related events, not action tags like this one.
Thank you! Got it.
The event was start )))
To animate the process of taking the plague staff I just manually move unit to the tile with the image where the plague staff is positioned, then transform the unit and then remove the image of the plague staff.
Now I will create move_to event.
But how I will manage these events, hmm. Event inside event?
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: how to change a side of an attacked unit

Post by Choicerer »

How I should specify in [variable] the id of the unit I am adressing?
Once again, you can't do that. The unit variable is a variable that gets automatically created once WML is inside a unit-related event. Then, this variable corresponds to the primary unit for that event... unit2 corresponds to the secondary unit.
If you want to do it from outside such an event, you first must store the unit in question.
OR - This solution does away with the unit variable and is convienent:

Code: Select all

[if]
	[have_unit]
		id=velendar3
		level=3
	[/have_unit]
	[then]
	#transform it
	[/then]
	[else]
	#transform to something else
	[/else]
[/if]
More info on the "unit" variables:
https://wiki.wesnoth.org/Eventwml#Prede ... th_Filters
Store unit:
https://wiki.wesnoth.org/InternalAction ... re_unit.5D
Have unit:
https://wiki.wesnoth.org/ConditionalAct ... ition_Tags

EDIT:
But how I will manage these events, hmm. Event inside event?
Not sure what you mean. You cannot put an [event] tag inside another one. They all must be defined separately, inside a scenario tag or a modification tag.
If you want to call an event from inside another one, do
https://wiki.wesnoth.org/InternalAction ... e_event.5D
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: how to change a side of an attacked unit

Post by Aldarisvet »

Choicerer wrote: May 28th, 2018, 7:02 pm OR - This solution does away with the unit variable and is convienent:
...
[have_unit]
Thank you much, [have_unit] is a simple decision that worked out!
Here are some screens, just to show your help results!
1.png
2.png
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: how to change a side of an attacked unit

Post by James_The_Invisible »

Choicerer wrote: May 28th, 2018, 7:02 pm You cannot put an [event] tag inside another one.
That is not true. See EventWML#Nested_Event_Example.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: how to change a side of an attacked unit

Post by Choicerer »

Aldarisvet wrote: May 28th, 2018, 7:27 pm
Choicerer wrote: May 28th, 2018, 7:02 pm OR - This solution does away with the unit variable and is convienent:
...
[have_unit]
Thank you much, [have_unit] is a simple decision that worked out!
Here are some screens, just to show your help results!
1.png
2.png
Great, I'm glad it worked!
James_The_Invisible wrote: May 28th, 2018, 7:28 pm
Choicerer wrote: May 28th, 2018, 7:02 pm You cannot put an [event] tag inside another one.
That is not true. See EventWML#Nested_Event_Example.
True, I wasn't aware of that.
Post Reply