Quiver for paladins - tfs1.X

xydius

Just an otland wanderer
Joined
Feb 25, 2016
Messages
43
Reaction score
30
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.

quiver demo.png

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.
 

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
28
this can be done without sources editing i think
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,401
Reaction score
1,977
i do that loooong time ago

never said you couldn't do it, it's not as flexible to set up, you most likely had to script each weapon to get it to pull the ammo out of the quiver
probably have to do it every time you make a new weapon, which is the reason why it's more flexible (and easier) to create something in c++
not everything is so godly in lua only, why would you use an embeddable language and completely ignore the parent language?
 

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
28
never said you couldn't do it, it's not as flexible to set up, you most likely had to script each weapon to get it to pull the ammo out of the quiver
probably have to do it every time you make a new weapon, which is the reason why it's more flexible (and easier) to create something in c++
not everything is so godly in lua only, why would you use an embeddable language and completely ignore the parent language?
Yeah i see now, thanks for the feature
 

Redleaf

Eternal Wanderer
Joined
Sep 21, 2012
Messages
444
Reaction score
94
Location
Tampa, Florida
See the very bottom of his post. You can always link this thread in a support thread of your own and see if anyone would help you convert it, but doesn't seem like the thread starter is interested in coding for outdated servers (rightfully so).

FAQ
Q.- do you "bla bla bla" for tfs 0.4?
A.- No, i dont. Move on already guys.
Regards,
Cody
 

Togu

Active Member
Joined
Jun 22, 2018
Messages
240
Reaction score
93
Location
Brazil
How do i choose the item to display? Not working here.
 

djblah

Banned User
Joined
Oct 15, 2010
Messages
59
Reaction score
12
I hope I'm not wrong but the only thing I see that changes in tfs 0.4.0

nullptr ------> c++11
NULL -------> TFS 0.4.0
IN PLAYER.CPP -------> TFS 0.4.0

C++:
Item* ammoItem = getInventoryItem(SLOT_AMMO);
down this line you hit this

C++:
 if (!ammoItem)
            {
                return NULL;
            }
          
            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 = (*iter); ------------------->
YOU WANT ON THIS LINE THERE IS AN ERRO BY THE *

I have not tested
 
Top