Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 1980

WML Workshop • v1.18 have_unit and die event

$
0
0
Hi,
I'm a bit baffled and am posting this to ensure I'm not missing something obvious and/or doing something stupid.

I have a test condition that works in [show_if] but not inside a [filter_condition] of a die event.

First off the working and not-working code:

This works fine:

Code:

      [objective]        description= _ "Victory!"        condition=win        [show_if]          {S15_VICTORY_TEST}        [/show_if]      [/objective]
But this doesn't (DEBUG_MSG never displays):

Code:

  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition]      {S15_VICTORY_TEST}    [/filter_condition]{DEBUG_MSG (_"In last wose die event, about to fire victory event")}    {S15_VICTORY}  [/event]
The scenario setup is rather complicated; there are 7 sides, several of which have the goto micro ai applied to some/all units.
Side 1 is player controlled and has defeat_condition=never.
Further, side 3 starts off as ai and then becomes player controlled later.
Finally, it's a b*gg*r to debug because I have to play the scenario through to the bitter end every time, there's no (easy) way to shortcut a full playthrough because of the way the scenario works.

Playing the scenario to the bitter end results in only side 3 units on the map (hence side 1 defeat condition) and when the final side 1 unit dies the player can win or lose.
If the dying unit is a leader, logic elsewhere causes the player to lose.
However otherwise the player loses that unit but wins the scenario.

Here's the macro definitions:

Code:

# Defined here to ease legibility#define S15_VICTORY_TEST_HAAG  [have_unit]    id=Haag    [filter_location]      terrain=*^Yah    [/filter_location]  [/have_unit]  [or]  [have_unit]    id=Haag    x,y=15,21  [/have_unit]  {VARIABLE_CONDITIONAL turn_number greater_than 15}  [/or]#enddef##define S15_VICTORY_TEST[have_unit]  side=1,2  count=0[/have_unit][and]  {S15_VICTORY_TEST_HAAG}[/and]#enddef#define S15_VICTORY[fire_event]  name=15_victory[/fire_event]#enddef
As well as the die event I added several others to narrow down where the issue is (one added recently and not yet tested, others have the result added as a comment). I played very specifically so that these only fired at the approriate time (i.e. when only 1 side 1 unit on map). Code below:

Code:

# When last non-leader wose dies test for victory## Debug tests  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]{DEBUG_MSG (_"Last wose non-leader dies, no filter_condition")}# FIRES OK  [/event]## Debug tests  [event]    name=die    [filter]      side=1,2      canrecruit=no    [/filter]{DEBUG_MSG (_"Last non-leader side 1 or 2 dies, no filter_condition")}# FIRES OK  [/event]#  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition][have_unit]  side=2  count=0[/have_unit]    [/filter_condition]{DEBUG_MSG (_"Last wose non-leader dies and filter_condition = no side *2* units")}# ??? UNTESTED ???ADDED SINCE LAST TEST RUN  [/event]#  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition][have_unit]  side=1  count=0[/have_unit]    [/filter_condition]{DEBUG_MSG (_"Last wose non-leader dies and filter_condition = no side 1 units")}# FAIL  [/event]#  [event]    name=die    [filter]      side=1,2      canrecruit=no    [/filter]    [filter_condition][have_unit]  side=1,2  count=0[/have_unit]    [/filter_condition]{DEBUG_MSG (_"Last wose non-leader dies and filter_condition = no side 1 or 2 units")}# FAIL  [/event]#  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition]  [have_unit]    id=Haag    [filter_location]      terrain=*^Yah    [/filter_location]  [/have_unit]  [or]  [have_unit]    id=Haag    x,y=15,21  [/have_unit]  {VARIABLE_CONDITIONAL turn_number greater_than 15}  [/or]    [/filter_condition]{DEBUG_MSG (_"Last wose non-leader dies and filter_condition = Haag safe")}# FIRES OK  [/event]#  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition][have_unit]  side=1,2  count=0[/have_unit]  [and]  [have_unit]    id=Haag    [filter_location]      terrain=*^Yah    [/filter_location]  [/have_unit]  [or]  [have_unit]    id=Haag    x,y=15,21  [/have_unit]  {VARIABLE_CONDITIONAL turn_number greater_than 15}  [/or]  [/and]    [/filter_condition]{DEBUG_MSG (_"Last wose non-leader dies and filter_condition = victory test in ""longhand""")}# FAIL  [/event]#  [event]    name=die    [filter]      side=1      canrecruit=no    [/filter]    [filter_condition]      {S15_VICTORY_TEST}    [/filter_condition]{DEBUG_MSG (_"In last wose die event, about to fire victory event")}    {S15_VICTORY}  [/event]
As you can hopefully see, the issue seems to be within the [have_unit] segment.

There are various inelegant work-arounds but I'd rather get this logic working.
The next thing to try is to remove the [filter_condition] and add first_time_only=no plus an [if] test.
Also maybe replace:

Code:

[have_unit]  side=1,2  count=0[/have_unit]
with:

Code:

[not]  [have_unit]    side=1,2  [/have_unit][/not]
So my question (finally!) is: are there any known issues, bugs or gotchas with [have_unit] that anyone knows about?
Otherwise I'll have to spend hours and hours replaying with slightly different tests each time. :augh:

One little wrinkle is that around the time of tthis issue there is a log error:
Tile at 35,1 isn't on the map, can't scroll to the tile.
I've commented those lines out but haven't had chance to test it yet... and my little brain's starting to hurt...

So I'm really hoping someone can either see what stupid mistake I've made or explain some possibly relevant issue with [have_unit]...

Any help very gratefully received!

Cheers!
-- Spannerbag

Statistics: Posted by Spannerbag — Yesterday, 10:21 pm



Viewing all articles
Browse latest Browse all 1980

Trending Articles