• 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+ [Problem,question] 0 dmg in pvp. About different hit effect when you are in pvp

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
I'm using TFS 1.2
And today i went to test pvp with friend and i was confused when i saw that when you fight 1x1 one player can deal damage with melee weapon and other just deal zero (DIDN'T TRIED SPELLS). And second think i was wondering is it possible to apply different hiteffect when you are in fight againts other people? I mean check if you are in pvp and if yes it sends some kind of effect.

  • I haven't changed anything in source that can affect pvp
  • My server is pretty much in default stage if we talk about .lua
  • config.lua haven't changed anything its absolutely default stage
  • Yes i marked skull when i tried to attack player
Server i use: [8.60] The Forgotten Server 1.2
 
Solution
Probably i miss understood something i meant if i delete the whole your script and replace it with Vulcan_ it sends the text. So i dont know where exactly is the problem. I didnt tried to delete only if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
Ok try this
C++:
      uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
           {
               Position effectPos = targetPos;
               effectPos.x++;
               effectPos.y++...
try this out
by default i have it as textcolor blue and effect as CONST_ME_MAGIC_BLUE, ctrl+f and search for CONST_ME_MAGIC_BLUE if you want to change those parts (there's two of them)
C++:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    const Position& targetPos = target->getPosition();
    if (damage.primary.value > 0) {
        if (target->getHealth() <= 0) {
            return false;
        }

        Player* attackerPlayer;
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        } else {
            attackerPlayer = nullptr;
        }

        Player* targetPlayer = target->getPlayer();
        if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
            return false;
        }

        if (damage.origin != ORIGIN_NONE) {
            const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
            if (!events.empty()) {
                for (CreatureEvent* creatureEvent : events) {
                    creatureEvent->executeHealthChange(target, attacker, damage);
                }
                damage.origin = ORIGIN_NONE;
                return combatChangeHealth(attacker, target, damage);
            }
        }

        int32_t realHealthChange = target->getHealth();
        target->gainHealth(attacker, damage.primary.value);
        realHealthChange = target->getHealth() - realHealthChange;

        if (realHealthChange > 0 && !target->isInGhostMode()) {
            std::string damageString = std::to_string(realHealthChange) + (realHealthChange != 1 ? " hitpoints." : " hitpoint.");

            std::string spectatorMessage;
            if (!attacker) {
                spectatorMessage += ucfirst(target->getNameDescription());
                spectatorMessage += " was healed for " + damageString;
            } else {
                spectatorMessage += ucfirst(attacker->getNameDescription());
                spectatorMessage += " healed ";
                if (attacker == target) {
                    spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "herself" : "himself") : "itself");
                } else {
                    spectatorMessage += target->getNameDescription();
                }
                spectatorMessage += " for " + damageString;
            }

            TextMessage message;
            std::ostringstream strHealthChange;
            strHealthChange << realHealthChange;
            addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_MAYABLUE);

            SpectatorVec list;
            map.getSpectators(list, targetPos, false, true);
            for (Creature* spectator : list) {
                Player* tmpPlayer = spectator->getPlayer();
                if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = "You heal " + target->getNameDescription() + " for " + damageString;
                } else if (tmpPlayer == targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    if (!attacker) {
                        message.text = "You were healed for " + damageString;
                    } else if (targetPlayer == attackerPlayer) {
                        message.text = "You heal yourself for " + damageString;
                    } else {
                        message.text = "You were healed by " + attacker->getNameDescription() + " for " + damageString;
                    }
                } else {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = spectatorMessage;
                }
                tmpPlayer->sendTextMessage(message);
            }
        }
    } else {
        if (!target->isAttackable()) {
            if (!target->isInGhostMode()) {
                addMagicEffect(targetPos, CONST_ME_POFF);
            }
            return true;
        }

        Player* attackerPlayer;
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        } else {
            attackerPlayer = nullptr;
        }

        Player* targetPlayer = target->getPlayer();
        if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
            return false;
        }

        damage.primary.value = std::abs(damage.primary.value);
        damage.secondary.value = std::abs(damage.secondary.value);

        int32_t healthChange = damage.primary.value + damage.secondary.value;
        if (healthChange == 0) {
            return true;
        }

        TextMessage message;
        SpectatorVec list;
        if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) {
            int32_t manaDamage = std::min<int32_t>(target->getMana(), healthChange);
            if (manaDamage != 0) {
                if (damage.origin != ORIGIN_NONE) {
                    const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
                    if (!events.empty()) {
                        for (CreatureEvent* creatureEvent : events) {
                            creatureEvent->executeManaChange(target, attacker, healthChange, damage.origin);
                        }
                        if (healthChange == 0) {
                            return true;
                        }
                        manaDamage = std::min<int32_t>(target->getMana(), healthChange);
                    }
                }

                target->drainMana(attacker, manaDamage);
                map.getSpectators(list, targetPos, true, true);
                addMagicEffect(list, targetPos, CONST_ME_LOSEENERGY);

                std::string damageString = std::to_string(manaDamage);
                std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana";
                if (attacker) {
                    spectatorMessage += " due to ";
                    if (attacker == target) {
                        spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
                    } else {
                        spectatorMessage += "an attack by " + attacker->getNameDescription();
                    }
                }
                spectatorMessage += '.';

                std::ostringstream strManaDamage;
                strManaDamage << manaDamage;
                addAnimatedText(strManaDamage.str(), targetPos, TEXTCOLOR_BLUE);

                for (Creature* spectator : list) {
                    Player* tmpPlayer = spectator->getPlayer();
                    if (tmpPlayer->getPosition().z != targetPos.z) {
                        continue;
                    }

                    if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana due to your attack.";
                    } else if (tmpPlayer == targetPlayer) {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        if (!attacker) {
                            message.text = "You lose " + damageString + " mana.";
                        } else if (targetPlayer == attackerPlayer) {
                            message.text = "You lose " + damageString + " mana due to your own attack.";
                        } else {
                            message.text = "You lose " + damageString + " mana due to an attack by " + attacker->getNameDescription() + '.';
                        }
                    } else {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        message.text = spectatorMessage;
                    }
                    tmpPlayer->sendTextMessage(message);
                }

                damage.primary.value -= manaDamage;
                if (damage.primary.value < 0) {
                    damage.secondary.value = std::max<int32_t>(0, damage.secondary.value + damage.primary.value);
                    damage.primary.value = 0;
                }
            }
        }

        int32_t realDamage = damage.primary.value + damage.secondary.value;
        if (realDamage == 0) {
            return true;
        }

        if (damage.origin != ORIGIN_NONE) {
            const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
            if (!events.empty()) {
                for (CreatureEvent* creatureEvent : events) {
                    creatureEvent->executeHealthChange(target, attacker, damage);
                }
                damage.origin = ORIGIN_NONE;
                return combatChangeHealth(attacker, target, damage);
            }
        }

        int32_t targetHealth = target->getHealth();
        if (damage.primary.value >= targetHealth) {
            damage.primary.value = targetHealth;
            damage.secondary.value = 0;
        } else if (damage.secondary.value) {
            damage.secondary.value = std::min<int32_t>(damage.secondary.value, targetHealth - damage.primary.value);
        }

        realDamage = damage.primary.value + damage.secondary.value;
        if (realDamage == 0) {
            return true;
        } else if (realDamage >= targetHealth) {
            for (CreatureEvent* creatureEvent : target->getCreatureEvents(CREATURE_EVENT_PREPAREDEATH)) {
                if (!creatureEvent->executeOnPrepareDeath(target, attacker)) {
                    return false;
                }
            }
        }

        target->drainHealth(attacker, realDamage);
        if (list.empty()) {
            map.getSpectators(list, targetPos, true, true);
        }
        addCreatureHealth(list, target);

        message.primary.value = damage.primary.value;
        message.secondary.value = damage.secondary.value;

        uint8_t hitEffect;
        if (message.primary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
            }
        }

        if (message.primary.color != TEXTCOLOR_NONE || message.secondary.color != TEXTCOLOR_NONE) {
            std::string damageString = std::to_string(realDamage) + (realDamage != 1 ? " hitpoints" : " hitpoint");
            std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString;
            if (attacker) {
                spectatorMessage += " due to ";
                if (attacker == target) {
                    spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
                } else {
                    spectatorMessage += "an attack by " + attacker->getNameDescription();
                }
            }
            spectatorMessage += '.';

            for (Creature* spectator : list) {
                Player* tmpPlayer = spectator->getPlayer();
                if (tmpPlayer->getPosition().z != targetPos.z) {
                    continue;
                }

                if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " due to your attack.";
                } else if (tmpPlayer == targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    if (!attacker) {
                        message.text = "You lose " + damageString + '.';
                    } else if (targetPlayer == attackerPlayer) {
                        message.text = "You lose " + damageString + " due to your own attack.";
                    } else {
                        message.text = "You lose " + damageString + " due to an attack by " + attacker->getNameDescription() + '.';
                    }
                } else {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    // TODO: Avoid copying spectatorMessage everytime we send to a spectator
                    message.text = spectatorMessage;
                }
                tmpPlayer->sendTextMessage(message);
            }
        }
    }

    return true;
}
 
