• 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 Ghost Mode

Syryniss

Member
Joined
Feb 13, 2014
Messages
206
Reaction score
20
Hi. I wanted to ask if anyone know where I can find function that make player ghost. I want to disable this on going effect that is visible to us, when we are in ghost mode. In talkaction there were only effects which trigger at turning it on and off, so it must be somewhere in sources.
 
I analyzed a lot of cpp files but I'm stuck at this in player.h:
Code:
void sendCreatureChangeVisible(const Creature* creature, bool visible) {
            if (!client) {
                return;
            }

            if (creature->getPlayer()) {
                if (visible) {
                    client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
                } else {
                    static Outfit_t outfit;
                    client->sendCreatureOutfit(creature, outfit);
                }
            } else if (canSeeInvisibility()) {
                client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
            } else {
                int32_t stackpos = creature->getTile()->getStackposOfCreature(this, creature);
                if (stackpos == -1) {
                    return;
                }

                if (visible) {
                    client->sendAddCreature(creature, creature->getPosition(), stackpos, false);
                } else {
                    client->sendRemoveTileThing(creature->getPosition(), stackpos);
                }
            }
        }
and
Code:
void sendCreatureAppear(const Creature* creature, const Position& pos, bool isLogin) {
            if (client) {
                client->sendAddCreature(creature, pos, creature->getTile()->getStackposOfCreature(this, creature), isLogin);
            }
        }
It leads me nowhere from here, but I'm 90% sure, this is good direction. This appear function sends single teleport effect, but I have no idea where it is in code. Maybe it's client-sided? I'm using OTClient tho and coudn't find there anything as well...
 
Last edited:
I don't even understand what does he want xd
You need to do excatuly when you say /ghost function
What is that effect you speak about
 
