P_SetOrigin & P_MoveOrigin to replace P_TeleportMove

This commit is contained in:
Sally Coolatta 2021-11-29 08:20:27 -05:00 committed by Eidolon
parent 2f46725984
commit d476b41dfa
9 changed files with 85 additions and 25 deletions

View file

@ -1008,7 +1008,7 @@ void G_ReadMetalTic(mobj_t *metal)
oldmetal.x = READFIXED(metal_p);
oldmetal.y = READFIXED(metal_p);
oldmetal.z = READFIXED(metal_p);
P_TeleportMove(metal, oldmetal.x, oldmetal.y, oldmetal.z);
P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z);
oldmetal.x = metal->x;
oldmetal.y = metal->y;
oldmetal.z = metal->z;

View file

@ -1783,7 +1783,42 @@ static int lib_pTeleportMove(lua_State *L)
INLEVEL
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_TeleportMove(thing, x, y, z));
LUA_Deprecated(L, "P_TeleportMove", "P_SetOrigin or P_MoveOrigin");
lua_pushboolean(L, P_SetOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
return 2;
}
static int lib_pSetOrigin(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
NOHUD
INLEVEL
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_SetOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
return 2;
}
static int lib_pMoveOrigin(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
NOHUD
INLEVEL
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_MoveOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
return 2;
@ -4021,6 +4056,8 @@ static luaL_Reg lib[] = {
{"P_TryMove",lib_pTryMove},
{"P_Move",lib_pMove},
{"P_TeleportMove",lib_pTeleportMove},
{"P_SetOrigin",lib_pSetOrigin},
{"P_MoveOrigin",lib_pMoveOrigin},
{"P_SlideMove",lib_pSlideMove},
{"P_BounceMove",lib_pBounceMove},
{"P_CheckSight", lib_pCheckSight},

View file

@ -458,7 +458,7 @@ static int mobj_get(lua_State *L)
}
#define NOSET luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly.", mobj_opt[field])
#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_TeleportMove") " instead.", mobj_opt[field])
#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_SetOrigin") ", or " LUA_QL("P_MoveOrigin") " instead.", mobj_opt[field])
static int mobj_set(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));

View file

@ -475,7 +475,7 @@ void Command_RTeleport_f(void)
CONS_Printf(M_GetText("Teleporting by %d, %d, %d...\n"), intx, inty, FixedInt((intz-p->mo->z)));
P_MapStart();
if (!P_TeleportMove(p->mo, p->mo->x+intx*FRACUNIT, p->mo->y+inty*FRACUNIT, intz))
if (!P_SetOrigin(p->mo, p->mo->x+intx*FRACUNIT, p->mo->y+inty*FRACUNIT, intz))
CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n"));
else
S_StartSound(p->mo, sfx_mixup);
@ -696,7 +696,7 @@ void Command_Teleport_f(void)
}
P_MapStart();
if (!P_TeleportMove(p->mo, intx, inty, intz))
if (!P_SetOrigin(p->mo, intx, inty, intz))
CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n"));
else
S_StartSound(p->mo, sfx_mixup);
@ -1315,7 +1315,7 @@ void OP_ObjectplaceMovement(player_t *player)
if (cmd->forwardmove != 0)
{
P_Thrust(player->mo, player->mo->angle, (cmd->forwardmove*player->mo->scale/MAXPLMOVE)*cv_speed.value);
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
P_MoveOrigin(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
player->mo->momx = player->mo->momy = 0;
}
if (cmd->sidemove != 0)

View file

@ -1331,7 +1331,7 @@ void A_FaceStabHurl(mobj_t *actor)
hwork->destscale = FixedSqrt(step*basesize);
P_SetScale(hwork, hwork->destscale);
hwork->fuse = 2;
P_TeleportMove(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<<FRACBITS)));
P_MoveOrigin(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<<FRACBITS)));
step -= NUMGRADS;
}
@ -2091,7 +2091,7 @@ void A_CrushclawAim(mobj_t *actor)
#undef anglimit
#undef angfactor
P_TeleportMove(actor,
P_MoveOrigin(actor,
crab->x + P_ReturnThrustX(actor, actor->angle, locvar1*crab->scale),
crab->y + P_ReturnThrustY(actor, actor->angle, locvar1*crab->scale),
crab->z + locvar2*crab->scale);
@ -2229,7 +2229,7 @@ void A_CrushclawLaunch(mobj_t *actor)
fixed_t idx = dx, idy = dy, idz = dz;
while (chain)
{
P_TeleportMove(chain, actor->target->x + idx, actor->target->y + idy, actor->target->z + idz);
P_MoveOrigin(chain, actor->target->x + idx, actor->target->y + idy, actor->target->z + idz);
chain->movefactor = chain->z;
idx += dx;
idy += dy;
@ -11149,7 +11149,7 @@ void A_VileAttack(mobj_t *actor)
// move the fire between the vile and the player
//fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]);
//fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]);
P_TeleportMove(fire,
P_MoveOrigin(fire,
actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
fire->z);
@ -11194,7 +11194,7 @@ void A_VileAttack(mobj_t *actor)
// move the fire between the vile and the player
//fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]);
//fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]);
P_TeleportMove(fire,
P_MoveOrigin(fire,
actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
fire->z);
@ -11865,12 +11865,12 @@ void A_FlickyCenter(mobj_t *actor)
if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1)
{
actor->extravalue2 = 1;
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
P_SetOrigin(actor, actor->target->x, actor->target->y, actor->target->z);
}
else if(actor->extravalue2)
{
actor->extravalue2 = 0;
P_TeleportMove(actor, originx, originy, originz);
P_SetOrigin(actor, originx, originy, originz);
}
}
}
@ -12406,7 +12406,7 @@ void A_LightBeamReset(mobj_t *actor)
actor->momy = (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
actor->momz = (P_SignedRandom()*FRACUNIT)/128;
P_TeleportMove(actor,
P_SetOrigin(actor,
actor->spawnpoint->x*FRACUNIT - (P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->y*FRACUNIT + (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->z*FRACUNIT + (P_SignedRandom()*FRACUNIT)/2);
@ -12991,7 +12991,7 @@ void A_DoNPCSkid(mobj_t *actor)
actor->momy = (2*actor->momy)/3;
}
P_TeleportMove(actor, x, y, z);
P_MoveOrigin(actor, x, y, z);
// Spawn a particle every 3 tics.
if (!(leveltime % 3))
@ -13332,7 +13332,7 @@ void A_Boss5MakeJunk(mobj_t *actor)
if (locvar1 > 0)
P_SetMobjState(broked, locvar1);
if (!P_MobjWasRemoved(broked))
P_TeleportMove(broked, broked->x + broked->momx, broked->y + broked->momy, broked->z);
P_MoveOrigin(broked, broked->x + broked->momx, broked->y + broked->momy, broked->z);
ang += ANGLE_45;
}
@ -14550,7 +14550,7 @@ void A_DragonWing(mobj_t *actor)
actor->angle = target->angle + actor->movedir;
x = target->x + P_ReturnThrustX(actor, actor->angle, -target->radius);
y = target->y + P_ReturnThrustY(actor, actor->angle, -target->radius);
P_TeleportMove(actor, x, y, target->z);
P_MoveOrigin(actor, x, y, target->z);
}
// Function: A_DragonSegment
@ -14591,7 +14591,7 @@ void A_DragonSegment(mobj_t *actor)
zdist = P_ReturnThrustY(target, zangle, radius);
actor->angle = hangle;
P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist);
P_MoveOrigin(actor, target->x + xdist, target->y + ydist, target->z + zdist);
}
// Function: A_ChangeHeight

View file

@ -414,7 +414,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam);
boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff);
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff);
boolean P_Move(mobj_t *actor, fixed_t speed);
boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
void P_InitAngle(mobj_t *thing, angle_t newValue);
void P_InitPitch(mobj_t *thing, angle_t newValue);
void P_InitRoll(mobj_t *thing, angle_t newValue);

View file

@ -75,7 +75,7 @@ camera_t *mapcampointer;
//
// P_TeleportMove
//
boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
{
// the move is ok,
// so link the thing into its new position
@ -104,11 +104,33 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
thing->floorrover = tmfloorrover;
thing->ceilingrover = tmceilingrover;
R_ResetMobjInterpolationState(thing);
return true;
}
// P_SetOrigin - P_TeleportMove which RESETS interpolation values.
//
boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
{
boolean result = P_TeleportMove(thing, x, y, z);
if (result == true)
{
thing->old_x = thing->x;
thing->old_y = thing->y;
thing->old_z = thing->z;
}
return result;
}
//
// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values.
//
boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
{
return P_TeleportMove(thing, x, y, z);
}
//
// P_InitAngle - Change an object's angle, including interp values.
//
@ -1941,7 +1963,7 @@ static boolean PIT_CheckLine(line_t *ld)
cosradius = FixedMul(dist, FINECOSINE(langle>>ANGLETOFINESHIFT));
sinradius = FixedMul(dist, FINESINE(langle>>ANGLETOFINESHIFT));
tmthing->flags |= MF_NOCLIP;
P_TeleportMove(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z);
P_MoveOrigin(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z);
tmthing->flags &= ~MF_NOCLIP;
}
#endif

View file

@ -6440,7 +6440,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
if (dist < source->movefactor)
{
source->momx = source->momy = source->momz = 0;
P_TeleportMove(source, tx, ty, tz);
P_MoveOrigin(source, tx, ty, tz);
}
else
{

View file

@ -122,7 +122,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
*/
boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, boolean flash, boolean dontstopmove)
{
if (!P_TeleportMove(thing, x, y, z))
if (!P_SetOrigin(thing, x, y, z))
return false;
if (!dontstopmove)