Go to game.cpp, find
Lua:
 bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
And you can do something here:
Lua:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
Check if attacker && attacker->getPlayer(), target->getPlayer(), and if damage.primary.type == COMBAT_PHYSICALDAMAGE, change hitEffect for the effect that you want.
 
try this out
by default i have it as textcolor blue and effect as CONST_ME_MAGIC_BLUE, ctrl+f and search for CONST_ME_MAGIC_BLUE if you want to change those parts (there's two of them)
C++:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    const Position& targetPos = target->getPosition();
    if (damage.primary.value > 0) {
        if (target->getHealth() <= 0) {
            return false;
        }

        Player* attackerPlayer;
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        } else {
            attackerPlayer = nullptr;
        }

        Player* targetPlayer = target->getPlayer();
        if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
            return false;
        }

        if (damage.origin != ORIGIN_NONE) {
            const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
            if (!events.empty()) {
                for (CreatureEvent* creatureEvent : events) {
                    creatureEvent->executeHealthChange(target, attacker, damage);
                }
                damage.origin = ORIGIN_NONE;
                return combatChangeHealth(attacker, target, damage);
            }
        }

        int32_t realHealthChange = target->getHealth();
        target->gainHealth(attacker, damage.primary.value);
        realHealthChange = target->getHealth() - realHealthChange;

        if (realHealthChange > 0 && !target->isInGhostMode()) {
            std::string damageString = std::to_string(realHealthChange) + (realHealthChange != 1 ? " hitpoints." : " hitpoint.");

            std::string spectatorMessage;
            if (!attacker) {
                spectatorMessage += ucfirst(target->getNameDescription());
                spectatorMessage += " was healed for " + damageString;
            } else {
                spectatorMessage += ucfirst(attacker->getNameDescription());
                spectatorMessage += " healed ";
                if (attacker == target) {
                    spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "herself" : "himself") : "itself");
                } else {
                    spectatorMessage += target->getNameDescription();
                }
                spectatorMessage += " for " + damageString;
            }

            TextMessage message;
            std::ostringstream strHealthChange;
            strHealthChange << realHealthChange;
            addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_MAYABLUE);

            SpectatorVec list;
            map.getSpectators(list, targetPos, false, true);
            for (Creature* spectator : list) {
                Player* tmpPlayer = spectator->getPlayer();
                if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = "You heal " + target->getNameDescription() + " for " + damageString;
                } else if (tmpPlayer == targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    if (!attacker) {
                        message.text = "You were healed for " + damageString;
                    } else if (targetPlayer == attackerPlayer) {
                        message.text = "You heal yourself for " + damageString;
                    } else {
                        message.text = "You were healed by " + attacker->getNameDescription() + " for " + damageString;
                    }
                } else {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = spectatorMessage;
                }
                tmpPlayer->sendTextMessage(message);
            }
        }
    } else {
        if (!target->isAttackable()) {
            if (!target->isInGhostMode()) {
                addMagicEffect(targetPos, CONST_ME_POFF);
            }
            return true;
        }

        Player* attackerPlayer;
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        } else {
            attackerPlayer = nullptr;
        }

        Player* targetPlayer = target->getPlayer();
        if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
            return false;
        }

        damage.primary.value = std::abs(damage.primary.value);
        damage.secondary.value = std::abs(damage.secondary.value);

        int32_t healthChange = damage.primary.value + damage.secondary.value;
        if (healthChange == 0) {
            return true;
        }

        TextMessage message;
        SpectatorVec list;
        if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) {
            int32_t manaDamage = std::min<int32_t>(target->getMana(), healthChange);
            if (manaDamage != 0) {
                if (damage.origin != ORIGIN_NONE) {
                    const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
                    if (!events.empty()) {
                        for (CreatureEvent* creatureEvent : events) {
                            creatureEvent->executeManaChange(target, attacker, healthChange, damage.origin);
                        }
                        if (healthChange == 0) {
                            return true;
                        }
                        manaDamage = std::min<int32_t>(target->getMana(), healthChange);
                    }
                }

                target->drainMana(attacker, manaDamage);
                map.getSpectators(list, targetPos, true, true);
                addMagicEffect(list, targetPos, CONST_ME_LOSEENERGY);

                std::string damageString = std::to_string(manaDamage);
                std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana";
                if (attacker) {
                    spectatorMessage += " due to ";
                    if (attacker == target) {
                        spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
                    } else {
                        spectatorMessage += "an attack by " + attacker->getNameDescription();
                    }
                }
                spectatorMessage += '.';

                std::ostringstream strManaDamage;
                strManaDamage << manaDamage;
                addAnimatedText(strManaDamage.str(), targetPos, TEXTCOLOR_BLUE);

                for (Creature* spectator : list) {
                    Player* tmpPlayer = spectator->getPlayer();
                    if (tmpPlayer->getPosition().z != targetPos.z) {
                        continue;
                    }

                    if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana due to your attack.";
                    } else if (tmpPlayer == targetPlayer) {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        if (!attacker) {
                            message.text = "You lose " + damageString + " mana.";
                        } else if (targetPlayer == attackerPlayer) {
                            message.text = "You lose " + damageString + " mana due to your own attack.";
                        } else {
                            message.text = "You lose " + damageString + " mana due to an attack by " + attacker->getNameDescription() + '.';
                        }
                    } else {
                        message.type = MESSAGE_STATUS_DEFAULT;
                        message.text = spectatorMessage;
                    }
                    tmpPlayer->sendTextMessage(message);
                }

                damage.primary.value -= manaDamage;
                if (damage.primary.value < 0) {
                    damage.secondary.value = std::max<int32_t>(0, damage.secondary.value + damage.primary.value);
                    damage.primary.value = 0;
                }
            }
        }

        int32_t realDamage = damage.primary.value + damage.secondary.value;
        if (realDamage == 0) {
            return true;
        }

        if (damage.origin != ORIGIN_NONE) {
            const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
            if (!events.empty()) {
                for (CreatureEvent* creatureEvent : events) {
                    creatureEvent->executeHealthChange(target, attacker, damage);
                }
                damage.origin = ORIGIN_NONE;
                return combatChangeHealth(attacker, target, damage);
            }
        }

        int32_t targetHealth = target->getHealth();
        if (damage.primary.value >= targetHealth) {
            damage.primary.value = targetHealth;
            damage.secondary.value = 0;
        } else if (damage.secondary.value) {
            damage.secondary.value = std::min<int32_t>(damage.secondary.value, targetHealth - damage.primary.value);
        }

        realDamage = damage.primary.value + damage.secondary.value;
        if (realDamage == 0) {
            return true;
        } else if (realDamage >= targetHealth) {
            for (CreatureEvent* creatureEvent : target->getCreatureEvents(CREATURE_EVENT_PREPAREDEATH)) {
                if (!creatureEvent->executeOnPrepareDeath(target, attacker)) {
                    return false;
                }
            }
        }

        target->drainHealth(attacker, realDamage);
        if (list.empty()) {
            map.getSpectators(list, targetPos, true, true);
        }
        addCreatureHealth(list, target);

        message.primary.value = damage.primary.value;
        message.secondary.value = damage.secondary.value;

        uint8_t hitEffect;
        if (message.primary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
            }
        }

        if (message.primary.color != TEXTCOLOR_NONE || message.secondary.color != TEXTCOLOR_NONE) {
            std::string damageString = std::to_string(realDamage) + (realDamage != 1 ? " hitpoints" : " hitpoint");
            std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString;
            if (attacker) {
                spectatorMessage += " due to ";
                if (attacker == target) {
                    spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
                } else {
                    spectatorMessage += "an attack by " + attacker->getNameDescription();
                }
            }
            spectatorMessage += '.';

            for (Creature* spectator : list) {
                Player* tmpPlayer = spectator->getPlayer();
                if (tmpPlayer->getPosition().z != targetPos.z) {
                    continue;
                }

                if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " due to your attack.";
                } else if (tmpPlayer == targetPlayer) {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    if (!attacker) {
                        message.text = "You lose " + damageString + '.';
                    } else if (targetPlayer == attackerPlayer) {
                        message.text = "You lose " + damageString + " due to your own attack.";
                    } else {
                        message.text = "You lose " + damageString + " due to an attack by " + attacker->getNameDescription() + '.';
                    }
                } else {
                    message.type = MESSAGE_STATUS_DEFAULT;
                    // TODO: Avoid copying spectatorMessage everytime we send to a spectator
                    message.text = spectatorMessage;
                }
                tmpPlayer->sendTextMessage(message);
            }
        }
    }

    return true;
}
Go to game.cpp, find
Lua:
 bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
