Merge branch 'nightsplus-laplogic' into 'master'

NiGHTS: Track player mare lap variables

See merge request STJr/SRB2Internal!143
This commit is contained in:
Digiku 2018-08-29 10:58:05 -04:00
commit 900cbf72c8
8 changed files with 106 additions and 10 deletions

View File

@ -456,16 +456,25 @@ typedef struct player_s
boolean bonustime; // Capsule destroyed, now it's bonus time!
mobj_t *capsule; // Go inside the capsule
UINT8 mare; // Current mare
UINT8 marelap; // Current mare lap
UINT8 marebonuslap; // Current mare lap starting from bonus time
// Statistical purposes.
tic_t marebegunat; // Leveltime when mare begun
tic_t startedtime; // Time which you started this mare with.
tic_t finishedtime; // Time it took you to finish the mare (used for display)
tic_t lapbegunat; // Leveltime when lap begun
tic_t lapstartedtime; // Time which you started this lap with.
INT16 finishedspheres; // The spheres you had left upon finishing the mare
INT16 finishedrings; // The rings/stars you had left upon finishing the mare
UINT32 marescore; // score for this nights stage
UINT32 lastmarescore; // score for the last mare
UINT32 totalmarescore; // score for all mares
UINT8 lastmare; // previous mare
UINT8 lastmarelap; // previous mare lap
UINT8 lastmarebonuslap; // previous mare bonus lap
UINT8 totalmarelap; // total mare lap
UINT8 totalmarebonuslap; // total mare bonus lap
INT32 maxlink; // maximum link obtained
UINT8 texttimer; // nights_texttime should not be local
UINT8 textvar; // which line of NiGHTS text to show -- let's not use cheap hacks

View File

@ -2230,6 +2230,8 @@ void G_PlayerReborn(INT32 player)
if (p->mare == 255)
p->mare = 0;
p->marelap = p->marebonuslap = 0;
// Check to make sure their color didn't change somehow...
if (G_GametypeHasTeams())
{

View File

@ -290,12 +290,20 @@ static int player_get(lua_State *L)
LUA_PushUserdata(L, plr->capsule, META_MOBJ);
else if (fastcmp(field,"mare"))
lua_pushinteger(L, plr->mare);
else if (fastcmp(field,"marelap"))
lua_pushinteger(L, plr->marelap);
else if (fastcmp(field,"marebonuslap"))
lua_pushinteger(L, plr->marebonuslap);
else if (fastcmp(field,"marebegunat"))
lua_pushinteger(L, plr->marebegunat);
else if (fastcmp(field,"startedtime"))
lua_pushinteger(L, plr->startedtime);
else if (fastcmp(field,"finishedtime"))
lua_pushinteger(L, plr->finishedtime);
else if (fastcmp(field,"lapbegunat"))
lua_pushinteger(L, plr->lapbegunat);
else if (fastcmp(field,"lapstartedtime"))
lua_pushinteger(L, plr->lapstartedtime);
else if (fastcmp(field,"finishedspheres"))
lua_pushinteger(L, plr->finishedspheres);
else if (fastcmp(field,"finishedrings"))
@ -304,8 +312,18 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->marescore);
else if (fastcmp(field,"lastmarescore"))
lua_pushinteger(L, plr->lastmarescore);
else if (fastcmp(field,"totalmarescore"))
lua_pushinteger(L, plr->totalmarescore);
else if (fastcmp(field,"lastmare"))
lua_pushinteger(L, plr->lastmare);
else if (fastcmp(field,"lastmarelap"))
lua_pushinteger(L, plr->lastmarelap);
else if (fastcmp(field,"lastmarebonuslap"))
lua_pushinteger(L, plr->lastmarebonuslap);
else if (fastcmp(field,"totalmarelap"))
lua_pushinteger(L, plr->totalmarelap);
else if (fastcmp(field,"totalmarebonuslap"))
lua_pushinteger(L, plr->totalmarebonuslap);
else if (fastcmp(field,"maxlink"))
lua_pushinteger(L, plr->maxlink);
else if (fastcmp(field,"texttimer"))
@ -570,12 +588,20 @@ static int player_set(lua_State *L)
}
else if (fastcmp(field,"mare"))
plr->mare = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"marelap"))
plr->marelap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"marebonuslap"))
plr->marebonuslap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"marebegunat"))
plr->marebegunat = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"startedtime"))
plr->startedtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"finishedtime"))
plr->finishedtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lapbegunat"))
plr->lapbegunat = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lapstartedtime"))
plr->lapstartedtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"finishedspheres"))
plr->finishedspheres = (INT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"finishedrings"))
@ -584,8 +610,18 @@ static int player_set(lua_State *L)
plr->marescore = (UINT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastmarescore"))
plr->lastmarescore = (UINT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"totalmarescore"))
plr->totalmarescore = (UINT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastmare"))
plr->lastmare = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastmarelap"))
plr->lastmarelap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastmarebonuslap"))
plr->lastmarebonuslap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"totalmarelap"))
plr->totalmarelap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"totalmarebonuslap"))
plr->totalmarebonuslap = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"maxlink"))
plr->maxlink = (INT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"texttimer"))