Oh well, fck my english >.<
Ok then, do you remember
Code:
ghostModeInvisibleEffect = false
from TFS 0.3.6 config? I want to disable this effect, but there is no such option in TFS 1.0 so i guess it must be somewhere in sources (I don't know where exactly - that's why I'm asking). It's CONST_ME_MAGIC_BLUE effect that in running always when player is ghost or under invisible condition. I know that on ghost it isn't visible to anyone else, but still I want to disable it.
 
Oh well, fck my english >.<
Ok then, do you remember
Code:
ghostModeInvisibleEffect = false
from TFS 0.3.6 config? I want to disable this effect, but there is no such option in TFS 1.0 so i guess it must be somewhere in sources (I don't know where exactly - that's why I'm asking). It's CONST_ME_MAGIC_BLUE effect that in running always when player is ghost or under invisible condition. I know that on ghost it isn't visible to anyone else, but still I want to disable it.

what happened if u removed this from ghost talkaction
Code:
position:sendMagicEffect(CONST_ME_YALAHARIGHOST)
 
open tfs 1.1 in visual studio
go to luascript.cpp:
Code:
registerMethod("Player", "setGhostMode", LuaScriptInterface::luaPlayerSetGhostMode);

right click on function -> go to definition till you find it

or...

ctrl+f, select entire solution, write "ghost" and select "show all results"

if you're using older tfs, you should find similiar stuff
 
open tfs 1.1 in visual studio
go to luascript.cpp:
Code:
registerMethod("Player", "setGhostMode", LuaScriptInterface::luaPlayerSetGhostMode);

right click on function -> go to definition till you find it

or...

ctrl+f, select entire solution, write "ghost" and select "show all results"

if you're using older tfs, you should find similiar stuff

i already did it xD
no important result bro :)
that's why i've asked if he deleted this line what will happen xD
 
nothing
it's cpp version of doSendMagicEffect(getThingPos(cid), CONST_ME_YALAHARIGHOST)

but from my search there is nothing about effect related to ghostMode in source
the effect is only in ghost.lua script
in source it just speak about
push , walk , add , attack , etc .. but nothing speak about unvisible effect :D
 
@
This is mine ghost.lua:
Code:
function onSay(cid, words, param)
    local player = Player(cid)

    if player:getGroup():getId() < GROUP_BANNER then
        return false
    end

    local position = player:getPosition()
    local isGhost = not player:isInGhostMode()

    player:setGhostMode(isGhost)
    if isGhost then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now invisible.")
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
        position.x = position.x + 1
        position:sendMagicEffect(CONST_ME_SMOKE)
    end
    return false
end
The only effect here is smoke and it only appears when I turn it off, as intended. Thing, I'm looking for must be somewhere in sources.

I'm using TFS 1.0, but I think it doesn't matter in that case. I was already searching through source files, but I didn't find any effect connected to luaPlayerSetGhostMode function.
  1. Function in luascript.cpp is sending
    Code:
    player->switchGhostMode();
    tmpPlayer->sendRemoveTileThing(position, tile->getStackposOfCreature(tmpPlayer, player));
    tmpPlayer->sendCreatureAppear(player, position, true);
    tmpPlayer->sendCreatureChangeVisible(player, !enabled);
    First thing is just for other functions to check status. Second is removing player from others view(?). Third spawning this player back. And last one is for future meet creatures to not be able to see him. At least that's what I understand.
  2. Next, sendCreatureChangeVisible is declared in player.h and is sending:
    Code:
    client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
    client->sendCreatureOutfit(creature, outfit);
    client->sendAddCreature(creature, creature->getPosition(), stackpos, false);
    client->sendRemoveTileThing(creature->getPosition(), stackpos);
  3. sendAddCreature is defined in protocolgame.cpp and it's sending teleport effect. sendCreatureOutfit is also in protocolgame.cpp and looks like that:
    Code:
    void ProtocolGame::sendCreatureOutfit(const Creature* creature, const Outfit_t& outfit)
    {
        if (!canSee(creature)) {
            return;
        }
    
        NetworkMessage msg;
        msg.AddByte(0x8E);
        msg.add<uint32_t>(creature->getID());
        AddOutfit(msg, outfit);
        writeToOutputBuffer(msg);
    }
    I guess that outfit must be continious animation, but how to change it to no outfit at all?
 
Last edited:
so what happen if you delete this line too
Code:
position:sendMagicEffect(CONST_ME_SMOKE)
tell me result please and if u explain with pics it will be awesome
because i feel that i'm stupid :/ and miss understand you xD
 
This line adds single effect when I exit ghost mode. Doesn't matter at all.

Edit
Hold on guys. The rescue is coming (I mean video, to help you understand xD)
 
Last edited:
Here you have video - sprites are not from original Tibia, but whatever.
You can see, after I use ghost there is continious animation = this is what I want to remove. And when I turn it off there is CONST_ME_SMOKE which o_O o_O was asking for.
Sorry for double post, but I wanted to make it visible, I know my english is bad and sometimes it's hard to understand what I want to say.
 
Here you have video - sprites are not from original Tibia, but whatever.
You can see, after I use ghost there is continious animation = this is what I want to remove. And when I turn it off there is CONST_ME_SMOKE which o_O o_O was asking for.
Sorry for double post, but I wanted to make it visible, I know my english is bad and sometimes it's hard to understand what I want to say.

delete this line to remove smoke .. ghost.lua
Code:
position:sendMagicEffect(CONST_ME_SMOKE)

the effect happen on water only or normal tiles too ?
what about normal tiles ? cuz it maybe swimming effect :) and we can check if it could be delete through swiming.lua , to delete the effect
 
client->sendCreatureOutfit(creature, outfit);
try replacing to
client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
 
also try this is movements/swimming.lua
Code:
local outfit = {lookType = 267, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}

function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player or player:isInGhostMode() then
        return false
    end

    doSetCreatureOutfit(cid, outfit, -1)
end

function onStepOut(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return false
    end

    player:removeCondition(CONDITION_OUTFIT)
end
 
The water where I was recording is not using swimming.lua. Also the same thing happens on any other tile. And I already told you that
Code:
position:sendMagicEffect(CONST_ME_SMOKE)
is for the single animation at the end, which you can see on video.

@zbizu
As I expected, after the change I keep my outfit (so, I'm not transparent), but the animation is gone. So, the question is, how to send blank outfit instead of currentOutfit?
6h4V4ok.png

PS. Also, this is not very important, but after change when I'm ghost I keep my outfit and im invisible to others. BUT moving on water (which uses swimming) and returning back to ground or not "swimming" water brings animation back and my outfit is gone. So this needs few more changes, but it's not a big deal, it's only water.
 
Back
Top