• 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 doAreaCombatHealth spell help D:<

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
Well I've been redoing a lot of my spells this way, honestly idk why, easier to use i suppose. WARNING: if you plan to use this spell file format, it does not work with bonuses such as utito tempo, or equipment bonuses, there's ways around the equipment bonuses. ( check slot item ) But I'm not 100% sure how to use this function, let me know where it's wrong.
PHP:
function onCastSpell(cid, var) 
local lvl = getPlayerLevel(cid) 
local dmgMax = ((lvl * 5))
local dmgMin = ((dmgMax*0.90))
ret = doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, getCreaturePosition(cid), AREA_SMALLSHIELD, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
return ret
end
 
if you have the spell working you just need to add more areas, and in the script check for the position of the target...

Code:
local areaNorth = {
{0, 3, 0},
{0, 1, 0}
}

local areaSouth = {
{0, 1, 0},
{0, 3, 0}
}
local areaEast = {
{0, 0},
{1, 3},
{0, 0}
}
local areaWest = {
{0, 0},
{3, 1},
{0, 0}
}

local setAreaNorth = createCombatArea(areaNorth)
local setAreaSouth = createCombatArea(areaSouth)
local setAreaEast = createCombatArea(areaEast)
local setAreaWest = createCombatArea(areaWest)

function onCastSpell(creature, var)
local target = creature:getTarget()
local tpos = target:getPosition()
local mpos = creature:getPosition()
local dmgMin = 570
local dmgMax = 750

if tpos.x == mpos.x and tpos.y < mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setWestArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.x == mpos.x and tpos.y > mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setEastArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x > mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setSouthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x < mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setNorthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
end
end
 
if you have the spell working you just need to add more areas, and in the script check for the position of the target...

Code:
local areaNorth = {
{0, 3, 0},
{0, 1, 0}
}

local areaSouth = {
{0, 1, 0},
{0, 3, 0}
}
local areaEast = {
{0, 0},
{1, 3},
{0, 0}
}
local areaWest = {
{0, 0},
{3, 1},
{0, 0}
}

local setAreaNorth = createCombatArea(areaNorth)
local setAreaSouth = createCombatArea(areaSouth)
local setAreaEast = createCombatArea(areaEast)
local setAreaWest = createCombatArea(areaWest)

function onCastSpell(creature, var)
local target = creature:getTarget()
local tpos = target:getPosition()
local mpos = creature:getPosition()
local dmgMin = 570
local dmgMax = 750

if tpos.x == mpos.x and tpos.y < mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setWestArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.x == mpos.x and tpos.y > mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setEastArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x > mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setSouthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x < mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setNorthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
end
end
if you have the spell working you just need to add more areas, and in the script check for the position of the target...

Code:
local areaNorth = {
{0, 3, 0},
{0, 1, 0}
}

local areaSouth = {
{0, 1, 0},
{0, 3, 0}
}
local areaEast = {
{0, 0},
{1, 3},
{0, 0}
}
local areaWest = {
{0, 0},
{3, 1},
{0, 0}
}

local setAreaNorth = createCombatArea(areaNorth)
local setAreaSouth = createCombatArea(areaSouth)
local setAreaEast = createCombatArea(areaEast)
local setAreaWest = createCombatArea(areaWest)

function onCastSpell(creature, var)
local target = creature:getTarget()
local tpos = target:getPosition()
local mpos = creature:getPosition()
local dmgMin = 570
local dmgMax = 750

if tpos.x == mpos.x and tpos.y < mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setWestArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.x == mpos.x and tpos.y > mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setEastArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x > mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setSouthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x < mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setNorthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
end
end
or you could create a direction table with the areas for each direction and check direction oncastspell and execute accordingly
 
Back
Top