• 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 Quiver [TFS 1.X + 0.X]

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
252
Solutions
13
Reaction score
410
Location
Bialystok, Poland
GitHub
rookgaard
YouTube
Rookgaard
Hello. Inspired @xydius solution I've created possibility to make use for quivers for both TFS (1.X based on otland/forgottenserver (https://github.com/otland/forgottenserver) and 0.X on Fir3element/3777 (https://github.com/Fir3element/3777)).

I won't post what to change in what line, instead here you have GitHub branches:
My solution will require creating an item which have name set to Quiver:
- TFS 1.X
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)
- TFS 0.X
Lua:
local item = doCreateItemEx(11241, 1)
doItemSetAttribute(item, 'name', 'Quiver')
doItemSetAttribute(item, 'article', 'a')
doPlayerAddItemEx(cid, item)

Created Quiver will:
  • not allow to put inside otems other than ammo (container.cpp part)
  • have max items amount set to 4 both in "look at" and "put into" (container.h, item.cpp and protocolgame.cpp part); if you don't want to set max amout, just skip that changes
  • get first matching ammo item from Quiver in arrow slot
  • allow in newer versions to put Quiver in arrow slot without enabling CLASSIC_EQUIPMENT_SLOTS option

Hope you enjoy :)
 
Works just fine so far, nice one!
Though on OTX3 the last change is in protocolgamebase.cpp instead of protocolgame.cpp, the rest is on spot.
 
@rpierott answering your question from other thread (I would like to move discussion here to bring attention ;) ) - you can create talkaction like /quiver or add aid/uid to some chest/lever where you put that part (in onUse or onSay function).
 
@kor Alright, I will try it as soon as I get home and give you feedback. But thanks for the effort put to help me!
Post automatically merged:

@kor, wonderful, worked perfectly! Thank you very much brother! You are the best! :D
 
Last edited:
@kor

This:
C++:
getName() == "Quiver"

Can be replaced with:
C++:
getName().find("quiver") != std::string::npos

So you can add custom items and name them "Whatever quiver" and still works


Don't know if I did something wrong, but if my backpack is full and slots available in quiver and you try to buy stuff from NPC for example, money will be removed but you wont get the item.
 
Last edited:
@kor

This:
C++:
getName() == "Quiver"

Can be replaced with:
C++:
getName().find("quiver") != std::string::npos

So you can add custom items and name them "Whatever quiver" and still works


Don't know if I did something wrong, but if my backpack is full and slots available in quiver and you try to buy stuff from NPC for example, money will be removed but you wont get the item.
Nice add man!

Did you figure out how to fix the buy issue?
 
Nice add man!

Did you figure out how to fix the buy issue?

Yes I did.

Not sure if all this needs to be added, but it works for me so..

in container.cpp

In function ReturnValue Container::queryMaxCount

Below this:
C++:
    if (hasBitSet(FLAG_NOLIMIT, flags)) {
        maxQueryCount = std::max<uint32_t>(1, count);
        return RETURNVALUE_NOERROR;
    }

Add:
C++:
    if (getName().find("quiver") != std::string::npos && !(item->getSlotPosition() & SLOTP_AMMO)) {
        return RETURNVALUE_NOTENOUGHROOM;
    }

In function
Cylinder* Container::queryDestination

Below this:
C++:
const Item* item = thing.getItem();
    if (!item) {
        return this;
    }

Add:
C++:
    if (getName().find("quiver") != std::string::npos && !(item->getSlotPosition() & SLOTP_AMMO)) {
        return this;
    }

Now when you buy stuff that is not itemtype Ammo, it wont do anything.
 
Yes I did.

Not sure if all this needs to be added, but it works for me so..

in container.cpp

In function ReturnValue Container::queryMaxCount

Below this:
C++:
    if (hasBitSet(FLAG_NOLIMIT, flags)) {
        maxQueryCount = std::max<uint32_t>(1, count);
        return RETURNVALUE_NOERROR;
    }

Add:
C++:
    if (getName().find("quiver") != std::string::npos && !(item->getSlotPosition() & SLOTP_AMMO)) {
        return RETURNVALUE_NOTENOUGHROOM;
    }

In function
Cylinder* Container::queryDestination

Below this:
C++:
const Item* item = thing.getItem();
    if (!item) {
        return this;
    }

Add:
C++:
    if (getName().find("quiver") != std::string::npos && !(item->getSlotPosition() & SLOTP_AMMO)) {
        return this;
    }

Now when you buy stuff that is not itemtype Ammo, it wont do anything.
Hey @Pox you are the best! Nice add! I didn't see this option... :D
 
it works, but also you can have a normal backpack in a arrow slow and bolts inside it and it also will work as quiver :s
Post automatically merged:

and also putting other items than ammo to quiver is possible.
maybe I did something wrong?
 
Thanks to @marek12 I've found a bug in my feature. For those who already using his, I've updated my code.
make sure that the quiver you are using is spelled with capital Q, otherwise it won't work.
example: if you got item which is names as a "quiver" it wont work. It has to be "Quiver"
 
Quiver can have other quiver inside bug do you can fix that ?
 
Quiver can have other quiver inside bug do you can fix that ?
In case of 1.x version in container.cpp replace:
Code:
if (getName() == "Quiver" && !(item->getSlotPosition() & SLOTP_AMMO)) {
with:
Code:
if (getName() == "Quiver" && (!(item->getSlotPosition() & SLOTP_AMMO) || item->getName() == "Quiver")) {
 
i followed the steps the item recognizes but it doesn't attack

my doubts -> HERE
 
Back
Top