Dungeon Editor Code for begginers.

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Dungeon Editor Code for begginers.

Post by Azel »

Since I read this question in another thread, I figured I would upload another Dungeon File.

This is a 2-room dungeon that shows two different ways to spawn a mimic. The first is the basic approach, which uses Script to call the setMimic method. The other uses a floor trigger to spawn a mimic with modified status (higher level and more hitpoints).

Code: Select all

-- This file has been generated by Dungeon Editor 2.2.4

--- level 1 ---

newMap{
	name = "Mimic Room",
	width = 32,
	height = 32,
	levelCoord = {0,0,0},
	ambientTrack = "dungeon",
	tiles = {
		"dungeon_floor",
		"dungeon_wall",
	}
}

loadLayer("tiles", {
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,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2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
})

spawn("starting_location",15,15,1,0,"starting_location")
spawn("torch_holder",15,14,0,0,"torch_holder_1")
torch_holder_1.controller:setHasTorch(true)
spawn("torch_holder",21,14,0,0,"torch_holder_2")
torch_holder_2.controller:setHasTorch(true)
spawn("chest",19,15,3,0,"chest_1")
spawn("chest",24,15,3,0,"chest_2")
spawn("invisible_teleporter",26,15,3,0,"inv_portal")
inv_portal.teleporter:setTeleportTarget(1,24,15,0)
inv_portal.teleporter:setSpin("west")
inv_portal.teleporter:setTriggeredByParty(false)
inv_portal.teleporter:setTriggeredByMonster(true)
inv_portal.teleporter:setTriggeredByItem(false)
inv_portal.teleporter:setTriggeredBySpell(false)
inv_portal.controller:setInitialState("deactivate")
spawn("mimic",26,15,3,0,"mimic_1")
mimic_1.monster:setLevel(2)
mimic_1.monster:setHealth(800)
spawn("script_entity",21,12,0,0,"script_entity_1")
script_entity_1.script:setSource("chest_1.chest:setMimic(true); -- this runs when the level loads\
\
function TriggerMimic()\
\
\9local mChest = findEntity(\"chest_2\");\
\9\
\9if mChest ~= nil then\
\9\9mChest:destroy();\
\9\9inv_portal.controller:activate();\
\9end\
\
end")
spawn("floor_trigger",23,15,1,0,"floor_trigger_1")
floor_trigger_1.floortrigger:setTriggeredByParty(true)
floor_trigger_1.floortrigger:setTriggeredByMonster(false)
floor_trigger_1.floortrigger:setTriggeredByItem(false)
floor_trigger_1.floortrigger:setTriggeredByDigging(false)
floor_trigger_1.floortrigger:setDisableSelf(false)
floor_trigger_1.floortrigger:addConnector("onActivate", "script_entity_1", "TriggerMimic")

User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Dungeon Editor Code for begginers.

Post by Eleven Warrior »

Azel as always awesome thxs mate. You may want to make your code as Editor Files though as new comers may not understand what your doing yeah.

Create a zipped Dungeon Editor File mate.. thxs :)

EDIT: That way the people can understand what you trying to tell them bro :) Rem easy Mod bro :)
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Dungeon Editor Code for begginers.

Post by Azel »

Here is the zipped up Dungeon Project for this "fun with Mimic's" example: http://www.mystrock.com/files/MimicFun.zip
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Dungeon Editor Code for begginers.

Post by Azel »

In another thread someone asked for help with creating a 4 Alcove puzzle. I decided to create a dungeon dedicated to Alcoves.

Here is the first iteration: http://mystrock.com/files/Alcoves.zip

This version has only 1 room with 4 Alcoves. The player can place items in any of them; and as long as one Alcove is empty (and the other 3 have at least 1 item), then the empty Alcove will spawn a key.

Feel free to post other Alcove requests and I can add them to this dungeon file. Cheers! :mrgreen:
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Dungeon Editor Code for begginers.

Post by Azel »

Decided to share this one as well, it deals with spawning Pits and Chasms in the game, based on a Player event/trigger:

http://mystrock.com/files/chasms.zip

There are 2 sample situations in that file.

1) The player sets off a fire bomb in a Dungeon, which causes a Pit to spawn right above the explosion.

2) The player sets off a fire bomb in a Mine, which causes a Chasm to spawn in the forest right above.

Both scenarios are slightly different in their approach, but should work perfectly and bug free. Everything was done using the Editor only (no modifying script files).
Post Reply