- Redid A_SetHealth.

- This function will not take the actor's health below 1, and any attempts to do so will simply set it to 1 in its place.
This commit is contained in:
MajorCooke 2015-01-20 22:54:30 -06:00
parent 845bcdf14c
commit 4fd87a1ce9
2 changed files with 39 additions and 1 deletions

View file

@ -5656,7 +5656,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SwapTeleFog)
//
// A_SetFloatBobPhase
//
// Changes the FloatBobPhase of the
// Changes the FloatBobPhase of the actor.
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatBobPhase)
@ -5669,6 +5669,43 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatBobPhase)
self->FloatBobPhase = bob;
}
//===========================================================================
// A_SetHealth
//
// Changes the health of the actor.
// Takes a pointer as well.
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetHealth)
{
ACTION_PARAM_START(2);
ACTION_PARAM_INT(health, 0);
ACTION_PARAM_INT(ptr, 1);
AActor *mobj = COPY_AAPTR(self, ptr);
if (!mobj)
{
return;
}
player_t *player = mobj->player;
if (player)
{
if (health <= 0)
player->mo->health = mobj->health = player->health = 1; //Copied from the buddha cheat.
else
player->mo->health = mobj->health = player->health = health;
}
else if (mobj)
{
if (health <= 0)
mobj->health = 1;
else
mobj->health = health;
}
}
//===========================================================================
//
// A_SetRipperLevel(int level)

View file

@ -327,6 +327,7 @@ ACTOR Actor native //: Thinker
action native A_SetTeleFog(name oldpos, name newpos);
action native A_SwapTeleFog();
action native A_SetFloatBobPhase(int bob);
action native A_SetHealth(int health, int ptr = AAPTR_DEFAULT);
action native A_SetRipperLevel(int level);
action native A_SetRipMin(int min);
action native A_SetRipMax(int max);