Skip to content

Commit

Permalink
New functions to manipulate an actor's roll.
Browse files Browse the repository at this point in the history
- DECORATE functions: A_SetRoll code pointer.
- DECORATE expressions: "roll" variable.
- ACS functions: SetActorRoll, GetActorRoll.
  • Loading branch information
nashmuhandes committed Jan 5, 2015
1 parent f03e05d commit 2b12db1
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/actor.h
Expand Up @@ -785,6 +785,7 @@ class AActor : public DThinker
// 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
{
Expand Down
44 changes: 44 additions & 0 deletions src/p_acs.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions src/p_mobj.cpp
Expand Up @@ -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
//
Expand Down
16 changes: 16 additions & 0 deletions src/thingdef/thingdef_codeptr.cpp
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/thingdef/thingdef_expression.cpp
Expand Up @@ -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)


//==========================================================================
Expand Down
2 changes: 2 additions & 0 deletions wadsrc/static/actors/actor.txt
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/actors/constants.txt
Expand Up @@ -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;

Expand Down

0 comments on commit 2b12db1

Please sign in to comment.