Code: Select all
if direction == 0 then y = y-1 else if direction == 1 then x = x+1 else if direction == 2 then y = y+1 else x = x-1 end end end

Code: Select all
if direction == 0 then y = y-1 else if direction == 1 then x = x+1 else if direction == 2 then y = y+1 else x = x-1 end end end
Code: Select all
function checkwall()
local direction = party.facing
local x = party.x
local y = party.y
local elevation = party.elevation
local myx = x
local myy = y
if direction == 0 then
myy = y - 1
elseif direction == 1 then
myx = x + 1
elseif direction == 2 then
myy = y + 1
elseif direction == 3 then
myx = x - 1
end
if not party.map:checkLineOfFire(x,y,myx,myy,elevation) then
return true
else
return false
end
end
I dont know why, but when I create custom fireball spell, it perfectly works only when party facing north and south. I tryed many different scripts from all over the forum but result is same.GoldenShadowGS wrote:You need to do a check to see if the party is in front of a wall.
Add this to your script and run the function checkwall(), if it returns true, then spawn the fireball on the same square as the party, if it returns false, spawn it one tile in front of the party.
SpoilerShowCode: Select all
function checkwall() local direction = party.facing local x = party.x local y = party.y local elevation = party.elevation local myx = x local myy = y if direction == 0 then myy = y - 1 elseif direction == 1 then myx = x + 1 elseif direction == 2 then myy = y + 1 elseif direction == 3 then myx = x - 1 end if not party.map:checkLineOfFire(x,y,myx,myy,elevation) then return true else return false end end
Code: Select all
defineSpell{
name = "my_fireball",
uiName = "Fireball",
gesture = 1,
manaCost = 10,
onCast = function(champion, x, y, direction, elevation, skillLevel)
local myx = x
local myy = y
if direction == 0 then myy = y - 0.5 end
if direction == 1 then myx = x + 0.5 end
if direction == 2 then myy = y + 0.5 end
if direction == 3 then myx = x - 0.5 end
if dep.script:checkwall() then
spawn("projectile_fireball", party.level, x, y, direction, elevation)
else
spawn("projectile_fireball", party.level, myx, myy, direction, elevation)
end
end,
skill = "fire_magic",
requirements = { "fire_magic", 0},
icon = 61,
spellIcon = 7,
description = "A flaming ball of fire shoots from your fingertips causing devastating damage to your foes.",
}