need help on re-spawn

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
Jinnaraka
Posts: 55
Joined: June 8th, 2010, 9:51 pm

need help on re-spawn

Post by Jinnaraka »

need help on re-spawn the human leader. So when a human leader is dead, he will re-spawn in the next turn.

I have use [store_unit] and [unstore_unit], but it doesn't work. The unstore doesn't work.
Here is the macro I copy and modified from creep war. can someone correct my mistake? thank in advance


#define RESPAWN side
[event]
name=die
first_time_only=no
[filter]
side={side}
canrecruit=yes
[/filter]
[object]
silent=yes
[effect]
apply_to=hitpoints
heal_full=yes
[/effect]
[effect]
apply_to=status
remove=poisoned
[/effect]
[effect]
apply_to=status
remove=slowed
[/effect]
[/object]

[set_variable]
name=dead_{side}
equals=yes
[/set_variable]

[store_unit]
[filter]
side={side}
canrecruit=yes
[/filter]
variable=dead_leader_{side}
kill=yes
[/store_unit]



[print]
text="Hero down, He will be back!!"
size=24
red=255
duration=110
[/print]

[/event]
#enddef

#define REVIVE side x y
[event]

name=side turn
first_time_only=no
[if]
[variable]
name=side_number
equals={side}
[/variable]
[then]

[if]

[variable]
name=dead_{side}
equals=yes
[/variable]

[then]
[unstore_unit]
variable=dead_leader_{side}
x={x}
y={y}
find_vacant=yes
[/unstore_unit]
[set_variable]
name=dead_{side}
value=no
[/set_variable]
[/then]
[/if]

[/then]
[/if]
[/event]
#enddef
Legendary Thief (single player (Intermediated level, 20 scenarios) campaign; author)
Various Multiplayer scenarios modifier
Jinnaraka
Posts: 55
Joined: June 8th, 2010, 9:51 pm

Re: need help on re-spawn

Post by Jinnaraka »

#define REVIVE side x y
[event]

name=side turn
first_time_only=no

[if]

[variable]
name=dead_{side}
equals=yes
[/variable]

[then]
[unstore_unit]
variable=dead_leader_{side}
x={x}
y={y}
find_vacant=yes
[/unstore_unit]
[set_variable]
name=dead_{side}
value=no
[/set_variable]
[/then]
[/if]

[/event]
#enddef


this won't work too
Legendary Thief (single player (Intermediated level, 20 scenarios) campaign; author)
Various Multiplayer scenarios modifier
Jinnaraka
Posts: 55
Joined: June 8th, 2010, 9:51 pm

Re: need help on re-spawn

Post by Jinnaraka »

and changing from

[variable]
name=side_number
equals={side}
[/variable]


to

[variable]
name=$side_number
equals={side}
[/variable]

doesn't work also
Legendary Thief (single player (Intermediated level, 20 scenarios) campaign; author)
Various Multiplayer scenarios modifier
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: need help on re-spawn

Post by Reepurr »

Whoa. What's with the triple post? Use the [edit] button in the top right hand corner of your post.

Try

Code: Select all

[event]
    name=last breath
    first_time_only=no
    [filter]
        {PUT A SPECIAL FILTER HERE}
        canrecruit=yes #check it's a leader
    [/filter]
    [store_unit]
    [filter]
        x,y=$x1,$y1
    [/filter]
        variable=undead_leader
    [/store_unit]
    {VARIABLE_OP undead_leader.hitpoints $undead_leader.max_hitpoints}
[/event]

[event]
    name=new turn
    [unstore_unit]
        x,y=?
        variable=undead_leader
    [/unstore_unit]
[/event]
I'm not so sure I've got the hitpoints thing right, but that should pretty much do it.
"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!
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: need help on re-spawn

Post by monochromatic »

A slight edit on Reepurr's code. (Also it seems like he wants a macro :hmm: ) this also ensures the respawn is done on the next turn.

Code: Select all

