Skip to content

Commit

Permalink
no more ID's, just declare beautiful names
Browse files Browse the repository at this point in the history
  • Loading branch information
MillhioreBT committed Dec 7, 2021
1 parent a5644c0 commit 51a4cf7
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 170 deletions.
20 changes: 10 additions & 10 deletions data/events/scripts/creature.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
function Creature:onChangeOutfit(outfit)
if hasEventCallback(EVENT_CALLBACK_ONCHANGEMOUNT) then
if not EventCallback(EVENT_CALLBACK_ONCHANGEMOUNT, self, outfit.lookMount) then
if EventCallback.onChangeMount then
if not EventCallback.onChangeMount(self, outfit.lookMount) then
return false
end
end
if hasEventCallback(EVENT_CALLBACK_ONCHANGEOUTFIT) then
return EventCallback(EVENT_CALLBACK_ONCHANGEOUTFIT, self, outfit)
if EventCallback.onChangeOutfit then
return EventCallback.onChangeOutfit(self, outfit)
else
return true
end
end

function Creature:onAreaCombat(tile, isAggressive)
if hasEventCallback(EVENT_CALLBACK_ONAREACOMBAT) then
return EventCallback(EVENT_CALLBACK_ONAREACOMBAT, self, tile, isAggressive)
if EventCallback.onAreaCombat then
return EventCallback.onAreaCombat(self, tile, isAggressive)
else
return RETURNVALUE_NOERROR
end
end

function Creature:onTargetCombat(target)
if hasEventCallback(EVENT_CALLBACK_ONTARGETCOMBAT) then
return EventCallback(EVENT_CALLBACK_ONTARGETCOMBAT, self, target)
if EventCallback.onTargetCombat then
return EventCallback.onTargetCombat(self, target)
else
return RETURNVALUE_NOERROR
end
end

function Creature:onHear(speaker, words, type)
if hasEventCallback(EVENT_CALLBACK_ONHEAR) then
EventCallback(EVENT_CALLBACK_ONHEAR, self, speaker, words, type)
if EventCallback.onHear then
EventCallback.onHear(self, speaker, words, type)
end
end
8 changes: 4 additions & 4 deletions data/events/scripts/monster.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function Monster:onDropLoot(corpse)
if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
if EventCallback.onDropLoot then
EventCallback.onDropLoot(self, corpse)
end
end

function Monster:onSpawn(position, startup, artificial)
if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
if EventCallback.onSpawn then
return EventCallback.onSpawn(self, position, startup, artificial)
else
return true
end
Expand Down
14 changes: 7 additions & 7 deletions data/events/scripts/party.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
function Party:onJoin(player)
if hasEventCallback(EVENT_CALLBACK_ONJOIN) then
return EventCallback(EVENT_CALLBACK_ONJOIN, self, player)
if EventCallback.onJoin then
return EventCallback.onJoin(self, player)
else
return true
end
end

function Party:onLeave(player)
if hasEventCallback(EVENT_CALLBACK_ONLEAVE) then
return EventCallback(EVENT_CALLBACK_ONLEAVE, self, player)
if EventCallback.onLeave then
return EventCallback.onLeave(self, player)
else
return true
end
end

function Party:onDisband()
if hasEventCallback(EVENT_CALLBACK_ONDISBAND) then
return EventCallback(EVENT_CALLBACK_ONDISBAND, self)
if EventCallback.onDisband then
return EventCallback.onDisband(self)
else
return true
end
Expand Down Expand Up @@ -45,5 +45,5 @@ function Party:onShareExperience(exp)
end

