Add P_SetPower; remove mobj hack from line 434

This commit is contained in:
James R 2022-02-01 03:51:01 -08:00
parent 9dfa153e74
commit 6325185091
4 changed files with 28 additions and 20 deletions

View file

@ -4179,7 +4179,6 @@ void A_CustomPower(mobj_t *actor)
player_t *player;
INT32 locvar1 = var1;
INT32 locvar2 = var2;
boolean spawnshield = false;
if (LUA_CallAction(A_CUSTOMPOWER, actor))
return;
@ -4198,15 +4197,10 @@ void A_CustomPower(mobj_t *actor)
player = actor->target->player;
if (locvar1 == pw_shield && player->powers[pw_shield] != locvar2)
spawnshield = true;
P_SetPower(player, locvar1, locvar2);
player->powers[locvar1] = (UINT16)locvar2;
if (actor->info->seesound)
S_StartSound(player->mo, actor->info->seesound);
if (spawnshield) //workaround for a bug
P_SpawnShieldOrb(player);
}
// Function: A_GiveWeapon

View file

@ -155,6 +155,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff);
void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative);
void P_RestoreMusic(player_t *player);
void P_SetPower(player_t *player, powertype_t power, UINT16 value);
void P_SpawnShieldOrb(player_t *player);
void P_SwitchShield(player_t *player, UINT16 shieldtype);
mobj_t *P_SpawnGhostMobj(mobj_t *mobj);

View file

@ -2888,25 +2888,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 434: // Custom Power
if (mo && mo->player)
{
mobj_t *dummy = P_SpawnMobj(mo->x, mo->y, mo->z, MT_NULL);
var1 = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1;
powertype_t power = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1;
UINT16 value;
if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef
var2 = sides[line->sidenum[1]].toptexture;
value = sides[line->sidenum[1]].toptexture;
else if (line->flags & ML_NOCLIMB) // 'Infinite'
var2 = UINT16_MAX;
value = UINT16_MAX;
else
var2 = sides[line->sidenum[0]].textureoffset>>FRACBITS;
value = sides[line->sidenum[0]].textureoffset>>FRACBITS;
P_SetTarget(&dummy->target, mo);
A_CustomPower(dummy);
P_SetPower(mo->player, power, value);
if (bot) {
P_SetTarget(&dummy->target, bot);
A_CustomPower(dummy);
}
P_RemoveMobj(dummy);
if (bot)
P_SetPower(bot->player, power, value);
}
break;

View file

@ -2011,6 +2011,24 @@ void P_SwitchShield(player_t *player, UINT16 shieldtype)
}
}
//
// P_SetPower
//
// Sets a power and spawns a shield orb if required.
//
void P_SetPower(player_t *player, powertype_t power, UINT16 value)
{
boolean spawnshield = false;
if (power == pw_shield && player->powers[pw_shield] != value)
spawnshield = true;
player->powers[power] = value;
if (spawnshield) //workaround for a bug
P_SpawnShieldOrb(player);
}
//
// P_SpawnGhostMobj
//