Defeated Unit Swaps Sides?
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.
- VampiricRose
- Posts: 16
- Joined: May 5th, 2009, 9:11 am
- Location: Hell
Defeated Unit Swaps Sides?
Is it possible to have a unit that has just been defeated switch sides without killing it?
I'm at a loss.

I'm at a loss.



You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
- mnewton1
- Posts: 777
- Joined: November 12th, 2008, 4:31 am
- Location: On my pretty teal horsey.
- Contact:
Re: Defeated Unit Swaps Sides?
Here is an actual working example:
This is what you want?
Code: Select all
#define ABILITY_INFECT
[dummy]
id=infect
name= _ "infect"
description=_ "Infect:
This unit can latch onto enemies and take control of them."
[/dummy]
[/abilities]
[event]
name=attacker_hits
[filter]
ability=infect
[/filter]
[store_unit]
[filter]
x,y=$x2,$y2
[/filter]
variable=unit_temp
text= _ "INFECTED!"
red=255
[/store_unit]
[set_variable]
name=unit_temp.side
value=$unit.side
[/set_variable]
[unstore_unit]
variable=unit_temp
[/unstore_unit]
[kill]
x,y=$x1,$y1
fire_event=yes
[/kill]
[clear_variable]
name=unit_temp
[/clear_variable]
[/event]
[+abilities]
#enddef
Creator of Ageless Era
Check out Frogatto & Friends, it's made by the same people who created The Battle for Wesnoth!
Check out Frogatto & Friends, it's made by the same people who created The Battle for Wesnoth!
- Aethaeryn
- Translator
- Posts: 1554
- Joined: September 15th, 2007, 10:21 pm
- Location: Baltimore, Maryland, USA
Re: Defeated Unit Swaps Sides?
Isn't that needlessly complicated? The macro list uses a side change as an example.
Also, I think the original poster asked for it to happen when a unit is defeated (i.e. dies), not when an attack hits.
Also, I think the original poster asked for it to happen when a unit is defeated (i.e. dies), not when an attack hits.
Aethaeryn (User Page)
Wiki Moderator (wiki)
Latin Translator [wiki=Latin Translation](wiki)[/wiki]
Maintainer of Thunderstone Era (wiki) and Aethaeryn's Maps [wiki=Aethaeryn's Maps](wiki)[/wiki]
Wiki Moderator (wiki)
Latin Translator [wiki=Latin Translation](wiki)[/wiki]
Maintainer of Thunderstone Era (wiki) and Aethaeryn's Maps [wiki=Aethaeryn's Maps](wiki)[/wiki]
Re: Defeated Unit Swaps Sides?
Yeah, it works exactly once, kills the attacker and doesn't even show the floating text.mnewton1 wrote:Here is an actual working example:
Re: Defeated Unit Swaps Sides?
text= should be inside [unstore_unit]. reading the description i guess it's intended that the attacker is killed and it's a first_time_only=yes event...
Re: Defeated Unit Swaps Sides?
You mean something like this? (untested, but should work if memory serves me.)VampiricRose wrote:Is it possible to have a unit that has just been defeated switch sides without killing it?
Code: Select all
[event]
name=die
#insert filters here
{VARIABLE unit.side $second_unit.side} #or whatever side you want to switch to.
{VARIABLE unit.hitpoints 1} #or however many hitpoints you want it to have
[unstore_unit]
variable=unit
[/unstore_unit]
[/event]
- VampiricRose
- Posts: 16
- Joined: May 5th, 2009, 9:11 am
- Location: Hell
Re: Defeated Unit Swaps Sides?
Thanks everyone! I get it now. 

You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.