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

Dodge System Sevu

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Staff member
TFS Developer
Support Team
Joined
Mar 16, 2017
Messages
1,427
Solutions
155
Reaction score
1,990
Location
London
GitHub
MillhioreBT
Twitch
millhiorebt
Only work with oficial TFS 1.3 Revscript

data/scripts/dodgesevusystem.lua

Lua:
local config = {
    dodgeItemId = 8298,
    chance = 100, -- default 100%
    limit = 100, -- default 100%
    storage = 25250, -- default 25250
    say = "DODGE!",
    effect = CONST_ME_POFF,
    defaultChance = 0
}

local dodgeSevu = Action()

function dodgeSevu.onUse(player, item, fromPos, target, toPos, isHotkey)
    if not target or not target:isPlayer() then
        player:sendCancelMessage("Only work on players.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF, player)
        return true
    end

    local current = math.max(target:getStorageValue(config.storage), 0)
    if current >= config.limit then
        player:sendCancelMessage("You already have the ability to dodge to the maximum.")
        target:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    if math.random(100) <= config.chance then
        target:setStorageValue(config.storage, current +1)
        target:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, stirng.format("You have improved your ability to dodge: [%d/%d]!", current +1, config.limit))
        target:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
        return true
    end

    player:sendCancelMessage("The dodge upgrade has failed!")
    target:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end

dodgeSevu:id(config.dodgeItemId)
dodgeSevu:register()

local dodgeSevuHC = CreatureEvent("DodgeSevuHC")

