• 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++ Enable Monster Friendly Fire [OTX3]

Crevasse

惡名昭彰
Joined
Jan 13, 2017
Messages
133
Solutions
15
Reaction score
85
Location
Washington, D.C.
I'm working with OTX3, 7.72 distribution. Normally in version 7.72 monster's spells should hurt each other. However, this distribution is a downgrade and that aspect was not changed.

I checked "bool Game::combatChangeHealth" in game.cpp and it seems that nothing is blocking creature vs. creature damage there. Xeraphus helped me check as well and didn't see anything wrong with that section either.

I've been searching for a couple days now and I keep coming up blank. There must be somewhere else that is returning false for creature vs. creature damage, does anyone know what file it would be in?

Thanks
 
Solution
Check ReturnValue Combat::canDoCombat(Creature* attacker, Creature* target, bool aggressive)

Somewhere inside this function you gonna find:

Code:
            } 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;
                    }
                }
            }

As far i can tell right now this is the piece of code that prevents monsters damaging each other.
Check ReturnValue Combat::canDoCombat(Creature* attacker, Creature* target, bool aggressive)

Somewhere inside this function you gonna find:

Code:
            } 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;
                    }
                }
            }

As far i can tell right now this is the piece of code that prevents monsters damaging each other.
 
Solution
Thank you for your reply. I will check it now.

Edit: that was it. Thank you. Removing the following lines solved the issue:
Code:
            } 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;
                    }
                }
            }

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
 
Last edited:
I'm using TFS 1.2 and i want to use this, but how can i make it work just for races, like if there are 2 demons they don't attack each other or 1 dragon and 1 DL but if there are 1 demon and 1 DL they attack eachother is it possible?
 
I'm using TFS 1.2 and i want to use this, but how can i make it work just for races, like if there are 2 demons they don't attack each other or 1 dragon and 1 DL but if there are 1 demon and 1 DL they attack eachother is it possible?
You will have to do the edit above then make a lua script to negate damage of they are the same creature name (easy) or race (hard, cuz u will have to create the races yourself)
 
You will have to do the edit above then make a lua script to negate damage of they are the same creature name (easy) or race (hard, cuz u will have to create the races yourself)
If i just negate the damage wouldn't they still "try" to attack but deal no damage? Is it possible to exclude a target from a creature target list? And every monster already has a race why can't i use the built in races?
 
If i just negate the damage wouldn't they still "try" to attack but deal no damage? Is it possible to exclude a target from a creature target list? And every monster already has a race why can't i use the built in races?
with the source edit above, creatures still classify each other as friends, they won't actively try to attack other creatures, but their AOE damage will affect other creatures aswell.

so if you want creatures to attack each other, u'll have to tinker with creature:addtarget and etc
 
with the source edit above, creatures still classify each other as friends, they won't actively try to attack other creatures, but their AOE damage will affect other creatures aswell.

so if you want creatures to attack each other, u'll have to tinker with creature:addtarget and etc

Oh i see now its only for the aoe damage sorry for my stupidity I thought it was for everything D:
Thx for highlighting this part maybe Im able to make it :D
 
Back
Top