Event "when leader dies"
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.
Event "when leader dies"
I have 4 vs 4 CPU scenario and want to add the following rule to it: If one of the CPU leaders die, the other 3 leaders get 100 gold. How can I write such an event?
Wesnoth
The developer says "no".
The developer says "no".
Re: Event "when leader dies"
I think this is what you want. (I might have made a mistake in the code, it's been a while )
Replace the id in the 'die' event with the leader's id, and replace the sides with the sides that are to recieve gold.
Code: Select all
[event]
name=die
[filter]
id=BadGuy
[/filter]
[gold]
amount=100
side=Badguyside2, Badguyside3, Badguyside4
[/gold]
[/event]
Sorta on a break from the forums ATM, have been for a while. If I was doing something for/with you and I haven't recently, that's why, I will be back soon hopefully.
Re: Event "when leader dies"
So the four leaders are on the same team? As in they have the same team_name= in their [side] definitions? That would be one way to identify them in a [filter] tag. Here's a translation of your rule into WML:
You could instead do a filter on each leader's ID, but then you would need to list all four IDs. The fewer details you encode into your event, the more robust the event is as changes are made to the scenario.
Code: Select all
[event]
# "If [someone] die"
name = die
# "one of the CPU leaders"
[filter]
canrecruit = yes # This matches leaders
[filter_side]
team_name = CPU # This matches the same field in a [side] definition.
[/filter_side]
[/filter]
# "get 100 gold"
[gold]
amount = 100
# "the other 3 leaders" (which I am taking to mean the allies of the killed unit)
[filter_side] # This tag (but not its contents) goes away in 1.12.
[allied_with]
side = $unit.side # This means the side of the unit that died.
[/allied_with]
[not]
side = $unit.side # This means the side of the unit that died.
[/not]
[/filter_side]
[/gold]
[/event]
Last edited by JaMiT on January 15th, 2013, 7:31 pm, edited 1 time in total.
Reason: WML corrections
Reason: WML corrections
Re: Event "when leader dies"
I'd go with JaMiT's code if I were you, mine's kinda crude...
Sorta on a break from the forums ATM, have been for a while. If I was doing something for/with you and I haven't recently, that's why, I will be back soon hopefully.
Re: Event "when leader dies"
Oh yeah that solution seems really nice.
How would I know the leader unit ID anyway? Shouldn't I rather filter for side then?
By the way, the closing filter tag should be [/filter] I think.
Edit: Hmm doesn't work it gives the following error:
That's strange...
How would I know the leader unit ID anyway? Shouldn't I rather filter for side then?
By the way, the closing filter tag should be [/filter] I think.
Edit: Hmm doesn't work it gives the following error:
Code: Select all
empty_side= and no [filter_side] is deprecated, use either side=1 or [filter_side]
Wesnoth
The developer says "no".
The developer says "no".
Re: Event "when leader dies"
Sometimes leader IDs are assigned in the scenario.Rya wrote:How would I know the leader unit ID anyway?
Right. Fixed it.Rya wrote:By the way, the closing filter tag should be [/filter] I think.
Oh sorry. I was using the 1.11/1.12 syntax. In 1.10, you still need a [filter_side] tag (which I've edited into my earlier post).Rya wrote:Edit: Hmm doesn't work it gives the following error:That's strange...Code: Select all
empty_side= and no [filter_side] is deprecated, use either side=1 or [filter_side]