Creep Revive

Status
Not open for further replies.
Level 5
Joined
Nov 11, 2009
Messages
172
I'd like a creep revive system, preferably in vJass, gui is fine aslong as it doesn't use custom unit value. My own does and I just don't like it =(
You have to be able to specify a respawn time for every creep type.
 
Here you go:

This stores the creeps.
Code:
INIT Store Creeps
    Events
        Map initialization
        Time - Elapsed game time is 2.00 seconds
    Conditions
    Actions
        Set Loop = 0
        Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Creep_Type[Loop] = (Unit-type of (Picked unit))
                Set Creep_Position[Loop] = (Position of (Picked unit))
                Unit - Set the custom value of (Picked unit) to Loop
                Set Loop = (Loop + 1)
        Destructible - Pick every destructible in (Playable map area) and do (Actions)
            Loop - Actions
                Destructible - Open All walls of (Picked destructible)
and for the revive:
Code:
function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM
    set CUSTOM = GetUnitUserData(GetDyingUnit())
    call TriggerSleepAction( 60.00 )
    call CreateNUnitsAtLoc( 1, udg_Creep_Type[CUSTOM], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Position[CUSTOM], bj_UNIT_FACING )
    call SetUnitUserData( GetLastCreatedUnit(), CUSTOM )
endfunction

//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
    set gg_trg_Revive_Creeps = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction

Just change how much time it takes to revive them.

Code:
    call TriggerSleepAction( 60.00 )

if i want 120 seconds i make it be:

Code:
    call TriggerSleepAction( 120.00 )

-=-=-=-=-=-=-=-=-
+rep if i helpd :wink:
 
Last edited:
A few time ago I found this system here
JASS:
library CreepRespawn initializer init

globals
    private constant integer KEY = 0
    private hashtable ht = InitHashtable()
    private trigger GetDying = CreateTrigger()
endglobals

private struct Data
    real    x
    real    y
    real    d
    real    f
    integer uid
    integer id
    player p
    static method create takes real x, real y, real d, unit u returns thistype
        local thistype this = thistype.allocate()
        set .x   = x
        set .y   = y
        set .d   = d
        set .uid = GetHandleId(u)
        set .f   = GetUnitFacing(u)
        set .id  = GetUnitTypeId(u)
        set .p   = GetOwningPlayer(u)
        return this
    endmethod
endstruct

function SetCreepRespawn takes unit u, real delay returns boolean
    local integer uid  = GetHandleId(u)
    local Data t       = LoadInteger(ht,uid,KEY)
    local Data    data = 0
    if t >= 1 then // unit already added to the system
        if delay <= 0. then // if delay < 0 then disable respawn of the unit
            call SaveInteger(ht,uid,KEY, 0)
            call RemoveSavedInteger(ht,uid,KEY)
            return false
        elseif t.uid == uid then // if delay > 0 then set respawn time to new value
            set t.d = delay
            return false
        endif
    endif
    set data = Data.create(GetUnitX(u),GetUnitY(u),delay,u)
    call SaveInteger(ht,uid,KEY,data)
    return true
endfunction

private function ActionDelayed takes Data data returns nothing
    local integer uid = 0
    call TriggerSleepAction(data.d)
    set uid = GetHandleId(CreateUnit(data.p,data.id,data.x,data.y,data.f))
    call SaveInteger(ht,data.uid,KEY, 0)
    call RemoveSavedInteger(ht,data.uid,KEY)
    call SaveInteger(ht,uid,KEY,data)
    set data.uid = uid
endfunction

private function Action takes nothing returns boolean
    local Data data = LoadInteger(ht,GetHandleId(GetTriggerUnit()),KEY)
    if data <= 0 then
        return false
    endif
    call ActionDelayed.execute(data)
    return false
endfunction

private function init takes nothing returns nothing
    call Data.create(0.,0.,0.,null)
    call TriggerRegisterAnyUnitEventBJ( GetDying, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(GetDying, Condition(function Action))
endfunction

endlibrary

With this you can make a unit group containing this trigger:
  • Custom script: call SetCreepRespawn( GetEnumUnit() , time in Seconds. )
It doesn't look like working with custom values and worked perfectly for my map
 
Status
Not open for further replies.
Back
Top