Skip to content

Commit

Permalink
Changed (all games): A dead player can now instigate the "reborn" pro…
Browse files Browse the repository at this point in the history
…cess by using the attack controls (formerly only "use" would do this). Changed to aid all those DOOM newbies out there. Note, a brief (one second) wait has been added to stop players from accidentally beginning the reborn process (e.g., they died trying to open a door whilst fleeing from impending doom).
  • Loading branch information
danij committed Feb 9, 2009
1 parent d6581e4 commit c378a13
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 18 deletions.
1 change: 1 addition & 0 deletions doomsday/plugins/common/include/g_controls.h
Expand Up @@ -120,6 +120,7 @@ typedef struct playerbrain_s {
uint mapMarkClearAll : 1;
uint hudShow : 1;
uint scoreShow : 1;
uint doReborn: 1; // Set when the player wishes to be reborn.
} playerbrain_t;

void G_ControlRegister(void);
Expand Down
22 changes: 10 additions & 12 deletions doomsday/plugins/common/include/p_player.h
Expand Up @@ -45,26 +45,24 @@
void P_InitPlayerClassInfo(void);
#endif

int P_GetPlayerNum(player_t *player);
int P_GetPlayerCheats(player_t *player);
int P_GetPlayerNum(player_t* player);
int P_GetPlayerCheats(player_t* player);

weapontype_t P_PlayerFindWeapon(player_t *player, boolean next);
weapontype_t P_MaybeChangeWeapon(player_t *player, weapontype_t weapon,
weapontype_t P_PlayerFindWeapon(player_t* player, boolean next);
weapontype_t P_MaybeChangeWeapon(player_t* player, weapontype_t weapon,
ammotype_t ammo, boolean force);
boolean P_CheckAmmo(player_t* plr);
void P_ShotAmmo(player_t *player);
boolean P_CheckAmmo(player_t* player);
void P_ShotAmmo(player_t* player);

void P_PlayerThink(player_t *player, timespan_t ticLength);
void P_RaiseDeadPlayer(player_t *player);
#if __JHEXEN__
void P_PlayerChangeClass(player_t* player, playerclass_t newClass);
#endif

void P_SetMessage(player_t *pl, char *msg, boolean noHide);
void P_SetMessage(player_t* player, char* msg, boolean noHide);
#if __JHEXEN__ || __JSTRIFE__
void P_SetYellowMessage(player_t *pl, char *msg, boolean noHide);
void P_SetYellowMessage(player_t* player, char* msg, boolean noHide);
#endif

boolean P_IsCamera(mobj_t *mo);
void P_PlayerThinkCamera(player_t *player);
boolean P_IsCamera(mobj_t* mo);
void P_PlayerThinkCamera(player_t* player);
#endif
4 changes: 3 additions & 1 deletion doomsday/plugins/common/include/p_user.h
Expand Up @@ -34,6 +34,8 @@

#include "dd_types.h"

#define PLAYER_REBORN_TICS (1*TICSPERSEC)

extern boolean onground;

extern int maxHealth;
Expand All @@ -54,7 +56,7 @@ void P_Thrust(player_t *player, angle_t angle, float move);
boolean P_IsPlayerOnGround(player_t *player);
void P_CheckPlayerJump(player_t *player);
void P_MovePlayer(player_t *player);
void P_RaiseDeadPlayer(player_t *player);
void P_PlayerReborn(player_t *player);

void P_ClientSideThink(void);
void P_DeathThink(player_t *player);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -48,6 +48,7 @@
#include "d_net.h"
#include "p_svtexarc.h"
#include "p_player.h"
#include "p_user.h"
#include "p_map.h"
#include "g_common.h"
#include "p_tick.h"
Expand Down Expand Up @@ -1380,7 +1381,7 @@ void NetSv_DoAction(int player, const char *data)
if(pl->playerState == PST_DEAD)
{
// This player is dead. Rise, my friend!
P_RaiseDeadPlayer(pl);
P_PlayerReborn(pl);
return;
}

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/common/src/p_tick.c
Expand Up @@ -43,6 +43,7 @@
#include "g_common.h"
#include "g_controls.h"
#include "p_player.h"
#include "p_user.h"
#include "hu_menu.h"
#include "hu_msg.h"

Expand Down
22 changes: 18 additions & 4 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -57,6 +57,7 @@
#include "d_net.h"
#include "p_player.h"
#include "p_map.h"
#include "p_user.h"
#include "g_common.h"
#include "am_map.h"

Expand Down Expand Up @@ -479,6 +480,9 @@ void P_DeathThink(player_t* player)
angle_t delta;
int lookDelta;

if(player->rebornWait > 0)
player->rebornWait--;

P_MovePsprites(player);

onground = (player->plr->mo->pos[VZ] <= player->plr->mo->floorZ);
Expand Down Expand Up @@ -606,25 +610,25 @@ void P_DeathThink(player_t* player)
#endif
}

