New Spells >> show them off here

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

Re: New Spells >> show them off here

Post by flatline »

Thanks a lot!
I've been doing this when I should've been sleeping so I am aware that it is a mess, efficiency-wise. The benefits of a script entity are obvious, but it's just me hating to clutter my maps and forcing people to edit their maps, rather than just putting entries into their ini files. I'll improve all of this once I've gotten some sleep. Thanks again.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: New Spells >> show them off here

Post by Grimwold »

Grimwold's Area of Effect Spell System
Have been working on this on and off for a few days since Akroma222 and, originally, cromcrom mentioned area effect spells... this is my somewhat generic system for creating such area effect spells.

First you will need a script_entity which I have called grimwold_spell_script. Here you paste in the following:

Code: Select all

function stormSpell(ordinal,effect,particle,sound,damage,area)
  local dx,dy = getForward(party.facing) -- forward
  local ldx,ldy = getForward((party.facing+3)%4) -- left
  local rdx,rdy = getForward((party.facing+1)%4) -- right
  local originator = 2 ^ (ordinal+1) 
  local effect_translation_table = {fire = 1 , cold = 1, shock = 1, poison = 1 }
  local coords = {}
  if area == "square" then
    coords = {xcoord = {-1,-1,-1,0,0,1,1,1},ycoord = {-1,0,1,-1,1,-1,0,1}}
  elseif area == "bigsquare" then
    coords = {xcoord = {-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2},ycoord = {-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2}}
  elseif area == "cone" then
    coords = {xcoord = {dx,2*dx,2*dx+ldx,2*dx+rdx,3*dx,3*dx+2*ldx,3*dx+ldx,3*dx+rdx,3*dx+2*rdx},ycoord = {dy,2*dy,2*dy+ldy,2*dy+rdy,3*dy,3*dy+2*ldy,3*dy+ldy,3*dy+rdy,3*dy+2*rdy}}
  elseif area == "smallcone" then
    coords = {xcoord = {dx+ldx,dx,dx+rdx},ycoord = {dy+ldy,dy,dy+rdy}}
  elseif area == "line" then
    coords = {xcoord = {dx,2*dx,3*dx},ycoord = {dy,2*dy,3*dy}}
  else 
    coords = {xcoord = {dx},ycoord = {dy}}
  end
  local coord_pairs = math.min(#coords["xcoord"],#coords["ycoord"])
  for i = 1,coord_pairs do
    if particle == "poison_cloud" or particle == "ice_shards" or particle == "one_ice_shard" then
      spawn(particle,party.level, party.x + coords["xcoord"][i], party.y + coords["ycoord"][i], party.facing)
    else
      spawn("fx", party.level, party.x + coords["xcoord"][i], party.y + coords["ycoord"][i], party.facing)
        :setParticleSystem(particle)
        :translate(0, effect_translation_table[effect], 0)
      playSoundAt(sound, party.level, party.x + coords["xcoord"][i], party.y + coords["ycoord"][i])
    end
    damageTile(party.level, party.x + coords["xcoord"][i], party.y + coords["ycoord"][i], party.facing, originator , effect, damage)
  end
end
Then in your spells.lua file you need to paste in the following, which also includes 4 sample spells for you to keep/tweak/overwrite:

Code: Select all

-- STORM SPELL PACK --
-- SAMPLE SPELL DEFINITIONS --

    defineSpell{
    name = "fire_storm",
    uiName = "Fire Storm",
    skill = "fire_magic",
    level = 16,
    runes = "AFH",
    manaCost = 35,
    onCast = function(caster,x,y,direction,skill)
      return grimwold_spell_script.stormSpell(caster:getOrdinal(),"fire","firestorm","fireburst",skill*3,"square")
    end,
    }

    defineSpell{
    name = "ice_cone",
    uiName = "Ice Cone",
    skill = "ice_magic",
    level = 19,
    runes = "FHI",
    manaCost = 35,
    onCast = function(caster,x,y,direction,skill)
      return grimwold_spell_script.stormSpell(caster:getOrdinal(),"cold","one_ice_shard","ice_shard",skill*3,"cone")
    end,
    }

    defineSpell{
    name = "lightning_storm",
    uiName = "Lightning Storm",
    skill = "air_magic",
    level = 19,
    runes = "CFH",
    manaCost = 35,
    onCast = function(caster,x,y,direction,skill)
      return grimwold_spell_script.stormSpell(caster:getOrdinal(),"shock","shockburst","shockburst",skill*3,"bigsquare")
    end,
    }

    defineSpell{
    name = "poison_burst",
    uiName = "Poision Burst",
    skill = "earth_magic",
    level = 13,
    runes = "FGH",
    manaCost = 35,
    onCast = function(caster,x,y,direction,skill)
      return grimwold_spell_script.stormSpell(caster:getOrdinal(),"poison","poison_cloud","poison_cloud",skill*3,"square")
    end,
    }

-- STORM SPELL PACK --
-- SAMPLE SPELL SCROLL ITEM DEFINITIONS --

defineObject{
  name = "scroll_fire_storm",
  class = "Item",
  uiName = "Scroll of Fire Storm",
  model = "assets/models/items/scroll_spell.fbx",
  gfxIndex = 113,
  scroll = true,
  spell = "fire_storm",
  weight = 0.3,
}

defineObject{
  name = "scroll_ice_cone",
  class = "Item",
  uiName = "Scroll of Ice Storm",
  model = "assets/models/items/scroll_spell.fbx",
  gfxIndex = 113,
  scroll = true,
  spell = "ice_cone",
  weight = 0.3,
}

defineObject{
  name = "scroll_lightning_storm",
  class = "Item",
  uiName = "Scroll of Lightning Storm",
  model = "assets/models/items/scroll_spell.fbx",
  gfxIndex = 113,
  scroll = true,
  spell = "lightning_storm",
  weight = 0.3,
}

defineObject{
  name = "scroll_poison_burst",
  class = "Item",
  uiName = "Scroll of Poison Storm",
  model = "assets/models/items/scroll_spell.fbx",
  gfxIndex = 113,
  scroll = true,
  spell = "poison_burst",
  weight = 0.3,
}

-- STORM SPELL PACK --
-- OBJECT DEFINITIONS --

defineObject{
	name = "one_ice_shard",
	class = "IceShards",
	attackPower = 20,
	chainCounter = 1,
	--cameraShake = true,
	tags = { "spell" },
}

-- STORM SPELL PACK --
-- PARTICLE DEFINITIONS --

defineParticleSystem{
	name = "firestorm",
	emitters = {

		-- flames
		{
			spawnBurst = true,
			maxParticles = 30,
			sprayAngle = {0,360},
                        velocity = {3,5},
			objectSpace = true,
                        texture = "assets/textures/particles/torch_flame.tga",
			frameRate = 35,
			frameSize = 64,
			frameCount = 16,
			lifetime = {0.4,0.6},
			color0 = {1, 0.5, 0.25},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.3,
			size = {0.5, 1.5},
                        gravity = {0,-15,0},
                        airResistance = 0.5,
                        rotationSpeed = 0,
                        blendMode = "Additive",
		},

		-- glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,-0.1},
			boxMax = {0,0,-0.1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {0.5, 0.5},
			colorAnimation = false,
			color0 = {1.500000, 0.495000, 0.090000},
			opacity = 1,
			fadeIn = 0.01,
			fadeOut = 0.5,
			size = {4, 4},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 2,
			blendMode = "Additive",
		}

	}
}
To define a new Area of Effect Spell you need to use the following patten, which I will explain.

