• 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 Help to change formula wands

dudie

Member
Joined
May 23, 2016
Messages
128
Reaction score
12
I want make a new formula attack wand to make others system...
Someone could help me? Whats i made worng?

weapons.xml
Code:
  <wand id="2190" mana="2" type="energy" event="function" value="wands.lua"> <!-- Wand of Vortex -->
     <vocation id="1"/>
   </wand>

weapons/wands.lua
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
   min = (attack * 5.0) * -1
   max = (attack * 8.0) * -1
   return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


items.xml
Code:
  <item id="2190" article="a" name="wand of vortex">
     <attribute key="description" value="Surges of energy rush through the tip of this wand." />
     <attribute key="weight" value="1900" />
     <attribute key="weaponType" value="wand" />
     <attribute key="shootType" value="energy" />
     <attribute key="range" value="3" />
     <attribute key="attack" value="1"/>
   </item>
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onGetFormulaValues(cid, level, skill, attack, factor)
   min = (attack * 5.0) * -1
   max = (attack * 8.0) * -1
   return -min, -max
end

combat:setCombatCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

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

just made right now, and here we have some mistakes assuming you are trying to make a wand for mages,
1:
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
this parameters are suppose to skill based damaged (distance, sword, axe, club) for based on maglevel and level (mages) instead use:
Code:
function onGetFormulaValues(cid, level, maglevel)
2:
the formulae should look like this:
Code:
    local min = (level / 5) + (maglevel * 1.4) + 8
    local max = (level / 5) + (maglevel * 2.2) + 14
    return -min, -max
ofc as your wish the results.
3:
to everything works also the function setCombatCallback() needs the parameter maglevel instead skills.
Code:
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

to weapons.xml i think this shall work.
Code:
    <wand id="2190" level="7" mana="2" script="wand.lua">
        <vocation name="Sorcerer" />
    </wand>

hope you understood, i tried to be explainable i could.
 
Last edited:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onGetFormulaValues(cid, level, skill, attack, factor)
   min = (attack * 5.0) * -1
   max = (attack * 8.0) * -1
   return -min, -max
end

combat:setCombatCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

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

just made right now, and here we have some mistakes assuming you are trying to make a wand for mages,
1:
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
this parameters are suppose to skill based damaged (distance, sword, axe, club) for based on maglevel and level (mages) instead use:
Code:
function onGetFormulaValues(cid, level, maglevel)
2:
the formulae should look like this:
Code:
    local min = (level / 5) + (maglevel * 1.4) + 8
    local max = (level / 5) + (maglevel * 2.2) + 14
    return -min, -max
ofc as your wish the results.
3:
to everything works also the function setCombatCallback() needs the parameter maglevel instead skills.
Code:
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

to weapons.xml i think this shall work.
Code:
    <wand id="2190" level="7" mana="2" script="wand.lua">
        <vocation name="Sorcerer" />
    </wand>

hope you understood, i tried to be explainable i could.

function onGetFormulaValues(cid, level, maglevel)
???

But i don't want use level and magic level... I just want use attack of this wands
 
function onGetFormulaValues(cid, level, maglevel)
???

But i don't want use level and magic level... I just want use attack of this wands

so why you just do it through xml?
Code:
<wand id="2190" level="7" mana="8" min="42" max="48" type="energy">
keep in mind wands does NOT have an attack damage, their damage comes from between min and max in weapons.xml, and i really don't know if you just insert on items.xml the attack value will make a work around, because attack value are suppose to calc weapons like swords and such not magic damage, so try by yourself.
 
Last edited:
I mean this attack
Code:
<item id="2190" article="a" name="wand of vortex">
<attribute key="description" value="Surges of energy rush through the tip of this wand." />
<attribute key="weight" value="1900" />
<attribute key="weaponType" value="wand" />
<attribute key="shootType" value="energy" />
<attribute key="range" value="3" />
<attribute key="attack" value="1"/>
</item>

Code:
<attribute key="attack" value="1"/>
 
I mean this attack
Code:
<item id="2190" article="a" name="wand of vortex">
<attribute key="description" value="Surges of energy rush through the tip of this wand." />
<attribute key="weight" value="1900" />
<attribute key="weaponType" value="wand" />
<attribute key="shootType" value="energy" />
<attribute key="range" value="3" />
<attribute key="attack" value="1"/>
</item>

Code:
<attribute key="attack" value="1"/>
what about it
 
Item(getPlayerSlotItem(cid, slot)):getAttribute(ITEM_ATTRIBUTE_ATTACK)
theres ur wep attack, make sure cid and slot is right
 
yes, and you check both and use the one which has attack...

(player:getSlotItem(CONST_SLOT_LEFT)):getType():getAttack())

Errors
Code:
[13:58:31.332] [Error - LuaInterface::loadFile] cannot open data/weapons/scripts/wand.lua: No such file or directory
[13:58:31.332] [Warning - Event::loadScript] Cannot load script (data/weapons/scripts/wand.lua)
[13:58:31.332] cannot open data/weapons/scripts/wand.lua: No such file or directory

[13:58:32.282] [Error - LuaInterface::loadFile] cannot open data/movements/scripts/onEquipItem: No such file or directory
[13:58:32.282] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/onEquipItem)
[13:58:32.282] cannot open data/movements/scripts/onEquipItem: No such file or directory
[13:58:32.282] [Error - LuaInterface::loadFile] cannot open data/movements/scripts/onDeEquipItem: No such file or directory
[13:58:32.282] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/onDeEquipItem)
[13:58:32.282] cannot open data/movements/scripts/onDeEquipItem: No such file or directory

Script:

Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
   local atk_first = (player:getSlotItem(CONST_SLOT_LEFT)):getType():getAttack())
   local atk_second = (player:getSlotItem(CONST_SLOT_RIGHT)):getType():getAttack())
   local atk = atk_first + atk_second
   min = (atk * 5.0) * -1
   max = (atk * 8.0) * -1
   return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

Right?
 
Last edited:
read your errors, they're pretty self explanatory..

I need put wand of vortex on movements?

Code:
  <!-- wand of vortex -->
   <movevent type="Equip" itemid="2190" slot="hand" event="script" value="onEquipItem"/>  
   <movevent type="DeEquip" itemid="2190" slot="hand" event="script" value="onDeEquipItem"/>
 
Back
Top