diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 980ff88a9..300ee7556 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4563,6 +4563,8 @@ enum WARPF WARPF_TOFLOOR = 0x100, WARPF_TESTONLY = 0x200, WARPF_ABSOLUTEPOSITION = 0x400, + WARPF_BOB = 0x800, + WARPF_MOVEPTR = 0x1000, }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) @@ -4579,19 +4581,29 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) AActor *reference = COPY_AAPTR(self, destination_selector); + //If there is no actor to warp to, fail. if (!reference) { ACTION_SET_RESULT(false); return; } - fixed_t oldx = self->x; - fixed_t oldy = self->y; - fixed_t oldz = self->z; + AActor *caller = self; + + if (flags & WARPF_MOVEPTR) + { + AActor *temp = reference; + reference = caller; + caller = temp; + } + + fixed_t oldx = caller->x; + fixed_t oldy = caller->y; + fixed_t oldz = caller->z; if (!(flags & WARPF_ABSOLUTEANGLE)) { - angle += (flags & WARPF_USECALLERANGLE) ? self->angle : reference->angle; + angle += (flags & WARPF_USECALLERANGLE) ? caller->angle : reference->angle; } if (!(flags & WARPF_ABSOLUTEPOSITION)) { @@ -4612,7 +4624,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) { // set correct xy - self->SetOrigin( + caller->SetOrigin( reference->x + xofs, reference->y + yofs, reference->z); @@ -4623,10 +4635,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) if (zofs) { // extra unlink, link and environment calculation - self->SetOrigin( - self->x, - self->y, - self->floorz + zofs); + caller->SetOrigin( + caller->x, + caller->y, + caller->floorz + zofs); } else { @@ -4634,12 +4646,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) // already identified floor // A_Teleport does the same thing anyway - self->z = self->floorz; + caller->z = caller->floorz; } } else { - self->SetOrigin( + caller->SetOrigin( reference->x + xofs, reference->y + yofs, reference->z + zofs); @@ -4649,51 +4661,57 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) { if (flags & WARPF_TOFLOOR) { - self->SetOrigin(xofs, yofs, self->floorz + zofs); + caller->SetOrigin(xofs, yofs, caller->floorz + zofs); } else { - self->SetOrigin(xofs, yofs, zofs); + caller->SetOrigin(xofs, yofs, zofs); } } - if ((flags & WARPF_NOCHECKPOSITION) || P_TestMobjLocation(self)) + if ((flags & WARPF_NOCHECKPOSITION) || P_TestMobjLocation(caller)) { if (flags & WARPF_TESTONLY) { - self->SetOrigin(oldx, oldy, oldz); + caller->SetOrigin(oldx, oldy, oldz); } else { - self->angle = angle; + caller->angle = angle; if (flags & WARPF_STOP) { - self->velx = 0; - self->vely = 0; - self->velz = 0; + caller->velx = 0; + caller->vely = 0; + caller->velz = 0; } if (flags & WARPF_WARPINTERPOLATION) { - self->PrevX += self->x - oldx; - self->PrevY += self->y - oldy; - self->PrevZ += self->z - oldz; + caller->PrevX += caller->x - oldx; + caller->PrevY += caller->y - oldy; + caller->PrevZ += caller->z - oldz; } else if (flags & WARPF_COPYINTERPOLATION) { - self->PrevX = self->x + reference->PrevX - reference->x; - self->PrevY = self->y + reference->PrevY - reference->y; - self->PrevZ = self->z + reference->PrevZ - reference->z; + caller->PrevX = caller->x + reference->PrevX - reference->x; + caller->PrevY = caller->y + reference->PrevY - reference->y; + caller->PrevZ = caller->z + reference->PrevZ - reference->z; } else if (!(flags & WARPF_INTERPOLATE)) { - self->PrevX = self->x; - self->PrevY = self->y; - self->PrevZ = self->z; + caller->PrevX = caller->x; + caller->PrevY = caller->y; + caller->PrevZ = caller->z; + } + + if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) + { + caller->z += reference->GetBobOffset(); } } + if (success_state) { ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! @@ -4706,7 +4724,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) } else { - self->SetOrigin(oldx, oldy, oldz); + caller->SetOrigin(oldx, oldy, oldz); ACTION_SET_RESULT(false); } @@ -5634,6 +5652,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_SwapTeleFog) } } +//=========================================================================== +// +// A_SetFloatBobPhase +// +// Changes the FloatBobPhase of the +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatBobPhase) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_INT(bob, 0); + + //Respect float bob phase limits. + if (self && (bob >= 0 && bob <= 63)) + self->FloatBobPhase = bob; +} + //=========================================================================== // // A_SetRipperLevel(int level) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index a1e6b275b..b2fa80c30 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -326,6 +326,7 @@ ACTOR Actor native //: Thinker action native A_TakeFromSiblings(class itemtype, int amount = 0); action native A_SetTeleFog(name oldpos, name newpos); action native A_SwapTeleFog(); + action native A_SetFloatBobPhase(int bob); action native A_SetRipperLevel(int level); action native A_SetRipMin(int min); action native A_SetRipMax(int max); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 9b872df52..074953afe 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -345,6 +345,8 @@ Const Int WARPF_TOFLOOR = 0x100; Const Int WARPF_TESTONLY = 0x200; Const Int WAPRF_ABSOLUTEPOSITION = 0x400; Const Int WARPF_ABSOLUTEPOSITION = 0x400; +Const Int WARPF_BOB = 0x800; +Const Int WARPF_MOVEPTR = 0x1000; // flags for A_SetPitch/SetAngle/SetRoll const int SPF_FORCECLAMP = 1;