djcev.com

//

Git Repos / fte_dogmode / qc / items / armor.qc

Last update to this file was on 2024-06-15 at 19:50.

Show armor.qc

//==============================================================================
// armor.qc
//==============================================================================

//======================================================================
// constants
//======================================================================

#ifdef SSQC
const float ARMOR_GREEN_ABSORB = 0.3; // absorb percent; id1 0.3
const float ARMOR_GREEN_AMOUNT = 100; // amount per pickup; id1 100
const float ARMOR_GREEN_MAX = 125; // id1 125

const float ARMOR_YELLOW_ABSORB = 0.6; // id1 0.6
const float ARMOR_YELLOW_AMOUNT = 150; // id1 150
const float ARMOR_YELLOW_MAX = 175; // id1 175

const float ARMOR_RED_ABSORB = 0.8; // id1 0.8
const float ARMOR_RED_AMOUNT = 200; // id1 200
const float ARMOR_RED_MAX = 225; // id1 225

const float ARMOR_SHARD_AMOUNT = 5; // Q3 5

const float ARMOR_RESPAWN_SP = 30; // id1 30s
const float ARMOR_RESPAWN_DM = 20; // id1 20s
#endif

//======================================================================
// forward declarations
//======================================================================

#ifdef SSQC
// base_item_armor
entity(entity src, vector org, vector vel, void(entity) initfn)
spawn_item_armor;
void() base_item_armor_touch;
void(entity e) base_item_armor_init;
strip void() base_item_armor;
#endif

#ifdef SSQC
// item_armor1
entity(entity src, vector org, vector vel) spawn_item_armor1;
void(entity e) item_armor1_init;
void() item_armor1;
#endif

#ifdef SSQC
// item_armor2
entity(entity src, vector org, vector vel) spawn_item_armor2;
void(entity e) item_armor2_init;
void() item_armor2;
#endif

#ifdef SSQC
// item_armorInv
entity(entity src, vector org, vector vel) spawn_item_armorInv;
void(entity e) item_armorInv_init;
void() item_armorInv;
#endif

#ifdef SSQC
// item_armor_shard
void() item_armor_shard_touch;
entity(entity src) item_armor_shard_drop;
entity(entity src, vector org, vector vel) spawn_item_armor_shard;
void(entity e) item_armor_shard_init;
void() item_armor_shard;
#endif

//------------------------------------------------------------------------------

#ifdef SSQC
//----------------------------------------------------------------------
// class base_item_armor: base_item
// {
//--------------------------------------------------------------
entity(entity src, vector org, vector vel, void(entity) init_fn)
spawn_item_armor =
{
local entity e = spawn ();
e.owner = src;
e.origin = org;
e.velocity = vel;
init_fn (e);
return e;
};

