From 2b12db153bd95518aa1f4533402c1f54280805fe Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Mon, 5 Jan 2015 17:51:32 +0800 Subject: [PATCH] New functions to manipulate an actor's roll. - DECORATE functions: A_SetRoll code pointer. - DECORATE expressions: "roll" variable. - ACS functions: SetActorRoll, GetActorRoll. --- src/actor.h | 1 + src/p_acs.cpp | 44 ++++++++++++++++++++++++++++ src/p_mobj.cpp | 12 ++++++++ src/thingdef/thingdef_codeptr.cpp | 16 ++++++++++ src/thingdef/thingdef_expression.cpp | 1 + wadsrc/static/actors/actor.txt | 2 ++ wadsrc/static/actors/constants.txt | 2 +- 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/actor.h b/src/actor.h index bc6e830f0..0ab589107 100644 --- a/src/actor.h +++ b/src/actor.h @@ -785,6 +785,7 @@ public: // These also set CF_INTERPVIEW for players. void SetPitch(int p, bool interpolate); void SetAngle(angle_t ang, bool interpolate); + void SetRoll(angle_t roll, bool interpolate); const PClass *GetBloodType(int type = 0) const { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2ea64f26e..4b9a8bbab 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4440,6 +4440,9 @@ enum EACSFunctions ACSF_CanRaiseActor, ACSF_SetActorTeleFog, // 86 ACSF_SwapActorTeleFog, + ACSF_SetActorRoll, + ACSF_ChangeActorRoll, + ACSF_GetActorRoll, /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -4751,6 +4754,27 @@ static void SetActorPitch(AActor *activator, int tid, int angle, bool interpolat } } +static void SetActorRoll(AActor *activator, int tid, int angle, bool interpolate) +{ + if (tid == 0) + { + if (activator != NULL) + { + activator->SetRoll(angle << 16, interpolate); + } + } + else + { + FActorIterator iterator(tid); + AActor *actor; + + while ((actor = iterator.Next())) + { + actor->SetRoll(angle << 16, interpolate); + } + } +} + static void SetActorTeleFog(AActor *activator, int tid, FName telefogsrc, FName telefogdest) { //Simply put, if it doesn't exist, it won't change. One can use "" in this scenario. @@ -5832,6 +5856,26 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) } break; + // [Nash] Actor roll functions. Let's roll! + case ACSF_SetActorRoll: + actor = SingleActorFromTID(args[0], activator); + if (actor != NULL) + { + actor->SetRoll(args[1] << 16, false); + } + return 0; + + case ACSF_ChangeActorRoll: + if (argCount >= 2) + { + SetActorRoll(activator, args[0], args[1], argCount > 2 ? !!args[2] : false); + } + break; + + case ACSF_GetActorRoll: + actor = SingleActorFromTID(args[0], activator); + return actor != NULL? actor->roll >> 16 : 0; + default: break; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6a035933d..09f84663a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3077,6 +3077,18 @@ void AActor::SetAngle(angle_t ang, bool interpolate) } } +void AActor::SetRoll(angle_t r, bool interpolate) +{ + if (r != roll) + { + roll = r; + if (player != NULL && interpolate) + { + player->cheats |= CF_INTERPVIEW; + } + } +} + // // P_MobjThinker // diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 9554a3c25..980ff88a9 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3973,6 +3973,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) self->SetPitch(pitch, !!(flags & SPF_INTERPOLATE)); } +//=========================================================================== +// +// [Nash] A_SetRoll +// +// Set actor's roll (in degrees). +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_ANGLE(roll, 0); + ACTION_PARAM_INT(flags, 1); + self->SetRoll(roll, !!(flags & SPF_INTERPOLATE)); +} + //=========================================================================== // // A_ScaleVelocity diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index d1c2eba9e..08b261bbf 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -89,6 +89,7 @@ DEFINE_MEMBER_VARIABLE(radius, AActor) DEFINE_MEMBER_VARIABLE(reactiontime, AActor) DEFINE_MEMBER_VARIABLE(meleerange, AActor) DEFINE_MEMBER_VARIABLE(Speed, AActor) +DEFINE_MEMBER_VARIABLE(roll, AActor) //========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8b1cf6a65..a1e6b275b 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -68,6 +68,7 @@ ACTOR Actor native //: Thinker native int reactiontime; native fixed_t meleerange; native fixed_t speed; + native angle_t roll; // Meh, MBF redundant functions. Only for DeHackEd support. action native A_Turn(float angle = 0); @@ -290,6 +291,7 @@ ACTOR Actor native //: Thinker action native A_MonsterRefire(int chance, state label); action native A_SetAngle(float angle = 0, int flags = 0); action native A_SetPitch(float pitch, int flags = 0); + action native A_SetRoll(float roll, int flags = 0); action native A_ScaleVelocity(float scale); action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0); action native A_SetArg(int pos, int value); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index e8ba15d46..9b872df52 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -346,7 +346,7 @@ Const Int WARPF_TESTONLY = 0x200; Const Int WAPRF_ABSOLUTEPOSITION = 0x400; Const Int WARPF_ABSOLUTEPOSITION = 0x400; -// flags for A_SetPitch/SetAngle +// flags for A_SetPitch/SetAngle/SetRoll const int SPF_FORCECLAMP = 1; const int SPF_INTERPOLATE = 2;