Killing spawned monsters

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Lemonz
Posts: 3
Joined: Sun Oct 07, 2012 2:37 am

Killing spawned monsters

Post by Lemonz »

I'm having a bit of trouble with killing (not destroying) a spawned monster. In my case a cube. I have it so the player steps on a hidden pressure plate spawning a cube around the corner. In the same block that contains the hidden pressure plate I have one more that's connected to a script_entity. I want the cube to be killed once it touches the second hidden pressure plate. I've tried Monster:setHealth(0), however, I can't seem to find the cube's ID.

This was posted before, but it assigns a random ID on every run. I tried running the second script Grimwold posted that I've edited to suit my needs, but that just crashed the editor.

Code: Select all

function killCube()
  for i in entitiesAt(1,6,14) do
    if i.name == "cube"
    then
      i:destroy()
    end
  end
end
If I use i:setHealth(0) instead of i:destroy() it doesn't do anything.

This is the error it gives when it crashes.
SpoilerShow
[string "Cube.lua"]:0: attempt to index field 'map' (a nil value)
stack traceback:
[string "Cube.lua"]: in function 'crushEntities'
[string "Cube.lua"]: in function 'update'
[string "Monster.lua"]: in function 'update'
[string "Map.lua"]: in function 'updateEntities'
[string "Dungeon.lua"]: in function 'updateLevels'
[string "GameMode.lua"]: in function 'update'
[string "DungeonEditor.lua"]: in main chunk
[C]: in function 'xpcall'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk
stack traceback:
[C]: in function 'error'
[string "DungeonEditor.lua"]: in function 'handleError'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
Any and all help would be greatly appreciated. Thanks in advance :D
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Killing spawned monsters

Post by Komag »

have you tested with other monsters? I've read that the cube is very different and causes problems a lot with trying to do stuff like this
Finished Dungeons - complete mods to play
User avatar
Lemonz
Posts: 3
Joined: Sun Oct 07, 2012 2:37 am

Re: Killing spawned monsters

Post by Lemonz »

I guess it's just the cube. I tried it on a snail and it removed it just fine. Interestingly enough I set it's HP to 0 as well and I was unable to hit it, but it was still able to move and attack me. It's the same for negative numbers. I'd still like to figure out how to kill a cube (or any enemy) once they step on a certain area much like when you press K on an enemy in debug mode.
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Killing spawned monsters

Post by Montis »

setting the health to zero is a bit strange since that causes the monster to be dead and alive at the same time = invulnerable. same with the party btw.
you could try to set up a killsquare. I don't know if that would work on the cube though, so many things hardcoded with that...
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Lemonz
Posts: 3
Joined: Sun Oct 07, 2012 2:37 am

Re: Killing spawned monsters

Post by Lemonz »

It doesn't work on a cube.

Code: Select all

function killCube()
  for i in entitiesAt(1,6,14) do
    if i.name == "cube"
    then
      damageTile(1,6,14,1,128,"physical",9001)
    end
  end
end
Perhaps these things are impossible to kill, though you can kill them when you press K on them. I'd like to know what command that does. I've searched quite a bit, but maybe not enough.
User avatar
Drachir
Posts: 17
Joined: Wed Aug 22, 2012 4:32 pm
Location: Southlands of UK

Re: Killing spawned monsters

Post by Drachir »

Just wondering if you got a response from the devs on the error

[string "Cube.lua"]:0: attempt to index field 'map' (a nil value)
stack traceback:

I had the same thing with a teleporter... a pure guess says the problem is the game losing track of where something actually is when you attempt to destroy it.
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: Killing spawned monsters

Post by SpiderFighter »

Drachir wrote:Just wondering if you got a response from the devs on the error

[string "Cube.lua"]:0: attempt to index field 'map' (a nil value)
stack traceback:

I had the same thing with a teleporter... a pure guess says the problem is the game losing track of where something actually is when you attempt to destroy it.
I also had a teleported Big Herder become invincible as I was hitting it, so that explanation makes sense.

(edited for clarity)
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Killing spawned monsters

Post by msyblade »

is it possible that cube doesnt trigger plate, like a crowern?
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Billick
Posts: 201
Joined: Thu Apr 19, 2012 9:28 pm

Re: Killing spawned monsters

Post by Billick »

The cube is weird, and you can't do a lot of things with it that you can do with other monsters. I'm trying to figure out how to "kill" a cube in the game. The only thing I can think of is to destroy it and then spawn an fx object on top of it at the same time to simulate a death animation, and assign xp to the party through a script call. I haven't tried this yet though. A Monster:kill() command would be useful, but I don't think it exists as of yet.
msyblade wrote:is it possible that cube doesnt trigger plate, like a crowern?
I've gotten a cube to trigger plates. The issue seems to be that there's no way to do any damage to it.
Halls of Barrian - current version 1.0.3 - Steam Nexus
Me Grimrock no bozo!
User avatar
Edsploration
Posts: 104
Joined: Wed Sep 19, 2012 4:32 pm

Re: Killing spawned monsters

Post by Edsploration »

You could always just... spawn a pit under it, and then destroy that pit! "Sending it to hell", if you like. :lol: If you spawn another cube on top of it immediately before you could probably get one to leave a corpse behind. (Cubes crush other cubes, and that's the only way to do it I know of.) You'd probably have to time this with the cube's onMove hook in order to know exactly which space the cube was moving onto, and be able to time this sort of slight of hand.
Open Project -> Community FrankenDungeon: viewtopic.php?f=14&t=4276
Post Reply