Skip to content

Commit

Permalink
refactor: split player death event handler into smaller functions (#3113
Browse files Browse the repository at this point in the history
)

This refactors the PlayerDeath event script to improve code
readability and maintainability. The original function has been split
into smaller, more focused functions, each handling a specific part of
the player death processing logic. This includes identifying the killer,
logging deaths in the database, sending messages to the guild channel,
and checking guild wars.

With this refactoring, the code is more modular and easier to
understand, making future modifications and maintenance more manageable.
The PlayerDeath event logic remains unchanged, ensuring the system
continues to function as expected.

Changes:
•. Split the onDeath function into smaller local functions.
•. Improved SQL query formatting using string.format for clarity and to
avoid repetitive code.
•. Renamed local variables to follow the camelCase convention.
  • Loading branch information
omarcopires authored Dec 9, 2024
1 parent 9adf040 commit 3c98b41
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 260 deletions.
114 changes: 0 additions & 114 deletions data-canary/scripts/creaturescripts/player_death.lua

This file was deleted.

146 changes: 0 additions & 146 deletions data-otservbr-global/scripts/creaturescripts/others/player_death.lua

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local svargrondArenaPlayerDeath = CreatureEvent("SvargrondArenaPlayerDeath")

function svargrondArenaPlayerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
if player:getStorageValue(Storage.Quest.U8_0.BarbarianArena.PitDoor) > 0 then
player:setStorageValue(Storage.Quest.U8_0.BarbarianArena.PitDoor, 0)
end
end

svargrondArenaPlayerDeath:register()
Loading

0 comments on commit 3c98b41

Please sign in to comment.