Skip to content

Commit

Permalink
feat: quickloot (opentibiabr#960)
Browse files Browse the repository at this point in the history
* wip: quickloot

* Quicklooting attributes

* feat: working loot corpse and loot item inside container

* wip

* Quicklooting fixes and updates (opentibiabr#956)

This fixes some things like adding the main bp as fallback or searching for other able bps.

TODO add spam protection
TODO make player move to the loot before quicklooting, else it will grab from distance the loot
TODO add sendContainer when user clicks on the backpack inside manage loot container
TODO save quick loot list as a string in storage

* fix:quickloot

* chore: cleanup

* chore: database adjustments

* fix: search inbox items

* fix: gold pouch

* fix: loot analysers, openContainer

* feat: drop tracker

* feat: quicklooticons

Co-authored-by: eduardodantas <[email protected]>
Co-authored-by: dudztroyer <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2020
1 parent 8c9d41c commit 9e2453d
Show file tree
Hide file tree
Showing 12 changed files with 3,626 additions and 348 deletions.
2 changes: 2 additions & 0 deletions data/events/scripts/monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function Monster:onDropLoot(corpse)
player:sendTextMessage(MESSAGE_LOOT, text)
end
end

player:updateKillTracker(self, corpse)
else
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
Expand Down
30 changes: 28 additions & 2 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ function Player:onLook(thing, position, distance)
description = string.format("%s, Unique ID: %d", description, uniqueId)
end

if thing:isContainer() then
local quickLootCategories = {}
local container = Container(thing.uid)
for categoryId = LOOT_START, LOOT_END do
if container:hasQuickLootCategory(categoryId) then
table.insert(quickLootCategories, categoryId)
end
end

description = string.format("%s, QuickLootCategory: (%s)", description, table.concat(quickLootCategories, ", "))
end

local itemType = thing:getType()

local transformEquipId = itemType:getTransformEquipId()
Expand Down Expand Up @@ -277,17 +289,20 @@ local function antiPush(self, item, count, fromPosition, toPosition, fromCylinde
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

-- No move items with actionID = 8000
if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

-- Store Items
if isInArray(storeItemID,item.itemid) then
self:sendCancelMessage('You cannot move this item outside this container.')
return false
end
-- No move if item count > 20 items

-- No move if item count > 20 items
local tile = Tile(toPosition)
if tile and tile:getItemCount() > 20 then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
Expand Down Expand Up @@ -461,11 +476,22 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder,
return false
end

-- Check two-handed weapons
-- Handle move items to the ground
if toPosition.x ~= CONTAINER_POSITION then
if item:isContainer() then
local container = Container(item.uid)
for categoryId = LOOT_START, LOOT_END do
if container:hasQuickLootCategory(categoryId) then
container:removeQuickLootCategory(categoryId)
self:setQuickLootBackpack(categoryId, nil)
end
end
end

return true
end

-- Check two-handed weapons
if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
local itemType, moveItem = ItemType(item:getId())
if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
Expand Down
Loading

0 comments on commit 9e2453d

Please sign in to comment.