• 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+ Conjure runes in backpack

Olddies

Classicot.com
Premium User
Joined
Nov 21, 2009
Messages
1,172
Solutions
12
Reaction score
309
Location
Dominican Republic 🇩🇴
Hello i was searching around the forum and google trying to find the code for conjure runes directly from backpack without put the blank rune in the hands (slots) im using tfs 1.2
 
Solution
Hello i was searching around the forum and google trying to find the code for conjure runes directly from backpack without put the blank rune in the hands (slots) im using tfs 1.2
Hello i was searching around the forum and google trying to find the code for conjure runes directly from backpack without put the blank rune in the hands (slots) im using tfs 1.2
 
Solution
What you can do actually is this (not the best solution, but works):

Go to your player.cpp and adds this function (you need to change player.h too)
C++:
Item* Player::getFirstItemById(uint16_t itemId, int32_t subType /*= -1*/) const
{
    uint32_t count = 0;
    for (int32_t i = CONST_SLOT_FIRST; i <= CONST_SLOT_LAST; i++) {
        Item* item = inventory[i];
        if (!item) {
            continue;
        }

        if (item->getID() == itemId) {
            return item;
        }

        if (Container* container = item->getContainer()) {
            for (ContainerIterator it = container->iterator(); it.hasNext(); it.advance()) {
                if ((*it)->getID() == itemId) {
                    return *it;
                }
            }
        }
    }

    return nullptr;
}

player.h
C++:
Item* getFirstItemById(uint16_t itemId, int32_t subType = -1) const;


Change your conjureItem in your player.cpp:
C++:
bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    Item* item = player->getFirstItemById(reagentId);

    if (reagentId != 0 && player->getItemTypeCount(reagentId) <= 0 && !item) {
        player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }

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

    Item* ret = g_game.transformItem(item, conjureId, conjureCount);
    if (!ret) {
        player->sendCancelMessage(RETURNVALUE_NOERROR);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        delete newItem;
        return false;
    }

    g_game.startDecay(newItem);

    postCastSpell(player);
    g_game.addMagicEffect(player->getPosition(), CONST_ME_MAGIC_RED);
    return true;
}
 
What you can do actually is this (not the best solution, but works):

Go to your player.cpp and adds this function (you need to change player.h too)
C++:
Item* Player::getFirstItemById(uint16_t itemId, int32_t subType /*= -1*/) const
{
    uint32_t count = 0;
    for (int32_t i = CONST_SLOT_FIRST; i <= CONST_SLOT_LAST; i++) {
        Item* item = inventory[i];
        if (!item) {
            continue;
        }

        if (item->getID() == itemId) {
            return item;
        }

        if (Container* container = item->getContainer()) {
            for (ContainerIterator it = container->iterator(); it.hasNext(); it.advance()) {
                if ((*it)->getID() == itemId) {
                    return *it;
                }
            }
        }
    }

    return nullptr;
}

player.h
C++:
Item* getFirstItemById(uint16_t itemId, int32_t subType = -1) const;


Change your conjureItem in your player.cpp:
C++:
bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    Item* item = player->getFirstItemById(reagentId);

    if (reagentId != 0 && player->getItemTypeCount(reagentId) <= 0 && !item) {
        player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }

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

    Item* ret = g_game.transformItem(item, conjureId, conjureCount);
    if (!ret) {
        player->sendCancelMessage(RETURNVALUE_NOERROR);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        delete newItem;
        return false;
    }

    g_game.startDecay(newItem);

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

I found a bug with this solution as this code was not taking care of arrows and exevo pan. New solution now:

spells.cpp
C++:
bool ConjureSpell::loadFunction(const pugi::xml_attribute&)
{
    scripted = false;
    return true;
}

bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const uint32_t conjureCost = getManaCost(player);

    if (reagentId != 0) {
        Item* item = player->getFirstItemById(reagentId);

        if (player->getItemTypeCount(reagentId) <= 0 || !item) {
            player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            return false;
        }

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

        Item* ret = g_game.transformItem(item, conjureId, conjureCount);
        if (!ret) {
            player->sendCancelMessage(RETURNVALUE_NOERROR);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }
        
        g_game.startDecay(newItem);
    }
    else {
        Item* newItem = Item::CreateItem(conjureId, conjureCount);
        if (!newItem) {
            return false;
        }

        ReturnValue ret = g_game.internalPlayerAddItem(player, newItem);
        if (ret != RETURNVALUE_NOERROR) {
            player->sendCancelMessage(ret);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }

        g_game.startDecay(newItem);
    }

    postCastSpell(player);
    g_game.addMagicEffect(player->getPosition(), CONST_ME_MAGIC_RED);
    return true;
}
 
not working for me :(

MY BAD THI IS REALLY WORKING PERFECTLY!!! I LOVE YOU :D!!
I found a bug with this solution as this code was not taking care of arrows and exevo pan. New solution now:

spells.cpp
C++:
bool ConjureSpell::loadFunction(const pugi::xml_attribute&)
{
    scripted = false;
    return true;
}

bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const uint32_t conjureCost = getManaCost(player);

    if (reagentId != 0) {
        Item* item = player->getFirstItemById(reagentId);

        if (player->getItemTypeCount(reagentId) <= 0 || !item) {
            player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            return false;
        }

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

        Item* ret = g_game.transformItem(item, conjureId, conjureCount);
        if (!ret) {
            player->sendCancelMessage(RETURNVALUE_NOERROR);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }
     
        g_game.startDecay(newItem);
    }
    else {
        Item* newItem = Item::CreateItem(conjureId, conjureCount);
        if (!newItem) {
            return false;
        }

        ReturnValue ret = g_game.internalPlayerAddItem(player, newItem);
        if (ret != RETURNVALUE_NOERROR) {
            player->sendCancelMessage(ret);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }

        g_game.startDecay(newItem);
    }

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

@Olddies this is better solution :D!
 
Last edited:
I found a bug with this solution as this code was not taking care of arrows and exevo pan. New solution now:

spells.cpp
C++:
bool ConjureSpell::loadFunction(const pugi::xml_attribute&)
{
    scripted = false;
    return true;
}

bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const uint32_t conjureCost = getManaCost(player);

    if (reagentId != 0) {
        Item* item = player->getFirstItemById(reagentId);

        if (player->getItemTypeCount(reagentId) <= 0 || !item) {
            player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            return false;
        }

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

        Item* ret = g_game.transformItem(item, conjureId, conjureCount);
        if (!ret) {
            player->sendCancelMessage(RETURNVALUE_NOERROR);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }
        
        g_game.startDecay(newItem);
    }
    else {
        Item* newItem = Item::CreateItem(conjureId, conjureCount);
        if (!newItem) {
            return false;
        }

        ReturnValue ret = g_game.internalPlayerAddItem(player, newItem);
        if (ret != RETURNVALUE_NOERROR) {
            player->sendCancelMessage(ret);
            g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
            delete newItem;
            return false;
        }

        g_game.startDecay(newItem);
    }

    postCastSpell(player);
    g_game.addMagicEffect(player->getPosition(), CONST_ME_MAGIC_RED);
    return true;
}
Hi, i'm having two issues with this code the first one is with spears ,if i have 20 spears in a stack and use exeta con vis to enchant the spears,all stack turns into just one spear.The second problem is this warnings during compilationerro1.png
 
Back
Top