Se eu não poder fazer isso por favor me avisem aqui no tópico que eu retiro.
Créditos SOMENTE do: cbrm (OTLand)
Tópico Oficial:https://otland.net/threads/reward-chest-boss-reward-tfs-1-2.233397/
Tested on TFS 1.2, 10.77/78
Based on http://www.tibia.com/news/?subtopic=newsarchive&id=2486
Oque tem?
To-do
Changelog
Comentários
Agradecimentos especiais para
Instruções de instalação
Execute a query na database
CREATE TABLE IF NOT EXISTS `player_rewardchest` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`player_id` int(11) NOT NULL,
`reward` text NOT NULL,
`date` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
src/const.h
Abaixo...
ITEM_MARKET = 14405
...Adicione:
ITEM_REWARD_CHEST = 21584,
REWARD_CHEST_DEPOT = 99,
src/depotchest.h
Abaixo...
explicit DepotChest(uint16_t _type);
...Adicione:
uint32_t getDepotId() const {
return depotId;
}
void setDepotId(uint32_t id) {
depotId = id;
}
Abaixo...
uint32_t maxDepotItems;
...Adicione:
uint32_t depotId;
src/depotchest.cpp
Abaixo...
maxDepotItems = 1500;
...Adicione:
depotId = 0;
Acima...
return Container::queryAdd(index, thing, count, flags, actor);
...Adicione:
if (actor != nullptr && getDepotId() == REWARD_CHEST_DEPOT) {
return RETURNVALUE_NOTPOSSIBLE;
}
src/depotlocker.h
Acima...
//cylinder implementations
...Adicione:
void setMaxLockerItems(uint32_t maxitems) {
maxSize = maxitems;
}
src/luascript.h
Acima...
static int luaContainerGetSize(lua_State* L);
...Adicione:
static int luaContainerGetContentDescription(lua_State* L);
src/luascript.cpp
Acima...
registerMethod("Container", "getSize", LuaScriptInterface::luaContainerGetSize);
...Adicione:
registerMethod("Container", "getContentDescription", LuaScriptInterface::luaContainerGetContentDescription);
Acima...
int LuaScriptInterface::luaContainerGetSize(lua_State* L)
...Adicione:
int LuaScriptInterface::luaContainerGetContentDescription(lua_State* L)
{
// container:getContentDescription()
Container* container = getUserdata<Container>(L, 1);
if (container) {
std::ostringstream ss;
ss << container->getContentDescription();
pushString(L, ss.str());
} else {
lua_pushnil(L);
}
return 1;
}
src/actions.cpp
Troque:
//depot container
if (DepotLocker* depot = container->getDepotLocker()) {
DepotLocker* myDepotLocker = player->getDepotLocker(depot->getDepotId());
myDepotLocker->setParent(depot->getParent()->getTile());
openContainer = myDepotLocker;
player->setLastDepotId(depot->getDepotId());
} else {
openContainer = container;
}
Por:
//reward chest and depot container
if (item->getID() == ITEM_REWARD_CHEST) {
DepotLocker* myRewardChest = player->getRewardChest();
myRewardChest->setParent(item->getTile());
openContainer = myRewardChest;
player->setLastDepotId(REWARD_CHEST_DEPOT);
} else if (DepotLocker* depot = container->getDepotLocker()) {
DepotLocker* myDepotLocker = player->getDepotLocker(depot->getDepotId());
myDepotLocker->setParent(depot->getParent()->getTile());
openContainer = myDepotLocker;
player->setLastDepotId(depot->getDepotId());
} else {
openContainer = container;
}
src/player.h
Abaixo...
DepotLocker* getDepotLocker(uint32_t depotId);
...Adicione:
DepotLocker* getRewardChest();
src/player.cpp
Abaixo...
DepotChest* depotChest = new DepotChest(ITEM_DEPOT);
...Adicione:
depotChest->setDepotId(depotId);
Acima...
void Player::sendCancelMessage(ReturnValue message) const
...Adicione:
DepotLocker* Player::getRewardChest()
{
auto it = depotLockerMap.find(REWARD_CHEST_DEPOT);
if (it != depotLockerMap.end()) {
inbox->setParent(it->second);
return it->second;
}
DepotLocker* rewardChest = new DepotLocker(ITEM_LOCKER1);
rewardChest->setDepotId(REWARD_CHEST_DEPOT);
rewardChest->setMaxLockerItems(1);
rewardChest->internalAddThing(getDepotChest(REWARD_CHEST_DEPOT, true));
depotLockerMap[REWARD_CHEST_DEPOT] = rewardChest;
return rewardChest;
}
On player.cpp, container.cpp, inbox.cpp
Change:
if (!item->isPickupable()) {
Por:
if (item->getID() != 21518 && !item->isPickupable()) {
Adicione em @ data/actions/actions.xml
<!-- Reward Chest System -->
<action itemid="21584" script="reward_chest.lua"/>
<action actionid="21584" script="reward_chest.lua"/>
Crie @ data/actions/scripts/reward_chest.lua
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
--Reward Chest
if item:getId() == 21584 then
if player:getExhaustion(REWARD_CHEST.STORAGE) > 0 then
return player:sendCancelMessage('You need to wait ' .. string.diff(player:getStorageValue(REWARD_CHEST.STORAGE)-os.time()) .. ' before using this chest again.')
end
player:updateRewardChest()
--Boss Corpse
elseif item:getActionId() == 21584 then
local reward = REWARD_CHEST.LOOT[tonumber(item:getAttribute('text'))][player:getGuid()]
if reward ~= nil then
local rewardBag = Container(doCreateItemEx(REWARD_CHEST.CONTAINER, 1))
addContainerItems(rewardBag, reward)
if player:getCapacity() < rewardBag:getCapacity() then
return player:sendCancelMessage(RETURNVALUE_NOTENOUGHCAPACITY)
end
if player:addItemEx(rewardBag, false) == RETURNVALUE_NOERROR then
REWARD_CHEST.LOOT[tonumber(item:getAttribute('text'))][player:getGuid()] = nil
player:sendCancelMessage('You have picked up a reward container.')
else
player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
return true
end
end
end
return false
end
Adicione @ data/creaturescripts/creaturescripts.xml
<event type="kill" name="RewardChest" script="reward_chest.lua"/>
Registre em @data/creaturescripts/scripts/login.lua
player:registerEvent("RewardChest")
Adicione @ data/items/items.xml
<item id="21518" article="a" name="reward container">
<attribute key="weight" value="1800" />
<attribute key="containersize" value="24" />
<attribute key="slotType" value="backpack" />
</item>
<item id="21584" article="a" name="reward chest">
<attribute key="type" value="depot" />
<attribute key="containerSize" value="1" />
<attribute key="description" value="This chest contains your rewards earned in battles." />
</item>
Add @ data/lib/core/player.lua
function Player.setExhaustion(self, value, time)
return self:setStorageValue(value, time + os.time())
end
function Player.getExhaustion(self, value)
local storage = self:getStorageValue(value)
if storage <= 0 then
return 0
end
return storage - os.time()
end
Crie em @ data/creaturescripts/scripts/reward_chest.lua
(download anexado nesse post)
Download
RELEMBRANDO CRÉDITOS APENAS DO CBRM DA OTLAND