• 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:
Solved my problem with:
monster:searchTarget(TARGETSEARCH_NEAREST)
For now.
But That is sad that I cant set specific target what to follow.
 
You can start by adding some prints here - https://github.com/otland/forgottenserver/blob/master/src/creature.cpp#L963-L992
Ex.
Code:
function
std::cout << "1" << std::endl;
function
std::cout << "2" << std::endl;

That way you can see where it stops and look more into the problem there.
is it not possible without soureCode changes? I cant compile

Test if your TFS 1.1 or TFS 1.2 depends what you are using. changes target and FOLLOW TARGET when using above lua functions.
Because it doesnt work for TFS 1.0
 
is it not possible without soureCode changes? I cant compile

Test if your TFS 1.1 or TFS 1.2 depends what you are using. changes target and FOLLOW TARGET when using above lua functions.
Because it doesnt work for TFS 1.0

Since the function is in your source code you have to compile it.
Using 1.2:
Code:
    local targetPlayer = Player("HerpiDerpDerp")
    if(targetPlayer) then
        player:setFollowCreature(targetPlayer)
    end

As a login script, and once I logged in the character started running after me.
If you don't wanna edit your source you should serach for things Printer has opened, he posted something with the SEARCH function that Mark fixed.
 
Since the function is in your source code you have to compile it.
Using 1.2:
Code:
    local targetPlayer = Player("HerpiDerpDerp")
    if(targetPlayer) then
        player:setFollowCreature(targetPlayer)
    end

As a login script, and once I logged in the character started running after me.
If you don't wanna edit your source you should serach for things Printer has opened, he posted something with the SEARCH function that Mark fixed.
Well good enough information that TFS 1.2 works.
I will keep that in mind and note it up when I someday update my Source.

Edit. just to be sure, could you switch target and set new follow?
(target switched is monster who targets player and then after function, target new player and follows new player)
 
Well good enough information that TFS 1.2 works.
I will keep that in mind and note it up when I someday update my Source.

Edit. just to be sure, could you switch target and set new follow?
(target switched is monster who targets player and then after function, target new player and follows new player)

A = player who follows
B = player to follow
C = player to follow next

A logins and follows B then follow C?

Could you give me your script insted and I can test that.
 
A = player who follows
B = player to follow
C = player to follow next

A logins and follows B then follow C?

Could you give me your script insted and I can test that.
on post 1?

the monster should be the one who changes follow and target.
 
Was talking about the full script, so I can just copy paste it.
not only I don't have it (using the double searchtarget now),
It was also part of my spellcreating system, which is ~2500 lines.
and too tired to sketch that within few minutes, already preparing to sleep.

honestly, copy pasting that script takes as much as writing it from head xD

just create registrate onUse action.

and use the item on monster to make it target you and follow you.

doubleclient login and check can you keep switching the monster follow and target with the item.
 
not only I don't have it (using the double searchtarget now),
It was also part of my spellcreating system, which is ~2500 lines.
and too tired to sketch that within few minutes, already preparing to sleep.

honestly, copy pasting that script takes as much as writing it from head xD

just create registrate onUse action.

and use the item on monster to make it target you and follow you.

doubleclient login and check can you keep switching the monster follow and target with the item.

Well the callback should not matter, if you still have the problem then it's the serachTarget function.
 
the problem is TFS 1.0
if it setfollow() works for you.

double searchtarget is working for me.

Worked for me with the script I posted above, used it in the login script and it right away started to follow my admin char.
 
so it didn't work for you too?

It worked as I said, that when I logged in I would set the follow to my GM char.
No ide if it's the serachTarget function or not, you will have to check on 1.2 with your code.
You should still update even if it dosen't work, will make it alot easier to add the fix (and get support to actually get it fixed).
 
It worked as I said, that when I logged in I would set the follow to my GM char.
No ide if it's the serachTarget function or not, you will have to check on 1.2 with your code.
You should still update even if it dosen't work, will make it alot easier to add the fix (and get support to actually get it fixed).
:| alright, one day I will.
 
Back
Top