• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help with wand's attack

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
923
Location
Chile
Hello guys, i'm trying to make custom wands but i dont get the attack i want, check
im using otx 2.52

Code:
<wand id="21160" level="8" range="10" mana="15" enabled="1" swing="yes" script="Rare Prestige Magic Staff.lua">
             <vocation id="1"/>
            <vocation id="5"/>
    </wand>


Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT,50)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 31)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.0, -70, -1.0, -150)

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

setCombatArea(combat, area)

function onUseWeapon(cid, var)

return doCombat(cid, combat, var)
end

so i want this to attack between 70 and 150, but is attacking way more like 400 D:
plz how can i fix this? Also i get this effects, how can i change them? :/
1L6Jya6.png

distance and that plant one
 
Hello guys, i'm trying to make custom wands but i dont get the attack i want, check
im using otx 2.52

Code:
<wand id="21160" level="8" range="10" mana="15" enabled="1" swing="yes" script="Rare Prestige Magic Staff.lua">
             <vocation id="1"/>
            <vocation id="5"/>
    </wand>


Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT,50)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 31)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.0, -70, -1.0, -150)

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

setCombatArea(combat, area)

function onUseWeapon(cid, var)

return doCombat(cid, combat, var)
end

so i want this to attack between 70 and 150, but is attacking way more like 400 D:
plz how can i fix this? Also i get this effects, how can i change them? :/
1L6Jya6.png

distance and that plant one
effects are the effects in the script
legit says effect in the const name

also 70-150 is base damage, you're using combat_formula_levelmagic which lets the damage scale based on your magic level, that's why you're getting 400
 
effects are the effects in the script
legit says effect in the const name

also 70-150 is base damage, you're using combat_formula_levelmagic which lets the damage scale based on your magic level, that's why you're getting 400
ooh i see, and wich is the formula to make that specific attack? no matter the mglvl?
thanks, i alredy changed the effects :P
 
Code:
setCombatFormula(combat, COMBAT_FORMULA_DAMAGE, -70, 0, -150, 0)

Too many non-helping bananas nowadays.
 
Last edited:
Thanks guys!! altho one missing thing, i set this
Code:
setCombatParam(combat, COMBAT_PARAM_EFFECT,50)
but i dont see the effect on game, only the distance one and the "damage blood" one
zwseBIO.png

Also, how can i edit the speed of the attack?
and what does this mean? =)
Code:
swing="yes"

oh and this is weird..just realized that when i first attack looks fine(the shoot), then i move one sqm and starts this
3SrdnC.png

then i move another sqm and backs to normal xd, never seen this before
 
Last edited:
Code:
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
overrides your:
Code:
setCombatParam(combat, COMBAT_PARAM_EFFECT,50)
This is source issue. But you can make it by adding effect after like 0.01 seconds.



'Swing' thing is probably something added in otx, have no idea what it doing.

There are few ways to increase attack speed. First is changing attackspeed in vocations.xml, but this will be permanent.
Second way will be changing your script to do a second attack after 0.1 sec. So, it will looks like your AS is doubled.
The third way is source edit, so you will not be limited by anything.
 
Code:
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
overrides your:
Code:
setCombatParam(combat, COMBAT_PARAM_EFFECT,50)
This is source issue. But you can make it by adding effect after like 0.01 seconds.



'Swing' thing is probably something added in otx, have no idea what it doing.

There are few ways to increase attack speed. First is changing attackspeed in vocations.xml, but this will be permanent.
Second way will be changing your script to do a second attack after 0.1 sec. So, it will looks like your AS is doubled.
The third way is source edit, so you will not be limited by anything.
Thanks mate! already fixed speed, swing..whatever xd, and what should i do with this then=?
Code:
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

Also plz check that weird thing in the previous post, the spell effect changes
 
You can use this instead:
Code:
function onUseWeapon(cid, var)
    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(variantToNumber(var)), 31)
    doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -70, -150, 50)
    return true
end

It's exactly the same as your long script.
 
You can use this instead:
Code:
function onUseWeapon(cid, var)
    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(variantToNumber(var)), 31)
    doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -70, -150, 50)
    return true
end

It's exactly the same as your long script.

great! thanks for that script, however i still see this spell effect
v_QgEc.png

only like i said before, you shoot without spell effect, then you move one sqm and you see that, move again and dont, move again and you see that again...so weird :/
also with your script how can i edit the spell effect?
 
Distance effect:
doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(variantToNumber(var)), 31)

Hit effect:
doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -70, -150, 50)


Those big effects sometimes aren't shown, if there are alot of effects around. This is a issue with old Tibia client.
Maybe this script will solve it:
Code:
local function extraEffect(pos)
    return doSendMagicEffect(pos, 50) -- effect id 50
end

function onUseWeapon(cid, var)
    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(variantToNumber(var)), 31)
    doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -70, -150, 50)
    addEvent(extraEffect, 10, getCreaturePosition(variantToNumber(var))) -- executes function extraeffect after 10 miliseconds
    return true
end
 
Distance effect:
doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(variantToNumber(var)), 31)

Hit effect:
doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -70, -150, 50)


Those big effects sometimes aren't shown, if there are alot of effects around. This is a issue with old Tibia client.
i use otclient and i'm alone :/ there must be something interfiering, have any idea what could be? :/
imV1y09.png

RSCMvO.png

VEZwLEA.png



oh and just realized is not sending the correct shoot effect D: D: D:
 
Or try it not as a GOD. Also, keep in mind that otx isn't favourable engine.

I editted my last post, check it.
 
Or try it not as a GOD. Also, keep in mind that otx isn't favourable engine.

I editted my last post, check it.
thanks man, well i downloaded it a long time ago, i fixed the wand, i'll keep it simple, just did this
Code:
<wand id="21160" level="8" range="10" mana="17" min="110" max="150" type="holy" event="function" value="default">
lol xd
easier this way haha, thanks a lot man! =)
 
Back
Top