New Spells >> show them off here

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Komag
Posts: 3601
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: New Spells >> show them off here

Post by Komag » Mon Mar 25, 2013 11:11 am

It will work for the whole dungeon, no problem. The only thing that is level-affected is timers
Finished Dungeons - complete mods to play

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

Re: New Spells >> show them off here

Post by akroma222 » Mon Mar 25, 2013 12:11 pm

edit-post deleted
Last edited by akroma222 on Mon Apr 01, 2013 11:48 am, edited 2 times in total.

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

Re: New Spells >> show them off here

Post by akroma222 » Mon Apr 01, 2013 11:46 am

Howdy,
Thanks again for the help with the transmute scripts!! I have used the script provided by Marble Mouth and have made a few alterations (sounds and lights for the transmute... expanded the list to include all throwing weapons and ammunitions)
I ordered the items in the table in increasing power/value and then changed the local stack size so that each time the spell is cast, you lose 1 off the stack... this is so all the ammunition in the game isn't able to be converted over as you collect it... you lose a little each time you cast it, so you need to hoard a bit then convert... which runs you into carrying capacity issues (just trying to balance)
SpoilerShow

Code: Select all

ammoCycle = { "rock" , "throwing_knife" , "arrow" , "shuriken" , "throwing_axe" , "quarrel" , "throwing_hammer" , "death_star" }

ammoNumbers = {}
--build inverse table
for i , v in ipairs( ammoCycle ) do
   ammoNumbers[v] = i
end

function transmute(caster,x,y,direction,skill)

   local item
   local slot
   for i = 7,8 do
      item = caster:getItem(i)
      if item and ammoNumbers[item.name] then
         slot = i
         break
      end
   end
   if not slot then
      return
   end

   local oldAmmoName = item.name
   local stackSize = (item:getStackSize()) - 1
   caster:removeItem(slot)
   if stackSize == 0 then
		hudPrint("According to the Law of Diminishing Returns... You must transmute more than 1 piece of ammunition")
   		return false
   end
   local newAmmoNumber = ( ammoNumbers[oldAmmoName] % ( table.getn( ammoCycle ) ) ) + 1
   local newAmmo = spawn( ammoCycle[newAmmoNumber] )
   newAmmo:setStackSize( stackSize  )
   caster:insertItem( slot , newAmmo )
   playSound("generic_spell")
   party:playScreenEffect("damage_screen_yellow")
   hudPrint( caster:getName() .. " transmuted ammunition." )
end
I will also add onto the script so that a few key items can be converted into something else (like a secret kinda thing... scrap metal part that looks kinda different >>> Oooo! It turns into a special key! :mrgreen: )

Thanks again for the help! Very much appreciated

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

Re: New Spells >> show them off here

Post by akroma222 » Fri Apr 05, 2013 11:48 am

REMOTE DETONATING (MINE) SPELLS

Hi All :)
Crisman (big credits for him as this is his great idea :) )posted an explosive mine spell earlier in this thread but it was causing some problems. I have devised a slightly different spell which involves the caster casting a second spell to detonate a planted devise. I believe I have come up with a working script that will award EXP to the caster :)
There are 3 spells listed here:
Explosive Mine (fire)
Freezing Trap (ice)
Vapor Snag (earth)

The idea behind these spells is simple. You cast the first part of the spell - to set up the explosive devise - and then you cast the second part - which will detonate the devise. The fire version is just raw damage, the ice version will freeze monsters and the earth version will deal poison damage and leave a poison cloud.

This is for spells.lua:
SpoilerShow

Code: Select all

-----------------------------------FIRE-------------------------------
defineSpell{
  name = "explosive_mine",
  uiName = "Explosive Mine",
  skill = "fire_magic",
  level = 0,
  runes = "ABDG",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.explosive_mine(caster,x,y,direction,skill)
  end,
}

defineSpell{
  name = "detonate_mine",
  uiName = "Detonate Mine",
  skill = "fire_magic",
  level = 0,
  runes = "ABG",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.detonate(caster,x,y,direction,skill)
  end,
}
-----------------------------ICE----------------------------
defineSpell{
  name = "freezing_trap",
  uiName = "Freezing Trap",
  skill = "ice_magic",
  level = 0,
  runes = "BFI",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.freezingtrap(caster,x,y,direction,skill)
  end,
}

