Rheias
New Helper (I got over 2000 posts)
- Reaction score
- 232
Yes, there are dozens in the website, however I found a problem with them all. They all revive the unit where it died. This system will revive the creeps in their original location. MUI? Indeed. Easy? Yes. GUI? No. Comments? Lots.
I use KaTTaNa's handle variable system (just to ease things) you need only 5 functions of it. Copy them to the header of the map. After that copy the three triggers to your map as well and you are done.
Note: I could have used 1 global trigger, but just to ease things I used 3.
This is a few minutes work to help whoever needs it, feedbacks always welcomed.
KaTTaNa's handle system:
Trigger 1:
Trigger 2:
Trigger 3:
And finally demo map:
Enjoy.
I use KaTTaNa's handle variable system (just to ease things) you need only 5 functions of it. Copy them to the header of the map. After that copy the three triggers to your map as well and you are done.
Note: I could have used 1 global trigger, but just to ease things I used 3.
This is a few minutes work to help whoever needs it, feedbacks always welcomed.
KaTTaNa's handle system:
JASS:
function H2I takes handle h returns integer
return h
return 0
endfunction
function LocalVars takes nothing returns gamecache
// Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
return InitGameCache("jasslocalvars.w3v")
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
Trigger 1:
JASS:
// Init event (check the box above)
// This will pick in the game at the start
function Set_Creeps_Group_Condition takes nothing returns boolean
return GetOwningPlayer(GetFilterUnit()) == Player(12) // Checks that the owning player is player 13 (JASS starts from 0, thus 12 + 1 = 13)
endfunction
function Set_Creeps_Group_Actions takes nothing returns nothing
call SetHandleReal(GetEnumUnit(),"x",GetUnitX(GetEnumUnit())) // Gets the creeps' loc's X
call SetHandleReal(GetEnumUnit(),"y",GetUnitY(GetEnumUnit())) // Gets the creeps' loc's Y
call SetHandleReal(GetEnumUnit(),"f",GetUnitFacing(GetEnumUnit())) // Gets creep facing
endfunction
function Set_Creeps_Actions takes nothing returns nothing
local group creeps = CreateGroup() // Local group, we'll store here the creeps.
call GroupEnumUnitsInRect(creeps,GetWorldBounds(),Condition(function Set_Creeps_Group_Condition)) // Puts inside creeps all units owned by player 13.
call ForGroup(creeps,function Set_Creeps_Group_Actions) // Loops through the creeps, getting their facing angle and location
call DestroyGroup(creeps) // Destroys group
set creeps = null // Nulls it
endfunction
//Creates the trigger
function InitTrig_Set_Creeps takes nothing returns nothing
set gg_trg_Set_Creeps = CreateTrigger()
call TriggerAddAction(gg_trg_Set_Creeps,function Set_Creeps_Actions)
endfunction
Trigger 2:
JASS:
// This will run when a creep enters map
function Set_Creeps_Mid_Conditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(12) // Checks that the creeps is owned by player 13
endfunction
function Set_Creeps_Mid_Actions takes nothing returns nothing
call SetHandleReal(GetTriggerUnit(),"x",GetUnitX(GetTriggerUnit())) // Gets creep's loc's X
call SetHandleReal(GetTriggerUnit(),"y",GetUnitY(GetTriggerUnit())) // Gets creep's loc's Y
call SetHandleReal(GetTriggerUnit(),"f",GetUnitFacing(GetTriggerUnit())) // Gets creep's facing
endfunction
// Creates the trigger
function InitTrig_Set_Creeps_Mid takes nothing returns nothing
set gg_trg_Set_Creeps_Mid = CreateTrigger()
call TriggerRegisterEnterRectSimple(gg_trg_Set_Creeps_Mid,GetWorldBounds())
call TriggerAddCondition(gg_trg_Set_Creeps_Mid,Condition(function Set_Creeps_Mid_Conditions))
call TriggerAddAction(gg_trg_Set_Creeps_Mid,function Set_Creeps_Mid_Actions)
endfunction
Trigger 3:
JASS:
// This is the core of the system, when a unit dies it will revive it.
constant function Revive_Creeps_Wait_Time takes integer lvl returns real
// Returns the waiting time. Creep's level * 3 + 5
return lvl * 3.00 + 5.00
endfunction
function Revive_Creeps_Conditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(12) // Checks that the creep's owner is player 13
endfunction
function Revive_Creeps_Actions takes nothing returns nothing
local unit creep = GetTriggerUnit() // Gets the creep in a var
local integer id = GetUnitTypeId(creep) // Gets it's type in a var
local player owner = GetOwningPlayer(creep) // It's owner (in case you change conditions)
local real x = GetHandleReal(creep,"x") // Gets the X
local real y = GetHandleReal(creep,"y") // Gets the Y
local real f = GetHandleReal(creep,"f") // Gets the creep's facing
local integer lvl = GetUnitLevel(creep)
call PolledWait(Revive_Creeps_Wait_Time(lvl)) // Wait the time written above
call CreateUnit(owner,id,x,y,f) // Creates the unit
call RemoveUnit(creep) // Removes original creep to hide body.
set creep = null // Null creep
set owner = null // Null Owner
endfunction
//Creates the trigger
function InitTrig_Revive_Creeps takes nothing returns nothing
set gg_trg_Revive_Creeps = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Revive_Creeps, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition(gg_trg_Revive_Creeps,Condition(function Revive_Creeps_Conditions))
call TriggerAddAction(gg_trg_Revive_Creeps,function Revive_Creeps_Actions)
endfunction
And finally demo map:
Enjoy.