• 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 Dual Wield || Weapons for tfs (1.x)

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

Hello! Your code is very similar to the one I need for my Sword art online server, could you help me adapt it for my server or something like that? Contact me please
 
Where the new position for 1.3?
C++:
else if (tmpStrValue == "defense") {
            it.defense = pugi::cast<int32_t>(valueAttribute.value());
        }
 
Back
Top