defineSpell{
  name = "trigger_freeze",
  uiName = "Trigger Freeze",
  skill = "ice_magic",
  level = 0,
  runes = "AFI",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.freeze(caster,x,y,direction,skill)
  end,
}
----------------EARTH------------------------------------------
defineSpell{
  name = "vapor_snare",
  uiName = "Vapor Snare",
  skill = "earth_magic",
  level = 0,
  runes = "BFG",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.vaporsnare(caster,x,y,direction,skill)
  end,
}

defineSpell{
  name = "trigger_vapors",
  uiName = "Trigger Vapors",
  skill = "earth_magic",
  level = 0,
  runes = "ABFG",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return magicScript.poisonsnare(caster,x,y,direction,skill)
  end,
}
** Energy cost and skill level are set to 1 and 0 for testing purposes, change as you like...

Then paste this into a script entity ("magicScript") in your dungeon:
SpoilerShow

Code: Select all

-----------------------explosive mine-------------------------------

function explosive_mine(caster, x, y, direction, skill)

if findEntity("counterMine") ~= nil then
   findEntity("counterMine"):destroy()
else
   spawn("counter", party.level, party.x, party.y, 0, "counterMine")
end

local a = "mine"..counterMine:getValue()
spawn("pressure_plate_hidden", party.level, party.x, party.y, 0, "a")
	:setTriggeredByParty(false)
	:setTriggeredByMonster(true)
	:setTriggeredByItem(false)
	:addConnector("any", "magic", "detonate")
hudPrint("You have prepared the explosive mine...")

counterMine:increment()

end

function detonate(caster, x, y, direction, skill)

explosives_ord = 1
explosives_ord = caster:getOrdinal()
local originator = 2 ^ (explosives_ord+1)

if findEntity("counterMine") == nil then
hudPrint("You must first set the Explosive Mine before detonating it....")
return true
else
for i = 0, counterMine:getValue() do
a = findEntity("mine"..i)
   if a ~= nil then
	  spawn("fireburst", a.level, a.x, a.y, a.facing)
	  damageTile(a.level, a.x, a.y, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x, a.y-1, a.facing)
      damageTile(a.level, a.x, a.y-1, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x+1, a.y, a.facing)
      damageTile(a.level, a.x+1, a.y, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x, a.y+1, a.facing)
      damageTile(a.level, a.x, a.y+1, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x-1, a.y, a.facing)
      damageTile(a.level, a.x-1, a.y, a.facing,originator+1,'fire',skill*5)
	  spawn("fireburst", a.level, a.x+1, a.y+1, a.facing)
	  damageTile(a.level, a.x+1, a.y+1, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x-1, a.y-1, a.facing)
      damageTile(a.level, a.x-1, a.y-1, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x-1, a.y+1, a.facing)
      damageTile(a.level, a.x-1, a.y+1, a.facing,originator+1,'fire',skill*5)
      spawn("fireburst", a.level, a.x+1, a.y-1, a.facing)
      damageTile(a.level, a.x+1, a.y-1, a.facing,originator+1,'fire',skill*5)
   end
      a:setTriggeredByMonster(false)
	  findEntity("counterMine"):destroy()
	  findEntity("a"):destroy()
      return		
   end
end
end

-------------------------freeze bomb-----------------------------

function freezingtrap()

if findEntity("counterFreeze") ~= nil then
   findEntity("counterFreeze"):destroy()
else
   spawn("counter", party.level, party.x, party.y, 0, "counterFreeze")
end

local f = "trap"..counterFreeze:getValue()
spawn("pressure_plate_hidden", party.level, party.x, party.y, 0, "f")
	:setTriggeredByParty(false)
	:setTriggeredByMonster(true)
	:setTriggeredByItem(false)
	:addConnector("any", "magic", "freeze")
hudPrint("You have prepared the Freezing Trap...")

counterFreeze:increment()

end

function freeze()

