how to change a side of an attacked unit

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

Re: how to change a side of an attacked unit

Post by Aldarisvet » May 28th, 2018, 6:58 pm

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 Zombies:Introduction single map campaign
Art thread:Mostly frankenstains

Choicerer
Posts: 215
Joined: April 29th, 2017, 11:37 pm

Re: how to change a side of an attacked unit

Post by Choicerer » May 28th, 2018, 7:02 pm

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
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Aldarisvet
Translator
Posts: 630
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: how to change a side of an attacked unit

Post by Aldarisvet » 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
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see Zombies:Introduction single map campaign
Art thread:Mostly frankenstains

User avatar
James_The_Invisible
Posts: 450
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: how to change a side of an attacked unit

Post by James_The_Invisible » 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.

Choicerer
Posts: 215
Joined: April 29th, 2017, 11:37 pm

Re: how to change a side of an attacked unit

Post by Choicerer » May 28th, 2018, 7:30 pm

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.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

Post Reply