Spawning Props, Destroying Props

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Spawning Props, Destroying Props

Post by monkey »

Hello,

I post here besides my searches for hints. So sorry if I missed the answer somewhere. Also I'm rather bad at programming.
But here we are :

I want to press a hidden button and make spawn an alcove with a brass key inside :

Code: Select all

function ThugsAlcove()
	spawn("dungeon_alcove", 3, 5, 19, 2):addItem(spawn("brass_key"))
end
But the result is that the wallset hides the alcove but its edges. Can someone tells me how to reset the wall so the game show the alcove correctly please ?
I've been looking for this solution for the same problem at level one : I want a gladiator spear statue to stand in front of the door. But the wallset isn't solid so you can go through it. But I place here a secret door then the secret will hide most parts of the statue. As well if I try to destroy the statue and spawn it elsewhere then the statue can be partly hidden by the wall set already generated by the game.

Later to access a chest (that is meant to be opened with the brass key) I want the party to step in on a pressure plate, it actually toggle a secret door but stepping out closes it. What stepping on the pressure does aswell is spawn a secret button on a wall, let's say the south one, upon switching it, it despawns and spawns another button on the opposite wall, upon switching it it despawns to spawn a third one on the secret door, upon switching it, it opens the door and deactivate the pressure plate. So I wrote this :

Code: Select all

if pressure_plate_hidden_2:isDown() then SpawnSB1()
end

function SpawnSB1()
	spawn("dungeon_secret_button_small", 3, 3, 16, 2, "THSBVault_1")
	THSBVault_1:addConnector("toggle", "THSecretVault", "SpawnSB2()")
	THSBVault_1:setActivateOnce(true)
end

function SpawnSB2()
	spawn("dungeon_secret_button_small", 3, 3, 16, 0, "THSBVault_2")
	THSBVault_2:addConnector("toggle", "THSecretVault", "SpawnSB3()")
	THSBVault_2:setActivateOnce(true)
	spawn("dungeon_secret_door", 3, 3, 16, 2)
	THSBVault_1:destroy()
end

function SpawnSB3()
	spawn("dungeon_secret_button_small", 3, 3, 16, 3, "THSBVault_3")
	THSBVault_3:addConnector("toggle", "dungeon_secret_door_3", "open")
	THSBVault_2:setActivateOnce(true)
	spawn("dungeon_secret_door", 3, 3, 16, 0)
	THSBVault_2:destroy()
end
I used 2 pressure plate at the same location : one to activate/deactivate the door and one linked to the script.
What it actually does is that it spawns the first secret button but it is hidden by the wallset (that makes a super-hidden super-secret button !) but doesn't trigger the spawning of the others.

Alos to the developpers : would it be possible to have a third AI state like "friendly" to make npcs ?

edit : edited the code of the script (named THSecretVault)

Thank you )
Last edited by monkey on Mon Jan 07, 2013 3:23 am, edited 1 time in total.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Spawning Props, Destroying Props

Post by msyblade »

The second one is beyond my power, but for the first. Open the wall behind your alcove spawn point. and place a secret door blocking it.
Then in your script add this line:

function ThugsAlcove()
spawn("dungeon_alcove", 3, 5, 19, 2):addItem(spawn("brass_key"))
dungeon_secret_door_17: destroy() --this is the line to add, and change it's name to your door
end

You may place a blocker of some sort in the now empty square behind your alcove or the player can walk thru it.

Hope it works for you!
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
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Re: Spawning Props, Destroying Props

Post by monkey »

Thank you !

I'v thought about this one but in a way it wasn't very clean design so was looking for a clean way to do that kind of stuff.

For the second one I'm looking at chaining several buttons that are connected to each others. My guess is I'm confused by the name, the ID, and the kind of item and where each fits somewhere.
User avatar
Roman42
Posts: 42
Joined: Tue Dec 11, 2012 11:38 am

Re: Spawning Props, Destroying Props

Post by Roman42 »

monkey wrote:Thank you !
I'v thought about this one but in a way it wasn't very clean design so was looking for a clean way to do that kind of stuff.
I'm doing it almost that way in my random dungeon generator. It would work perfectly, if the alcove would count as a wall in the automap, but it doesn't, so it's an open wall in the map, otherwise it's perfect and I've learned to live with it. :)

EDIT: Perhaps its possible to clone an alcove/wall object, I didn't try this so far.

EDIT2: As a blocker I've used the metal junk object (because it cant be destroyed) and simply removed it's model, so it won't stand out of the alcove.
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Re: Spawning Props, Destroying Props // Need help

Post by monkey »

I've tried the solution suggested and it works wonderfull.

But it adds on the map an additional square that is not accessible. If I take off the tile and just let or the secret door or the cave_in which is not really needed then the glitch stays just as if I hadn't changed a thing. So I'll let things as is for now and see if I can work around when I intend to create new objects : why not make a door with the wallset of the alcove and both properties ? don't know if it's possible but it's far away on my list :)

Right now I still have my other script problem which is I want by walking on a plate it creates a button on a wall, if pressed it creates another one on another wall, etc until the last one is pressed it opens door :

I've been through the repository and tried the button combination lock method with the counters, so I just modified the way buttons are spawned and made part of functions. But there must be certainly something wrong with my code and I can't figure out which one, if anyone can help it'd be much appreciated :)
So to ease things I suppressed the pressure plate and integrated it into the script but doesn't work either :

I have set up dungeone_pressure_plate_3 that opens a door upon activation and closes it upon deactivation
I have set up a pressure plate called THPHidden connected to the script below called THSecretVault
I have set p a counter called CounterV not connected to anything with a base value of 0
The last routine is for once the last button has been pressed and the door opened, dungeon_pressure_plate doesn't closes or open the door anymore

Code: Select all

function THSBCounter()
	if CounterV == 0 then
		spawn("dungeon_secret_button_small", 3, 3, 16, 2, "THSB_1")
		:setActivateOnce(true)
		:addConnector("toggle", "THSecretVault", "THSBCounter")
		:addConnector("toggle", "THSB_1", "destroy")
		CounterV:increment()
	elseif CounterV == 1 then
		spawn("dungeon_secret_button_small", 3, 3, 16, 0, "THSB_2")
		:setActivateOnce(true)
		:addConnector("toggle", "THSecretVault", "THSBCounter")
		:addConnector("toggle", "THSB_2", "destroy")
		CounterV:increment()
	elseif CounterV == 2 then
		spawn("dungeon_secret_button_small", 3, 3, 16, 3, THSB_3)
		:setActivateOnce(true)
		:addConnector("toggle", "dungeon_secret_door_3", "open")
		:addConnector("toggle", "THSB_3", "destroy")
		CounterV:increment()
	elseif CounterV == 3 then
		THPHidden:destroy()
		dungeon_pressure_plate_3:setActivateOnce(true)
	end
end
It's been some time I'm stuck on this one and I spend most of my time on looking for the coma I forget or quotes ... :(
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Spawning Props, Destroying Props

Post by crisman »

You must use getValue() function if you want to know the value of a counter!
So the script will be:

function THSBCounter()

if CounterV:getValue() == 0 then
spawn("dungeon_secret_button_small", 3, 3, 16, 2, "THSB_1")
etc...
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Re: Spawning Props, Destroying Props

Post by monkey »

Holy many thanks !!!

It actually works !!
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Spawning Props, Destroying Props

Post by crisman »

I'm glad it works now ;)
Surely you are good in scripting, now you just have to take some confidence with it :D
Anyway, for you alcove problem, apparently there's no way to spawn those kind of objects (alcoves, secret_buttons, etc...) without having them clipping the walls...
But you can try a little trick:
where you want to spawn the alcove/button, you add an empty space behind the wall, and add a secret door where the wall was. in the empty space add something that blocks the player (a statue, for example)
Then, you spawn the alcove/button on the secret door, and destroy it.
the problem with this method is the automap reveling the empty space.
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Re: Spawning Props, Destroying Props

Post by monkey »

Hello,

Just wanted to update an info that could be useful to some (sorry if it's old news) :

If you want to hide and unhide say an alcove or a secret button (like in Lands of Lore that which I'm working on) :

In object.lua create the new props you want with the right wallset :

Code: Select all

cloneObject{
name = "dungeon_hidden_alcove",
baseObject = "dungeon_alcove",
model = "assets/models/env/dungeon_wall_01.fbx"
}
Then in dungeone editor just call your script that will replace the hidden prop with the apparent one after switching a button for example :

Code: Select all

function unhide_alcove()
	spawn("dungeon_alcove", dungeon_lvl, x, y, facing):addItem(item)
	dungeon_hidden_alcove_1:destroy()
end
The game has a priority which is all the walls are set before any other object (correct me if I'm wrong), so if you already place a prop that has the same wallset than the walls themselves then the prop is hidden in a clean way. If you destroy your first prop, the game doesn't update the wallset leaving it blank so you can replace it without a glitch.
monkey
Posts: 7
Joined: Sun Jan 06, 2013 7:25 pm

Re: Spawning Props, Destroying Props

Post by monkey »

Now I'd like to solve another issue I have :

I want to create in object.lua a secret door that inherits of both funtionnalities of a door and a secret button at the same time :

I tried this :

Code: Select all

cloneObject{
name = "dungeon_secret_door_button",
baseObject = "dungeon_secret_door",
diffuseMap = "assets/textures/env/brickwall_secret_button_dif.tga",
specularMap = "assets/textures/env/brickwall_secret_button_spec.tga",
normalMap = "assets/textures/env/brickwall_secret_button_normal.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 20,
depthBias = 0,
}
But it tells me they can't find a certain node. I' missing something if someone can help me out ?
Thanks
Post Reply