• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Reward Chest TFS 1.5

Extrodus

|| Blazera.net ||
Joined
Dec 22, 2008
Messages
2,750
Solutions
7
Reaction score
552
Location
Canada
Hurro; quick question guys!

Would the following system be safe to implement on TFS 1.5 [Downgrade 8.6] with changed container/reward itemID's or would it be safer to update/optimize the system first before adding it? As I see a few suggested edits in the comments.

Reward Chest System:
Seems there is also a Loot Issue Patch Here:
 
Last edited:
Managed to get the system to compile on TFS 1.5; however it seems in monsters.cpp createLoot has been moved to lua; so I am unable to add:

Code:
    if (isRewardBoss) {
        auto timestamp = time(nullptr);
        Item* rewardContainer = Item::CreateItem(ITEM_REWARD_CONTAINER);
        rewardContainer->setIntAttr(ITEM_ATTRIBUTE_DATE, timestamp);    
        corpse->setIntAttr(ITEM_ATTRIBUTE_DATE, timestamp);
        corpse->internalAddThing(rewardContainer);
        corpse->setRewardCorpse();
        corpse->startDecaying();
        return;
    }

Does anyone have ideas how to convert this to LUA?
 
data/scripts/eventcallbacks/monster/default_onDropLoot.lua
LUA:
    local mType = self:getType()
    if mType:isRewardBoss() then
        local timestamp = os.time()
        local rewardContainer = Game.createItem(ITEM_REWARD_CONTAINER)
        rewardContainer:setAttribute(ITEM_ATTRIBUTE_DATE, timestamp)
        corpse:setAttribute(ITEM_ATTRIBUTE_DATE, timestamp)
        corpse:addItemEx(rewardContainer)
        corpse:setAttribute(ITEM_ATTRIBUTE_CORPSEOWNER, 0xFFFFFFFF)
        corpse:decay()
        return
    end
 
Hurro; quick question guys!

Would the following system be safe to implement on TFS 1.5 [Downgrade 8.6] with changed container/reward itemID's or would it be safer to update/optimize the system first before adding it? As I see a few suggested edits in the comments.

Reward Chest System:
Seems there is also a Loot Issue Patch Here:
How did you manage to get this system into TFS 1.5? provide a tutorial?
 
Why commit to the rewards system?
This Reward system, which is more updated and improved, I have already added to my TFS 1.4.2 1098, 1.5 8.60 Nekiro, and 1.7 8.60, and it's working fine. You can check it out here and add it to your TFS.

 
This Reward system, which is more updated and improved, I have already added to my TFS 1.4.2 1098, 1.5 8.60 Nekiro, and 1.7 8.60, and it's working fine. You can check it out here and add it to your TFS.

how did you solve the too few arguments in the rewardchest.cpp? using 8.60 tfs 1.5
Post automatically merged:

1746722342509.webp
 
Last edited:
how did you solve the too few arguments in the rewardchest.cpp? using 8.60 tfs 1.5
The only error was in iologindata.cpp, which wasn’t compatible with your base. But you should look for this line:

