Handling crazy amounts of secret doors (new problem)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors (solved)

Post by HaunterV »

Xanathar wrote:This was posted on the OneRoom challenge thread. Copying here as it's relevant to this discussion.

I don't know if I have understood the problem properly, so I resume what I understand of it first:
  • You want to do a maze-kind-of-thing where you have secret doors all around
  • Some kind of activator (plates, levers, etc) do change the secret doors to a number of configurations
If this is the case you probably can do as following.

1) Define a table of tables for configurations:
SpoilerShow

Code: Select all

DOORSPATTERNS =
{
	["config1"] = { "secret_door_1", "secret_door_5", "secret_door_7" },
	["config2"] = { "secret_door_11", "secret_door_25", "secret_door_37" },
	["config4"] = { "secret_door_2", "secret_door_5", "secret_door_7" },
}

ALLDOORS = { "secret_door_1", "secret_door_5", "secret_door_7", ....... etc etc etc }

2) Have an activate configuration method:

Code: Select all

function activatePattern(patternName)
	for _, doorName in ipairs(ALLDOORS) do
		local door = findEntity(doorName)
		door:close()
	end

	for _, doorName in ipairs(DOORSPATTERNS[patternName]) do
		local door = findEntity(doorName)
		door:open()
	end
end
3) find some way (whatever you want) to call activatePattern("config1") etc. etc.

Notes:
  • There is no need to stay all-lower-case inside a scripting entity. Use whatever makes the code clearer (I usually stay with the convention that read-only values are all-upper-case).
  • The code above is NOT TESTED.
  • Never put objects inside table, always put the id of the objects - otherwise GrimRock crashes when saving.
  • Always test the code in the game at regular intervals in time (say, once a day), including saving and reloading.

--

Edited for various fixes.
See I was trying to save my brain by just drawing all the patterns with doors and saying "screw that" to making note of the different configurations I wanted.. i ended up redrawing the whole room a couple times until I finally understood what was wrong. (Thanks to Edsploration for clearing it up over a convo).

Now that being said the way i wanted it and the way it is now, the over all feel has shifted from a Jackie Chan Adventures-esque fight scene to more of a minotaur in the maze claustrophobic feel. I originally intended for the room patterns to be more open with more room to move around while groups of 1-3 hit-to-kill baddies appear around you in puffs of dust and try to take you down while the big bad chases you down. Now it's more "oh crap oh crap dead end he's coming! Please change, please change for the better." I have since scrapped the 1 shot baddies as they will probably get you killed.

I will go back at a later date, possibly for my CFD submission with the original idea fully intact.

for now I'm ok with what I have produced, I just have to put in the on monster.die=open all doors script and it's finished. I'm just having a problem getting just a button to open and close all the doors as a bit of a debug check.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors (new problem)

Post by HaunterV »

ok i got the room functioning properly in every way but one.

i've made 5 SEs with this script;
SpoilerShow

Code: Select all

function activate()
  for i=1,100 do
    local door = findEntity("sd_rm_cfg_5_"..i) 
    if door then
      door:open()   
     end
  end
end
obviously i change the number for each configuration so all doors are accounted for... however, for some reason i cant get them to fire on monster death.

i've made this as a debug;
SpoilerShow

Code: Select all

cloneObject{
   name = "stone_ogre_2",
   baseObject = "stone_ogre",
   
   health = 1,
   onDie = function(self)
      local s=stoneogredeath
	  s:increment()
	end,  
}


it just doesnt cooperate.

a Pressure plate hooked up to the scripts works wonders, but i refuse to put down 100 plates.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
Post Reply