if(player->brain.use)
if(!(player->rebornWait > 0) && player->brain.doReborn)
{
if(IS_CLIENT)
{
NetCl_PlayerActionRequest(player, GPA_USE);
}
else
{
P_RaiseDeadPlayer(player);
P_PlayerReborn(player);
}
}
}

/**
* Called when a dead player wishes to be reborn.
*
* @param player Player that wants to be reborn.
* @param player Player that wishes to be reborn.
*/
void P_RaiseDeadPlayer(player_t *player)
void P_PlayerReborn(player_t* player)
{
player->playerState = PST_REBORN;
#if __JHERETIC__ || __JHEXEN__
Expand Down Expand Up @@ -1846,6 +1850,7 @@ void P_PlayerThinkUpdateControls(player_t* player)
int i;
boolean strafe = false;
playerbrain_t *brain = &player->brain;
boolean oldAttack = brain->attack;

// Check for speed.
P_GetControlState(playerNum, CTL_SPEED, &vel, 0);
Expand Down Expand Up @@ -1896,6 +1901,15 @@ void P_PlayerThinkUpdateControls(player_t* player)
P_GetControlState(playerNum, CTL_ATTACK, &vel, &off);
brain->attack = (vel + off != 0);

// Once dead, the intended action for a given control state change,
// changes. Here we interpret Use and Fire as "I wish to be Reborn".
brain->doReborn = false;
if(player->playerState == PST_DEAD)
{
if(brain->use || (brain->attack && !oldAttack))
brain->doReborn = true;
}

// Weapons.
brain->changeWeapon = WT_NOCHANGE;
for(i = 0; i < NUM_WEAPON_TYPES && (CTL_WEAPON1 + i <= CTL_WEAPON0); i++)
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_player.h
Expand Up @@ -106,6 +106,7 @@ typedef struct player_s {
int jumpTics;
int airCounter;
int flyHeight;
int rebornWait; // The player can be reborn if this counter is zero.
int update, startSpot;

// Target view to a mobj (NULL=disabled):
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/src/p_inter.c
Expand Up @@ -771,6 +771,7 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)
target->flags2 &= ~MF2_FLY;
target->player->powers[PT_FLIGHT] = 0;
target->player->playerState = PST_DEAD;
target->player->rebornWait = PLAYER_REBORN_TICS;
target->player->update |= PSF_STATE;
target->player->plr->flags |= DDPF_DEAD;
P_DropWeapon(target->player);
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/include/d_player.h
Expand Up @@ -136,6 +136,7 @@ typedef struct player_s {
// The player can jump if this counter is zero.
int jumpTics;
int airCounter;
int rebornWait; // The player can be reborn if this counter is zero.
int update, startSpot;

// Target view to a mobj (NULL=disabled).
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/src/p_inter.c
Expand Up @@ -817,6 +817,7 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)
target->flags2 &= ~MF2_FLY;
target->player->powers[PT_FLIGHT] = 0;
target->player->playerState = PST_DEAD;
target->player->rebornWait = PLAYER_REBORN_TICS;
target->player->update |= PSF_STATE;
target->player->plr->flags |= DDPF_DEAD;
P_DropWeapon(target->player);
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/include/h_player.h
Expand Up @@ -145,6 +145,7 @@ typedef struct player_s {
// The player can jump if this counter is zero.
int jumpTics;
int airCounter;
int rebornWait; // The player can be reborn if this counter is zero.
int update, startSpot;

// Target view to a mobj (NULL=disabled).
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/src/p_inter.c
Expand Up @@ -829,6 +829,7 @@ void P_KillMobj(mobj_t *source, mobj_t *target)
target->player->powers[PT_FLIGHT] = 0;
target->player->powers[PT_WEAPONLEVEL2] = 0;
target->player->playerState = PST_DEAD;
target->player->rebornWait = PLAYER_REBORN_TICS;
target->player->plr->flags |= DDPF_DEAD;
target->player->update |= PSF_STATE;
P_DropWeapon(target->player);
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/include/x_player.h
Expand Up @@ -117,6 +117,7 @@ typedef struct player_s {
int morphTics; // Player is a pig if > 0.
int jumpTics; // Delay the next jump for a moment.
int airCounter;
int rebornWait; // The player can be reborn if this counter is zero.
unsigned int worldTimer; // Total time the player's been playing.
int update, startSpot;
// Target view to a mobj (NULL=disabled).
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/src/p_inter.c
Expand Up @@ -1115,6 +1115,7 @@ void P_KillMobj(mobj_t *source, mobj_t *target)
target->flags2 &= ~MF2_FLY;
target->player->powers[PT_FLIGHT] = 0;
target->player->playerState = PST_DEAD;
target->player->rebornWait = PLAYER_REBORN_TICS;
target->player->update |= PSF_STATE | PSF_POWERS;

// Let the engine know about this, too. The DEAD flag will be
Expand Down

0 comments on commit c378a13

Please sign in to comment.