if findEntity("counterFreeze") == nil then
hudPrint("You must first set the Freezing Trap before triggering it....")
return true
else
for i = 0, counterFreeze:getValue() do
f = findEntity("trap"..i)
   if f ~= nil then
	  spawn("frostburst", f.level, f.x, f.y, f.facing)
      spawn("frostburst", f.level, f.x, f.y-1, f.facing)
      spawn("frostburst", f.level, f.x+1, f.y, f.facing)
      spawn("frostburst", f.level, f.x, f.y+1, f.facing)
      spawn("frostburst", f.level, f.x-1, f.y, f.facing)
	  spawn("frostburst", f.level, f.x+1, f.y+1, f.facing)
      spawn("frostburst", f.level, f.x-1, f.y-1, f.facing)
      spawn("frostburst", f.level, f.x-1, f.y+1, f.facing)
      spawn("frostburst", f.level, f.x+1, f.y-1, f.facing)
   end
      f:setTriggeredByMonster(false)
	  findEntity("counterFreeze"):destroy()
	  findEntity("f"):destroy()
      return		
   end
end
end

-----------vapor snare--------------------------------------

function vaporsnare(caster, x, y, direction, skill)

if findEntity("counterSnare") ~= nil then
   findEntity("counterSnare"):destroy()
else
   spawn("counter", party.level, party.x, party.y, 0, "counterSnare")
end

local a = "snare"..counterSnare:getValue()
spawn("pressure_plate_hidden", party.level, party.x, party.y, 0, "a")
	:setTriggeredByParty(false)
	:setTriggeredByMonster(true)
	:setTriggeredByItem(false)
	:addConnector("any", "magic", "poisonsnare")
hudPrint("You have prepared the Poison Vapor Snare...")

counterSnare:increment()

end

function poisonsnare(caster, x, y, direction, skill)

explosives_ord = 1
explosives_ord = caster:getOrdinal()
local originator = 2 ^ (explosives_ord+1)

if findEntity("counterSnare") == nil then
hudPrint("You must first set the Vapor Snag before triggering it....")
return true
else
for i = 0, counterSnare:getValue() do
a = findEntity("snare"..i)
   if a ~= nil then
	  spawn("poison_cloud", a.level, a.x, a.y, a.facing)
	  damageTile(a.level, a.x, a.y, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x, a.y-1, a.facing)
      damageTile(a.level, a.x, a.y-1, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x+1, a.y, a.facing)
      damageTile(a.level, a.x+1, a.y, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x, a.y+1, a.facing)
      damageTile(a.level, a.x, a.y+1, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x-1, a.y, a.facing)
      damageTile(a.level, a.x-1, a.y, a.facing,originator+1,'poison',skill*2)
	  spawn("poison_cloud", a.level, a.x+1, a.y+1, a.facing)
	  damageTile(a.level, a.x+1, a.y+1, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x-1, a.y-1, a.facing)
      damageTile(a.level, a.x-1, a.y-1, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x-1, a.y+1, a.facing)
      damageTile(a.level, a.x-1, a.y+1, a.facing,originator+1,'poison',skill*2)
      spawn("poison_cloud", a.level, a.x+1, a.y-1, a.facing)
      damageTile(a.level, a.x+1, a.y-1, a.facing,originator+1,'poison',skill*2)
   end
      a:setTriggeredByMonster(false)
	  findEntity("counterSnare"):destroy()
	  findEntity("a"):destroy()
      return		
   end
end
end
If you have not 'set' the mine/trap and cast a detonating spell nothing will happen and the hud print will direct you to cast a 'setting' spell... You will need to cast a new 'setting' spell after each detonation.

If you want the ice version to be ice shards instead of frostburst, just...

1.change the spawning entity in the script- eg..
spawn("frostburst", f.level, f.x, f.y, f.facing) >change to> spawn("one_ice_shard", f.level, f.x, f.y, f.facing)

2.then add the damage tile- eg...
damageTile(a.level, f.x, f.y, f.facing,originator+1,'ice',skill*3)

3.add these lines just underneath function freeze(caster, x, y, direction, skill)
SpoilerShow

Code: Select all

function freeze(caster, x, y, direction, skill)

shards_ord = 1                                                            --add
shards_ord = caster:getOrdinal()                                 --add
local originator = 2 ^ (shards_ord+1)                           --add

if findEntity("counterFreeze") == nil then
hudPrint("You must first set the Freezing Trap before triggering it....")
return true
else


