• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.X otx 2.16 based on 0.3.7 --- dodge ---

Creating everyday threads instead of using chatGpt or deepseek (its free) is crazy
and using 0.3.6/0.4 is even crazier without any experience

trust me you will be mad later that you havent used tfs 1.x
 
I asked. What harm did it do? I'll try chat gpt
Post automatically merged:

I have datapack baiak for otx 2.16 with events. Iam stay at
 
Last edited:
I asked. What harm did it do? I'll try chat gpt
Post automatically merged:

I have datapack baiak for otx 2.16 with events. Iam stay at

My bad said it like a idiot to be honest
Just trying to save your life with tfs 0.4 xD
 
Hehe datapack only works with otx. Its brazilian style evo. This is popular engine there. 0.4 I tryed run but events doesnt work. always something...
Post automatically merged:

MY dodge script is :
LUA:
local storagedodge = 98798644 -- storage do dodge
local cor = 250 -- cor do texto
local effect = 31 -- id do magic effect
local msg = "Esquivou." -- msg
 
 local dodge = {
    {min = 1, max = 10, chance = 4}, -- se o dodge tiver entre 1 e 2 tem 10% de chance de da dodge.
    {min = 11, max = 20, chance = 5}, -- vocęs pode adicionar mas se quiserem
    {min = 21, max = 40, chance = 6},    --- quando chance estriver = 1 equivale a 10%, quando estiver 0.5 = 5 % e etc..
    {min = 41, max = 50, chance = 7},
    {min = 51, max = 70, chance = 8},
    {min = 71, max = 90, chance = 9},
    {min = 91, max = 100, chance = 12},
}
 
function onStatsChange(cid, attacker, type, combat, value)
    if not isPlayer(cid) then
        return false
    end
    if combat == COMBAT_HEALING then return true end
    local sto_doge = tonumber(getPlayerStorageValue(cid, storagedodge))
    if sto_doge and sto_doge >= 1 then
        if getCreatureStorage(cid,722640) == 1 then
            sto_doge = tonumber(sto_doge + 10)
        end
        local chance = (sto_doge/6) >= 1 and math.ceil(sto_doge / 6) or 1
        local random = math.random(100)
        if random <= chance then
            local cid_pos = getCreaturePosition(cid)
            doSendMagicEffect(cid_pos, effect)
            doSendAnimatedText(cid_pos, msg, cor)
            return false
        end
    end

    if getCreatureStorage(cid, 722640) == 1 then
        value = value - (value * 0.03)
        return true
    end
    --[[for _, tudo in pairs(dodge) do
        if sto_doge and sto_doge >= tudo.min and sto_doge < tudo.max then
            local chancex = math.random(1, 100)
            if chancex <= tudo.chance then
                doSendMagicEffect(getCreaturePosition(cid), effect)
                doSendAnimatedText(getCreaturePosition(cid), msg, cor)
                return false
            end
        end
    end]]
    return true
end

and in data/creaturescript/login.lua
Code:
if getPlayerStorageValue(cid, 48902) == -1 then -- dodge system essential
        setPlayerStorageValue(cid, 48902, 0)
    end
It should be difrent storage number 48902 and 98798644 ??
 
Last edited:
Here

LUA:
local storagedodge = 98798644 -- storage del dodge
local cor = 250 -- color del texto
local effect = 31 -- efecto mágico
local msg = "Esquivou." -- texto

-- tabla opcional si algún día quieres sistema por rangos (ahora no se usa)
local dodge = {
    {min = 1, max = 10, chance = 4},
    {min = 11, max = 20, chance = 5},
    {min = 21, max = 40, chance = 6},
    {min = 41, max = 50, chance = 7},
    {min = 51, max = 70, chance = 8},
    {min = 71, max = 90, chance = 9},
    {min = 91, max = 100, chance = 12},
}

function onStatsChange(cid, attacker, type, combat, value)
    if not isPlayer(cid) then
        return true
    end

    if combat == COMBAT_HEALING then
        return true
    end

    local sto_doge = tonumber(getPlayerStorageValue(cid, storagedodge))
    if sto_doge == nil then
        sto_doge = 0
    end

    -- Si tiene dodge activo
    if sto_doge >= 1 then
        -- Bonus extra si tiene este storage
        if getCreatureStorage(cid, 722640) == 1 then
            sto_doge = sto_doge + 10
        end

        -- Chance escalado
        local chance = (sto_doge / 6) >= 1 and math.ceil(sto_doge / 6) or 1
        local random = math.random(100)

        if random <= chance then
            local pos = getCreaturePosition(cid)
            doSendMagicEffect(pos, effect)
            doSendAnimatedText(pos, msg, cor)
            return false -- esquiva el golpe
        end
    end

    -- Reducción de daño si tiene este storage activo
    if getCreatureStorage(cid, 722640) == 1 then
        value = value - (value * 0.03)
        doTargetCombatHealth(attacker, cid, COMBAT_PHYSICALDAMAGE, -value, -value, effect)
        return false -- ya aplicamos el daño manual
    end

    return true
end
 
I asked. What harm did it do? I'll try chat gpt
Post automatically merged:

I have datapack baiak for otx 2.16 with events. Iam stay at
otx2 or tfs 0.3.6 0.4 should go to the trash can. even if you don't know how to improve it. do not waste your time. any free or paid ot (included)
 
in player.cpp
add
LUA:
int32_t Player::getDodge() const
{
    int32_t Dodgestorage = 0;
    std::string value;
    getStorage("98798644", value); // add here your dodge storage
    Dodgestorage = (int32_t)(atoi(value.c_str()));

    return  Dodgestorage;
}

in player.h after getArmor() const; add virtual int32_t getDodge() const;



in BlockType_t Player::blockHit
after
if(damage <= 0)
return blockType;

add
Code:
int32_t dodge =  getDodge();
    if(combatType != COMBAT_NONE && (random_range(1, 100) < dodge))
    {
        sendDodge();
        blockType = BLOCK_IMMUNITY;
        return blockType;
    }


at the end of player.cpp file add
Code:
void Player::sendDodge() const

{

        g_game.addAnimatedText(getPosition(), COLOR_GREY, "Dodge!");

    //    g_game.addMagicEffect(getPosition(), 76);   if you have effect can use it

}

and in player.h after void sendCritical() const; add
void sendDodge() const;
 
probably it will be problem at compiling

Thanks for CODE. Do you maybe know witch version of visual studio I can use ?
 
in BlockType_t Player::blockHit
after
if(damage <= 0)
return blockType;

I don't have
LUA:
if(damage <= 0)

return blockType;
I have got
Code:
        virtual BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
            bool checkDefense = false, bool checkArmor = false, bool reflect = true, bool field = false, bool element = false);
 
ok I uninstal visual 2015 and will install 2022 . We are waiting
Post automatically merged:

i got the error boost/foreach.hpp. Visual start compile and end at first cpp file otpch.cpp. Do you know what it is?
 
Last edited:
OKAY. compile works for clean source. with Your code i've got problem.
Maybe can you fill it out for me? and made alone to.

hot request
 
LUA:
void Player::sendDodge() const
{
    g_game.addAnimatedText(getPosition(), COLOR_DARKRED, "Dodge!");
  //g_game.addMagicEffect(getPosition(), 20);   if you have effect can use it
}

player.h
void sendDodge() const;


or remove sendDodge and use this code


Code:
int32_t dodge =  getDodge();
    if(combatType != COMBAT_NONE && (random_range(1, 100) < dodge))
    {
        g_game.addAnimatedText(getPosition(), COLOR_DARKRED, "Dodge!");
        blockType = BLOCK_IMMUNITY;
        return blockType;
    }
 
Back
Top