• 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 Distance weapon adds DoT?

Jompi

A hoagie in disguise.
Joined
Oct 22, 2007
Messages
197
Solutions
1
Reaction score
8
Location
Sweden
I have created a custom bow and I want it to add a fire DoT (like a fire field) to the target when you fire regular arrows from it, I also want the arrow to do the same damage as it did before (not just adding a DoT) and when you use a regular bow the arrow works just like normal.

I have not managed to get it to work from the comments below:
 
Last edited:
Solution
lol, I found the problem, do this
Lua:
local bowid = 22418
local condition = createConditionObject(CONDITION_FIRE)
    addDamageCondition(condition, 10, 2000, -10)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
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)
  
function onUseWeapon(cid, var)
    local slotleft = getPlayerSlotItem(cid,CONST_SLOT_LEFT)
    local slotright = getPlayerSlotItem(cid,CONST_SLOT_RIGHT)
    if slotleft.itemid == bowid or slotright.itemid == bowid and getCreatureTarget(cid) then...
This is the default poison arrow from the sources just change what you need such as the CONST_ANI_XXX effect COMBAT_XXX damage type & CONDITION_XXX and the addDamage values. :)
forgottenserver/poison_arrow.lua at 33d074fe1cb28d7f094e0e6896ada65d9cd472a2 · otland/forgottenserver · GitHub
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local condition = Condition(CONDITION_POISON)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(4, 4000, -3)
condition:addDamage(9, 4000, -2)
condition:addDamage(20, 4000, -1)
combat:setCondition(condition)

function onUseWeapon(player, variant)
    return combat:execute(player, variant)
end
 
This is the default poison arrow from the sources just change what you need such as the CONST_ANI_XXX effect COMBAT_XXX damage type & CONDITION_XXX and the addDamage values. :)
forgottenserver/poison_arrow.lua at 33d074fe1cb28d7f094e0e6896ada65d9cd472a2 · otland/forgottenserver · GitHub
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

local condition = Condition(CONDITION_POISON)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(4, 4000, -3)
condition:addDamage(9, 4000, -2)
condition:addDamage(20, 4000, -1)
combat:setCondition(condition)

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

Yeah I tried doing that but it doesn't work. I think that's only for ammunition? I want the fire dot to be added only if you use the custom bow and a regular arrow, not a regular bow and a regular arrow.

I'm not getting any errors after adding the bow btw.
 
Lua:
function onUseWeapon(player, variant)
    local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
    combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
    combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
    if player:getSlotItem(CONST_SLOT_LEFT).itemid == [BOW ID GOES HERE] and player:getSlotItem(CONST_SLOT_ARROW).itemid == [ARROW ID GOES HERE] then
        local condition = Condition(CONDITION_FIRE)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:addDamage(10, 2000, -10)
        combat:setCondition(condition)
    end
    return combat:execute(player, variant)
end
 
Lua:
function onUseWeapon(player, variant)
    local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
    combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
    combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
    if player:getSlotItem(CONST_SLOT_LEFT).itemid == [BOW ID GOES HERE] and player:getSlotItem(CONST_SLOT_ARROW).itemid == [ARROW ID GOES HERE] then
        local condition = Condition(CONDITION_FIRE)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:addDamage(10, 2000, -10)
        combat:setCondition(condition)
    end
    return combat:execute(player, variant)
end

Strange, I'm not getting any errors and yet nothing happens. All the ID's are correct. I have checked plenty of times :eek:
 
Sorry replace
Lua:
CONST_SLOT_ARROW
with
Lua:
CONST_SLOT_AMMO
I am not as smart as I think I am
 
Sorry replace
Lua:
CONST_SLOT_ARROW
with
Lua:
CONST_SLOT_AMMO
I am not as smart as I think I am

Still nothing. Just fires arrows like regular :/

What am I to put in weapons.xml? Maybe I did something wrong there.
 
Last edited:
XML:
    <distance id="2546" action="removecount" script="arrowdot.lua" />
Lua:
local combat = Combat()
local combatnodot = Combat()

for i, c in ipairs({combat, combatnodot}) do
    c:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    c:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
    c:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
    c:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
    c:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
end

local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(10, 2000, -10)
combat:setCondition(condition)

function onUseWeapon(player, variant)
    if player:getSlotItem(CONST_SLOT_LEFT).itemid == 22418 then
         return combat:execute(player, variant)
    else
         return combatnodot:execute(player, variant)
    end
end
I don't know what was wrong but this works for me
chance id in xml to whatever arrow you want and bowitemid in lua to whatever bow you want
 
Last edited:
XML:
    <distance id="2546" action="removecount" script="arrowdot.lua" />
Lua:
local combat = Combat()
local combatnodot = Combat()

for i, c in ipairs({combat, combatnodot}) do
    c:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    c:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
    c:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
    c:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
    c:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
end

local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(10, 2000, -10)
combat:setCondition(condition)

function onUseWeapon(player, variant)
    if player:getSlotItem(CONST_SLOT_LEFT).itemid == 22418 then
         return combat:execute(player, variant)
    else
         return combatnodot:execute(player, variant)
    end
end
I don't know what was wrong but this works for me
chance id in xml to whatever arrow you want and bowitemid in lua to whatever bow you want

