Doors with Doom 3 logic

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Doors with Doom 3 logic

Re: Doors with Doom 3 logic

by Cherno » Mon Jun 08, 2020 5:12 pm

It's certainly possible, I created a door like this for my Hired Guns TC. The door consists of the door itself, which is an actor, and a "blocker", which is the door's child and handles activation. So, when a player of monster collides with the blocker, the blocker will either reset the door's closing timer if it's open, or start the opening process (or reverse the closing process). There may be problems with hitscan attacks, I can't remember to be honest.

Here is the door blocker code.

Code: Select all

class HG_DoorBlocker : SwitchableDecoration
{
	HG_DoorBase door;
	bool doorWasBlocked;

	Default
	{
			radius 40;
			height 80;
	
			RenderStyle "None";
	
			+SOLID
			+NOGRAVITY
			
			
			Activation THINGSPEC_MonsterTrigger | THINGSPEC_Switch;
			+BUMPSPECIAL
			//+USESPECIAL
	}
	
	override bool cancollidewith (actor other, bool passive)
	{
		if(passive == true && other != null)
		{
			if(other.health > 0 && other.bSOLID == true && (PlayerPawn(other) != null || other.bISMONSTER == true))
			{
				if(door != null)
				{
					door.blocked = true;
					if(door.isOpen == false || door.closing == true)
					{
						door.Activate(other);
					}
				}
				
			}
		}
		
		return false;
	}
	
	int doorBlockTimer;
	
	override void Tick()
	{
		Super.Tick();
		if(door != null)
		{
			if(door.blocked == true)
			{
				if(doorBlockTimer < 4)
				{
					doorBlockTimer++;
					if(doorBlockTimer >= 4)
					{
						door.blocked = false;
						doorBlockTimer = 0;
					}
				}
				
			}
		}
	}
	
	/*
	override void Tick()
	{
		Super.Tick();
		if(master)
		{
			HG_DoorBase door = HG_DoorBase(master);
			if(door.isOpen == true)
			{
				//RadiusGive?
				if(CheckProximity("PlayerPawn", 45.0, 1, CPXF_ANCESTOR))
				{
					door.blocked = true;
					//A_Log("blocked");
				}
				else {
					door.blocked = false;
					//A_Log("not blocked");
				}
			}
		}
	}
	*/
	
	override void Activate(Actor activator)
	{
		if(activator != null)
		{
			if(abs(activator.pos.z - self.pos.z) > 80)
			{
				return;
			}
		}
		if(master)
		{
			master.Activate(activator);
		}
	}
	
	override void Deactivate(Actor activator)
	{
		Activate(activator);
	}

	States
	{
		Spawn:	
		FRAM A 1;
		Loop;
	}
}

Re: Doors with Doom 3 logic

by Nerotrobe » Mon Jun 08, 2020 4:45 pm

I'm attempting to do something with CheckProcimity to see if the player is nearby I thought I used it wrong until I found this thread. The example provided by TheSeventh works flawlessly when I run his example.wad but if I rebuild his level or use his script in my level it always returns false for the proximity check. Running latest nightly GZDoom build.

Re: Doors with Doom 3 logic

by TheSeventh » Wed Nov 14, 2018 5: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 all

#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 25 times

Re: Doors with Doom 3 logic

by DOOMGABR [RU] » Thu Nov 01, 2018 2:32 pm

Yes, good thinking. How to realize this actor?

Re: Doors with Doom 3 logic

by Enjay » Thu Nov 01, 2018 1: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.

Doors with Doom 3 logic

by DOOMGABR [RU] » Thu Nov 01, 2018 12: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

Top