And you can do something here:
Lua:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
Check if attacker && attacker->getPlayer(), target->getPlayer(), and if damage.primary.type == COMBAT_PHYSICALDAMAGE, change hitEffect for the effect that you want.
1>..\src\game.cpp(3834): error C2065: 'CONST_ME_STEPSHORIZONTA': undeclared identifier
1>..\src\game.cpp(3847): error C2065: 'CONST_ME_STEPSHORIZONTA': undeclared identifier

Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTA) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTA) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
            }
        }
 
So, for what you're trying to do i would recommend this:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
 
So yea i tried this one
Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
and it doesnt work still send effect from bool Game::combatBlockHit. Ideas?
 
So yea i tried this one
Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
and it doesnt work still send effect from bool Game::combatBlockHit. Ideas?
i gave you code to test and told you how to edit the effect in my post
 
So yea i tried this one
Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
            if (hitEffect != CONST_ME_STEPSHORIZONTAL) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
and it doesnt work still send effect from bool Game::combatBlockHit. Ideas?

Even when the player is hitting the other its not showing the new effect? Its showing the blood effect or block effect? Also you tried my code?
 
i gave you code to test and told you how to edit the effect in my post
Yea i saw your post and i did what you told or you meant to say replace this code
Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
            }
        }
with mine?
 
Yea i saw your post and i did what you told or you meant to say replace this code
Code:
        uint8_t hitEffect;
        if (message.primary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.primary.color != TEXTCOLOR_NONE) {
                std::ostringstream strPrimaryDamage;
                strPrimaryDamage << message.primary.value;
                addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
            }
        }

        if (message.secondary.value) {
            if (attackerPlayer && targetPlayer) {
                message.primary.color = TEXTCOLOR_BLUE;
                hitEffect = CONST_ME_MAGIC_BLUE;
            } else {
                combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
            }
            if (hitEffect != CONST_ME_NONE) {
                addMagicEffect(list, targetPos, hitEffect);
            }

            if (message.secondary.color != TEXTCOLOR_NONE) {
                std::ostringstream strSecondaryDamage;
                strSecondaryDamage << message.secondary.value;
                addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
            }
        }
