• 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
95
Best answers
10
Reaction score
89
Location
Bialystok, Poland
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 :)
 

70011983

Ners
Joined
Nov 21, 2011
Messages
354
Best answers
1
Reaction score
51
Location
Croatia
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.
 
OP
kor

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
95
Best answers
10
Reaction score
89
Location
Bialystok, Poland
Thanks :) My servers are on 0.4 and 1.3 so I didn't have possibility to test it on OTX.
 
OP
kor

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
95
Best answers
10
Reaction score
89
Location
Bialystok, Poland
@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).
 

rpierott

Premium User
Premium User
Joined
Dec 2, 2008
Messages
16
Best answers
0
Reaction score
1
@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:

Pox

Active Member
Joined
Apr 28, 2020
Messages
49
Best answers
1
Reaction score
28
@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:

rpierott

Premium User
Premium User
Joined
Dec 2, 2008
Messages
16
Best answers
0
Reaction score
1
@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?
 

Pox

Active Member
Joined
Apr 28, 2020
Messages
49
Best answers
1
Reaction score
28
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.
 

rpierott

Premium User
Premium User
Joined
Dec 2, 2008
Messages
16
Best answers
0
Reaction score
1
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
 
Top