Feature Dual Wield || Weapons for tfs (1.x)

EvilSkillz

Back
Joined
Jul 12, 2012
Messages
1,709
Reaction score
297
Location
Egypt - Cairo
Hello OTLand :)
today i've made this feature for tfs 1.x
tested and working very well

first we start with code
at enums.h
find
Code:
ITEM_ATTRIBUTE_DOORID = 4194304
and add this after
Code:
ITEM_ATTRIBUTE_DUAL = 8388608
at item.cpp
find
Code:
case ATTR_EXTRADEFENSE: {
            int32_t extraDefense;
            if (!propStream.read<int32_t>(extraDefense)) {
                return ATTR_READ_ERROR;
            }

            setIntAttr(ITEM_ATTRIBUTE_EXTRADEFENSE, extraDefense);
            break;
        }
and add this after
Code:
case ATTR_DUAL: {
            bool dual;
            if (!propStream.read<bool>(dual)) {
                return ATTR_READ_ERROR;
            }

            break;
        }
find
Code:
if (hasAttribute(ITEM_ATTRIBUTE_EXTRADEFENSE)) {
        propWriteStream.write<uint8_t>(ATTR_EXTRADEFENSE);
        propWriteStream.write<int32_t>(getIntAttr(ITEM_ATTRIBUTE_EXTRADEFENSE));
    }
and add this after
Code:
if (hasAttribute(ITEM_ATTRIBUTE_DUAL)) {
        return;
    }
at item.h
find
Code:
ATTR_SHOOTRANGE = 33,
and add this after
Code:
ATTR_DUAL = 34
find
Code:
int32_t getDefense() const {
            if (hasAttribute(ITEM_ATTRIBUTE_DEFENSE)) {
                return getIntAttr(ITEM_ATTRIBUTE_DEFENSE);
            }
            return items[id].defense;
        }
and add this after
Code:
bool isDual() const {
            if (hasAttribute(ITEM_ATTRIBUTE_DUAL)) {
                return bool(ITEM_ATTRIBUTE_DUAL);
            }
            return items[id].dual;
        }
at items.cpp
find
Code:
armor = 0;
and add this after
Code:
dual = false;
find
Code:
else if (tmpStrValue == "defense") {
            it.defense = pugi::cast<int32_t>(valueAttribute.value());
        }
and add this after
Code:
else if (tmpStrValue == "dual") {
            it.dual = valueAttribute.as_bool();
        }
