Adapt crusher linedefs to UDMF

This commit is contained in:
MascaraSnake 2021-06-26 12:53:14 +02:00
parent c8bb18b389
commit 9fdd9060e4
5 changed files with 44 additions and 51 deletions

View file

@ -140,11 +140,7 @@ void T_CrushCeiling(ceiling_t *ceiling)
if (res == pastdest)
{
ceiling->direction = -1;
if (lines[ceiling->sourceline].flags & ML_EFFECT4)
ceiling->speed = ceiling->oldspeed;
else
ceiling->speed = ceiling->oldspeed*2;
ceiling->speed = lines[ceiling->sourceline].args[2] << (FRACBITS - 2);
if (ceiling->type == crushCeilOnce
|| ceiling->type == crushBothOnce)
@ -185,12 +181,8 @@ void T_CrushCeiling(ceiling_t *ceiling)
ceiling->sector->soundorg.z = ceiling->sector->floorheight;
S_StartSound(mp,sfx_pstop);
if (lines[ceiling->sourceline].flags & ML_EFFECT4)
ceiling->speed = ceiling->oldspeed;
else
ceiling->speed = ceiling->oldspeed/2;
ceiling->direction = 1;
ceiling->speed = lines[ceiling->sourceline].args[3] << (FRACBITS - 2);
}
break;
}
@ -387,41 +379,29 @@ INT32 EV_DoCrush(mtag_t tag, line_t *line, ceiling_e type)
ceiling->sector = sec;
ceiling->crush = true;
ceiling->sourceline = (INT32)(line-lines);
if (line->flags & ML_EFFECT4)
ceiling->oldspeed = FixedDiv(abs(line->dx),4*FRACUNIT);
else
ceiling->oldspeed = (R_PointToDist2(line->v2->x, line->v2->y, line->v1->x, line->v1->y)/16);
ceiling->speed = ceiling->oldspeed = line->args[2] << (FRACBITS - 2);
switch(type)
{
case fastCrushAndRaise: // Up and then down
case raiseAndCrush: // Up and then down
ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
ceiling->direction = 1;
ceiling->speed = ceiling->oldspeed;
// Retain stupid behavior for backwards compatibility
if (!udmf && !(line->flags & ML_EFFECT4))
ceiling->speed /= 2;
else
ceiling->speed = line->args[3] << (FRACBITS - 2);
ceiling->bottomheight = sec->floorheight + FRACUNIT;
break;
case crushBothOnce:
ceiling->topheight = sec->ceilingheight;
ceiling->bottomheight = sec->floorheight + (sec->ceilingheight-sec->floorheight)/2;
ceiling->direction = -1;
if (line->flags & ML_EFFECT4)
ceiling->speed = ceiling->oldspeed;
else
ceiling->speed = ceiling->oldspeed*2;
break;
case crushCeilOnce:
default: // Down and then up.
ceiling->topheight = sec->ceilingheight;
ceiling->direction = -1;
if (line->flags & ML_EFFECT4)
ceiling->speed = ceiling->oldspeed;
else
ceiling->speed = ceiling->oldspeed*2;
ceiling->bottomheight = sec->floorheight + FRACUNIT;
break;
}

View file

@ -222,6 +222,7 @@ void T_MoveFloor(floormove_t *movefloor)
{
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
movefloor->direction = -1;
movefloor->speed = lines[movefloor->texture].args[3] << (FRACBITS - 2);
movefloor->sector->soundorg.z = movefloor->sector->floorheight;
S_StartSound(&movefloor->sector->soundorg, sfx_pstop);
remove = false;
@ -1863,8 +1864,7 @@ void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
break;
case crushFloorOnce:
dofloor->speed = FixedDiv(abs(line->dx),4*FRACUNIT);
dofloor->origspeed = dofloor->speed;
dofloor->speed = dofloor->origspeed = line->args[2] << (FRACBITS - 2);
dofloor->floordestheight = line->frontsector->ceilingheight;
if (dofloor->floordestheight >= sec->floorheight)
@ -1872,10 +1872,6 @@ void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
else
dofloor->direction = -1; // down
// Any delay?
dofloor->delay = sides[line->sidenum[0]].textureoffset >> FRACBITS;
dofloor->delaytimer = sides[line->sidenum[0]].rowoffset >> FRACBITS;
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
break;

View file

@ -3119,6 +3119,18 @@ static void P_ConvertBinaryMap(void)
case 61: //Crusher (Ceiling to floor)
case 62: //Crusher (Floor to ceiling)
lines[i].args[0] = tag;
lines[i].args[1] = lines[i].special - 61;
if (lines[i].flags & ML_EFFECT4)
{
lines[i].args[2] = abs(lines[i].dx) >> FRACBITS;
lines[i].args[3] = lines[i].args[2];
}
else
{
lines[i].args[2] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> (FRACBITS + 1);
lines[i].args[3] = lines[i].args[2] / 4;
}
lines[i].special = 61;
break;
case 76: //Make FOF bouncy
lines[i].args[0] = tag;
@ -3568,6 +3580,18 @@ static void P_ConvertBinaryMap(void)
case 430: //Crush floor once
case 431: //Crush floor and ceiling once
lines[i].args[0] = tag;
lines[i].args[1] = (lines[i].special == 429) ? 1 : ((lines[i].special == 430) ? 0 : 2);
if (lines[i].special == 430 || lines[i].flags & ML_EFFECT4)
{
lines[i].args[2] = abs(lines[i].dx) >> FRACBITS;
lines[i].args[3] = lines[i].args[2];
}
else
{
lines[i].args[2] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> (FRACBITS + 1);
lines[i].args[3] = lines[i].args[2] / 4;
}
lines[i].special = 429;
break;
case 443: //Call Lua function
if (lines[i].text)

View file

@ -2870,15 +2870,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
EV_DoElevator(line->args[0], line, elevateContinuous);
break;
case 429: // Crush Ceiling Down Once
EV_DoCrush(line->args[0], line, crushCeilOnce);
break;
case 430: // Crush Floor Up Once
case 429: // Crush planes once
if (line->args[1] == 0)
EV_DoFloor(line->args[0], line, crushFloorOnce);
break;
case 431: // Crush Floor & Ceiling to middle Once
else if (line->args[1] == 1)
EV_DoCrush(line->args[0], line, crushCeilOnce);
else
EV_DoCrush(line->args[0], line, crushBothOnce);
break;
@ -6353,11 +6350,7 @@ void P_SpawnSpecials(boolean fromnetsave)
break;
case 61: // Crusher!
EV_DoCrush(lines[i].args[0], &lines[i], crushAndRaise);
break;
case 62: // Crusher (up and then down)!
EV_DoCrush(lines[i].args[0], &lines[i], fastCrushAndRaise);
EV_DoCrush(lines[i].args[0], &lines[i], lines[i].args[1] ? raiseAndCrush : crushAndRaise);
break;
case 63: // support for drawn heights coming from different sector

View file

@ -264,7 +264,7 @@ typedef enum
instantRaise, // instant-move for ceilings
crushAndRaise,
fastCrushAndRaise,
raiseAndCrush,
crushCeilOnce,
crushBothOnce,