4. and finally add this to your spells.lua and objects.lua
SpoilerShow

Code: Select all

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

Enjoy being sneaky with your own traps ;-)

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

Re: New Spells >> show them off here

Post by akroma222 » Sat Apr 06, 2013 1:16 am

TRANSMUTATION SPELL VARIATIONS

Thanks to Marble Mouth and Acolade, I have been checking out variations for transmute scripts.
I wanted to go a number of different ways with it and have somehow managed to bundle the scripts together for convenience... There is of course the changing ammunition script which has been posted earlier... also posted below is a script for a random outcome (transmuting ore into various things)... and also a simple script that checks a table for the item held with the mouse cursor and then transmutes it (turn your boring stuff into cooler stuff!!)

I have also added some custom screen and sound effects.
In the examples I have just used basic items from the asset pack.

This is for spells.lua: (skill level 0 and cost 1 - change to your liking)
SpoilerShow

Code: Select all

defineSpell{
  name = "transmutation",
  uiName = "Transmutation",
  skill = "earth_magic",
  level = 0,
  runes = "EFG",
  manaCost = 1,
  onCast = function(caster, x, y, direction, skill)
    return transmutationScript.transmuteSorting(caster,x,y,direction,skill)
  end,
}
This is the floating sword socket created in Neikun's Alcove thread ....for objects.lua:
SpoilerShow

Code: Select all

defineObject{
   name = "floating_sword_socket",
   class = "Alcove",
   anchorPos = vec(0, 1.1, -1.0),
   anchorRotation = vec(90,0,90),
   targetPos = vec(0, 1.1, -0.38),
   targetSize = vec(0, 0, 0),
   placement = "wall",
   editorIcon = 92,
}
This is (optional) for sounds.lua...
SpoilerShow

Code: Select all

defineSound{
		name = "anime_sword",
		filename = "mod_assets/sounds/anime_sword.wav",
		loop = false,
		volume = 1.5,
		minDistance = 1.5,
		maxDistance = 5,
	}
now go to the link and download the "anime_sword" sound effect ... http://ge.tt/2Itz7Ad
(and any others you may want too) and copy the file into your "mod_assets/sounds" file
**If you do not want this sound effect, just change the instances of that effect with "generic_spell" in the script below.

Here are some (optional) screen effects for particles.lua:
SpoilerShow

Code: Select all

defineParticleSystem{
	name = "damage_screen_yellow",
	emitters = {
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,1},
			boxMax = {0,0,1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/damage_screen.tga",
			lifetime = {0.4, 0.4},
			colorAnimation = false,
			color0 = {1.5, 1.5, 0.5},
			opacity = 0.45,
			fadeIn = 0.001,
			fadeOut = 0.3,
			size = {2.3, 2.3},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Translucent",
			objectSpace = true,
		}
	}
}

defineParticleSystem{
	name = "damage_screen_pink",
	emitters = {
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,1},
			boxMax = {0,0,1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/damage_screen.tga",
			lifetime = {0.4, 0.4},
			colorAnimation = false,
			color0 = {1.2, 0.2, 0.7},
			opacity = 0.45,
			fadeIn = 0.001,
			fadeOut = 0.3,
			size = {2.3, 2.3},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Translucent",
			objectSpace = true,
		}
	}
}

defineParticleSystem{
	name = "damage_screen_white",
	emitters = {
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,1},
			boxMax = {0,0,1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/damage_screen.tga",
			lifetime = {0.4, 0.4},
			colorAnimation = false,
			color0 = {2, 2, 2},
			opacity = 0.45,
			fadeIn = 0.001,
			fadeOut = 0.3,
			size = {2.3, 2.3},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Translucent",
			objectSpace = true,
		}
	}
}
And this you need to paste into a script entity ("transmutationScript") in your dungeon:
SpoilerShow

Code: Select all

---------------------------------Sorting function----------------------------------

function transmuteSorting(caster,x,y,direction,skill)
   		local item = getMouseItem()
      	        local x = item
   		if x == nil then
        	hudPrint("This spell is 'usually' used to alter types of ammunition... and you must hold the ammunition with           
the mouse cursor.") 
	  	return
   	end
    	
	if x and isInTable(ammoCycle, x.name) then
		return transmutationScript.transmuteAmmo(caster,x,y,direction,skill)
	end
        if x and item.name == "mystery_ore" then
		return transmutationScript.oreTransmute(caster,x,y,direction,skill)
	end
  	if x and isInTable(transmuteList, x.name) then
		return transmutationScript.secretTransmute(caster,x,y,direction,skill)
	end
end

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

-------------------------------Ammunition Change----------------------------------------------------

ammoCycle = { "rock" , "throwing_knife" , "arrow" , "shuriken" , "throwing_axe" , "quarrel" }
                                              --you can freely add more items to this table without having to change anything else
ammoNumbers = {}
--build inverse table
for i , v in ipairs( ammoCycle ) do
   ammoNumbers[v] = i
end

function transmuteAmmo(caster,x,y,direction,skill)     --each time cast, stack size is reduced by 1
   local x = getMouseItem()
   local z = x:getStackSize()
   if z == 0 then
		hudPrint("According to the Law of Diminishing Returns... You must transmute more than 1 piece of ammo")
   		return
   end
   local stackSize = (z) - 1
   local oldAmmoName = x.name
   local newAmmoNumber = ( ammoNumbers[oldAmmoName] % ( table.getn( ammoCycle ) ) ) + 1
   local newAmmo = spawn(ammoCycle[newAmmoNumber])
   x:destroy()
   setMouseItem(newAmmo)
   newAmmo:setStackSize( stackSize  )
   playSound("anime_sword")                                                            --custom sound
   party:playScreenEffect("damage_screen_yellow")                           --custom screen effect
   hudPrint( caster:getName() .. " transmuted ammunition." )
   return
end

---------------------------------Random Ore Change------------------------------------------------------

mysteryList = {"full_helmet" , "magic_orb" , "throwing_axe" , "milkreed" , "long_sword" , "chitin_boots" , "whitewood_wand" , "flask" , "rock" , "leather_gloves" , "red_gem" , "note" , "bracelet_tirin" , "rat_shank" , "arrow"}
                                               --^^change items to reflect your needs or custom stuff,  items represent #1 - 15
	
function oreTransmute(caster,x,y,direction,skill)	--an earth spell but you will need sufficient skill in air, earth and                
                                                                                  --fire magic to cast transmute if you have the ore in mouse 
                                                                                    --cursor
	
	if findEntity("oresocket") ~= nil then
		findEntity("oresocket"):destroy()
	end
	local d = getMouseItem()
	if d and d.name == "machine_part_north" then 
	  	local skillLevel = 5
   	  	if caster:getSkillLevel("air_magic") >= skillLevel and caster:getSkillLevel("earth_magic") >= skillLevel and caster:getSkillLevel("fire_magic") >= skillLevel then
   	  		setMouseItem(nil)
			spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "oresocket")
	    	        findEntity("oresocket"):addItem(spawn( mysteryList[math.random(1,15)] ,nil, nil, nil, nil))
			hudPrint( caster:getName() .. " transmuted the piece of Ore ...... ")
   	  		playSound("anime_sword")                                                          --custom sound
   	  		party:playScreenEffect("damage_screen_yellow")                         --custom effect
			return
		end
		hudPrint("You must be more skilled in earth, air and fire magic to transmute this piece of ore...") 
	end
end

--------------------------------------Secret Change-------------------------------------------------------
	
transmuteList = {"chitin_greaves" , "chitin_mask" , "chitin_boots" , "chitin_mail" , "magic_orb" , "throwing_axe" , "ring_mail" ,"cutlas" , "whitewood_wand" , "longbow" ,  "rock" , "machine_junk4" , "machine_part_north"}

--^^change to suit your needs, I have only included basic asset pack items - I have not used all of them

