• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Resurection Stone Trigger?

Status
Not open for further replies.
Level 4
Joined
May 17, 2011
Messages
106
Hello!

I've already googled it, I found a 6 years old post on hive workshop about this trigger but it didn't help me much.

I want people to resurect at a resurection stone like 30 secs after they died but this isn't only for 1 person, I would like everyone to choose their own stone (there's currently 4 on my map, I won't add more of them).

Just like the orc campaign, they would just need to walk by the stone to activate it and resurection at this special location when they die.

Is this possible?

And btw, could someone tell me what is the name effect of the resurection stone?

Thanks!

Edit: I would also like a timer for the resurection, top right of the screen. I might know how to make it but any ideas are welcome.

Edit[2]: Just found out that I posted in the wrong section, my bad, I didn't even notice when I made this post. Sorry about that!
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Ofcourse it is possible.

You map players to their stones using an array of units (the unit being stone) and index the player number.
Like wise you are after doing something simplar with heroes and their players.
You also have a timer array where each player has their own timer.

When a player's hero dies. You start their timer for 30 seconds. When any of the timers expires (same code handles all of them) you then use a linear search to find which player the timer corosponds to and then resurrect that hero. I am aware linear search is not the most efficient solution but for such a simple task it is perfectly acceptable.

Alternatives would be...
To use a hashtable to map for O(1) lookup efficiency (compared to O(n) of linear search. The speed gain should be invisible as the code runs very seldomly and only has a maximum of n=16.
To use a queue structure for the whole system (probably the best) as expiring timers would obviously corospond to the top of the queue.
 
Level 4
Joined
May 17, 2011
Messages
106
Ofcourse it is possible.

You map players to their stones using an array of units (the unit being stone) and index the player number.
Like wise you are after doing something simplar with heroes and their players.
You also have a timer array where each player has their own timer.

When a player's hero dies. You start their timer for 30 seconds. When any of the timers expires (same code handles all of them) you then use a linear search to find which player the timer corosponds to and then resurrect that hero. I am aware linear search is not the most efficient solution but for such a simple task it is perfectly acceptable.

Alternatives would be...
To use a hashtable to map for O(1) lookup efficiency (compared to O(n) of linear search. The speed gain should be invisible as the code runs very seldomly and only has a maximum of n=16.
To use a queue structure for the whole system (probably the best) as expiring timers would obviously corospond to the top of the queue.

Since stones are destructibles, isn't it possible to turn them into units? Or use the unit function for a destructible? And btw you lost me at the linear thing hehe... :p

I'm going to try something with what you gave me and give news of it ;)

Edit: Actually this is harder than what I thought I might need a few hints :eek:
 
Last edited:
make a building with that model
and then make the trigger

A unit dies

unit type of triggering unit is a hero equal to true

timer start timer[player number of owner of triggering unit] that will expire in 30 seconds
create timer window for last created timer
set timer window[player number of owner of trigering unit] = last created timer window


trigger 2

timer expires

condition
NONE
For (interget A/B/Whatever/) loop 1 to (number of players available in your map mister...)
-If Timer(For Loop interger A/B/Whatever) equal to expiring timer (idk about this condition, i think this is correct) then do actions
-Destroy timer windows For loop integerA/B/WHATEVERRRR
-Hero revive (Your hero's unit variable)[Forloop integer A/B/Whatever]

Else:
NOPE: DON"T FILL the else


Requirement variables:
-Hero[Arrays]
-Timer[Array]
-Timer window[array also duh]
set the hero variable when your player selected their hero


if you need a test map TELL ME RIGHT AWAY, if i don't reply then go to my http://ancientblades.forumcircle.com/ (i will reply : ))
 
Level 4
Joined
May 17, 2011
Messages
106
Hmm that's a good idea. A building with stone model... I'll try that

Edit: What about ther hero variable? I believe I have to set it in the first trigger with the player owner of the triggering unit? I just don't get what I should put after the = sign in this function.

Edit2: Nvm about the first edit, didn't read the end of your post. But anyway, what kind of variable is the hero variable suposed to be? There's no hero-type variable.. so I guess it should be player or unit?

And what would the action be? Something like Set Hero Variable [Player number of (owner of (buying unit))] = ?

There's also the Timer variable thing, what to put instead of the [ Index ] ?
 
Last edited:
Level 4
Joined
May 17, 2011
Messages
106
unit type variable
but..

Set Unit Variable[Player number of (owner of (trained/buying/triggering unit)]
give me your map and i'll see what to do.

Ah thanks I appreciate help but my map is far from done and I'd really like to make this trigger work on my own ;)

The only thing I don't understand yet is what to put here: Timer [ ? ] Expires

Instead of timer there's my timer variable, but what to put instead of the array? I know it should be something about the designated hero but...
 
I'd really like to make this trigger work on my own ;)


that my friend, is actually not a good thing to do,if you only hope on your own legs(you know what i mean :wink:)

okay bck on topic.

Make the event like this


repeat it how many players can play e.g i have 12 players that can play so...

Event
Timer [1] Expires
Timer [2] Expires
Timer [3] Expires
Timer [4] Expires
Timer [5] Expires until i reach 12.
 
Level 4
Joined
May 17, 2011
Messages
106
that my friend, is actually not a good thing to do,if you only hope on your own legs(you know what i mean :wink:)

okay bck on topic.

Make the event like this


repeat it how many players can play e.g i have 12 players that can play so...

Event
Timer [1] Expires
Timer [2] Expires
Timer [3] Expires
Timer [4] Expires
Timer [5] Expires until i reach 12.

The same trigger can handle all of them? (I mean timers)

Edit: About this condition..
If Timer(For Loop interger A/B/Whatever) equal to expiring timer (idk about this condition, i think this is correct) then do actions

Why would it need that? Since the trigger is gonna work when a Timer expires this is kind of useless no?

Anyway it doesn't solve my main problem. I wish to make this trigger work with a resurrection stone...
 
Last edited:
Level 4
Joined
May 17, 2011
Messages
106
yes just use a timer expires
condition:
-expiring timer equal to
Or any conditions are true
Timer[1]
Timer[2]
until you reach the available player slots.

and insert the actions.

What kind if condition is this? I can't find any condition that works with a timer...

Anyway it doesn't solve my main problem. It's not working with resurrection stones for the moment being it only resurrect heroes at center of the map...

How to make it work with stones?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Use an array to map the stones to their appropiate players (so from the player you can get a stone to revive them at). This is done by getting the player's slot number and using it as an index.

When a unit owned by a player that is of type hero approches a resurrection stone (unit enters region event) then set the owner of that unit's resurrection stone to that stone.

Now for the target of resurrection, you specify a point nearby the player's resurrection stone. Avoid reviving them inside the resurrection stone as that can cause bugs.
 
Level 4
Joined
May 17, 2011
Messages
106
Use an array to map the stones to their appropiate players (so from the player you can get a stone to revive them at). This is done by getting the player's slot number and using it as an index.

When a unit owned by a player that is of type hero approches a resurrection stone (unit enters region event) then set the owner of that unit's resurrection stone to that stone.

Now for the target of resurrection, you specify a point nearby the player's resurrection stone. Avoid reviving them inside the resurrection stone as that can cause bugs.

Alright

Got a question tho... what do you mean by map the stones ? I got some problems understanding english expressions... :s

Maybe you could give me an example of such function? Gosh I feel like an idiot... sorry about that.

There's also something I don't understand. Should I be doing something like : Set (resurrection stone variable) [Player number of (owner of (triggering unit))] = Value ???

What am I suposed to set the value at? I just don't get it...

Edit: What type of variable is my resurrection stone variable is suposed to be btw?

Edit2: Okay I think I made this work... found out myself a few things but there's a problem... my hero won't revive... and I'm not sure if it's going to revive at the right place if I can make it work... here is what I have so far:

  • RezStoneAstria
    • Events
      • Unit - A unit enters AstriaRezStone <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Custom script: call DisplayTextToPlayer(GetOwningPlayer(GetEnteringUnit()),0,0,"Revival point saved...")
      • Set Stones[(Player number of (Owner of (Triggering unit)))] = AstriaRezStone <gen>
I have the same trigger 4 times (1 for each city/revival point) I just replaced the Regions to fit their city

  • rez
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Heroes[(Player number of (Owner of (Triggering unit)))] = (Revivable Hero)
      • Countdown Timer - Start RezTimer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 20.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title (Name of (Owner of (Dying unit)))
      • Set RezWindow[(Player number of (Owner of (Triggering unit)))] = (Last created timer window)
  • rez2
    • Events
      • Time - RezTimer[1] expires
      • Time - RezTimer[2] expires
      • Time - RezTimer[3] expires
      • Time - RezTimer[4] expires
      • Time - RezTimer[5] expires
      • Time - RezTimer[6] expires
      • Time - RezTimer[7] expires
      • Time - RezTimer[8] expires
      • Time - RezTimer[9] expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy (Last created timer window)
      • Hero - Instantly revive Heroes[(Player number of (Owner of (Triggering unit)))] at (Center of Stones[(Player number of (Owner of (Triggering unit)))]), Show revival graphics
I doubt that this is right since it's not working properly... can someone tell me what's wrong?

Edit3: Oops, gotta remove the Coundown Timer - Destroy and replace it with my RezWindow variable thing...

Heroes = Unit variable with arrays
RezWindow = Timer Window
Stones = Region variable

Edit4: Okay well when I enter a stone region the message revival point saved appear, when I die the window timer starts (with my name) and when the timer reaches 0 it's destroyed but my hero isn't reviving.

I think I know what's the problem, it's with the hero revive line... I have to change player number of owner of triggering unit by revivable hero... right? I'll try that... nvm it still won't work

Edit5: Damn I am an idiot... I forgot about the heroes setting part should be at the start of the game when a player select his hero... that's why it's not working... I just gotta remove the heroes setting variable line in this trigger and set it at the begining of the game right? Correct me if I'm wrong

Edit6: Still won't work... here's my Heroes Variable setting trigger

  • Heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[(Player number of (Owner of (Buying unit)))] = (Last created unit)
Is it correct? :s
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You could make it a rect array and have each stone as the rect that detects when you are near it. Then you can spawn in the middle of the rect and not the stone.

Map is a term used in computer science as a function which stores data in a certain structure. Eg a hashing algorthim can be used to map data into a bucket array.
 
Level 4
Joined
May 17, 2011
Messages
106
You could make it a rect array and have each stone as the rect that detects when you are near it. Then you can spawn in the middle of the rect and not the stone.

Map is a term used in computer science as a function which stores data in a certain structure. Eg a hashing algorthim can be used to map data into a bucket array.

I see. Anyway I still didn't figure out what's the problem with my triggers. I have no idea of what's wrong there... Maybe you could take a look at it and tell me? :)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Hero - Instantly revive Heroes[(Player number of (Owner of (Triggering unit)))] at (Center of Stones[(Player number of (Owner of (Triggering unit)))]), Show revival graphics

This makes no sense as there is no triggering unit (only a triggering timer).

I advise using the triggering timer to perform a linear search on the timer array to find which player the timer corosponds to and then resurrect the hero for that player.
 
Level 4
Joined
May 17, 2011
Messages
106
This makes no sense as there is no triggering unit (only a triggering timer).

I advise using the triggering timer to perform a linear search on the timer array to find which player the timer corosponds to and then resurrect the hero for that player.

...and how can I do that? :s
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You loop through all player timers and when you find one which matches the expiring timer you then know which player should be resurrected.

You can then resurrect the player at their resurrection spot.

Alternitivly you coulc check out how the rexar campaign did it in the patch MPQ and scale it for many players.
 
Level 4
Joined
May 17, 2011
Messages
106
You loop through all player timers and when you find one which matches the expiring timer you then know which player should be resurrected.

You can then resurrect the player at their resurrection spot.

Alternitivly you coulc check out how the rexar campaign did it in the patch MPQ and scale it for many players.

Well the thing is, I tried that but couldn't find the right file. That's why I posted here hehe...

Anyway I can't open that file (patch MPQ) with the editor... so I don't know how to check it.

Edit: I understand the loop action, but I just don't know which function can do it. There's no condition that works with a timer...

Please can someone explain me exactly what to do because right now I'm completly lost... I think one of these trigger is the problem but I'm not sure...

Heroes variable = unit variable (array)

  • Heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[(Player number of (Owner of (Buying unit)))] = (Last created unit)
and my resurrection trigger...

  • rez2
    • Events
      • Time - RezTimer[1] expires
      • Time - RezTimer[2] expires
      • Time - RezTimer[3] expires
      • Time - RezTimer[4] expires
      • Time - RezTimer[5] expires
      • Time - RezTimer[6] expires
      • Time - RezTimer[7] expires
      • Time - RezTimer[8] expires
      • Time - RezTimer[9] expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Elapsed time for RezTimer[1]) Greater than or equal to 20.00
        • Then - Actions
          • Hero - Instantly revive Heroes[1] at (Center of Stones[1]), Show revival graphics
          • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Elapsed time for RezTimer[2]) Greater than or equal to 20.00
            • Then - Actions
              • Hero - Instantly revive Heroes[2] at (Center of Stones[2]), Show revival graphics
              • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Elapsed time for RezTimer[3]) Greater than or equal to 20.00
                • Then - Actions
                  • Hero - Instantly revive Heroes[3] at (Center of Stones[3]), Show revival graphics
                  • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Elapsed time for RezTimer[4]) Greater than or equal to 20.00
                    • Then - Actions
                      • Hero - Instantly revive Heroes[4] at (Center of Stones[4]), Show revival graphics
                      • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Elapsed time for RezTimer[5]) Greater than or equal to 20.00
                        • Then - Actions
                          • Hero - Instantly revive Heroes[5] at (Center of Stones[5]), Show revival graphics
                          • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Elapsed time for RezTimer[6]) Greater than or equal to 20.00
                            • Then - Actions
                              • Hero - Instantly revive Heroes[6] at (Center of Stones[6]), Show revival graphics
                              • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Elapsed time for RezTimer[7]) Greater than or equal to 20.00
                                • Then - Actions
                                  • Hero - Instantly revive Heroes[7] at (Center of Stones[7]), Show revival graphics
                                  • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Elapsed time for RezTimer[8]) Greater than or equal to 20.00
                                    • Then - Actions
                                      • Hero - Instantly revive Heroes[8] at (Center of Stones[8]), Show revival graphics
                                      • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Elapsed time for RezTimer[9]) Greater than or equal to 20.00
                                        • Then - Actions
                                          • Hero - Instantly revive Heroes[9] at (Center of Stones[9]), Show revival graphics
                                          • Countdown Timer - Destroy RezWindow[(Player number of (Owner of (Triggering unit)))]
                                        • Else - Actions
                                          • Do nothing
