gold adding event help... PLEASE!!!

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.
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

gold adding event help... PLEASE!!!

Post by zengetsu88 »

Hey everybody! I need help with an event that I am placing into my eras file.
This event loads when the game starts and It is supposed to continually check if the is a certain unit on the battlefield (called: Trigon of Wealth)
If this unit is on the field then it is supposed to give its user one gold for every unit on the field at the beginning of the user's turn.

Here is what I got.

Code: Select all

#define TRIGON_WEALTH_THING
[event]
    name=prestart
    
    [if]
        [have_unit]
            [filter]
                side=$side_number
                type=Trigon of Wealth
            [/filter]
        [/have_unit]
    [then]
        [event]
            name=side turn
            first_time_only=no

            [store_unit]
                [filter]
                    side=$side_number
                [/filter]
                variable=units
            [/store_unit]
            
            [store_gold]
                side=$side_number
                variable=gold
            [/store_gold]

            {FOREACH units i}
                {VARIABLE_OP gold add 1}
            {NEXT i}
            
            [unstore_gold]
                variable=gold
                find_vacant=no
            [/unstore_gold]
            
            {CLEAR_VARIABLE units}
            {CLEAR_VARIABLE gold}
        [/event]
    [/then]
    [/if]
    {CLEAR_VARIABLE my_side}
[/event]
#enddef
I'm not sure what im doing wrong. I hate the stupid side thing and I always have trouble with that so i assume my side declaration is part of the reason.

Lastly this is for multiplayer, not campaign or a scenario.
my logic is sound
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: gold adding event help... PLEASE!!!

Post by Ceres »

a) no [filter] in [have_unit].
b) you don't need to unstore gold. [unstore_gold] doesn't exist.
c) I'm not sure if side_number is already defined in a prestart event, and if, it won't be anything but 1.
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: gold adding event help... PLEASE!!!

Post by Reepurr »

zengetsu88 wrote:This event loads when the game starts and It is supposed to continually check if the is a certain unit on the battlefield (called: Trigon of Wealth)
In that case, you don't want prestart, you want side turn. That makes it happen each side turn (when each player has a go, in other words).

As Ceres said, [have_unit] has no filter. If it makes it easier for you to remember, think of [have_unit] as a filter, but for [if] and [set_menu_item].
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"

Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: gold adding event help... PLEASE!!!

Post by zengetsu88 »

Okay I did the fixes ya'll told me to do.
It is still not working.

here's what I got:

Code: Select all

#define TRIGON_WEALTH_THING
[event]
    name=prestart
    
    [if]
        [have_unit]
            side=1
            type=Trigon of Wealth
        [/have_unit]
    [then]
        [event]
            name=side turn
            first_time_only=no

            [store_unit]
                [filter]
                    side=1
                [/filter]
                variable=units
            [/store_unit]

            {FOREACH units i}
                [gold]
                    amount=1
                    side=1
                [/gold]
            {NEXT i}
            
            {CLEAR_VARIABLE units}
        [/event]
    [/then]
    [/if]
[/event]
#enddef

Thanks for the help so far!!!
my logic is sound
User avatar
DEATH_is_undead
Posts: 960
Joined: March 4th, 2007, 3:00 pm
Location: Northern United States

Re: gold adding event help... PLEASE!!!

Post by DEATH_is_undead »

zengetsu88 wrote:Okay I did the fixes ya'll told me to do.
It is still not working.

here's what I got:
#define TRIGON_WEALTH_THING
[event]
name=prestart

[if]
[have_unit]
side=1
type=Trigon of Wealth
[/have_unit]
[then]
[event]
name=side turn
first_time_only=no

[store_unit]
[filter]
side=1
[/filter]
variable=units
[/store_unit]

{FOREACH units i}
[gold]
amount=1
side=1
[/gold]
{NEXT i}

{CLEAR_VARIABLE units}
[/event]
[/then]
[/if]
[/event]
#enddef



Thanks for the help so far!!!
If I recall correctly, [store_unit] does not need a filter.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: gold adding event help... PLEASE!!!

Post by zookeeper »

DEATH_is_undead wrote:If I recall correctly, [store_unit] does not need a filter.
You don't recall correctly.
User avatar
DEATH_is_undead
Posts: 960
Joined: March 4th, 2007, 3:00 pm
Location: Northern United States

Re: gold adding event help... PLEASE!!!

Post by DEATH_is_undead »

