• 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 TFS 0.3.6

Daemonium

Programmer
Joined
Oct 18, 2015
Messages
57
Solutions
1
Reaction score
8
Location
Canada
Hello,
I would like to add a dodge system on my server. So if someone have one I would apreciate it!
Exemple:
0/100 dodge skill = 0% chance of dodge
100/100 dodge skill = 30% of dodge

Thank you!
 
Solution
Alright, you will need to add this in /data/action/action.xml:

XML:
<action itemid="ID OF YOUR ITEM HERE" event="script" value="dodge.lua" />

Then you need to add this in /data/action/script :
Name it dodge.lua

Lua:
local config = {
    effectonuse = 28, -- effect (/z)
    levelsdodge = 100,  --- Maximum dodge you can use
    storagedodge = 48902 -- storage verification
}
   
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 advanced your dodge skill to ["..(getPlayerStorageValue(cid, config.storagedodge)+1).."/100].")...
Alright, you will need to add this in /data/action/action.xml:

XML:
<action itemid="ID OF YOUR ITEM HERE" event="script" value="dodge.lua" />

Then you need to add this in /data/action/script :
Name it dodge.lua

Lua:
local config = {
    effectonuse = 28, -- effect (/z)
    levelsdodge = 100,  --- Maximum dodge you can use
    storagedodge = 48902 -- storage verification
}
   
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 advanced 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

Then you must add this in /data/creaturescript/creaturescript.xml :

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

then you must add again in /data/creaturescript/script :
Name it dodge.lua

Lua:
local lvldodge = 48902
local percent = 1


function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS 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

Finaly, add this in /data/creaturescript/script/login.lua

Lua:
if getPlayerStorageValue(cid, 48902) == -1 then -- dodge system essential
        setPlayerStorageValue(cid, 48902, 0) 
    end

registerCreatureEvent(cid, "dodge")

That's not made by me, I took it on blacktibia.
 
Solution
Code:
local lvldodge = 48902
local percent = 1
function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS 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

you can explain more this script ?
 
well with local percent = 1, you will have 30% chance of dodge if you have 100/100 dodge...

(getPlayerStorageValue(cid, lvldodge)*3) --> lvl dodge * 3 ex: 100*3==300
math.random (0,1000) ---> get a random number from 0 to 1000
300 >= random

anything else ?
 
Alright, you will need to add this in /data/action/action.xml:

XML:
<action itemid="ID OF YOUR ITEM HERE" event="script" value="dodge.lua" />

Then you need to add this in /data/action/script :
Name it dodge.lua

Lua:
local config = {
    effectonuse = 28, -- effect (/z)
    levelsdodge = 100,  --- Maximum dodge you can use
    storagedodge = 48902 -- storage verification
}
  
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 advanced 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

Then you must add this in /data/creaturescript/creaturescript.xml :

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

then you must add again in /data/creaturescript/script :
Name it dodge.lua

Lua:
local lvldodge = 48902
local percent = 1


function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS 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

Finaly, add this in /data/creaturescript/script/login.lua

Lua:
if getPlayerStorageValue(cid, 48902) == -1 then -- dodge system essential
        setPlayerStorageValue(cid, 48902, 0)
    end

registerCreatureEvent(cid, "dodge")

That's not made by me, I took it on blacktibia.
what about critical
 
is there a way to restrict by a storage? Example, player had to be a "x" storage above "x" value to use item.
 
Last edited:
I'll add here critical too:
Add this line in /data/action/action.xml:
XML:
<action itemid="ITEM ID HERE" event="script" value="critical.lua" />
Create this file /data/action/script/critical.lua:
Lua:
 local config = {
   effectonuse = 28, -- effect (/z)
   levelscrit = 100,  --- maximum critical you can use
   storagecrit = 48903 -- storage verification
   }
  
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, config.storagecrit) < config.levelscrit then
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(topos,config.effectonuse)
        doPlayerSendTextMessage(cid,22,"You've advanced your critical skill to ["..(getPlayerStorageValue(cid, config.storagecrit)+1).."/100].")
        setPlayerStorageValue(cid, config.storagecrit, getPlayerStorageValue(cid, config.storagecrit)+1)
    elseif getPlayerStorageValue(cid, config.storagecrit) >= config.levelscrit then
        doPlayerSendTextMessage(cid,22,"You've already reached the MAX level of critical skill.\nCongratulations!!!!")
    return 0
    end
return 1
end
Add this in /data/creaturescript/creaturescript.xml:
XML:
<event type="statschange" name="critical" event="script" value="critical.lua"/>
Create this file /data/creaturescript/script/critical.lua:
Lua:
local lvlcrit = 48903
local multiplier = 1

function onStatsChange(cid, attacker, type, combat, value)
    if (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and isPlayer(attacker) and isCreature(cid) then
        if (getPlayerStorageValue(attacker, lvlcrit)*3) >= math.random (0,1000) then
            value = math.ceil(value*(multiplier))
            doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
            doSendAnimatedText(getCreaturePos(attacker), "CRITICAL", 144)
        return false
        end
    end
return true
end
Finaly, add this in /data/creaturescript/script/login.lua:
Lua:
    if getPlayerStorageValue(cid, 48903) == -1 then --critical system essential
        setPlayerStorageValue(cid, 48903, 0)
    end

    registerCreatureEvent(cid, "critical")
 
Dodge works, but critical dont =/. No error, no console error. but no appear critical damage and no increase damage. (put multplier 1.5). When i attack player (PvP) pop-up critical appears, but not increase damage. I want to put critical against monsters too
 
Last edited:
if you have more than 100 players online will get laaag with this script, the best way to make dodge and critical for 0.3 or 0.4 in source edit
mana leech and life leech and dodge and critical and increase damage and reduction damage fo 0.4 source edit
 
if you have more than 100 players online will get laaag with this script, the best way to make dodge and critical for 0.3 or 0.4 in source edit
mana leech and life leech and dodge and critical and increase damage and reduction damage fo 0.4 source edit
do you have one place who teach do this?
 
Back
Top