Right now I'm trying to create new items for a Mod I'm working on and any help would be appreciated to improve my... flamethrower !
My aim is to create a heavy weapon with a secondary action with a custom spell ("Ignite") which will burn the two next tiles in front of the party. Of course, if there is a wall or an obstacle, the party's tile will be inflamed instead (like with a fireburst or a fireball). I don't know if that kind of spell has already been created ?
I managed to customize my item to launch the spell. I also managed to combine and edit the fireburst and the poison cloud assets to create the visual effects and damage I was looking for (instant damage + damage in time), but I'm still struggling with the spell itself. Here is the code of the asset, with some explanation about what works and what doesn't work.
I put the code in a spoiler tag due to its length
Code: Select all
defineSpell{
name = "ignite",
uiName = "Ignite",
gesture = 123,
manaCost = 60,
onCast = function(champion, x, y, direction, elevation, skillLevel)
local ix,iy = getForward(party.facing) -- get coordinates of the tile in front of the party
ix = ix + party.x
iy = iy + party.y
local iix,iiy = getForward(party.facing) -- get coordinates of the tile one space away in front of the party
iix = (iix*2) + party.x
iiy = (iiy*2) + party.y
-- check the first tile
local bloque1 = true
local bloque2 = true
if not party.map:isWall(ix,iy) then --if the party doesn't face a wall, the tile in front of the party can be targeted
bloque1 = false
end
if party.map:isObstacle(ix,iy,party.elevation) then -- possibly there is no wall but an obstacle
for each in party.map:entitiesAt(ix,iy) do -- check if this obstacle is a monster
if each:getComponent("monster") ~= nil then
bloque1 = false
break -- if there is at least one monster, that means that the tile is passable. No need to check other entities
else bloque1 = true
end
end
end
if bloque1 == true then -- if there is a wall or a non-monster obstacle, target the tile of the party
spawn("ignite",party.level, party.x, party.y, direction, elevation,"ignite1")
else
spawn("ignite",party.level, ix, iy, direction, elevation,"ignite1") -- if there is no wall and no obstacle (or a monster-class obstacle), target the tile in front of the party
end
local iz = ignite1:getWorldPositionY()
iz = iz-0.5
ignite1:setWorldPositionY(iz)
-- check the second tile if the first has been targeted. Basically the same code but with coordinates of the tile one space away
if bloque1 == false then
if not party.map:isWall(iix,iiy) then
bloque2 = false
end
if party.map:isObstacle(iix,iiy,party.elevation) then
for each in party.map:entitiesAt(iix,iiy) do
if each:getComponent("monster") ~= nil then
bloque2 = false
break
else bloque2 = true
end
end
end
if bloque2 == false then
spawn("ignite",party.level, iix, iiy, direction, elevation,"ignite2")
local iiz = ignite2:getWorldPositionY()
iiz = iiz-0.5
ignite2:setWorldPositionY(iiz)
end
end
end,
skill = "fire_magic",
requirements = { "fire_magic", 3, "air_magic", 3 },
icon = 99,
spellIcon = 8,
description = "Burn your way out!",
}
1/ If there is a wall in front of the party, it burns the party...
2/ if there is a wall one tile away in front of the party, it only inflames the first tile
3/ and obviously it doesn't inflame the second tile if the first is a wall or has an obstacle
Now, it can happen there is no wall but another type of obstacle
4/ in that case, the script check if the obstacle is a monster (then it burns it ) or something else : a rockpile, a tree etc.
What does not works well is the door-type obstacles (doors,secret doors etc.). In that case, I can't make the script understand that it's an obstacle, which is quite realistic with a portcullis (after all, you could cast a spell through the bars) but not at all with other kinds of doors.
I did try with getComponent() as for the monster class, but I can't get the same result. Are doors not considered as obstacle ? Maybe there is something I didn't understand yet in the way they work? What do I miss here ?
I did notice checkLineOfFire() and checkLineOfSight() functions but I couldn't understand them either. Could they be useful in my case ?
Thanks for your help.
Cheers,
Khollik
PS : apologies for possible misspelling, non English native speaking.