Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
vedan

Poly double swing doors problem

Question

Hi,

 

I want to have 2 polyobject doors that, when activated, swing open (left and right door), wait and close.

 

So I tried this script:

// poly swing doors

script 994 (int poly1, int poly2, int pause) { // left door wing, right door wing, time before closing
	int speed = 16;
	int angle = 0.5;

	// open
	Polyobj_RotateLeft(poly1, speed, angle);
	Polyobj_RotateRight(poly2, speed, angle);
	Delay(30);
	Polyobj_Stop(poly1);
	Polyobj_Stop(poly2);

	// wait
	Delay(pause);

	// close
	Polyobj_RotateLeft(poly2, speed, angle);
	Polyobj_RotateRight(poly1, speed, angle);
	Delay(30);
	Polyobj_Stop(poly1);
	Polyobj_Stop(poly2);
}

...which works fine so far BUT when the player collides with one of the doors, it gets blocked and "out of sync" (it's not fully opened or closed when the script is finished).

 

I tried to counter this effect with the poly override functions and the door swing functions, too - but the polyobject still gets blocked.

 

Is there a way to have the doors NOT to get blocked by the player and move as they are supposed to?

 

Any help is greatly appreciated!

 

PS: I already tried different poly anchor start spots (crush & hurt), made no difference too (except I died when it was set to "hurt"^^).

 

PSS: I might have figured out a dirty workaround: Remove the "Impassable" flag of the poly objects while they are swinging. Still got to try that, though. Anybody knows how?

 

doors.png

Edited by vedan

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0

Do you have any special reason for using Polyobject_rotate instead of polyobject_swing, which already has the auto-closing mechanism already built in?

 

Also, you're causing the desync by using delay() instead of PolyWait(), which is more suitable for this job.

Share this post


Link to post
  • 0

Polyobj_DoorSwing did the trick, I didn't use it correctly at first (angle was at 0.5 instead of 64).

 

Solved it, thanks!

Share this post


Link to post
  • 0

alternative check out gzfreedoom now known as gzfreepunk ... its e1m1 has those kind of doors without the need for a script

Share this post


Link to post
  • 0
12 hours ago, CBM said:

alternative check out gzfreedoom now known as gzfreepunk ... its e1m1 has those kind of doors without the need for a script

Betting it uses polyobject_swing called diretly from linedef.

 

Also, if you want a more polished, functionalized script for controlling polyobject doors, here it is. This one script could be used to control up to 1000 polyobject doors without the need to redefine the script for each door.

 

#include "zcommon.acs"

#define MAX_SWINGING_DOORS 1000
bool polyDoor[MAX_SWINGING_DOORS]; //'dynamic' variable = array

function void doorSwing_Left(int poly, int spd)
{
    Polyobj_RotateLeft(poly, spd, 64);
    AmbientSound("sounds/doorOpenClose", 127);
}

function void doorSwing_Right(int poly, int spd)
{
    Polyobj_RotateRight(poly, spd, 64);
    AmbientSound("sounds/doorOpenClose", 127);
}

script "poDoorSwing_Right" (int poly, int speedOctics)
{
    if (!polyDoor[poly])
    {
        doorSwing_Right(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = true;
    }
    else if(polyDoor[poly])
    {
        doorSwing_Left(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = false;
    }
}

script "poDoorSwing_Left" (int poly, int speedOctics)
{
    if (!polyDoor[poly])
    {
        doorSwing_Left(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = true;
    }
    else if (polyDoor[poly])
    {
        doorSwing_Right(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = false;
    }
}

script "poDoorSwingClose_Right" (int poly, int speedOctics, int openTics)
{      
    if (!polyDoor[poly])
    {
        doorSwing_Right(poly, speedOctics);
        polyDoor[poly] = true;
        PolyWait(poly);
        Delay(openTics);
        doorSwing_Left(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = false;
    }
}

script "poDoorSwingClose_Left" (int poly, int speedOctics, int openTics)
{
    if (!polyDoor[poly])
    {
        doorSwing_Left(poly, speedOctics);
        polyDoor[poly] = true;
        PolyWait(poly);
        Delay(openTics);
        doorSwing_Right(poly, speedOctics);
        PolyWait(poly);
        polyDoor[poly] = false;
    }
}

 

Edited by ramon.dexter

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×