Arn
Member
- Joined
- Mar 8, 2010
- Messages
- 282
- Reaction score
- 18
Hi. My onCast creature event is not working. Here is my code. (Rev 5960 Version 0.3.7)
login.lua
creaturescripts.xml
onCast.lua
spells.xml
test.lua
I log in the game on a GM and on a normal character. I cast the spell. Nothing happens. Any suggestions?
P.S. I have onAttack, onCombat, onDirection, and onStatsChange all working. Why is this different.
login.lua
Code:
registerCreatureEvent(cid, "onCast")
creaturescripts.xml
Code:
<event type="cast" name="onCast" event="script" value="custom/onCast.lua"/>
onCast.lua
Code:
function onCast(cid, target)
print ("working")
return true
end
spells.xml
Code:
<instant name="Whirlwind Throw" words="exori hur" lvl="1" mana="0" prem="1" range="5" needtarget="1" blockwalls="1" needweapon="1" exhaustion="6000" groups="1,2000" icon="107" needlearn="0" event="script" value="test.lua">
</instant>
test.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
function onGetFormulaValues(cid, level, skill, attack, element, factor)
local levelTotal, formula = level / 5, 0.0332
local normal, elemental = -(skill * attack * formula + levelTotal), math.ceil((skill * element * formula + levelTotal))
return normal/2, normal, -math.random(elemental/2, elemental)
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
I log in the game on a GM and on a normal character. I cast the spell. Nothing happens. Any suggestions?
P.S. I have onAttack, onCombat, onDirection, and onStatsChange all working. Why is this different.
Last edited: