New Spells >> show them off here

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
akroma222
Posts: 1002
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 » Wed Feb 05, 2014 12:19 pm

Hey Localfire,
do you have a link for your energy_particle texture?
I have tried it just replacing it with the asset pack 'glow'
Akroma

User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: New Spells >> show them off here

Post by LocalFire » Thu Feb 06, 2014 12:28 am

I just grabbed an image from google and turned it into a texture with paint.net heres the link to the original image
https://encrypted-tbn0.gstatic.com/imag ... CABH33I75u
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443

User avatar
akroma222
Posts: 1002
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 » Thu Feb 06, 2014 12:39 am

Awesome stuff! ;)

User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: New Spells >> show them off here

Post by Eightball » Thu Feb 06, 2014 4:06 am

FAN OF KNIVES
JohnWordsworth wrote:
It's easy to modify the 'fan of knives' so that you can pickup the knives afterwards, and so that it does more damage! In my spell compendium, I will be using the following parameters for shootProjectile,

Code: Select all

shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, false)
The last parameter determines whether the projectile hangs around afters, and the 20 is the new damage. This feels about fair. I also made it ignore the party, as it would sometimes hit the party! In my version, I've changed modif so that there are only 5 blades too...

Code: Select all

for modif = -0.5,0.5,0.2 do

I must be doing something wrong. When I try to cast Fan of Knives all I get is my mage's spell "fizzles". Here's the script as in my spells.lua.
SpoilerShow

Code: Select all

defineSpell{
   name = "knives",
   uiName = "Fan of Knives",
   skill = "earth_magic",
   level = 1,
   runes = "GFC",
   manaCost = 5,
   onCast = function(champ, x, y, direction, skill)
      local dx,dy = getForward(party.facing)
      local x,y = party.x + dx, party.y + dy
      if party.facing == 0 or party.facing == 2 then
         for modif = -0.5,0.5,0.2 do
shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, true)
         end
      else
         for modif = -0.5,0.5,0.2 do
shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, true)
         end
      end
   end,
}

User avatar
akroma222
Posts: 1002
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 » Thu Feb 06, 2014 8:25 am

Hey Eightball,
this is how I have my 'Blades' spell set up.
Once a champ gets to Earth Magic 40 it upgrades to 'Shrapnel Blast' -
.....if you want to use this - create a counter in dungeon called 'learnShrapnelBlastCounter' and set it to 1

This in objects.lua
SpoilerShow

Code: Select all

defineSpell{
   name = "blades",
   uiName = "Blades",
   skill = "earth_magic",
   level = 15,
   runes = "CFG",
   manaCost = 50,
   onCast = function(caster, x, y, direction, skill)
      return mymod_spells.castBlades(caster,x,y,direction,skill)
   end
}
Which calls a script 'mymod_spells' script in dungeon
SpoilerShow

Code: Select all

spellCaster = 0
----------------------Blades----------------------------------
	
	function castBlades(caster,x,y,direction,skill)
        
        local dx,dy = getForward(party.facing)
      	local x,y = party.x + dx, party.y + dy
		local originator = caster:getOrdinal()
		local e = caster:getSkillLevel("earth_magic")
		local c = findEntity("learnShrapnelBlastCounter")
		
		playSound("blades_gear")
        if e >= 40 then
			if party.facing == 0 or party.facing == 2 then
    			for modif = -0.4,0.4,0.1 do
            		shootProjectile("blade_gear", party.level, x+modif, y, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 35, party, true, originator)
        		end
      		else
        		for modif = -0.4,0.4,0.1 do
            		shootProjectile("blade_gear", party.level, x, y+modif, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 35, party, true, originator)
        		end
    		end
			for ent in entitiesAt(party.level, party.x, party.y) do
        		if ent.name == "blade_gear" then
            		fxScripts.addProjectileEffect(ent, "blades_knife", 9, "hit_flame")
        		end
			end
			if c and c:getValue() == 0 then
				hudPrint("Blades has upgraded (Earth 40) to a new spell: Shapnel Blast!")
				playSound("upgrade_spell")
				c:destroy()
			end
		else
			if party.facing == 0 or party.facing == 2 then
    			for modif = -0.4,0.4,0.1 do
            		shootProjectile("blade_knife", party.level, x+modif, y, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 15, party, true, originator)
        		end
      		else
        		for modif = -0.4,0.4,0.1 do
            		shootProjectile("blade_knife", party.level, x, y+modif, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 15, party, true, originator)
        		end
    		end
			for ent in entitiesAt(party.level, party.x, party.y) do
        		if ent.name == "blade_knife" then
            		fxScripts.addProjectileEffect(ent, "blades_knife", 9, "hit_flame")
        		end
			end
		end
		spellCaster = caster:getOrdinal()
		return true
	end	
Here are the item definitions for items.lua (or wherever you put them?) ** you will need to alter the particle effect to suit you**
SpoilerShow

Code: Select all

defineObject{
   	name = "blade_gear",
   	class = "Item",
	uiName = "Blade Gear",
	model = "assets/models/items/machine_part/machine_part_junk4.fbx",
	gfxAtlas = "mod_assets/textures/akroma_icons5.tga",
    	gfxIndex = 103,
	attackPower = 35,
	particleEffect = "blades_knife",
	attackSound = "swipe_special",
	impactSound = "impact_blade",
	projectileSpeed = 10,
	projectileRotationSpeed = 10,
	projectileRotationX = 0,
	projectileRotationY = 0,
	projectileRotationZ = -60,
	weight = 10,
}


defineObject{
	name = "blade_knife",
	class = "Item",
	uiName = "Blade Knife",
	model = "assets/models/items/throwing_knife.fbx",
	gfxAtlas = "mod_assets/textures/akroma_icons3.tga",
    	gfxIndex = 42,
	attackPower = 15,
	particleEffect = "blades_knife",
	attackSound = "swipe_special",
	impactSound = "impact_blade",
	projectileSpeed = 9,
	projectileRotationSpeed = 10,
	projectileRotationX = 0,
	projectileRotationY = 0,
	projectileRotationZ = -60,
	weight = 1,
}
In the same 'mymod_spells' script I have placed a function for the monster onProjectileHitHook.
You will need to create a table called 'allMonstersList' in your monsters.lua file
In monsters.lua -
SpoilerShow

Code: Select all

allMonstersList = { "crab" , "spider" etc etc etc }

for i=1,# allMonstersList do
  cloneObject{
        name = allMonstersList[i],
        baseObject = allMonstersList[i],
        onProjectileHit = function(monster, projectile, damage, damageType)
          	return mymod_spells.customSpellOnProjectileHitHook(monster,projectile,damage, damageType)
        end,
}
end
In 'mymod_spells' script -
SpoilerShow

Code: Select all

projectileItems = {'blade_knife' , 'blade_gear' }


function isInTable(table, element)
  for _,value in pairs(table) do
    if value == element then
      return true
    end
  end
  return false
end


function customSpellOnProjectileHitHook(monster,projectile,damage,damageType)
 	local dx,dy = getForward(monster.facing)
 	if isInTable(projectileItems, projectile.name) then
if projectile.name == 'blade_knife' then
      local originator = 2 ^ (spellCaster+1) -- calculate the originator of the spell
      local damage = math.random(15,20) --
      damageTile(monster.level,monster.x,monster.y,(monster.facing + 2)%4,originator+1, 'physical',damage)
	  playSoundAt("impact_blade",monster.level,monster.x,monster.y)
      return false
   
   elseif projectile.name == 'blade_gear' then
      local originator = 2 ^ (spellCaster+1) -- calculate the originator of the spell
      local damage = math.random(30,40) --
      damageTile(monster.level,monster.x,monster.y,(monster.facing + 2)%4,originator+1, 'physical',35)
	  playSoundAt("impact_blade",monster.level,monster.x,monster.y)
      return false
    end
  end
end
You will notice also that the code for the spell in mymod_spells calls another function that adds particle effects and sorts out originator for EXP
In another script called 'fxScripts' I have-
SpoilerShow

Code: Select all

