Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
- added custom boss death actions.
Browse files Browse the repository at this point in the history
These work roughly like MBF's A_LineEffect, but are a bit more thorough about what is allowed and avoid hacking the first player to trigger the action.
For the definition it uses the same class names as ZDoom because that is the closest to a naming standard there is.
  • Loading branch information
coelckers committed Apr 22, 2017
1 parent df223d2 commit b461e26
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 34 deletions.
54 changes: 51 additions & 3 deletions prboom2/src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ static dboolean P_Move(mobj_t *actor, dboolean dropoff) /* killough 9/12/98 */
*/

for (good = false; numspechit--; )
if (P_UseSpecialLine(actor, spechit[numspechit], 0))
if (P_UseSpecialLine(actor, spechit[numspechit], 0, false))
good |= spechit[numspechit] == blockline ? 1 : 2;

/* cph - compatibility maze here
Expand Down Expand Up @@ -2223,6 +2223,54 @@ void A_BossDeath(mobj_t *mo)
line_t junk;
int i;

// numbossactions == 0 means to use the defaults.
// numbossactions == -1 means to do nothing.
// positive values mean to check the list of boss actions and run all that apply.
if (gamemapinfo && gamemapinfo->numbossactions != 0)
{
if (gamemapinfo->numbossactions < 0) return;

// make sure there is a player alive for victory
for (i=0; i<MAXPLAYERS; i++)
if (playeringame[i] && players[i].health > 0)
break;

if (i==MAXPLAYERS)
return; // no one left alive, so do not end game

for (i = 0; i < gamemapinfo->numbossactions; i++)
{
if (gamemapinfo->bossactions[i].type == mo->type)
break;
}
if (i >= gamemapinfo->numbossactions)
return; // no matches found

// scan the remaining thinkers to see
// if all bosses are dead
for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
if (th->function == P_MobjThinker)
{
mobj_t *mo2 = (mobj_t *) th;
if (mo2 != mo && mo2->type == mo->type && mo2->health > 0)
return; // other boss not dead
}
for (i = 0; i < gamemapinfo->numbossactions; i++)
{
if (gamemapinfo->bossactions[i].type == mo->type)
{
junk = *lines;
junk.special = (short)gamemapinfo->bossactions[i].special;
junk.tag = (short)gamemapinfo->bossactions[i].tag;
// use special semantics for line activation to block problem types.
if (!P_UseSpecialLine(mo, &junk, 0, true))
P_CrossSpecialLine(&junk, 0, mo, true);
}
}

return;
}

if (gamemode == commercial)
{
if (gamemap != 7)
Expand Down Expand Up @@ -2773,8 +2821,8 @@ void A_LineEffect(mobj_t *mo)
if (!junk.special)
return;
junk.tag = (short)mo->state->misc2;
if (!P_UseSpecialLine(mo, &junk, 0))
P_CrossSpecialLine(&junk, 0, mo);
if (!P_UseSpecialLine(mo, &junk, 0, false))
P_CrossSpecialLine(&junk, 0, mo, false);
mo->state->misc1 = junk.special;
mo->player = oldplayer;
}
4 changes: 2 additions & 2 deletions prboom2/src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ dboolean P_TryMove(mobj_t* thing,fixed_t x,fixed_t y,
int oldside;
if ((oldside = P_PointOnLineSide(oldx, oldy, spechit[numspechit])) !=
P_PointOnLineSide(thing->x, thing->y, spechit[numspechit]))
P_CrossSpecialLine(spechit[numspechit], oldside, thing);
P_CrossSpecialLine(spechit[numspechit], oldside, thing, false);
}

return true;
Expand Down Expand Up @@ -1789,7 +1789,7 @@ dboolean PTR_UseTraverse (intercept_t* in)

// return false; // don't use back side

P_UseSpecialLine (usething, in->d.line, side);
P_UseSpecialLine (usething, in->d.line, side, false);

//WAS can't use for than one special line in a row
//jff 3/21/98 NOW multiple use allowed with enabling line flag
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static dboolean CheckForIdentifier(int lumpnum, const byte *id, size_t length)
{
dboolean result = false;

if (W_LumpLength(lumpnum) >= length)
if (W_LumpLength(lumpnum) >= (int)length)
{
const char *data = W_CacheLumpNum(lumpnum);

Expand Down
31 changes: 17 additions & 14 deletions prboom2/src/p_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ dboolean PUREFUNC P_WasSecret(const sector_t *sec)
// crossed. Change is qualified by demo_compatibility.
//
// CPhipps - take a line_t pointer instead of a line number, as in MBF
void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing, dboolean bossaction)
{
int ok;

Expand All @@ -1237,7 +1237,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else
{
if (!thing->player)
if (!thing->player && !bossaction)
{
// Things that should NOT trigger specials...
switch(thing->type)
Expand Down Expand Up @@ -1270,7 +1270,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenFloorBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if ((line->special & FloorChange) || !(line->special & FloorModel))
return; // FloorModel is "Allow Monsters" if FloorChange is 0
if (!comperr(comperr_zerotag) && !line->tag) //e6y //jff 2/27/98 all walk generalized types require tag
Expand All @@ -1279,7 +1279,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenCeilingBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if ((line->special & CeilingChange) || !(line->special & CeilingModel))
return; // CeilingModel is "Allow Monsters" if CeilingChange is 0
if (!comperr(comperr_zerotag) && !line->tag) //e6y //jff 2/27/98 all walk generalized types require tag
Expand All @@ -1288,7 +1288,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenDoorBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
{
if (!(line->special & DoorMonster))
return; // monsters disallowed from this door
Expand All @@ -1301,7 +1301,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenLockedBase)
{
if (!thing->player)
if (!thing->player || bossaction) // boss actions can't handle locked doors
return; // monsters disallowed from unlocking doors
if (((line->special&TriggerType)==WalkOnce) || ((line->special&TriggerType)==WalkMany))
{ //jff 4/1/98 check for being a walk type before reporting door type
Expand All @@ -1314,7 +1314,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenLiftBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if (!(line->special & LiftMonster))
return; // monsters disallowed
if (!comperr(comperr_zerotag) && !line->tag) //e6y //jff 2/27/98 all walk generalized types require tag
Expand All @@ -1323,7 +1323,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
else if ((unsigned)line->special >= GenStairsBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if (!(line->special & StairMonster))
return; // monsters disallowed
if (!comperr(comperr_zerotag) && !line->tag) //e6y //jff 2/27/98 all walk generalized types require tag
Expand All @@ -1346,18 +1346,16 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
}
}

if (!thing->player)
if (!thing->player || bossaction)
{
ok = 0;
switch(line->special)
{
// teleporters are blocked for boss actions.
case 39: // teleport trigger
case 97: // teleport retrigger
case 125: // teleport monsteronly trigger
case 126: // teleport monsteronly retrigger
case 4: // raise door
case 10: // plat down-wait-up-stay trigger
case 88: // plat down-wait-up-stay retrigger
//jff 3/5/98 add ability of monsters etc. to use teleporters
case 208: //silent thing teleporters
case 207:
Expand All @@ -1371,6 +1369,11 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
case 267:
case 268:
case 269:
if (bossaction) return;

case 4: // raise door
case 10: // plat down-wait-up-stay trigger
case 88: // plat down-wait-up-stay retrigger
ok = 1;
break;
}
Expand Down Expand Up @@ -1531,7 +1534,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
case 52:
// EXIT!
// killough 10/98: prevent zombies from exiting levels
if (!(thing->player && thing->player->health <= 0 && !comp[comp_zombie]))
if (bossaction || (!(thing->player && thing->player->health <= 0 && !comp[comp_zombie])))
G_ExitLevel ();
break;

Expand Down Expand Up @@ -1617,7 +1620,7 @@ void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing)
// Secret EXIT
// killough 10/98: prevent zombies from exiting levels
// CPhipps - change for lxdoom's compatibility handling
if (!(thing->player && thing->player->health <= 0 && !comp[comp_zombie]))
if (bossaction || (!(thing->player && thing->player->health <= 0 && !comp[comp_zombie])))
G_SecretExitLevel ();
break;

Expand Down
5 changes: 3 additions & 2 deletions prboom2/src/p_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,14 @@ void P_UpdateSpecials
dboolean P_UseSpecialLine
( mobj_t* thing,
line_t* line,
int side );
int side,
dboolean noplayercheck);

void P_ShootSpecialLine
( mobj_t* thing,
line_t* line );

void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing);
void P_CrossSpecialLine(line_t *line, int side, mobj_t *thing, dboolean noplayercheck);

void P_PlayerInSpecialSector
( player_t* player );
Expand Down
52 changes: 41 additions & 11 deletions prboom2/src/p_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ dboolean
P_UseSpecialLine
( mobj_t* thing,
line_t* line,
int side )
int side,
dboolean bossaction)
{

// e6y
Expand All @@ -285,7 +286,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenFloorBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if ((line->special & FloorChange) || !(line->special & FloorModel))
return false; // FloorModel is "Allow Monsters" if FloorChange is 0
if (!comperr(comperr_zerotag) && !line->tag && ((line->special&6)!=6)) //e6y //jff 2/27/98 all non-manual
Expand All @@ -294,7 +295,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenCeilingBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if ((line->special & CeilingChange) || !(line->special & CeilingModel))
return false; // CeilingModel is "Allow Monsters" if CeilingChange is 0
if (!comperr(comperr_zerotag) && !line->tag && ((line->special&6)!=6)) //e6y //jff 2/27/98 all non-manual
Expand All @@ -303,7 +304,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenDoorBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
{
if (!(line->special & DoorMonster))
return false; // monsters disallowed from this door
Expand All @@ -316,7 +317,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenLockedBase)
{
if (!thing->player)
if (!thing->player || bossaction)
return false; // monsters disallowed from unlocking doors
if (!P_CanUnlockGenDoor(line,thing->player))
return false;
Expand All @@ -327,7 +328,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenLiftBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if (!(line->special & LiftMonster))
return false; // monsters disallowed
if (!comperr(comperr_zerotag) && !line->tag && ((line->special&6)!=6)) //e6y //jff 2/27/98 all non-manual
Expand All @@ -336,7 +337,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenStairsBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if (!(line->special & StairMonster))
return false; // monsters disallowed
if (!comperr(comperr_zerotag) && !line->tag && ((line->special&6)!=6)) //e6y //jff 2/27/98 all non-manual
Expand All @@ -345,7 +346,7 @@ P_UseSpecialLine
}
else if ((unsigned)line->special >= GenCrusherBase)
{
if (!thing->player)
if (!thing->player && !bossaction)
if (!(line->special & CrusherMonster))
return false; // monsters disallowed
if (!comperr(comperr_zerotag) && !line->tag && ((line->special&6)!=6)) //e6y //jff 2/27/98 all non-manual
Expand Down Expand Up @@ -379,7 +380,7 @@ P_UseSpecialLine
}

// Switches that other things can activate.
if (!thing->player)
if (!thing->player && !bossaction)
{
// never open secret doors
if (line->flags & ML_SECRET)
Expand All @@ -404,6 +405,35 @@ P_UseSpecialLine
}
}

if (bossaction)
{
switch(line->special)
{
// 0-tag specials, locked switches and teleporters need to be blocked for boss actions.
case 1: // MANUAL DOOR RAISE
case 32: // MANUAL BLUE
case 33: // MANUAL RED
case 34: // MANUAL YELLOW
case 117: // Blazing door raise
case 118: // Blazing door open
case 133: // BlzOpenDoor BLUE
case 135: // BlzOpenDoor RED
case 137: // BlzOpenDoor YEL

case 99: // BlzOpenDoor BLUE
case 134: // BlzOpenDoor RED
case 136: // BlzOpenDoor YELLOW

//jff 3/5/98 add ability to use teleporters for monsters
case 195: // switch teleporters
case 174:
case 210: // silent switch teleporters
case 209:
return false;
break;
}
}

if (!P_CheckTag(line)) //jff 2/27/98 disallow zero tag on some types
return false;

Expand Down Expand Up @@ -443,7 +473,7 @@ P_UseSpecialLine
/* Exit level
* killough 10/98: prevent zombies from exiting levels
*/
if (thing->player && thing->player->health <= 0 && !comp[comp_zombie])
if (!bossaction && thing->player && thing->player->health <= 0 && !comp[comp_zombie])
{
S_StartSound(thing, sfx_noway);
return false;
Expand Down Expand Up @@ -523,7 +553,7 @@ P_UseSpecialLine
/* Secret EXIT
* killough 10/98: prevent zombies from exiting levels
*/
if (thing->player && thing->player->health <= 0 && !comp[comp_zombie])
if (!bossaction && thing->player && thing->player->health <= 0 && !comp[comp_zombie])
{
S_StartSound(thing, sfx_noway);
return false;
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void S_Start(void)

if (gamemapinfo && gamemapinfo->music[0])
{
int muslump = W_CheckNumForName(gamemapinfo->music, ns_global);
int muslump = W_CheckNumForName(gamemapinfo->music);
if (muslump >= 0)
{
S_ChangeMusInfoMusic(muslump, true);
Expand Down
Loading

0 comments on commit b461e26

Please sign in to comment.