- Added A_ResetHealth(ptr). Defaults to AAPTR_DEFAULT (the action caller).

- Added pointers to the following functions, all of them set to AAPTR_DEFAULT:
- A_SetAngle
- A_SetPitch
- A_SetScale
- A_SetSpeed
- A_ScaleVelocity
This commit is contained in:
MajorCooke 2015-01-23 09:26:34 -06:00
parent 7157db89b7
commit 19b43d4752
2 changed files with 100 additions and 24 deletions

View File

@ -2504,12 +2504,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeTo)
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetScale)
{
ACTION_PARAM_START(2);
ACTION_PARAM_START(3);
ACTION_PARAM_FIXED(scalex, 0);
ACTION_PARAM_FIXED(scaley, 1);
ACTION_PARAM_INT(ptr, 2);
self->scaleX = scalex;
self->scaleY = scaley ? scaley : scalex;
AActor *ref = COPY_AAPTR(self, ptr);
if (!ref)
{
ACTION_SET_RESULT(false);
return;
}
ref->scaleX = scalex;
ref->scaleY = scaley ? scaley : scalex;
}
//===========================================================================
@ -3934,10 +3943,19 @@ enum
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle)
{
ACTION_PARAM_START(2);
ACTION_PARAM_START(3);
ACTION_PARAM_ANGLE(angle, 0);
ACTION_PARAM_INT(flags, 1)
self->SetAngle(angle, !!(flags & SPF_INTERPOLATE));
ACTION_PARAM_INT(flags, 1);
ACTION_PARAM_INT(ptr, 2);
AActor *ref = COPY_AAPTR(self, ptr);
if (!ref)
{
ACTION_SET_RESULT(false);
return;
}
ref->SetAngle(angle, !!(flags & SPF_INTERPOLATE));
}
//===========================================================================
@ -3950,18 +3968,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch)
{
ACTION_PARAM_START(2);
ACTION_PARAM_START(3);
ACTION_PARAM_ANGLE(pitch, 0);
ACTION_PARAM_INT(flags, 1);
ACTION_PARAM_INT(ptr, 2);
if (self->player != NULL || (flags & SPF_FORCECLAMP))
AActor *ref = COPY_AAPTR(self, ptr);
if (!ref)
{
ACTION_SET_RESULT(false);
return;
}
if (ref->player != NULL || (flags & SPF_FORCECLAMP))
{ // clamp the pitch we set
int min, max;
if (self->player != NULL)
if (ref->player != NULL)
{
min = self->player->MinPitch;
max = self->player->MaxPitch;
min = ref->player->MinPitch;
max = ref->player->MaxPitch;
}
else
{
@ -3970,7 +3997,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch)
}
pitch = clamp<int>(pitch, min, max);
}
self->SetPitch(pitch, !!(flags & SPF_INTERPOLATE));
ref->SetPitch(pitch, !!(flags & SPF_INTERPOLATE));
}
//===========================================================================
@ -3999,20 +4026,29 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity)
{
ACTION_PARAM_START(1);
ACTION_PARAM_START(2);
ACTION_PARAM_FIXED(scale, 0);
ACTION_PARAM_INT(ptr, 1);
AActor *ref = COPY_AAPTR(self, ptr);
if (!ref)
{
ACTION_SET_RESULT(false);
return;
}
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);
ref->velx = FixedMul(ref->velx, scale);
ref->vely = FixedMul(ref->vely, scale);
ref->velz = FixedMul(ref->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)
{
CheckStopped(self);
CheckStopped(ref);
}
}
@ -5073,10 +5109,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropItem)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed)
{
ACTION_PARAM_START(1);
ACTION_PARAM_START(2);
ACTION_PARAM_FIXED(speed, 0);
ACTION_PARAM_INT(ptr, 1);
AActor *ref = COPY_AAPTR(self, ptr);
if (!ref)
{
ACTION_SET_RESULT(false);
return;
}
self->Speed = speed;
ref->Speed = speed;
}
static bool DoCheckSpecies(AActor *mo, FName species, bool exclude)
@ -5715,6 +5760,36 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetHealth)
}
}
//===========================================================================
// A_ResetHealth
//
// Resets the health of the actor to default, except if their dead.
// Takes a pointer.
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth)
{
ACTION_PARAM_START(1);
ACTION_PARAM_INT(ptr, 0);
AActor *mobj = COPY_AAPTR(self, ptr);
if (!mobj)
{
return;
}
player_t *player = mobj->player;
if (player && (player->mo->health > 0))
{
player->health = player->mo->health = player->mo->GetDefault()->health; //Copied from the resurrect cheat.
}
else if (mobj && (mobj->health > 0))
{
mobj->health = mobj->GetDefault()->health;
}
}
//===========================================================================
//
// A_SetRipperLevel(int level)

View File

@ -231,7 +231,7 @@ ACTOR Actor native //: Thinker
action native A_FadeIn(float reduce = 0.1, int flags = 0);
action native A_FadeOut(float reduce = 0.1, int flags = 1); //bool remove == true
action native A_FadeTo(float target, float amount = 0.1, int flags = 0);
action native A_SetScale(float scalex, float scaley = 0);
action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT);
action native A_SetMass(int mass);
action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1);
action native A_CheckSight(state label);
@ -289,10 +289,10 @@ ACTOR Actor native //: Thinker
action native A_DropWeaponPieces(class<Actor> p1, class<Actor> p2, class<Actor> p3);
action native A_PigPain ();
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_SetAngle(float angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
action native A_SetPitch(float pitch, int flags = 0, int ptr = AAPTR_DEFAULT);
action native A_SetRoll(float roll, int flags = 0);
action native A_ScaleVelocity(float scale);
action native A_ScaleVelocity(float scale, int ptr = AAPTR_DEFAULT);
action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
action native A_SetArg(int pos, int value);
action native A_SetUserVar(name varname, int value);
@ -302,7 +302,7 @@ ACTOR Actor native //: Thinker
action native A_SetTics(int tics);
action native A_SetDamageType(name damagetype);
action native A_DropItem(class<Actor> item, int dropamount = -1, int chance = 256);
action native A_SetSpeed(float speed);
action native A_SetSpeed(float speed, int ptr = AAPTR_DEFAULT);
action native A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
@ -328,6 +328,7 @@ ACTOR Actor native //: Thinker
action native A_SwapTeleFog();
action native A_SetFloatBobPhase(int bob);
action native A_SetHealth(int health, int ptr = AAPTR_DEFAULT);
action native A_ResetHealth(int ptr = AAPTR_DEFAULT);
action native A_SetRipperLevel(int level);
action native A_SetRipMin(int min);
action native A_SetRipMax(int max);