//--------------------------------------------------------------
// was armor_touch -- CEV
//--------------------------------------------------------------
void() base_item_armor_touch =
{
local float type, value, bit;

if (sub_checkvalidtouch(other) == FALSE)
return;

if (self.classtype == CT_ITEM_ARMOR_GREEN)
{
// green armor
type = ARMOR_GREEN_ABSORB;
value = ARMOR_GREEN_AMOUNT;
bit = IT_ARMOR1;
}
else if (self.classtype == CT_ITEM_ARMOR_YELLOW)
{
// yellow armor
type = ARMOR_YELLOW_ABSORB;
value = ARMOR_YELLOW_AMOUNT;
bit = IT_ARMOR2;
}
else if (self.classtype == CT_ITEM_ARMOR_RED)
{
// red armor
type = ARMOR_RED_ABSORB;
value = ARMOR_RED_AMOUNT;
bit = IT_ARMOR3;
}
else
{
dprint (sprintf("base_item_armor::do_touch: unknown "
"classname %s!\n", self.classname));
return;
}

if (other.armortype * other.armorvalue >= type * value)
return;

other.armortype = type;
other.armorvalue = value;

other.items = other.items - (other.items &
(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;

self.solid = SOLID_NOT;
self.model = __NULL__;
base_item_check_respawn (self,
ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);

if (self.obit_name != __NULL__ && self.obit_name != "")
// custom armor name
sprint (other, sprintf("You got %s\n",
self.obit_name));
else
sprint (other, "You got armor\n");

// armor touch sound
// dumptruck_ds custom models and sounds START
if (self.snd_misc != "")
sound_misc (other, CHAN_ITEM, self.snd_misc,
VOL_HIGH, ATTN_NORM);
else
sound_misc (other, CHAN_ITEM,"items/armor1.wav",
VOL_HIGH, ATTN_NORM);
// dumptruck_ds custom models and sounds END

stuffcmd (other, "bf\n");

activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
void(entity e) base_item_armor_init =
{
e.classgroup |= CG_ITEM_ARMOR;
base_item_init (e);
};

//--------------------------------------------------------------
strip void() base_item_armor =
{
base_item_armor_init (self);
};
// };
#endif

#ifdef SSQC
/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/armor.mdl");
}
*/
//----------------------------------------------------------------------
// class item_armor1: base_item_armor
// {
//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_item_armor1 =
{
return spawn_item_armor (src, org, vel, item_armor1_init);
};

//--------------------------------------------------------------
void(entity e) item_armor1_init =
{
e.classname = "item_armor1";
e.classtype = CT_ITEM_ARMOR_GREEN;
e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
precache_body_model (e, "progs/armor.mdl");
// setmodel (e, "progs/armor.mdl");
body_model (e, "progs/armor.mdl");
precache_sound_misc (e, "items/armor1.wav");
// dumptruck_ds custom models and sounds END

if !(e.skin)
e.skin = 0;
e.pos1 = '-16 -16 0';
e.pos2 = '16 16 56';

// StartItem
base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor1 =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

item_armor1_init (self);
};
// };
#endif

#ifdef SSQC
/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model({ "path": ":progs/armor.mdl", "skin": 1 }); }
*/
//----------------------------------------------------------------------
// class item_armor2: base_item_armor
// {
//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_item_armor2 =
{
return spawn_item_armor (src, org, vel, item_armor2_init);
};

//--------------------------------------------------------------
void(entity e) item_armor2_init =
{
e.classname = "item_armor2";
e.classtype = CT_ITEM_ARMOR_YELLOW;
e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
precache_body_model (e, "progs/armor.mdl");
// setmodel (e, "progs/armor.mdl");
body_model (e, "progs/armor.mdl");
// dumptruck_ds custom models and sounds END

if !(e.skin)
e.skin = 1;
precache_sound_misc (e, "items/armor1.wav");
e.pos1 = '-16 -16 0';
e.pos2 = '16 16 56';

// StartItem
base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor2 =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

item_armor2_init (self);
};
// };
#endif

#ifdef SSQC
/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model({ "path": ":progs/armor.mdl", "skin": 2 });
}
*/
//----------------------------------------------------------------------
// class item_armorInv: base_item_armor
// {
//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_item_armorInv =
{
return spawn_item_armor (src, org, vel, item_armorInv_init);
};

//--------------------------------------------------------------
void(entity e) item_armorInv_init =
{
e.classname = "item_armorInv";
e.classtype = CT_ITEM_ARMOR_RED;
e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
precache_body_model (e, "progs/armor.mdl");
// setmodel (e, "progs/armor.mdl");
body_model (e, "progs/armor.mdl");
// dumptruck_ds custom models and sounds END

if !(e.skin)
e.skin = 2;
precache_sound_misc (e, "items/armor1.wav");
e.pos1 = '-16 -16 0';
e.pos2 = '16 16 56';

// StartItem
base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armorInv =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

item_armorInv_init (self);
};
// };
#endif