Code: Select all

    defineSpell{
    name = "fire_storm",
    uiName = "Fire Storm",
    skill = "fire_magic",
    level = 16,
    runes = "AFH",
    manaCost = 35,
    onCast = function(caster,x,y,direction,skill)
      return grimwold_spell_script.stormSpell(caster:getOrdinal(),"fire","firestorm","fireburst",skill*3,"square")
    end,
    }
The early entries should all be familiar to anyone who has defined a spell: name, uiName, skill, level, runes, manaCost. Following that is the meat of the spell definition, the function which takes a number of variables as follows:
#1 - caster:getOrdinal() - this transfers the ordinal of the spellcaster to the function and is necessary for granting XP. This entry should remain unchanged.
#2 - "fire" - this is the type of damage to deal. you can use "fire","cold","shock" or "poison"
#3 - "firestorm" - this is the particle system to use in each square of the spell's effect. you can use any defined particle system, but there are 3 special cases "poison_cloud", "ice_shards" and my new "one_ice_shard" where the name is used to spawn an object instead of an FX with a particle system.
#4 - "fireburst" - this is the sound to play in each square of the spell's effect. Can use any defined sound... preferably one that doesn't loop!
#5 - skill*3 - this is the damage done in each square of the spell's effect. You can use any numerical value.
#6 - "square" - this is the target pattern to use for the spell. supported patterns are "square", "bigsquare", "cone", "smallcone" and "line". If you don't use one of these, then only the square infront of the party will be affected.

