Problem with my creep respawn system

Reflexar

New Member
Reaction score
12
Can you please tell me why this doesn't work. It doesn't create the unit, neither does it create the effect.:banghead:

Please help me :D

JASS:
scope Settings initializer Actions

globals
    real respawn_time = 5.0
    integer Player_For_Respawn = 1 
    integer Creep_Integer = 1
    location array Creep_Point 
endglobals

private function callback takes nothing returns nothing
    local unit u = GetEnumUnit()
    call SetUnitUserData( u, Creep_Integer )
    set Creep_Point[Creep_Integer] = GetUnitLoc(u)
    set Creep_Integer = Creep_Integer + 1
endfunction

private function Actions takes nothing returns nothing
    local group Creeps = CreateGroup()
    set Creeps = GetUnitsOfPlayerAll(Player(Player_For_Respawn))
    call ForGroup(Creeps,function callback)
    call DestroyGroup(Creeps)
endfunction

endscope


JASS:
scope RespawnTrigger initializer InitTrig_Respawn_Trigger

private function Actions takes nothing returns nothing
    call TriggerSleepAction( respawn_time )
    call CreateUnitAtLoc(Player(Player_For_Respawn), GetUnitTypeId(GetTriggerUnit()), Creep_Point[GetUnitUserData(GetTriggerUnit())], bj_UNIT_FACING )
    call AddSpecialEffectTarget( "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl", GetLastCreatedUnit(), "origin" )
    call DestroyEffect(bj_lastCreatedEffect)
    call SetUnitUserData( GetLastCreatedUnit(), GetUnitUserData(GetTriggerUnit()) )
endfunction

//===========================================================================
private function InitTrig_Respawn_Trigger takes nothing returns nothing
    set gg_trg_Respawn_Trigger = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEvent( gg_trg_Respawn_Trigger, Player(Player_For_Respawn), EVENT_PLAYER_UNIT_DEATH, null )
    call TriggerAddAction( gg_trg_Respawn_Trigger, function Actions )
endfunction

endscope



Kind Regards
 

Sooda

Diversity enchants
Reaction score
318
Add debug messages and see does unit custom value contains something. You could simplify this trigger and store to locals died unit type, it's owner and facing. Then use TriggerSleepAction and create unit for that player again. Use native instead CreateUnitAtLoc, it assumes you store unit's X and Y coordinates also.

Wild guess, does your trigger is set to run on Map Initialization from Trigger Editor?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> is your trigger set to run on Map Initialization from Trigger Editor?

Uhm...


"GetUnitsOfPlayerAll" already creates a group.
"CreateUnitAtLoc" does not set a last created unit. Instead, it returns it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top