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

TFS 0.X Problem with target after "death".

ausirosiris

Member
Joined
May 23, 2020
Messages
105
Reaction score
22
Ok, this is driving me crazy. I have absolutely no idea the cause of the problem. And here what it is:

Its a team war server with a simple preparedeath script to teleport the player back to temple after he dies in the field but, if the player (who died) have a target on, after he teleports back to the temple, the target continues to be toggled. (it doesn't continues to attack the player if he leaves pz, but is still on. I've tried using send cancels, interrupt attack scripts and nothing.
 
Solution
That could be indeed a otc problem, do have any advice for it?
You can use 'cancel target' packet to unset current target in tibia client.
On TFS 1.4 code that sends it is not available from Lua.
C++:
void ProtocolGame::sendCancelTarget()
{
    NetworkMessage msg;
    msg.addByte(0xA3);
    msg.add<uint32_t>(0x00);
    writeToOutputBuffer(msg);
}
but you can generate it in Lua and send this packet to player using:
LUA:
local networkMessage = NetworkMessage()
networkMessage:addByte(0xA3)
// if your client version is BELOW 8.60 remove line below (networkMessage:addU32(0x00))
networkMessage:addU32(0x00)
networkMessage:sendToPlayer(player)
networkMessage:delete()

EDIT:
On 0.4 there is also code to cancel target on...
That could be indeed a otc problem, do have any advice for it?
You can use 'cancel target' packet to unset current target in tibia client.
On TFS 1.4 code that sends it is not available from Lua.
C++:
void ProtocolGame::sendCancelTarget()
{
    NetworkMessage msg;
    msg.addByte(0xA3);
    msg.add<uint32_t>(0x00);
    writeToOutputBuffer(msg);
}
but you can generate it in Lua and send this packet to player using:
LUA:
local networkMessage = NetworkMessage()
networkMessage:addByte(0xA3)
// if your client version is BELOW 8.60 remove line below (networkMessage:addU32(0x00))
networkMessage:addU32(0x00)
networkMessage:sendToPlayer(player)
networkMessage:delete()

EDIT:
On 0.4 there is also code to cancel target on Tibia 8.6:
C++:
void ProtocolGame::sendCancelTarget()
{
    NetworkMessage_ptr msg = getOutputBuffer();
    if(msg)
    {
        TRACK_MESSAGE(msg);
        msg->put<char>(0xA3);
        msg->put<uint32_t>(0); //? creatureId?
    }
}
but you can't send packets from Lua, so you will have to add function in luascripts.cpp and luascripts.h that will allow you to execute C++ sendCancelTarget on Player* from Lua.
 
Solution
You can use 'cancel target' packet to unset current target in tibia client.
On TFS 1.4 code that sends it is not available from Lua.
C++:
void ProtocolGame::sendCancelTarget()
{
    NetworkMessage msg;
    msg.addByte(0xA3);
    msg.add<uint32_t>(0x00);
    writeToOutputBuffer(msg);
}
but you can generate it in Lua and send this packet to player using:
LUA:
local networkMessage = NetworkMessage()
networkMessage:addByte(0xA3)
// if your client version is BELOW 8.60 remove line below (networkMessage:addU32(0x00))
networkMessage:addU32(0x00)
networkMessage:sendToPlayer(player)
networkMessage:delete()

EDIT:
On 0.4 there is also code to cancel target on Tibia 8.6:
C++:
void ProtocolGame::sendCancelTarget()
{
    NetworkMessage_ptr msg = getOutputBuffer();
    if(msg)
    {
        TRACK_MESSAGE(msg);
        msg->put<char>(0xA3);
        msg->put<uint32_t>(0); //? creatureId?
    }
}
but you can't send packets from Lua, so you will have to add function in luascripts.cpp and luascripts.h that will allow you to execute C++ sendCancelTarget on Player* from Lua.
First of all! Thanks for the insight! I think its time to update the core of the server and engine to 1.4. I started crafting my project long couple years and left untouched for too long. Tfs 0.4 clearly has some unusual bugs. And 1.4 offers way more possibilities overall to expand ideas! Thank you!

But overall, before that, i'll try that fix that you propose and update the thread!


EDIT:
Tested with pure cipsoft client and that issue doesn't exist.

Now, i'm confused!
 
Last edited:
Tested with pure cipsoft client and that issue doesn't exist.
Probably no one get into that problem before. War servers were popular before OTC existed. On normal server you die and client get 'login packet' that resets every module to clear state ex. attack target = null.
IDK how OTC/OTS did not reset target on your server. It's pretty strange. Normal 'teleport' (to temple) Lua function should detect that you get into PZ and target is outside, so it should send 'cancelTarget' packet. Maybe it's combination of TFS 0.4 bug and OTC bug.
 
Probably no one get into that problem before. War servers were popular before OTC existed. On normal server you die and client get 'login packet' that resets every module to clear state ex. attack target = null.
IDK how OTC/OTS did not reset target on your server. It's pretty strange. Normal 'teleport' (to temple) Lua function should detect that you get into PZ and target is outside, so it should send 'cancelTarget' packet. Maybe it's combination of TFS 0.4 bug and OTC bug.
I suppose you are right! I could just leave without the system tho, and let the death message appear and make the player login back. Reseting all packets. But the 'respawn effect" kinda adds an extra coolness effect. I'll investigate lil bit more. Overall, thanks for all the answers and suggestions!


another thing: everytime i try to login/relog i keep getting connection error 2 (connection lost) i need to retry like 2~3x before being able to login. It's that packet size or because im runNing a 32bit build on a 64bit system?
 
Last edited:
In case you don't want to or can't compile your engine with changes.

I could use an npc in the temple and have the player follow that npc with the doPlayerFollowCreature(cid, target) function.
That would des-select the target.
 
In case you don't want to or can't compile your engine with changes.

I could use an npc in the temple and have the player follow that npc with the doPlayerFollowCreature(cid, target) function.
That would des-select the target.
I can compile with no problem! But for now, until i finish the fixes i just removed the teleport function and let the death message appear. But thats interesting... Can i use something else like getCreatureTarget
 
I don't know exactly what engine you are using, but assuming you are using this: theforgottenserver-0.4 then you don't have a method to establish a target.

I was checking and there is only one method for monsters: luascript.cpp

I can compile with no problem! But for now, until i finish the fixes i just removed the teleport function and let the death message appear. But thats interesting... Can i use something else like getCreatureTarget

LUA:
local templePosition = {x = 0, y = 0, z = 0}
local dummyNpcName = "Dummy Npc"

function onPrepareDeath(cid, deathList)
    doTeleportThing(cid, templePosition, false)
    doSendMagicEffect(templePosition, CONST_ME_TELEPORT)

    local npcId = getCreatureByName(dummyNpcName)
    if npcId then
        doPlayerFollowCreature(cid, npcId)
    end
    return false
end
 
I don't know exactly what engine you are using, but assuming you are using this: theforgottenserver-0.4 then you don't have a method to establish a target.

I was checking and there is only one method for monsters: luascript.cpp



LUA:
local templePosition = {x = 0, y = 0, z = 0}
local dummyNpcName = "Dummy Npc"

function onPrepareDeath(cid, deathList)
    doTeleportThing(cid, templePosition, false)
    doSendMagicEffect(templePosition, CONST_ME_TELEPORT)

    local npcId = getCreatureByName(dummyNpcName)
    if npcId then
        doPlayerFollowCreature(cid, npcId)
    end
    return false
end
Thank you for the attention and time you put into this! But, unfortunately, that did not work! I'll keep as i said. Without the respawn script until i convert all my luas to revscript! It's working... Again, i thank everybody for the answers and enlightenment!
 
in player.cpp ondeath use sendCancelTarget();
BRO... ROFL; I was like, wait, what... I was investigating that exactly function on cpp; Added after teleport (because im using prepareDeath) and ondeath... Worked perfectly! So simple, unreal! Thanks a lot!


EDIT: PROBLEM SOLVED!
 
Back
Top