Doors with Doom 3 logic

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Doors with Doom 3 logic

Postby DOOMGABR [RU] » Thu Nov 01, 2018 1:00 pm

Hey! How to realize smart door opening/closing like in Doom 3? When player in range of door it must open and check player's presence in door's range. Door must close only after player is out of range and open again if player in door's range while it closing. I was trying using simple open/close lines, but thing is player can out of door's range while door is opening/closing.
old example:
https://imgur.com/a/bhWERd8
p.s.: sorry for terrible English
DOOMGABR [RU]
 
Joined: 08 Jun 2016
Location: Russia

Re: Doors with Doom 3 logic

Postby Enjay » Thu Nov 01, 2018 2:55 pm

I wonder if some sort of "motion sensor" actor could be possible? i.e. an invisible actor placed near the door that looks for the player; if the player is within a certain distance of the actor, it opens the door (via ACS or ZScript (if that can be done)), if the player moves out of that distance, the door can close.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Doors with Doom 3 logic

Postby DOOMGABR [RU] » Thu Nov 01, 2018 3:32 pm

Yes, good thinking. How to realize this actor?
DOOMGABR [RU]
 
Joined: 08 Jun 2016
Location: Russia

Re: Doors with Doom 3 logic

Postby TheSeventh » Wed Nov 14, 2018 6:49 pm

I just threw this together with an edit to the CheckProximity example from the wiki. I'm sure you could use A_LookEx and state jumps which trigger ACS_NamedExecute but I figured since you would have to resort to ACS anyway to alter the map I thought it was better to start there instead.

Tag 1 is the door sector and Tag 2 is the MapSpot which I placed in the doorframe but you could easily place it anywhere else and it should function appropriately.
Code: Select allExpand view
#include "zcommon.acs"

Script "AutomaticDoor" Enter
{
   if (CheckProximity(2,"DoomPlayer",256.0, 1) )//The 2 here is the mapspot
      {
      Door_Open(1, 60);//Open the door
      }
   else
       {
       Door_Close(1, 60);//And close it when the player isn't there.
       }
   delay(35);
   restart;
}


I'm not sure if it's good practice to reference "DoomPlayer" here or if it would be better to look for "PlayerPawn" or something like that but for vanilla doom this works and you could probably use a modded playerpawn name instead if you were using one.

The .zip is an example map I threw together to demonstrate the script.
Attachments
Example.zip
(1.51 KiB) Downloaded 1 time
TheSeventh
 
Joined: 24 Oct 2018
Location: +NOGRAVY


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest