Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBF21 Skillsaw Codepointers #41

Merged
merged 10 commits into from
May 9, 2021
9 changes: 9 additions & 0 deletions prboom2/src/d_deh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,10 +1494,19 @@ static const deh_bexptr deh_bexptrs[] = // CPhipps - static const
{A_MonsterBulletAttack, "A_MonsterBulletAttack", 5, {0, 0, 1, 3, 5}},
{A_MonsterMeleeAttack, "A_MonsterMeleeAttack", 4, {3, 8, 0, MELEERANGE}},
{A_RadiusDamage, "A_RadiusDamage", 2},
{A_NoiseAlert, "A_NoiseAlert", 0},
{A_HealChase, "A_HealChase", 2},
{A_JumpIfHealthBelow, "A_JumpIfHealthBelow", 2},
{A_JumpIfTargetInSight, "A_JumpIfTargetInSight", 1},
{A_JumpIfTargetCloser, "A_JumpIfTargetCloser", 2},
{A_JumpIfFlagsSet, "A_JumpIfFlagsSet", 2},
{A_AddFlags, "A_AddFlags", 1},
{A_RemoveFlags, "A_RemoveFlags", 1},
{A_WeaponProjectile, "A_WeaponProjectile", 5},
{A_WeaponBulletAttack, "A_WeaponBulletAttack", 5, {0, 0, 1, 5, 3}},
{A_WeaponMeleeAttack, "A_WeaponMeleeAttack", 5, {2, 10, 1 * FRACUNIT, 0, MELEERANGE}},
{A_WeaponSound, "A_WeaponSound", 2},
{A_WeaponAlert, "A_WeaponAlert", 0},
{A_WeaponJump, "A_WeaponJump", 2},
{A_ConsumeAmmo, "A_ConsumeAmmo", 1},
{A_CheckAmmo, "A_CheckAmmo", 2},
Expand Down
173 changes: 166 additions & 7 deletions prboom2/src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ mobj_t* corpsehit;
mobj_t* vileobj;
fixed_t viletryx;
fixed_t viletryy;
int viletryradius;

static dboolean PIT_VileCheck(mobj_t *thing)
{
Expand All @@ -1756,7 +1757,7 @@ static dboolean PIT_VileCheck(mobj_t *thing)
if (thing->info->raisestate == g_s_null)
return true; // monster doesn't have a raise state

maxdist = thing->info->radius + mobjinfo[MT_VILE].radius;
maxdist = thing->info->radius + viletryradius;

if (D_abs(thing->x-viletryx) > maxdist || D_abs(thing->y-viletryy) > maxdist)
return true; // not actually touching
Expand Down Expand Up @@ -1802,11 +1803,11 @@ static dboolean PIT_VileCheck(mobj_t *thing)
}

//
// A_VileChase
// P_HealCorpse
// Check for ressurecting a body
//

void A_VileChase(mobj_t* actor)
static dboolean P_HealCorpse(mobj_t* actor, int radius, statenum_t healstate, sfxenum_t healsound)
{
int xl, xh;
int yl, yh;
Expand All @@ -1826,6 +1827,7 @@ void A_VileChase(mobj_t* actor)
yh = P_GetSafeBlockY(viletryy - bmaporgy + MAXRADIUS*2);

vileobj = actor;
viletryradius = radius;
for (bx=xl ; bx<=xh ; bx++)
{
for (by=yl ; by<=yh ; by++)
Expand All @@ -1843,8 +1845,8 @@ void A_VileChase(mobj_t* actor)
A_FaceTarget(actor);
actor->target = temp;

P_SetMobjState(actor, S_VILE_HEAL1);
S_StartSound(corpsehit, sfx_slop);
P_SetMobjState(actor, healstate);
S_StartSound(corpsehit, healsound);
info = corpsehit->info;

P_SetMobjState(corpsehit,info->raisestate);
Expand Down Expand Up @@ -1881,12 +1883,22 @@ void A_VileChase(mobj_t* actor)
/* killough 8/29/98: add to appropriate thread */
P_UpdateThinker(&corpsehit->thinker);

return;
return true;
}
}
}
}
A_Chase(actor); // Return to normal attack.
return false;
}

//
// A_VileChase
//

void A_VileChase(mobj_t* actor)
{
if (!P_HealCorpse(actor, mobjinfo[MT_VILE].radius, S_VILE_HEAL1, sfx_slop))
A_Chase(actor); // Return to normal attack.
}

//
Expand Down Expand Up @@ -3198,6 +3210,153 @@ void A_RadiusDamage(mobj_t *actor)
P_RadiusAttack(actor, actor->target, actor->state->args[0], actor->state->args[1]);
}

