Door can be pried open

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!
Post Reply
OGDA
Posts: 115
Joined: Tue Oct 28, 2014 5:07 pm

Door can be pried open

Post by OGDA »

Hello,

thanks to Doridion's excellent clickable doors modification ( viewtopic.php?f=22&t=8227 ) I was able to create the well known door, that is half open and can be pried open once on a random click number and with the notification.

This is based on his modification and I recommend you read the above thread first.
The reason why I created a new one is that I don't like searching for such additions in the depths of other threads, I think it can be found easier this way. ;-)

This goes to the objects.lua, use you preferred door as baseObject.

Code: Select all

   defineObject{
       name = "pry_door",
            baseObject = "dungeon_door_wooden",
       components = {
          {
             class = "Door",
             sparse = true,
             killPillars = true,
          },
          {
             class = "Clickable",
             maxDistance = 1,
             -- offset vector is the point where begin the clickable box
             offset = vec(0,1.3,0),
             -- size is the size of our clickable box
             size = vec(2.5,2.5,0.3),
	
             onClick = function(self)
                if math.random(1, 6) == 1 then
					self.go.door:open()
				end
             end
          },
          {
             class = "Controller",
             onOpen = function(self, name)
                --self.go.door:open()
				
             end,
             onClose = function(self)
                -- self.go.door:close()
             end,
             onToggle = function(self)
                -- self.go.door:toggle()
             end,
          },
       },
       placement = "wall",
       editorIcon = 124,
    }
The line
if math.random(1, 6) == 1 then
defines a random number so that you don't know how often you have to click until the door is pried open.

There still need to be several objects.
Here is an example set up dungeon:
https://das-kartell.org/files/pry_door_open.zip

The following script is used in the test dungeon. It is tried and the door saves its state also after reloading.

Code: Select all

function doortestinitializedoor()
	local door_start_position = my_clickable_door_1:getWorldPosition()
	local door_x = door_start_position[1]
	local door_y = door_start_position[2]+0.5
	local door_f = door_start_position[3]
	my_clickable_door_1:setWorldPosition(door_x, door_y, door_f, 0)
	my_clickable_door_1.door:addConnector("onOpen", "script_entity_1", "doortestdisable")
end

doortestinitializedoor()

function doortestdisable()
	my_clickable_door_1.clickable:disable()
	hudPrint("You pry the door open.")
end

Kind regards,
Joerg
Last edited by OGDA on Sat Nov 08, 2014 9:15 pm, edited 1 time in total.
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Door can be pried open

Post by Doridion »

haha, intersting to play ^^

"Pretty door, open up that i can follow my... "
"NO ..."
"What's no ?!"
"NO ..."
"Open yourself !"
"NO ..."
"Won't you open ? Ok, i'll pass through another way ..."
"YES ..."
"Rah ... F#*@ !"
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Door can be pried open

Post by Mysterious »

Wow this is awesome man thxs ill be using this. Thxs again good work :)

EDIT: What would make this even better if the player had to use a Spear to pry the door open :)
OGDA
Posts: 115
Joined: Tue Oct 28, 2014 5:07 pm

Re: Door can be pried open

Post by OGDA »

This would be cool: new item crowbar and the door only opens when you have the crowbar on the mouse (as the pointer).
Unfortunately I have no idea how to do this. ^^
Post Reply