exp = math.ceil((exp * sharedExperienceMultiplier) / (#self:getMembers() + 1))
return hasEventCallback(EVENT_CALLBACK_ONSHAREEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONSHAREEXPERIENCE, self, exp, rawExp) or exp
return EventCallback.onShareExperience and EventCallback.onShareExperience(self, exp, rawExp) or exp
end
68 changes: 34 additions & 34 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
function Player:onBrowseField(position)
if hasEventCallback(EVENT_CALLBACK_ONBROWSEFIELD) then
return EventCallback(EVENT_CALLBACK_ONBROWSEFIELD, self, position)
if EventCallback.onBrowseField then
return EventCallback.onBrowseField(self, position)
end
return true
end

function Player:onLook(thing, position, distance)
local description = ""
if hasEventCallback(EVENT_CALLBACK_ONLOOK) then
description = EventCallback(EVENT_CALLBACK_ONLOOK, self, thing, position, distance, description)
if EventCallback.onLook then
description = EventCallback.onLook(self, thing, position, distance, description)
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
local description = ""
if hasEventCallback(EVENT_CALLBACK_ONLOOKINBATTLELIST) then
description = EventCallback(EVENT_CALLBACK_ONLOOKINBATTLELIST, self, creature, distance, description)
if EventCallback.onLookInBattleList then
description = EventCallback.onLookInBattleList(self, creature, distance, description)
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
local description = "You see " .. item:getDescription(distance)
if hasEventCallback(EVENT_CALLBACK_ONLOOKINTRADE) then
description = EventCallback(EVENT_CALLBACK_ONLOOKINTRADE, self, partner, item, distance, description)
if EventCallback.onLookInTrade then
description = EventCallback.onLookInTrade(self, partner, item, distance, description)
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInShop(itemType, count, description)
local description = "You see " .. description
if hasEventCallback(EVENT_CALLBACK_ONLOOKINSHOP) then
description = EventCallback(EVENT_CALLBACK_ONLOOKINSHOP, self, itemType, count, description)
if EventCallback.onLookInShop then
description = EventCallback.onLookInShop(self, itemType, count, description)
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if hasEventCallback(EVENT_CALLBACK_ONMOVEITEM) then
return EventCallback(EVENT_CALLBACK_ONMOVEITEM, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if EventCallback.onMoveItem then
return EventCallback.onMoveItem(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
end
return true
end

function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if hasEventCallback(EVENT_CALLBACK_ONITEMMOVED) then
EventCallback(EVENT_CALLBACK_ONITEMMOVED, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if EventCallback.onItemMoved then
EventCallback.onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
end
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
if hasEventCallback(EVENT_CALLBACK_ONMOVECREATURE) then
return EventCallback(EVENT_CALLBACK_ONMOVECREATURE, self, creature, fromPosition, toPosition)
if EventCallback.onMoveCreature then
return EventCallback.onMoveCreature(self, creature, fromPosition, toPosition)
end
return true
end

function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation)
if hasEventCallback(EVENT_CALLBACK_ONREPORTRULEVIOLATION) then
EventCallback(EVENT_CALLBACK_ONREPORTRULEVIOLATION, self, targetName, reportType, reportReason, comment, translation)
if EventCallback.onReportRuleViolation then
EventCallback.onReportRuleViolation(self, targetName, reportType, reportReason, comment, translation)
end
end

function Player:onReportBug(message, position, category)
if hasEventCallback(EVENT_CALLBACK_ONREPORTBUG) then
return EventCallback(EVENT_CALLBACK_ONREPORTBUG, self, message, position, category)
if EventCallback.onReportBug then
return EventCallback.onReportBug(self, message, position, category)
end
return true
end

function Player:onTurn(direction)
if hasEventCallback(EVENT_CALLBACK_ONTURN) then
return EventCallback(EVENT_CALLBACK_ONTURN, self, direction)
if EventCallback.onTurn then
return EventCallback.onTurn(self, direction)
end
return true
end

function Player:onTradeRequest(target, item)
if hasEventCallback(EVENT_CALLBACK_ONTRADEREQUEST) then
return EventCallback(EVENT_CALLBACK_ONTRADEREQUEST, self, target, item)
if EventCallback.onTradeRequest then
return EventCallback.onTradeRequest(self, target, item)
end
return true
end

function Player:onTradeAccept(target, item, targetItem)
if hasEventCallback(EVENT_CALLBACK_ONTRADEACCEPT) then
return EventCallback(EVENT_CALLBACK_ONTRADEACCEPT, self, target, item, targetItem)
if EventCallback.onTradeAccept then
return EventCallback.onTradeAccept(self, target, item, targetItem)
end
return true
end

function Player:onTradeCompleted(target, item, targetItem, isSuccess)
if hasEventCallback(EVENT_CALLBACK_ONTRADECOMPLETED) then
EventCallback(EVENT_CALLBACK_ONTRADECOMPLETED, self, target, item, targetItem, isSuccess)
if EventCallback.onTradeCompleted then
EventCallback.onTradeCompleted(self, target, item, targetItem, isSuccess)
end
end

Expand Down Expand Up @@ -155,24 +155,24 @@ function Player:onGainExperience(source, exp, rawExp)
end
end

return hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
return EventCallback.onGainExperience and EventCallback.onGainExperience(self, source, exp, rawExp) or exp
end

function Player:onLoseExperience(exp)
return hasEventCallback(EVENT_CALLBACK_ONLOSEEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONLOSEEXPERIENCE, self, exp) or exp
return EventCallback.onLoseExperience and EventCallback.onLoseExperience(self, exp) or exp
end

function Player:onGainSkillTries(skill, tries)
if APPLY_SKILL_MULTIPLIER == false then
return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
return EventCallback.onGainSkillTries and EventCallback.onGainSkillTries(self, skill, tries) or tries
end

if skill == SKILL_MAGLEVEL then
tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
return EventCallback.onGainSkillTries and EventCallback.onGainSkillTries(self, skill, tries) or tries
end
tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
return EventCallback.onGainSkillTries and EventCallback.onGainSkillTries(self, skill, tries) or tries
end

function Player:onWrapItem(item)
Expand Down Expand Up @@ -202,7 +202,7 @@ function Player:onWrapItem(item)
return
end

if not hasEventCallback(EVENT_CALLBACK_ONWRAPITEM) or EventCallback(EVENT_CALLBACK_ONWRAPITEM, self, item) then
if not EventCallback.onWrapItem or EventCallback.onWrapItem(self, item) then
local oldId = item:getId()
item:remove(1)
local item = tile:addItem(wrapId)
Expand Down
Loading

0 comments on commit 51a4cf7

Please sign in to comment.