Checking WML for non-dying breath

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
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Checking WML for non-dying breath

Post by Simons Mith »

I have a buncha work to do before Fate of a Princess is playable again, and my WML is very rusty.
I wanted to check whether the following code is reasonable:

Quite simply, I'm bored with leaders only talking when they die - so this fellow is supposed to say
'you can't kill me' the first time his hit points are dropped below 25 by an incoming attack.

Have I got it right?

Thanks

Code: Select all

[set_variable]
  name=troll_warrior_harmed
  value=no
[/set_variable]

...

[event]
    name=attack end
    first_time_only=no
    [filter_second]
        id=Troll Warrior
        [variable]
          name=$second_unit.hitpoints
          less_than=25
        [/variable]
        [variable]
          name=troll_warrior_harmed
          equals=no
        [/variable]
    [/filter_second]
    [message]
        speaker=Troll Warrior
        message= _ "Puny damage not kill me!"
    [/message]
    [set_variable]
        name=troll_warrior_harmed
        equals=yes
    [/set_variable]
[/event]
 
User avatar
Pentarctagon
Project Manager
Posts: 5496
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Checking WML for non-dying breath

Post by Pentarctagon »

name=$second_unit.hitpoints shouldn't have a dollar sign.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Checking WML for non-dying breath

Post by Ravana »

Some conditions in [filter_second] need to be in [filter_condition] instead. Also, if troll_warrior_harmed is only about the message, you can just use first_time_only=yes.
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Checking WML for non-dying breath

Post by Simons Mith »

Thank you very much. I'll apply the fixes and report back later. Might be a while though :-)
 
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Checking WML for non-dying breath

Post by Celtic_Minstrel »

Ravana wrote: July 23rd, 2021, 12:54 pm Also, if troll_warrior_harmed is only about the message, you can just use first_time_only=yes.
That's possibly not true. If it's a single scenario, you'd be right, but if the intent is for the message to appear once in the entire campaign, you'll definitely need a variable.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Checking WML for non-dying breath

Post by Ravana »

Possible, but this message sounds like it is intended for specific fight and therefore would be scenario event.
Post Reply