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;
}
}
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]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;
}
}[/code]