Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
Ok, I requested this a long time ago and Cykotitan did it for me, but it only works for stars, clubs, swords, and axes. My main worry is it doesnt work for bow and arrow.
Code:
local combat = {}
local effect =
{[1] = 11, [2] = 15, [3] = 43, [4] = 9}
local distEffect =
{[1] = 32, [2] = 33, [3] = 34, [4] = 17}
local cType =
{[1] = COMBAT_ENERGYDAMAGE, [2] = COMBAT_FIREDAMAGE,
[3] = COMBAT_ICEDAMAGE, [4] = COMBAT_PHYSICALDAMAGE}
for i = 1, #effect do
combat[i] = createCombatObject()
setCombatParam(combat[i], COMBAT_PARAM_TYPE, cType[i])
setCombatParam(combat[i], COMBAT_PARAM_EFFECT, effect[i])
setCombatParam(combat[i], COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat[i], COMBAT_PARAM_DISTANCEEFFECT, distEffect[i])
setCombatParam(combat[i], COMBAT_PARAM_USECHARGES, true)
function onGetFormulaValues(cid, level, maglevel)
local t, min, max = getItemInfo(math.max(100, getPlayerWeapon(cid).itemid)).weaponType, 0, 0
local wType = t == 1 and 2 or t == 2 and 1 or t == 5 and 4 or t
if isInArray({SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE}, wType) then
min = level * 1.0 + getPlayerSkillLevel(cid, wType) * 4
max = level * 1.3 + getPlayerSkillLevel(cid, wType) * 5
end
return -min, -max
end
setCombatCallback(combat[i], CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
end
local function castSpell(cid, var, combat)
return isPlayer(cid) and doCombat(cid, combat, var)
end
function onCastSpell(cid, var)
castSpell(cid, var, combat[1])
for i = 2, #combat do
addEvent(castSpell, i * 250 - 250, cid, var, combat[i])
end
return true
end