I tried everything I could but I just can't figure out how to make it work.

The timer is destroyed so I guess it's the revive line that won't work but I just don't know why... maybe it's because of the Heroes setting variable's trigger but I just don't know...
 
Last edited:
Level 4
Joined
May 17, 2011
Messages
106
Why do you check if the elapsed time is > than blah.
You should compare if the Expired timer is == Timer and then you got the index for your region.


There's no condition I can use with an Expiring timer :p

And I don't understand the last part... I got the index for my region? What do you mean? Because my stones variable is used to know where the hero should be revived at.
 
Level 4
Joined
May 17, 2011
Messages
106
Yeah I just noticed that.
You could use a custom script tho :/
if thats no problem(some mappers dont want custom scripts in their GUI) ill make it for you.

Well I wish I had the proper skills but since I'm still a bit new to the wc3 editor I'd gladly accept some help. :)
 
Level 23
Joined
Jan 1, 2009
Messages
1,615
Well one easy way in GUI would just be to have 9 triggers, each only 1 timer as event and do the number thing static.
Anyway, if you only want one, you can do it like that:
  • rez2
    • Events
      • Time - RezTimer[1] expires
      • Time - RezTimer[2] expires
      • Time - RezTimer[3] expires
      • Time - RezTimer[4] expires
      • Time - RezTimer[5] expires
      • Time - RezTimer[6] expires
      • Time - RezTimer[7] expires
      • Time - RezTimer[8] expires
      • Time - RezTimer[9] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • Custom script: if GetExpiredTimer() == udg_RezTimer[bj_forLoopAIndex]
          • Hero - Instantly revive Heroes[bj_forLoopAIndex] at (Center of Stones[bj_forLoopAIndex]), Show revival graphics
          • Countdown Timer - Destroy RezWindow[bj_forLoopAIndex]
          • Custom script: endif