Well that last script gave me an error.
Code:
[18/4/2017 14:34:4] data/weapons/scripts/paladin/explosive arrow.lua
[18/4/2017 14:34:4] Description:
[18/4/2017 14:34:4] data/weapons/scripts/paladin/explosive arrow.lua:5: attempt to call method 'setParameter' (a nil value)
[18/4/2017 14:34:4] [Error - Event::checkScript] Cannot load script (data/weapons/scripts/paladin/explosive arrow.lua)

I don't think we understand each other here quite. I want the bow to still fire arrows that do regular damage but also adds the fire dot.
And 2546 is the burst arrow script and if I try to add anything in there I get errors.

Here is my current burst arrow script:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, -150)

local area = createCombatArea( { {1, 1, 1}, {1, 3, 1}, {1, 1, 1} } )
setCombatArea(combat, area)

function onUseWeapon(cid, var)
    return doCombat(cid, combat, var)
end
 
We do understand each other here, you did something wrong
what distro are you using?
EDIT:
reeks of 0.4, one sec
 
try this
Lua:
local bowid = 22418
local combat = createCombatObject()
local combatnodot = createCombatObject()
for i, c in ipairs({combat,combatnodot}) do
    setCombatParam(c, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(c, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
    setCombatParam(c, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
    setCombatFormula(c, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, -150)
end
local condition = createConditionObject(CONDITION_FIRE)
    addDamageCondition(condition, 10, 2000, -1)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
    setCombatCondition(combat, condition)
function onUseWeapon(cid, var)
    if getPlayerSlotItem(cid,CONST_SLOT_LEFT).itemid == bowid then
        return doCombat(cid, combat, var)
    else
        return doCombat(cid, combatnodot, var)
    end
end
 
That was important information, the above should be good now though

Yeah sorry, forgot to mention that.

Now it's going somewhere. But now only burst arrow adds a fire dot and it looks different and when the burst arrow lands it looks different, the old AoE is gone and it only effects 1 sqm. Shouldn't I add this with an arrow script instead?

pYjNHmC.jpg
 
I still wanna use the burst arrow.
by this I assume you mean
I still want the burst arrow to function as per usual.
what your asking for is very straightforward, you just need to clarify

in weapons.xml change
XML:
    <distance id="2544" action="removecount"/> <!-- arrow -->
for
XML:
    <distance id="2544" action="removecount" script="arrow.lua"/> <!-- arrow -->
and in arrow.lua:
Lua:
local bowid = 22418
local combat = createCombatObject()
local combatnodot = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
    setCombatParam(combat, COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
    setCombatParam(combatnodot, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(combatnodot, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
    setCombatParam(combatnodot, COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
local condition = createConditionObject(CONDITION_FIRE)
    addDamageCondition(condition, 10, 2000, -1)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
    setCombatCondition(combat, condition)
function onUseWeapon(cid, var)
    if getPlayerSlotItem(cid,CONST_SLOT_LEFT).itemid == bowid then
        return doCombat(cid, combat, var)
    else
        return doCombat(cid, combatnodot, var)
    end
end
go to the tutorials section you can learn a lot there
 
Last edited:
by this I assume you mean

what your asking for is very straightforward, you just need to clarify

in weapons.xml change
XML:
    <distance id="2544" action="removecount"/> <!-- arrow -->
for
XML:
    <distance id="2544" action="removecount" script="arrow.lua"/> <!-- arrow -->
and in arrow.lua:
Lua:
local bowid = 22418
local combat = createCombatObject()
local combatnodot = createCombatObject()
for i, c in ipairs({combat,combatnodot}) do
    setCombatParam(c, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(c, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
    setCombatParam(c, COMBAT_FORMULA_SKILL, 0, 0, 1, 0)
end
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
local condition = createConditionObject(CONDITION_FIRE)
    addDamageCondition(condition, 10, 2000, -1)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
    setCombatCondition(combat, condition)
function onUseWeapon(cid, var)
    if getPlayerSlotItem(cid,CONST_SLOT_LEFT).itemid == bowid then
        return doCombat(cid, combat, var)
    else
        return doCombat(cid, combatnodot, var)
    end
end
go to the tutorials section you can learn a lot there

Yeah I'm sick atm so having a hard time focusing on typing, hehe. But I have decided not trying to fix this, it doesn't seem to work. But like I said, I appreciate the help.
The last thing you wrote gave these errors btw:
Code:
[18/4/2017 20:14:46] [Error - Test Interface] 
[18/4/2017 20:14:46] data/weapons/scripts/paladin/arrow.lua
[18/4/2017 20:14:46] Description: 
[18/4/2017 20:14:46] (LuaInterface::luaSetCombatParam) Combat not found

[18/4/2017 20:14:46] [Error - Test Interface] 
[18/4/2017 20:14:46] data/weapons/scripts/paladin/arrow.lua
[18/4/2017 20:14:46] Description: 
[18/4/2017 20:14:46] (LuaInterface::luaSetCombatParam) Combat not found

[18/4/2017 20:14:46] [Error - Weapon Interface] 
[18/4/2017 20:14:46] data/weapons/scripts/paladin/arrow.lua
[18/4/2017 20:14:46] Description: 
[18/4/2017 20:14:46] (LuaInterface::luaSetCombatParam) Combat not found

[18/4/2017 20:14:46] [Error - Weapon Interface] 
[18/4/2017 20:14:46] data/weapons/scripts/paladin/arrow.lua
[18/4/2017 20:14:46] Description: 
[18/4/2017 20:14:46] (LuaInterface::luaSetCombatParam) Combat not found
 
Back
Top