function secretTransmute(caster,x,y,direction,skill)
	
   	if findEntity("secretsocket") ~= nil then
		findEntity("secretsocket"):destroy()
   	end
        local b = getMouseItem()
	if b and isInTable(transmuteList, b.name) then
   		if b.name == "chitin_mask" or b.name == "chitin_mail" or b.name == "chitin_boots" or b.name ==       
                "chitin_greaves" then 
		 	local c = caster:getSkillLevel("earth_magic")
         	        if c >= 5 then
				setMouseItem(nil)
    			        spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "secretsocket")
				findEntity("secretsocket"):addItem(spawn( "longbow" ,nil, nil, nil, nil))
				hudPrint( caster:getName() .. " transmuted the Chitin Armour to create a Long Bow." )
    			playSound("anime_sword")
    			party:playScreenEffect("damage_screen_white")
			else
				hudPrint("You need to be more skilled in earth magic to transmute pieces of Chitin armour...")
			end
		elseif b.name == "magic_orb" then 
			local c = caster:getSkillLevel("earth_magic")
        	        if c >= 5 then
				setMouseItem(nil)
        		        spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "secretsocket")
				findEntity("secretsocket"):addItem(spawn( "zhandul_orb" ,nil, nil, nil, nil))
	    		        hudPrint( caster:getName() .. " transmuted the Orb of Radiance to create Zhandul's Orb." )
   				playSound("anime_sword")
   				party:playScreenEffect("damage_screen_white")
			else
				hudPrint("You need to be more skilled in earth magic to transmute the Orb of Radiance...")
			end
		elseif b.name == "ring_mail" then 
			local c = caster:getSkillLevel("earth_magic")
        	        if c >= 5 then
				setMouseItem(nil)
        		        spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "secretsocket")
				findEntity("secretsocket"):addItem(spawn( "plate_cuirass" ,nil, nil, nil, nil))
	    		        hudPrint( caster:getName() .. " transmuted the Ring Mail to create Plate Cuirass" )
   				playSound("anime_sword")
   				party:playScreenEffect("damage_screen_white")
			else
				hudPrint("You need to be more skilled in earth magic to transmute the Ring Mail...")
			end
		elseif b.name == "throwing_axe" then 
			local c = caster:getSkillLevel("earth_magic")
        	        if c >= 5 then
				setMouseItem(nil)
        		        spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "secretsocket")
				findEntity("secretsocket"):addItem(spawn( "tar_bead" ,nil, nil, nil, nil))
	    		        hudPrint( caster:getName() .. " transmuted the Throwing Axe to create some Tar Bead." )
   				playSound("anime_sword")
   				party:playScreenEffect("damage_screen_white")
			else
				hudPrint("You need to be more skilled in earth magic to transmute theThrowing Axe...")
			end
		end
	end
	hudPrint("You must hold the item to Transmute with the mouse cursor...")
	return false
end
   
**I have used the floating sword socket + get/setMouse items approach as special items being spawned into the hands of champions - the caster - was going to be problematic as many items had effects for equip and unequip hooks - this way you can just grab it out of the air, also some items that you may want to transmute may have skill requirements attached to them, meaning you mage will not be able to hold them in slots 7, 8... checking mouse item handles this nicely....

EDIT - I forgot to mention, the last script detailed above can easily be used to recharge wands too. example -
SpoilerShow

Code: Select all

elseif b.name == "fire_blade" or b.name == "fire_blade_empty"  then 
			local c = caster:getSkillLevel("earth_magic")
        	        if c >= 5 then
				setMouseItem(nil)
        		        spawn("floating_sword_socket", party.level, party.x, party.y, party.facing, "secretsocket")
				findEntity("secretsocket"):addItem(spawn( "fire_blade" ,nil, nil, nil, nil))
	    		        hudPrint( caster:getName() .. " transmuted the Throwing Axe to create some Tar Bead." )
   				playSound("anime_sword")
   				party:playScreenEffect("damage_screen_white")
			else
				hudPrint("You need to be more skilled in earth magic to transmute theThrowing Axe...")
			end
Either a half used fire blade or an empty one, destroyed and replaced with a brand new (fully charged) one....

And that is it.. thanks again Marble Mouth and Acolade for the fine examples to work from :D

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

Re: New Spells >> show them off here

Post by akroma222 » Sun Apr 21, 2013 9:15 pm

Hi All,
I have a question regarding setting the attack power of a burst spell.
I have tried the following method but with no luck....
I am not sure how to find or get hold off the burst spell that is cast from the spell....
I do know that we can go - BurstSpell:setAttackPower(power)

1.onCastSpell hook calling a function in dungeon:
SpoilerShow