#ifdef SSQC
//------------------------------------------------------------------------------
// item_armor_shard
//------------------------------------------------------------------------------
// class item_armor_shard: base_item_armor
// {
//--------------------------------------------------------------
// shard_touch -- this is from RMQ shard_touch
//--------------------------------------------------------------
void() item_armor_shard_touch =
{
local float bit;

if (sub_checkvalidtouch(other) == FALSE)
return;

if ((other.items & IT_ARMOR1) || (other.items & IT_ARMOR2)
|| (other.items & IT_ARMOR3))
{
// has armor
// Supa, check bounds, original armourvalue + 25
if (other.items & IT_ARMOR1 &&
other.armorvalue >= ARMOR_GREEN_MAX)
{
return;
}
if (other.items & IT_ARMOR2 &&
other.armorvalue >= ARMOR_YELLOW_MAX)
{
return;
}
if (other.items & IT_ARMOR3 &&
other.armorvalue >= ARMOR_RED_MAX)
{
return;
}

// was 2, RMQ team
other.armorvalue = other.armorvalue +
ARMOR_SHARD_AMOUNT;

// Supa, now cap armourvalue to bounds
if (other.items & IT_ARMOR1 &&
other.armorvalue >= ARMOR_GREEN_MAX)
{
other.armorvalue = ARMOR_GREEN_MAX;
}
else if (other.items & IT_ARMOR2 &&
other.armorvalue >= ARMOR_YELLOW_MAX)
{
other.armorvalue = ARMOR_YELLOW_MAX;
}
else if (other.items & IT_ARMOR3 &&
other.armorvalue >= ARMOR_RED_MAX)
{
other.armorvalue = ARMOR_RED_MAX;
}
}
else
{
// shard = Green armor level
other.armortype = ARMOR_GREEN_ABSORB;
other.armorvalue = ARMOR_SHARD_AMOUNT;
bit = IT_ARMOR1;
other.items = other.items - (other.items &
(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
}

self.solid = SOLID_NOT;
self.model = __NULL__;
base_item_check_respawn (self,
ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);

if (self.obit_name != __NULL__ && self.obit_name != "")
// custom armor name
sprint (other, sprintf("You got %s\n", self.obit_name));
else
sprint (other, "You got armor\n");

// armor touch sound
// dumptruck_ds custom models and sounds START
if (self.snd_misc != "")
sound_misc (other, CHAN_AUTO, self.snd_misc,
VOL_HIGH, ATTN_NORM);
else
sound_misc (other, CHAN_AUTO,
"items/shard_pickup.ogg", VOL_MID, ATTN_NORM);

// dumptruck_ds custom models and sounds END
stuffcmd (other, "bf\n");

// fire all targets / killtargets
activator = other;
sub_usetargets ();
};

//--------------------------------------------------------------
entity(entity src) item_armor_shard_drop =
{
local vector vel;
vel_x = -100 + (random() * 200);
vel_y = -100 + (random() * 200);
vel_z = 300;
return spawn_item_armor_shard (src, src.origin - '0 0 24', vel);
};

//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_item_armor_shard =
{
return spawn_item_armor (src, org, vel, item_armor_shard_init);
};

//--------------------------------------------------------------
void(entity e) item_armor_shard_init =
{
e.classname = "item_armor_shard";
e.classtype = CT_ITEM_ARMOR_SHARD;
e.touch = item_armor_shard_touch;

// dumptruck_ds custom models and sounds START
precache_body_model (e, "progs/armshr.mdl");
// setmodel (e, "progs/armor.mdl");
body_model (e, "progs/armshr.mdl");
precache_sound_misc (e, "items/armor_shard_q3.wav");
// dumptruck_ds custom models and sounds END

if !(e.skin)
e.skin = 0;
e.pos1 = '-16 -16 0';
e.pos2 = '16 16 56';

// StartItem
base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor_shard =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

item_armor_shard_init (self);
};
// };
#endif

Return to the top of this page or return to the overview of this repo.

Log armor.qc

Return to the top of this page or return to the overview of this repo.