0
0
Fork 0
mirror of https://github.com/coop-deluxe/sm64coopdx.git synced 2024-12-03 17:27:27 +00:00
sm64coopdx/mods/arena/arena-spawn.lua

35 lines
943 B
Lua
Raw Normal View History

2022-05-22 04:05:41 +00:00
sArenaSpawns = {}
function bhv_arena_spawn_init(obj)
table.insert(sArenaSpawns, {
pos = { x = obj.oPosX, y = obj.oPosY, z = obj.oPosZ },
yaw = obj.oFaceAngleYaw,
type = (obj.oBehParams >> 24) & 0xFF,
})
obj_mark_for_deletion(obj)
end
id_bhvArenaSpawn = hook_behavior(nil, OBJ_LIST_LEVEL, true, bhv_arena_spawn_init, nil)
-------------
function find_spawn_point()
if gGameModes[gGlobalSyncTable.gameMode].teamSpawns then
local spawn = sArenaSpawns[math.random(#sArenaSpawns)]
local s = gPlayerSyncTable[0]
local itr = 0
repeat
spawn = sArenaSpawns[math.random(#sArenaSpawns)]
itr = itr + 1
until spawn.type == s.team or itr > 50
return spawn
end
local spawn = sArenaSpawns[math.random(#sArenaSpawns)]
return spawn
end
function on_level_init()
sArenaSpawns = {}
end
hook_event(HOOK_ON_LEVEL_INIT, on_level_init)