I created a melee basic attack spell to a rat.
But the damage is not calculated from the script.
For the rat damage to someone, I need to configure in the monster file.
And it is not the intention.
Script:
If the rat.xml is:
The hit is min="-1" and max="-7"
But if the rat.xml is:
The rat can't hit
Why?
But the damage is not calculated from the script.
For the rat damage to someone, I need to configure in the monster file.
And it is not the intention.
Script:
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)
function onGetFormulaValues(cid, level, skill, attack, factor)
local attack =
{
balance = 5,
weapon = 7,
skill = 10
} -- Max 7,5
if getPlayerStorageValue(getCreatureTarget(cid), DAMAGE_REDUCTION) >= 1 then
return -(((attack.balance*attack.weapon*attack.skill)/200)/getPlayerStorageValue(getCreatureTarget(cid), DAMAGE_REDUCTION)), -(((attack.balance*attack.weapon*attack.skill)/100)/getPlayerStorageValue(getCreatureTarget(cid), DAMAGE_REDUCTION))
else
return -((attack.balance*attack.weapon*attack.skill)/200), -((attack.balance*attack.weapon*attack.skill)/100)
end
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
if isPlayer(cid) == false then
return doCombat(cid, combat, var)
else
return false
end
end
If the rat.xml is:
Code:
<attacks>
<attack name="Rat" interval="2000" min="-1" max="-7" chance="100" range="1">
</attack>
</attacks>
But if the rat.xml is:
Code:
<attacks>
<attack name="Rat" interval="2000" chance="100" range="1">
</attack>
</attacks>
Why?