Death event that has a second_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.
Post Reply
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Death event that has a second_unit

Post by The_Gnat »

Basically i want to do some things to the unit that kills another unit.

For example:

Code: Select all

[event]
   name=last breath

   [filter]
       id=Master
   [/filter]

   [modify_unit]
         [filter]
              id=$second_unit.id
        [/filter]
        // ... some stuff
   [/modify_unit]

[/event]
When a Master dies then the unit that kills him is modified. However, this does not work because apparently last breath does not have a second unit stored. Is there another event i can use instead?

Thank you! :D
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: Death event that has a second_unit

Post by Bitron »

you could try name=die instead. It will fire after the killed unit actually died. Not sure if it stores a second unit though.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Death event that has a second_unit

Post by The_Gnat »

I will give it a try! :D
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Death event that has a second_unit

Post by The_Gnat »

Unfortunately that does not seem to have a second_unit either. :hmm:
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: Death event that has a second_unit

Post by Bitron »

have you tried using [filter_second]?

EDIT:
have you tried using [filter_second]?
Not sure but it might be that you are asking if the first unit ([filter]) has the id of the second unit ($second_unit.id). I never really understood the depth of those filters..

EDIT2: Oh, I guess not. It's the filter of the [modify_unit]
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: Death event that has a second_unit

Post by Bitron »

Code: Select all

    [event]
    	name=die
    	[filter]
    	[/filter]
    	
    	[message]
    		speaker=unit
    		message= _ "I die!"
    	[/message]
    	
    	[message]
    		speaker=second_unit
    		message= _ "I killed you!"
    	[/message]
    [/event]
This little masterpiece of code works totally fine in 1.13.8, using the second unit as speaker. It should be there.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Death event that has a second_unit

Post by The_Gnat »

Hmm... when i tried something similar to that it did not work. I must have made an error. :P I will attempt it again, Thank you!

EDIT: Thank you i was able to make it work! :D
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: Death event that has a second_unit

Post by Bitron »

Good to hear you made it. What was the problem?
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Death event that has a second_unit

Post by The_Gnat »

:D my problem was in the die event i was using the second_unit as a variable but i was using it incorrectly (because $second_unit doesn't actually mean anything as a variable it just represents a unit). I solved it by using $second_unit.side which worked.

Thank you again for telling me about the die event! :D
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Death event that has a second_unit

Post by WhiteWolf »

As far as I know, last breath works the same way, it also stores the second unit in every case. The only difference between last breath and die is that last breath happens just before the death animation, and die happens right after it, so that the $unit is no longer on the map, but is still stored, and can be saved. [message]speaker=unit is fine in a last breath event, but it looks funny in a die event.

What I do instead of trying to read the $second_unit, is filter for the unit standing on x,y=$x2,$y2. This always works :) (Unless you move units in your event, and the second unit moves away from this hex.)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Death event that has a second_unit

Post by The_Gnat »

Thank you whitewolf, yes probably the last breath event is better for my situation, and since i have figured out my problem (the incorrect use of $second_unit) it should work! :D
Post Reply