New Spells >> show them off here

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Currann
Posts: 7
Joined: Mon Oct 15, 2012 3:38 am

Re: New Spells >> show them off here

Post by Currann »

Filipsan wrote:

Code: Select all


defineSpell{
   name = "unstoppable_fireball",
   uiName = "Unstoppable Fireball",
   skill = "fire_magic",
   level = 1,
   runes = "E",
   manaCost = 30,
   onCast = function(caster,x,y,facing,skill)
   local dx,dy = getForward(party.facing)
   local x,y = party.x + dx, party.y + dy
   local xIncrease = 0
   local yIncrease

   if party.facing == 0 then
      while yIncrease > -20 do
         if y-yIncrease <= 0 then
            yIncrease = yIncrease - 1
         else
            spawn("fireburst", party.level, x, y-yIncrease, party.facing)
            yIncrease = yIncrease - 1
         end
      end
   else if party.facing == 1 then
      while xIncrease < 20 do
         if x+xIncrease >= 31 then
            xIncrease = xIncrease + 1
         else
            spawn("fireburst", party.level, x+xIncrease, y, party.facing)
            xIncrease = xIncrease + 1
         end
      end
   else if party.facing == 2 then
      while yIncrease < 20 do
         if y+yIncrease >= 31 then
            yIncrease = yIncrease + 1
         else
            spawn("fireburst", party.level, x, y+yIncrease, party.facing)
            yIncrease = yIncrease + 1
         end
      end
   else
      while xIncrease > -20 do
         if x-xIncrease <= 0 then
            xIncrease = xIncrease - 1
         else
            spawn("fireburst", party.level, x-xIncrease, y, party.facing)
            xIncrease = xIncrease - 1
         end
      end
   end
   end
}
indeed, last end is extra IMO :)
Good thought, i just tried it without the fourth end, but it still gave the same error :?:
forcommenting
Posts: 3
Joined: Sun Oct 21, 2012 4:26 pm

Re: New Spells >> show them off here

Post by forcommenting »

Grimw wrote: Push Monster
Great spell! There are a couple things that I've found that haven't worked out though. I wasn't able to cast it when testing it because my level was to low, I'm not sure why but maybe your spell runes are the same as another spell, I changed the runes to "AB" and now it casts. I wasn't able to push an ogre (it said there was no monster) and thought maybe I didn't copy something right but decided for the sake of being complete I spawned a snail and it pushed, the problem here happened when I pushed the snail right through a closed secret door. I haven't checked other types of doors but I would assume they'd do the same. Thought you might like to know, thanks for sharing! :D
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: New Spells >> show them off here

Post by crisman »

Currann wrote:
Filipsan wrote:

Code: Select all


defineSpell{
   name = "unstoppable_fireball",
   uiName = "Unstoppable Fireball",
   skill = "fire_magic",
   level = 1,
   runes = "E",
   manaCost = 30,
   onCast = function(caster,x,y,facing,skill)
   local dx,dy = getForward(party.facing)
   local x,y = party.x + dx, party.y + dy
   local xIncrease = 0
   local yIncrease

   if party.facing == 0 then
      while yIncrease > -20 do
         if y-yIncrease <= 0 then
            yIncrease = yIncrease - 1
         else
            spawn("fireburst", party.level, x, y-yIncrease, party.facing)
            yIncrease = yIncrease - 1
         end
      end
   else if party.facing == 1 then
      while xIncrease < 20 do
         if x+xIncrease >= 31 then
            xIncrease = xIncrease + 1
         else
            spawn("fireburst", party.level, x+xIncrease, y, party.facing)
            xIncrease = xIncrease + 1
         end
      end
   else if party.facing == 2 then
      while yIncrease < 20 do
         if y+yIncrease >= 31 then
            yIncrease = yIncrease + 1
         else
            spawn("fireburst", party.level, x, y+yIncrease, party.facing)
            yIncrease = yIncrease + 1
         end
      end
   else
      while xIncrease > -20 do
         if x-xIncrease <= 0 then
            xIncrease = xIncrease - 1
         else
            spawn("fireburst", party.level, x-xIncrease, y, party.facing)
            xIncrease = xIncrease - 1
         end
      end
   end
   end
}
indeed, last end is extra IMO :)
Good thought, i just tried it without the fourth end, but it still gave the same error :?:
the last end must have the comma I guess
end,
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: New Spells >> show them off here

Post by Decayer »

It's 'elseif', not 'else if'. It's rather annoying if you're used to certain other programming languages.
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 »

forcommenting wrote:
Grimw wrote: Push Monster
Great spell! There are a couple things that I've found that haven't worked out though. I wasn't able to cast it when testing it because my level was to low, I'm not sure why but maybe your spell runes are the same as another spell, I changed the runes to "AB" and now it casts. I wasn't able to push an ogre (it said there was no monster) and thought maybe I didn't copy something right but decided for the sake of being complete I spawned a snail and it pushed, the problem here happened when I pushed the snail right through a closed secret door. I haven't checked other types of doors but I would assume they'd do the same. Thought you might like to know, thanks for sharing! :D
Thanks for the comments... I hadn't checked, but it makes sense that you can push monsters through secret doors, as it uses a teleport and only checks that the space behind the monster is 'free'. I guess you could push them into doorways if the door is open, but it wouldn't push if there's a closed door behind the monster.

Not sure about your other issues... I'm pretty sure I picked a rune combination that had not been used in the base game, so unless you've added other spells, that shouldn't be an issue. I'll investigate the Ogre problem... but it should work as ogre is in the list of monsters that can be pushed. The only one I took out of the list was tentacles, for obvious reasons.

EDIT.. just tested with an ogre and pushed it fine. Maybe you just caught it at the moment it was moving or something.
forcommenting
Posts: 3
Joined: Sun Oct 21, 2012 4:26 pm

Re: New Spells >> show them off here

Post by forcommenting »

Grimwold wrote:
forcommenting wrote: I guess you could push them into doorways if the door is open, but it wouldn't push if there's a closed door behind the monster.

Not sure about your other issues... I'm pretty sure I picked a rune combination that had not been used in the base game, so unless you've added other spells, that shouldn't be an issue. I'll investigate the Ogre problem... but it should work as ogre is in the list of monsters that can be pushed. The only one I took out of the list was tentacles, for obvious reasons.

EDIT.. just tested with an ogre and pushed it fine. Maybe you just caught it at the moment it was moving or something.
Not sure whats up with it, I tried other monsters just in case I messed up the monster.lua file and it just pushed snails or something.
SpoilerShow

Code: Select all

cloneObject{
   name = "teleport_probe",
   baseObject = "snail",
}
They pushed, I went back and tried the ogres and still have nothing, I had also checked to make sure it allowed ogres in case I messed that up, still does. I'll work on it and let you know what I did wrong if I ever figure it out.

The door thing happens on any closed door, I wonder if there is a script the doors could have that would let it know it shouldn't happen, and if there was, hopefully that wouldn't interfere other teleports in the game.
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 »

forcommenting wrote:
Grimwold wrote:
forcommenting wrote: I guess you could push them into doorways if the door is open, but it wouldn't push if there's a closed door behind the monster.

Not sure about your other issues... I'm pretty sure I picked a rune combination that had not been used in the base game, so unless you've added other spells, that shouldn't be an issue. I'll investigate the Ogre problem... but it should work as ogre is in the list of monsters that can be pushed. The only one I took out of the list was tentacles, for obvious reasons.

EDIT.. just tested with an ogre and pushed it fine. Maybe you just caught it at the moment it was moving or something.
Not sure whats up with it, I tried other monsters just in case I messed up the monster.lua file and it just pushed snails or something.
SpoilerShow

Code: Select all

cloneObject{
   name = "teleport_probe",
   baseObject = "snail",
}
They pushed, I went back and tried the ogres and still have nothing, I had also checked to make sure it allowed ogres in case I messed that up, still does. I'll work on it and let you know what I did wrong if I ever figure it out.

The door thing happens on any closed door, I wonder if there is a script the doors could have that would let it know it shouldn't happen, and if there was, hopefully that wouldn't interfere other teleports in the game.
Hmm. really not sure what is going on in your case.. I have used my script copied from here in a couple of dungeons and had no trouble with it. If I get time I will have another look maybe with another brand new
dungeon.

The bit you quote from monsters.lua does not reflect whether it will push certain monsters... that is simply a 'probe' to see if it's possible to spawn a monster in the space behind the monster you are pushing. I needed a 'fake' monster to do this, and it is destroyed instantly, so you never see it!! The actual code that checks the list of monsters to push is in the script entity (a big long list of monsters called allMonsters).

I suggest you also try setting up the script in a brand new dungeon, just to check. Please post back here if you can/can't get the script working in a new dungeon.
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 »

I tested it again in a fresh dungeon and the spell worked absolutely fine. If you still can't get it to work in a new dungeon of your own let me know and I can provide the source of my new test dungeon for you to look at.
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 »

