Skip to content

Commit

Permalink
fix: hireling stash and bank
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 22, 2023
1 parent fd0602a commit c3170a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions data-otservbr-global/npc/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function createHirelingType(HirelingName)
end

local npcConfig = {}
local enableBankSystem = {}

npcConfig.name = HirelingName
npcConfig.description = HirelingName
Expand Down Expand Up @@ -355,6 +356,7 @@ function createHirelingType(HirelingName)
end

npcType.onDisappear = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onDisappear(npc, creature)
end

Expand All @@ -363,6 +365,7 @@ function createHirelingType(HirelingName)
end

npcType.onCloseChannel = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onCloseChannel(npc, creature)
end

Expand Down Expand Up @@ -586,7 +589,9 @@ function createHirelingType(HirelingName)
elseif MsgContains(message, "stash") then
if hireling:hasSkill(HIRELING_SKILLS.STEWARD) then
npcHandler:say(GREETINGS.STASH, npc, creature)
player:setSpecialContainersAvailable(true)
player:openStash(true)
player:sendTextMessage(MESSAGE_FAILURE, "Your supply stash contains " .. player:getStashCount() .. " item" .. (player:getStashCount() > 1 and "s." or "."))
else
sendSkillNotLearned(npc, creature, HIRELING_SKILLS.STEWARD)
end
Expand Down Expand Up @@ -614,15 +619,18 @@ function createHirelingType(HirelingName)
npcHandler:setTopic(playerId, TOPIC.SERVICES)
npcHandler:say("Alright then, I will be here.", npc, creature)
end
elseif npcHandler:getTopic(playerId) >= TOPIC.BANK and npcHandler:getTopic(playerId) < TOPIC.FOOD then
elseif npcHandler:getTopic(playerId) == TOPIC.BANK then
enableBankSystem[playerId] = true
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
if enableBankSystem[playerId] then
-- Parse bank
npc:parseBank(message, npc, creature, npcHandler)
-- Parse guild bank
npc:parseGuildBank(message, npc, creature, playerId, npcHandler)
-- Normal messages
npc:parseBankMessages(message, npc, creature, npcHandler)
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
return true
end
Expand Down
2 changes: 2 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4214,6 +4214,8 @@ void Game::playerStashWithdraw(uint32_t playerId, uint16_t itemId, uint32_t coun
if (player->isDepotSearchOpenOnItem(itemId)) {
player->requestDepotSearchItem(itemId, 0);
}

player->sendOpenStash(true);
}

void Game::playerSeekInContainer(uint32_t playerId, uint8_t containerId, uint16_t index, uint8_t containerCategory) {
Expand Down

0 comments on commit c3170a6

Please sign in to comment.