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

Solved Three different items cause different damage

Rhyund

New Member
Joined
May 3, 2010
Messages
23
Reaction score
0
I have this .lua file:

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0.65, 0, 2.0, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0.845, 0, 2.6, 0)


function onUseWeapon(cid, var)
if getPlayerSlotItem(cid, CONST_SLOT_RIGTH).itemid == 7438 or getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 7438 then

return doCombat(cid, combat2, var)
else

return doCombat(cid, combat, var)

end
end

So, if I use itemid 7438 the combat changes from combat1 to combat2. I would like to add another itemid with another formula (combat3). How can I do this? :confused:
 
Last edited:
Solution
I made fast example with new combat on weapon with id 9999. There are explanations in comments. Hope it help you to better understand the code

Lua:
-- combat definition and its params
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0.65, 0, 2.0, 0)

-- combat2 definition and its params
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat2...
I made fast example with new combat on weapon with id 9999. There are explanations in comments. Hope it help you to better understand the code

Lua:
-- combat definition and its params
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0.65, 0, 2.0, 0)

-- combat2 definition and its params
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0.845, 0, 2.6, 0)

-- combat3 definition and its params
local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, 22)
setCombatFormula(combat3, COMBAT_FORMULA_SKILL, 0.9, 0, 2.6, 0)

function onUseWeapon(cid, var)
    -- if both hands are empty do the default combat
    if not getPlayerSlotItem(cid, CONST_SLOT_RIGTH) and not getPlayerSlotItem(cid, CONST_SLOT_LEFT) then
        return doCombat(cid, combat, var)
    end
    -- save weapon ids to better-lookin variables
    local rightHandId = getPlayerSlotItem(cid, CONST_SLOT_RIGTH).itemid
    local leftHandId = getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid
 
 
    if rightHandId == 7438 or leftHandId == 7438 then -- if right weapon OR left weapon has id = 7438
        return doCombat(cid, combat2, var) -- do the combat2
    elseif rightHandId == 9999 or leftHandId == 9999 then -- if right weapon OR left weapon has id = 9999
        return doCombat(cid, combat3, var) -- do the combat3
    else -- any other case
        return doCombat(cid, combat, var) -- do the 'normal' combat
    end
end
 
Solution
Back
Top