hardcoded A_DoNPCPain

This commit is contained in:
Monster Iestyn 2019-05-02 18:32:43 +01:00
parent 75701294ea
commit 3bbc5d0b08
3 changed files with 60 additions and 0 deletions

View file

@ -2225,6 +2225,7 @@ static actionpointer_t actionpointers[] =
{{A_ParentTriesToSleep}, "A_PARENTTRIESTOSLEEP"}, {{A_ParentTriesToSleep}, "A_PARENTTRIESTOSLEEP"},
{{A_CryingToMomma}, "A_CRYINGTOMOMMA"}, {{A_CryingToMomma}, "A_CRYINGTOMOMMA"},
{{A_CheckFlags2}, "A_CHECKFLAGS2"}, {{A_CheckFlags2}, "A_CHECKFLAGS2"},
{{A_DoNPCPain}, "A_DONPCPAIN"},
{{NULL}, "NONE"}, {{NULL}, "NONE"},

View file

@ -239,6 +239,7 @@ void A_WhoCaresIfYourSonIsABee();
void A_ParentTriesToSleep(); void A_ParentTriesToSleep();
void A_CryingToMomma(); void A_CryingToMomma();
void A_CheckFlags2(); void A_CheckFlags2();
void A_DoNPCPain();
// ratio of states to sprites to mobj types is roughly 6 : 1 : 1 // ratio of states to sprites to mobj types is roughly 6 : 1 : 1
#define NUMMOBJFREESLOTS 256 #define NUMMOBJFREESLOTS 256

View file

@ -266,6 +266,7 @@ void A_WhoCaresIfYourSonIsABee(mobj_t *actor);
void A_ParentTriesToSleep(mobj_t *actor); void A_ParentTriesToSleep(mobj_t *actor);
void A_CryingToMomma(mobj_t *actor); void A_CryingToMomma(mobj_t *actor);
void A_CheckFlags2(mobj_t *actor); void A_CheckFlags2(mobj_t *actor);
void A_DoNPCPain(mobj_t *actor);
//for p_enemy.c //for p_enemy.c
// //
@ -11852,3 +11853,60 @@ void A_CheckFlags2(mobj_t *actor)
if (actor->flags2 & locvar1) if (actor->flags2 & locvar1)
P_SetMobjState(actor, (statenum_t)locvar2); P_SetMobjState(actor, (statenum_t)locvar2);
} }
// Function: A_DoNPCPain
//
// Description: Something that looks like a player was hit, put them in pain.
//
// var1 = If zero, always fling the same amount.
// Otherwise, slowly reduce the vertical
// and horizontal speed to the base value
// multiplied by this the more damage is done.
// var2 = If zero, use default fling values.
// Otherwise, vertical and horizontal speed
// will be multiplied by this.
//
void A_DoNPCPain(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
fixed_t vspeed = 0;
fixed_t hspeed = FixedMul(4*FRACUNIT, actor->scale);
#ifdef HAVE_BLUA
if (LUA_CallAction("A_DoNPCPain", actor))
return;
#endif
actor->flags &= ~(MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT);
var1 = var2 = 0;
A_Pain(actor);
actor->z += P_MobjFlip(actor);
if (actor->eflags & MFE_UNDERWATER)
vspeed = FixedDiv(10511*FRACUNIT,2600*FRACUNIT);
else
vspeed = FixedDiv(69*FRACUNIT,10*FRACUNIT);
if (actor->target)
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x + actor->target->momx, actor->target->y + actor->target->momy);
if (locvar1)
{
if (actor->info->spawnhealth)
return; // there's something very wrong here if you're using this action on something with no starting health
locvar1 += ((FRACUNIT - locvar1)/actor->info->spawnhealth)*actor->health;
hspeed = FixedMul(hspeed, locvar1);
vspeed = FixedMul(vspeed, locvar1);
}
if (locvar2)
{
hspeed = FixedMul(hspeed, locvar2);
vspeed = FixedMul(vspeed, locvar2);
}
P_SetObjectMomZ(actor, vspeed, false);
P_InstaThrust(actor, actor->angle, -hspeed);
}