I have the model, sound, etc.... that's all well and good, everything is where it belongs. What I'm trying to do is build a function that will allow accumulative armor per shard pickup (with a maximum of 200 or 250, whatever). 10 per shard. I've tried this a multitude of different ways and can't seem to get it working. I'm attempting to keep this separate from the armor in items.qc obviously for ease of use (it has it's own models, sounds etc.). Here is the stripped down version before I started really cranking on it:
Code: Select all
defs.qc:
//for Armor Shards
float IT_SHARD = 16777216;
shard.qc
void() shard_touch;
void() shard_touch =
{
local float type, value, bit;
if (other.health <= 0)
return;
if (other.classname != "player")
return;
if (self.classname == "item_shard")
{
type = 0.2;
value = 10;
bit = IT_SHARD;
}
if (other.armortype*other.armorvalue >= type*value)
return;
else (self.armorvalue = value + bit);
other.armortype = type;
other.armorvalue = value;
other.items = other.items - (other.items & (IT_SHARD | IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
self.solid = SOLID_NOT;
self.model = string_null;
if (deathmatch == 1)
self.nextthink = time + 20;
self.think = SUB_regen;
sprint(other, "You got an armor shard\n");
// touch sound
sound(other, CHAN_ITEM, "items/shard.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
};
/*QUAKED item_shard (0 .5 .8) (-8 -8 0) (8 8 32)
*/
void() item_shard =
{
precache_sound("items/shard.wav");
self.touch = shard_touch;
precache_model ("progs/shard.mdl");
setmodel (self, "progs/shard.mdl");
setsize (self, '-8 -8 0', '8 8 32');
StartItem ();
};