• 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!

weapon type

tnecniiv

scripter to be
Joined
Jan 6, 2012
Messages
294
Solutions
3
Reaction score
23
i updated all my .cpp files and const.h file to include fist as a weapon type.
but now it doesnt add the attack of the weapon it will only go based on fist fighting skill
the damage out put is the same as the damage output as having no weapon equipped.
the weapon does how ever register as fist fighting weapon and will increase my fist fighting skill.
i am running tfs 1.2 i had already recompiled my server
 
Solution
i found the solution to this when i was going through the files to fix my post.
so ill explain a little about this
what this is to make fist fighting be an attribute that you can put on weapons and make weapons based off fist fighting instead of sword skill axe and so forth. this is based off tfs 1.2

my problem was in my .cpp files which you use to compile the server
note you have to edit these files in order make this happen

for starters in your const.h
look for this
Code:
enum WeaponType_t {
    WEAPON_NONE = 0,
    WEAPON_SWORD = 1,
    WEAPON_CLUB = 2,
    WEAPON_AXE = 3,
    WEAPON_SHIELD = 4,
    WEAPON_DISTANCE = 5,
    WEAPON_WAND = 6,
    WEAPON_AMMO = 7,
};
and change to this
Code:
enum WeaponType_t {
    WEAPON_NONE = 0...
he's referring to the fact that you didn't bother to post any changes you made to the source or the script that isn't working with your weapon(s)
 
i found the solution to this when i was going through the files to fix my post.
so ill explain a little about this
what this is to make fist fighting be an attribute that you can put on weapons and make weapons based off fist fighting instead of sword skill axe and so forth. this is based off tfs 1.2

my problem was in my .cpp files which you use to compile the server
note you have to edit these files in order make this happen

for starters in your const.h
look for this
Code:
enum WeaponType_t {
    WEAPON_NONE = 0,
    WEAPON_SWORD = 1,
    WEAPON_CLUB = 2,
    WEAPON_AXE = 3,
    WEAPON_SHIELD = 4,
    WEAPON_DISTANCE = 5,
    WEAPON_WAND = 6,
    WEAPON_AMMO = 7,
};
and change to this
Code:
enum WeaponType_t {
    WEAPON_NONE = 0,
    WEAPON_SWORD = 1,
    WEAPON_CLUB = 2,
    WEAPON_AXE = 3,
    WEAPON_SHIELD = 4,
    WEAPON_DISTANCE = 5,
    WEAPON_WAND = 6,
    WEAPON_AMMO = 7,
    WEAPON_FIST = 8
};

in your combat.cpp
change this
Code:
        switch (player->getWeaponType()) {
            case WEAPON_AXE:
                effect = CONST_ANI_WHIRLWINDAXE;
                break;
            case WEAPON_SWORD:
                effect = CONST_ANI_WHIRLWINDSWORD;
                break;
            case WEAPON_CLUB:
                effect = CONST_ANI_WHIRLWINDCLUB;
                break;
            default:
                effect = CONST_ANI_NONE;
                break;
        }
    }
to this
Code:
        switch (player->getWeaponType()) {
            case WEAPON_AXE:
                effect = CONST_ANI_WHIRLWINDAXE;
                break;
            case WEAPON_SWORD:
                effect = CONST_ANI_WHIRLWINDSWORD;
                break;
            case WEAPON_CLUB:
                effect = CONST_ANI_WHIRLWINDCLUB;
                break;
            case WEAPON_FIST:
                effect = CONST_ANI_LARGEROCK;
                break;
            default:
                effect = CONST_ANI_NONE;
                break;
        }
    }
in your items.cpp
change this
Code:
                it.weaponType = WEAPON_SWORD;
            } 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_DISTANCE;
            } 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;
            }
to this
Code:
                it.weaponType = WEAPON_SWORD;
            } 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_DISTANCE;
            } 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 your player.cpp
change this
Code:
WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            attackSkill = getSkillLevel(SKILL_SWORD);
            break;
        }

        case WEAPON_CLUB: {
            attackSkill = getSkillLevel(SKILL_CLUB);
            break;
        }

        case WEAPON_AXE: {
            attackSkill = getSkillLevel(SKILL_AXE);
            break;
        }

        case WEAPON_DISTANCE: {
            attackSkill = getSkillLevel(SKILL_DISTANCE);
            break;
        }

        default: {
            attackSkill = 0;
            break;
        }
    }
    return attackSkill;
}
to this
Code:
WeaponType_t weaponType = item->getWeaponType();
    switch (weaponType) {
        case WEAPON_SWORD: {
            attackSkill = getSkillLevel(SKILL_SWORD);
            break;
        }

        case WEAPON_CLUB: {
            attackSkill = getSkillLevel(SKILL_CLUB);
            break;
        }

        case WEAPON_AXE: {
            attackSkill = getSkillLevel(SKILL_AXE);
            break;
        }
       
        case WEAPON_FIST: {
            attackSkill = getSkillLevel(SKILL_FIST);
            break;
        }

        case WEAPON_DISTANCE: {
            attackSkill = getSkillLevel(SKILL_DISTANCE);
            break;
        }

        default: {
            attackSkill = 0;
            break;
        }
    }
    return attackSkill;
}
in spells.cpp
change this
Code:
    if (needWeapon) {
        switch (player->getWeaponType()) {
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_AXE:
                break;
to this
Code:
    if (needWeapon) {
        switch (player->getWeaponType()) {
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_AXE:
            case WEAPON_FIST:
                break;
in tools.cpp
change this
Code:
std::string getWeaponName(WeaponType_t weaponType)
{
    switch (weaponType) {
        case WEAPON_SWORD: return "sword";
        case WEAPON_CLUB: return "club";
        case WEAPON_AXE: return "axe";
        case WEAPON_DISTANCE: return "distance";
        case WEAPON_WAND: return "wand";
        case WEAPON_AMMO: return "ammunition";
        default: return std::string();
    }
}
to this
Code:
std::string getWeaponName(WeaponType_t weaponType)
{
    switch (weaponType) {
        case WEAPON_SWORD: return "sword";
        case WEAPON_CLUB: return "club";
        case WEAPON_AXE: return "axe";
        case WEAPON_DISTANCE: return "distance";
        case WEAPON_WAND: return "wand";
        case WEAPON_AMMO: return "ammunition";
        case WEAPON_FIST: return "fist";
        default: return std::string();
    }
}
this is where i messed up. i had overlooked a simple code in weapons.cpp and forgot to add fist here which would allow you to wield a weapon and have your fist fighting+ your weapon attack. to resolve this you must open your weapons.cpp
and change this
Code:
        switch (it.weaponType) {
            case WEAPON_AXE:
            case WEAPON_SWORD:
            case WEAPON_CLUB:        {
                WeaponMelee* weapon = new WeaponMelee(&scriptInterface);
                weapon->configureWeapon(it);
                weapons[i] = weapon;
                break;
            }
to this

Code:
        switch (it.weaponType) {
            case WEAPON_AXE:
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_FIST:            {
                WeaponMelee* weapon = new WeaponMelee(&scriptInterface);
                weapon->configureWeapon(it);
                weapons[i] = weapon;
                break;
            }
and also in weapons.cpp
change this aswell
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;
}
to this aswell
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;
        }
       
        case WEAPON_FIST: {
            skill = SKILL_FIST;
            return true;
        }

        default:
            break;
    }
    return false;
}
then all you have to do is recompile your server and it should work as well.
 
Solution
Back
Top