View File

@ -1128,6 +1128,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{
player->nightstime += special->info->speed;
player->startedtime += special->info->speed;
player->lapstartedtime += special->info->speed;
P_RestoreMusic(player);
}
else
@ -1137,6 +1138,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{
players[i].nightstime += special->info->speed;
players[i].startedtime += special->info->speed;
players[i].lapstartedtime += special->info->speed;
P_RestoreMusic(&players[i]);
}
if (special->info->deathsound != sfx_None)

View File

@ -1097,24 +1097,35 @@ static boolean PIT_CheckThing(mobj_t *thing)
P_SetTarget(&thing->target, tmthing);
}
// Respawn rings and items
// NiGHTS lap logic
if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE)
&& (tmthing->player || thing->player))
{
mobj_t *droneobj = (tmthing->type == MT_NIGHTSDRONE) ? tmthing : thing;
player_t *pl = (droneobj == thing) ? tmthing->player : thing->player;
// Must be in bonus time, and must be NiGHTS, must wait about a second
// Must be NiGHTS, must wait about a second
// must be flying in the SAME DIRECTION as the last time you came through.
// not (your direction) xor (stored direction)
// In other words, you can't u-turn and respawn rings near the drone.
if (pl->bonustime && (pl->powers[pw_carry] == CR_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && (
if ((pl->powers[pw_carry] == CR_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && (
!(pl->flyangle > 90 && pl->flyangle < 270)
^ (droneobj->extravalue1 > 90 && droneobj->extravalue1 < 270)
))
{
// Reload all the fancy ring stuff!
P_ReloadRings();
pl->marelap++;
pl->totalmarelap++;
pl->lapbegunat = leveltime;
pl->lapstartedtime = pl->nightstime;
if (pl->bonustime)
{
pl->marebonuslap++;
pl->totalmarebonuslap++;
// Respawn rings and items
P_ReloadRings();
}
}
droneobj->extravalue1 = pl->flyangle;
droneobj->extravalue2 = (INT32)leveltime + TICRATE;

View File

@ -198,15 +198,24 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].drilldelay);
WRITEUINT8(save_p, players[i].bonustime);
WRITEUINT8(save_p, players[i].mare);
WRITEUINT8(save_p, players[i].marelap);
WRITEUINT8(save_p, players[i].marebonuslap);
WRITEUINT32(save_p, players[i].marebegunat);
WRITEUINT32(save_p, players[i].startedtime);
WRITEUINT32(save_p, players[i].finishedtime);
WRITEUINT32(save_p, players[i].lapbegunat);
WRITEUINT32(save_p, players[i].lapstartedtime);
WRITEINT16(save_p, players[i].finishedspheres);
WRITEINT16(save_p, players[i].finishedrings);
WRITEUINT32(save_p, players[i].marescore);
WRITEUINT32(save_p, players[i].lastmarescore);
WRITEUINT32(save_p, players[i].totalmarescore);
WRITEUINT8(save_p, players[i].lastmare);
WRITEUINT8(save_p, players[i].lastmarelap);
WRITEUINT8(save_p, players[i].lastmarebonuslap);
WRITEUINT8(save_p, players[i].totalmarelap);
WRITEUINT8(save_p, players[i].totalmarebonuslap);
WRITEINT32(save_p, players[i].maxlink);
WRITEUINT8(save_p, players[i].texttimer);
WRITEUINT8(save_p, players[i].textvar);
@ -387,15 +396,24 @@ static void P_NetUnArchivePlayers(void)
players[i].drilldelay = READUINT8(save_p);
players[i].bonustime = (boolean)READUINT8(save_p);
players[i].mare = READUINT8(save_p);
players[i].marelap = READUINT8(save_p);
players[i].marebonuslap = READUINT8(save_p);
players[i].marebegunat = READUINT32(save_p);
players[i].startedtime = READUINT32(save_p);
players[i].finishedtime = READUINT32(save_p);
players[i].lapbegunat = READUINT32(save_p);
players[i].lapstartedtime = READUINT32(save_p);
players[i].finishedspheres = READINT16(save_p);
players[i].finishedrings = READINT16(save_p);
players[i].marescore = READUINT32(save_p);
players[i].lastmarescore = READUINT32(save_p);
players[i].totalmarescore = READUINT32(save_p);
players[i].lastmare = READUINT8(save_p);
players[i].lastmarelap = READUINT8(save_p);
players[i].lastmarebonuslap = READUINT8(save_p);
players[i].totalmarelap = READUINT8(save_p);
players[i].totalmarebonuslap = READUINT8(save_p);
players[i].maxlink = READINT32(save_p);
players[i].texttimer = READUINT8(save_p);
players[i].textvar = READUINT8(save_p);

View File

@ -2382,12 +2382,16 @@ static void P_LevelInitStuff(void)
players[i].maxlink = players[i].startedtime =\
players[i].finishedtime = players[i].finishedspheres =\
players[i].finishedrings = players[i].lastmare =\
players[i].lastmarelap = players[i].lastmarebonuslap =\
players[i].totalmarelap = players[i].totalmarebonuslap =\
players[i].marebegunat = players[i].textvar =\
players[i].texttimer = players[i].linkcount =\
players[i].linktimer = players[i].flyangle =\
players[i].anotherflyangle = players[i].nightstime =\
players[i].mare = players[i].realtime =\
players[i].exiting = 0;
players[i].mare = players[i].marelap =\
players[i].marebonuslap = players[i].lapbegunat =\
players[i].lapstartedtime = players[i].totalmarescore =\
players[i].realtime = players[i].exiting = 0;
// i guess this could be part of the above but i feel mildly uncomfortable implicitly casting
players[i].gotcontinue = false;

View File

@ -387,6 +387,8 @@ boolean P_TransferToNextMare(player_t *player)
CONS_Debug(DBG_NIGHTS, "Mare is %d\n", mare);
player->mare = mare;
player->marelap = 0;
player->marebonuslap = 0;
// scan the thinkers
// to find the closest axis point
@ -574,6 +576,8 @@ static void P_DeNightserizePlayer(player_t *player)
player->climbing = 0;
player->mo->fuse = 0;
player->speed = 0;
player->marelap = 0;
player->marebonuslap = 0;
player->flyangle = 0;
player->anotherflyangle = 0;
P_SetTarget(&player->mo->target, NULL);
@ -635,7 +639,7 @@ static void P_DeNightserizePlayer(player_t *player)
// NiGHTS Time!
void P_NightserizePlayer(player_t *player, INT32 nighttime)
{
INT32 oldmare;
UINT8 oldmare, oldmarelap, oldmarebonuslap;
// Bots can't be NiGHTSerized, silly!1 :P
if (player->bot)
@ -666,7 +670,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
player->followitem = skins[DEFAULTNIGHTSSKIN].followitem;
}
player->nightstime = player->startedtime = nighttime*TICRATE;
player->nightstime = player->startedtime = player->lapstartedtime = nighttime*TICRATE;
player->bonustime = false;
P_RestoreMusic(player);
@ -684,6 +688,8 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
}
oldmare = player->mare;
oldmarelap = player->marelap;
oldmarebonuslap = player->marebonuslap;
if (!P_TransferToNextMare(player))
{
@ -711,6 +717,8 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
players[i].texttimer = (3 * TICRATE) - 10;
players[i].textvar = 4; // Score and grades
players[i].lastmare = players[i].mare;
players[i].lastmarelap = players[i].marelap;
players[i].lastmarebonuslap = players[i].marebonuslap;
if (G_IsSpecialStage(gamemap))
{
players[i].finishedspheres = (INT16)total_spheres;
@ -729,6 +737,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
G_AddTempNightsRecords(players[i].marescore, leveltime - player->marebegunat, players[i].mare + 1);
// transfer scores anyway
players[i].totalmarescore += players[i].marescore;
players[i].lastmarescore = players[i].marescore;
players[i].marescore = 0;
@ -742,19 +751,24 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
// Spheres bonus
P_AddPlayerScore(player, (player->spheres) * 50);
player->lastmare = (UINT8)oldmare;
player->lastmare = oldmare;
player->lastmarelap = oldmarelap;
player->lastmarebonuslap = oldmarebonuslap;
player->texttimer = 4*TICRATE;
player->textvar = 4; // Score and grades
player->finishedspheres = (INT16)(player->spheres);
player->finishedrings = (INT16)(player->rings);
// Add score to temp leaderboards
if (!(netgame||multiplayer) && P_IsLocalPlayer(player))
G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1));
// Starting a new mare, transfer scores
player->totalmarescore += player->marescore;
player->lastmarescore = player->marescore;
player->marescore = 0;
player->marebegunat = leveltime;
player->lapbegunat = leveltime;
player->spheres = player->rings = 0;
}