projectiles = {}
function addProjectileEffect(projectile,effectName,speed,onHitEffectName)
   local timer = spawn('timer',projectile.level,projectile.x,projectile.y,projectile.facing)
   local effect = spawn('fx',projectile.level,projectile.x,projectile.y,projectile.facing)
   projectiles[timer.id] = {}
   projectiles[timer.id].projectile_id = projectile.id
   projectiles[timer.id].effect_id =  effect.id
   projectiles[timer.id].level = projectile.level
   projectiles[timer.id].x = 0
   projectiles[timer.id].y = 0
   projectiles[timer.id].facing = projectile.facing
   projectiles[timer.id].onHitEffect= onHitEffectName
   
   local dx,dy = getForward(projectile.facing)
   dy = -1 * dy

   projectiles[timer.id].x = dx * 0.5
   projectiles[timer.id].y = dy * 0.5

   timer:addConnector('activate','fxScripts','move_effect')
   timer:setTimerInterval(0.5/speed)
   local light = getLightPreset(effectName)
   if light then
      effect:setLight(unpack(light))
   end
   
   effect:translate(0.5*dx,1,0.5*dy)
   effect:setParticleSystem(effectName)
   timer:activate()
   return effect
end

function addProjectileManualHit(caster, projectile, damageAmount, damageType, radius)

   for key,value in pairs(projectiles) do
      if value.projectile_id == projectile.id then
         if caster then
            projectiles[key].caster = caster:getOrdinal()
         end
         projectiles[key].damage = damageAmount
         projectiles[key].damageType = damageType
         projectiles[key].radius = radius
      
      end
   end

end

function getLightPreset(preset)
   --FX:setLight(red, green, blue, brightness, range, time, castShadow)
   local s = {}
   s['fireball'] = {1, 0.5, 0.25,15,7,200,true} 
   s['fireball_hit'] = {1, 0.5, 0.25,40,7,1,true}
   s['magic_missile'] = {1, 1, 1,15,7,200,true}
   s['poison_bolt'] = {0.25, 0.6, 0.2,4,4,200,true}
   s['lightning_bolt'] = {0.25, 0.5, 1,30,5,1,true}
   s['lightning_bolt_hit'] = {0.25, 0.5, 1,100,5,0.5,true}
   s['magic_missile_hit'] = {1, 1, 1,40,10,1,true}
   s['wizards_fire'] = {1, 0.9, 0.5,40,10,1,true}
   s['wizards_life_fire'] = {1, 1, 1,120,10,1,true}
   s['wizards_fire_hit'] = {1, 1, 0.95, 150,10,0.6,true}
   
   local l = s[preset]
   
   if not l then
      l = {0, 0, 0, 0, 0, 0, false}
   end
   
   return l
   
end




function move_effect(timer)
   local e = projectiles[timer.id]
   local p = findEntity(e.projectile_id)
   local fx = findEntity(e.effect_id)
   
   if not p then
      if e.onHitEffect then
         local ohfx = spawn('fx',e.level,e.px,e.py,e.facing)
         ohfx:setParticleSystem(e.onHitEffect)
         ohfx:translate(0, 1, 0)
         local light = getLightPreset(e.onHitEffect)
         if light then
            ohfx:setLight(unpack(light))
         end         
      end
        
      projectiles[timer.id] = nil
      timer:deactivate()
      timer:destroy()
      fx:destroy()  
      return
   end
   e.px = p.x
   e.py = p.y 
   fx:translate(e.x,0,e.y)
end

^^This script is not mine, it is fairly beyond me but I know it works ok (it was written for Wizards Life Fire posted earlier in this thread)

And I think that is it!!! Basically I run all my mod projectile spells using this system. It is not the best system, Diarmuid has an advanced spell framework which can do lots of things we otherwise couldnt, but unfortunately it is too much work for me transfer all my spells over to his framework.

Also!! Regarding volley type spells like fan of knives, using the (modif = -0.5,0.5,0.1) will crash the game if you cast the spell along the outskirts of your map
I think it tries to spawn knives outside the map and will crash... this is why I have decided to go with (modif = -0.4,0.4,0.1) - the spell still looks the same but it spawns all the knives inside the map.

Hopefully this helps!!
Akroma

User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: New Spells >> show them off here

Post by Eightball » Thu Feb 06, 2014 11:18 am

