Requesting some specific helpful tips

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Aleitheo
Posts: 14
Joined: Tue Mar 19, 2013 7:59 pm

Requesting some specific helpful tips

Post by Aleitheo »

http://steamcommunity.com/sharedfiles/f ... =136781954

The dungeon is ready for testing, it does have a good few mod assets including two different tilesets. The first one being the Northern Dungeon and the other being the mine tileset from The Mine of Malan Vael (the floor using this one hasn't even been built yet).

----------

So I am currently making my first dungeon, I'm getting the hang of the editor and have already bookmarked a few helpful threads, the official modding tutorials, Komag and SpiderFighter's videos so far.

I was wondering if anyone can give me help on accomplishing the following.

- Solved - I have a set of enemies in a room, how do I trigger a hidden door to open when they are all dealt with?

- I've set up a timed trapdoor so X seconds after it is triggered it switches back again. How do I get the timer to click at each interval so the player knows the closed trapdoor is not indefinite?

- Solved - I've currently got a puzzle that requires you to put one of two certain items on an alcove in order to open up two or more secret doors. What changes would I need to make to the script found here; http://www.grimrock.net/modding/how-to- ... ve-puzzle/

Also Is there a specific thread with various little things like this that I can read? I'd love to learn how to design all sorts of puzzles in my dungeon.
Last edited by Aleitheo on Fri Apr 05, 2013 12:15 am, edited 5 times in total.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Requestion some specific helpful tips

Post by Ryeath_Greystalk »

Welcome.

For the first item the way I have done this in my mod is to create a new monster using the cloneObject() function, the add an onDie hook so when the monster dies it decrements a counter. The counter should be preset the same as the number of monsters so when the last one dies the counter goes to zero and opens the door.

For the second question I would probably go about it like this. Since a timer will keep repeating itself unless you deactivate it, you could set a timer for 1 second, then connect it to a counter preset to the number of seconds you want to stay open, let's say 5 seconds. You would also connect the timer to a script that plays a sound. So every second the timer would decrement the counter and call the script which would play a sound.
after the 5th cycle (when the counter hits zero) connect the counter to close the door and deactivate the timer. (Remember to always deactivate timers after use so they don't use up computer power)

For good references look to the modding superthread on the boards here and the scripting reference on the website here under the modding header.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Requestion some specific helpful tips

Post by Grimfan »

For checking to see whether a creature or object has been destroyed or is present in an area first have a script like this (there are a few variations to this script out there that are a lot cleaner or go about it differently and advanced scripters like Marble Mouth or Xanathar could also point out any errors I have made and perhaps offer better suggestions).

Code: Select all

function checkForThings(thing,xMin,xMax,yMin,yMax)
  for x = xMin,xMax do
    for y = yMin,yMax do
         for object in entitiesAt(party.level,x,y) do
            if object.name == thing then
               return false
            end
         end
      end
   end
   return true
end
You then create another script with the creature or object in question like this:

Code: Select all

function checkWarden()
   if checkForThings("warden",4,7,1,10) then
      dungeon_door_wooden_1:open()
   end
end
This function calls the first function (the checkForThings function) and when it doesn't find a warden (whether that's just one warden or a dozen) it opens the door.

Now you also have to link the second script to a timer that activates the checkWarden function every few seconds (otherwise it won't work).

Ryeath's second suggestion is good as well.

Have I missed something?
Marble Mouth
Posts: 52
Joined: Sun Feb 10, 2013 12:46 am
Location: Dorchester, MA, USA

Re: Requestion some specific helpful tips

Post by Marble Mouth »

Hi Aleitheo. I see some good advice in this thread, but I don't actually know if you're comfortable with scripting. So that's my first question: have you ever created a script_entity in your mod and gotten it to do something? Secondly, this is a slightly more advanced scripting concept, have you ever used cloneObject or defineObject in a .lua file? These scripting concepts can give you a lot more modding options, such as the advice already given above. Your level of comfort with scripting goes a long way towards determining what kind of solutions are viable to implement your designs.

Let's assume for the moment that you're not already comfortable with scripting. For your first scenario, I think that someone previously came up with a creative solution that does not involve scripting. Instead, it involves hidden, silent pressure plates in every tile of the room that are only triggered by monsters. Each pressure plate has two connectors:
1. event = activate , target = counter , action = increment
2. event = deactivate , target = counter , action = decrement
The counter starts at 0. It has two connectors:
1. event = activate , target = door , action = open
2. event = deactivate , target = door , action = close
This plan relies on the assumption that the monsters will not leave the room if they're still alive. The door will open as soon as there are no monsters in the room, because the counter will go down to 0 (activate.) This plan involves a lot of manual clicking and setup in the editor, and if you decide to change the size of your room, it will require a lot more setup at that point. There are also possible solutions that involve scripting. The scripting solutions are, in very many ways, simpler. The scripting solutions definitely makes it easier to expand, contract, or reshape the room. But it's your prerogative if the effort of learning scripting is worth it.

As far as I know, the only way to play sounds is through a script_entity .

There are a great many threads that contain useful info. I regularly find out new things (new to me anyway) by reading through old threads on this board. Some of the more useful threads are linked here.
Aleitheo
Posts: 14
Joined: Tue Mar 19, 2013 7:59 pm

Re: Requestion some specific helpful tips

Post by Aleitheo »

Thanks for the help so far guys.

My only experience with scripting in the past before has been with the GlovePie program to hook up a wiimote to the computer to use as a controller.

I have also used the scroll-on-alcove type script that is mentioned in the modding tutorials to put a note on a table I got from a mod. For that I pretty much copied the script example they used and changed the words I needed. Beyond that I have done nothing else with scripting.

@ Marble Mouth I tried your idea in a simple 3x3 room with 2 enemies and while it worked for some reason I heard a wall rising up repeatedly after defeating the first enemy with it stopping and the wall rising like it should be when the final enemy was dealt with. While this appears to work find for a single enemy I think something gets thrown off if there is more than one and one is killed.

@ Grimfan I think I may be missing something when I use your idea. I made a small room with two snails (I'd rather kill the enemy normally than use kill commends to make sure things run well) and I changed the instances of warden in the script to snail instead. I added two script entities, one with the first script and another with the second. For the second I connected a timer to it set to running with an interval of 1. However when I start up the preview after 1 second it stops it and I get the following error for the second line of the second script.

Code: Select all

attempt to call global 'checkforthings' a nil value
@ Ryeath I admit I'm not entirely sure as to what to do in order to replicate what you are suggesting. I've found this ( http://www.grimrock.net/modding/asset-d ... reference/) link which explains cloneobjects a bit more in detail but I'm still not sure where to go from there.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Requestion some specific helpful tips

Post by Ryeath_Greystalk »

Aleitheo wrote:
@ Ryeath I admit I'm not entirely sure as to what to do in order to replicate what you are suggesting. I've found this ( http://www.grimrock.net/modding/asset-d ... reference/) link which explains cloneobjects a bit more in detail but I'm still not sure where to go from there.
I can get some better details later tonight, but I'm at work right now.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Requestion some specific helpful tips

Post by Grimfan »

Sorry, I realized that I told you to have two separate scripts. That was a mistype. For the functions to work they both need to be in the same script entity (though the timer only needs to be linked to the checkSnails function).
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Requestion some specific helpful tips

Post by Ryeath_Greystalk »

Aleitheo,

In the dungeon I am working on I have a room that may be similar to what you are trying to accomplish. There are probably a few ways to do it but I will explain how I managed to accomplish it.

In my room i have a door which I named OfficeDoor1 and a secret door named OfficeDoor2. The layout is simple, when the party walks in a hidden pressure plate closes the door behind them. Once the party accomplishes a particular task in the room I then have 4 snails spawn in, one in each corner. The snails are custom assets using the cloneObject() function.

To clone the snails you would go into your dungeons Mod_Assets/scripts/monsters folder and add the following text.

Code: Select all

cloneObject{
	name = "officesnail",
	baseObject = "snail",
	onDie = function(self)
		OfficeCounter:decrement()
		end,
}
This will create a copy of the snail and name it officesnail. You could name yours something else, such as doorsnail, or funny_looking_snail etc. It will keep all the same attributes as the regular snail, but with the addition of the onDie hook. The onDie hook will cal a function when the snail dies. In this case I have a counter, named OfficeCounter, that will decrement by 1 when the snail dies.

If you take this code and put it in your Mod_Assets/Scripts/Monsters file and save it, then reload your dungeon in the editor, you should now find an officesnail in your entities list (or whatever you named yours.) If you wanted to use a herder just change the baseObject to herder etc.. Just be sure you put a counter in the dungeon with the same name as what you use i the monsters onDie function or the game will crash.

getting back to my room, once the 4 snails spawn, each time one is killed the counter goes down by 1 untill the last one dies and the counter hits 0.

When the counter hits 0, 3 things happen ( I have the counter connected to 3 items), 1 the door named OfficeDoor2 opens up, 2 a spawner behind that door spawns a mini boss herder, 3 a script prints some gibberish on the screen to make it look like the herder is saying something in mushroom language.

the miniboss herder is again a cloned monster. I use this text

Code: Select all


cloneObject{
	name = "officeherder",
	baseObject = "herder",
	health = 250,
	onDie = function(self)
		OfficeDoor1:open()
		end,

}
Here I copied a herder but just gave it more life to make a little bit longer fight. Notice I also used an onDie hook so that when the miniboss dies the OfficeDoor1 that the party came in through opens up and they can go about thier dungeon exploring. Agai yo can copy that to the monsters file, save it and reload the dungeon and the officeherder should show up in the entities list.

There you have examples of how using the onDie hook with a cloned monster can create siffect results in the game.

A valuable tool is to download the assets pack that lists what the default assets used in the game are. That can be found here http://www.grimrock.net/modding/asset-pack/ (big thank you goes out to komag and Neikun for showing me the way there) For example I wanted to make a swarm of spiders, but make them weaker than normal, so I just looked up spider in the assets pack, saw what the regular specs are and changed mine to this

Code: Select all


cloneObject{
	name = "weakspider",
	baseObject = "spider",
	health = 50,
	attackPower = 12,
	accuracy = 3,
	exp = 25,
}
If you compare to the standard spider I lowered the health, attackPower, accuracy and of course the exp. These are for more to establish a panic in the player when this swarm comes at them at a time when a normal spider is a tough fight.

One thing to mention with the way I use the onDie hook to decrement the counter. For some wierd reason if you use kill the monster using the 'K' key, the counter will decrement but it won't trigger the effect. You have to physically kill the snail just like in the real game. You can read about it here viewtopic.php?f=14&t=5090

Also I mention a 3rd item when the snails all die. I link the counter to a script, and on the script I have this

Code: Select all


function angryMushroom()

hudPrint("\"Harg arlu nago inagoa ish!")
hudPrint("Nago lugah raga ISHGANU!!!\"")
end
This just prints some gibberish on the screen.

Hope some of this helps. I came here nowing next to nothing about this stuff and I have learned a lot just reading these forums. There is a ton of good info here.

Good luck
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Requestion some specific helpful tips

Post by Ryeath_Greystalk »

Wow, I just reread my reply and I apologize for all the typo's. Guess I shouldn't have been watching baseball while typing. :o
Aleitheo
Posts: 14
Joined: Tue Mar 19, 2013 7:59 pm

Re: Requestion some specific helpful tips

Post by Aleitheo »

Thanks a lot Ryeath, I tried it out in a test dungeon and it works nicely.

Since the dungeon I am building is going to have a lot of moving walls triggered by various events, is there a limit I should know of for the amount of custom monsters I can put in?

EDIT: Okay, for some reason when I tried doing the same thing in my main dungeon the new monster wasn't showing up. I thought it was because I was using words that were too long or something for the monster name but even when I copied the snail script which I knew worked and opened up the dungeon after saving, it didn't show up.
Post Reply