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

Weapon auto upgrade

erikbs

Member
Joined
Jul 15, 2010
Messages
40
Reaction score
8
Hi there.

Here is a little script that I found to be cool. Iam just testing it on a closed server with only a limited amount of players, so I have no idea if this makes your server lag when more people are online.

Here is a wand script:
This script has a min and max dmg formula which it bases it damage lvling on.
So in this example, after a player has fired this wand 250 times, it will increase its damage by 3%.


Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

local executionCounterStorage = 120 -- Set the storage value to track execution count
local damageIncreasePercent = 3 -- Damage increase percentage
local damageIncreaseThreshold = 250 -- Threshold for damage increase

function onGetFormulaValues(player, level, magicLevel)
    local min = (level * 1.1) + (magicLevel * 4) + 5
    local max = (level * 1.15) + (magicLevel * 6) + 15

    -- Check execution count and increase damage if needed
    local executionCount = getPlayerStorageValue(player, executionCounterStorage) or 0
    local damageIncrease = math.floor(executionCount / damageIncreaseThreshold) * damageIncreasePercent

    min = min + (min * damageIncrease / 100)
    max = max + (max * damageIncrease / 100)

    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

arr1 = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 3, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local area = createCombatArea(arr1)
setCombatArea(combat, area)

function onUseWeapon(cid, var)
    local executionCount = getPlayerStorageValue(cid, executionCounterStorage) or 0
    setPlayerStorageValue(cid, executionCounterStorage, executionCount + 1)

    if executionCount % damageIncreaseThreshold == 0 then
    local damageIncrease = math.floor(executionCount / damageIncreaseThreshold) * damageIncreasePercent
        Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, "You increased the power of the wand by a total of " .. damageIncrease .. "%!")
    end

    return doCombat(cid, combat, var)
end

in weapons.xml

Lua:
<wand id="26708" level="1" mana="8" script="energywand.lua"> <!-- Your new Wand -->
    <vocation name="Mage"/>
    <vocation name="Elder Druid"/>
    <vocation name="Sorcerer"/>
    <vocation name="Master Sorcerer"/>
    </wand>

Here is how it can be done on a melee weapon, in this case a two handed one:

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SMALLPLANTS) -- You can change this to the desired effect

local executionCounterStorage = 200 -- Set the storage value to track execution count
local damageIncreasePercent = 5 -- Damage increase percentage
local damageIncreaseThreshold = 250 -- Threshold for damage increase


function onGetFormulaValues(player, skill, attack)
    local min = (player:getLevel() * 2) + (skill * 2.8) + (attack * 1.4) + 25
    local max = (player:getLevel() * 3) + (skill * 3.2) + (attack * 1.8) + 50

    -- Check execution count and increase damage if needed
    local executionCount = getPlayerStorageValue(player, executionCounterStorage) or 0
    local damageIncrease = math.floor(executionCount / damageIncreaseThreshold) * damageIncreasePercent

    min = min + (min * damageIncrease / 100)
    max = max + (max * damageIncrease / 100)

    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local area = createCombatArea({{1}})
setCombatArea(combat, area)

function onUseWeapon(cid, var)
    local executionCount = getPlayerStorageValue(cid, executionCounterStorage) or 0
    setPlayerStorageValue(cid, executionCounterStorage, executionCount + 1)

    if executionCount % damageIncreaseThreshold == 0 then
    local damageIncrease = math.floor(executionCount / damageIncreaseThreshold) * damageIncreasePercent
        Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, "You increased the power of your weapon by a total of " .. damageIncrease .. "%!")
    end

    return doCombat(cid, combat, var)
end

in weapons.xml

Lua:
<melee id="27024" script="greatsword.lua" />

Hope someone finds this usable :)
 
a very interesting script. it does not display an increase in the characteristics of the weapon. it writes to the console that the % has been increased. when viewing an item, it does not change the characteristics
 
a very interesting script. it does not display an increase in the characteristics of the weapon. it writes to the console that the % has been increased. when viewing an item, it does not change the characteristics
Yep, didn't find out how I did that. If you want to update the script with that working and share it here please do :)
Post automatically merged:

a very interesting script. it does not display an increase in the characteristics of the weapon. it writes to the console that the % has been increased. when viewing an item, it does not change the characteristics
It says that it has increased by a total of a certain percentage. Adds 3 percent every time to a total number. But doesn't change any stats on the Item itself no.

The thing is that if you loose your item it doesn't matter, you can get a new item (same item ID) and continue with the same percentage.
You don't start from scratch if you loose your weapon :)
 
maybe you can find a solution here?
 
Back
Top