Commit ed5d2265 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Experimental swinging door changes

This makes swinging doors reverse direction instead of stopping in place and later resuming when obstructed.

From-SVN: r8722
parent 4c4fdd1f
......@@ -72,7 +72,7 @@ typedef struct
extern int16_t clipsectorlist[MAXCLIPSECTORS];
int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
int clipinsidebox(vec2_t const * const vect, int const wallnum, int const walldist);
int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist);
extern int32_t clipmoveboxtracenum;
......
......@@ -552,7 +552,7 @@ int32_t clipmoveboxtracenum = 3;
//
// clipinsidebox
//
int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
int clipinsidebox(vec2_t const * const vect, int const wallnum, int const walldist)
{
int const r = walldist << 1;
......
......@@ -6757,8 +6757,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
else pData[0]=0;
break;
case SE_11_SWINGING_DOOR: //Swingdoor
case SE_11_SWINGING_DOOR:
if (pData[5] > 0)
{
pData[5]--;
......@@ -6767,50 +6766,77 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (pData[4])
{
int const endWall = pSector->wallptr+pSector->wallnum;
for (j=pSector->wallptr; j<endWall; j++)
auto dukeLivesMatter = [&](vec2_t const *const pos, int const w, int const clipdist)
{
for (SPRITES_OF(STAT_ACTOR, k))
if (clipinsidebox(pos, w, clipdist))
{
if (sprite[k].extra > 0 &&
(pSprite->sectnum == sprite[k].sectnum ||
sectoradjacent(pSprite->sectnum, sprite[k].sectnum)) &&
A_CheckEnemySprite(&sprite[k]) &&
clipinsidebox(&sprite[k].pos.vec2, j, 256) == 1)
goto next_sprite;
uint16_t const tag = sector[pSprite->sectnum].lotag & 0x8000u;
for (auto SPRITES_OF(STAT_EFFECTOR, i))
{
if (tag == (sector[SECT(i)].lotag & 0x8000u) && SLT(i) == SE_11_SWINGING_DOOR && pSprite->hitag == SHT(i))
{
actor[i].t_data[5] = 2; // delay
actor[i].t_data[2] -= l;
actor[i].t_data[4] -= l;
A_MoveSector(i);
actor[i].t_data[3] = -actor[i].t_data[3];
if (actor[i].t_data[4] < 0)
actor[i].t_data[4] += 512;
else
actor[i].t_data[4] -= 512;
}
}
A_CallSound(pSprite->sectnum, spriteNum);
return true;
}
}
return false;
};
int const endWall = pSector->wallptr+pSector->wallnum;
l = (SP(spriteNum) >> 3) * pData[3];
pData[2] += l;
pData[4] += l;
A_MoveSector(spriteNum);
setsprite(spriteNum, &pSprite->pos);
for (j=pSector->wallptr; j<endWall; j++)
for (auto SPRITES_OF(STAT_ACTOR, spr))
{
for (SPRITES_OF(STAT_PLAYER, k))
auto const foundSprite = (uspriteptr_t)&sprite[spr];
if (foundSprite->extra > 0 && A_CheckEnemySprite(foundSprite))
{
if (sprite[k].owner >= 0 && clipinsidebox(&sprite[k].pos.vec2, j, pPlayer->clipdist))
auto const clipdist = A_GetClipdist(spr, -1);
for (int w = pSector->wallptr; w < endWall; w++)
{
pData[5] = 8; // Delay
pData[2] -= l;
pData[4] -= l;
A_MoveSector(spriteNum);
setsprite(spriteNum, &pSprite->pos);
goto next_sprite;
if (dukeLivesMatter(&foundSprite->pos.vec2, w, clipdist))
break;
}
}
}
for (auto TRAVERSE_CONNECT(plr))
{
auto const foundPlayer = g_player[plr].ps;
for (int w = pSector->wallptr; w < endWall; w++)
{
if (dukeLivesMatter(&foundPlayer->pos.vec2, w, foundPlayer->clipdist))
break;
}
}
if (pData[4] <= -511 || pData[4] >= 512)
{
pData[4] = 0;
pData[2] &= 0xffffff00;
A_MoveSector(spriteNum);
setsprite(spriteNum, &pSprite->pos);
break;
}
}
break;
......
......@@ -919,7 +919,7 @@ REDODOOR:
if (j >= 0)
{
for (SPRITES_OF(STAT_EFFECTOR, i))
if (tag == (sector[SECT(i)].lotag & 0x8000u) && SLT(i) == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT(i) && T5(i))
if (tag == (sector[SECT(i)].lotag & 0x8000u) && SLT(i) == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT(i) && (T5(i)||T6(i)))
return;
int soundPlayed = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment