First of all, why doesn't the init work
2nd, it prints "successful" but not the 2nd print and the units dont respawn
2nd, it prints "successful" but not the 2nd print and the units dont respawn
JASS:
library Respawning
globals
hashtable RespawnTable
endglobals
function IsNeutralHostile takes nothing returns boolean
return ( GetOwningPlayer(GetFilterUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction
function Trig_Respawn_Copy_Func006Func003C takes nothing returns boolean
return true
endfunction
function IsBoss takes unit u returns boolean
if ( ( GetUnitTypeId(u) == 'nhef' ) ) then
return true
endif
if ( ( GetUnitTypeId(u) == 'hspt' ) ) then
return true
endif
if ( ( GetUnitTypeId(u) == 'hmpr' ) ) then
return true
endif
return false
endfunction
function RespawnActions takes nothing returns nothing
local unit Dying = GetDyingUnit()
local integer UData = GetUnitUserData(Dying)
local integer DyingHandle = GetHandleId(Dying)
local integer xCord = LoadInteger(RespawnTable, DyingHandle, 0)
local integer yCord = LoadInteger(RespawnTable, DyingHandle, 1)
local real facing = GetUnitFacing(Dying)
if IsBoss(Dying) then
// call TriggerSleepAction(30)
call CreateUnitAtLoc(GetOwningPlayer(Dying), GetUnitTypeId(Dying), Location(xCord, yCord), facing)
else
// call TriggerSleepAction(15)
call CreateUnitAtLoc(GetOwningPlayer(Dying), GetUnitTypeId(Dying), Location(xCord, yCord), facing)
endif
set Dying = null
endfunction
function SetHashtableData takes nothing returns nothing
local unit Enum = GetEnumUnit()
local integer EnumData = GetHandleId(Enum)
local location l = GetUnitLoc(Enum)
call SaveReal(RespawnTable,EnumData, 0,GetLocationX(l))
call SaveReal(RespawnTable,EnumData, 1,GetLocationY(l))
call SaveReal(RespawnTable,EnumData, 2,GetUnitFacing(Enum))
set Enum = null
call RemoveLocation(l)
call print("Unit Data Set for " + I2S(EnumData) + " Unit")
endfunction
function FormHashtables takes nothing returns nothing
local group getUnitspp = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IsNeutralHostile))
call ForGroupBJ(getUnitspp, function SetHashtableData )
set getUnitspp = null
endfunction
//===========================================================================
function StartRespawnTables takes nothing returns nothing
local trigger t = CreateTrigger()
set gg_trg_Respawn_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Respawn_Copy, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Respawn_Copy, function IsNeutralHostile )
call TriggerAddAction( gg_trg_Respawn_Copy, function RespawnActions )
call TriggerAddAction(t, function FormHashtables )
call print("Successful!")
set t = null
endfunction
endlibrary