• 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++ Checking if target is a monster or a player in TFS 0.3.6.

Dionizy

New Member
Joined
Mar 18, 2018
Messages
15
Reaction score
0
I'm changing distance shoot system a lot and I want accuracy to be different depending on if you're attacking a player or a monster. I checked how it's done in LUA and tried to replicate it in C++.
C++:
      int AUTOID_PLAYERS = 0x10000000;
        int AUTOID_MONSTERS = 0x40000000;
        int AUTOID_NPCS = 0x80000000    ;
              
      
        //isMonster
        if((target->id >= AUTOID_MONSTERS) && (target->id < AUTOID_NPCS))
        {
                  
             chance = skillmodpve;
        }
      
        //isPlayer
        if((target->id >= AUTOID_PLAYERS) && (target->id < AUTOID_MONSTERS))
        {
        if (targetflee >= skillmodpvp)
            {
            chance = 1;
            }
            else
            chance = skillmodpvp - targetflee;
            }
I always get the
Code:
`uint32_t Creature::id' is protected
error. How to access a protected class member in this context?
 
Solution
u solve this by calling target->getID() which is a public function
you dont access protected data directly, it requires a "get function" iirc
u solve this by calling target->getID() which is a public function
you dont access protected data directly, it requires a "get function" iirc
 
Last edited:
Solution
Back
Top