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

Lua Weapons

Il Knight

Veteran OT User
Joined
Dec 1, 2014
Messages
676
Solutions
7
Reaction score
350
Location
Spain
Hello! how i can solve this?

script = function on use weapon =
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
    local min =
    local max =
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
    local min =
    local max =
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(player, variant)
local percent = player:getEffectiveSkillLevel(SKILL_FIST)
local item = player:getSlotItem(CONST_SLOT_LEFT)

local roll = math.random(1,100)
local Max = item:getAttack() 
local Min = item:getDefense()
local Crit = item:getHitChance()
local Maxcrit = ((Max/100) * Crit)
local Mincrit = ((Min/100) * Crit)
local Speed = getEffectiveSkillLevel(SKILL_FISHING)

if roll >= percent then

return combat:execute(player, variant)

elseif roll <= percent then

return combat2:execute(player, variant)

    end
end

i need to add this values =

local Max = item:getAttack()
local Min = item:getDefense()
local Crit = item:getHitChance()
local Maxcrit = ((Max/100) * Crit)
local Mincrit = ((Min/100) * Crit)

on the

function onGetFormulaValues(player, skill, attack, factor)
local min =
local max =
return -min, -max
end

thanks in advance
 
Last edited by a moderator:
Combat() object itself is quite bad itself in my opinion

Why not simply calcualate your damage beforehand and then pass it with function:
doTargetCombatHealth(cid, targetID, type, min, max, effect, origin)

You can get your weapon userdata like this:
local weapon = player:getSlotItem(SLOT_LEFT)
 
Thanks whitevo

solved using

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
local item = player:getSlotItem(CONST_SLOT_LEFT)
local Maxd = ItemType(item:getId()):getAttack()  
local Mind = ItemType(item:getId()):getDefense()

    local min = Mind
    local max = Maxd
    return -min, -max
end
 
Thanks whitevo

solved using

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
local item = player:getSlotItem(CONST_SLOT_LEFT)
local Maxd = ItemType(item:getId()):getAttack() 
local Mind = ItemType(item:getId()):getDefense()

    local min = Mind
    local max = Maxd
    return -min, -max
end
can make it simpler by using item:getType():getAttack() & item:getType():getDefense()
 
Back
Top