C++ Critical Effect on Monster

Discussion in 'Support' started by boxxer321, Mar 13, 2018.

  1. boxxer321

    boxxer321 New Member

    Joined:
    Nov 5, 2011
    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    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:

     
  2. Nekiro

    Nekiro worst coder Support Team

    Joined:
    Sep 7, 2015
    Messages:
    1,664
    Likes Received:
    513
    Best Answers:
    64
    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 (Text):
    1. if (Creature* target = getAttackedCreature()) {
    2.     g_game.addMagicEffect(target->getPosition(), MAGIC_EFFECT_MIRRORVERTICAL);
    3. }
     
    Last edited: Mar 13, 2018
  3. boxxer321

    boxxer321 New Member

    Joined:
    Nov 5, 2011
    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    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
     
  4. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,869
    Likes Received:
    1,752
    Best Answers:
    292
    what version of TFS are you using?
     
  5. boxxer321

    boxxer321 New Member

    Joined:
    Nov 5, 2011
    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    TFS 0.4
    8.60
     
  6. boxxer321

    boxxer321 New Member

    Joined:
    Nov 5, 2011
    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
  7. Sarah Wesker

    Sarah Wesker S.E ©

    Joined:
    Mar 16, 2017
    Messages:
    271
    Likes Received:
    112
    Best Answers:
    19
    Code (C++):
    1. void Player::sendCritical() const
    2. {
    3.     if(g_config.getBool(ConfigManager::DISPLAY_CRITICAL_HIT)){
    4.         if(!attackedCreature){
    5.             return;
    6.         }
    7.  
    8.         g_game.addAnimatedText(attackedCreature->getPosition(), COLOR_DARKRED, "CRITICAL!");
    9.      }
    10. }
     
    bayview likes this.

Share This Page

Loading...