• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

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
 
The spell doesn't work. I'm trying to achieve a working area spell. I have changed it up to this now:
PHP:
function onCastSpell(cid, var) 
local lvl = getPlayerLevel(cid) 
local dmgMax = ((lvl * 5))
local dmgMin = ((dmgMax*0.90))
local areaa = createCombatArea{
	{1, 1, 1},
	{1, 3, 1}
}
ret = doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, pos, areaa, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
return ret
end

Edit; I get no errors on startup.
Here is the function itself that I don't understand parts of: doAreaCombatHealth(cid, type, pos, area, min, max, effect)
I don't understand how to use the pos and area.
Here is the error I get upon using the spell:
Code:
[20/07/2012 09:31:43] Lua Script Error: [Spell Interface] 
[20/07/2012 09:31:43] data/spells/scripts/attack/enchanted riot shield.lua:onCastSpell

[20/07/2012 09:31:43] luaCreateCombatArea(). This function can only be used while loading the script.

[20/07/2012 09:31:43] Lua Script Error: [Spell Interface] 
[20/07/2012 09:31:43] data/spells/scripts/attack/enchanted riot shield.lua:onCastSpell

[20/07/2012 09:31:43] attempt to index a nil value
[20/07/2012 09:31:43] stack traceback:
[20/07/2012 09:31:43] 	[C]: in function 'doAreaCombatHealth'
[20/07/2012 09:31:43] 	data/spells/scripts/attack/enchanted riot shield.lua:9: in function <data/spells/scripts/attack/enchanted riot shield.lua:1>
Here is an example of a working spell with this type of format, but it is not an area spell which is where I go wrong.
PHP:
function onCastSpell(cid, var) 
local target = variantToNumber(var)  
local lvl = getPlayerLevel(cid) 
local dmgMax = ((lvl * 1))
local dmgMin = ((dmgMax*0.50))
local playerTarget = getCreatureTarget(cid)
if(target ~= 0) then 
ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, 0)
end 
return ret 
end
Any further questions, please ask.
 
Last edited:
Well I somewhat got it working, it works for like an area spell which is a decent achievement, but it does not work with wave spells. I had it all set up in spells.xml, I know it wasn't wrong there. But any direction you turn, it casts in the same place. I'm thinking it has something to do with setCombatArea, but I don't know what to connect it to in place of the combat, I tried ret but idk. Here is what I came up with.
LUA:
local area = createCombatArea(AREA_SQUARE1X1)
function onCastSpell(cid, var) 
local lvl = getPlayerLevel(cid) 
local dmgMax = ((lvl * 3))
local dmgMin = ((dmgMax*0.90))
ret = doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, getCreaturePosition(cid), area, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
return ret
end
 
Did you try direction ="1" in spells.xml? also why are you using return ret? just do this
LUA:
local area = createCombatArea(AREA_SQUARE1X1)

function onCastSpell(cid, var) 
	local lvl = getPlayerLevel(cid) 
	local dmgMax = ((lvl * 3))
	local dmgMin = ((dmgMax*0.90))
	return doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, getCreaturePosition(cid), area, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
end
 
yes, i did try direction="1", wouldn't work. and it's because my first spell i made like that had like 4 functions in the ret, and it looked better, then i just started copying and pasting that spell haha, hopefully you can help, thanks in advance.
 
I don't think it will because I think directions are hardcoded? I could be wrong, but I'm not sure how else you'd do it unless you make the script check the player look direction
 
I was thinking about that too, but I also strongly believe that it's just a simple line like this: setCombatArea(combat, area). But I'm not sure how to use it without combat, I tried putting ret for combat in the (), but that's a no go, but then again the setCombatArea was set before the ret, but I can't make it local ret =, I'm stumped.
 
Code:
function onCastSpell(cid, var) 
local lvl = getPlayerLevel(cid) 
local dmgMax = ((lvl * 5))
local dmgMin = ((dmgMax*0.90))
local areaa = createCombatArea{
    {1, 1, 1},
    {1, 3, 1}
}
ret = doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, pos, areaa, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
return ret
end

The reason you get an error is because you have local areaa inside your function. Move it outside and try that again.

so..

local area = createCombatArea{}

function onCastSpell()
{
}
 
I wish that were true. It's not that it's giving me an error anymore, it doesn't work in wave format. I look south, it casts south. I look north, it casts south. i have direction="1" in spells.xml
 
Back
Top