with mine?
that's the edited code, replace yours with that right there and compile
 
Even when the player is hitting the other its not showing the new effect? Its showing the blood effect or block effect?
It doesnt show CONST_ME_STEPSHORIZONTAL at all. Only shows effect from static const auto sendBlockEffect. My point is not to show effect from bool Game::combatBlockHit and only show CONST_ME_STEPSHORIZONTAL in "PVP"
 
It doesnt show CONST_ME_STEPSHORIZONTAL at all. Only shows effect from static const auto sendBlockEffect. My point is not to show effect from bool Game::combatBlockHit and only show CONST_ME_STEPSHORIZONTAL in "PVP"
Try my code. If you didnt see it:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
 
Try my code. If you didnt see it:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
Ok i'll try it to
 
Try my code. If you didnt see it:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
               hitEffect = CONST_ME_STEPSHORIZONTAL;
           if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
So yea this one works but it has some bugs. Doesnt show damage text but probably because it doesnt have message.primary.color
And second think has wrong skill effect position, probably because i use bigger effect then 32x32. And it applies effect only for one player i dont know why other player didn't had CONST_ME_STEPSHORIZONTAL effect maybe because i had zero dmg :D
that's the edited code, replace yours with that right there and compile
About your code. It has no problems with text, everything is fine, but it has other problems to. So first problem is if i'm PK (FRAG) it sends sendBlockEffect but if you are the one who attack that pk it doesnt send sendBlockEffect everything is fine with it. And last problem is effect placement to.
 