zookeeper wrote:
DEATH_is_undead wrote:If I recall correctly, [store_unit] does not need a filter.
You don't recall correctly.
Heh, then its [kill] I must be thinking of.... Disregard my post, then.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
User avatar
bigkahuna
Posts: 657
Joined: September 11th, 2010, 6:24 pm
Location: In your mind.

Re: gold adding event help... PLEASE!!!

Post by bigkahuna »

Two things:

1. Where are you putting the macro {TRIGON_WEALTH_THING} within the scenario? It needs to be toplevel (inside the [scenario] tag, outside any [event] tags.)

2. If in a prestart event, the game ONLY checks at the FIRST time you start the scenario if you have the "Trigon of Wealth" unit. What you need to do is put it in an event named "side 1 turn" as so:

Code: Select all

#define TRIGON_WEALTH_THING
[event]
    name=side 1 turn   
    first_time_only=no 
    [if]
        [have_unit]
            side=1
            type=Trigon of Wealth
        [/have_unit]
        [then]
            [store_unit]
                [filter]
                    side=1
                [/filter]
                variable=units
            [/store_unit]

            {FOREACH units i}
                [gold]
                    amount=1
                    side=1
                [/gold]
            {NEXT i}
            
            {CLEAR_VARIABLE units}
        [/then]
    [/if]
[/event]
#enddef
Check out my campaign Sweet Revenge!
Join the new R2D forum!
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: gold adding event help... PLEASE!!!

Post by Reepurr »

...What? side 1 turn?

Code: Select all

[event]
    name=side turn
    first_time_only=no
would work just as well for all players, not just player 1.
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"

Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
User avatar
bigkahuna
Posts: 657
Joined: September 11th, 2010, 6:24 pm
Location: In your mind.

Re: gold adding event help... PLEASE!!!

Post by bigkahuna »

Right, but he is trying to do specifically side 1. If he does a normal side turn, he'd have to do yet another variable check to see if $side_number equalled 1.
Check out my campaign Sweet Revenge!
Join the new R2D forum!
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: gold adding event help... PLEASE!!!

Post by Reepurr »

zengetsu88 wrote:If this unit is on the field then it is supposed to give its user one gold
Its user, not side 1. The [gold] was only given and changed to side 1 when ceres said that on a prestart event, it'll only be 1.

Originally, it was supposed to happen each turn, for each side. A bit like the way an Elvish Shaman's healing is triggered.
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"

Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: gold adding event help... PLEASE!!!

Post by zengetsu88 »

Reepurr wrote:
zengetsu88 wrote:If this unit is on the field then it is supposed to give its user one gold
Its user, not side 1. The [gold] was only given and changed to side 1 when ceres said that on a prestart event, it'll only be 1.

Originally, it was supposed to happen each turn, for each side. A bit like the way an Elvish Shaman's healing is triggered.
Thank you, yes that is what I'm going for. And its not for a scenario but for multiplayer era. But it makes sense that I need to do the check inside the "side turn" event and remove the prestart.

I will do some fixes and get back to ya'll.

Thanks for the input so far!!!
my logic is sound
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: gold adding event help... PLEASE!!!

Post by zengetsu88 »

Alright here is what I got.

Code: Select all

#define TRIGON_WEALTH_THING
[event]
    name=side turn   
    first_time_only=no

    [store_side]
        side=$side_number
        variable=self
    [/store_side]

    [if]
        [have_unit]
            side=self
            type=Trigon of Wealth
        [/have_unit]

        [then]
            [store_unit]
                [filter]
                    side=self
                [/filter]
                variable=units
            [/store_unit]

            {FOREACH units i}
                [gold]
                    amount=1
                    side=self
                [/gold]
            {NEXT i}
           
            {CLEAR_VARIABLE units}
        [/then]
        {CLEAR_VARIABLE self}
    [/if]
[/event]
#enddef
It is still not working. I know that the problem is coming from the "side=" stuff. I hate side declaration, because I can never get it to work. I want this to be used on whichever side is currently playing. But it is purely not working.

Thanks everbody for the input so far.
my logic is sound
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: gold adding event help... PLEASE!!!

Post by Ceres »

Why don't you just go with side=$side_number for the [have_unit] and the [gold] also?
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: gold adding event help... PLEASE!!!

Post by Reepurr »

It's $self.side anyway, since $self is a container variable.
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"

Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
Post Reply