Basicly you loop through your timers and check if the Expired one matches the Timer[x].
You need the "udg_" in front of your variable.
The bj_forLoopAIndex is the GUI- Loop Index.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
And GUI fails again...
Sorry about that, I was not aware you could not compare timers in GUI.

The above code is prety much what I wanted however it could be made more efficient.

Instead of always looping 9 times, you could just loop until you find the target and break out of the loop via an "exitwhen true" statement. Then you run your code on that index. This gives you a minimum and average order that is much better than the current which will always be the maximum. Aka a linear search.
 
Level 4
Joined
May 17, 2011
Messages
106
Thanks for helping me guys, for the moment being I'll stick with that trigger. All I want right now is my resurrection trigger working fine. I'll probably make it more efficient (all of my triggers) when I'm done with my map making/triggers making.

Gonna try this code now...

Edit: nvm, fixed the "then"

Edit2: My hero still won't revive :(

I believe the problem is here:

  • Heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[(Player number of (Owner of (Buying unit)))] = (Last created unit)
What should the value be? Last created unit doesn't sound like a right choice to me... but since I'm don't know what else it should be... there it is

Or maybe is it all about the variable's type? Heroes = Unit variable type (array)
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,615
  • Heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[(Player number of (Owner of (Buying unit)))] = (Last created unit)
