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

Tibia Feature - Peace Between Monsters

Nottinghster

Tibia World RPG Developer
Joined
Oct 24, 2007
Messages
1,570
Solutions
6
Reaction score
437
Location
Brazil - Rio de Janeiro
GitHub
Nottinghster
Hello OTLanders!

I'm trying to reproduce that new Tibia feature, but I'm having just 1 problem, read below

Peace between Monsters? (http://www.tibia.com/news/?subtopic=newsarchive&id=2240)

TIBIA. According to the journal of a dead explorer, evil forces have agreed to settle their differences so all monsters have stopped harming each other with their attacks. In addition, monsters with summons will not damage their own summons anymore. We expect some challenges to get tougher due to this cunning move, so be prepared when heading out on adventures!

The problem is that one:
monsters with summons will not damage their own summons anymore.

My monsters are damaging their own summons, when it's not supposed to be

Here's the code:
Code:
    if (g_config.getBoolean(ConfigManager::PEACE_BETWEEN_MONSTERS))
    {
        Player* targetPlayer = target->getPlayer();
        Player* attackerPlayer;
       
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        } else {
            attackerPlayer = nullptr;
        }
   
        if(attacker && !attacker->isSummon() && target && !target->isSummon() && !attackerPlayer && !targetPlayer) {
            return false;
        }
    }

Someone can help me with that ?

Kind regards,
Nottinghster.
 
Code described:
Code:
if(attacker) // attack by some creature (not field)
{
    if(!attacker->isSummon()) // attacker is not summon
    {
        if(target) // there is some target creature
        {
            if(!target->isSummon()) // target is not summon
            {
                if(!attackerPlayer) // attacker is monster
                {
                    if(!targetPlayer) // target is monster
                    {
                        return false;
                    }
                }
            }
        }
    }
}
Possible combinations:
Code:
player vs player
player vs monster
player vs player summon
player vs monster summon

monster vs player
monster vs monster
monster vs player summon
monster vs monster summon

player summon vs player
player summon vs monster
player summon vs player summon
player summon vs monster summon

monster summon vs player
monster summon vs monster
monster summon vs player summon
monster summon vs monster summon
Now choose which are OK and which are not. Then just check them all with current script and modify it. Obvious problem is '!attacker/target->isSummon()' - summons can hit/get hit by anything, this script ignore them.

Try to use that function to check if creature is summon and is summon of player:
Code:
if(attacker->getMaster()) // creature is summon, master is not null
{
    // when we are sure that 'master' exists, we can check if its player
    if(!attacker->getMaster()->getPlayer()) // 'attacker' is summon and his master is monster [not player]
    {
         //creture is summon and its master is monster
    }
}
 
Last edited:
Back
Top