//
// A_NoiseAlert
// Alerts nearby monsters (via sound) to the calling actor's target's presence.
//
void A_NoiseAlert(mobj_t *actor)
{
if (!mbf21 || !actor->target)
return;

P_NoiseAlert(actor->target, actor);
}

//
// A_HealChase
// A parameterized version of A_VileChase.
// args[0]: State to jump to on the calling actor when resurrecting a corpse
// args[1]: Sound to play when resurrecting a corpse
//
void A_HealChase(mobj_t* actor)
{
int state, sound;

if (!mbf21 || !actor)
return;

state = actor->state->args[0];
sound = actor->state->args[1];

if (!P_HealCorpse(actor, actor->info->radius, state, sound))
A_Chase(actor);
}

//
// A_JumpIfHealthBelow
// Jumps to a state if caller's health is below the specified threshold.
// args[0]: State to jump to
// args[1]: Health threshold
//
void A_JumpIfHealthBelow(mobj_t* actor)
{
int state, health;

if (!mbf21 || !actor)
return;

state = actor->state->args[0];
health = actor->state->args[1];

if (actor->health < health)
P_SetMobjState(actor, state);
}

//
// A_JumpIfTargetInSight
// Jumps to a state if caller's target is in line-of-sight.
// args[0]: State to jump to
//
void A_JumpIfTargetInSight(mobj_t* actor)
{
int state;

if (!mbf21 || !actor)
return;

state = actor->state->args[0];

if (P_CheckSight(actor, actor->target))
P_SetMobjState(actor, state);
}

//
// A_JumpIfTargetCloser
// Jumps to a state if caller's target is closer than the specified distance.
// args[0]: State to jump to
// args[1]: Distance threshold
//
void A_JumpIfTargetCloser(mobj_t* actor)
{
int state, distance;

if (!mbf21 || !actor)
return;

state = actor->state->args[0];
distance = actor->state->args[1];

if (distance > P_AproxDistance(actor->x - actor->target->x,
actor->y - actor->target->y))
P_SetMobjState(actor, state);
}

//
// A_JumpIfFlagsSet
// Jumps to a state if caller has the specified thing flags set.
// args[0]: State to jump to
// args[1]: Flag(s) to check
//
void A_JumpIfFlagsSet(mobj_t* actor)
{
int state;
unsigned int flags;

if (!mbf21 || !actor)
return;

state = actor->state->args[0];
flags = actor->state->args[1];

if (actor->flags & flags)
kraflab marked this conversation as resolved.
Show resolved Hide resolved
P_SetMobjState(actor, state);
}

//
// A_AddFlags
// Adds the specified thing flags to the caller.
// args[0]: Flag(s) to add
//
void A_AddFlags(mobj_t* actor)
{
unsigned int flags;

if (!mbf21 || !actor)
return;

flags = actor->state->args[0];

actor->flags |= flags;
}

//
// A_RemoveFlags
// Removes the specified thing flags to the caller.
// args[0]: Flag(s) to add
//
void A_RemoveFlags(mobj_t* actor)
{
unsigned int flags;

if (!mbf21 || !actor)
return;

flags = actor->state->args[0];

actor->flags &= ~flags;
}



// heretic

Expand Down
8 changes: 8 additions & 0 deletions prboom2/src/p_enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ void A_MonsterProjectile(mobj_t *);
void A_MonsterBulletAttack(mobj_t *);
void A_MonsterMeleeAttack(mobj_t *);
void A_RadiusDamage(mobj_t *);
void A_NoiseAlert(mobj_t *);
void A_HealChase(mobj_t *);
void A_JumpIfHealthBelow(mobj_t *);
void A_JumpIfTargetInSight(mobj_t *);
void A_JumpIfTargetCloser(mobj_t *);
void A_JumpIfFlagsSet(mobj_t *);
void A_AddFlags(mobj_t *);
void A_RemoveFlags(mobj_t *);

// heretic

Expand Down
14 changes: 14 additions & 0 deletions prboom2/src/p_pspr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,20 @@ void A_WeaponSound(player_t *player, pspdef_t *psp)
S_StartSound(psp->state->args[1] ? NULL : player->mo, psp->state->args[0]);
}

//
// A_WeaponAlert
// Alerts monsters to the player's presence. Handy when combined with WPF_SILENT.
//
void A_WeaponAlert(player_t *player, pspdef_t *psp)
{
CHECK_WEAPON_CODEPOINTER("A_WeaponAlert", player);

if (!mbf21)
return;

P_NoiseAlert(player->mo, player->mo);
}

//
// A_WeaponJump
// Jumps to the specified state, with variable random chance.
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/p_pspr.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void A_WeaponProjectile();
void A_WeaponBulletAttack();
void A_WeaponMeleeAttack();
void A_WeaponSound();
void A_WeaponAlert();
void A_WeaponJump();
void A_ConsumeAmmo();
void A_CheckAmmo();
Expand Down