From bd4496a582dbbc21c15fd8ff1ee47b931567cc84 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 30 Jun 2009 21:24:29 +0000 Subject: [PATCH] - Added A_SetAngle, A_SetPitch, A_ScaleVelocity, and A_ChangeVelocity. SVN r1691 (trunk) --- docs/rh-log.txt | 1 + src/thingdef/thingdef_codeptr.cpp | 102 ++++++++++++++++++++++++++++- wadsrc/static/actors/actor.txt | 4 ++ wadsrc/static/actors/constants.txt | 4 ++ 4 files changed, 110 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4956a4362..e17e6ddfb 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ June 30, 2009 +- Added A_SetAngle, A_SetPitch, A_ScaleVelocity, and A_ChangeVelocity. - Enough with this "momentum" garbage. What Doom calls "momentum" is really velocity, and now it's known as such. The actor variables momx/momy/momz are now known as velx/vely/velz, and the ACS functions GetActorMomX/Y/Z diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 67f11a101..1f09dc94f 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2533,7 +2533,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveChildren) //=========================================================================== // -// keep firing unless target got out of sight +// A_MonsterRefire +// +// Keep firing unless target got out of sight // //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire) @@ -2557,3 +2559,101 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire) } } +//=========================================================================== +// +// A_SetAngle +// +// Set actor's angle (in degrees). +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_ANGLE(angle, 0); + self->angle = angle; +} + +//=========================================================================== +// +// A_SetPitch +// +// Set actor's pitch (in degrees). +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_ANGLE(pitch, 0); + self->pitch = pitch; +} + +//=========================================================================== +// +// A_ScaleVelocity +// +// Scale actor's velocity. +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(scale, 0); + + INTBOOL was_moving = self->velx | self->vely | self->velz; + + self->velx = FixedMul(self->velx, scale); + self->vely = FixedMul(self->vely, scale); + self->velz = FixedMul(self->velz, scale); + + // If the actor was previously moving but now is not, and is a player, + // update its player variables. (See A_Stop.) + if (was_moving && + self->player != NULL && + self->player->mo == self && + !(self->player->cheats & CF_PREDICTING) && + !(self->velx | self->vely | self->velz)) + { + self->player->mo->PlayIdle(); + self->player->velx = self->player->vely = 0; + } +} + +//=========================================================================== +// +// A_ChangeVelocity +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) +{ + ACTION_PARAM_START(4); + ACTION_PARAM_FIXED(x, 0); + ACTION_PARAM_FIXED(y, 1); + ACTION_PARAM_FIXED(z, 2); + ACTION_PARAM_INT(flags, 3); + + fixed_t vx = x, vy = y, vz = z; + fixed_t sina = finesine[self->angle >> ANGLETOFINESHIFT]; + fixed_t cosa = finecosine[self->angle >> ANGLETOFINESHIFT]; + + if (flags & 1) // relative axes - make x, y relative to actor's current angle + { + vx = DMulScale16(x, cosa, -y, sina); + vy = DMulScale16(x, sina, y, cosa); + } + if (flags & 2) // discard old velocity - replace old velocity with new velocity + { + self->velx = vx; + self->vely = vy; + self->velz = vz; + } + else // add new velocity to old velocity + { + self->velx += vx; + self->vely += vy; + self->velz += vz; + } +} diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index dcd3c1fa6..fde7daf41 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -241,6 +241,10 @@ ACTOR Actor native //: Thinker action native A_DropWeaponPieces(class p1, class p2, class p3); action native A_PigPain (); action native A_MonsterRefire(int chance, state label); + action native A_SetAngle(float angle); + action native A_SetPitch(float pitch); + action native A_ScaleVelocity(float scale); + action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0); States { diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 388344618..fb81d297e 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -33,6 +33,10 @@ const int LOF_DONTCHASEGOAL = 4; const int LOF_NOSEESOUND = 8; const int LOF_FULLVOLSEESOUND = 16; +// Flags for A_ChangeVelocity +const int CVF_RELATIVE = 1; +const int CVF_REPLACE = 2; + // Morph constants const int MRF_ADDSTAMINA = 1; const int MRF_FULLHEALTH = 2;