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

GhostMode for Gods

EduardoDantas

Intermediate OT User
Joined
Sep 25, 2013
Messages
192
Solutions
5
Reaction score
143
Location
Brazil
I am creating a "sauron ring" script just like the Lord of the Rings.
I was able to make the script functional, but when testing I came across a pretty chatinha function: when equipping the player it is invisible and everything, but also it has the condition of not being able to be attacked (which is annoying, since I intend to do with that by taking hit the player who has the equipped ring loses the condition of invisibility for x seconds and then returns to become invisible)
Can somebody get a light?
Searching I came to the conclusion that to change this I will have to tinker with the sources, but I have no idea how to change this, my knowledge in c ++ are shallow, to say nothing, haha
Can someone give a light?

Code:
function onEquip(cid, item, slot)
local player = Player(cid)
    if isPlayer() then
        return true
    end
    
    local position = player:getPosition()
    local isGhost = not player:isInGhostMode()
        item:transform(2202)
        player:setGhostMode(isGhost)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are invisible.")
        -- position.x = position.x + 1
        position:sendMagicEffect(67)
    return true
end

function onDeEquip(cid, item, slot)
local player = Player(cid)
    if isPlayer() then
        return true
    end

    local position = player:getPosition()
    local isGhost = not player:isInGhostMode()
        item:transform(2165)
        player:setGhostMode(isGhost)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
        -- position.x = position.x + 1
        position:sendMagicEffect(67)
    return true
end
 
This check causes players in ghost mode to block all hits. You could change it so it only blocks all hits if the player is a gm/god.
Afterwards, you should be able to add a health change creaturescript that removes ghost mode when the player is damaged.
 
This check causes players in ghost mode to block all hits. You could change it so it only blocks all hits if the player is a gm/god.
Afterwards, you should be able to add a health change creaturescript that removes ghost mode when the player is damaged.

First of all, thanks for the great idea.

If someone looks for the same, here is the changed function in source:

You are in a change in game.cpp so that the case is player can be as much as by monsters even in the ghostmode (function of the gods)


In the sources src/game.cpp replace from line 3738 to line 3747 by:
Code:
bool Game::combatBlockHit(CombatDamage& damage, Creature* attacker, Creature* target, bool checkDefense, bool checkArmor, bool field)
{
    Player* targetPlayer = target->getPlayer();
    if (damage.primary.type == COMBAT_NONE && damage.secondary.type == COMBAT_NONE) {
        return true;
    }

    if (target->isInGhostMode() && targetPlayer->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && targetPlayer->getAccountType() < ACCOUNT_TYPE_GOD) {
        return true;
    }
 
Last edited:
local invisible = createConditionObject(CONDITION_GAMEMASTER, -1, false, GAMEMASTER_INVISIBLE)
local outfit = createConditionObject(CONDITION_INVISIBLE, -1, false)

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, TRUE)
addDamageCondition(condition, -1, 1500, -500)


function onEquip(cid, item, slot)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "By using this ring you will become fully invisible and lose health over time because of it's curse.")
doAddCondition(cid, condition)
doAddCondition(cid, invisible)
doAddCondition(cid, outfit)
doSendMagicEffect(getCreaturePos(cid), 12)
return true
end

function onDeEquip(cid, item, slot)
doTransformItem(item.uid, 2165)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You're no longer receiving the special bonus..")
doRemoveCondition(cid, CONDITION_PHYSICAL)
doRemoveCondition(cid, CONDITION_INVISIBLE)
doSendMagicEffect(getCreaturePos(cid), 12)
doRemoveCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE)
return true
end
 
Back
Top