• 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 Elemental Bows TFS 1.5 7.72

SalvaART

TriasOT.online
Joined
May 1, 2017
Messages
208
Solutions
1
Reaction score
123
Location
USA
Hello everyone! :)

Someone can explain me how to make a elemental bows (3 different?)
(1 hit - giving condition) from 10 to 0 each like Medivia (9, 8, 7, 6, 5, 4, 3, 2, 1, 0) - you can hit again (no stacks from zero if you hit again, damage need go from 10 to 0 and you can again give condition.

I need:
Poison, fire, energy :)

i found one script, but its for 0.3.6 i think

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local bow_c = {
     [8855] = createConditionObject(CONDITION_FREEZING),
     [8856] = createConditionObject(CONDITION_POISON)
}
setConditionParam(bow_c[8855], CONDITION_PARAM_DELAYED, 1)
addDamageCondition(bow_c[8855], 15, 2000, -8)

setConditionParam(bow_c[8856], CONDITION_PARAM_DELAYED, 1)
addDamageCondition(bow_c[8856], 15, 2000, -6)
        
function onUseWeapon(cid, var)
    local wid = getPlayerWeapon(cid, true).itemid -- If getPlayerWeapon doesn't work on your server, locate ID of the weapon via another means, e.g. getPlayerSlotItem and store it in this var
    if getCreatureTarget(cid) ~= 0 then
        if bow_c[wid] then
            doTargetCombatCondition(cid, getCreatureTarget(cid), bow_c[wid], CONST_ME_FIRE)
        end
    end
   return doCombat(cid, combat, var)
end
 
Last edited:
not tested.

Revscripts
data/scripts.


Lua:
config = {
    bowPoison = 8856, -- ID of an item that represents the poison bow
    bowFire = 8857, -- ID of an item that represents the fire bow
    bowEnergy = 8858 -- ID of an item that represents the arc of energy
}

local BowsElements = Action()

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local elementalBows = {
    [config.bowPoison] = Condition(CONDITION_POISON),
    [config.bowFire] = Condition(CONDITION_FIRE),
    [config.bowEnergy] = Condition(CONDITION_ENERGY)
}

elementalBows[config.bowPoison]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowPoison]:addDamage(10, 3000, -10) -- Poison damage from 10 to 0

elementalBows[config.bowFire]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowFire]:addDamage(10, 3000, -10) -- Fire damage from 10 to 0

elementalBows[config.bowEnergy]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowEnergy]:addDamage(10, 3000, -10) -- Energy damage from 10 to 0

function BowsElements.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetCreature = Creature(target)
    local bowID = item:getId()

    local bowCondition = elementalBows[bowID]

    if targetCreature and bowCondition then
        targetCreature:addCondition(bowCondition)
    end

    local weaponType = player:getWeaponType()

    return combat:execute(player, Variant(targetCreature))
end

BowsElements:id(config.bowPoison)
BowsElements:id(config.bowFire)
BowsElements:id(config.bowEnergy)
BowsElements:register()
 
not tested.

Revscripts
data/scripts.


Lua:
config = {
    bowPoison = 8856, -- ID of an item that represents the poison bow
    bowFire = 8857, -- ID of an item that represents the fire bow
    bowEnergy = 8858 -- ID of an item that represents the arc of energy
}

local BowsElements = Action()

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local elementalBows = {
    [config.bowPoison] = Condition(CONDITION_POISON),
    [config.bowFire] = Condition(CONDITION_FIRE),
    [config.bowEnergy] = Condition(CONDITION_ENERGY)
}

elementalBows[config.bowPoison]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowPoison]:addDamage(10, 3000, -10) -- Poison damage from 10 to 0

elementalBows[config.bowFire]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowFire]:addDamage(10, 3000, -10) -- Fire damage from 10 to 0

elementalBows[config.bowEnergy]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[config.bowEnergy]:addDamage(10, 3000, -10) -- Energy damage from 10 to 0

function BowsElements.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetCreature = Creature(target)
    local bowID = item:getId()

    local bowCondition = elementalBows[bowID]

    if targetCreature and bowCondition then
        targetCreature:addCondition(bowCondition)
    end

    local weaponType = player:getWeaponType()

    return combat:execute(player, Variant(targetCreature))
end

BowsElements:id(config.bowPoison)
BowsElements:id(config.bowFire)
BowsElements:id(config.bowEnergy)
BowsElements:register()
Lua Script Error: [Scripts Interface]
C:\xxx\xxx\data\scripts\custom\elementalbows.lua:callback
LuaScriptInterface::luaCombatExecute(). Variant not found
stack traceback:
[C]: at 0x7ff60df9f0f0

@Mateus Robeerto i need make any changes in items.xml or weapons.xml ?
 
Sorry, I just noticed it was 'weapons' indeed... so I rewrote the script. Now, give it a try.

Lua:
local BowsElements = Weapon(WEAPON_AMMO)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local elementalBows = {
    [8856] = Condition(CONDITION_POISON),
    [8857] = Condition(CONDITION_FIRE),
    [8858] = Condition(CONDITION_ENERGY)
}

elementalBows[8856]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8856]:addDamage(10, 3000, -10) -- Poison damage from 10 to 0

elementalBows[8857]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8857]:addDamage(10, 3000, -10) -- Fire damage from 10 to 0

elementalBows[8858]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8858]:addDamage(10, 3000, -10) -- Energy damage from 10 to 0

function BowsElements.onUseWeapon(player, variant)
    local targetCreature = Combat.getAttackTarget(player)
    local bowID = BowsElements.itemid

    local bowCondition = elementalBows[bowID]

    if targetCreature and bowCondition then
        targetCreature:addCondition(bowCondition)
    end

    local weaponType = player:getWeaponType()

    return combat:execute(player, Variant(targetCreature))
end

BowsElements:register()
 
Sorry, I just noticed it was 'weapons' indeed... so I rewrote the script. Now, give it a try.

Lua:
local BowsElements = Weapon(WEAPON_AMMO)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local elementalBows = {
    [8856] = Condition(CONDITION_POISON),
    [8857] = Condition(CONDITION_FIRE),
    [8858] = Condition(CONDITION_ENERGY)
}

elementalBows[8856]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8856]:addDamage(10, 3000, -10) -- Poison damage from 10 to 0

elementalBows[8857]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8857]:addDamage(10, 3000, -10) -- Fire damage from 10 to 0

elementalBows[8858]:setParameter(CONDITION_PARAM_DELAYED, 1)
elementalBows[8858]:addDamage(10, 3000, -10) -- Energy damage from 10 to 0

function BowsElements.onUseWeapon(player, variant)
    local targetCreature = Combat.getAttackTarget(player)
    local bowID = BowsElements.itemid

    local bowCondition = elementalBows[bowID]

    if targetCreature and bowCondition then
        targetCreature:addCondition(bowCondition)
    end

    local weaponType = player:getWeaponType()

    return combat:execute(player, Variant(targetCreature))
end

BowsElements:register()
Hello now i didnt have any errors, but if i hit a monsters they don't have a condition - just a normal attack

i made a new ID and bow (test bow) with ID 5095, i replace [8856] id from script on [5095] and nothing :(
 
Back
Top