• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Very quick/simple question about ''wait''

Status
Not open for further replies.
Level 4
Joined
Jun 8, 2007
Messages
29
For example,for death timer; if i put ''wait'' action for revive,and IF a few people die at similar time will trigger mess up or will it be run separate times.I have been using wait and did not have problem,or i just didn't recognize one.Thanks
 
Level 4
Joined
Jun 8, 2007
Messages
29
thanks for responses! so my conclusion is; wait can work perfectly if i use array for variables, which means that trigger is ran separately each time? cos otherwise using or not using array does not change fact that timer is reset each time trigger is ran
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
thanks for responses! so my conclusion is; wait can work perfectly if i use array for variables, which means that trigger is ran separately each time? cos otherwise using or not using array does not change fact that timer is reset each time trigger is ran

Yes using an array can help, however you need to find usefil indices. For example: if you want to make a hero respawn and each player has only 1 hero you can just use the playernumber as an index for the array.

Other solution (a more general solution for 100% MUI / handling local timers and attaching stuff with GUI): http://warcraft.ingame.de/forum/showthread.php?t=211449 Its in german, just use google translate.
Then your code could look like this (with 25.0 seconds respawn delay):

DeathTrigger actions:
  • Set AAT_Counter = 1
  • Set AAT_Timeout = 25.0
  • Set AAT_Trigger = ReviveTrigger <gen>
  • Custom script: call AAT_prepareTimer()
  • Set AAT_store_unit = (Triggering unit)
  • Custom script: call AAT_pushUnit()
  • Custom script: call AAT_startTimer()
ReviveTrigger actions (doesnt need an event since its called by the script):
  • Custom script: call AAT_popUnit()
  • Revive Hero (AAT_store_unit) at position ...
  • Custom script: call AAT_deleteTimer()
Looks complicated at the first glance, but everytime you use it looks similar and you only have to adjust few lines.

I dont know if there is a similar system on the hive in english. If you have difficulties with the language just ask me and i will explain.
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
Waits are inefficent and you should etter use Timers (?) maybe. Because when wait is executed and at the same time, many units are under the effect of this, the trigger will mess up but if you didnt experience any problem, good for you but I am sure there will be leaks and such.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Waits are inefficent and you should etter use Timers (?) maybe. Because when wait is executed and at the same time, many units are under the effect of this, the trigger will mess up but if you didnt experience any problem, good for you but I am sure there will be leaks and such.

Ye, but the point is that GUI lacks proper support for timers. Leaks however are unrelated to timers/waits.

And about the accuracy, i dont think its a problem if a unit respawns 100 msec too early/late...
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
If u use triggering unit or other local variables waits will never mess up. Waits do not make a trigger MUI or non-MUI. Just the way u use them. Although waits are bad because of there I accuracy but this can be compensated. They are also bad because of the fact that they keep counting down when the player disconect box comes up.

U can use a second trigger and index and de-index everything. Timers will be hard for a beginning GUIer
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
Well, we can just make it into a different language like JASS or something but if we are to stay in GUI, we can keep the Wait but we should make sure that the other things are noticeable to be MUI. ANd others explianed by death about the triggering unit and blabla...lol XD
 
Using waits with a revive trigger and NOT using a local variable/unit index of some sort WILL fail if two unit die at the same time, when you want to revive both units.

If you don't want to use a unit indexing method (system or simple array) then use locals.
JASS:
function Trig_Revive_Actions takes nothing returns nothing
    local unit U=GetTriggerUnit()
    local real X=GetWidgetX(U)
    local real Y=GetWidgetY(U)
    local integer Id=GetUnitTypeId(U)
    local player P=GetOwningPlayer(U)
    local real A=GetUnitFacing(U)
    set U=null
    call TriggerSleepAction(20)
    call CreateUnit(P,Id,X,Y,A)
    set P=null
endfunction

function InitTrig_Revive takes nothing returns nothing
    set gg_trg_Revive=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Revive,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(gg_trg_Revive,function Revive)
endfunction

This will revive ANY unit that dies on the map. Feel free to add if statements to filter out unwanted deaths, or change the events.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Yea but if you are using jass anyway there is no reason to use waits. Same code with timers instead (you dont need unit indexing):

JASS:
globals
	hashtable ht
endglobals

struct Revive
	player p
	integer id
	real x
	real y
	real a
endstruct

function unitDeath takes nothing returns nothing
	local Revive r = Revive.create()
    local unit u = GetTriggerUnit()
	local timer t = CreateTimer()
	set r.p = GetOwningPlayer(u)
	set r.id = GetUnitTypeId(u)
	set r.x = GetUnitX(u)
	set r.y = GetUnitY(u)
	set r.a = GetUnitFacing(u)
	call SaveInteger(ht, GetHandleId(t), 1, r)
	call TimerStart(t, 20, false, function reviveUnit)
endfunction

function reviveUnit takes nothing returns nothing
    local timer t = GetExpiredTimer()
	local int hid = GetHandleId(t)
	local Revive r = LoadInteger(ht, hid, 1)
	call CreateUnit(r.p, r.id, r.x, r.y, r.a)
	call FlushChildHashtable(ht, hid)
	call DestroyTimer(t) // with TimerUtils: ReleaseTimer(t)
endfunction

function InitTrig_Revive takes nothing returns nothing
	set ht = InitHashtable()
    set gg_trg_Revive=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Revive,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(gg_trg_Revive,function unitDeath)
endfunction

But i think Stefanman wants a GUI solution. (actually i think hes not even reading this thread anymore..)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
a little corretion: you are not converting global variable to local, you are just masking its name usage

Someone once found out that if you make a local variable that has the same name as global variable, the compiler will not complain and the interpreter will search list of local variables before searching globals, so if I have global with same name as local, the local variable is always used.

This is just a neat trick to prevent having 90% of your code Custom Script
 
Level 4
Joined
Jun 8, 2007
Messages
29
Thanks everyone for replying! i'm not able to indulge in conversation for now, got no jass knowledge, but i understand most of it,(i know ''game maker'' language so it helps!)
Ye i will be using revive for one hero only,map is a mashup of arena-dota-style with only reapers.
 
Status
Not open for further replies.
Top