Defeated Unit Swaps Sides?

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.
Post Reply
User avatar
VampiricRose
Posts: 16
Joined: May 5th, 2009, 9:11 am
Location: Hell

Defeated Unit Swaps Sides?

Post by VampiricRose »

Is it possible to have a unit that has just been defeated switch sides without killing it?
I'm at a loss. :oops: :oops: :oops:
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.
User avatar
mnewton1
Posts: 777
Joined: November 12th, 2008, 4:31 am
Location: On my pretty teal horsey.
Contact:

Re: Defeated Unit Swaps Sides?

Post by mnewton1 »

Here is an actual working example:

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
This is what you want?
Creator of Ageless Era
Check out Frogatto & Friends, it's made by the same people who created The Battle for Wesnoth!
User avatar
Aethaeryn
Translator
Posts: 1554
Joined: September 15th, 2007, 10:21 pm
Location: Baltimore, Maryland, USA

Re: Defeated Unit Swaps Sides?

Post by Aethaeryn »

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.
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]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Defeated Unit Swaps Sides?

Post by zookeeper »

mnewton1 wrote:Here is an actual working example:
Yeah, it works exactly once, kills the attacker and doesn't even show the floating text.
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Defeated Unit Swaps Sides?

Post by Max »

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...
User avatar
melinath
Posts: 1298
Joined: May 20th, 2009, 7:42 am

Re: Defeated Unit Swaps Sides?

Post by melinath »

VampiricRose wrote:Is it possible to have a unit that has just been defeated switch sides without killing it?
You mean something like this? (untested, but should work if memory serves me.)

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]
User avatar
VampiricRose
Posts: 16
Joined: May 5th, 2009, 9:11 am
Location: Hell

Re: Defeated Unit Swaps Sides?

Post by VampiricRose »

Thanks everyone! I get it now. :D
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.
Post Reply