Add player_t marelap and marebonuslap, with logic

This commit is contained in:
mazmazz 2018-03-30 14:36:49 -04:00
parent 01f1e7fc33
commit 637a4a8446
6 changed files with 29 additions and 5 deletions

View File

@ -455,6 +455,8 @@ 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

View File

@ -288,6 +288,10 @@ 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"))
@ -564,6 +568,10 @@ 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"))

View File

@ -905,24 +905,31 @@ 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->anotherflyangle >= 90 && pl->anotherflyangle <= 270)
^ (droneobj->extravalue1 >= 90 && droneobj->extravalue1 <= 270)
))
{
// Reload all the fancy ring stuff!
P_ReloadRings();
pl->marelap++;
if (pl->bonustime)
{
pl->marebonuslap++;
// Respawn rings and items
P_ReloadRings();
}
}
droneobj->extravalue1 = pl->anotherflyangle;
droneobj->extravalue2 = (INT32)leveltime + TICRATE;

View File

@ -197,6 +197,8 @@ 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);
@ -384,6 +386,8 @@ 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);

View File

@ -2350,6 +2350,7 @@ static void P_LevelInitStuff(void)
players[i].linkcount = players[i].linktimer = 0;
players[i].flyangle = players[i].anotherflyangle = 0;
players[i].nightstime = players[i].mare = 0;
players[i].marelap = 0; players[i].marebonuslap = 0;
P_SetTarget(&players[i].capsule, NULL);
players[i].drillmeter = 40*20;

View File

@ -399,6 +399,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