• 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 [8.31+] Party attack protection

Gelio

Lua PHP C++ programmer
Joined
Jun 13, 2008
Messages
61
Reaction score
4
Location
Poland, Lublin
I've made this code for my war. This code make a blocade when you want to attack another player in your party. It run for spells too. Ok, let's go:

In configmanager.cpp:
Under:
Code:
m_confNumber[MAX_PLAYER_SUMMONS] = getGlobalNumber(L, "maxPlayerSummons", 2);
Add:
Code:
    m_confNumber[NO_DAMAGE_TO_PARTY_MEMBERS] = getGlobalNumber(L, "noDamageToPartyMembers", 0);

In configmanager.h:
Under:
Code:
MAX_PLAYER_SUMMONS,
Add:
Code:
NO_DAMAGE_TO_PARTY_MEMBERS,

In combat.cpp:
Under (around 250 line):
Code:
		if((attackerPlayer = attacker->getPlayer()) || (attacker->getMaster()
			&& (attackerPlayer = attacker->getMaster()->getPlayer())))
		{
Add:
Code:
		uint32_t party = g_config.getNumber(ConfigManager::NO_DAMAGE_TO_PARTY_MEMBERS);
		if(party != 0)
		{
              Party* attackerPlayerParty = attackerPlayer->getParty();
              Party* targetPlayerParty = targetPlayer->getParty();
              if(attackerPlayerParty == targetPlayerParty && attackerPlayerParty > 0 && targetPlayerParty > 0)
              {
                 return RET_YOUMAYNOTATTACKTHISPLAYER;
              }
        }

And thats it. Now compile/rebuild your server and add anywhere in config.lua:
Code:
noDamageToPartyMembers = 1
If you set 0 party members will get damage. If you set 1 damage will be ignored and blocked.


Yours,
Gelio
 
Last edited:
Sorry for the double post, but can you add another check for pz lock? So like if someone has a skull or pz lock they will attack their party members again?
 
edit.

you can shorten it 90% if you put it at the correct place.
 
Last edited:
Isn't it possible to be done by LUA with onAttack?

Basicaly it is.

Code:
function onAttack(cid, target)
if(isPlayer(target) == TRUE and getPlayerParty(cid) == getPlayerParty(target)) then
return FALSE
end

return TRUE
end

but it won't handle spells.
 
I do not know what but me this does not act...
to put in someone finished maybe ???
 
Hello, I used this code for my otserver, but the problem is that it crashes when monsters attack you because, you cannot compare a monster with a player, but I can't find a C++ function for like "isplayer(target)", or if there is another way to ignore monsters in that "if" case, I would really appreciate it if someone knows how to fix this, because its very useful :D
 
Basicaly it is.

Code:
function onAttack(cid, target)
if(isPlayer(target) == TRUE and getPlayerParty(cid) == getPlayerParty(target)) then
return FALSE
end

return TRUE
end

but it won't handle spells.
onAttack doesn't work with spells...
 
Geez calm down guys, why the HELL are some of you bashing him for no reason?? :S

Its not like he claimed "Ok here we go I have the best script ever I rock" or not even close, he didnt even claim anything, he just shared for free a feature he made for anyone who might want it, isnt that one of the main purposes of an OT-related forum?

I simply dont get why would you attack him like that if he isnt trying to prove anything to anyone, or even doing anything wrong, actually he's doing something great and if you dont have a thanks or a CONSTRUCTIVE criticism to make, why bother posting?

Anyways, on-topic, great script Gelio, thanks for sharing this and the other scripts you've made, keep it up!

+Rep from me.

Cheers~
 
In Dev-cpp project. You need to download Dev-cpp, open project (source->devcpp) and there in window in left side of screen you will see project files. There will be that file.

Yours,
Gelio
 
Gelio i have a error when re compiling

Code:
24 C:\Users\Baby\Desktop\TheForgottenServer-Source\game.h:31,               from ..\combat.cpp In file included from ../game.h:31,               from ../combat.cpp 
24 C:\Users\Baby\Desktop\TheForgottenServer-Source\combat.cpp                  from ../combat.cpp 
154 C:\Users\Baby\Desktop\TheForgottenServer-Source\player.h `virtual bool Player::canSeeInvisibility() const' and `virtual bool Player::canSeeInvisibility() const' cannot be overloaded 
 C:\Users\Baby\Desktop\TheForgottenServer-Source\player.h In member function `virtual bool Player::canSeeInvisibility() const': 
128 C:\Users\Baby\Desktop\TheForgottenServer-Source\player.h `getAccountType' was not declared in this scope 
128 C:\Users\Baby\Desktop\TheForgottenServer-Source\player.h `ACCOUNT_TYPE_GAMEMASTER' was not declared in this scope 
 C:\Users\Baby\Desktop\TheForgottenServer-Source\Project\Makefile.win [Build Error]  [../combat.o] Error 1

like u say under
Code:
		const Player* attackerPlayer = NULL;
		if((attackerPlayer = attacker->getPlayer()) || (attacker->getMaster()
			&& (attackerPlayer = attacker->getMaster()->getPlayer())))
		{
Code:
		const Player* attackerPlayer = NULL;
		if((attackerPlayer = attacker->getPlayer()) || (attacker->getMaster()
			&& (attackerPlayer = attacker->getMaster()->getPlayer())))
		{
		uint32_t party = g_config.getNumber(ConfigManager::NO_DAMAGE_TO_PARTY_MEMBERS);
		if(party != 0)
		{
              Party* attackerPlayerParty = attackerPlayer->getParty();
              Party* targetPlayerParty = targetPlayer->getParty();
              if(attackerPlayerParty == targetPlayerParty && attackerPlayerParty > 0 && targetPlayerParty > 0)
              {
                 return RET_YOUMAYNOTATTACKTHISPLAYER;
              }
        }
 
Hello, can somebody rewrite the script with her in a "party" to put hits on 50% less? (Does not apply to people from another "party"
--------------------------------------------
[8.41/42] The Forgotten Server 0.3.4PL2

Please answer fast
 
0.0 cant find first confmanager links
 
Back
Top Bottom