{script} corridor, players have to move backwards to proceed

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

{script} corridor, players have to move backwards to proceed

Post by Blichew »

Hey,
so one of my tricks is a not-so-long corridor that has to be walked-through backwards, otherwise - well, just copy and paste to check for yourselves.
Backwards might be a wrong word here, what I mean is that player has to turn around and start clicking "S" :P
First the layout:
Image

All hidden pressure plates, first and last runs the tpCleanUp() function
other plates run teleportBack() function.

Now, the code (feel free to modify/change/correct yada-yada :P ):

Note: This has been set to be passable going backwards from W to E.

Code: Select all

tp_index = 1
function teleportBack()
	if party.facing ~= 3 then
		x = party.x
		y = party.y
		l = party.level
		f = party.facing
		if findEntity("tp3_"..tp_index-1) then
			tpCleanUp()
		end
		hudPrint("Huh ?")
		spawn("teleporter",l,x,y,f,"tp3_"..tp_index)
		findEntity("tp3_"..tp_index):setInvisible(false)
		findEntity("tp3_"..tp_index):setHideLight(true)
		findEntity("tp3_"..tp_index):setSilent(true)
		findEntity("tp3_"..tp_index):setScreenFlash(false)
		findEntity("tp3_"..tp_index):setSilent(true)
		findEntity("tp3_"..tp_index):setTriggeredByParty(true)
		findEntity("tp3_"..tp_index):setTeleportTarget(x-1,y,f,l)
		tp_index = tp_index + 1
	else
		tpCleanUp()
	end
end

function tpCleanUp()
	if findEntity("tp3_"..tp_index-1) then
		findEntity("tp3_"..tp_index-1):destroy()
	end
end
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: {script} corridor, players have to move backwards to pro

Post by Eleven Warrior »

Hi I was wondering how to get it to work in the oppsite direction East to Westor other directions.. I have tried to modify (if party.facing ~= 3 then) to 0 1 2 but it goes all funny in the way the Party walks..

N
My hall way faces this way <--------- E
S

Thxs for any help....

Eleven Warrior...
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: {script} corridor, players have to move backwards to pro

Post by Komag »

Two sections of Master Quest have backwards requirements, one in Walkabout on level 6, and one by the Tomb on level 11. It's been a while so I can't remember exactly what I did, but the source code is available on Nexus :)
Finished Dungeons - complete mods to play
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: {script} corridor, players have to move backwards to pro

Post by Eleven Warrior »

Thank you Komag.. Ill check it out.. And get back to you
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: {script} corridor, players have to move backwards to pro

Post by Eleven Warrior »

UMMMM.... I checked it lvl 6 and 11 and I have to tell you I don't understand how it works (LOL) way over my head...

Man you really put a lot of effort in the Master Quest..I look at the coding and I may as well be reading Machine Code (001111100000111) LOL..

I noticed that you can Stop the Party from moving, but I have failed to do this.. I use a invisible blocker to do it thxs to Mysblade..
I guess ill just leave the Walking backwards thing out.. I could copy your Script and design layout, but it would not be the same. as I need the party to walk
<----- that way but backwards..

Thxs for your help, man scripting is hard BUT I LOVE IT LOL....

PS: How do I post a Image on this Forum?? I want to show some of my Dungeon....
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: {script} corridor, players have to move backwards to pro

Post by Komag »

Well a lot of the control comes from the party object within the objects.lua, using the onMove hook, and that's where you can return false if the facing isn't the right way and if they are standing on a certain pressure plate, thus they can't move.
Finished Dungeons - complete mods to play
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: {script} corridor, players have to move backwards to pro

Post by Eleven Warrior »

Hi Komag.. I assume you mean I make Object (pressure plate) with the onMove hook, I was wondering how I would create such an Object..EG: The coding for it.. Don't mean to waste your time but (LOL) imam desperate.. Thxs again

PS: I still a newbie in this Stuff..
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: {script} corridor, players have to move backwards to pro

Post by Komag »

no, it's the party "object", not a pressure plate object. You can see the details here: http://www.grimrock.net/modding/asset-d ... reference/ under Party. The pressure plates would simply exist, with specific ids of course. Have your script (triggered by the onMove hook) check what plate is down, what direction the party is facing, what direction the party is trying to move, and if all is well, return true, else return false. You could have the plates set a flag and have the onMove hook always check for that flag (quicker code that way) and only run the rest of the script if the flag is set. It is a bit complex, but worth learning I think.
Finished Dungeons - complete mods to play
Post Reply