at items.h
find
Code:
int32_t runeLevel;
and add this after
Code:
bool dual;
at luascript.cpp
find
Code:
registerEnum(ITEM_ATTRIBUTE_ATTACK)
add this after
Code:
registerEnum(ITEM_ATTRIBUTE_DUAL)
at player.cpp
find
Code:
case CONST_SLOT_RIGHT:
and replace this
Code:
if (item->getWeaponType() != WEAPON_SHIELD)
with this
Code:
if (item->getWeaponType() != WEAPON_SHIELD && !item->isDual())
find
Code:
else if (!leftItem->isWeapon() || !item->isWeapon()
and after this
Code:
|| type == WEAPON_AMMO
add this code
Code:
|| leftItem->isDual() && item->isDual()
find
Code:
case CONST_SLOT_LEFT:
and replace this
Code:
if (!item->isWeapon() || item->getWeaponType() == WEAPON_SHIELD)
with this
Code:
if (!item->isWeapon() && !item->isDual() || item->getWeaponType() == WEAPON_SHIELD)
find
Code:
else if (!rightItem->isWeapon() || !item->isWeapon()
and after this
Code:
type == WEAPON_AMMO
add this code
Code:
|| rightItem->isDual() && item->isDual()
at tools.cpp
find
Code:
else if (str == "defense") {
        return ITEM_ATTRIBUTE_DEFENSE;
    }
and add this after
Code:
else if (str == "dual") {
        return ITEM_ATTRIBUTE_DUAL;
    }
:) now we have done the dual code
how it work ?
at items.xml u can add this attribute key to any weapon
Code:
<attribute key="dual" value="1" />
Good Luck
Regards : EvilSkillz
 

Simon Here

不要直视陌生人的
Joined
Jun 2, 2012
Messages
397
Reaction score
386
Location
France/Poland
niceee :D Again something really nice from you :D
Ill try it soon for 100%

love ya Evil <3
 

gurden

i need support for my server, good scripter!
Joined
May 19, 2009
Messages
520
Reaction score
4
Location
Sweden
Nice work, this is not TFS-1.0 just write TFS-1.1 if its only for 1.1. Cause this wont work in tfs-1.0 sry
 

Evil Hero

Legacy Member
Joined
Dec 12, 2007
Messages
1,144
Reaction score
501
Location
Germany
You are missing an important part in your system.
Let's say you equip 2 different weapons at the same time ex: knight axe and fire axe.
Knight axe is equipped at left hand, then the server will take the knight axe always as the attack weapon, basicly you can say you can exploit this in a way like you equip a really good weapon in your left hand and in your right hand you just put a knive or so, you'll still deal the damage from the good weapon doesn't matter if you have a low weapon in the other hand.

You need to edit Item* Player::getWeapon(bool ignoreAmmo /*= false*/) in player.cpp and make weapon a list instead of an item and store the found weapons in it to switch index between the 2 weapons.
I know this sounds complicated but it's not so hard todo but it's necessary in this case.
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,216
Reaction score
372
You are missing an important part in your system.
Let's say you equip 2 different weapons at the same time ex: knight axe and fire axe.
Knight axe is equipped at left hand, then the server will take the knight axe always as the attack weapon, basicly you can say you can exploit this in a way like you equip a really good weapon in your left hand and in your right hand you just put a knive or so, you'll still deal the damage from the good weapon doesn't matter if you have a low weapon in the other hand.

You need to edit Item* Player::getWeapon(bool ignoreAmmo /*= false*/) in player.cpp and make weapon a list instead of an item and store the found weapons in it to switch index between the 2 weapons.
I know this sounds complicated but it's not so hard todo but it's necessary in this case.
Good eye!
 

Nu77

Active Member
Joined
Jul 19, 2014
Messages
112
Reaction score
45
You are missing an important part in your system.
Let's say you equip 2 different weapons at the same time ex: knight axe and fire axe.
Knight axe is equipped at left hand, then the server will take the knight axe always as the attack weapon, basicly you can say you can exploit this in a way like you equip a really good weapon in your left hand and in your right hand you just put a knive or so, you'll still deal the damage from the good weapon doesn't matter if you have a low weapon in the other hand.

You need to edit Item* Player::getWeapon(bool ignoreAmmo /*= false*/) in player.cpp and make weapon a list instead of an item and store the found weapons in it to switch index between the 2 weapons.
I know this sounds complicated but it's not so hard todo but it's necessary in this case.
Other points:

1. If a player equip two different weapons like a spike sword in left hand and a knight axe on the right, the selected weapon will be the spike sword and the selected skill too, this will merge the sword with axe attack and calculate from sword skill.

2. If a player want equip two weapons with elemental damage, like a serpent sword and a fire sword, only the left weapon with elemental damage will be calculated.
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,216
Reaction score
372
@EvilSkillz you got this! I know you got some evil skillz :D

If I knew how to fix what they are talking about, I would already have messaged you trying to help. I don't think it's likely for this to be accepted on github *crosses fingers, but this is still very appreciated for those who can add it to their source. Thanks for the release :D
 

Szare Jajko

Member
Joined
Jul 24, 2008
Messages
39
Reaction score
1
Few minutes and I've got it on my 1.2 TFS - thanks. One question 1.x it' mean 1.2 too. Next time use 1.0 or 1.1 tag. On TFS 1.2 in enums.h u'll not find
ITEM_ATTRIBUTE_DOORID = 4194304
but
ITEM_ATTRIBUTE_DOORID = 1 << 22,
 
Last edited:

samco

4x4 Developer.
Joined
Jul 3, 2007
Messages
908
Reaction score
183
Location
Spain
Beware this system is not working properly as full dual-wield sys
 

Bolmack

Member
Joined
Mar 7, 2015
Messages
91
Reaction score
6
@EvilSkillz So, it works in 1.0 too?

And a question, if i made a bow that could be used one handed, and i equip bows in both hands, will i shoot twice?
 
OP
EvilSkillz

EvilSkillz

Back
Joined
Jul 12, 2012
Messages
1,709
Reaction score
297
Location
Egypt - Cairo
@EvilSkillz So, it works in 1.0 too?

And a question, if i made a bow that could be used one handed, and i equip bows in both hands, will i shoot twice?
my system need to be fixed first , u can wear any 2 items if they got attribute " dual " but it always hit right hand only ..
i will fix it to calculate dmg from both hands

and this for 1.1 , 1.2
for 1.0 i will post it when i fix both codes
 
Top