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

Feature Conjure runes on your backpadck

Stellow

C++/C#/PHP/LUA
Joined
Oct 23, 2008
Messages
1,106
Reaction score
214
Location
Germany
GitHub
eubrunomiguel
Look for this function on spells.cpp:
Code:
ReturnValue ConjureSpell::internalConjureItem(Player* player, uint32_t conjureId,
    uint32_t conjureCount, uint32_t reagentId, slots_t slot, bool test /*= false*/)

On line:
Code:
        Item* item = player->getInventoryItem(slot);

Change to:
Code:
Item* item = player->getFirstItemById(reagentId);

It will look for the first blank rune on your character, and the conjured rune will be placed where the blank rune was. For example, if you have it on your hand, the rune will be conjured on your hand. Same as arrow, and inventory.

Enjoy.
 
It's not working, in TFS 0.4.0 gives me this error.

src\spells.cpp 'class Player' has no member named 'getFirstItemById'

How can I fix it? Thanks in advance!
 
for 0.4
in player.cpp

under

Item* Player::getEquippedItem(slots_t slot) const
{
Item* item = getInventoryItem(slot);
if(!item)
return NULL;

switch(slot)
{
case SLOT_LEFT:
case SLOT_RIGHT:
return item->getWieldPosition() == SLOT_HAND ? item : NULL;

default:
break;
}

return item->getWieldPosition() == slot ? item : NULL;
}

-----------------------------ADD----------------------

Item* Player::getFirstItemById(uint32_t id) const
{
Item* tmpItem = NULL;
Container* tmpContainer = NULL;
std::list<Container*> listContainer;
for(int32_t slot = SLOT_FIRST; slot <= SLOT_LAST; slot++){
if((tmpItem = getInventoryItem((slots_t)slot))){
if(tmpItem->getID() == id){
return tmpItem;
}
else if((tmpContainer = tmpItem->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}

ItemList::const_iterator it;
while(!listContainer.empty()){
Container* container = listContainer.front();
listContainer.pop_front();
for(it = container->getItems(); it != container->getEnd(); ++it){
if((tmpItem = *it)){
if(tmpItem->getID() == id){
return tmpItem;
}
else if((tmpContainer = tmpItem->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}
}

return NULL;
}

_________________________________________________________________________

IN SPELLS.CPP CHAGE

if(!(item = player->getInventoryItem((slots_t)i)))

--------------TO-------------

if(!(item = player->getFirstItemById((uint32_t)i)))
_________________________________________________________________________

IN PLAYER.H

under

Item* getInventoryItem(slots_t slot) const;

----------------add--------------

Item* Player::getFirstItemById(uint32_t id) const;
 
@heba Thanks man. I haven't seen the post till now.

I got this error

player.h extra qualification 'Player::' on member 'getFirstItemById'
player.h *** [obj//player.o] Error 1

I'm using TFS 0.4 rev. 3884
 
@heba Thanks man. I haven't seen the post till now.

I got this error

player.h extra qualification 'Player::' on member 'getFirstItemById'
player.h *** [obj//player.o] Error 1

I'm using TFS 0.4 rev. 3884

You don't need to use its class scope on a function declaration. Instead of Player::... Remove Player::
 
Can you give me a more elaborate example? Where should I edit that? Thanks!
 
Should I change this line in player.h
Code:
Item* Player::getFirstItemById(uint32_t id) const;

To this?
Code:
Item* getFirstItemById(uint32_t id) const;

Is that the only change I need to make? Thanks!
 
I did that already.
Now I'm getting this error.

64-bit mode not compiled in
*** [obj/player.o] Error 1

Do you know how can I fix it?

Thanks and sorry for the inconveniences
 
Look for this function on spells.cpp:
Code:
ReturnValue ConjureSpell::internalConjureItem(Player* player, uint32_t conjureId,
    uint32_t conjureCount, uint32_t reagentId, slots_t slot, bool test /*= false*/)

On line:
Code:
        Item* item = player->getInventoryItem(slot);

Change to:
Code:
Item* item = player->getFirstItemById(reagentId);

It will look for the first blank rune on your character, and the conjured rune will be placed where the blank rune was. For example, if you have it on your hand, the rune will be conjured on your hand. Same as arrow, and inventory.

Enjoy.
ur server do not have that function, you can always add it https://github.com/TwistedScorpio/O...d3317c13bf8d86485/source/player.cpp#L345-L378
also you need to add it to players.h


How do you not check the amount of blank rune that is in the backpack? Ex: If you have 30 or 100 blank rune works out to conjure ...
 
How to add it here?

I'm using tfs 1.2
C++:
bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    int32_t value;
    if (player->getStorageValue(666, value) || player->getStorageValue(777, value)) {
        if (value > 0) {
            player->sendCancelMessage("You cannot conjure items inside the arena.");
            return false;
        }
    }

    const uint32_t conjureCost = getManaCost(creature->getPlayer());
    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
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

            ReturnValue ret = g_game.internalAddItem(parent, newItem);
            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
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

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

            g_game.startDecay(newItem);

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

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

            // right arm conjure
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

            ReturnValue ret = g_game.internalAddItem(parent, newItem);
            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;
}
 
How to add it here?

I'm using tfs 1.2
C++:
bool ConjureSpell::conjureItem(Creature* creature) const
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    int32_t value;
    if (player->getStorageValue(666, value) || player->getStorageValue(777, value)) {
        if (value > 0) {
            player->sendCancelMessage("You cannot conjure items inside the arena.");
            return false;
        }
    }

    const uint32_t conjureCost = getManaCost(creature->getPlayer());
    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
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

            ReturnValue ret = g_game.internalAddItem(parent, newItem);
            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
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

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

            g_game.startDecay(newItem);

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

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

            // right arm conjure
            Cylinder* parent = item->getParent();
            g_game.internalRemoveItem(item);

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

            ReturnValue ret = g_game.internalAddItem(parent, newItem);
            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