Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
I messed around with this script a little, it works, but there is a few things i'd like.
1) add a cancel spell function if no monsters on screen
2) cleaned up a little because a lot of the script i think is unnecessary. -- I used the multi-target wand but made it a spell and made it so you don't need to target. Also, it's only pve, so if everything concerning players could be taken out that would be great.
Also, it shoots through walls, i did blockwalls="1" in the xml, but that doesn't help lol
any further questions please ask!
1) add a cancel spell function if no monsters on screen
2) cleaned up a little because a lot of the script i think is unnecessary. -- I used the multi-target wand but made it a spell and made it so you don't need to target. Also, it's only pve, so if everything concerning players could be taken out that would be great.
Also, it shoots through walls, i did blockwalls="1" in the xml, but that doesn't help lol
any further questions please ask!
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 4)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -4, -35, -6, -40)
local hitExtraTargets = 100
local hitExtraTargetsInRange = 4
function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z, stackpos = STACKPOS_TOP_CREATURE})
if (creature.type == 2 and showMonsters == 1) then
table.insert(creaturesList, creature.uid)
end
end
end
end
return creaturesList
end
function onCastSpell(cid, var)
local ret = doCombat(cid, combat, var)
if(ret == LUA_ERROR) then
return LUA_ERROR
end
local target = variantToNumber(var)
local hitplayers = 0
if(target ~= 0) then
local nowHit = 0
local randomId = 0
local otherTargets = getCreaturesInRange(getCreaturePosition(target), hitExtraTargets, hitExtraTargetsInRange, 1)
if(#otherTargets > 0) then
for i = 1, hitExtraTargets do
randomId = math.random(1, #otherTargets)
nowHit = otherTargets[randomId]
if(isCreature(nowHit) == TRUE) then
table.remove(otherTargets, randomId)
ret = doCombat(cid, combat, numberToVariant(nowHit))
if(#otherTargets == 0) then
break
end
else
break
end
end
end
end
return TRUE
end
Last edited: