From d2ad12c0343098ecc9bfcc16ab2e2ef18a9b5b70 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 4 Jul 2021 14:41:37 +0200 Subject: [PATCH] Adapt polyobject displacement linedefs to UDMF --- extras/conf/udb/Includes/SRB222_linedefs.cfg | 46 ++++++++++++++++++++ src/p_setup.c | 13 ++++++ src/p_spec.c | 22 ++++------ 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index ff25fee2c..63e363549 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -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 diff --git a/src/p_setup.c b/src/p_setup.c index 2b2efd0f8..59d8ada8b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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; diff --git a/src/p_spec.c b/src/p_spec.c index b98b244b3..721fe9d74 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -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); }