#define LEADER_RESPAWN SIDE X Y
[event]
    name=last breath
    first_time_only=no
    [filter]
        side={SIDE}
        canrecruit=yes #check it's a leader
    [/filter]
    [store_unit]
        [filter]
            x,y=$x1,$y1
        [/filter]
        variable=undead_leader
        kill=yes
    [/store_unit]
    {VARIABLE undead_leader.hitpoints $undead_leader.max_hitpoints}
    {VARIABLE undead_leader.status.poisoned no}
    {VARIABLE undead_leader.status.slowed no}
    {VARIABLE undead_leader.moves $undead_leader.max_moves}
    {VARIABLE leader_not_present_{SIDE} yes}
[/event]

[event]
    name=new turn
    first_time_only=no

    [if]
        [variable]
            name=leader_not_present_{SIDE}
            boolean_equals=yes
        [/variable]
        [then]
            [unstore_unit]
                x,y={X},{Y}
                variable=undead_leader
            [/unstore_unit]
            {CLEAR_VARIABLE undead_leader,leader_not_present_{SIDE}}
        [/then]
    [/if]
[/event]
#enddef
EDIT: Slight edits.
Jinnaraka
Posts: 55
Joined: June 8th, 2010, 9:51 pm

Re: need help on re-spawn

Post by Jinnaraka »

thanks it works. I added a find_vacant=yes to the [unstore_unit]
elvish_sovereign wrote:A slight edit on Reepurr's code. (Also it seems like he wants a macro :hmm: ) this also ensures the respawn is done on the next turn.

Code: Select all

#define LEADER_RESPAWN SIDE X Y
[event]
    name=last breath
    first_time_only=no
    [filter]
        side={SIDE}
        canrecruit=yes #check it's a leader
    [/filter]
    [store_unit]
        [filter]
            x,y=$x1,$y1
        [/filter]
        variable=undead_leader
        kill=yes
    [/store_unit]
    {VARIABLE undead_leader.hitpoints $undead_leader.max_hitpoints}
    {VARIABLE undead_leader.status.poisoned no}
    {VARIABLE undead_leader.status.slowed no}
    {VARIABLE undead_leader.moves $undead_leader.max_moves}
    {VARIABLE leader_not_present_{SIDE} yes}
[/event]

[event]
    name=new turn
    first_time_only=no

    [if]
        [variable]
            name=leader_not_present_{SIDE}
            boolean_equals=yes
        [/variable]
        [then]
            [unstore_unit]
                x,y={X},{Y}
                variable=undead_leader
            [/unstore_unit]
            {CLEAR_VARIABLE undead_leader,leader_not_present_{SIDE}}
        [/then]
    [/if]
[/event]
#enddef
EDIT: Slight edits.
Legendary Thief (single player (Intermediated level, 20 scenarios) campaign; author)
Various Multiplayer scenarios modifier
Jinnaraka
Posts: 55
Joined: June 8th, 2010, 9:51 pm

Re: need help on re-spawn

Post by Jinnaraka »

I am trying to separate the code, so it is clearer. thanks anyway.
Reepurr wrote:Whoa. What's with the triple post? Use the [edit] button in the top right hand corner of your post.

Try

Code: Select all

[event]
    name=last breath
    first_time_only=no
    [filter]
        {PUT A SPECIAL FILTER HERE}
        canrecruit=yes #check it's a leader
    [/filter]
    [store_unit]
    [filter]
        x,y=$x1,$y1
    [/filter]
        variable=undead_leader
    [/store_unit]
    {VARIABLE_OP undead_leader.hitpoints $undead_leader.max_hitpoints}
[/event]

[event]
    name=new turn
    [unstore_unit]
        x,y=?
        variable=undead_leader
    [/unstore_unit]
[/event]
I'm not so sure I've got the hitpoints thing right, but that should pretty much do it.
Legendary Thief (single player (Intermediated level, 20 scenarios) campaign; author)
Various Multiplayer scenarios modifier
Post Reply