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

setFollowCreature() BUG in TFS 1.x

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
Code:
    if table.changeTarget then
        print("before  "..monster:getFollowCreature():getName())
        print("new targetName "..target:getName())
    
        monster:removeTarget(monster:getFollowCreature())
        monster:selectTarget(target)
        monster:setTarget(target)
        monster:setFollowCreature(target)
        print("after  "..monster:getFollowCreature():getName())
    end

This is the statement what is executed only once.
I tried ALL of the functions invidually and in different combinations. I get Same Prints all the time(expect when i use setTarget ONLY)
The only thing what almost works is: monster:setTarget(target)
And if i don't put anything else then monster has new target, but he will keep following the old one.

Code:
 print("Even later  "..monster:getFollowCreature():getName())
                    print()
                end
            end
        end
    end
    print("Last line of code  "..monster:getFollowCreature():getName())
end
This is the end of the Monster AI itself.

Prints come as follows:
before Druid
new targetName Knight
after Knight
Even later Knight

Last line of code Knight

But what visually happens is:
Monster still keeps following and attacking old target.
If I ONLY use monster:setTarget(target) then it will change the attack target, but follows the old one.

What I want to do is to change target so that he will follow AND attack the new target I give him?
 
Last edited:
Found the problem, why it didn't work for me.

if Creature:getTarget() returns nil value then it finds new target and sets the follow creature to new target too.
as far this it what it looks l
Most likely its intentional, but to me its flaw. If you want good source code, don't make the basic method to do more than 1 different thing.

Anyway gotta rework my monster AI now :/

EDIT: Found out that a nil value from creature:getTarget() is only a problem when you have chance to switch monster in the monster.xml
 
Last edited:
latest tfs, this issue again..
monster:setTarget(newTarget)
monster:setFollowCreature(newTarget)

setFollowCreature does not work.. sometimes it does, but most of the time it just makes monster still follow the previous target and look at the current target.

Could someone already fix .setFollowCreature function or remove it from luascripts.
This clearly not working and keep wasting hours of my time because of this annoying bug i keep forgetting..
 
Back
Top