• 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++]Wild monsters are not harmed by attacks from other wild monsters

Joe Rod

Discord: joerod1
Joined
Mar 16, 2011
Messages
499
Solutions
2
Reaction score
172
GitHub
joerod1
hi guys, i need a code for make that wild monsters don't get harmed by attacks of another wild monsters. Basically i need that summons can only cause harm. It would be nice if someone can help me :).

Thanks in Advance
Kind Regards ;)
 
i've tested that code bro,with that code the monsters are not harmed by another wild monsters but summons either, the sumons can't die because are not harmed, can you fix that?
thanks in advance
 
this should work, untested:
monster.cpp replace void Monster::drainHealth function with this one (like before)
Code:
void Monster::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
{
	bool effect = true
	if(g_config.getBool(ConfigManager::MONSTER_DAMAGED_BY_PLAYER_ONLY))
	{
		if(!isPlayerSummon()) //Player summons can be damaged by players and monsters
		{
			if(attacker->getPlayer() || attacker->isPlayerSummon()) //Make sure it is a player making damage
				effect = true
			else
				effect = false
		}
		else
			effect = true
	}
	else
		effect = true
	
	if(effect)
	{
		Creature::drainHealth(attacker, combatType, damage);
		if(isInvisible())
			removeCondition(CONDITION_INVISIBLE);
	}
	else
		Creature::drainHealth(attacker, combatType, 0);
}
 
It's working ok, but it's still showing how much life it would have taken.

Ex.: Frost Dragon and Dragon attacking me. Frost Dragon hits me with a ice ball. Dragon gets hitted by this ice ball; his health is not being removed (working okay), but it shows the health damage number as if the Dragon was getting hitted.

Just tell me the function to verify it and I'll try to work on that, please :D
 
Yes, I'm using the fixed version he posted on this page :(
And using tfs 0.4 svn

Well its is for 0.3.6, I would have to look into 0.4 more to get it working properly for that.

EDIT: It must be calling another function for the messaging. I think it's doing that in the game.cpp
Code:
bool Game::combatChangeHealth
^ this method.

In there is my bet. But would have to check it out.
 
Last edited:
Back
Top