• 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++ Make monsters dont hit other monsters

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
I want to make the monster spells dont hit other monsters on OTHire 7.72
Like banshee wave, the banshee wave is killing demon, i want that they dont hit each other.
On an old topic about i saw @Peonso saying about changes on combat.cpp

He said to add something like this on combat.cpp (its a code from this forgottenserver)
C++:
else if (attacker->getMonster()) {
            const Creature* targetMaster = target->getMaster();

            if (!targetMaster || !targetMaster->getPlayer()) {
                const Creature* attackerMaster = attacker->getMaster();

                if (!attackerMaster || !attackerMaster->getPlayer()) {
                    return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
                }
            }
}

Ive tried this, but no success, nothing happens, monsters still hit each other, maybe this arguments are not compatible with othire functions, can someone help me?
here is the original combat.cpp from othire:
TwistedScorpio/OTHire (https://github.com/TwistedScorpio/OTHire/blob/08a3e77d2be851d037efd3937095b65da6289ba5/source/combat.cpp#L421)

any idea?
 
ReturnValue Combat::canDoCombat(const Creature* attacker, const Creature* target)
line 395 of combat.cpp othire u mean this?

what I need to add on combat.cpp exactly?
 
From @Peonso code:

From:
C++:
        else if(target->getMonster()){
            if(const Player* attackerPlayer = attacker->getPlayer()){
                if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)){
                    return RET_YOUMAYNOTATTACKTHISCREATURE;
                }
            }
        }

To:
C++:
        else if(target->getMonster()) {
            if(const Player* attackerPlayer = attacker->getPlayer()) {
                if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)) {
                    return RET_YOUMAYNOTATTACKTHISCREATURE;
                }
            } else if(attacker->getMonster()) {
                const Creature* attackerMaster = attacker->getMaster();
                if (!attackerMaster || !attackerMaster->getPlayer()) {
                    const Creature* targetMaster = target->getMaster();
                    if(!targetMaster || !targetMaster->getPlayer()) {
                        return RET_YOUMAYNOTATTACKTHISCREATURE;
                    }
                }
            }
        }
 
Porra, eu tava certo desde o inicio, vc q tava bizonhando ai kkkkk

kkkkkkkkkk
Your code was missing a "}" on line 27, but I see now that you fixed it.
Also, I changed the order of ifs because makes more legible to me.
And I don't think is necessary to send the whole function. Do you? xd
 
kkkkkkkkkk
Your code was missing a "}" on line 27, but I see now that you fixed it.
Also, I changed the order of ifs because makes more legible to me.
And I don't think is necessary to send the whole function. Do you? xd
Once I sent the reply I noticed the error, you might have clicked really fast. I thought my first guidance was enough but it wasn't haha.
@Peonso você é br? cara eu sou terrivel em c++

@River KA aaah i saw
Depende cara, se eu achar que vão me spammar muito eu omito esse detalhe.
 
From @Peonso code:

From:
C++:
        else if(target->getMonster()){
            if(const Player* attackerPlayer = attacker->getPlayer()){
                if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)){
                    return RET_YOUMAYNOTATTACKTHISCREATURE;
                }
            }
        }

To:
C++:
        else if(target->getMonster()) {
            if(const Player* attackerPlayer = attacker->getPlayer()) {
                if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)) {
                    return RET_YOUMAYNOTATTACKTHISCREATURE;
                }
            } else if(attacker->getMonster()) {
                const Creature* attackerMaster = attacker->getMaster();
                if (!attackerMaster || !attackerMaster->getPlayer()) {
                    const Creature* targetMaster = target->getMaster();
                    if(!targetMaster || !targetMaster->getPlayer()) {
                        return RET_YOUMAYNOTATTACKTHISCREATURE;
                    }
                }
            }
        }
this worked for me in OTX 2 (TFS 0.3.7) thanks
 
Back
Top