LUA:
bool IOLoginData::addRewardItems(uint32_t playerId, const ItemBlockList& itemList, DBInsert& query_insert, PropWriteStream& propWriteStream)
and replace everything with this version here.
C++:
bool IOLoginData::addRewardItems(uint32_t playerId, const ItemBlockList& itemList, DBInsert& query_insert, PropWriteStream& propWriteStream)
{
    using ContainerBlock = std::pair<Container*, int32_t>;
    std::list<ContainerBlock> queue;
    Database& db = Database::getInstance();
    DBResult_ptr result = db.storeQuery(fmt::format("SELECT MAX(pid) as max_pid FROM `player_rewarditems` WHERE `player_id` = {:d}", playerId));
    int32_t runningId = 1;
    int32_t pidCounter = 1;
    if (result) {
        int32_t maxPid = result->getNumber<int32_t>("max_pid");
        if (maxPid > 0) {
            pidCounter = maxPid + 1;
        }
    }
    int32_t parentPid = pidCounter;
    for (const auto& it : itemList) {
        Item* item = it.second;
        propWriteStream.clear();
        item->serializeAttr(propWriteStream);

        size_t streamSize;
        if (!query_insert.addRow(fmt::format("{:d}, {:d}, {:d}, {:d}, {:d}, {:s}",
            playerId, parentPid, runningId, item->getID(), item->getSubType(), db.escapeString(propWriteStream.getStream(streamSize))))) {
            return false;
        }

        if (Container* container = item->getContainer()) {
            queue.emplace_back(container, runningId);
        }
        ++runningId; // Always increment SID upwards
    }
    while (!queue.empty()) {
        const ContainerBlock& cb = queue.front();
        Container* container = cb.first;
        int32_t parentId = cb.second;
        queue.pop_front();
        for (Item* item : container->getItemList()) {
            propWriteStream.clear();
            item->serializeAttr(propWriteStream);

            size_t streamSize;
            if (!query_insert.addRow(fmt::format("{:d}, {:d}, {:d}, {:d}, {:d}, {:s}",
                playerId, parentId, runningId, item->getID(), item->getSubType(), db.escapeString(propWriteStream.getStream(streamSize))))) {
                return false;
            }
            Container* subContainer = item->getContainer();
            if (subContainer) {
                queue.emplace_back(subContainer, runningId);
            }
            ++runningId; // Always increment SID upwards
        }
    }
    return query_insert.execute();
}

Recompile and test — be happy.
 
The only error was in iologindata.cpp, which wasn’t compatible with your base. But you should look for this line:

LUA:
bool IOLoginData::addRewardItems(uint32_t playerId, const ItemBlockList& itemList, DBInsert& query_insert, PropWriteStream& propWriteStream)
and replace everything with this version here.
C++:
bool IOLoginData::addRewardItems(uint32_t playerId, const ItemBlockList& itemList, DBInsert& query_insert, PropWriteStream& propWriteStream)
{
    using ContainerBlock = std::pair<Container*, int32_t>;
    std::list<ContainerBlock> queue;
    Database& db = Database::getInstance();
    DBResult_ptr result = db.storeQuery(fmt::format("SELECT MAX(pid) as max_pid FROM `player_rewarditems` WHERE `player_id` = {:d}", playerId));
    int32_t runningId = 1;
    int32_t pidCounter = 1;
    if (result) {
        int32_t maxPid = result->getNumber<int32_t>("max_pid");
        if (maxPid > 0) {
            pidCounter = maxPid + 1;
        }
    }
    int32_t parentPid = pidCounter;
    for (const auto& it : itemList) {
        Item* item = it.second;
        propWriteStream.clear();
        item->serializeAttr(propWriteStream);

        size_t streamSize;
        if (!query_insert.addRow(fmt::format("{:d}, {:d}, {:d}, {:d}, {:d}, {:s}",
            playerId, parentPid, runningId, item->getID(), item->getSubType(), db.escapeString(propWriteStream.getStream(streamSize))))) {
            return false;
        }

        if (Container* container = item->getContainer()) {
            queue.emplace_back(container, runningId);
        }
        ++runningId; // Always increment SID upwards
    }
    while (!queue.empty()) {
        const ContainerBlock& cb = queue.front();
        Container* container = cb.first;
        int32_t parentId = cb.second;
        queue.pop_front();
        for (Item* item : container->getItemList()) {
            propWriteStream.clear();
            item->serializeAttr(propWriteStream);

            size_t streamSize;
            if (!query_insert.addRow(fmt::format("{:d}, {:d}, {:d}, {:d}, {:d}, {:s}",
                playerId, parentId, runningId, item->getID(), item->getSubType(), db.escapeString(propWriteStream.getStream(streamSize))))) {
                return false;
            }
            Container* subContainer = item->getContainer();
            if (subContainer) {
                queue.emplace_back(subContainer, runningId);
            }
            ++runningId; // Always increment SID upwards
        }
    }
    return query_insert.execute();
}

Recompile and test — be happy.
yeah and what arguments exactly RewardChest::RewardChest(uint16_t type, bool paginated /= true/) : for 8.6 conatiner?
 
Back
Top