• 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++ How to Fix that? TFS 1.5 Nekiro

mano368

Senior Support Team Member
Staff member
Support Team
Joined
Sep 2, 2011
Messages
647
Solutions
46
Reaction score
296
Location
Brazil
How to fix that to compile and work propelly?

That part of the script in condition.cpp is to do effect when a immune monster/creature step in field, tried with switch(creature->isImmune...) but idk c++

Copyed that part from combat.cpp "Game::combatBlockHit"
C:
bool ConditionDamage::doDamage(Creature* creature, int32_t healthChange)
{
    if (creature->isImmune(getType()) && !creature->isInGhostMode() && !creature->getPlayer()) {
        uint8_t hitEffect = 0;
        switch(creature->isImmune(getType())) { // <<<<< HERE IS THE PROBLEM, IDK HOW TO MAKE SYSTEM RECOGNIZE WHATS THE FIELD TYPE ACCORDING WITH THE IMMUNITY
            case COMBAT_UNDEFINEDDAMAGE: {
                return;
            }
            case COMBAT_ENERGYDAMAGE:
            case COMBAT_FIREDAMAGE:
            case COMBAT_PHYSICALDAMAGE: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
            case COMBAT_EARTHDAMAGE: {
                hitEffect = CONST_ME_GREEN_RINGS;
                break;
            }
            default: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
        }
        g_game.addMagicEffect(creature->getPosition(), hitEffect);
        return false;
    }

thanks in advance.
 
How to fix that to compile and work propelly?

That part of the script in condition.cpp is to do effect when a immune monster/creature step in field, tried with switch(creature->isImmune...) but idk c++

Copyed that part from combat.cpp "Game::combatBlockHit"
C:
bool ConditionDamage::doDamage(Creature* creature, int32_t healthChange)
{
    if (creature->isImmune(getType()) && !creature->isInGhostMode() && !creature->getPlayer()) {
        uint8_t hitEffect = 0;
        switch(creature->isImmune(getType())) { // <<<<< HERE IS THE PROBLEM, IDK HOW TO MAKE SYSTEM RECOGNIZE WHATS THE FIELD TYPE ACCORDING WITH THE IMMUNITY
            case COMBAT_UNDEFINEDDAMAGE: {
                return;
            }
            case COMBAT_ENERGYDAMAGE:
            case COMBAT_FIREDAMAGE:
            case COMBAT_PHYSICALDAMAGE: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
            case COMBAT_EARTHDAMAGE: {
                hitEffect = CONST_ME_GREEN_RINGS;
                break;
            }
            default: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
        }
        g_game.addMagicEffect(creature->getPosition(), hitEffect);
        return false;
    }

thanks in advance.
Are you trying to replicate the old behavior when players or monsters walks over fields, right? Could you share the whole code please? Please, I've looking for the same
and in combat.cpp the code by default is way different from yours
C++:
bool ConditionDamage::doDamage(Creature* creature, int32_t healthChange)
{
    if (creature->isSuppress(getType()) || creature->isImmune(getType())) {
        return false;
    }

    CombatDamage damage;
    damage.origin = ORIGIN_CONDITION;
    damage.primary.value = healthChange;
    damage.primary.type = Combat::ConditionToDamageType(conditionType);

    Creature* attacker = g_game.getCreatureByID(owner);
    if (field && creature->getPlayer() && attacker && attacker->getPlayer()) {
        damage.primary.value = static_cast<int32_t>(std::round(damage.primary.value / 2.));
    }

    if (!creature->isAttackable() || Combat::canDoCombat(attacker, creature) != RETURNVALUE_NOERROR) {
        if (!creature->isInGhostMode()) {
            g_game.addMagicEffect(creature->getPosition(), CONST_ME_POFF);
        }
        return false;
    }

    if (g_game.combatBlockHit(damage, attacker, creature, false, false, field)) {
        return false;
    }

    return g_game.combatChangeHealth(attacker, creature, damage);
}
 
Are you trying to replicate the old behavior when players or monsters walks over fields, right? Could you share the whole code please? Please, I've looking for the same
and in combat.cpp the code by default is way different from yours
[/CODE]
not only trying but already done my friend! thanks to Roddet.

don't know why yours is in combat.cpp, but looks the same

here we go. in condition.cpp in the ConditionDamage::doDamage part

change:
C:
    if (creature->isSuppress(getType()) || creature->isImmune(getType())) {
        return false;
    }

for:
C:
    if (creature->isImmune(getType()) && !creature->isInGhostMode()) {
        uint8_t hitEffect = 0;
        switch(Combat::ConditionToDamageType(getType())) {
            case COMBAT_UNDEFINEDDAMAGE: {
                return false;
            }
                case COMBAT_ENERGYDAMAGE:
                case COMBAT_FIREDAMAGE:
                case COMBAT_PHYSICALDAMAGE:
                case COMBAT_ICEDAMAGE:
                case COMBAT_DEATHDAMAGE: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
            case COMBAT_EARTHDAMAGE: {
                hitEffect = CONST_ME_GREEN_RINGS;
                break;
            }
            default: {
                hitEffect = CONST_ME_POFF;
                break;
            }
        }
        if (hitEffect != 0) {
            g_game.addMagicEffect(creature->getPosition(), hitEffect);
        }
        return false;
    }
   
    if (creature->isSuppress(getType())) {
        return false;
    }

idk if the code is correctly, but no error and working well
 
not only trying but already done my friend! thanks to Roddet.

don't know why yours is in combat.cpp, but looks the same

here we go. in condition.cpp in the ConditionDamage::doDamage part

change:
C:
    if (creature->isSuppress(getType()) || creature->isImmune(getType())) {
        return false;
    }

for:
C:
    if (creature->isImmune(getType()) && !creature->isInGhostMode()) {
        uint8_t hitEffect = 0;
        switch(Combat::ConditionToDamageType(getType())) {
            case COMBAT_UNDEFINEDDAMAGE: {
                return false;
            }
                case COMBAT_ENERGYDAMAGE:
                case COMBAT_FIREDAMAGE:
                case COMBAT_PHYSICALDAMAGE:
                case COMBAT_ICEDAMAGE:
                case COMBAT_DEATHDAMAGE: {
                hitEffect = CONST_ME_BLOCKHIT;
                break;
            }
            case COMBAT_EARTHDAMAGE: {
                hitEffect = CONST_ME_GREEN_RINGS;
                break;
            }
            default: {
                hitEffect = CONST_ME_POFF;
                break;
            }
        }
        if (hitEffect != 0) {
            g_game.addMagicEffect(creature->getPosition(), hitEffect);
        }
        return false;
    }
  
    if (creature->isSuppress(getType())) {
        return false;
    }

idk if the code is correctly, but no error and working well
i think yes this is the proper code for old behavior when walking on fields and monster is immune
but for player is not working, i think
 
i think yes this is the proper code for old behavior when walking on fields and monster is immune
but for player is not working, i think
players? what do you mean? the only two "players" that is immune: gm and npc... work well on them
 
players? what do you mean? the only two "players" that is immune: gm and npc... work well on them
When a snakes poisons a player with a silver neckace the player is not receiving the effect in fact it's not blocking dunno if night b the necklace that does not works or if it's the code, gonna revert
@mano368
and did you manage to fix this? this is still an issue in my server
 
Last edited:
When a snakes poisons a player with a silver neckace the player is not receiving the effect in fact it's not blocking dunno if night b the necklace that does not works or if it's the code, gonna revert
@mano368
and did you manage to fix this? this is still an issue in my server
What I do only change effect when you step in fields, I will see about items

@seems working well, but in real percents, if u use against 5 damage, u will receive 4 as damage, 10% from 5 = 0,5 damage

Already done something about initDamage, but I have a problem about step in poison field, trying to fix:

using this update, but poison field does weird animation(spark) when step in if u don't use the initDamage == 0 part
 
Last edited:
Back
Top