Event trigger: Why didn't work?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Event trigger: Why didn't work?

Post by Exasperation » June 28th, 2009, 12:38 am

You're misinterpreting what he's doing - he's making a copy of the unit that killed it, and putting that copy onto the hex that the dead unit had occupied. Of course, that unit is also already stored, but it's in second_unit, not unit.

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 28th, 2009, 6:29 pm

Thank you all!
Another problem... Could you help me here?
Messages:
Spoiler:
Full event:
Spoiler:
Those messages simply don't appear. I already tried puting "speaker=(unit's id)", but didn't work.

Aaand:
Spoiler:
When I use those messages wesnoth crashes like when we wrongly use a macro, simply crashes and closes.

User avatar
melinath
Posts: 1298
Joined: May 20th, 2009, 7:42 am

Re: Event trigger: Why didn't work?

Post by melinath » June 28th, 2009, 6:39 pm

the prestart event messages aren't working because when you use [message] with a filter, it checks to see if the unit exists. If the unit doesn't exist, Wesnoth assumes the unit is dead and doesn't display the message. It looks like when the code runs, side 1 doesn't have any units.

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 28th, 2009, 6:55 pm

melinath wrote:the prestart event messages aren't working because when you use [message] with a filter, it checks to see if the unit exists. If the unit doesn't exist, Wesnoth assumes the unit is dead and doesn't display the message. It looks like when the code runs, side 1 doesn't have any units.
No, it's not it. I already tried with other events. Thanks anyway.
Edited:
Let me try again.

Heh. Still doesn't work. I think it's something wrong with the filters.
How could I use a filter to these units:
Spoiler:
?

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Event trigger: Why didn't work?

Post by zookeeper » June 28th, 2009, 7:11 pm

Messages don't do anything in prestart events, because prestart events happen before anything is drawn on screen. Put everything you want to be visible to the player in a start event instead.

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 28th, 2009, 7:20 pm

Here you are:
Spoiler:
Still doesn't work. =D
Edited:
Sorry, I got an obscure error... Now it's fixed... You were right, after putting it on a start event, it worked.

User avatar
melinath
Posts: 1298
Joined: May 20th, 2009, 7:42 am

Re: Event trigger: Why didn't work?

Post by melinath » June 28th, 2009, 7:30 pm

zookeeper wrote:Messages don't do anything in prestart events, because prestart events happen before anything is drawn on screen. Put everything you want to be visible to the player in a start event instead.
The following code works inside a prestart event on my Wesnoth:

Code: Select all

    [message]
        speaker=narrator
        message=_"Whatever."
        image=wesnoth-icon.png
    [/message]
I find it very useful for things like emulating a storyboard. But maybe it only works with speaker=narrator.

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Event trigger: Why didn't work?

Post by zookeeper » June 28th, 2009, 7:49 pm

melinath wrote:
zookeeper wrote:Messages don't do anything in prestart events, because prestart events happen before anything is drawn on screen. Put everything you want to be visible to the player in a start event instead.
The following code works inside a prestart event on my Wesnoth:

Code: Select all

    [message]
        speaker=narrator
        message=_"Whatever."
        image=wesnoth-icon.png
    [/message]
I find it very useful for things like emulating a storyboard. But maybe it only works with speaker=narrator.
Oh. Well, that's news to me. Maybe it was changed at some point.

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 29th, 2009, 7:12 am

Oh, and after fixing that bug, the message at prestart worked.
Everything was black, but the characters talked to each other.

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 29th, 2009, 7:39 pm

Hello!
I've got a crazy "bug", and I can't see where I went wrong...
Yes, I came here to ask for help:

First, the codes:
Event that triggers everything:
Spoiler:
Variables:
morale(inside a prestart event):
Spoiler:
mstatus(inside a "new turn, first_time_only=no" event):
Spoiler:
Variable ops:
Inside a "new turn" event:
Spoiler:
Inside die events:
Spoiler:
Macro definition for {ACTION low}(works fine):
Spoiler:
Macro definition for {ACTION zero}(works fine):
Spoiler:
Translating codes:

At prestart, the morale is defined as -20(mstatus=zero).
At turn 1, before the guys do their turns and after the start events, mstatus is defined as "zero".

There are four ways to change the morale value:
A new turn(morale +1).
Killing an enemy not-zombie unit(morale +1).
Killing an enemy zombie unit(morale +0.1).
Losing an unit(morale -1).

The definitions for mstatus are:

morale<12.9, ->mstatus=high
12.9>morale<6 ->mstatus=normal
6.1>morale<0.1 ->mstatus=low
0>morale ->mstatus=zero

Like morale=-19(-20+1[new turn]), mstatus=zero

At every new turn, and after the mstatus be defined, the event that triggers everything I'm interested will be triggered, using a "macro variable", that, on this case, should be {ACTION zero}.
The problem is this one:
The macro used is {ACTION low}, instead of {ACTION zero}.

Without the first event that triggers everything, no action is triggered, with the first event, the macro used is {ACTION low}, I think the problem might be:
1: On the macros.
2: On the event.
I'm sure that the $mstatus is rightly defined.

Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Event trigger: Why didn't work?

Post by Exasperation » June 29th, 2009, 7:56 pm

When you define a macro, the parameters you pass are substituted into the macro wherever you put {<PARAMETER_NAME>}. Try something along these lines:

Code: Select all

#define MORALE_ACTION MORALE
	[switch]
		variable={MORALE}
		[case]
			value=high
			...stuff to happen with high morale
		[/case]
		[case]
			value=normal
			...stuff to happen with normal morale
		[/case]
		[case]
			value=low
			...stuff to happen with low morale
		[/case]
		[else]
			...stuff to happen with zero morale
		[/else]
	[/switch]
#enddef
And then to use it, {MORALE_ACTION mstatus} (no $).

AssassinT90
Posts: 39
Joined: December 20th, 2007, 9:47 am

Re: Event trigger: Why didn't work?

Post by AssassinT90 » June 30th, 2009, 7:48 am

@Exasperation:
Thank you very much! I never understood well how to use the Conditional Actions(save "if", and "then"), but now you explained everything.

Post Reply