Here's another funky spell I was stoked about when I realized how to get it work
Hold Monster
An earth magic spell.. currently level 5 with a mana cost of 30 and two runes - Earth(G) + Physicality(F).

The idea behind the spell is that the monster directly in front of the party is paralyzed unable to move, turn or attack for the duration of the spell (2 seconds per skill level). Like the Push Monster spell it can be used to get away from a dangerous opponent, or simply give the party a respite from attack.

The spell uses a number of monster hooks (onMove; onTurn and onAttack), so if you already use any of these hooks for other things, you will need to tweak the monster definitions.

Here are the parts:
spells.lua

Code: Select all

-- Hold Monster Spell
defineSpell{
   name = "hold_monster",
   uiName = "Hold Monster",
   skill = "earth_magic",
   level = 5,
   runes = "FG",
   manaCost = 30,
   onCast = function(caster, x, y, direction, skill)
     return hold_monster_spell_script.startHold(caster,x,y,direction,skill)
end,
}
monsters.lua

Code: Select all

local monstersList = {"crab","crowern","cube","goromorg","green_slime","herder","herder_big","herder_small","herder_swarm","ice_lizard","ogre","scavenger","scavenger_swarm","shrakk_torr","skeleton_archer","skeleton_archer_patrol","skeleton_patrol","skeleton_warrior","snail","spider","tentacles","uggardian","warden","wyvern"
}

for i=1,# monstersList do
  cloneObject{
    name = monstersList[i],
    baseObject = monstersList[i],
    onMove = function(monster)
      return hold_monster_spell_script.checkHeld(monster)
    end,
    onTurn = function(monster)
      return hold_monster_spell_script.checkHeld(monster)
    end,
    onAttack = function(monster)
      return hold_monster_spell_script.checkHeld(monster)
    end,
  }
end
script entity called hold_monster_spell_script

Code: Select all

held_monster = ""

function checkHeld(monster)
  if monster.id == held_monster then
    if findEntity("holding_fx") ~= nil then
      holding_fx:destroy()
    end
    spawn("fx", monster.level, monster.x, monster.y, monster.facing,"holding_fx")
      :setParticleSystem("death_dust")
    return false
  else
    return true
  end
end

function destroyTimer()
  local h_timer = findEntity("hold_timer")
  if h_timer ~= nil then
    h_timer:destroy()
  end
end

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

function whichMonster(level,eggs,why)
  local allMonsters = {"crab", "crowern", "goromorg", "green_slime", "herder", "herder_big", "herder_small", "herder_swarm", "ice_lizard", "molt_slime", "ogre", "scavenger", "scavenger_swarm", "shrakk_torr", "skeleton_archer", "skeleton_archer_patrol", "skeleton_warrior", "snail", "spider", "uggardian", "warden", "wyvern"}
  for i in entitiesAt(level,eggs,why) do
    if isInTable(allMonsters,i.name) then
      return i.id
    end
  end
  return ""
end

function startHold(caster,x,y,direction,skill)
  destroyTimer()
  spawn("timer",party.level,party.x,party.y,party.facing,"hold_timer")
    :setTimerInterval(2*skill)
    :addConnector("activate","hold_monster_spell_script","stopHold")
    :activate()
  local dx,dy = getForward(party.facing)
  held_monster = whichMonster(party.level,party.x+dx,party.y+dy)
  spawn("fx", party.level, party.x+dx, party.y+dy, party.facing, "death_dust")
    :setParticleSystem("death_dust")
end


function stopHold()
  -- hudPrint("Stopping Hold")
  held_monster = ""
  destroyTimer()
end
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 »

Existing Rune Combinations
For reference, these are the runes used for the built-in spells.

Code: Select all

Shock             C
Shock Arrow       BCFH
Lightning Bolt    CD
Invisibility	   CEH
Shock Shield      CE

POison Cloud		G
Poision Bolt		CG
Poision Arrow	  BFGH
Poison Shield     EG

Fireburst         A
Fire Arrow	     ABFH
Fireball          ACF
Fire Shield	    AE

Ice Shards        GI
Frost Arrow       BFHI
Frost Bolt        CI
Frost Shield		EI

Light	          BE
Darkness          EH
Looks like I need to change a few rune combinations in my earlier spells.

For reference, here are the manual pages on Runes:
Image
Image
Last edited by Grimwold on Wed Oct 24, 2012 11:54 am, edited 1 time in total.
Post Reply