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

TFS 1.X+ TFS 1.3 default Combat::getCombatDamage

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
2,326
Solutions
68
Reaction score
999
So im trying to change the way damage is calculated with weapons, spells, ect.

I need help with what mina,maxa,minb,maxb mean.
Code:
void Combat::setPlayerCombatValues(formulaType_t formulaType, double mina, double minb, double maxa, double maxb)
{
    this->formulaType = formulaType;
    this->mina = mina;
    this->minb = minb;
    this->maxa = maxa;
    this->maxb = maxb;
}

This is the code I have modified. There seems to be a problem with the switch statement when I try to compile.
Code:
CombatDamage Combat::getCombatDamage(Creature* creature, Creature* target) const
{
    CombatDamage damage;
    damage.origin = params.origin;
    damage.primary.type = params.combatType;
    int32_t min, max;
   
    if (creature && creature->getCombatValues(min, max)) {
        damage.primary.value = normal_random(min, max);
        return damage;
    }

    const Player* player = creature->getPlayer();

    if (player) {
        switch (formulaType) {
        case COMBAT_FORMULA_LEVELMAGIC:
            int32_t levelFormula = player->getLevel() + player->getMagicLevel();
            damage.primary.value = normal_random(
                static_cast<int32_t>(levelFormula + mina),
                static_cast<int32_t>(levelFormula + maxa)
            );
            break;

        case COMBAT_FORMULA_SKILL:
            Item* tool = player->getWeapon();
            const Weapon* weapon = g_weapons->getWeapon(tool);
            if (weapon) {
                damage.primary.value = normal_random(
                    static_cast<int32_t>((weapon->getWeaponDamage(player, target, tool, true) + player->getSkillLevel(player->getWeaponSkill(player->getWeapon()))) + mina),
                    static_cast<int32_t>((weapon->getWeaponDamage(player, target, tool, true) + player->getSkillLevel(player->getWeaponSkill(player->getWeapon()))) + maxa)
                );

                damage.secondary.type = weapon->getElementType();
                damage.secondary.value = weapon->getElementDamage(player, target, tool);
            }
            else {
                damage.primary.value = normal_random(
                    static_cast<int32_t>(mina),
                    static_cast<int32_t>(maxa)
                );
            }
            break;

        default:
            damage.primary.value = normal_random(
                static_cast<int32_t>(mina),
                static_cast<int32_t>(maxa)
            );
            break;

        }
    }

    return damage;
}

Thank for any help guys.
 
Back
Top