Skip to content

Commit

Permalink
Merge branch 'account_manager-andmore'
Browse files Browse the repository at this point in the history
  • Loading branch information
MillhioreBT committed May 20, 2023
2 parents 405031c + 0aff6b7 commit 51572f9
Show file tree
Hide file tree
Showing 112 changed files with 1,123 additions and 397 deletions.
1 change: 1 addition & 0 deletions data/events/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<event class="Player" method="onNetworkMessage" enabled="1" />
<event class="Player" method="onUpdateStorage" enabled="1" />
<event class="Player" method="onUpdateInventory" enabled="1" />
<event class="Player" method="onAccountManager" enabled="1" />

<!-- Monster methods -->
<event class="Monster" method="onDropLoot" enabled="1" />
Expand Down
10 changes: 7 additions & 3 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ end
function Player:onNetworkMessage(recvByte, msg)
local handler = PacketHandlers[recvByte]
if not handler then
io.write(string.format(
"Player: %s sent an unknown packet header: 0x%02X with %d bytes!\n",
self:getName(), recvByte, msg:len()))
print(string.format(
"Player: %s sent an unknown packet header: 0x%02X with %d bytes!\n",
self:getName(), recvByte, msg:len()))
return
end

Expand All @@ -145,3 +145,7 @@ function Player:onUpdateInventory(item, slot, equip)
Event.onUpdateInventory(self, item, slot, equip)
end
end

function Player:onAccountManager(text)
if hasEvent.onAccountManager then Event.onAccountManager(self, text) end
end
11 changes: 11 additions & 0 deletions data/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ string.trim = function(str)
return str:match '^()%s*$' and '' or str:match '^%s*(.*%S)'
end

do
local function tchelper(first, rest) return first:upper() .. rest:lower() end

-- Add extra characters to the pattern if you need to. _ and ' are
-- found in the middle of identifiers and English words.
-- We must also put %w_' into [%w_'] to make it handle normal stuff
-- and extra stuff the same.
-- This also turns hex numbers into, eg. 0Xa7d4
string.titleCase = function(str) return str:gsub("(%a)([%w_']*)", tchelper) end
end

if not nextUseStaminaTime then nextUseStaminaTime = {} end

function getPlayerDatabaseInfo(name_or_guid)
Expand Down
8 changes: 4 additions & 4 deletions data/lib/core/combat.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
function Combat:getPositions(creature, variant)
local positions = {}
function onTargetTile(creature, position) positions[#positions + 1] = position end
local function callback(creature, position) positions[#positions + 1] = position end

self:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
self:setCallback(CallBackParam.TARGETTILE, callback)
self:execute(creature, variant)
return positions
end

function Combat:getTargets(creature, variant)
local targets = {}
function onTargetCreature(creature, target) targets[#targets + 1] = target end
local function callback(creature, target) targets[#targets + 1] = target end

self:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
self:setCallback(CallBackParam.TARGETCREATURE, callback)
self:execute(creature, variant)
return targets
end
Loading

0 comments on commit 51572f9

Please sign in to comment.