From 32c17b145441726a1ed2a5e2c98d5d48e802892b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 10 Aug 2018 19:25:49 -0400 Subject: [PATCH] Basic implementation for player position correction to Drone center * player->drone mobj variable * P_MoveNiGHTSToDrone, will change later --- src/d_player.h | 1 + src/lua_playerlib.c | 9 +++++++++ src/p_inter.c | 1 + src/p_saveg.c | 17 +++++++++++++++++ src/p_setup.c | 2 +- src/p_user.c | 21 +++++++++++++++++++++ 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index 7bee5f337..91cafa515 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -455,6 +455,7 @@ typedef struct player_s UINT8 drilldelay; boolean bonustime; // Capsule destroyed, now it's bonus time! mobj_t *capsule; // Go inside the capsule + mobj_t *drone; // Move center to the drone UINT8 mare; // Current mare // Statistical purposes. diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index ff62f2459..4fdf25fad 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -288,6 +288,8 @@ static int player_get(lua_State *L) lua_pushboolean(L, plr->bonustime); else if (fastcmp(field,"capsule")) LUA_PushUserdata(L, plr->capsule, META_MOBJ); + else if (fastcmp(field,"drone")) + LUA_PushUserdata(L, plr->drone, META_MOBJ); else if (fastcmp(field,"mare")) lua_pushinteger(L, plr->mare); else if (fastcmp(field,"marebegunat")) @@ -568,6 +570,13 @@ static int player_set(lua_State *L) mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); P_SetTarget(&plr->capsule, mo); } + else if (fastcmp(field,"drone")) + { + mobj_t *mo = NULL; + if (!lua_isnil(L, 3)) + mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&plr->drone, mo); + } else if (fastcmp(field,"mare")) plr->mare = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"marebegunat")) diff --git a/src/p_inter.c b/src/p_inter.c index ce8bba6b6..688dc685d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -794,6 +794,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(netgame || multiplayer) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) P_SetTarget(&special->tracer, toucher); P_NightserizePlayer(player, special->health); // Transform! + P_SetTarget(&player->drone, special); // Mark the player as 'center into the drone' if (!spec) { if (toucher->tracer) // Move the ideya over to the drone! diff --git a/src/p_saveg.c b/src/p_saveg.c index 7cf437384..699b57a5c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -57,6 +57,7 @@ typedef enum FIRSTAXIS = 0x10, SECONDAXIS = 0x20, FOLLOW = 0x40, + DRONE = 0x80, } player_saveflags; // @@ -226,6 +227,9 @@ static void P_NetArchivePlayers(void) if (players[i].followmobj) flags |= FOLLOW; + if (players[i].drone) + flags |= DRONE; + WRITEINT16(save_p, players[i].lastsidehit); WRITEINT16(save_p, players[i].lastlinehit); @@ -254,6 +258,9 @@ static void P_NetArchivePlayers(void) if (flags & FOLLOW) WRITEUINT32(save_p, players[i].followmobj->mobjnum); + if (flags & DRONE) + WRITEUINT32(save_p, players[i].drone->mobjnum); + WRITEFIXED(save_p, players[i].camerascale); WRITEFIXED(save_p, players[i].shieldscale); @@ -428,6 +435,9 @@ static void P_NetUnArchivePlayers(void) if (flags & FOLLOW) players[i].followmobj = (mobj_t *)(size_t)READUINT32(save_p); + if (flags & DRONE) + players[i].drone = (mobj_t *)(size_t)READUINT32(save_p); + players[i].camerascale = READFIXED(save_p); players[i].shieldscale = READFIXED(save_p); @@ -3099,6 +3109,13 @@ static void P_RelinkPointers(void) if (!P_SetTarget(&mobj->player->followmobj, P_FindNewPosition(temp))) CONS_Debug(DBG_GAMELOGIC, "followmobj not found on %d\n", mobj->type); } + if (mobj->player && mobj->player->drone) + { + temp = (UINT32)(size_t)mobj->player->drone; + mobj->player->drone = NULL; + if (!P_SetTarget(&mobj->player->drone, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "drone not found on %d\n", mobj->type); + } } } } diff --git a/src/p_setup.c b/src/p_setup.c index c62f281b3..7e8d0fdb1 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2401,7 +2401,7 @@ static void P_LevelInitStuff(void) // unset ALL the pointers. P_SetTarget isn't needed here because if this // function is being called we're just going to clobber the data anyways players[i].mo = players[i].followmobj = players[i].awayviewmobj =\ - players[i].capsule = players[i].axis1 = players[i].axis2 = NULL; + players[i].capsule = players[i].axis1 = players[i].axis2 = players[i].drone = NULL; } } diff --git a/src/p_user.c b/src/p_user.c index fd09b0847..18e8e29ca 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6095,6 +6095,20 @@ static void P_DoNiGHTSCapsule(player_t *player) player->capsule->extravalue1 = -1; } +// +// P_MoveNiGHTSToDrone +// +// Pull NiGHTS to the drone during Nightserizing +// +static void P_MoveNiGHTSToDrone(player_t *player) +{ + if (!player->drone) + return; + player->mo->momx = player->mo->momy = player->mo->momz = 0; + P_TeleportMove(player->mo, player->drone->x, player->drone->y, player->drone->z); + P_SetTarget(&player->drone, NULL); +} + // // P_NiGHTSMovement // @@ -7007,6 +7021,13 @@ static void P_MovePlayer(player_t *player) return; } + // Suck player into their drone + if (player->drone) + { + P_MoveNiGHTSToDrone(player); + return; + } + // Test revamped NiGHTS movement. if (player->powers[pw_carry] == CR_NIGHTSMODE) {