Yan18
Member
- Joined
- Jun 14, 2014
- Messages
- 104
- Solutions
- 3
- Reaction score
- 17
Hello folks!
I want to do the player can't attack and target their summons.
I tried to do in Data/Events/creature.lua:
It didn't generates an error, but didn't work.
---------------------------------------------------------------------------------------------
EDIT
I solved my problem, I did a check in the source and it worked!
This was my solution:
Open the source and go in combat.cpp and look for the function: ReturnValue Combat::canTargetCreature(Player* attacker, Creature* target) and add the code below inside:
I want to do the player can't attack and target their summons.
I tried to do in Data/Events/creature.lua:
Lua:
function Creature:onTargetCombat(target)
local master = self:getMaster()
if not self then
return RETURNVALUE_NOERROR
end
if master and master == target then
return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
end
if self:isPlayer() and target:isPlayer() then
return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
end
if self:isPlayer() and target:isSummonable() then
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
end
return RETURNVALUE_NOERROR
end
It didn't generates an error, but didn't work.
---------------------------------------------------------------------------------------------
EDIT
I solved my problem, I did a check in the source and it worked!
This was my solution:
Open the source and go in combat.cpp and look for the function: ReturnValue Combat::canTargetCreature(Player* attacker, Creature* target) and add the code below inside:
C++:
ReturnValue Combat::canTargetCreature(Player* attacker, Creature* target)
{
if (attacker->getPlayer() && target->getCreature()->isSummon())
{
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
}
... // ANOTHER BLOCKS BELOW FROM THE FUNCTION
}
Last edited: