• 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 per item

115820

Member
Joined
Feb 27, 2011
Messages
193
Solutions
1
Reaction score
5
Location
London, England
Hi i'm use this system, but dont works like i want
This is a MODS

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Dodge System" version="0.1" author="Night Wolf" contact="" enabled="yes">
<event type="login" name="registerDodge" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid,"dodge")
return true
end
]]></event>


<event type="statschange" name="dodge" event="script"><![CDATA[






function onStatsChange(cid, attacker, type, combat, value)
if (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and isCreature(attacker) then
    local max = 40
    local slotPos = {1,2,3,4,5,6,7,8,9}
    local percent = 0.1
    local dodgePercent = 0


for i = 1, #slotPos do
if getPlayerSlotItem(cid, slotPos[i]).uid > 1 then
if getItemDodgePercent(getPlayerSlotItem(cid, slotPos[i]).uid) then
dodgePercent = dodgePercent + getItemDodgePercent(getPlayerSlotItem(cid, slotPos[i]).uid)
end
end
end
if dodgePercent >= max then dodgePercent = max end
if dodgePercent >= math.random (0,100) 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]]></event>
</mod>

Actions:

Lua:
function isHandItem(uid) -- NW based on Mock
         uid = uid or 0
        if isInArray({1,2,3,4,5,6}, getItemWeaponType(uid)) then
             return true
         end
         return false
end


function getItemDodgePercent(itemuid)
return getItemAttribute(itemuid, "dodgePercent") or 0
end


function setItemDodgePercent(uid, percent)
doItemSetAttribute(uid, "description", "[Dodge: "..percent.."%]")
doItemSetAttribute(uid, "dodgePercent", percent)
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
dodge = 0
local upgrade = {
[1] = {min = 1, max = 5, chance = 100},
[2] = {min = 5, max = 10, chance = 80},
[3] = {min = 10, max = 20, chance = 60},
[4] = {min = 25, max = 35, chance = 40},
[5] = {min = 35, max = 50, chance = 30}
}


function isWearing(uid) -- NW based on Mock
         uid = uid or 0
        if isInArray({uid}, getPlayerSlotItem(cid, 1).uid) or isInArray({uid},  -- HELMET --
        getPlayerSlotItem(cid, 2).uid) or isInArray({uid}, -- Aol --
        getPlayerSlotItem(cid, 4).uid) or isInArray({uid}, -- ARMOR --
        getPlayerSlotItem(cid, 9).uid) or isInArray({uid}, -- RING --
        getPlayerSlotItem(cid, 7).uid) or isInArray({uid}, -- LEGS --
        getPlayerSlotItem(cid, 8).uid) then -- BOOTS --
             return true
         end
         return false
end


if isHandItem(itemEx.uid) or isWearing(itemEx.uid) then
local name = getItemName(itemEx.uid)
local atual = math.floor(getItemDodgePercent(itemEx.uid)*10)/10
for i = 1, #upgrade do
if string.find(tostring(name),"Dodge: " .. i .."") then
dodge = i
end
end


if dodge >= #upgrade then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Este item ja esta no maximo de Dodge possivel!")
return true
end


if math.random(0,100) <= upgrade[dodge + 1].chance then
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Sucesso ao usar sua Dodge Stone!")
setItemDodgePercent(itemEx.uid, atual + (math.random(upgrade[dodge+1].min,upgrade[dodge+1].max))/10)
doItemSetAttribute(itemEx.uid,'name', getItemNameById(itemEx.itemid)..' [Dodge: ' ..dodge+1 .."/5]")
doSendMagicEffect(toPosition, math.random(28,30))
else
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Sua Dodge Stone Falhou :(")
doSendMagicEffect(toPosition, 4)
end


else
doPlayerSendTextMessage(cid, 24,"You cant refine this item.")
end
return true
end


LIB

Lua:
function getItemDodgePercent(itemuid)
return getItemAttribute(itemuid, "dodgePercent")
end
function doPlayerAddDodgeItem(cid, itemid, percent)
local item = doPlayerAddItem(cid, itemid)
doItemSetAttribute(item, "description", "[Dodge: "..percent.."%]")
doItemSetAttribute(item, "dodgePercent", percent)
end


ERROR :
1623127452143.png
 
Back
Top