Got any idea how to make this script shorter and faster?
It's spell to attack monsters only on pvp server.
PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 7, 7, 70.4, 75.8, 40, 70)
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setAttackFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, 7, 7, 70.4, 75.8, 40, 70)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setAttackFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 7, 7, 70.4, 75.8, 40, 70)
function onCastSpell(cid, var)
local pos = getCreaturePosition(cid)
for tx = pos.x-4, pos.x+4 do
for ty = pos.y-4, pos.y+4 do
doSendMagicEffect({x=tx,y=ty,z=pos.z}, CONST_ME_ENERGYHIT)
end
end
for i, target in pairs(getSpectators(pos, 4, 4, false)) do
if(not isPlayer(target)) then
doCombat(cid, combat, numberToVariant(target))
doCombat(cid, combat1, numberToVariant(target))
doCombat(cid, combat2, numberToVariant(target))
end
end
return true
end