• 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 How to remove targets from monsters?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,454
Solutions
1
Reaction score
627
Location
Estonia
I made function in LUA what is used to make monsters to ignore certain players.
However if player if player is visible to monster(not ghost mode) and is the only target Monster has, then it still follows them. Is there any non-source edit way to make monsters completely ignore regular player?

Function:

Code:
function checkTargets(monster) -- replace targetList, because Created monsters see everybody in server in some reason..
local targetList = monster:getTargetList()
local monsterID = monster:getId()

    Uprint(targetList, "before")
    for i, target in pairs(targetList) do
        if target:isPlayer() then
            if target:getStorageValue(SV.playerIsDead) == 1 and target:getStorageValue(SV.fakedeathOutfit) == 1 then
                targetList[i] = nil
            end
        end
     
        if tauntedCreatures[monsterID] then
            if target:getId() ~= tauntedCreatures[monsterID] then
                targetList[i] = nil
            end
        end
     
        if ghostProtectionZone(monster, target) then
            targetList[i] = nil
        end
    end
    Uprint(targetList, "after")
    creatureEnemies[monsterID] = targetList
end
 
ok I got it working with this: But if you have any other ideas or solution, let me know.
Code:
if #targetList == 0 then
        local friendList = monster:getFriendList()
      
        if #friendList > 0 then
            print("setting monster target")
            monster:setFollowCreature(friendList[1])
        end
    end

EDIT:

nvm thats even better xD didnt know i can pass NIL
Code:
if #targetList == 0 then
        monster:setFollowCreature()
end
 
Back
Top