• 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 WeaponType Fist TFS 1.0

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
1,633
Solutions
11
Reaction score
877
Hello Otland.

Here today I bring a modified code to be compatible with TFS 1.0

I don't take any credits for this code

I ONLY take credits for being the first to modify it for TFS 1.0 and releasing it on otland.

Now what does the code do?

It allows you to add this tag into items.xml

<attribute key="weaponType" value="fist"/>

And is fully functional, you can make any weapon into a fist weapon and it counts for your fist skill while killing with it. Yes I know this is possible thru lua. Blah blah blah, Idc, I wanted it for xml attribute and so here it is.


First open up your const.h

Replace
Code:
enumWeaponType_t{
WEAPON_NONE=0,
WEAPON_SWORD=1,
WEAPON_CLUB=2,
WEAPON_AXE=3,
WEAPON_SHIELD=4,
WEAPON_DIST=5,
WEAPON_WAND=6,
WEAPON_AMMO=7
};

with this

Code:
enum WeaponType_t {
    WEAPON_NONE = 0,
    WEAPON_SWORD = 1,
    WEAPON_CLUB = 2,
    WEAPON_AXE = 3,
    WEAPON_SHIELD = 4,
    WEAPON_DIST = 5,
    WEAPON_WAND = 6,
    WEAPON_AMMO = 7,
    WEAPON_FIST = 8
};

In combat.cpp replace

Code:
void Combat::addDistanceEffect(Creature* caster, const Position& fromPos, const Position& toPos, uint8_t effect)
{
    if (caster && effect == NM_SHOOT_WEAPONTYPE) {
        switch (caster->getWeaponType()) {
            case WEAPON_AXE:
                effect = NM_SHOOT_WHIRLWINDAXE;
                break;
            case WEAPON_SWORD:
                effect = NM_SHOOT_WHIRLWINDSWORD;
                break;
            case WEAPON_CLUB:
                effect = NM_SHOOT_WHIRLWINDCLUB;
                break;
            default:
                effect = NM_SHOOT_NONE;
                break;
        }
    }

with this
Code:
void Combat::addDistanceEffect(Creature* caster, const Position& fromPos, const Position& toPos, uint8_t effect)
{
    if (caster && effect == NM_SHOOT_WEAPONTYPE) {
        switch (caster->getWeaponType()) {
            case WEAPON_AXE:
                effect = NM_SHOOT_WHIRLWINDAXE;
                break;
            case WEAPON_SWORD:
                effect = NM_SHOOT_WHIRLWINDSWORD;
                break;
            case WEAPON_CLUB:
                effect = NM_SHOOT_WHIRLWINDCLUB;
                break;
            case WEAPON_FIST:
                effect = NM_SHOOT_LARGEROCK;
                break;
            default:
                effect = NM_SHOOT_NONE;
                break;
        }
    }

In Items.cpp replace
Code:
            } else if (tmpStrValue == "club") {
                it.weaponType = WEAPON_CLUB;
            } else if (tmpStrValue == "axe") {
                it.weaponType = WEAPON_AXE;
            } else if (tmpStrValue == "shield") {
                it.weaponType = WEAPON_SHIELD;
            } else if (tmpStrValue == "distance") {
                it.weaponType = WEAPON_DIST;
            } else if (tmpStrValue == "wand") {
                it.weaponType = WEAPON_WAND;
            } else if (tmpStrValue == "ammunition") {
                it.weaponType = WEAPON_AMMO;
            } else {
                std::cout << "[Warning - Items::parseItemNode] Unknown weaponType: " << valueAttribute.as_string() << std::endl;
            }

with this
Code:
            } else if (tmpStrValue == "club") {
                it.weaponType = WEAPON_CLUB;
            } else if (tmpStrValue == "axe") {
                it.weaponType = WEAPON_AXE;
            } else if (tmpStrValue == "shield") {
                it.weaponType = WEAPON_SHIELD;
            } else if (tmpStrValue == "distance") {
                it.weaponType = WEAPON_DIST;
            } else if (tmpStrValue == "wand") {
                it.weaponType = WEAPON_WAND;
            }else if (tmpStrValue == "ammunition") {
                it.weaponType = WEAPON_AMMO;
            }else if (tmpStrValue == "fist") {
                it.weaponType = WEAPON_FIST;
            } else {
                std::cout << "[Warning - Items::parseItemNode] Unknown weaponType: " << valueAttribute.as_string() << std::endl;
            }
 
