Adapt polyobject displacement linedefs to UDMF

This commit is contained in:
MascaraSnake 2021-07-04 14:41:37 +02:00
parent 429c6588af
commit d2ad12c034
3 changed files with 68 additions and 13 deletions

View file

@ -1588,6 +1588,52 @@ udmf
title = "Distance";
}
}
31
{
title = "Displacement by Front Sector";
prefix = "(31)";
arg0
{
title = "PolyObject ID";
type = 14;
}
arg1
{
title = "Base speed";
}
}
32
{
title = "Angular Displacement by Front Sector";
prefix = "(32)";
arg0
{
title = "PolyObject ID";
type = 14;
}
arg1
{
title = "Plane factor";
default = 128;
}
arg2
{
title = "Rotation factor";
default = 90;
}
arg3
{
title = "Flags";
type = 12;
enum
{
1 = "Don't turn others";
2 = "Turn players";
}
}
}
}
planemove

View file

@ -3086,6 +3086,19 @@ static void P_ConvertBinaryMap(void)
lines[i].args[1] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
break;
case 31: //Polyobject - displacement by front sector
lines[i].args[0] = tag;
lines[i].args[1] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> FRACBITS;
break;
case 32: //Polyobject - angular displacement by front sector
lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset ? sides[lines[i].sidenum[0]].textureoffset >> FRACBITS : 128;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset ? sides[lines[i].sidenum[0]].rowoffset >> FRACBITS : 90;
if (lines[i].flags & ML_NOCLIMB)
lines[i].args[3] |= TMPR_DONTROTATEOTHERS;
else if (lines[i].flags & ML_EFFECT4)
lines[i].args[3] |= TMPR_ROTATEPLAYERS;
break;
case 50: //Instantly lower floor on level load
case 51: //Instantly raise ceiling on level load
lines[i].args[0] = tag;

View file

@ -1201,12 +1201,14 @@ static boolean PolyFlag(line_t *line)
static boolean PolyDisplace(line_t *line)
{
polydisplacedata_t pdd;
fixed_t length = R_PointToDist2(line->v2->x, line->v2->y, line->v1->x, line->v1->y);
fixed_t speed = line->args[1] << FRACBITS;
pdd.polyObjNum = Tag_FGet(&line->tags);
pdd.polyObjNum = line->args[0];
pdd.controlSector = line->frontsector;
pdd.dx = line->dx>>8;
pdd.dy = line->dy>>8;
pdd.dx = FixedMul(FixedDiv(line->dx, length), speed) >> 8;
pdd.dy = FixedMul(FixedDiv(line->dy, length), speed) >> 8;
return EV_DoPolyObjDisplace(&pdd);
}
@ -1218,22 +1220,16 @@ static boolean PolyRotDisplace(line_t *line)
polyrotdisplacedata_t pdd;
fixed_t anginter, distinter;
pdd.polyObjNum = Tag_FGet(&line->tags);
pdd.polyObjNum = line->args[0];
pdd.controlSector = line->frontsector;
// Rotate 'anginter' interval for each 'distinter' interval from the control sector.
// Use default values if not provided as fallback.
anginter = sides[line->sidenum[0]].rowoffset ? sides[line->sidenum[0]].rowoffset : 90*FRACUNIT;
distinter = sides[line->sidenum[0]].textureoffset ? sides[line->sidenum[0]].textureoffset : 128*FRACUNIT;
anginter = line->args[2] << FRACBITS;
distinter = line->args[1] << FRACBITS;
pdd.rotscale = FixedDiv(anginter, distinter);
// Same behavior as other rotators when carrying things.
if (line->flags & ML_NOCLIMB)
pdd.turnobjs = 0;
else if (line->flags & ML_EFFECT4)
pdd.turnobjs = PTF_PLAYERS|PTF_OTHERS;
else
pdd.turnobjs = PTF_OTHERS;
pdd.turnobjs = line->args[3];
return EV_DoPolyObjRotDisplace(&pdd);
}