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

C++ Weapon works as shield

beliar34

Member
Joined
Feb 28, 2012
Messages
307
Solutions
7
Reaction score
11
Hello, i want weapon defence work as shield defence and gain shielding skill
i made this part with shielding skill i am trying now to make co-op shielding + weapon

what i tried to do :
Code:
int32_t Player::getDefense() const
{
    int32_t baseDefense = 5, defenseValue = 0, defenseSkill = 0, extraDefense = 0;
    float defenseFactor = getDefenseFactor();

    const Item* weapon = NULL;
    const Item* shield = NULL;
    getShieldAndWeapon(shield, weapon);
    if(weapon)
    {
        extraDefense = weapon->getExtraDefense();
        defenseValue = baseDefense + weapon->getDefense();
        defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
    }

    if(shield && shield->getDefense() > defenseValue)
    {
        if(shield->getExtraDefense() > extraDefense)
            extraDefense = shield->getExtraDefense();

        defenseValue = baseDefense + shield->getDefense();
        defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
    }

    if(!defenseSkill)
        return 0;

    defenseValue += extraDefense;
    if(vocation->getMultiplier(MULTIPLIER_DEFENSE) != 1.0)
        defenseValue = int32_t(defenseValue * vocation->getMultiplier(MULTIPLIER_DEFENSE));

    return ((int32_t)std::ceil(((float)(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));
}

This should work or not ?
 
Solution
@pasiak12 Thanks for answer, my script worked
Code:
if(weapon)
    {
        extraDefense = weapon->getExtraDefense();
        defenseValue = baseDefense + weapon->getDefense();
        defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
    }
<<<< This is edited part and this says that Shielding skill work with weapon + i add a function in game.cpp that add 1% all dmg abso for 5 shielding skill :)

Thread can be closed

Wow, you are having more issues than anyone else. Why don't you go one by one? There are multiple threads by you which are not even solved. You can't just drop bricks on the ground and wait someone to build the wall for you.

jXbYUKh.jpg


It's a good start that you are trying...
Wow, you are having more issues than anyone else. Why don't you go one by one? There are multiple threads by you which are not even solved. You can't just drop bricks on the ground and wait someone to build the wall for you.

jXbYUKh.jpg


It's a good start that you are trying something at least, but don't ask someone if that would work since you can do it on your own. If you try it and get trouble with code (erros), post them here so we can all help you to find a useful solution.
 
This should work or not ?
You should run it and decide if it satisfy you or not :)

What version are you running? Can you provide original func or better just mark your changes what you did there (in that func/the differences)?

The function purpose you just pointed is getting player defense value (calculate based on player weapon, shield and skill). The skill gain definitely should not be there because it will rise up your shielding_skill every time it just 'check def stats'. Despite of that It always almost comes with shield usage it can be called from another functions whenever it needs to check the player def value. It should raise the skill level only on effective block hit, so look on onBlockHit() method and I think you will find easy what to do there :) If even any trouble happens, post them here and We will help.
 
@pasiak12 Thanks for answer, my script worked
Code:
if(weapon)
    {
        extraDefense = weapon->getExtraDefense();
        defenseValue = baseDefense + weapon->getDefense();
        defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
    }
<<<< This is edited part and this says that Shielding skill work with weapon + i add a function in game.cpp that add 1% all dmg abso for 5 shielding skill :)

Thread can be closed

Wow, you are having more issues than anyone else. Why don't you go one by one? There are multiple threads by you which are not even solved. You can't just drop bricks on the ground and wait someone to build the wall for you.

jXbYUKh.jpg


It's a good start that you are trying something at least, but don't ask someone if that would work since you can do it on your own. If you try it and get trouble with code (erros), post them here so we can all help you to find a useful solution.
i love you answer xD, i fixed that by myself after few hours i was looking for ideas from people on forum
 
Last edited by a moderator:
Solution
Back
Top