Awesome. Thanks for the help. I was hoping I could just use the simple one bit of script and get that to work, but maybe there was more to it to begin with. I tried finding your asset texture "mod_assets/textures/akroma_icons5.tga" to complete the spell, but I guess that's not in your asset pack on nexus. I'll have to tinker with it for a while. Or do you mind sharing that one? Sounds like your spell is perfect the way you have it! I'll just try to go with shuriken and knives for the moment. I was sorta thinking shuriken anyway.

Edit: woot! that works! now to make that long list of monsters and figuring out a particle effect :D

User avatar
akroma222
Posts: 1002
Joined: Thu Oct 04, 2012 10:08 am

Re: New Spells >> show them off here

Post by akroma222 » Sat Feb 08, 2014 5:40 am

Hey Eightball,

akroma icons 5 is just the first main icon atlas from the original game - referencing the throwing knife :)

and the particle effect I have is very simple -
SpoilerShow

Code: Select all

defineParticleSystem{
	name = "blades_knife",
	emitters = {
		-- sparks
		{
			emissionRate = 30,
			emissionTime = 0,
			maxParticles = 100,
			boxMin = {-0.015, 0.02, 0.015},
			boxMax = { 0.015, 0.1,  -0.015},
			sprayAngle = {0,180},
			velocity = {0.1, 2.4},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {0.25, 0.85},
			colorAnimation = false,
			color0 = {1.5, 1.5, 1.5},
			opacity = 0.8,
			fadeIn = 0.15,
			fadeOut = 0.3,
			size = {0.01, 0.05},
			gravity = {0,0,0},
			airResistance = 1.0,
			rotationSpeed = 1,
			blendMode = "Additive",
			depthBias = -0.0005,
			objectSpace = true,
		}
	}
}
My asset pack will be updated very soon with a lot more stuff.

Glad it's working for you :D :D
Akroma

User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: New Spells >> show them off here

Post by LocalFire » Sun Mar 02, 2014 1:30 am

I've got a question, how can I add a spell effect to an item?

I want to add Grimwolds pushback spell to an item, so it casts when the item hits an enemy, I've tried onAttack and onUseItem but neither works, is this even possible to do?
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443

User avatar
Grimwold
Posts: 508
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 » Wed Mar 05, 2014 10:14 pm

LocalFire wrote:I've got a question, how can I add a spell effect to an item?

I want to add Grimwolds pushback spell to an item, so it casts when the item hits an enemy, I've tried onAttack and onUseItem but neither works, is this even possible to do?
I did this once for a room I never used... a long time ago... I'm pretty sure you just add the following to the items.lua file.. (make sure you have the spell "push_monster" defined in lua as well). Then you can add the wand_push item in the editor. It basically looks like the lightning rod.

Code: Select all

-- A wand that uses the Push Monster spell
defineObject{
   name = "wand_push",
   class = "Item",
   description = "The wand pulses with a powerful energy.",
   uiName = "Wand of Push Monster",
   attackMethod = "castWandSpell",
   spell = "push_monster",
   wandPower = 25,
   coolDownTime = 2,
   model = "assets/models/items/lightning_rod.fbx",
   gfxIndex = 222,
   attackPower = 14,
   accuracy = 0,
   attackSwipe = "vertical",
   attackSound = "swipe",
   impactSound = "impact_blunt",
   weight = 1.7,
}

Here's a freebie... a wand of hold monster (from the same aborted room)

Code: Select all

-- A wand that uses the Hold  Monster spell
defineObject{
 name = "wand_hold",
  class = "Item",
  uiName = "Wand of Hold Monster",
  model = "assets/models/items/whitewood_wand.fbx",
  description = "A hand crafted wooden wand",
  skill = "spellcraft",
  requiredLevel = 1,
  gfxIndex = 56,
  energy = 5,
  wandPower = 25,
  coolDownTime = 2,
  attackMethod = "castWandSpell",
  spell = "hold_monster",
  impactSound = "impact_blunt",
  weight = 3.5,
}

User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: New Spells >> show them off here

Post by LocalFire » Thu Mar 06, 2014 12:41 pm

Cool, I've already got that actually (it's a gem that casts the spell) What was thinking was trying to make a weapon with a knockback effect, so you attack with a sword or mace and it also knocksback the monster

I don't know if that possible.
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443

Post Reply