respawn on local player works.

origin
stpohle 22 years ago
parent f7d1b74fd4
commit 5842d80f24

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.18 2004/01/27 20:44:02 stpohle Exp $ */ /* $Id: basic.h,v 1.19 2004/01/27 22:52:08 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -200,7 +200,7 @@ enum _playerstateflags { // not Set | Set
#define PSFM_used (PSF_used + PSF_playing) #define PSFM_used (PSF_used + PSF_playing)
#define PSFM_alife (PSF_used + PSF_alife + PSF_playing) #define PSFM_alife (PSF_used + PSF_alife + PSF_playing)
#define PS_IS_dead(__ps) (((__ps) & (PSFM_alife + PSF_respawn)) == (PSFM_used)) #define PS_IS_dead(__ps) (((__ps) & (PSFM_alife + PSF_respawn)) == (PSFM_used))
#define PS_IS_respawn(__ps) ((PSFM_alife + PSF_respawn) == (PSFM_used + PSF_respawn)) #define PS_IS_respawn(__ps) (((__ps) & (PSFM_alife + PSF_respawn)) == (PSFM_used + PSF_respawn))
#define PS_IS_alife(__ps) (((__ps) & (PSFM_alife)) == (PSFM_alife)) #define PS_IS_alife(__ps) (((__ps) & (PSFM_alife)) == (PSFM_alife))
#define PS_IS_netplayer(__ps) (((__ps) & (PSF_net)) != 0) #define PS_IS_netplayer(__ps) (((__ps) & (PSF_net)) != 0)
#define PS_IS_playing(__ps) (((__ps) & (PSFM_used)) == (PSFM_used)) #define PS_IS_playing(__ps) (((__ps) & (PSFM_used)) == (PSFM_used))

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.71 2004/01/27 22:17:22 stpohle Exp $ /* $Id: player.c,v 1.72 2004/01/27 22:52:14 stpohle Exp $
* player.c - everything what have to do with the player */ * player.c - everything what have to do with the player */
#include <SDL.h> #include <SDL.h>
@ -60,7 +60,6 @@ draw_player (_player * player)
/* player is respawning /* player is respawning
* first: draw the star */ * first: draw the star */
printf ("Respawn Drawing \n");
dest.w = src.w = gfx.respawn.image->w; dest.w = src.w = gfx.respawn.image->w;
dest.h = src.h = player->gfx->ani.h; dest.h = src.h = player->gfx->ani.h;
@ -587,10 +586,15 @@ player_animation (_player * player)
player->frame += player->gfx->ani.frames; player->frame += player->gfx->ani.frames;
} }
if (PS_IS_dead (player->state) || PS_IS_respawn (player->state)) { if (PS_IS_dead (player->state)) {
if ((int)player->frame < gfx.dead.frames) if ((int)player->frame < gfx.dead.frames)
player->frame += (timefactor * ANI_PLAYERTIMEOUT); player->frame += (timefactor * ANI_PLAYERTIMEOUT);
} }
if (PS_IS_respawn (player->state)) {
if ((int)player->frame < gfx.respawn.frames)
player->frame += (timefactor * ANI_PLAYERTIMEOUT);
}
}; };
@ -860,14 +864,16 @@ player_findfreebomb (_player * player)
/* check if a player died and check if we have to respawn */ /* check if a player died and check if we have to respawn */
void player_checkdeath (int pnr) { void player_checkdeath (int pnr) {
_player *player = &players[pnr]; _player *player = &players[pnr];
int trypos; int trypos, i;
/* check for respawn */ /* check for respawn */
if (bman.gametype == GT_deathmatch && PS_IS_dead (player->state) && player->frame >= gfx.dead.frames) { if (bman.gametype == GT_deathmatch && PS_IS_dead (player->state) && player->frame >= gfx.dead.frames) {
/* check new position */ /* check new position */
printf ("Respawn Test OK\n"); d_printf ("Respawn for player %s\n", player->name);
trypos = 0; trypos = 0;
do { do {
player->pos.x = -1.0f;
player->pos.y = -1.0f;
map_set_player_way1 (pnr); map_set_player_way1 (pnr);
trypos++; trypos++;
} while (trypos < 100 && (player->pos.x == -1 || player->pos.y == -1)); } while (trypos < 100 && (player->pos.x == -1 || player->pos.y == -1));
@ -880,4 +886,24 @@ void player_checkdeath (int pnr) {
net_game_send_respawn (pnr); net_game_send_respawn (pnr);
} }
} }
/* check for respawn finish */
if (bman.gametype == GT_deathmatch && PS_IS_respawn (player->state) && player->frame >= gfx.respawn.frames) {
d_printf ("Respawn completed for player %s\n", player->name);
player->frame = 0;
player->state &= (0xFF - PSF_respawn);
player->state |= PSF_alife;
if (bman.dropitemsondeath) {
player->speed = bman.start_speed;
player->bombs_n = bman.start_bombs;
player->range = bman.start_range;
for (i = 0; i < PI_max; i++)
player->ill[i].to = 0.0f;
}
for (i = 0; i < PI_max; i++)
if (player->ill[i].to > 0.0f)
player_clear_ilness (player, i);
}
}; };

Loading…
Cancel
Save