Merge branch 'starpost-config-additions' into 'next'

Starpost config additions

See merge request STJr/SRB2!680
This commit is contained in:
James R 2020-02-01 21:42:43 -05:00
commit 5a524f21da
4 changed files with 119 additions and 94 deletions

View File

@ -1428,98 +1428,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
// Misc touchables //
// *************** //
case MT_STARPOST:
if (player->bot)
return;
// In circuit, player must have touched all previous starposts
if (circuitmap
&& special->health - player->starpostnum > 1)
{
// blatant reuse of a variable that's normally unused in circuit
if (!player->tossdelay)
S_StartSound(toucher, sfx_lose);
player->tossdelay = 3;
return;
}
// We could technically have 91.1 Star Posts. 90 is cleaner.
if (special->health > 90)
{
CONS_Debug(DBG_GAMELOGIC, "Bad Starpost Number!\n");
return;
}
if (player->starpostnum >= special->health)
return; // Already hit this post
if (cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (netgame || multiplayer))
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
if (players[i].bot) // ignore dumb, stupid tails
continue;
players[i].starposttime = leveltime;
players[i].starpostx = player->mo->x>>FRACBITS;
players[i].starposty = player->mo->y>>FRACBITS;
players[i].starpostz = special->z>>FRACBITS;
players[i].starpostangle = special->angle;
players[i].starpostscale = player->mo->destscale;
if (special->flags2 & MF2_OBJECTFLIP)
{
players[i].starpostscale *= -1;
players[i].starpostz += special->height>>FRACBITS;
}
players[i].starpostnum = special->health;
if (cv_coopstarposts.value == 2 && (players[i].playerstate == PST_DEAD || players[i].spectator) && P_GetLives(&players[i]))
P_SpectatorJoinGame(&players[i]); //players[i].playerstate = PST_REBORN;
}
}
S_StartSound(NULL, special->info->painsound);
}
else
{
// Save the player's time and position.
player->starposttime = leveltime;
player->starpostx = toucher->x>>FRACBITS;
player->starposty = toucher->y>>FRACBITS;
player->starpostz = special->z>>FRACBITS;
player->starpostangle = special->angle;
player->starpostscale = player->mo->destscale;
if (special->flags2 & MF2_OBJECTFLIP)
{
player->starpostscale *= -1;
player->starpostz += special->height>>FRACBITS;
}
player->starpostnum = special->health;
S_StartSound(toucher, special->info->painsound);
}
P_ClearStarPost(special->health);
// Find all starposts in the level with this value - INCLUDING this one!
if (!(netgame && circuitmap && player != &players[consoleplayer]))
{
thinker_t *th;
mobj_t *mo2;
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_STARPOST)
continue;
if (mo2->health != special->health)
continue;
P_SetMobjState(mo2, mo2->info->painstate);
}
}
P_TouchStarPost(special, player, special->spawnpoint && (special->spawnpoint->options & MTF_OBJECTSPECIAL));
return;
case MT_FAKEMOBILE:
@ -1872,6 +1781,112 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->shadowscale = 0;
}
/** Saves a player's level progress at a star post
*
* \param post The star post to trigger
* \param player The player that should receive the checkpoint
* \param snaptopost If true, the respawn point will use the star post's position, otherwise player x/y and star post z
*/
void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost)
{
size_t i;
mobj_t *toucher = player->mo;
mobj_t *checkbase = snaptopost ? post : toucher;
if (player->bot)
return;
// In circuit, player must have touched all previous starposts
if (circuitmap
&& post->health - player->starpostnum > 1)
{
// blatant reuse of a variable that's normally unused in circuit
if (!player->tossdelay)
S_StartSound(toucher, sfx_lose);
player->tossdelay = 3;
return;
}
// With the parameter + angle setup, we can go up to 1365 star posts. Who needs that many?
if (post->health > 1365)
{
CONS_Debug(DBG_GAMELOGIC, "Bad Starpost Number!\n");
return;
}
if (player->starpostnum >= post->health)
return; // Already hit this post
if (cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (netgame || multiplayer))
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
if (players[i].bot) // ignore dumb, stupid tails
continue;
players[i].starposttime = leveltime;
players[i].starpostx = checkbase->x>>FRACBITS;
players[i].starposty = checkbase->y>>FRACBITS;
players[i].starpostz = post->z>>FRACBITS;
players[i].starpostangle = post->angle;
players[i].starpostscale = player->mo->destscale;
if (post->flags2 & MF2_OBJECTFLIP)
{
players[i].starpostscale *= -1;
players[i].starpostz += post->height>>FRACBITS;
}
players[i].starpostnum = post->health;
if (cv_coopstarposts.value == 2 && (players[i].playerstate == PST_DEAD || players[i].spectator) && P_GetLives(&players[i]))
P_SpectatorJoinGame(&players[i]); //players[i].playerstate = PST_REBORN;
}
}
S_StartSound(NULL, post->info->painsound);
}
else
{
// Save the player's time and position.
player->starposttime = leveltime;
player->starpostx = checkbase->x>>FRACBITS;
player->starposty = checkbase->y>>FRACBITS;
player->starpostz = post->z>>FRACBITS;
player->starpostangle = post->angle;
player->starpostscale = player->mo->destscale;
if (post->flags2 & MF2_OBJECTFLIP)
{
player->starpostscale *= -1;
player->starpostz += post->height>>FRACBITS;
}
player->starpostnum = post->health;
S_StartSound(toucher, post->info->painsound);
}
P_ClearStarPost(post->health);
// Find all starposts in the level with this value - INCLUDING this one!
if (!(netgame && circuitmap && player != &players[consoleplayer]))
{
thinker_t *th;
mobj_t *mo2;
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_STARPOST)
continue;
if (mo2->health != post->health)
continue;
P_SetMobjState(mo2, mo2->info->painstate);
}
}
}
/** Prints death messages relating to a dying or hit player.
*
* \param player Affected player.

View File

@ -486,6 +486,7 @@ void P_PlayerWeaponPanelOrAmmoBurst(player_t *player);
void P_PlayerEmeraldBurst(player_t *player, boolean toss);
void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck);
void P_TouchStarPost(mobj_t *starpost, player_t *player, boolean snaptopost);
void P_PlayerFlagBurst(player_t *player, boolean toss);
void P_CheckTimeLimit(void);
void P_CheckPointLimit(void);

View File

@ -12935,7 +12935,16 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
thinker_t* th;
mobj_t* mo2;
boolean foundanother = false;
mobj->health = (mthing->angle/360) + 1;
if (mthing->extrainfo)
// Allow thing Parameter to define star post num too!
// For starposts above param 15 (the 16th), add 360 to the angle like before and start parameter from 1 (NOT 0)!
// So the 16th starpost is angle=0 param=15, the 17th would be angle=360 param=1.
// This seems more intuitive for mappers to use until UDMF is ready, since most SP maps won't have over 16 consecutive star posts.
mobj->health = mthing->extrainfo + (mthing->angle/360)*15 + 1;
else
// Old behavior if Parameter is 0; add 360 to the angle for each consecutive star post.
mobj->health = (mthing->angle/360) + 1;
// See if other starposts exist in this level that have the same value.
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)

View File

@ -4692,7 +4692,7 @@ DoneSection2:
if (!post)
break;
P_TouchSpecialThing(post, player->mo, false);
P_TouchStarPost(post, player, false);
break;
}