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

Solved [TFS 1.0] Make a monster attack other monsters?

Tufte

Member
Joined
Nov 19, 2007
Messages
652
Reaction score
24
Location
Norway
Possible? If not, could someone point me to where in the sourcecodes I need to edit?

Thanks
 
monster.cpp
Change isFriend / isOpponent and maybe edit the process of searching the target.
 
Why wont this work?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
       
    local skeleton = doSummonCreature("Skeleton", toPosition)
    local chicken = doSummonCreature("Chicken", toPosition)
   
    local monster = Monster(skeleton)
   
    monster:removeFriend(chicken)
   
    doSetMonsterTarget(skeleton, chicken)
   
    return TRUE
end
 
You have to edit sources. There is a function called "isFriend" which will always change the chicken to a friend.
 
I have managed to make 2 creature target eachother, and they keep the target. But they wont do any damage, where can I edit so they will do damage? This is what I did to make them target eachother:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
       
    local skeleton = doSummonCreature("Skeleton", toPosition)
    local rat = doSummonCreature("Rat", toPosition)
   
    local monster = Monster(skeleton)
    local monster2 = Monster(rat)
   
    monster:addTarget(rat)
    monster2:addTarget(skeleton)
   
    return TRUE
end
 
Just to test, I made isOpponent always return true, and isFriend always return false. They still wont deal any damage so it gotta be something else I need to edit.
 
Code:
} else if (target->getMonster()) {
        if (const Player* attackerPlayer = attacker->getPlayer()) {
                if (attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)) {
                        return RET_YOUMAYNOTATTACKTHISCREATURE;
                }

                if (target->isSummon() && target->getMaster()->getPlayer() && target->getZone() == ZONE_NOPVP) {
                        return RET_ACTIONNOTPERMITTEDINANOPVPZONE;
                }
        } else if (attacker->getMonster()) {
                const Creature* targetMaster = target->getMaster();

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

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

Combat.cpp
 
yeah thanks, it works now. This is suuuper simple way to do it, but this is all you need to do if you want to make 1 creature be able to attack other creatures:
Code:
else if (attacker->getMonster()) {
           
            if (attacker->getName().compare("YOUR_MONSTER") != 0) {
                return RET_YOUMAYNOTATTACKTHISCREATURE;
            }
       
        }
 
Back
Top