So yea this one works but it has some bugs. Doesnt show damage text but probably because it doesnt have message.primary.color
And second think has wrong skill effect position, probably because i use bigger effect then 32x32. And it applies effect only for one player i dont know why other player didn't had CONST_ME_STEPSHORIZONTAL effect maybe because i had zero dmg :D.
64x64 effects fits better giving it x+1 and y+1, like:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
           {
               hitEffect = CONST_ME_STEPSHORIZONTAL;
               Position effectPos = targetPos;
               effectPos.x++;
               effectPos.y++;
               addMagicEffect(list, effectPos, hitEffect);
           }
           else if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
           {
               hitEffect = CONST_ME_STEPSHORIZONTAL;
               Position effectPos = targetPos;
               effectPos.x++;
               effectPos.y++;
               addMagicEffect(list, effectPos, hitEffect);
           }
           else if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
About not showing the text, i don't see why. Did you use his code + my code or the old code + my code?
 
64x64 effects fits better giving it x+1 and y+1, like:
C++:
       uint8_t hitEffect;
       if (message.primary.value) {
           combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.primary.type == COMBAT_PHYSICALDAMAGE)
           {
               hitEffect = CONST_ME_STEPSHORIZONTAL;
               Position effectPos = targetPos;
               effectPos.x++;
               effectPos.y++;
               addMagicEffect(list, effectPos, hitEffect);
           }
           else if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }

       if (message.secondary.value) {
           combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
           if (attacker && attacker->getPlayer() && target->getPlayer() && damage.secondary.type == COMBAT_PHYSICALDAMAGE)
           {
               hitEffect = CONST_ME_STEPSHORIZONTAL;
               Position effectPos = targetPos;
               effectPos.x++;
               effectPos.y++;
               addMagicEffect(list, effectPos, hitEffect);
           }
           else if (hitEffect != CONST_ME_NONE) {
               addMagicEffect(list, targetPos, hitEffect);
           }
       }
About not showing the text, i don't see why. Did you use his code + my code or the old code + my code?
Yea now it sends effect perfectly so it has last problem it doesnt show text damage. No i just used your code i didn't combined them. But i tried to add message.primary.color = TEXTCOLOR_BLUE; didnt helped probably i have to add something dunno what
 
Back
Top