• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Random Spell

Hekan

New Member
Joined
Jun 14, 2008
Messages
94
Reaction score
0
Hello. I need help with script that can cast random 1 of 5 spells. For example i have 5 spells and i want make 6th spell that can cast one of the 5 spells in random.
 
test this then

Lua:
	for meffect = math.random(1, 2, 26, 30) -- random effect
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 35)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 11)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.5, -50, -0.6, 0)
 
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 36)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, meffect)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.5, -50, -0.6, 0)
 
local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, 35)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 11)
setCombatFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, -0.5, -50, -0.6, 0)
 
local function onCastSpell1(parameters) 
doCombat(parameters.cid, parameters.combat1, parameters.var) 
end 
 
local function onCastSpell2(parameters) 
doCombat(parameters.cid, parameters.combat2, parameters.var) 
end 
 
local function onCastSpell3(parameters) 
doCombat(parameters.cid, parameters.combat3, parameters.var) 
end 

function onCastSpell(cid, var) 
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2, combat3 = combat3 } 
local events = {onCastSpell1, onCastSpell2, onCastSpell3}
local time = {500, 600, 800,}
local target = getCreatureTarget(cid)
for i = 1, 3 do     
   addEvent(events[i], time[i], parameters) 
		end
		end
 
That's not even random, it casts all 3 combats.
Lua:
local t, combat = {
{COMBAT_ENERGYDAMAGE, 35, 11, -0.5, -50, -0.6, 0},
{COMBAT_FIREDAMAGE, 36, {1,2,26,30}, -0.5, -50, -0.6, 0},
{COMBAT_ENERGYDAMAGE, 35, 11, -0.5, -50, -0.6, 0},
}, {}