function dodgeSevuHC.onHealthChange(player, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local chance = (config.defaultChance + (player:getStorageValue(config.storage) / 2))
    if chance > 0 and math.random(100) <= chance then
        player:say(config.say)
        player:getPosition():sendMagicEffect(config.effect)
        return 0, primaryType, 0, secondaryType
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

dodgeSevuHC:register()

local dodgeSevuMC = CreatureEvent("DodgeSevuMC")

function dodgeSevuMC.onManaChange(player, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local chance = (config.defaultChance + (player:getStorageValue(config.storage) / 2))
    if chance > 0 and math.random(100) <= chance then
        player:say(config.say)
        player:getPosition():sendMagicEffect(config.effect)
        return 0, primaryType, 0, secondaryType
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

dodgeSevuMC:register()

local dodgeSevuLogin = CreatureEvent("DodgeSevuLogin")

function dodgeSevuLogin.onLogin(player)
    player:registerEvent("DodgeSevuHC")
    player:registerEvent("DodgeSevuMC")
    return true
end

dodgeSevuLogin:register()

Use item 8298 on your player to increase your dodge skill
 
Last edited:
What would be the equivalent for type="healthchange" and player:registerEvent( )?
 
Works great but can you make it so when i use the item it gets removed from my backpack?
 
@Christ_11

creaturescripts.xml
XML:
<event type="statschange" name="dodge" event="script" value="dodge.lua"/>

create new lua file, rename it for: dodge.lua
Lua:
local lvldodge = 48902
local percent = 0.5

function onStatsChange(cid, attacker, type, combat, value)
if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS and isCreature(attacker) then
if (getPlayerStorageValue(cid, lvldodge)*3) >= math.random (0,1000) then
value = math.ceil(value*(percent))
doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
doSendAnimatedText(getCreaturePos(cid), "DODGE", 6)
return false
end
end
return true
end

add this on login.lua
Lua:
registerCreatureEvent(cid, “dodge”)
if getPlayerStorageValue(cid, 48902) == –1 then       
setPlayerStorageValue(cid, 48902, 0)      end

go to actions.xml
XML:
<action itemid="ITEMID" script="dodge.lua"/>

dodge.lua
Lua:
local config = {
   effectonuse = 14, -- effect
   levelsdodge = 100,  --- max dodge level
   storagedodge = 48902 -- storage
   }
   
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, config.storagedodge) < config.levelsdodge then
   doRemoveItem(item.uid, 1)
doSendMagicEffect(topos,config.effectonuse)
doPlayerSendTextMessage(cid,22,"You've Leveled your Dodge Skill to ["..(getPlayerStorageValue(cid, config.storagedodge)+1).."/100].")
setPlayerStorageValue(cid, config.storagedodge, getPlayerStorageValue(cid, config.storagedodge)+1)
elseif getPlayerStorageValue(cid, config.storagedodge) >= config.levelsdodge then
doPlayerSendTextMessage(cid,22,"You've already reached the MAX level of Dodge Skill.\nCongratulations!!!!")
    return 0
    end
return 1
end
 
@changos can you make this remove the item?
local configuracion = {
dodge_chance = 100, -- default 100% ( recomendado 100% ) probabilidad de que no falle
dodge_limite = 100, -- default 100% ( recomendado 100% ) 100 = 50
dodge_storage = 25250 -- default 25250
}
local function storageMenor(self)
local current = 0
if self:getStorageValue(configuracion.dodge_storage) < 0 then
self:setStorageValue(configuracion.dodge_storage, 0)
end
current = self:getStorageValue(configuracion.dodge_storage)
return current
end
function onUse(player, item, fromPos, target, toPos, isHotkey)
if not target:isPlayer() then
player:doRemoveItem(item.uid, 1)
player:sendCancelMessage('This item can only be used by characters.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
else
if (math.random(100) <= configuracion.dodge_chance) then
local dodge_current = target:getStorageValue(configuracion.dodge_storage)
if dodge_current < configuracion.dodge_limite then
dodge_current = (storageMenor(target) + 1)
target:setStorageValue(configuracion.dodge_storage, dodge_current)
target:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You have improved the Dodge Skill [ ' .. dodge_current .. ' / ' .. configuracion.dodge_limite .. ' ]')
target:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
else
player:sendCancelMessage('This character already has the Dodge Skill to the maximum [ ' .. configuracion.dodge_limite .. ' ]')
target:getPosition():sendMagicEffect(CONST_ME_POFF)
end else
player:sendCancelMessage('Skill Improvement Failed.')
target:getPosition():sendMagicEffect(CONST_ME_POFF)
end end
return true
end
function onCastSpell(creature, var, isHotkey)
return combat:execute(creature, var)
end
 
@Turith

Lua:
 local configuracion = {
dodge_chance = 100, -- default 100% ( recomendado 100% ) probabilidad de que no falle
dodge_limite = 100, -- default 100% ( recomendado 100% ) 100 = 50
dodge_storage = 25250 -- default 25250
}
local function storageMenor(self)
local current = 0
if self:getStorageValue(configuracion.dodge_storage) < 0 then
self:setStorageValue(configuracion.dodge_storage, 0)
end
current = self:getStorageValue(configuracion.dodge_storage)
return current
end
function onUse(player, item, fromPos, target, toPos, isHotkey)
if not target:isPlayer() then
player:sendCancelMessage('This item can only be used by characters.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
else
if (math.random(100) <= configuracion.dodge_chance) then
local dodge_current = target:getStorageValue(configuracion.dodge_storage)
if dodge_current < configuracion.dodge_limite then
dodge_current = (storageMenor(target) + 1)
target:setStorageValue(configuracion.dodge_storage, dodge_current)
target:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You have improved the Dodge Skill [ ' .. dodge_current .. ' / ' .. configuracion.dodge_limite .. ' ]')
target:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
item:remove(1)
else
player:sendCancelMessage('This character already has the Dodge Skill to the maximum [ ' .. configuracion.dodge_limite .. ' ]')
target:getPosition():sendMagicEffect(CONST_ME_POFF)
end 
else
player:sendCancelMessage('Skill Improvement Failed.')
target:getPosition():sendMagicEffect(CONST_ME_POFF)
item:remove(1)
end
 end
return true
end
 
Hola amigas y amigos de ot land, quiero compartir con todos ustedes un sistema de dodge que he creado, funciona perfectamente, muy parecido pero solo sera compatible si tu server es TFS [ 1.2 ] quizas [ 1.0 ]
bueno sin mas empezemos:

Primero que nada crearemos la dodge stone, vamos a data/actions/
abrimos el archivo actions.xml y pegamos este codigo.
Code:
<action itemid="8298" script="dodge stone.lua" />
Luego vamos a data/actions/scripts/ y creamos un nuevo archivo.lua [ le ponen de nombre dodge stone.lua ] donde vamos a pegar este codigo:
Lua:
    local configuracion = {

    dodge_chance = 100, -- default 100% ( recomendado 100% ) probabilidad de que no falle
    dodge_limite = 100, -- default 100% ( recomendado 100% ) 100 = 50
    dodge_storage = 25250 -- default 25250
    }

    local function storageMenor(self)
    local current = 0
    if self:getStorageValue(configuracion.dodge_storage) < 0 then
    self:setStorageValue(configuracion.dodge_storage, 0)
    end
    current = self:getStorageValue(configuracion.dodge_storage)
    return current
    end

    function onUse(player, item, fromPos, target, toPos, isHotkey)

    if not target:isPlayer() then
    player:sendCancelMessage('Este objeto solo puede ser usado por personajes.')
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
    else
    if (math.random(100) <= configuracion.dodge_chance) then
    local dodge_current = target:getStorageValue(configuracion.dodge_storage)
    if dodge_current < configuracion.dodge_limite then
    dodge_current = (storageMenor(target) + 1)
    target:setStorageValue(configuracion.dodge_storage, dodge_current)
    target:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Has mejorado el Dodge Skill [ ' .. dodge_current .. ' / ' .. configuracion.dodge_limite .. ' ]')
    target:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    else
    player:sendCancelMessage('Este personaje ya tiene el Dodge Skill al maximo [ ' .. configuracion.dodge_limite .. ' ]')
    target:getPosition():sendMagicEffect(CONST_ME_POFF)
    end else
    player:sendCancelMessage('Ha fallado la mejora del Skill.')
    target:getPosition():sendMagicEffect(CONST_ME_POFF)
    end end


    return true
    end
Despues nos vamos a data/creaturescripts/ y abrimos el archivo creaturescripts.xml y pegamos esto:
Code:
<event type="healthchange" name="DodgeSystem" script="dodge system.lua" />
Ahora vamos a data/creaturescripts/scripts/ y creamos un archivo.lua [ le ponen de nombre dodge system.lua ] y pegamos este codigo en ese nuevo archivo:
Lua:
    -- SRH Momentum (Sevu)

    local configuracion = {
    proteccion = 0, -- deafault 0% to 1% ( recomendado 0 )
    dodge_chance = 0, -- default chance 0% to 100% ( recomendado 0 )
    dodge_storage = 25250, -- default storage 25250 ( recomendado cualquiera no repetido )
    dodge_say = 'DODGE!', -- default 'DODGE!' recomendado ( 'DODGE!' )
    dodge_effect = CONST_ME_POFF
    }

    function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

    if creature:isPlayer() then
    if primaryDamage > 0 then
    local chance = (configuracion.dodge_chance + (creature:getStorageValue(configuracion.dodge_storage) / 2))
    if chance < 0 then chance = 0 end
    if (math.random(100) < chance) then
    primaryDamage = (primaryDamage * configuracion.proteccion)
    creature:say(configuracion.dodge_say, TALKTYPE_MONSTER_SAY)
    creature:getPosition():sendMagicEffect(configuracion.dodge_effect)
    end end end
   
    return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
Para terminar con este tutorial nos vamos a data/creaturescripts/scripts/ abrimos el archivo [ login.lua ] y pegaremos este codigo:
Lua:
player:registerEvent("DodgeSystem")
Bueno eso seria todo chic@s, espero les guste mucho.

ighkb4.jpg
buen sistema pero deberias agregar un doRemoveItem(item:getUniqueId(), 1 ) si falla o no falla dodge stone.lua
la otra cuestion es que tambien hace dodge cuando se usan hechizos de curacion, cuando regrese a casa vere como agregar para que eso no pase
 
en dodge system se puede agregar en el
Lua:
if primaryDamage > 0  then
agregar esto
Lua:
and primaryType ~= COMBAT_HEALING
quedaria asi
Lua:
if primaryDamage > 0 and primaryType ~= COMBAT_HEALING then

parece ser que con eso se corregiria lo del heal
 
Agradezco mucho a los que ayudan a acomodar esos pequeños errores, de verdad disculpenme por eso, debido a que nunca probé ese sistema pues no sabia si existía alguna falla, bueno al menos sirve chicos! Saludos y gracias nuevamente. Si alguien sabe de precios de OT server me informaría ??? Quiero vender un gran proyecto pero no tengo ni la remota idea de cuanto vale o cuesta algo así!!! Sean realistas por favor. Byeee
 
Agradezco mucho a los que ayudan a acomodar esos pequeños errores, de verdad disculpenme por eso, debido a que nunca probé ese sistema pues no sabia si existía alguna falla, bueno al menos sirve chicos! Saludos y gracias nuevamente. Si alguien sabe de precios de OT server me informaría ??? Quiero vender un gran proyecto pero no tengo ni la remota idea de cuanto vale o cuesta algo así!!! Sean realistas por favor. Byeee
De nada y la verdad es que no tengo ni la mas mínima idea haha yo solo tengo el pasatiempo de hacer mi ot ideal
 
Lo siento parece ser que me equivoque un poco la cuestion de que hace dodge en los heals es por que el if es primaryDamage > 0 y deberia ser primaryDamage < 0 ya que el daño debe ser negativo o bueno ahora que estoy haciendo test en mi ot asi es como parece ser que funciona haha una disculpa si confundi a alguien
 
Back
Top