In Player.cpp replace


Code:
    WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            attackSkill = getSkill(SKILL_SWORD, SKILL_LEVEL);
            break;
        }

        case WEAPON_CLUB: {
            attackSkill = getSkill(SKILL_CLUB, SKILL_LEVEL);
            break;
        }

        case WEAPON_AXE: {
            attackSkill = getSkill(SKILL_AXE, SKILL_LEVEL);
            break;
        }

        case WEAPON_DIST: {
            attackSkill = getSkill(SKILL_DIST, SKILL_LEVEL);
            break;
        }

        default: {
            attackSkill = 0;
            break;
        }
    }
    return attackSkill;
}

With this
Code:
    WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            attackSkill = getSkill(SKILL_SWORD, SKILL_LEVEL);
            break;
        }

        case WEAPON_CLUB: {
            attackSkill = getSkill(SKILL_CLUB, SKILL_LEVEL);
            break;
        }

        case WEAPON_AXE: {
            attackSkill = getSkill(SKILL_AXE, SKILL_LEVEL);
            break;
        }

        case WEAPON_FIST:{
            attackSkill = getSkill(SKILL_FIST, SKILL_LEVEL);
            break;
        }

        case WEAPON_DIST: {
            attackSkill = getSkill(SKILL_DIST, SKILL_LEVEL);
            break;
        }

        default: {
            attackSkill = 0;
            break;
        }
    }
    return attackSkill;
}

In spells.cpp replace

