• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature No damage to same colors

Gelio

Lua PHP C++ programmer
Joined
Jun 13, 2008
Messages
61
Reaction score
4
Location
Poland, Lublin
Hello. It's my first C++ code. I've tested it and it run. Ok, now:

In configmanager.cpp:
Under:
Code:
	m_confNumber[ALLOW_CLONES] = getGlobalNumber(L, "allowClones", 0);
Add:
Code:
    m_confNumber[NO_DAMAGE_TO_SAME_COLORS] = getGlobalNumber(L, "noDamageToSameColors", 0);
In configmanager.h:
Under:
Code:
ALLOW_CLONES,
Add:
Code:
NO_DAMAGE_TO_SAME_COLORS,
In combat.cpp:
Under:
Code:
		if((attackerPlayer = attacker->getPlayer()) || (attacker->getMaster() && (attackerPlayer = attacker->getMaster()->getPlayer())))
Add:
Code:
		uint32_t color = g_config.getNumber(ConfigManager::NO_DAMAGE_TO_SAME_COLORS);
		if(color != 0)
		{
                 Outfit_t attackerOutfit = attackerPlayer->getCurrentOutfit();
                 Outfit_t targetOutfit = targetPlayer->getCurrentOutfit();
                 if(attackerOutfit.lookHead == targetOutfit.lookHead && attackerOutfit.lookBody == targetOutfit.lookBody && attackerOutfit.lookLegs == targetOutfit.lookLegs && attackerOutfit.lookFeet == targetOutfit.lookFeet)
                 {
                  return RET_YOUMAYNOTATTACKTHISPLAYER;
                 }
        }

And thats it. If you attack player with same color you get a message:
You may not attack this player.

It's good code for wars. I'm using this code on my war.


Yours,
Gelio


@edit
Now I'm going to disable damage when player step on else player field.


@down
What? Which option? No damage to same look feet?
 
Last edited:
Sorry, but my English is bad. It's stable. I didn't get any debug or other. It's on my war if you want to test: inferno-war.no-ip.org (8.4).

Yours,
Gelio
 
Sorry, but my English is bad. It's stable. I didn't get any debug or other. It's on my war if you want to test: inferno-war.no-ip.org (8.4).

Yours,
Gelio

Why do u need it for 8.4 server if it's already in TFS?? And as Rudolf said, you can still hit them with spells ;]
 
@up
No, you can't hit they with spells. Check if you want: inferno-war.no-ip.org.


Yours,
Gelio
 
Probably he's talking about this variable in config:
noDamageToSameLookfeet = "no"
I didn't saw any other thing for this ;)
 
Yes, but when I've set it to "yes" I wasn't able to attack anybody. Monsters and players. So I've made it.

Yours,
Gelio
 
Well since it's your first c++ Code i'll give you rep.
Keep learning and you will p0wn TFS :p
 
Hello. It's my first C++ code. I've tested it and it run. Ok, now:

In configmanager.cpp:
Under:
Code:
	m_confNumber[ALLOW_CLONES] = getGlobalNumber(L, "allowClones", 0);
Add:
Code:
    m_confNumber[NO_DAMAGE_TO_SAME_COLORS] = getGlobalNumber(L, "noDamageToSameColors", 0);
In configmanager.h:
Under:
Code:
ALLOW_CLONES,
Add:
Code:
NO_DAMAGE_TO_SAME_COLORS,
In combat.cpp:
Under:
Code:
		if((attackerPlayer = attacker->getPlayer()) || (attacker->getMaster() && (attackerPlayer = attacker->getMaster()->getPlayer())))
Add:
Code:
		uint32_t color = g_config.getNumber(ConfigManager::NO_DAMAGE_TO_SAME_COLORS);
		if(color != 0)
		{
                 Outfit_t attackerOutfit = attackerPlayer->getCurrentOutfit();
                 Outfit_t targetOutfit = targetPlayer->getCurrentOutfit();
                 if(attackerOutfit.lookHead == targetOutfit.lookHead && attackerOutfit.lookBody == targetOutfit.lookBody && attackerOutfit.lookLegs == targetOutfit.lookLegs && attackerOutfit.lookFeet == targetOutfit.lookFeet)
                 {
                  return RET_YOUMAYNOTATTACKTHISPLAYER;
                 }
        }

And thats it. If you attack player with same color you get a message:


It's good code for wars. I'm using this code on my war.


Yours,
Gelio


@edit
Now I'm going to disable damage when player step on else player field.


@down
What? Which option? No damage to same look feet?

and How can add this function to my config.lua?

example:
Damage player to same color outfit: yes/no

???
 
Back
Top