• 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 change the effect of the arrow using a bow

darkmu

Active Member
Joined
Aug 26, 2007
Messages
249
Solutions
1
Reaction score
44
Location
Paraná,Brazil
Good morning people,

I would like to know if there is a possibility to exchange the Diamond Arrow Combat by checking the BOW id that I will be using.

In the case of each bow used the:
combat: setParameter (COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) will change.

TFS 1.3

Lua:
local area = createCombatArea({
     {0, 1, 1, 1, 0},
     {1, 1, 1, 1, 1},
     {1, 1, 3, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0},
 })

 local combat = Combat()
 combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
 combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DIAMONDARROW)
 combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
 combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
 combat:setArea(area)

 function onUseWeapon(player, variant)
     return combat:execute(player, variant)
 end
 
Solution
Yes.

You'd want to find the bow itemid using some function, and then use the setParameter before combat execute is performed.

example
Lua:
local weapons = {
    [1111] = {combatType = COMBAT_EARTHDAMAGE},
    [2222] = {combatType = COMBAT_ENERGYDAMAGE},
    [3333] = {combatType = COMBAT_ICEDAMAGE},
}

local area = createCombatArea({
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 3, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0},
 })

 local combat = Combat()
 --combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
 combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DIAMONDARROW)
 combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,678
Solutions
406
Reaction score
3,789
Yes.

You'd want to find the bow itemid using some function, and then use the setParameter before combat execute is performed.

example
Lua:
local weapons = {
    [1111] = {combatType = COMBAT_EARTHDAMAGE},
    [2222] = {combatType = COMBAT_ENERGYDAMAGE},
    [3333] = {combatType = COMBAT_ICEDAMAGE},
}

local area = createCombatArea({
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 3, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0},
 })

 local combat = Combat()
 --combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
 combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DIAMONDARROW)
 combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
 combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
 combat:setArea(area)
 
 local function getWeaponId(cid)
    local weaponItemId = 0
    -- find the weapon itemid however you want.
    return weaponItemId
 end

 function onUseWeapon(player, variant)
    local weaponID = getWeaponId(cid)
    if weapons[weaponID] then
        combat:setParameter(COMBAT_PARAM_TYPE, weapons[weaponID].combatType)
    else
        -- default damage type if the bow can't be found in table
        combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    end
    return combat:execute(player, variant)
 end
 
Solution
Top