• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Critical Effect on Monster

boxxer321

Well-Known Member
Joined
Nov 5, 2011
Messages
122
Reaction score
68
Hi, guys!
first of all, sorry for my bad english!

I come here because I changed a few lines in the player.cpp to send a "CRIT!" Effect, but the effect is being shown to the player and I wanted it to go to the monster

here is the line:

void Player::sendCritical() const
{
if(g_config.getBool(ConfigManager:: DISPLAY_CRITICAL_HIT))
g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_MIRRORVERTICAL);

}
 
You have to get current player target or add the effect somewhere where you know who is the target. "getPosition()" used in player.cpp will return player position not the target position.

Code for tfs 1.x.
Code:
if (Creature* target = getAttackedCreature()) {
    g_game.addMagicEffect(target->getPosition(), MAGIC_EFFECT_MIRRORVERTICAL);
}
 
Last edited:
You have to get current player target or add the effect somewhere where you know who is the target. "getPosition()" used in player.cpp will return player position not the target position.

Code:
if (Creature* target = getAttackedCreature()) {
    g_game.addMagicEffect(target->getPosition(), MAGIC_EFFECT_MIRRORVERTICAL);
}
sorry, but this happened

1>..\player.cpp(5325): error C2662: 'Creature::getAttackedCreature' : cannot convert 'this' pointer from 'const Player' to 'Creature &'
1> Conversion loses qualifiers
1>..\player.cpp(5330): fatal error C1075: end of file found before the left brace '{' at '..\player.cpp(5324)' was matched
 
C++:
void Player::sendCritical() const
{
    if(g_config.getBool(ConfigManager::DISPLAY_CRITICAL_HIT)){
        if(!attackedCreature){
            return;
        }

        g_game.addAnimatedText(attackedCreature->getPosition(), COLOR_DARKRED, "CRITICAL!");
     }
}
 
Back
Top