The sample spells I have included are:
Firestorm - fire damage to the 8 spaces around the party in a "square". Using my new "firestorm" particle system.
Ice Cone - cold damage to a triangle of 9 squares in front of the party.. in the shape 1,3,5. this uses my new "one_ice_shard" object which creates a single space ice_shard instead of a chain of 4
Lightning Storm - shock damage to 24 spaces around the party like the "square" but 2 spaces wide
Poison Burst - poison damage to a row of 3 squares in front of the party (e.g. one side of the "square")
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 »

Flatline-
Thank you sir!! However.. the spell is being cast successfully but I am still getting hit by arrows :o
may it be because 'arrowstest' and 'randomscript' appear to be the same script?? Curious...

Grimwold-
Very impressive indeed, you have just made a "make your own AOE spell toolkit" !! Fantastic... definitely will be using this for AOE business.
I have tried each example spell with each type of 'square' (I think) and all works very well :D
.... although I am now running out of logical rune combinations lol...
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 »

Post deleted - freezing blast and other variations posted but damage tile forgotten, will re-post once it is fixed.
EDIT - Thanks Grimwold, got Freeze Monster online now ;) Very cool indeed
Last edited by akroma222 on Fri Nov 23, 2012 8:36 am, edited 1 time in total.
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: New Spells >> show them off here

Post by Komag »

I just gotta say, this spell thread is incredible, so much goodness here! Maybe the juiciest stuff could be condensed and put on the wiki
Finished Dungeons - complete mods to play
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: New Spells >> show them off here

Post by Grimwold »

Komag wrote:I just gotta say, this spell thread is incredible, so much goodness here! Maybe the juiciest stuff could be condensed and put on the wiki
I must admit I have neglected the wiki. I will certainly try to put some of my stuff up there.
flatline

Re: New Spells >> show them off here

Post by flatline »

*Edit* Updated my Spell pack with Infravision spell 26 nov.


Updated my magic pack in line with Grimwolds excellent ideas and Akromas thoughts. Still learning, but this update makes it somewhat more coherent:

Some of the fixes:
Corrected bugs pointed out by Grimwold
Added Arrowshield (works against all forms of ranged attacks)
Streamlined in-game script
Some balance changes.
Added notes for the spells

Get it from this post:
viewtopic.php?f=14&t=3475&p=44161#p44161
Last edited by flatline on Wed Nov 28, 2012 8:46 am, edited 1 time in total.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: New Spells >> show them off here

Post by Soaponarope »

A see through walls spell, could it be done?

I'm thinking of the spell from Dungeon Master which opens a window through the wall allowing you to look through. I have an idea of how the script would look(using self.facing and swapping props for a few seconds then back), but is it possible to swap out sections of actual wall, or would the entire dungeon have to be made of placeable walls like secret doors? Just brainstorming, could make for some cool puzzles.
flatline

Re: New Spells >> show them off here

Post by flatline »

Soaponarope wrote:A see through walls spell, could it be done?

I'm thinking of the spell from Dungeon Master which opens a window through the wall allowing you to look through. I have an idea of how the script would look(using self.facing and swapping props for a few seconds then back), but is it possible to swap out sections of actual wall, or would the entire dungeon have to be made of placeable walls like secret doors? Just brainstorming, could make for some cool puzzles.
Secret Door Walls (ie the thin walls) could be done easily by replacing it with a transparent obstacle for a moment, but the solid walls would be a lot harder.Converting my Infravision spell could convey a lot of info through different particles, for example letting keys shine golden, monsters red and doors green. You get the point.

Come to think of it, it could be done for solid walls too but would require cloning every item you want to be visible through a wall, adding a negative depthBias to it, and then spawning the cloned version on top of the real version, say within 3 squares of the party. You would then see everything within 3 of your party through walls.

Theoretical example:
1.Clone the regular door
2. Give it a negative depthBias
3. Make a spell that spawns the cloned door on top of any regular door within 3 of the party.
4. Repeat for every item you want visible with the spell.
4. Cast spell
5. Profit
6. Remember to delete the spawned items after a set time.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: New Spells >> show them off here

Post by Grimwold »

Just fixed a bug in my Burn Monster spell that didn't materialise till a dungeon containing the mod was exported and the game saved after casting it. Many thanks to Akroma222 for pointing it out.

I've updated the original script and have updated my magic pack on nexus (link in my sig). I've also included the "sample" Area Effect spells in the magic pack.
Post Reply