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

Quiver for paladins - tfs1.X

@jackl90 @froy
C++:
            if (Container* container = ammoItem->getContainer())
            {
                if (container->getID() == 1999) // change quiver id here
                {
                    for (ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance())
                    {
                        const ItemType& itr = Item::items[(*iter)->getID()];
                        if (itr.ammoType == it.ammoType)
                        {
                            item = (*iter);
                            return item;
                        }
                    }
                }
            }
any method to block for example items diferent of xxx id inside container->getID() == 1999 ? for example?
because i tested here, i can put a normal backpack inside quiver container and work normally like a quiver.
 
@jackl90 @froy
C++:
            if (Container* container = ammoItem->getContainer())
            {
                if (container->getID() == 1999) // change quiver id here
                {
                    for (ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance())
                    {
                        const ItemType& itr = Item::items[(*iter)->getID()];
                        if (itr.ammoType == it.ammoType)
                        {
                            item = (*iter);
                            return item;
                        }
                    }
                }
            }

in this case for example, how add a condition if container is different of id 1999 no work this system?
 
because people can put other container inside container 1999 and this code will work too...
maybe is this part?

C++:
iter.hasNext(); iter.advance()
 
Hello guys.
I just added the code preseted on this thread inside player.cpp on my fork from tfs 1.3 and made:
Lua:
mkdir build   
cd build
cmake ..           
make
It compiled just fine as usually and I'm using the new tfs file generated. But when I get into the game and try to equip a backpack (example /i 1988) it just says: [CODE] you cannot dress this object there [/CODE]

I'm starting with programming, I'm really lost and I don't know what is going wrong. I already tried evetything. Could someone be so kind to help me with this issue? This is my first source modification!

Thank you all in advance!
 
Hello @rpierott, can you check if it happen also using my solution - Feature - Quiver [TFS 1.X + 0.X]?
@kor No, it is the solution presented on this thread only. I plan to use your solution after I see this one working properly because since I never made any changes in source code, I want to see if my changes generate any effect inside the game before moving to some better-developed solutions like yours.

Do you have any suggestions that could help me see if my modifications are being considered or to make it work?
 
@rpierott author's solution don't include slot accessibility check (that's why you can't wear backpack in arrow slot) - so I asked if my solution will work for you.

@pink_panther it will use arrows in normal order, so if you have (looking from left to right), 100 poison arrow, 100 arrow and 100 burst arrow it will shoot them in that order.
 
@kor I see, I saw ppl saying that now all containers are usable as quiver. I will definitely check you post today.

To create a Quiver, in your post you say>
Lua:
local item = Game.createItem(11241, 1) -- example ID, in my case Expedition Backpack
item:setAttribute(ITEM_ATTRIBUTE_NAME, 'Quiver')
item:setAttribute(ITEM_ATTRIBUTE_ARTICLE, 'a') -- in my case Expedition Backpack have prefix "an", so I'm changing it here
player:addItemEx(item)

Where should I put that? Should I create a spell and invoke in game to test?
 
because people can put other container inside container 1999 and this code will work too...
maybe is this part?

C++:
iter.hasNext(); iter.advance()

So you can put another content inside the quiver and still the code works, solution?
 
metod for quiver implement

Item* Player::getWeapon(slots_t slot, bool ignoreAmmo) const
{
Item* item = inventory[slot];
if (!item) {
return nullptr;
}

WeaponType_t weaponType = item->getWeaponType();
if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO) {
return nullptr;
}

if (!ignoreAmmo && weaponType == WEAPON_DISTANCE) {
const ItemType& it = Item::items[item->getID()];
if (it.ammoType != AMMO_NONE) {

Item* ammoItem = inventory[CONST_SLOT_AMMO];

if (!ammoItem || ammoItem->getAmmoType() != it.ammoType) {
return nullptr;
}
if (Container* container = ammoItem->getContainer())
{
for (ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance())
{
const ItemType& itr = Item::items[(*iter)->getID()];
if (itr.ammoType == it.ammoType)
{
item = (*iter);
//return item;
}
}
}
//item = ammoItem;
}
}
return item;
}
Post automatically merged:

method for implement quiver in tfs 0.4

Item* Player::getWeapon(slots_t slot, bool ignoreAmmo) const
{
Item* item = inventory[slot];
if (!item) {
return nullptr;
}

WeaponType_t weaponType = item->getWeaponType();
if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO) {
return nullptr;
}

if (!ignoreAmmo && weaponType == WEAPON_DISTANCE) {
const ItemType& it = Item::items[item->getID()];
if (it.ammoType != AMMO_NONE) {

Item* ammoItem = inventory[CONST_SLOT_AMMO];

if (!ammoItem || ammoItem->getAmmoType() != it.ammoType) {
return nullptr;
}
if (Container* container = ammoItem->getContainer())
{
for (ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance())
{
const ItemType& itr = Item::items[(*iter)->getID()];
if (itr.ammoType == it.ammoType)
{
item = (*iter);
//return item;
}
}
}
//item = ammoItem;
}
}
return item;
}
 
Hello fellow otlanders heres a little edit i did for my custom ot and i felt like sharing it.

First of all what is a quiver? A quiver is a container where u can put your arrows/bolts and use them while equiped with a bow/crossbow like show in the picture below.

View attachment 30370

EDIT

  1. First go to your source files and look for player.cpp
  2. Then look for
    Code:
    Item* Player::getWeapon(slots_t slot, bool ignoreAmmo) const
    mine was at line 230 so your should be around that line also.
  3. In that function look for
    Code:
    if (it.ammoType != AMMO_NONE) {
                Item* ammoItem = inventory[CONST_SLOT_AMMO];
    and right below that just add
    Code:
    /*edit for quiver*/
                if (!ammoItem)
                {
                    return nullptr;
                }
             
                if (Container* container = ammoItem->getContainer())
                {
                    for (ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance())
                    {
                        const ItemType& itr = Item::items[(*iter)->getID()];
                        if (itr.ammoType == it.ammoType)
                        {
                            item = (*iter);
                            return item;
                        }
                    }
                }
                /*end of edit*/
  4. Thats it LoL.
  5. To add an item to add as a quiver remember to edit it with an itemEditor so it can work as a container and add the attribute to the item like this
    Code:
    <attribute key="containerSize" value="20" />
    and that should do.
FAQ
Q.- do you "bla bla bla" for tfs 0.4?
A.- No, i dont. Move on already guys.
Sadly not working with TFS 1.3 as it seems like. :/
 
Back
Top