for i = 1, #t do
	local k = t[i]
	combat[i] = createCombatObject()
	setCombatParam(combat[i], COMBAT_PARAM_TYPE, k[1])
	setCombatParam(combat[i], COMBAT_PARAM_DISTANCEEFFECT, type(k[2])=='table' and k[2][math.random(#k[2])] or k[2])
	setCombatParam(combat[i], COMBAT_PARAM_EFFECT, type(k[3])=='table' and k[3][math.random(#k[3])] or k[3])
	setCombatFormula(combat[i], COMBAT_FORMULA_LEVELMAGIC, k[4], k[5], k[6], k[7])
end
t = nil

function onCastSpell(cid, var)
	doCombat(cid, combat[math.random(#combat)], var)
end
 
Last edited:
Well Maybe i shall post here that spells i need to make random? :)

First one
Code:
--Spell by Jovial
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}

local combat = createCombatObject()

local combat2 = createCombatObject()

local combat3 = createCombatObject()

local combat4 = createCombatObject()

local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, 52)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local meteore = createCombatObject()
setCombatParam(meteore, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteore, COMBAT_PARAM_EFFECT, 41)
setCombatFormula(meteore, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local stun = createConditionObject(CONDITION_PARALYZE)
setConditionParam(stun, CONDITION_PARAM_TICKS, 5000)
setConditionFormula(stun, -0.8, 0, -0.9, 0)
setCombatCondition(meteor, stun)


local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatFormula(meteor_water, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

combat_arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 3, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}
}

combat_arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 3, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

combat_arr3 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 3, 0, 1, 1, 0, 0},
{0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

combat_arr4 = {
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local combat_area1 = createCombatArea(combat_arr1)
setCombatArea(combat, combat_area1)

local combat_area2 = createCombatArea(combat_arr2)
setCombatArea(combat2, combat_area2)

local combat_area3 = createCombatArea(combat_arr3)
setCombatArea(combat3, combat_area3)

local combat_area4 = createCombatArea(combat_arr4)
setCombatArea(combat4, combat_area4)

local function meteorCast(p)
        doCombat(p.cid, p.combat, positionToVariant(p.pos))
end

local function stunEffect(cid)
        doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end

function onTargetTile(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 190, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile2(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile3(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile4(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 28)
                        addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(combat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")
setCombatCallback(combat3, CALLBACK_PARAM_TARGETTILE, "onTargetTile3")
setCombatCallback(combat4, CALLBACK_PARAM_TARGETTILE, "onTargetTile4")

function onCastSpell(cid, var)
	doCreatureSay(cid, "BLIZZARD!", TALKTYPE_MONSTER)
	local msg = getCreatureMaster(cid)
	if isPlayer(msg) == true then
	local mon = getCreatureName(cid)
	doCreatureSay(msg, ""..mon..", use Blizzard!", TALKTYPE_SAY)
	end
	addEvent(doCombat, 300, cid, combat, var)
	addEvent(doCombat, 600, cid, combat2, var)
	addEvent(doCombat, 900, cid, combat3, var)
	addEvent(doCombat, 1200, cid, combat4, var)
	return doCombat(cid, combat, var)
end

Second
Code:
function onCastSpell(cid, var)
	doCreatureSay(cid, "FALLING ROCKS!", TALKTYPE_MONSTER)
	if getPlayerStorageValue(cid, 3) >= 1 then
	doSendAnimatedText(getThingPos(cid), "MISS", 215)
	setPlayerStorageValue(cid, 3, -1)
	return true
	end
	if getPlayerStorageValue(cid, 5) >= 1 then
		if math.random(1,100) <= 33 then
		doSendAnimatedText(getThingPos(cid), "SELF HIT", 180)
			if isPlayer(getCreatureTarget(cid)) then
			huah = getPlayerLevel(getCreatureTarget(cid))
			else
			huah = getPlayerLevel(getCreatureMaster(getCreatureTarget(cid)))
			end
		local levels = huah
		doTargetCombatHealth(getCreatureTarget(cid), cid, COMBAT_PHYSICALDAMAGE, -(math.random((levels*3),(levels*5))), -((math.random((levels*3),(levels*5))+10)), 3)
		return true
		end
	end
local parameters = { cid = cid, var = var}
if getCreatureName(cid) == "Graveler" then
dmga = 350
elseif getCreatureName(cid) == "Golem" then
dmga = 550
end
local dmg = dmga

		local function fall(params)
		if isCreature(params.cid) then
		local pos = getThingPos(cid)
		pos.x = pos.x + math.random(-3,3)
		pos.y = pos.y + math.random(-3,3)
		local frompos = getThingPos(cid)
		frompos.x = pos.x - 7
		frompos.y = pos.y - 6
		doSendDistanceShoot(frompos, pos, 11)
		doAreaCombatHealth(cid, ROCKDAMAGE, pos, 0, -(dmg), -(dmg+45), 44)
		end
		end
		
for rocks = 1, 20 do
addEvent(fall, rocks*150, {cid = cid})
end
for rocks = 1, 20 do
addEvent(fall, rocks*110, {cid = cid})
end
end

Third
Code:
local acombat1 = createCombatObject()
local acombat2 = createCombatObject()
local acombat3 = createCombatObject()
local acombat4 = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 79)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -0.4, 0)
 

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 79)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -0.4, 0)

local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 79)
setCombatFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -0.4, 0)

local comb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 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}
 
local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)
local area3 = createCombatArea(arr3)
local area4 = createCombatArea(arr4)
setCombatArea(acombat1, area1)
setCombatArea(acombat2, area2)
setCombatArea(acombat3, area3)
setCombatArea(acombat4, area4)


function onTargetTile(cid, pos)
    doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
    doCombat(cid,combat2,positionToVariant(pos))
end

function onTargetTile3(cid, pos)
    doCombat(cid,combat3,positionToVariant(pos))
end

function onTargetTile4(cid, pos)
    doCombat(cid,combat4,positionToVariant(pos))
end

setCombatCallback(acombat1, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

setCombatCallback(acombat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

setCombatCallback(acombat3, CALLBACK_PARAM_TARGETTILE, "onTargetTile3")

setCombatCallback(acombat4, CALLBACK_PARAM_TARGETTILE, "onTargetTile4")


local function onCastSpell1(parameters)
    doCombat(parameters.cid, acombat1, parameters.var)
end
 
local function onCastSpell2(parameters)
    doCombat(parameters.cid, acombat2, parameters.var)
end

local function onCastSpell3(parameters)
    doCombat(parameters.cid, acombat3, parameters.var)
end

local function onCastSpell4(parameters)
    doCombat(parameters.cid, acombat4, parameters.var)
end
 
function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 100, parameters)
addEvent(onCastSpell2, 400, parameters)
addEvent(onCastSpell3, 800, parameters)
addEvent(onCastSpell4, 1200, parameters)


end
Fourth
Code:
--Spell by Jovial
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}

local combat = createCombatObject()

local combat2 = createCombatObject()

local combat3 = createCombatObject()

local combat4 = createCombatObject()

local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local meteore = createCombatObject()
setCombatParam(meteore, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteore, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(meteore, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local stun = createConditionObject(CONDITION_PARALYZE)
setConditionParam(stun, CONDITION_PARAM_TICKS, 5000)
setConditionFormula(stun, -0.8, 0, -0.9, 0)
setCombatCondition(meteor, stun)


local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatFormula(meteor_water, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

combat_arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 3, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}
}

combat_arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0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 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local combat_area1 = createCombatArea(combat_arr1)
setCombatArea(combat, combat_area1)

local combat_area2 = createCombatArea(combat_arr2)
setCombatArea(combat2, combat_area2)

local combat_area3 = createCombatArea(combat_arr3)
setCombatArea(combat3, combat_area3)

local combat_area4 = createCombatArea(combat_arr4)
setCombatArea(combat4, combat_area4)

local function meteorCast(p)
        doCombat(p.cid, p.combat, positionToVariant(p.pos))
end

local function stunEffect(cid)
        doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end

function onTargetTile(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 190, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile2(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile3(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile4(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 3)
                        addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(combat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")
setCombatCallback(combat3, CALLBACK_PARAM_TARGETTILE, "onTargetTile3")
setCombatCallback(combat4, CALLBACK_PARAM_TARGETTILE, "onTargetTile4")

function onCastSpell(cid, var)
	doCreatureSay(cid, "MAGMA STORM!", TALKTYPE_MONSTER)
	local msg = getCreatureMaster(cid)
	if isPlayer(msg) == true then
	local mon = getCreatureName(cid)
	doCreatureSay(msg, ""..mon..", use Magma Storm!", TALKTYPE_SAY)
	end
	addEvent(doCombat, 300, cid, combat, var)
	addEvent(doCombat, 600, cid, combat2, var)
	addEvent(doCombat, 900, cid, combat3, var)
	addEvent(doCombat, 1200, cid, combat4, var)
	return doCombat(cid, combat, var)
end

Fifth
Code:
--Spell by Jovial
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}

local combat = createCombatObject()

local combat2 = createCombatObject()

local combat3 = createCombatObject()

local combat4 = createCombatObject()

local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, 48)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local meteore = createCombatObject()
setCombatParam(meteore, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteore, COMBAT_PARAM_EFFECT, 48)
setCombatFormula(meteore, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

local stun = createConditionObject(CONDITION_PARALYZE)
setConditionParam(stun, CONDITION_PARAM_TICKS, 5000)
setConditionFormula(stun, -0.8, 0, -0.9, 0)
setCombatCondition(meteor, stun)


local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatFormula(meteor_water, COMBAT_FORMULA_LEVELMAGIC, -4.6, -200, -4.2, -200)

combat_arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 3, 1, 0, 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 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local combat_area1 = createCombatArea(combat_arr1)
setCombatArea(combat, combat_area1)

local combat_area2 = createCombatArea(combat_arr2)
setCombatArea(combat2, combat_area2)

local combat_area3 = createCombatArea(combat_arr3)
setCombatArea(combat3, combat_area3)

local combat_area4 = createCombatArea(combat_arr4)
setCombatArea(combat4, combat_area4)

local function meteorCast(p)
        doCombat(p.cid, p.combat, positionToVariant(p.pos))
end

local function stunEffect(cid)
        doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end

function onTargetTile(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 190, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile2(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile3(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 450, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end

function onTargetTile4(cid, pos)
        if (math.random(0, 1) == 1) then
                local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
                if (isInArray(water, ground.itemid) == TRUE) then
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
                else
                        local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
                        doSendDistanceShoot(newpos, pos, 41)
                        addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
			addEvent(meteorCast, 690, {cid = cid,pos = pos, combat = meteore})
                end
        end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(combat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")
setCombatCallback(combat3, CALLBACK_PARAM_TARGETTILE, "onTargetTile3")
setCombatCallback(combat4, CALLBACK_PARAM_TARGETTILE, "onTargetTile4")

function onCastSpell(cid, var)
	doCreatureSay(cid, "THUNDER STORM!", TALKTYPE_MONSTER)
	local msg = getCreatureMaster(cid)
	if isPlayer(msg) == true then
	local mon = getCreatureName(cid)
	doCreatureSay(msg, ""..mon..", use Thunder Storm!", TALKTYPE_SAY)
	end
	addEvent(doCombat, 300, cid, combat, var)
	addEvent(doCombat, 600, cid, combat2, var)
	addEvent(doCombat, 900, cid, combat3, var)
	addEvent(doCombat, 1200, cid, combat4, var)
	return doCombat(cid, combat, var)
end
 
Back
Top