• 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!

Help with race combat problem

Holloweye

New Member
Joined
Jul 13, 2007
Messages
52
Reaction score
4
Okey so I have added new sex to the server so there is:
Male
Female
Orc
Orc(female)
Elf
Elf(female)

They work great.
But the problem is when I want to add so other races dont need to turn on the secure thing to attack another races. But if they are in the same race they need to turn it on.
- So basicly if a Male Human attack a Orc the human dont need to turn on the secure mode to attack. Same thing for the orc.
- If Orc(Male) attack an Orc(female) then Orc(Male) need to turn on the secure mode and he will get skull.

This is how it looks like:
Code:
if(target->getPlayer())
	{
		if(isProtected(player, target->getPlayer()))
			return RET_YOUMAYNOTATTACKTHISPLAYER;

        if(((player->getSex() == 0 || player->getSex() == 2 || player->getSex() == 4) && (target->getSex() == player->getSex() + 1)) || ((player->getSex() == 1 || 
        player->getSex() == 3 || player->getSex() == 5) && (target->getSex() == player->getSex() - 1)))
        {
        //Same race
               if(player->getSecureMode() == SECUREMODE_ON && !Combat::isInPvpZone(player, target) &&
			   player->getSkullClient(target->getPlayer()) == SKULL_NONE)
		       {
			        return RET_TURNSECUREMODETOATTACKUNMARKEDPLAYERS;
               }
        }else{
        //Diffrent race
           
        }   
	}

But I get this error:
Code:
-  In static member function `static ReturnValue Combat::canTargetCreature(const Player*, const Creature*)': 

- 279 C:\Users\Christer\Documents\Server\Sources 3.5\Sources 3.0\Sources 3.0\combat.cpp 'const class Creature' has no member named 'getSex' 

- 280 C:\Users\Christer\Documents\Server\Sources 3.5\Sources 3.0\Sources 3.0\combat.cpp 'const class Creature' has no member named 'getSex' 

- 280 C:\Users\Christer\Documents\Server\Sources 3.5\Sources 3.0\Sources 3.0\combat.cpp *** [../combat.o] Error 1

Anyone know how to fix this? Thanks for the help!
 
You must cast Creature class member into Player class member.

Briefly it's something like:
Code:
if(Player* targetPlayer = target->getPlayer())
because your trying to use Players class method (getSex()) with non-Player class. Player class inherits Creature but not the other way round.

edit: Use then targetPlayer with getSex() ofc
 
Back
Top