Page 1 of 1

Doors with Doom 3 logic

PostPosted: Thu Nov 01, 2018 1:00 pm
by DOOMGABR [RU]
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

Re: Doors with Doom 3 logic

PostPosted: Thu Nov 01, 2018 2:55 pm
by Enjay
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.

Re: Doors with Doom 3 logic

PostPosted: Thu Nov 01, 2018 3:32 pm
by DOOMGABR [RU]
Yes, good thinking. How to realize this actor?

Re: Doors with Doom 3 logic

PostPosted: Wed Nov 14, 2018 6:49 pm
by TheSeventh
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.