From ad14caa80026a1713377c050d77b1e7ef08dd2d7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 10 Aug 2015 11:19:54 -0500 Subject: [PATCH 1/6] - Added A_Warp heightoffset property. Only has an effect by two flags. - WARPF_ADDHEIGHT adds the pointed actor's height to heightoffset, and adds to the pointed actor's z position. - WARPF_MULHEIGHT multiplies the pointed actor's height by heightoffset, and adds to the pointed actor's z position. Overridden by ADDHEIGHT. --- src/p_acs.cpp | 3 ++- src/p_local.h | 4 +++- src/p_things.cpp | 18 ++++++++++++------ src/thingdef/thingdef_codeptr.cpp | 5 +++-- wadsrc/static/actors/actor.txt | 2 +- wadsrc/static/actors/constants.txt | 2 ++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 83a087d8f..b703b87dd 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5862,6 +5862,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) int flags = args[5]; const char *statename = argCount > 6 ? FBehavior::StaticLookupString(args[6]) : ""; bool exact = argCount > 7 ? !!args[7] : false; + fixed_t heightoffset = argCount > 8 ? args[8] : 0; FState *state = argCount > 6 ? activator->GetClass()->ActorInfo->FindStateByString(statename, exact) : 0; @@ -5879,7 +5880,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (!reference) return false; - if (P_Thing_Warp(activator, reference, xofs, yofs, zofs, angle, flags)) + if (P_Thing_Warp(activator, reference, xofs, yofs, zofs, angle, flags, heightoffset)) { if (state && argCount > 6) { diff --git a/src/p_local.h b/src/p_local.h index 0b1c9c7a8..6022d8e8e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -176,7 +176,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser); bool P_Thing_CanRaise(AActor *thing); const PClass *P_GetSpawnableType(int spawnnum); void InitSpawnablesFromMapinfo(); -int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags); +int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags, fixed_t heightoffset); enum WARPF { @@ -198,6 +198,8 @@ enum WARPF WARPF_MOVEPTR = 0x1000, WARPF_USEPTR = 0x2000, WARPF_USETID = 0x2000, + WARPF_ADDHEIGHT = 0x4000, + WARPF_MULHEIGHT = 0x8000, }; diff --git a/src/p_things.cpp b/src/p_things.cpp index 799e72893..db80e35ca 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -680,7 +680,7 @@ void InitSpawnablesFromMapinfo() } -int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags) +int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags, fixed_t heightoffset) { if (flags & WARPF_MOVEPTR) { @@ -692,6 +692,12 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t oldx = caller->x; fixed_t oldy = caller->y; fixed_t oldz = caller->z; + fixed_t height = 0; + + if (flags & WARPF_ADDHEIGHT) + height = reference->height + heightoffset; + else if (flags & WARPF_MULHEIGHT) + height = FixedMul(reference->height, heightoffset); if (!(flags & WARPF_ABSOLUTEANGLE)) { @@ -719,7 +725,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller->SetOrigin( reference->x + xofs, reference->y + yofs, - reference->z); + reference->z + height); // now the caller's floorz should be appropriate for the assigned xy-position // assigning position again with @@ -730,7 +736,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller->SetOrigin( caller->x, caller->y, - caller->floorz + zofs); + caller->floorz + zofs + height); } else { @@ -745,18 +751,18 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller->SetOrigin( reference->x + xofs, reference->y + yofs, - reference->z + zofs); + reference->z + zofs + height); } } else // [MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's. { if (flags & WARPF_TOFLOOR) { - caller->SetOrigin(xofs, yofs, caller->floorz + zofs); + caller->SetOrigin(xofs, yofs, caller->floorz + zofs + height); } else { - caller->SetOrigin(xofs, yofs, zofs); + caller->SetOrigin(xofs, yofs, zofs + height); } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 69dd89cd0..5f863e746 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4671,7 +4671,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) { - ACTION_PARAM_START(7); + ACTION_PARAM_START(8); ACTION_PARAM_INT(destination_selector, 0); ACTION_PARAM_FIXED(xofs, 1); @@ -4680,6 +4680,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) ACTION_PARAM_ANGLE(angle, 4); ACTION_PARAM_INT(flags, 5); ACTION_PARAM_STATE(success_state, 6); + ACTION_PARAM_FIXED(heightoffset,7) AActor *reference; @@ -4699,7 +4700,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) return; } - if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags)) + if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags, heightoffset)) { if (success_state) { diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 6885ad2d6..00476b502 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -249,7 +249,7 @@ ACTOR Actor native //: Thinker action native A_PlayerSkinCheck(state label); action native A_BasicAttack(int meleedamage, sound meleesound, class missiletype, float missileheight); action native A_Teleport(state teleportstate = "", class targettype = "BossSpot", class fogtype = "TeleportFog", int flags = 0, float mindist = 0, float maxdist = 0, int ptr = AAPTR_DEFAULT); - action native A_Warp(int ptr_destination, float xofs = 0, float yofs = 0, float zofs = 0, float angle = 0, int flags = 0, state success_state = ""); + action native A_Warp(int ptr_destination, float xofs = 0, float yofs = 0, float zofs = 0, float angle = 0, int flags = 0, state success_state = "", float heightoffset = 0); action native A_ThrowGrenade(class itemtype, float zheight = 0, float xyvel = 0, float zvel = 0, bool useammo = true); action native A_Weave(int xspeed, int yspeed, float xdist, float ydist); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 04ed6f1fc..a0c6f1f98 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -361,6 +361,8 @@ Const Int WARPF_ABSOLUTEPOSITION = 0x400; Const Int WARPF_BOB = 0x800; Const Int WARPF_MOVEPTR = 0x1000; Const Int WARPF_USETID = 0x2000; +Const Int WARPF_ADDHEIGHT = 0x4000; +Const Int WARPF_MULHEIGHT = 0x8000; // flags for A_SetPitch/SetAngle/SetRoll const int SPF_FORCECLAMP = 1; From 9cf8a2a26ca137196874763965dedb9a19584ea4 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 10 Aug 2015 12:20:42 -0500 Subject: [PATCH 2/6] - Missed a spot. --- src/p_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_things.cpp b/src/p_things.cpp index db80e35ca..6c8349a72 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -743,7 +743,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, // if there is no offset, there should be no ill effect from moving down to the already defined floor // A_Teleport does the same thing anyway - caller->z = caller->floorz; + caller->z = caller->floorz + height; } } else From 7e661dfe573c6101f7b0d215f12f5cd6d64f5c43 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 10 Aug 2015 12:41:40 -0500 Subject: [PATCH 3/6] - Clean up. --- src/p_things.cpp | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/p_things.cpp b/src/p_things.cpp index 6c8349a72..1467935d7 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -692,12 +692,16 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t oldx = caller->x; fixed_t oldy = caller->y; fixed_t oldz = caller->z; - fixed_t height = 0; + if (flags & WARPF_ADDHEIGHT) - height = reference->height + heightoffset; + { + zofs += reference->height + heightoffset; + } else if (flags & WARPF_MULHEIGHT) - height = FixedMul(reference->height, heightoffset); + { + zofs += FixedMul(reference->height, heightoffset); + } if (!(flags & WARPF_ABSOLUTEANGLE)) { @@ -725,44 +729,33 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller->SetOrigin( reference->x + xofs, reference->y + yofs, - reference->z + height); + reference->z); // now the caller's floorz should be appropriate for the assigned xy-position - // assigning position again with - - if (zofs) - { - // extra unlink, link and environment calculation - caller->SetOrigin( - caller->x, - caller->y, - caller->floorz + zofs + height); - } - else - { - // if there is no offset, there should be no ill effect from moving down to the already defined floor - - // A_Teleport does the same thing anyway - caller->z = caller->floorz + height; - } + // assigning position again with. + // extra unlink, link and environment calculation + caller->SetOrigin( + caller->x, + caller->y, + caller->floorz + zofs); } else { caller->SetOrigin( reference->x + xofs, reference->y + yofs, - reference->z + zofs + height); + reference->z + zofs); } } else // [MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's. { if (flags & WARPF_TOFLOOR) { - caller->SetOrigin(xofs, yofs, caller->floorz + zofs + height); + caller->SetOrigin(xofs, yofs, caller->floorz + zofs); } else { - caller->SetOrigin(xofs, yofs, zofs + height); + caller->SetOrigin(xofs, yofs, zofs); } } From 54af1e379edcc6a2f58034c06d0e406710adb570 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 10 Aug 2015 15:03:29 -0500 Subject: [PATCH 4/6] - Removed WARPF_MULHEIGHT. Enable its ability by default. - WARPF_ADDHEIGHT will simply change HeightOffset from multiplying to adding by default. --- src/p_local.h | 1 - src/p_things.cpp | 2 +- wadsrc/static/actors/constants.txt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 6022d8e8e..a457cd877 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -199,7 +199,6 @@ enum WARPF WARPF_USEPTR = 0x2000, WARPF_USETID = 0x2000, WARPF_ADDHEIGHT = 0x4000, - WARPF_MULHEIGHT = 0x8000, }; diff --git a/src/p_things.cpp b/src/p_things.cpp index 1467935d7..678608dc6 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -698,7 +698,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, { zofs += reference->height + heightoffset; } - else if (flags & WARPF_MULHEIGHT) + else { zofs += FixedMul(reference->height, heightoffset); } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index a0c6f1f98..b7baca73a 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -362,7 +362,6 @@ Const Int WARPF_BOB = 0x800; Const Int WARPF_MOVEPTR = 0x1000; Const Int WARPF_USETID = 0x2000; Const Int WARPF_ADDHEIGHT = 0x4000; -Const Int WARPF_MULHEIGHT = 0x8000; // flags for A_SetPitch/SetAngle/SetRoll const int SPF_FORCECLAMP = 1; From 87cc3f77f9c7eccd247448c131b57ad9871bab4f Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 10 Aug 2015 16:05:44 -0500 Subject: [PATCH 5/6] - Removed WARPF_ADDHEIGHT. --- src/p_local.h | 1 - src/p_things.cpp | 9 +-------- wadsrc/static/actors/constants.txt | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index a457cd877..a2fa00c71 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -198,7 +198,6 @@ enum WARPF WARPF_MOVEPTR = 0x1000, WARPF_USEPTR = 0x2000, WARPF_USETID = 0x2000, - WARPF_ADDHEIGHT = 0x4000, }; diff --git a/src/p_things.cpp b/src/p_things.cpp index 678608dc6..f9d85c43f 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -693,15 +693,8 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t oldy = caller->y; fixed_t oldz = caller->z; + zofs += FixedMul(reference->height, heightoffset); - if (flags & WARPF_ADDHEIGHT) - { - zofs += reference->height + heightoffset; - } - else - { - zofs += FixedMul(reference->height, heightoffset); - } if (!(flags & WARPF_ABSOLUTEANGLE)) { diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index b7baca73a..04ed6f1fc 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -361,7 +361,6 @@ Const Int WARPF_ABSOLUTEPOSITION = 0x400; Const Int WARPF_BOB = 0x800; Const Int WARPF_MOVEPTR = 0x1000; Const Int WARPF_USETID = 0x2000; -Const Int WARPF_ADDHEIGHT = 0x4000; // flags for A_SetPitch/SetAngle/SetRoll const int SPF_FORCECLAMP = 1; From ebf515f8c76ca32d2fd5fe9b70783987af5c12ca Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 25 Aug 2015 20:18:06 -0500 Subject: [PATCH 6/6] - Fixed unneeded dual call to SetOrigin. --- src/p_things.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/p_things.cpp b/src/p_things.cpp index f9d85c43f..b7e3f058b 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -718,19 +718,13 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, if (flags & WARPF_TOFLOOR) { // set correct xy - - caller->SetOrigin( - reference->x + xofs, - reference->y + yofs, - reference->z); - // now the caller's floorz should be appropriate for the assigned xy-position // assigning position again with. // extra unlink, link and environment calculation caller->SetOrigin( - caller->x, - caller->y, - caller->floorz + zofs); + reference->x + xofs, + reference->y + yofs, + reference->floorz + zofs); } else {