What should the value be? Last created unit doesn't sound like a right choice to me... but since I'm don't know what else it should be... there it is

Or maybe is it all about the variable's type? Heroes = Unit variable type (array)

Using Buying Unit with MapInit as Event doesnt sound like a good choice for me.
And what are you trying to accomplish with that trigger?
 
Level 4
Joined
May 17, 2011
Messages
106
Using Buying Unit with MapInit as Event doesnt sound like a good choice for me.
And what are you trying to accomplish with that trigger?

Well that's for my resurrection trigger... I need that trigger so the resurrection trigger knows which hero it needs to resurrect. Take a look at page 1 I posted the whole thing if you need to understand it.
 
Level 4
Joined
May 17, 2011
Messages
106
Dude, there is no understanding, you got the problem wrong?
The Event Map Init doesnt have a Buying Unit. Also the Last Created one is wrong
I also dont know how you pick a hero?
You buy them at a tavern? Then change the Event.

Yes I buy heroes at one of my three taverns but what kind of event should I change it to? Only thing I see is a generic unit event but I'm not sure about this since there is nothing about buying a unit...
 
Level 23
Joined
Jan 1, 2009
Messages
1,615
You know what map Init it? Thats the time when the loadingbar is shown.
You cant respond to anything there, because no handle fires the event.

How about something like this
  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • ((Sold unit) is A Hero) Equal to True
    • Actions
      • Set Heros[(Player number of (Owner of (Sold unit)))] = (Sold unit)
 
Level 4
Joined
May 17, 2011
Messages
106
You know what map Init it? Thats the time when the loadingbar is shown.
You cant respond to anything there, because no handle fires the event.

How about something like this
  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • ((Sold unit) is A Hero) Equal to True
    • Actions
      • Set Heros[(Player number of (Owner of (Sold unit)))] = (Sold unit)

Aaaaaahhhhh !!! I see

I thought map Init was all about the game starting... obviously I was wrong

Edit: AAAHHHHH Nice it's working! :D Gotta test it with a friend and see if it works for multiple players at the same time tho. But for some reason the first time I die the Timer is stuck to 0 and 20 secs after I died I revive and the timer window is destroyed. Then whenever I die again the timer works properly... That's weird... it's happening only since I modified this last trigger...
 
Level 4
Joined
May 17, 2011
Messages
106
Good that I could help. The 2nd problem, dunno, too less specifix information

Yeah thank you and also thanks to Dr Super Good

About the second problem. When I die for the first time, the Resurrection Window Timer on top right show 00:00:00 and won't progress. 20 seconds after the death of my hero, the window is destroyed and my hero revives.

Normally, it would show 00:20:00, 00:19:00, 00:18:00 etc to 00:00:00 and then this window would be destroyed and my hero would revive.

The timer is f*cked up for the first death, and then it works properly.
 
Status
Not open for further replies.
Top