|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: player.c,v 1.62 2004/01/06 00:03:01 stpohle Exp $
|
|
|
|
|
/* $Id: player.c,v 1.63 2004/01/06 01:24:56 stpohle Exp $
|
|
|
|
|
* player.c - everything what have to do with the player */
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
@ -166,7 +166,7 @@ player_check_powerup (int p_nr)
|
|
|
|
|
switch (ft) {
|
|
|
|
|
/* we found a bomb powerup */
|
|
|
|
|
case FT_bomb:
|
|
|
|
|
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0) {
|
|
|
|
|
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0.0) {
|
|
|
|
|
p->bombs_n++;
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
}
|
|
|
|
@ -174,7 +174,7 @@ player_check_powerup (int p_nr)
|
|
|
|
|
break;
|
|
|
|
|
/* we found a fire powerup */
|
|
|
|
|
case FT_fire:
|
|
|
|
|
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) {
|
|
|
|
|
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0.0) {
|
|
|
|
|
p->range++;
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
}
|
|
|
|
@ -182,7 +182,7 @@ player_check_powerup (int p_nr)
|
|
|
|
|
break;
|
|
|
|
|
/* we found a shoe powerup */
|
|
|
|
|
case FT_shoe:
|
|
|
|
|
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) {
|
|
|
|
|
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0.0) {
|
|
|
|
|
p->speed *= SPEEDMUL;
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
}
|
|
|
|
@ -190,7 +190,7 @@ player_check_powerup (int p_nr)
|
|
|
|
|
break;
|
|
|
|
|
/* we found a death ?powerup? */
|
|
|
|
|
case FT_death:
|
|
|
|
|
player_set_ilness (p, -1);
|
|
|
|
|
player_set_ilness (p, -1, ILL_TIMEOUT);
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
if (GT_MP)
|
|
|
|
|
net_game_send_ill (bman.p_nr);
|
|
|
|
@ -597,7 +597,7 @@ player_calcpos ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
player_ilness_loop (int pl_nr)
|
|
|
|
|
player_ilness_loop ()
|
|
|
|
|
{
|
|
|
|
|
_player *p;
|
|
|
|
|
int type,
|
|
|
|
@ -610,35 +610,35 @@ player_ilness_loop (int pl_nr)
|
|
|
|
|
/* do the illness for the network players */
|
|
|
|
|
if (GT_MP) {
|
|
|
|
|
for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
|
|
|
|
|
if (pnr != pl_nr && PS_IS_alife (players[pnr].state)) {
|
|
|
|
|
if (pnr != bman.p_nr && PS_IS_alife (players[pnr].state) && PS_IS_netplayer (players[pnr].state)) {
|
|
|
|
|
p = &players[pnr];
|
|
|
|
|
for (type = 0; type < PI_max; type++)
|
|
|
|
|
if (p->ill[type].to > 0.0f) {
|
|
|
|
|
p->ill[type].to -= timediff;
|
|
|
|
|
p->illframe += timefactor;
|
|
|
|
|
if (p->illframe < 0 || p->illframe >= gfx.ill.frames)
|
|
|
|
|
p->illframe = 0;
|
|
|
|
|
if (p->illframe < 0.0f || p->illframe >= gfx.ill.frames)
|
|
|
|
|
p->illframe = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check if we have contact with an other ill player */
|
|
|
|
|
p = &players[pl_nr];
|
|
|
|
|
p = &players[bman.p_nr];
|
|
|
|
|
get_player_on (p->pos.x, p->pos.y, pl);
|
|
|
|
|
for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++)
|
|
|
|
|
if (pl[i] != pl_nr) {
|
|
|
|
|
if (pl[i] != bman.p_nr) {
|
|
|
|
|
send = 0;
|
|
|
|
|
for (type = 0; type < PI_max; type++) {
|
|
|
|
|
if (players[pl[i]].ill[type].to > p->ill[type].to) {
|
|
|
|
|
tmpf = p->ill[type].to;
|
|
|
|
|
player_set_ilness (p, type);
|
|
|
|
|
player_set_ilness (p, type, players[pl[i]].ill[type].to);
|
|
|
|
|
p->ill[type].to = players[pl[i]].ill[type].to;
|
|
|
|
|
if (tmpf <= 0.0f)
|
|
|
|
|
send = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (send != 0 && GT_MP)
|
|
|
|
|
net_game_send_ill (pl_nr);
|
|
|
|
|
net_game_send_ill (bman.p_nr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* do the illness for the givin player */
|
|
|
|
@ -672,16 +672,17 @@ player_ilness_loop (int pl_nr)
|
|
|
|
|
}
|
|
|
|
|
else if (type == PI_bomb)
|
|
|
|
|
/* player is dropping bombs */
|
|
|
|
|
player_drop_bomb (pl_nr);
|
|
|
|
|
player_drop_bomb (bman.p_nr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* player picked up the death powerup, add timeout for
|
|
|
|
|
this illness to the maybe excisting timeout */
|
|
|
|
|
/* Set or add the timeout for one illness, depends on if one was givin.
|
|
|
|
|
* if the type is -1 so the timeout will be added, else the timeout is
|
|
|
|
|
* set to the new value */
|
|
|
|
|
void
|
|
|
|
|
player_set_ilness (_player * p, int t)
|
|
|
|
|
player_set_ilness (_player * p, int t, float new_to)
|
|
|
|
|
{
|
|
|
|
|
int type;
|
|
|
|
|
if (t == -1)
|
|
|
|
@ -711,24 +712,28 @@ player_set_ilness (_player * p, int t)
|
|
|
|
|
else
|
|
|
|
|
p->ill[type].dataf = p->speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p->speed = ILL_FASTSPEED;
|
|
|
|
|
break;
|
|
|
|
|
case PI_range:
|
|
|
|
|
if (p->ill[type].to <= 0.0f)
|
|
|
|
|
p->ill[type].datai = p->range;
|
|
|
|
|
d_printf ("player_set_ilness PI_range %d\n", p->ill[type].datai);
|
|
|
|
|
d_printf (" PI_range %d\n", p->ill[type].datai);
|
|
|
|
|
p->range = 1;
|
|
|
|
|
break;
|
|
|
|
|
case PI_nobomb:
|
|
|
|
|
if (p->ill[type].to <= 0.0f)
|
|
|
|
|
p->ill[type].datai = p->bombs_n;
|
|
|
|
|
d_printf ("player_set_ilness PI_nobomb %d\n", p->ill[type].datai);
|
|
|
|
|
d_printf (" PI_nobomb %d\n", p->ill[type].datai);
|
|
|
|
|
p->bombs_n = s_random (2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
p->ill[type].to += ILL_TIMEOUT;
|
|
|
|
|
|
|
|
|
|
/* add or set the new timeout */
|
|
|
|
|
if (t == -1)
|
|
|
|
|
p->ill[type].to += new_to;
|
|
|
|
|
else
|
|
|
|
|
p->ill[type].to = new_to;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|