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

developing weapon

Gubailovo

Well-Known Member
Joined
Dec 19, 2013
Messages
407
Solutions
2
Reaction score
62
I need weapons that increase their level with the number of hits.
I have an example of a staff.
But it works the other way around.
After applying a certain number of hits, it disappears.
\data\actions\lib\actions
Code:
function removeCharge(cid, itemuid)
    charge = itemUseCharge(itemuid)
    -- doPlayerSendTextMessage(cid,18,"заряды: "..charge )
    if charge < 0 then
        --doPlayerRemoveItem(cid, itemid, 1)
        doRemoveItem(itemuid, 1)
        doPlayerSendTextMessage(cid,20,"Заряды предмета закончились.")
    end
end

function tryUseStuff(item)
     charges = getItemCharges(item.uid)
    if chrages >= 1 then
        setItemCharges(item.uid, charges - 1)
        return true
    else
        return false
    end
end

\data\items\items
XML:
<item id="2453" isStuff="1" minLevel="10" charges="50000" priceSC="10">
    <buff title="Death damage" func_name="buff_death_damage" value="1"/>
</item>
\data\actions\actions
XML:
<action itemid="2453" script="stuff_astral_wand.lua" />
\data\actions\scripts\stuff_astral_wand.lua
Lua:
attackType = ATTACK_DEATH
animationEffect = NM_ANI_SUDDENDEATH

hitEffect = NM_ME_MORT_AREA
damageEffect = NM_ME_DRAW_BLOOD
animationColor = BLACK
offensive = true
drawblood = true

SuddenDeathObject = MagicDamageObject(attackType, animationEffect, hitEffect, damageEffect, animationColor, offensive, drawblood, 0, 0)

function onAttack(cid, cid2, item, frompos, topos, damage)
    mana = 2

    if tryUseAutomaticStuff(cid, topos, mana) == false then
        return 0
    end
    removeCharge(cid, item.uid)

    centerpos = {x=topos.x, y=topos.y, z=topos.z}
    
    SuddenDeathObject.minDmg = stuffDamageMin(cid, 5.1)
    SuddenDeathObject.maxDmg = stuffDamageMax(cid, 8.1)

    doTargetMagicNoExhaustion(cid, centerpos, SuddenDeathObject:ordered())

    return 1
end


i tried adding to the library
Lua:
function tryUseSword(item)

     charges = getItemCharges(item.uid)

    if chrages >= 1 then

        setItemCharges(item.uid, charges + 1)

        return true

    else

        return false

    end

end
But it didn't work. Perhaps you need to link this to a database. How to do it?
Thanks in advance for any hint.
 
hard to say since i dont recognize most functions you used i guess you can try something like this
Lua:
function tryUseSword(item)
local itemCharges = getItemCharges(item.uid)
local maxCharges = 50000 
local getExpChance = 100 -- get charge percent
if itemCharges < maxCharges and math.random(1,100) <= getExpChance  then
        setItemCharges(item.uid, charges + 1)
end
        return true

end
make basic item charges = 1 this will be your 0% level and 50 000 charges would be your 100% level - max value cant exceed ~60000 since charges variable is based on int16
Now calculate your damage based on actual item charges, if you want to slow exping weapon lower getExpChance.
You can also make something more advanced based on custom attributes that will count your levels and reset charges on every level up but solution I wrote will be good enough
 
Back
Top