Code: Select all

cloneObject{
	name = "party",
	baseObject = "party",
	onCastSpell = function(champion, spell)
		return partySpellScripts.spellEnhancements(champion, spell)								
	end
}	
2.a script that checks the name of the spell (shock in this case) then locates the burstspell object and then sets attack power:
SpoilerShow

Code: Select all

function spellEnhancements(champion, spell)
	
	if spell == "shock" then
		if (champion:getItem(7) ~= nil and champion:getItem(7).name == "spark_staff") or (champion:getItem(8) ~=    
                nil and champion:getItem(8).name == "spark_staff") then
         	        --how do I ask the burst spell to set Attack Power????--
			hudPrint("zappy!")
		end
	end
end
	
Can anyone point me in the right direction here???
Thanks!!

User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: New Spells >> show them off here

Post by Neikun » Mon May 06, 2013 1:32 pm

Hey, Akromma sorry for the delay on this.

Code: Select all

defineObject{
	name = "frostburst",
	class = "BurstSpell",
	particleSystem = "frostburst",
	lightColor = vec(0.25, 0.5, 1),
	lightBrightness = 40,
	lightRange = 4,
	sound = "frostburst",
	attackPower = 20,
	damageType = "cold",
	--cameraShake = true,
	tags = { "spell" },
}
Does the line for attack power do nothing?
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!

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

Re: New Spells >> show them off here

Post by akroma222 » Tue May 21, 2013 7:03 am

Hey Neikun!
Sorry about the delay in getting back to you... stuff is hectic ;)

Yes you are right. We can change the attack power of existing spells by changing the attack power in the ^definition.
However, I was hoping to learn how to do this via the onCast hook for a party clone, calling a function in the dungeon.

This is what I have so far -
A party clone in init.lua:
SpoilerShow

Code: Select all


cloneObject{
	name = "party",
	baseObject = "party",
	onCastSpell = function(champion, spell)
		return partySpellScripts.spellEnhancements(champion, spell)								
	end
}	
Then a script in the dungeon with the following function:
SpoilerShow

Code: Select all


spellCasters = 0

function spellEnhancements(champion, spell)
	
	local item
   	local slot
	if spell == "spellfire_burst" then
		for i = 7,8 do
      		item = champion:getItem(i)
      		if item and item.name == "shield_spellfire" then
         		return attackingWeaponScripts.shieldSpellfire(champion, item)
      		end
   		end
	end
	
	if spell == "shock" then
		if (champion:getItem(7) ~= nil and champion:getItem(7).name == "spark_staff") or (champion:getItem(8) ~=   
                nil and champion:getItem(8).name == "spark_staff") then
                return grimwold_AOEspell_script.stormSpell(champion:getOrdinal(),"shock","shockburst","shockburst",100,"") 	
		end
	end
	
	if spell == "lightning_bolt" then
		if (champion:getItem(7) ~= nil and champion:getItem(7).name == "spark_staff") or (champion:getItem(8) ~= 
                nil and champion:getItem(8).name == "spark_staff") then
   			local dx,dy = getForward(party.facing)
			spawn("lightning_bolt_greater",party.level,party.x+ dx,party.y+ dy,party.facing)
		end
	end
	return true
end

So I have been a little inventive using work arounds (my version of inventive hehe :oops: )

1.Spellfire burst (if caster is holding the spellfire shield) calls another function that does some cool things - and works (I can post up the rest of the code if anyone wants it)

2.Shock (if caster is holding Spark Staff) basically just calls on Grimwolds AOE fucntion and spawns another damage tile and effect on the space where the burst spell is >> which replicates Zhandul's Orb's intense fire game effect except for Shock and Lightning Bolt....,

3. Lightning Bolt (if caster is holding Spark Staff) will spawn a greater lightning bolt as well as the normal lightning bolt (although I have not yet added in the originator for EXP).

What would be delightfully easy would be if I could just use - Projectilespell:setAttackPower() or Burstspell:setAttackPower() to change attack powers if caster is holding a staff or something. Further, it would good to be able to change the particle effects in the same situation without the work-arounds stated above....

I do know Diarmuid's EXSP system can handle this easily but I am looking for a non-EXSP solution for the time being.
Anyways, I will update when I find out more stuff :D

