2003-10-24 21:43:32 +00:00
|
|
|
#include "common.qh"
|
|
|
|
|
|
|
|
#include "mapents_util.qh"
|
|
|
|
#include "misc.qh"
|
|
|
|
|
|
|
|
#include "items.qh"
|
|
|
|
|
2003-10-28 21:20:34 +00:00
|
|
|
.float() th_takeitem;
|
|
|
|
|
2003-10-24 21:43:32 +00:00
|
|
|
void() _item_regen_think = {
|
|
|
|
self.solid = SOLID_TRIGGER;
|
2004-02-09 04:41:39 +00:00
|
|
|
setmodel (self, self.model);
|
|
|
|
sound (self, CHAN_VOICE, self.noise7, 1, ATTN_NORM);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void() item_remove_regen = {
|
|
|
|
local float del;
|
|
|
|
|
|
|
|
self.solid = SOLID_NOT;
|
|
|
|
self.modelindex = 0;
|
|
|
|
|
2004-02-09 04:41:39 +00:00
|
|
|
del = self.wait + random () * self.delay;
|
2003-10-24 21:43:32 +00:00
|
|
|
if (del <= 0) {
|
|
|
|
safe_remove(self);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.think = _item_regen_think;
|
|
|
|
self.nextthink = time + del;
|
|
|
|
};
|
|
|
|
|
|
|
|
void() item_generic_touch = {
|
|
|
|
if (!other.th_takeitem)
|
|
|
|
return;
|
2004-02-09 04:41:39 +00:00
|
|
|
if (!util_check_targets ())
|
|
|
|
return;
|
|
|
|
if (!switcheroo (other, self, other.th_takeitem))
|
2003-10-24 21:43:32 +00:00
|
|
|
return;
|
|
|
|
|
2004-02-09 04:41:39 +00:00
|
|
|
util_use_targets ();
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-09 04:41:39 +00:00
|
|
|
item_remove_regen ();
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void() item_generic = {
|
|
|
|
if (!self.noise7)
|
|
|
|
self.noise7 = "items/itembk2.wav";
|
|
|
|
|
|
|
|
if (sv_spawning)
|
2004-02-09 04:41:39 +00:00
|
|
|
precache_sound (self.noise7);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
self.solid = SOLID_TRIGGER;
|
|
|
|
self.touch = item_generic_touch;
|
|
|
|
|
2004-02-09 04:41:39 +00:00
|
|
|
util_map_entity_init ();
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
self.flags |= FL_ITEM;
|
|
|
|
|
|
|
|
if (!self.wait && !self.delay) {
|
|
|
|
self.wait = 20;
|
|
|
|
self.delay = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sv_spawning) {
|
|
|
|
self.think = util_map_entity_drop;
|
|
|
|
self.nextthink = time + 0.2; // Let everything else drop to floor.
|
|
|
|
}
|
|
|
|
};
|