Page 1 of 4
Help with constructing spells?
Posted: Fri Oct 05, 2012 2:42 pm
by flatline
In short: I want to expand the dark magic with a few spells, tied to spellcraft.
Dark magic=low mana cost, but costs HP to cast (of the entire party). Think "blood magic" sort of. Might give it area effect, ie several "damageTile" based around the caster. Sacrifice HP to do high damage all around you.
Here's the code I began to experiment with, but if I use the "damageTile"-line, the editor crashes.
(never mind the values, they're for testing)
defineSpell{
name = "curse",
uiName = "Caliginous curse",
skill = "spellcraft",
level = 1,
runes = "DEF",
manaCost = 10,
onCast = function(party)
damageTile(party.level, party.x, party.y, party.facing, 1, "physical", 5)
playSound("level_up")
party:playScreenEffect("frostburst")
end,
}
What is it I don't understand? (a lot, admittedly...)
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 2:51 pm
by Blichew
flatline wrote:In short: I want to expand the dark magic with a few spells, tied to spellcraft.
Dark magic=low mana cost, but costs HP to cast (of the entire party). Think "blood magic" sort of. Might give it area effect, ie several "damageTile" based around the caster. Sacrifice HP to do high damage all around you.
Here's the code I began to experiment with, but if I use the "damageTile"-line, the editor crashes.
(never mind the values, they're for testing)
defineSpell{
name = "curse",
uiName = "Caliginous curse",
skill = "spellcraft",
level = 1,
runes = "DEF",
manaCost = 10,
onCast = function(party)
damageTile(party.level, party.x, party.y, party.facing, 1, "physical", 5)
playSound("level_up")
party:playScreenEffect("frostburst")
end,
}
What is it I don't understand? (a lot, admittedly...)
Look at assed definition reference for onCast function of a spell asset:
onCast: this function is called when the spell is cast. The function receives the following parameters: the champion casting the spell, x, y, direction, skill.
So, you should get the same number parameters in your function, like this:
Code: Select all
defineSpell{
name = "curse",
uiName = "Caliginous curse",
skill = "spellcraft",
level = 1,
runes = "DEF",
manaCost = 10,
onCast = function(party, x, y, direction, skill)
damageTile(party.level, party.x, party.y, party.facing, 1, "physical", 5)
playSound("level_up")
party:playScreenEffect("frostburst")
end
}
also, no "," after "end" (as far as I can remember)
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 2:53 pm
by flatline
Thanks, I probably should've seen that. Still getting used to Lua

Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 2:53 pm
by petri
Party is not the same thing as "caster" here. Caster means the champion casting the spell. These should not be mixed up.
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 3:20 pm
by Blichew
Yeah, I've just left the var name from original flatline's script.
So to avaid mix-up:
Code: Select all
defineSpell{
name = "curse",
uiName = "Caliginous curse",
skill = "spellcraft",
level = 1,
runes = "DEF",
manaCost = 10,
onCast = function(champ, x, y, direction, skill)
damageTile(champ.level, champ.x, champ.y, champ.facing, 1, "physical", 5)
playSound("level_up")
party:playScreenEffect("frostburst")
end
}
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 3:29 pm
by flatline
Still crashes, tried a few variants too, simplifying stuff. If I take out the damageTile-line, it is stable.
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 4:22 pm
by petri
A champion does not have x,y coords and other properties, only the party does.
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 5:14 pm
by Blichew
Thanks, petri.
Again then:
Code: Select all
defineSpell{
name = "curse",
uiName = "Caliginous curse",
skill = "spellcraft",
level = 1,
runes = "DEF",
manaCost = 10,
onCast = function(champ, x, y, direction, skill)
hudPrint(champ:getName().." pulls some of party's life force to strenghten the spell")
damageTile(party.level, party.x, party.y, party.facing, 1, "physical", 10)
local newX = party.x
local newY = party.y
if party.facing == 0 then
newY = newY - 1
elseif party.facing == 1 then
newX = newX + 1
elseif party.facing == 2 then
newY = newY + 1
elseif party.facing == 3 then
newX = newX - 1
end
damageTile(party.level, newX, newY, party.facing, 1, "fire",50)
playSound("level_up")
party:playScreenEffect("frostburst")
end
}
You can add an fx with particle effect on the (party.level, newX, newY) tile for the better effect

Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 6:25 pm
by LordGarth
I think I am seeing a way to assign runes needed for new spells.
Is that true
runes "def"
LG
Re: Help with constructing spells?
Posted: Fri Oct 05, 2012 6:38 pm
by LordGarth
hahahah
Yes
Lots of new spells coming
LG