Audience-related functions: Rename + adjust

- Since they're not necessarily going to be randomised, make the prefix Obj_Audience instead of Obj_RandomAudience.
- Externalise some properties that we may not want affecting all hypothetical uses.
    - Flag auto-application should be done externally, since this won't be general.
    - Focusing on player should be controlled by the function call, not an ambiguous flag.
This commit is contained in:
toaster 2023-04-21 15:09:07 +01:00
parent d7547edf05
commit 1e5fadc901
3 changed files with 23 additions and 20 deletions

View file

@ -115,8 +115,8 @@ void Obj_RingShooterDelete(mobj_t *mo);
void Obj_UpdateRingShooterFace(mobj_t *part);
/* Follower Audience */
void Obj_RandomAudienceInit(mobj_t * mobj, mapthing_t *mthing);
void Obj_RandomAudienceThink(mobj_t * mobj);
void Obj_AudienceInit(mobj_t * mobj, mapthing_t *mthing, INT32 followerpick);
void Obj_AudienceThink(mobj_t * mobj, boolean focusonplayer);
#ifdef __cplusplus
} // extern "C"

View file

@ -21,20 +21,21 @@
#define audience_focusdelay(o) ((o)->movecount)
void
Obj_RandomAudienceInit
Obj_AudienceInit
( mobj_t * mobj,
mapthing_t *mthing)
mapthing_t *mthing,
INT32 followerpick)
{
UINT16 *reflist = NULL;
UINT16 tempreflist[MAXHEADERFOLLOWERS];
UINT8 numref = 0;
INT32 followerpick = 0;
P_SetScale(mobj, (mobj->destscale *= 3));
audience_mainstate(mobj) = S_NULL;
// Pick follower
if (mthing != NULL)
{
if (mthing->stringargs[0] != NULL)
{
@ -92,16 +93,6 @@ Obj_RandomAudienceInit
if (P_MobjWasRemoved(mobj))
return;
if (mthing->args[2] != 0)
{
mobj->flags |= MF_NOGRAVITY;
}
if (mthing->args[3] != 0)
{
mobj->flags2 |= MF2_AMBUSH;
}
// The following is derived from the default bobamp
if (!(mobj->flags & MF_NOGRAVITY) && followers[followerpick].bobamp < 4*FRACUNIT)
{
@ -122,6 +113,7 @@ Obj_RandomAudienceInit
}
// Handle colors
if (mthing != NULL)
{
UINT16 colorpick = SKINCOLOR_NONE;
@ -168,8 +160,9 @@ Obj_RandomAudienceInit
}
void
Obj_RandomAudienceThink
( mobj_t * mobj)
Obj_AudienceThink
( mobj_t * mobj,
boolean focusonplayer)
{
if (audience_mainstate(mobj) == S_NULL)
{
@ -177,7 +170,7 @@ Obj_RandomAudienceThink
return;
}
if (mobj->flags2 & MF2_AMBUSH)
if (focusonplayer == true)
{
if (audience_focusdelay(mobj) == 0)
{

View file

@ -10269,7 +10269,7 @@ void P_SceneryThinker(mobj_t *mobj)
if (mobj->type == MT_RANDOMAUDIENCE)
{
Obj_RandomAudienceThink(mobj);
Obj_AudienceThink(mobj, !!(mobj->flags2 & MF2_AMBUSH));
}
}
@ -13154,7 +13154,17 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
}
case MT_RANDOMAUDIENCE:
{
Obj_RandomAudienceInit(mobj, mthing);
if (mthing->args[2] != 0)
{
mobj->flags |= MF_NOGRAVITY;
}
if (mthing->args[3] != 0)
{
mobj->flags2 |= MF2_AMBUSH;
}
Obj_AudienceInit(mobj, mthing, -1);
if (P_MobjWasRemoved(mobj))
return false;