Help with constructing spells?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
flatline

Help with constructing spells?

Post 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)
SpoilerShow
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...)
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: Help with constructing spells?

Post 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)
SpoilerShow
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)
flatline

Re: Help with constructing spells?

Post by flatline »

Thanks, I probably should've seen that. Still getting used to Lua :D
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Help with constructing spells?

Post by petri »

Party is not the same thing as "caster" here. Caster means the champion casting the spell. These should not be mixed up.
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: Help with constructing spells?

Post 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
}
flatline

Re: Help with constructing spells?

Post by flatline »

Still crashes, tried a few variants too, simplifying stuff. If I take out the damageTile-line, it is stable.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Help with constructing spells?

Post by petri »

A champion does not have x,y coords and other properties, only the party does.
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: Help with constructing spells?

Post 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 :)
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Help with constructing spells?

Post by LordGarth »

I think I am seeing a way to assign runes needed for new spells.

Is that true

runes "def"

LG
Dungeon Master and DOOM will live forever.
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Help with constructing spells?

Post by LordGarth »

hahahah

Yes

Lots of new spells coming

LG
Dungeon Master and DOOM will live forever.
Post Reply