counting zombies
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.
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
counting zombies
This counts number of zombifications, it works most of the time (adds 1 to $zombie_number per kill) but occassionally it flips out and loops couple of times thus adding more than 1 per kill. Occassionally it even fires when the attack special isn't plague... Can't quite put my finger on why, and how to fix.
Code: Select all
# if turned zombie, +1.
[event]
name=attacker hits
first_time_only=no
[filter]
side=1
[/filter]
[filter_attack]
special=plague
[/filter_attack]
[filter_second]
[or]
side=2
side=3
side=4
[/or]
[/filter_second]
# [message]
# id=Valia
# message= _ "$zombie_number"
# [/message]
[event]
name=die
first_time_only=yes
[filter]
[not]
side=1
[/not]
[/filter]
[set_variable]
name=zombie_number
add=1
[/set_variable]
[message]
id=Valia
message= _ "We have zombified $zombie_number humans."
[/message]
[/event]
[/event]
Last edited by battlestar on June 22nd, 2011, 3:54 am, edited 1 time in total.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: counting zombies
Well, the first event (
However, imagine the following situation: You need two hits to kill your opponent - then two of the latter events are registered and triggered on that unit's death. This even works, if you hit one unit, don't kill it and then kill another one.
I don't think it's necessary to use nested events here, you should also be fine with only the
Crend
attacker hits
) is fired each time when a unit of side 1 is hitting another unit (I don't know if the filters are correct, they're looking weird, but I'm not that good in WML. Leaving this for someone else). In this event, you register another event - a die
event which only triggers once.However, imagine the following situation: You need two hits to kill your opponent - then two of the latter events are registered and triggered on that unit's death. This even works, if you hit one unit, don't kill it and then kill another one.
I don't think it's necessary to use nested events here, you should also be fine with only the
die
event (modified, of course).Crend
UMC Story Images — Story images for your campaign!
Re: counting zombies
this is definitely wrong:
Assuming for a moment that side= in Standard Unit Filter doesn't support lists, the first condition should be outside the [or] tag and the others should have their own seperate [or] tags. However, since side= in SUF *does* support lists, you don't need the [or] tag at all.
Code: Select all
[or]
side=2
side=3
side=4
[/or]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: counting zombies
Thanks for your inputs. Portion of the code fixed according to Sapient and the problem persist as Crendgrim pointed out. It added multiple times if several attacks using plague was done.
Using only name=die didn't work, it didn't seem to accept the weapon filter (the wiki also didn't list weapon filter can be used in die event). It needs an if-else I think, either inside the nested event: if another unit was selected -- nothing happens, else -- variable plus 1. Or no nested event: if secondary unit dies -- variable plus 1, else -- nothing.
Anyways, close to figuring it out.
Using only name=die didn't work, it didn't seem to accept the weapon filter (the wiki also didn't list weapon filter can be used in die event). It needs an if-else I think, either inside the nested event: if another unit was selected -- nothing happens, else -- variable plus 1. Or no nested event: if secondary unit dies -- variable plus 1, else -- nothing.
Anyways, close to figuring it out.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: counting zombies
Check the target's HP - it should be zero or less if the unit is dying.
Alternatively, check whether the unit's tile is occupied in the Die event. The unit should be gone by then, so if the tile is occupied, then it's probably due to a plague attack (you can check the unit type for more insurance).
Alternatively, check whether the unit's tile is occupied in the Die event. The unit should be gone by then, so if the tile is occupied, then it's probably due to a plague attack (you can check the unit type for more insurance).
You are a Dark Adept: you dimmerse yourself in the dark arts...potentially with great rewards....
-JW's personality quiz
-JW's personality quiz
Re: counting zombies
No, this shouldn't work; at least not if the Wiki is right. It says that the unit isn't removed until after the die event finishes and that it can still be adressed. So this won't work.Brilliand wrote:Alternatively, check whether the unit's tile is occupied in the Die event. The unit should be gone by then, so if the tile is occupied, then it's probably due to a plague attack (you can check the unit type for more insurance).
Crend
UMC Story Images — Story images for your campaign!
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: counting zombies
If I'm understanding what you want:
Code: Select all
[event]
name=prestart
{VARIABLE zombie_number 0}
[/event]
[event]
name=attack end
first_time_only=no
[filter]
side=1
[/filter]
[filter_attack]
special=plague
[/filter_attack]
[filter_second]
[not]
race=undead
[and]
race=mechanical
[/and]
[/not]
[/filter]
[if]
[variable]
name=second_unit.hitpoints
less_than_equal_to=0
[/variable]
[then]
{VARIABLE_OP zombie_number add 1}
# Messages.. and the like.
[/then]
[/if]
[/event]
# And repeat backwards in the case of a retaliatory plague kill.
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: counting zombies
thanks, that does exactly it.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: counting zombies
Did you repeat it backwards? At this stage, it won't count a kill if the WC kills a unit in retaliation.
Re: counting zombies
Wouldn't [or] be more senseful?monochromatic wrote:Code: Select all
[filter_second] [not] race=undead [and] race=mechanical [/and] [/not] [/filter]
Also, the closing tag should be [/filter_second] (though [/filter] would've created an error, which it apparently didn't, so I guess it's fixed by now).
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: counting zombies
He must have fixed it. Sorry, my bad. And on the [or] things, I'm not sure.Ceres wrote:Wouldn't [or] be more senseful?monochromatic wrote:Code: Select all
[filter_second] [not] race=undead [and] race=mechanical [/and] [/not] [/filter]
Also, the closing tag should be [/filter_second] (though [/filter] would've created an error, which it apparently didn't, so I guess it's fixed by now).
Re: counting zombies
IMO Ceres is right; and if he isn't, it should be changed. You have to read "from inward to outward", so you first see "race=undead [logical and] race=mechanical" which cannot be true anytime, and then you negate this which will cause the event to trigger always.
At least that's how it makes sense to me.
Crend
At least that's how it makes sense to me.
Crend
UMC Story Images — Story images for your campaign!
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: counting zombies
For the purpose of the current SP scn, it doesn't need to consider retaliation, I'll keep it in mind if another map has something similar. The only kink is when the enemy is on a village it doesn't get zombified... but I thought the player should get the bonus for the motion anyway, so letting it slide I guess.
Thanks for the help.
monochromatic's code syntax adjusted:
Thanks for the help.
monochromatic's code syntax adjusted:
Code: Select all
[event]
name=prestart
{VARIABLE zombie_number 0}
[/event]
[event]
name=attack end
first_time_only=no
[filter]
side=1
[/filter]
[filter_attack]
special=plague
[/filter_attack]
[filter_second]
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
[/filter_second]
[if]
[variable]
name=second_unit.hitpoints
less_than_equal_to=0
[/variable]
[then]
{VARIABLE_OP zombie_number add 1}
# Messages.. and the like.
[/then]
[/if]
[/event]
# And repeat backwards in the case of a retaliatory plague kill.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: counting zombies
For villages, this should work (untested):
Code: Select all
# Replace the [filter_second] with
[filter_second]
[not]
[filter_location]
terrain=*^V*
[/filter_location]
[and]
race=undead
[or]
race=mechanical
[/or]
[/and]
[/not]
[/filter_second]
Re: counting zombies
It just occured to me that isntead of:
You could probably use a more general/exhaustive code (I haven,t done this in a while, the exact syntax may be a bit flawed):
Basically, undead/mechanical/whatever races are made unaffected by plague/poison/drain/etc. via giving them the not_living status (aka. making not_living=true, or "yes")
But you could also just filter every non-living as you are doing, it's just a different way of doing it
And by the way I don't know why you wouldn't want to check for zombie creation in retaliation, it souldn't be too difficult to add...
Code: Select all
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
Code: Select all
[not]
[filter_wml]
[status]
not_living="yes"
[/status]
[/filter_wml]
[/not]
But you could also just filter every non-living as you are doing, it's just a different way of doing it
And by the way I don't know why you wouldn't want to check for zombie creation in retaliation, it souldn't be too difficult to add...
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth