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

Lua Monsters attacking eachother

Yaze

Well-Known Member
Joined
Sep 15, 2014
Messages
382
Reaction score
61
heellloo, its a simple question not even worth to make a topic but yeh, xd
how i can do that monsters don't hit eachother with like area attacks from them ?

kind regards,
 
This is a good question, depends on the distro, but you should be able to check within the monsters spells if the target / spectators are a summons or a player and handle the damage accordingly.

Monsters will change targets even if they are attacking you, so if you run a check if is player or is summons then do damage else do no damage.
 
Apparently you didn't read the question.
Apparently you didn't. Let me break it down for you because yet again you prove to be slow.

how i can do that monsters don't hit eachother with like area attacks from them ?

Now if there's an area attack, before the damage formula you add
Code:
if isMonster(target) then
return true
end
And the damage does not effect the target. I'd know I've used it a time or two. You continue to try and make yourself a name by taking shots at other people. Are you trying to be cool? Get a new hobby.

Edit - That target, can be local target = getTopCreature(pos).uid Not too complicated to understand really.
 
Last edited:
heellloo, its a simple question not even worth to make a topic but yeh, xd
how i can do that monsters don't hit eachother with like area attacks from them ?

kind regards,


You didn't say what server version you are using, or the interface. These things matter, if you only want it for that one spell or all area of effect spells possible. There are many of ways to this, and the different ways are determined by your server version, so we need to know your server version.
 
@Yaze

Here it is man

In game.cpp, find the function
Code:
bool Game::combatChangeHealth(CombatType_t combatType, MagicEffectClasses customHitEffect, TextColor_t customTextColor, Creature* attacker, Creature* target, int32_t healthChange)

Below that lines:
Code:
const Position& targetPos = target->getPosition();
const SpectatorVec& list = getSpectators(targetPos);

Add this:
Code:
    Player* targetPlayer = target->getPlayer();
    Player* attackerPlayer;

    if (attacker) {
        attackerPlayer = attacker->getPlayer();
    } else {
        attackerPlayer = nullptr;
    }

    if(!attackerPlayer && !targetPlayer) {
        return false;
    }

Enjoy it ;)
 
@Yaze

Here it is man

In game.cpp, find the function
Code:
bool Game::combatChangeHealth(CombatType_t combatType, MagicEffectClasses customHitEffect, TextColor_t customTextColor, Creature* attacker, Creature* target, int32_t healthChange)

Below that lines:
Code:
const Position& targetPos = target->getPosition();
const SpectatorVec& list = getSpectators(targetPos);

Add this:
Code:
    Player* targetPlayer = target->getPlayer();
    Player* attackerPlayer;

    if (attacker) {
        attackerPlayer = attacker->getPlayer();
    } else {
        attackerPlayer = nullptr;
    }

    if(!attackerPlayer && !targetPlayer) {
        return false;
    }

Enjoy it ;)


wait, after the line
Code:
bool Game::combatChangeHealth(CombatType_t combatType, MagicEffectClasses customHitEffect, TextColor_t customTextColor, Creature* attacker, Creature* target, int32_t healthChange)

i will post
Code:
const Position& targetPos = target->getPosition();
const SpectatorVec& list = getSpectators(targetPos);
or not?

and this one i add below which line now, im confused
Code:
    Player* targetPlayer = target->getPlayer();
    Player* attackerPlayer;

    if (attacker) {
        attackerPlayer = attacker->getPlayer();
    } else {
        attackerPlayer = nullptr;
    }

    if(!attackerPlayer && !targetPlayer) {
        return false;
    }

Im sorry, i actually know what u mean but i didnt understand which line to post after what line, i dont know if it would matter but i just want to be sure :p
 
No, after those lines
Code:
const Position& targetPos = target->getPosition();
const SpectatorVec& list = getSpectators(targetPos);

You will add this:
Code:
Player* targetPlayer = target->getPlayer();
Player* attackerPlayer;

if (attacker) {
attackerPlayer = attacker->getPlayer();
} else {
attackerPlayer = nullptr;
}

if(!attackerPlayer && !targetPlayer) {
return false;
}

Understand now ?? :)
 
Back
Top