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

Issue with full attack/Balanced/Full defence

erikbs

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

I have this script which I have connected to my sword.
This kinda works the same way as wands do, so it does the same Damage if you go full attack, balanced or full defence. Is it possible to make, or does anyone know how I can change this so that full attack, balanced and full defence has an effect like it would have without any script connected to the weapon?

Right now when the player chooses full defence, it still does full attack while getting full defence, I want the attack to be lower when the player goes full defence. Does this make sense? XD

Here is the script:

Lua:
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 = 100 -- Set the storage value to track execution count
local damageIncreasePercent = 3 -- Damage increase percentage
local damageIncreaseThreshold = 500 -- Threshold for damage increase


function onGetFormulaValues(player, skill, attack)
    local min = (player:getLevel() * 2) + (skill * 4) + (attack * 2) - 150
    local max = (player:getLevel() * 2) + (skill * 4) + (attack * 2) - 150

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

Hope someone can help :)

Erik
 
Hi,

I finaly found it: player:getFightMode()
return will be:
1 for full attack
2 for balanced
3 for full defense

Just grab the fight mode of the player and do the math as u want. Good Luck.
 
Back
Top