Code:
    if (needWeapon) {
        switch (player->getWeaponType()) {
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_AXE:
                break;

with this


Code:
    if (needWeapon) {
        switch (player->getWeaponType()) {
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_AXE:
            case WEAPON_FIST:
                break;

In tools.cpp replace

Code:
    switch (weaponType) {
        case WEAPON_SWORD: return "sword";
        case WEAPON_CLUB: return "club";
        case WEAPON_AXE: return "axe";
        case WEAPON_DIST: return "distance";
        case WEAPON_WAND: return "wand";
        case WEAPON_AMMO: return "ammunition";
        default: return std::string();

with this
Code:
    switch (weaponType) {
        case WEAPON_SWORD: return "sword";
        case WEAPON_CLUB: return "club";
        case WEAPON_AXE: return "axe";
        case WEAPON_DIST: return "distance";
        case WEAPON_WAND: return "wand";
        case WEAPON_AMMO: return "ammunition";
        case WEAPON_FIST: return "fist";
        default: return std::string();

in weapons.cpp find
Code:
        if (it.weaponType != WEAPON_NONE) {
            switch (it.weaponType) {
                case WEAPON_AXE:
                case WEAPON_SWORD:
                case WEAPON_CLUB: {
and replace it with this
Code:
        if (it.weaponType != WEAPON_NONE) {
            switch (it.weaponType) {
                case WEAPON_AXE:
                case WEAPON_SWORD:
                case WEAPON_CLUB:
                case WEAPON_FIST:{

and lastly still in weapons.cpp find
Code:
    WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            skill = SKILL_SWORD;
            return true;
        }

        case WEAPON_CLUB: {
            skill = SKILL_CLUB;
            return true;
        }

        case WEAPON_AXE: {
            skill = SKILL_AXE;
            return true;
        }

        default:
            break;
    }
    return false;
}

and replace with this
Code:
    WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            skill = SKILL_SWORD;
            return true;
        }

        case WEAPON_CLUB: {
            skill = SKILL_CLUB;
            return true;
        }

        case WEAPON_FIST: {
            skill = SKILL_FIST;
            return true;
        }

        case WEAPON_AXE: {
            skill = SKILL_AXE;
            return true;
        }

        default:
            break;
    }
    return false;
}

WORKS 100% ON TFS 1.0

Example in items.xml

Code:
    <item id="2218" article="a" name="hand of dapova">
        <attribute key="weight" value="10"/>
        <attribute key="defense" value="16"/>
        <attribute key="attack" value="16"/>
        <attribute key="weaponType" value="fist"/>
    </item>
 
Thanks for the code. Word of warning though, you may have to do some damage code modifications.
 
Where were you thinking?
The problem I faced was that with the custom fist weapons I created, the damage wasn't being modified at all by the attack of the fist weapons. I figured out that the useFist() method was being used to get damage for the custom fist weapons and that method did not have a way to retrieve the attack damage of the weapons. I'm sure there are other ways of going about it to fix that but I did the quick and dirty method and just added code to find the attack value of the fist weapon I was equipping.
 
I have thoroughly tested this code and it is dependant upon your fist level for attack, it gains skill tries, ect, ect.
If you would like to try my code out and report back where you found a bug please be more than welcome to try...
 
cpp_fail.jpg


i Got Error :(
 
The error is saying that all of them are undefined, which means you copied it wrong, because I didn't have you add the others they were already there they would already be defined. It's a problem with punctuation or something. Try reading the differences yourself and typing them out.
 
i saw i can't find anything about that part in item.cpp

Code:
            } else if (tmpStrValue == "club") {
                it.weaponType = WEAPON_CLUB;
            } else if (tmpStrValue == "axe") {
                it.weaponType = WEAPON_AXE;
            } else if (tmpStrValue == "shield") {
                it.weaponType = WEAPON_SHIELD;
            } else if (tmpStrValue == "distance") {
                it.weaponType = WEAPON_DIST;
            } else if (tmpStrValue == "wand") {
                it.weaponType = WEAPON_WAND;
            } else if (tmpStrValue == "ammunition") {
                it.weaponType = WEAPON_AMMO;
            } else {
                std::cout << "[Warning - Items::parseItemNode] Unknown weaponType: " << valueAttribute.as_string() << std::endl;
            }

so i dont need to edit? :eek:
 
okay the engine is created.. but i can't find anything from you edits in item.cpp so i edited nothing.. will try it now :)

Edit: You can help me to edit my Item.cpp?
Because in Engine Window comes how before edit the Messenge "WeaponType Fist not found"
 
Last edited:
Mircosoft Visual Studio Express 2013 für Windows Desktop

Omg.. my Fail.. i found the part of Item.cpp was a little bit other as yours...
But BIG THANKS For you Help and spend time. ;)

Its Works Fine!
 
Last edited:
Missed this before sending that last message. Great! Glad you figured it out, but this actually doesn't work perfect. I found the bug @Hmoobphajej had noted. It doesn't read the attack value of the weapon, there is one more spot you have to put it, I plan on updating this thread, but if you want to find the fix yourself, here is how you do it.

Find

WEAPON_CLUB

in your source, highlight it. Right-click on find all references. In the result box on the bottom it will show all the lines it is there, click on all of them and find the one that has all of the weapon types except fist, and add it there. It is just one spot I missed. Easy to find... Tested, it fixes the problem with attack not making a difference...
 
Got another problem now..

I tested my Assassin Class (Play with Fist Weapons)

added a fist weapons like this:
Code:
    <item id="22400" article="a" name="umbral masterblade">
        <attribute key="weight" value="5500" />
        <attribute key="defense" value="31" />
        <attribute key="attack" value="73" />
        <attribute key="weaponType" value="fist" />
        <attribute key="skillFist" value="8"/>

and the assassin have fist skill 80 but he deals only dmg with max 50.. What works wrong? Know
any fast idea? Its like he ignore the Fist Weapon :( Same Speed for Fist up without weapon.. i am confused

Domy
 
Last edited:
(Play with Fist Weapons)

If you would read the post above yours, it says how to fix the problem. I have already told you that was a bug; but this code is outdated, and before I update it here, I want to update mine to current source for tfs 1.1
 
Ah Damned! My Bad.. Thanks.. i will try to fix it.
Thanks 4 Help

Edit:

ALL WORKS FINE NOW THANKS!
 
Last edited:
No problem's bro, glad I could help. Like I said, gonna have to update this code, but right now I am sick, and I need to re-install my OS so I can wipe my system, then I will update everything to latest version of 1.1 for my server, and then probably all the links in my signature to 1.1 as well, with any and all bug fixes I have found since then..
 
Ahaha! I got it working as well, thanks to your previous comment about going through the source files and looking for WEAPON_CLUB. Only had to add WEAPON_FIST in two more spots for it to work. Thanks a bunch for awesome contributions! Goodwork and keep it up!
 
hi im test it on tfs 1.2 and i have this error
[Warning - Items::parseItemNode] Unknown weaponType: fist
 
Back
Top