2003-10-24 21:43:32 +00:00
|
|
|
#include "common.qh"
|
2003-10-27 22:27:29 +00:00
|
|
|
#include "misc.qh"
|
2003-10-24 21:43:32 +00:00
|
|
|
#include "server.qh"
|
|
|
|
#include "delays.qh"
|
|
|
|
|
|
|
|
.float delay_health, delay_armorvalue, delay_currentammo;
|
|
|
|
.float delay_items, delay_effects;
|
|
|
|
|
|
|
|
.float delay_ammo_shells, delay_ammo_nails;
|
|
|
|
.float delay_ammo_rockets, delay_ammo_cells;
|
|
|
|
|
|
|
|
.float delay_dmg_take, delay_dmg_save;
|
|
|
|
|
|
|
|
.float delay_time, delay_last_change;
|
|
|
|
|
|
|
|
#define all_func(func) \
|
2004-02-08 07:34:17 +00:00
|
|
|
void () func##_all = { \
|
2003-10-24 21:43:32 +00:00
|
|
|
local entity oldself; \
|
|
|
|
local float i; \
|
|
|
|
\
|
|
|
|
oldself = self; \
|
|
|
|
\
|
|
|
|
self = world; \
|
|
|
|
for (i = 0; i < max_clients; i++) { \
|
2004-02-08 07:34:17 +00:00
|
|
|
self = nextent (self); \
|
2003-10-24 21:43:32 +00:00
|
|
|
\
|
2004-02-08 07:34:17 +00:00
|
|
|
if (!is_cl (self)) \
|
2003-10-24 21:43:32 +00:00
|
|
|
continue; \
|
|
|
|
\
|
2004-02-08 07:34:17 +00:00
|
|
|
func (); \
|
2003-10-24 21:43:32 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
self = oldself; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define do_fields() \
|
|
|
|
do_(health); \
|
|
|
|
do_(armorvalue); \
|
|
|
|
do_(currentammo); \
|
|
|
|
do_(items); \
|
|
|
|
do_(effects); \
|
|
|
|
do_(ammo_shells); \
|
|
|
|
do_(ammo_nails); \
|
|
|
|
do_(ammo_rockets); \
|
2004-02-08 07:34:17 +00:00
|
|
|
do_(ammo_cells);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
delays_swapin_stats =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
local float tmp;
|
|
|
|
|
|
|
|
#define do_(field) \
|
|
|
|
tmp = self.field; \
|
|
|
|
self.field = self.delay_##field; \
|
2004-02-08 07:34:17 +00:00
|
|
|
self.delay_##field = tmp;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
do_fields ();
|
2003-10-24 21:43:32 +00:00
|
|
|
#undef do_
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
all_func (delays_swapin_stats);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
// ===================================================================== //
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float ()
|
|
|
|
delays_changed =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
#define do_(field) \
|
2004-02-08 07:34:17 +00:00
|
|
|
if (floor (self.field) != floor (self.delay_##field)) \
|
2003-10-24 21:43:32 +00:00
|
|
|
return TRUE
|
2004-02-08 07:34:17 +00:00
|
|
|
do_fields ();
|
2003-10-24 21:43:32 +00:00
|
|
|
#undef do_
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ===================================================================== //
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
delays_force_update =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
self.delay_time = 0;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
all_func (delays_force_update);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
// ===================================================================== //
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
void ()
|
|
|
|
delays_swapout_stats =
|
|
|
|
{
|
|
|
|
if (delays_changed ())
|
2003-10-24 21:43:32 +00:00
|
|
|
self.delay_last_change = time;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.delay_dmg_take += self.dmg_take;
|
|
|
|
self.dmg_take = 0;
|
|
|
|
self.delay_dmg_save += self.dmg_save;
|
|
|
|
self.dmg_save = 0;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
if (time < self.delay_time) {
|
2004-02-08 07:34:17 +00:00
|
|
|
delays_swapin_stats ();
|
2003-10-24 21:43:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define do_(field) self.delay_##field = self.field
|
2004-02-08 07:34:17 +00:00
|
|
|
do_fields ();
|
2003-10-24 21:43:32 +00:00
|
|
|
#undef do_
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
self.dmg_take = ceil (self.delay_dmg_take);
|
|
|
|
self.delay_dmg_take = 0;
|
|
|
|
if (self.dmg_take > 255)
|
|
|
|
self.dmg_take = 255;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
self.dmg_save = ceil(self.delay_dmg_save); self.delay_dmg_save = 0;
|
2004-02-08 07:34:17 +00:00
|
|
|
if (self.dmg_save > 255)
|
|
|
|
self.dmg_save = 255;
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
if ((self.delay_last_change - time) >= -CONFIG_STATS_DELAY)
|
|
|
|
self.delay_time = time + CONFIG_STATS_DELAY;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
all_func (delays_swapout_stats);
|