Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalwk committed Jul 29, 2023
1 parent 41d8d4b commit 0627fbb
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 82 deletions.
64 changes: 8 additions & 56 deletions INDEV/Battle Royale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function BattleRoyale:loadDependencies()
end)

if (not success) then
cprint('[TRUCE] FILE DEPENDENCY NOT FOUND: ' .. path .. file .. '.lua', 12)
cprint('[BATTLE ROYALE] FILE DEPENDENCY NOT FOUND: ' .. path .. file .. '.lua', 12)
goto next
end

Expand All @@ -129,11 +129,15 @@ function BattleRoyale:loadDependencies()
setmetatable(s, { __index = f })
s = f

_G[file] = path:find('events/') and function(...)
return f[file](self, ...)
end or nil

:: next ::
end
end

self:onStart() -- in case the plugin loads mid-game
self:on_start() -- in case the plugin loads mid-game
end

api_version = '1.12.0.0'
Expand All @@ -142,62 +146,10 @@ function OnScriptLoad()
BattleRoyale:loadDependencies()
end

function OnStart()
BattleRoyale:onStart()
end

function OnEnd()
BattleRoyale:onEnd()
end

function OnJoin(...)
BattleRoyale:onJoin(...)
end

function OnQuit(...)
BattleRoyale:onQuit(...)
end

function OnPreSpawn(...)
BattleRoyale:onPreSpawn(...)
end

function OnSpawn(...)
BattleRoyale:onSpawn(...)
end

function OnTick()
BattleRoyale:onTick()
end

function OnDeath(...)
BattleRoyale:onDeath(...)
end

function OnPickup(...)
return BattleRoyale:onPickup(...)
end

function OnDrop(...)
return BattleRoyale:onDrop(...)
end

function OnCommand(...)
return BattleRoyale:onCommand(...)
end

function OnObjectSpawn(...)
return BattleRoyale:onObjectSpawn(...)
end

function OnDamage(...)
return BattleRoyale:onDamage(...)
function OnScriptUnload()
-- N/A
end

function OnError()
print(debug.traceback())
end

function OnScriptUnload()
-- N/A
end
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
-- @param id (player id)
-- @param command (command string)
-- @return false (to prevent sapp from spamming 'unknown command' error.)
function event:onCommand(id, command)
function event:on_command(id, command)

local args = stringSplit(command)
local cmd = self.cmds[args[1]]
Expand All @@ -31,6 +31,6 @@ function event:onCommand(id, command)
return true
end

register_callback(cb['EVENT_COMMAND'], 'OnCommand')
register_callback(cb['EVENT_COMMAND'], 'on_command')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_damage.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local event = {}

-- Prevent spectators from damaging (or being damaged) by other players:
function event:onDamage(victim, killer, meta_id, damage)
function event:on_damage(victim, killer, meta_id, damage)

local v = tonumber(victim)
local k = tonumber(killer)
Expand Down Expand Up @@ -44,6 +44,6 @@ function event:onDamage(victim, killer, meta_id, damage)
return true, damage
end

register_callback(cb['EVENT_DAMAGE_APPLICATION'], 'OnDamage')
register_callback(cb['EVENT_DAMAGE_APPLICATION'], 'on_damage')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_death.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local function endGame(self)
return false
end

function event:onDeath(victim)
function event:on_death(victim)

if (not self.game or not self.game.started) then
return
Expand Down Expand Up @@ -60,6 +60,6 @@ function event:onDeath(victim)
victim:newMessage('You have ' .. victim.lives .. ' ' .. life .. ' remaining', 5)
end

register_callback(cb['EVENT_DIE'], 'OnDeath')
register_callback(cb['EVENT_DIE'], 'on_death')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_drop.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local event = {}

function event:onDrop(id)
function event:on_drop(id)

end

register_callback(cb['EVENT_WEAPON_DROP'], 'OnDrop')
register_callback(cb['EVENT_WEAPON_DROP'], 'on_drop')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_end.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local event = {}

function event:onEnd()
function event:on_end()
self.game = nil
self.safe_zone = nil
end

register_callback(cb['EVENT_GAME_END'], 'OnEnd')
register_callback(cb['EVENT_GAME_END'], 'on_end')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_join.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function event:newPlayer(o)
return o
end

function event:onJoin(id)
function event:on_join(id)

self.players[id] = self:newPlayer({
id = id,
Expand All @@ -24,6 +24,6 @@ function event:onJoin(id)
self:phaseCheck(false, id)
end

register_callback(cb['EVENT_JOIN'], 'OnJoin')
register_callback(cb['EVENT_JOIN'], 'on_join')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_object_spawn.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local event = {}

function event:onObjectSpawn(player, map_id, parent_id, object_id, sapp_spawning)
function event:on_object_spawn(player, map_id, parent_id, object_id, sapp_spawning)

if (not sapp_spawning) then
-- not currently used
Expand Down Expand Up @@ -92,6 +92,6 @@ function event:trackNuke()
end
end

register_callback(cb['EVENT_OBJECT_SPAWN'], 'OnObjectSpawn')
register_callback(cb['EVENT_OBJECT_SPAWN'], 'on_object_spawn')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_pickup.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local event = {}

function event:onPickup(id)
function event:on_pickup(id)

end

register_callback(cb['EVENT_WEAPON_PICKUP'], 'OnPickup')
register_callback(cb['EVENT_WEAPON_PICKUP'], 'on_pickup')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_pre_spawn.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local event = {}

function event:onPreSpawn(id)
function event:on_pre_spawn(id)

local player = self.players[id]
if (not player) then
Expand All @@ -13,6 +13,6 @@ function event:onPreSpawn(id)
self.players[id]:teleport(true, true)
end

register_callback(cb['EVENT_PRESPAWN'], 'OnPreSpawn')
register_callback(cb['EVENT_PRESPAWN'], 'on_pre_spawn')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_quit.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local event = {}

function event:onQuit(id)
function event:on_quit(id)

self:phaseCheck(true, id)
self.players[id] = nil

end

register_callback(cb['EVENT_LEAVE'], 'OnQuit')
register_callback(cb['EVENT_LEAVE'], 'on_quit')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_spawn.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local event = {}

function event:onSpawn(id)
function event:on_spawn(id)

local player = self.players[id]
if (not player) then
Expand Down Expand Up @@ -54,6 +54,6 @@ function event:onSpawn(id)
end
end

register_callback(cb['EVENT_SPAWN'], 'OnSpawn')
register_callback(cb['EVENT_SPAWN'], 'on_spawn')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_start.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local event = {}

function event:onStart()
function event:on_start()
if (get_var(0, '$gt') ~= 'n/a') then
self:initialize()
end
end

register_callback(cb['EVENT_GAME_START'], 'OnStart')
register_callback(cb['EVENT_GAME_START'], 'on_start')

return event
4 changes: 2 additions & 2 deletions INDEV/Battle Royale/events/on_tick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local function UpdateVectors(object, x, y, z)
write_float(object + 0x94, 0) -- roll
end

function event:onTick()
function event:on_tick()

self:preGameTimer() -- pre-game timer
self:landing() -- sky spawning / god mode timer
Expand Down Expand Up @@ -66,6 +66,6 @@ function event:onTick()
--end
end

register_callback(cb['EVENT_TICK'], 'OnTick')
register_callback(cb['EVENT_TICK'], 'on_tick')

return event

0 comments on commit 0627fbb

Please sign in to comment.