--time to wait before removing the dead bodies (in seconds) --note, dont set too long or it may get removed by the system and then there will be no possibility of respawn local body_removal_delay = 2 --time to wait before respawning the enemies (in seconds) local respawn_delay = 6 --amount of variation in x,y and z placements when enemies are respawned (in percent) --note this is taken from where they die --note2 y position doesnt currently work due to a GG bug local xmod = 0.02 local zmod = 0.02 local ymod = 0 --time to wait between checks (for performance reasons) local delay = 1000 --------- local x = {} local y = {} local z = {} local timer = {} --script to work in conjunction with ai_respawn.lua --set always active function ai_respawner_init(e) Hide(e) CollisionOff(e) end function ai_respawner_main(e) Hide(e) CollisionOff(e) if GetTimer(e) > delay then StartTimer(e) for a = 1,9999 do if g_Entity[a] ~= nil and a ~= e then if dead[a] ~= nil then if dead[a] == 1 then if xmod <= 0 or xmod > 99 then x[a] = g_Entity[a]['x'] else x[a] = g_Entity[a]['x'] * math.random(1-(xmod/10),1+(xmod/10)) end if ymod <= 0 or ymod > 99 then y[a] = g_Entity[a]['y'] else y[a] = g_Entity[a]['y'] * math.random(1-(ymod/10),1+(ymod/10)) end if zmod <= 0 or zmod > 99 then z[a] = g_Entity[a]['z'] else z[a] = g_Entity[a]['z'] * math.random(1-(zmod/10),1+(zmod/10)) end dead[a] = 2 timer[a] = g_Time + (body_removal_delay*1000) --check body for removal elseif dead[a] == 2 then if g_Time >= timer[a] then --PromptDuration("removed body",500) timer[a] = g_Time + (respawn_delay*1000) Spawn(a) SetAttachmentVisible(a,0) Hide(a) CollisionOff(a) SetPosition(a,x[a],y[a],z[a]) ResetPosition(a,x[a],y[a],z[a]) AIEntityGoToPosition(g_Entity[a]['obj'],x[a],z[a]) dead[a] = 3 end --check for respawn elseif dead[a] == 3 then if g_Time >= timer[a] then --PromptDuration("respawned enemy",500) Show(a) SetAttachmentVisible(a,1) CollisionOn(a) dead[a] = 0 end end end end end end end function ai_respawner_exit(e) end