Akroma

s.a.eish
Posts: 1
Joined: Fri Jan 10, 2014 11:38 am

Re: New Spells >> show them off here

Post by s.a.eish » Fri Jan 10, 2014 1:12 pm

I know this thread isn't active, but I spent too much time debugging the second one not to brag about it.
They are both made for the 4-mages party dungeon I am working on.

Redistribute
Feel a little helpless? Of course you are, you useless piece! At least give your mana to your friends!
SpoilerShow

Code: Select all

defineSpell{
	name = "redistribute",
	uiName = "Redistribute",
	skill = "spellcraft",
	level = 5,
	runes = "BEH",
	manaCost = 1,
	onCast = function(caster, x, y, direction, skill)
		local amount = caster:getStat("energy")
		local share = 3
		for i =1,4 do
			if not party:getChampion(i):getEnabled() or not party:getChampion

(i):isAlive()
			then
				share = share - 1
			end
		end
		for i=1,4 do
			if party:getChampion(i):getEnabled() and party:getChampion

(i):isAlive() then
				party:getChampion(i):modifyStat("energy", amount/share)
			end
		end
		caster:modifyStat("energy", -amount)
		playSound("consume_food")
		party:playScreenEffect("death_dust")
	end,
}
Mix Energy Potions
don't care for manual potion making? I don't blame you. It's slow.
SpoilerShow

Code: Select all

defineSpell{
	name = "mix_potions_energy",
	uiName = "Mix Energy Potions",
	skill = "spellcraft",
	level = 10,
	runes = "D",
	manaCost = 5,
	onCast = function(caster, x, y, direction, skill)
		local counter_flasks = 0
		local counter_blooddrops = 0
		local amount = 0
		local helper = 0
		local k = 1
		local q = 1
		local a = nill
		for i=1,4 do
			for j=1,31 do
				if party:getChampion(i):getItem(j) ~= nill then
					if party:getChampion(i):getItem(j).name == "flask"
					then
						counter_flasks = counter_flasks + 1
					elseif party:getChampion(i):getItem(j).name == 

"blooddrop_blossom"
					then
						counter_blooddrops = counter_blooddrops + 

party:getChampion(i):getItem(j):getStackSize()
					end
				end
			end
		end
		if counter_flasks >= counter_blooddrops
		then
			amount = counter_blooddrops
		else
			amount = counter_flasks
		end
		helper = amount
		while k<=4 and amount~=0 do
			q = 1
			while q<=31 and amount~=0 do
				if party:getChampion(k):getItem(q) ~= nill then
					if party:getChampion(k):getItem(q).name == "flask"
					then
						party:getChampion(k):removeItem(q)
						a = spawn("potion_energy")
						party:getChampion(k):insertItem(q, a)
						amount = amount - 1
					end
				end
				q = q +1
			end
			k = k+1
		end
		amount = helper
		k=1
		while k<=4 and amount~=0 do
			q = 1
			while q<=31 and amount~=0 do
				if party:getChampion(k):getItem(q) ~= nill then
					if party:getChampion(k):getItem(q).name == 

"blooddrop_blossom"
					then
						party:getChampion(k):getItem

(q):setStackSize(party:getChampion(k):getItem(q):getStackSize() - 1)
						amount = amount - 1
						if party:getChampion(k):getItem

(q):getStackSize() == 0
						then
							party:getChampion(k):removeItem(q)
							q = q-1
						end
					end
				end
				q = q +1
			end
			k = k+1
		end
	end,
}
it puts the energy potion where the flask used to be.
It handles it if the ingredients are at different inventories, and it handles stacks.
It doesn't handle ingredients that are inside of boxes.
I'm not sure if it does any problems if one of the champions is disabled, but it's a few simple if's here and there anyway.
Last edited by s.a.eish on Wed Jan 22, 2014 2:19 pm, edited 1 time in total.

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

Re: New Spells >> show them off here

Post by akroma222 » Tue Jan 14, 2014 11:37 pm

Very cool!!!

I always have my eye on this thread... lets make it active!
I will be posting a bucket load of spells here once Labyrinth of Lies is playable for the masses :D

Akroma

Post Reply