Help with hatch script

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
neillomax
Lieutenant General
Posts: 880
Joined: Thu Jun 23, 2005 6:57 am

Help with hatch script

Post by neillomax »

How do you make this close like a regular door would ? /////////////////////
How do you give it sound ? ///////////////////////////////////////////////////

//---------------------------------------->

hatch1_open:

level.hatch1pos = 0
$hatch1 time 1.75 // set for 13/4 seconds travel time
goto hatch1_move

//---------------------------------------->

hatch1_move:

$hatch1_trigger waittill trigger
if(level.hatch1pos == 0)
{
$hatch1 rotateXup 90 // or Y or Z if your hatch opens that way.
$hatch1 playsound metal_bunker_hatch_open
$hatch1 waitmove
level.hatch1pos = 1
goto hatch1_move
}
else
if(level.hatch1pos == 1)
{
$hatch1 rotateXdown 90 // or Y or Z if your hatch opens that way.
$hatch1 playsound metal_bunker_hatch_open
$hatch1 waitmove
level.hatch1pos = 0
goto hatch1_move
}

//---------------------------------------->
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

tltrude's door2 tutorial map has a scripted door that opens like a hatch.
Diego
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Post by tltrude »

This should work.

//---------------------------------------->

hatch1_open:

$hatch1 time 1.75 // this line can be under prespawn

$hatch1_trigger waittill trigger
$hatch1 rotateXup 90 // or Y or Z if your hatch opens that way.
$hatch1 playsound door_wood_open_move
$hatch1 waitmove
$hatch1 playsound door_wood_open_stop

wait 4

$hatch1 rotateXdown 90 // or Y or Z if your hatch opens that way.
$hatch1 playsound door_wood_close_move
$hatch1 waitmove
$hatch1 playsound door_wood_close_stop
goto hatch1_open

end

//---------------------------------------->
Tom Trude,

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Here is a hatch script I made for "Vemork Ferry" ( A map I forgot to release now that I think of it :roll: )

Code: Select all

setup_hatch:
	// Hatch to lower deck
	level.hatch_open = 0
	level.hatch_moving = 0
	$hatch_trigger_opened hide
	$hatch_trigger_closed show
end

use_hatch local.close_only:
	if(local.close_only !=1 || ( local.close_only ==1 && level.hatch_open) ) {
		if(level.hatch_moving == 0) {
			level.hatch_moving = 1
			local.hatch_time = 1

			$hatch time local.hatch_time

			if (level.hatch_open) {
				$hatch rotateZup 90
				$hatch_trigger_opened hide
				$hatch_trigger_closed show
				$hatch playsound hatch_close
			} else {
				$hatch openportal
				$hatch rotateZup -90
				$hatch_trigger_opened show
				$hatch_trigger_closed hide
				$hatch playsound hatch_open
			}
			level.hatch_open = !level.hatch_open

			$hatch waitmove
			level.hatch_moving = 0
			if(!level.hatch_open) {
				$hatch closeportal
			}
			if(level.hatch_open) {
				thread hatch_auto_shut
			}
		}
	}
end

hatch_auto_shut:
	level.time_left_to_auto_shut = 3
	if( level.auto_shut_active != 1 ) {
		level.auto_shut_active = 1
		while ( level.time_left_to_auto_shut > 0 ) {
			level.time_left_to_auto_shut --
			wait 1
		}
		thread use_hatch 1
	}
	level.auto_shut_active = 0
end
Call "setup_hatch" from main.
Call "use_hatch" from a trigger around the hatch.

It got this complicated because I wanted the hatch to auto close because the hatch covers an areaportal. The areaportal is controlled by the "closeportal" and "closeportal" commands.

Hmmm... perhaps this code is so hairy that it should be bundled with a prefab of the hatch...
Admin .MAP Forums
Image
Head above heels.
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Bjarne BZR wrote:Here is a hatch script I made for "Vemork Ferry" ( A map I forgot to release now that I think of it :roll: )
Well, now that you've remembered, are you going to release it? I remember looking at screenies of it a LONG time ago.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Yes I will, remind me in a few weeks and lets stop hogging neillomax thread :)
Admin .MAP Forums
Image
Head above heels.
Post Reply