• 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!

C++ Conjured items are moved to the main backpack when created

Blasphemy

Well-Known Member
Joined
Jan 5, 2012
Messages
387
Reaction score
67
Invalid title
Hi everyone, I'm needing to work in this code to change the way the runes conjure.

I want to conjure runes from anywhere on backpack. I already used this code:


But it has only one issue, when you conjure the rune, it moves to the begin of your container...


Its from TFS 1.2 (7.72)
Anyone can help me?
C++:
bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const uint32_t conjureCost = getManaCost(player);
    const uint32_t soulCost = getSoulCost();

    if (reagentId != 0) {
        bool foundReagent = false;

        Item* item = player->getInventoryItem(CONST_SLOT_LEFT);
        if (item && item->getID() == reagentId) {
            foundReagent = true;

            // left arm conjure
            int32_t index = player->getThingIndex(item);
            g_game.internalRemoveItem(item);

            Item* newItem = Item::CreateItem(conjureId, conjureCount);
            if (!newItem) {
                return false;
            }

            ReturnValue ret = g_game.internalAddItem(player, newItem, index);
            if (ret != RETURNVALUE_NOERROR) {
                delete newItem;
                return false;
            }

            g_game.startDecay(newItem);

            Spell::postCastSpell(player, conjureCost, soulCost);
        }

        item = player->getInventoryItem(CONST_SLOT_RIGHT);
        if (item && item->getID() == reagentId && player->getMana() >= conjureCost) {
            foundReagent = true;

            // right arm conjure
            int32_t index = player->getThingIndex(item);
            g_game.internalRemoveItem(item);

            Item* newItem = Item::CreateItem(conjureId, conjureCount);
            if (!newItem) {
                return false;
            }

            ReturnValue ret = g_game.internalAddItem(player, newItem, index);
            if (ret != RETURNVALUE_NOERROR) {
                delete newItem;
                return false;
            }

            g_game.startDecay(newItem);

            Spell::postCastSpell(player, conjureCost, soulCost);
        }

        if (!foundReagent) {
            player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            return false;
        }
    } else {
        Item* newItem = Item::CreateItem(conjureId, conjureCount);
        if (!newItem) {
            return false;
        }

        ReturnValue ret = g_game.internalPlayerAddItem(player, newItem);
        if (ret != RETURNVALUE_NOERROR) {
            delete newItem;
            return false;
        }

        g_game.startDecay(newItem);
        Spell::postCastSpell(player, conjureCost, soulCost);
    }

    postCastSpell(player, true, false);
    g_game.addMagicEffect(player->getPosition(), CONST_ME_MAGIC_RED);
    return true;
}
 
Back
Top