48 #define HEALTH_IGNORE_MAX 1
49 #define HEALTH_TIMED 2
123 master = ent->teammaster;
125 for (count = 0, ent = master; ent; ent = ent->chain, count++)
128 choice = rand() % count;
130 for (count = 0, ent = master; count < choice; ent = ent->chain, count++)
134 ent->svflags &= ~SVF_NOCLIENT;
135 ent->solid = SOLID_TRIGGER;
139 ent->s.event = EV_ITEM_RESPAWN;
145 ent->svflags |= SVF_NOCLIENT;
146 ent->solid = SOLID_NOT;
160 if ((
skill->value == 1 && quantity >= 2) || (
skill->value >= 2 && quantity >= 1))
174 ent->item->use(
other, ent->item);
184 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
194 other->max_health += 1;
207 other->max_health += 2;
220 if (
other->client->pers.max_bullets < 250)
221 other->client->pers.max_bullets = 250;
222 if (
other->client->pers.max_shells < 150)
223 other->client->pers.max_shells = 150;
224 if (
other->client->pers.max_cells < 250)
225 other->client->pers.max_cells = 250;
226 if (
other->client->pers.max_slugs < 75)
227 other->client->pers.max_slugs = 75;
233 if (
other->client->pers.inventory[index] >
other->client->pers.max_bullets)
234 other->client->pers.inventory[index] =
other->client->pers.max_bullets;
241 if (
other->client->pers.inventory[index] >
other->client->pers.max_shells)
242 other->client->pers.inventory[index] =
other->client->pers.max_shells;
256 if (
other->client->pers.max_bullets < 300)
257 other->client->pers.max_bullets = 300;
258 if (
other->client->pers.max_shells < 200)
259 other->client->pers.max_shells = 200;
260 if (
other->client->pers.max_rockets < 100)
261 other->client->pers.max_rockets = 100;
262 if (
other->client->pers.max_grenades < 100)
263 other->client->pers.max_grenades = 100;
264 if (
other->client->pers.max_cells < 300)
265 other->client->pers.max_cells = 300;
266 if (
other->client->pers.max_slugs < 100)
267 other->client->pers.max_slugs = 100;
273 if (
other->client->pers.inventory[index] >
other->client->pers.max_bullets)
274 other->client->pers.inventory[index] =
other->client->pers.max_bullets;
281 if (
other->client->pers.inventory[index] >
other->client->pers.max_shells)
282 other->client->pers.inventory[index] =
other->client->pers.max_shells;
289 if (
other->client->pers.inventory[index] >
other->client->pers.max_cells)
290 other->client->pers.inventory[index] =
other->client->pers.max_cells;
297 if (
other->client->pers.inventory[index] >
other->client->pers.max_grenades)
298 other->client->pers.inventory[index] =
other->client->pers.max_grenades;
305 if (
other->client->pers.inventory[index] >
other->client->pers.max_rockets)
306 other->client->pers.inventory[index] =
other->client->pers.max_rockets;
313 if (
other->client->pers.inventory[index] >
other->client->pers.max_slugs)
314 other->client->pers.inventory[index] =
other->client->pers.max_slugs;
329 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
340 ent->client->quad_framenum += timeout;
344 gi.sound(ent, CHAN_ITEM,
gi.soundindex(
"items/damage.wav"), 1, ATTN_NORM, 0);
351 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
355 ent->client->breather_framenum += 300;
366 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
370 ent->client->enviro_framenum += 300;
381 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
385 ent->client->invincible_framenum += 300;
389 gi.sound(ent, CHAN_ITEM,
gi.soundindex(
"items/protect.wav"), 1, ATTN_NORM, 0);
396 ent->client->pers.inventory[
ITEM_INDEX(item)]--;
398 ent->client->silencer_shots += 30;
408 if (strcmp(ent->classname,
"key_power_cube") == 0) {
409 if (
other->client->pers.power_cubes & ((ent->spawnflags & 0x0000ff00) >> 8))
412 other->client->pers.power_cubes |= ((ent->spawnflags & 0x0000ff00) >> 8);
435 max = ent->client->pers.max_bullets;
437 max = ent->client->pers.max_shells;
439 max = ent->client->pers.max_rockets;
441 max = ent->client->pers.max_grenades;
443 max = ent->client->pers.max_cells;
445 max = ent->client->pers.max_slugs;
451 if (ent->client->pers.inventory[index] == max)
454 ent->client->pers.inventory[index] += count;
456 if (ent->client->pers.inventory[index] > max)
457 ent->client->pers.inventory[index] = max;
469 if ((weapon) && ((
int)
dmflags->value & DF_INFINITE_AMMO))
474 count = ent->item->quantity;
481 if (weapon && !oldcount) {
483 other->client->newweapon = ent->item;
498 if (ent->client->pers.inventory[index] >= item->
quantity)
501 dropped->count = ent->client->pers.inventory[index];
503 if (ent->client->pers.weapon &&
506 ent->client->pers.inventory[index] - dropped->count <= 0) {
507 gi.cprintf(ent, PRINT_HIGH,
"Can't drop current weapon\n");
512 ent->client->pers.inventory[index] -= dropped->count;
521 if (self->owner->health > self->owner->max_health) {
523 self->owner->health -= 1;
539 other->health += ent->count;
551 ent->svflags |= SVF_NOCLIENT;
552 ent->solid = SOLID_NOT;
596 if (!old_armor_index)
599 other->client->pers.inventory[old_armor_index] += 2;
603 else if (!old_armor_index) {
620 salvagecount = salvage *
other->client->pers.inventory[old_armor_index];
621 newcount = newinfo->
base_count + salvagecount;
626 other->client->pers.inventory[old_armor_index] = 0;
634 newcount =
other->client->pers.inventory[old_armor_index] + salvagecount;
639 if (
other->client->pers.inventory[old_armor_index] >= newcount)
643 other->client->pers.inventory[old_armor_index] = newcount;
678 gi.sound(ent, CHAN_AUTO,
gi.soundindex(
"misc/power2.wav"), 1, ATTN_NORM, 0);
681 if (!ent->client->pers.inventory[index]) {
682 gi.cprintf(ent, PRINT_HIGH,
"No cells for power armor.\n");
686 gi.sound(ent, CHAN_AUTO,
gi.soundindex(
"misc/power1.wav"), 1, ATTN_NORM, 0);
703 ent->item->use(
other, ent->item);
729 if (
other->health < 1)
731 if (!ent->item->pickup)
734 taken = ent->item->pickup(ent,
other);
738 other->client->bonus_alpha = 0.25;
741 other->client->ps.stats[STAT_PICKUP_ICON] =
gi.imageindex(ent->item->icon);
742 other->client->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS +
ITEM_INDEX(ent->item);
747 other->client->pers.selected_item =
other->client->ps.stats[STAT_SELECTED_ITEM] =
ITEM_INDEX(ent->item);
751 gi.sound(
other, CHAN_ITEM,
gi.soundindex(
"items/s_health.wav"), 1, ATTN_NORM, 0);
752 else if (ent->count == 10)
753 gi.sound(
other, CHAN_ITEM,
gi.soundindex(
"items/n_health.wav"), 1, ATTN_NORM, 0);
754 else if (ent->count == 25)
755 gi.sound(
other, CHAN_ITEM,
gi.soundindex(
"items/l_health.wav"), 1, ATTN_NORM, 0);
757 gi.sound(
other, CHAN_ITEM,
gi.soundindex(
"items/m_health.wav"), 1, ATTN_NORM, 0);
758 }
else if (ent->item->pickup_sound) {
759 gi.sound(
other, CHAN_ITEM,
gi.soundindex(ent->item->pickup_sound), 1, ATTN_NORM, 0);
783 if (
other == ent->owner)
807 dropped->item = item;
810 dropped->s.renderfx = RF_GLOW;
811 VectorSet(dropped->mins, -15, -15, -15);
812 VectorSet(dropped->maxs, 15, 15, 15);
813 gi.setmodel(dropped, dropped->item->world_model);
814 dropped->solid = SOLID_TRIGGER;
817 dropped->owner = ent;
823 VectorSet(offset, 24, 0, -16);
825 trace =
gi.trace(ent->s.origin, dropped->mins, dropped->maxs,
826 dropped->s.origin, ent, CONTENTS_SOLID);
827 VectorCopy(trace.endpos, dropped->s.origin);
830 VectorCopy(ent->s.origin, dropped->s.origin);
833 VectorScale(
forward, 100, dropped->velocity);
834 dropped->velocity[2] = 300;
839 gi.linkentity(dropped);
846 ent->svflags &= ~SVF_NOCLIENT;
850 ent->solid = SOLID_BBOX;
853 ent->solid = SOLID_TRIGGER;
873 v =
tv(-15, -15, -15);
874 VectorCopy(v, ent->mins);
876 VectorCopy(v, ent->maxs);
879 gi.setmodel(ent, ent->model);
881 gi.setmodel(ent, ent->item->world_model);
882 ent->solid = SOLID_TRIGGER;
887 VectorAdd(ent->s.origin, v, dest);
889 tr =
gi.trace(ent->s.origin, ent->mins, ent->maxs, dest, ent, MASK_SOLID);
891 gi.dprintf(
"droptofloor: %s startsolid at %s\n", ent->classname,
vtos(ent->s.origin));
896 VectorCopy(tr.endpos, ent->s.origin);
900 ent->chain = ent->teamchain;
901 ent->teamchain = NULL;
903 ent->svflags |= SVF_NOCLIENT;
904 ent->solid = SOLID_NOT;
905 if (ent == ent->teammaster) {
912 ent->solid = SOLID_BBOX;
914 ent->s.effects &= ~EF_ROTATE;
915 ent->s.renderfx &= ~RF_GLOW;
919 ent->svflags |= SVF_NOCLIENT;
920 ent->solid = SOLID_NOT;
940 char data[MAX_QPATH];
970 while (*s && *s !=
' ')
974 if (len >= MAX_QPATH || len < 5)
975 gi.error(
"PrecacheItem: %s has bad precache string", it->
classname);
976 memcpy(data, start, len);
982 if (!strcmp(data + len - 3,
"md2"))
984 else if (!strcmp(data + len - 3,
"sp2"))
986 else if (!strcmp(data + len - 3,
"wav"))
988 if (!strcmp(data + len - 3,
"pcx"))
1007 if (ent->spawnflags) {
1008 if (strcmp(ent->classname,
"key_power_cube") != 0) {
1009 ent->spawnflags = 0;
1010 gi.dprintf(
"%s at %s has invalid spawnflags set\n", ent->classname,
vtos(ent->s.origin));
1016 if ((
int)
dmflags->value & DF_NO_ARMOR) {
1022 if ((
int)
dmflags->value & DF_NO_ITEMS) {
1028 if ((
int)
dmflags->value & DF_NO_HEALTH) {
1034 if ((
int)
dmflags->value & DF_INFINITE_AMMO) {
1035 if ((item->
flags ==
IT_AMMO) || (strcmp(ent->classname,
"weapon_bfg") == 0)) {
1042 if (
coop->value && (strcmp(ent->classname,
"key_power_cube") == 0)) {
1056 ent->s.renderfx = RF_GLOW;
1058 gi.modelindex(ent->model);
1080 "misc/ar1_pkup.wav",
1081 "models/items/armor/body/tris.md2", EF_ROTATE,
1098 "item_armor_combat",
1103 "misc/ar1_pkup.wav",
1104 "models/items/armor/combat/tris.md2", EF_ROTATE,
1121 "item_armor_jacket",
1126 "misc/ar1_pkup.wav",
1127 "models/items/armor/jacket/tris.md2", EF_ROTATE,
1149 "misc/ar2_pkup.wav",
1150 "models/items/armor/shard/tris.md2", EF_ROTATE,
1168 "item_power_screen",
1173 "misc/ar3_pkup.wav",
1174 "models/items/armor/screen/tris.md2", EF_ROTATE,
1191 "item_power_shield",
1196 "misc/ar3_pkup.wav",
1197 "models/items/armor/shield/tris.md2", EF_ROTATE,
1208 "misc/power2.wav misc/power1.wav"
1227 "models/weapons/v_blast/tris.md2",
1237 "weapons/blastf1a.wav misc/lasfly.wav"
1249 "models/weapons/g_shotg/tris.md2", EF_ROTATE,
1250 "models/weapons/v_shotg/tris.md2",
1260 "weapons/shotgf1b.wav weapons/shotgr1b.wav"
1266 "weapon_supershotgun",
1272 "models/weapons/g_shotg2/tris.md2", EF_ROTATE,
1273 "models/weapons/v_shotg2/tris.md2",
1283 "weapons/sshotf1b.wav"
1289 "weapon_machinegun",
1295 "models/weapons/g_machn/tris.md2", EF_ROTATE,
1296 "models/weapons/v_machn/tris.md2",
1306 "weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"
1318 "models/weapons/g_chain/tris.md2", EF_ROTATE,
1319 "models/weapons/v_chain/tris.md2",
1329 "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"
1341 "models/items/ammo/grenades/medium/tris.md2", 0,
1342 "models/weapons/v_handgr/tris.md2",
1352 "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "
1358 "weapon_grenadelauncher",
1364 "models/weapons/g_launch/tris.md2", EF_ROTATE,
1365 "models/weapons/v_launch/tris.md2",
1375 "models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"
1381 "weapon_rocketlauncher",
1387 "models/weapons/g_rocket/tris.md2", EF_ROTATE,
1388 "models/weapons/v_rocket/tris.md2",
1398 "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"
1404 "weapon_hyperblaster",
1410 "models/weapons/g_hyperb/tris.md2", EF_ROTATE,
1411 "models/weapons/v_hyperb/tris.md2",
1421 "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"
1433 "models/weapons/g_rail/tris.md2", EF_ROTATE,
1434 "models/weapons/v_rail/tris.md2",
1444 "weapons/rg_hum.wav"
1456 "models/weapons/g_bfg/tris.md2", EF_ROTATE,
1457 "models/weapons/v_bfg/tris.md2",
1467 "sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"
1478 "models/weapons/g_flareg/tris.md2",
1480 "models/weapons/v_flareg/tris.md3",
1505 "models/items/ammo/shells/medium/tris.md2", 0,
1528 "models/items/ammo/bullets/medium/tris.md2", 0,
1551 "models/items/ammo/cells/medium/tris.md2", 0,
1574 "models/items/ammo/rockets/medium/tris.md2", 0,
1597 "models/items/ammo/slugs/medium/tris.md2", 0,
1624 "models/items/quaddama/tris.md2", EF_ROTATE,
1635 "items/damage.wav items/damage2.wav items/damage3.wav"
1641 "item_invulnerability",
1647 "models/items/invulner/tris.md2", EF_ROTATE,
1649 "p_invulnerability",
1658 "items/protect.wav items/protect2.wav items/protect4.wav"
1670 "models/items/silencer/tris.md2", EF_ROTATE,
1693 "models/items/breather/tris.md2", EF_ROTATE,
1716 "models/items/enviro/tris.md2", EF_ROTATE,
1734 "item_ancient_head",
1740 "models/items/c_head/tris.md2", EF_ROTATE,
1764 "models/items/adrenal/tris.md2", EF_ROTATE,
1787 "models/items/band/tris.md2", EF_ROTATE,
1810 "models/items/pack/tris.md2", EF_ROTATE,
1837 "models/items/keys/data_cd/tris.md2", EF_ROTATE,
1861 "models/items/keys/power/tris.md2", EF_ROTATE,
1885 "models/items/keys/pyramid/tris.md2", EF_ROTATE,
1909 "models/items/keys/spinner/tris.md2", EF_ROTATE,
1933 "models/items/keys/pass/tris.md2", EF_ROTATE,
1957 "models/items/keys/key/tris.md2", EF_ROTATE,
1981 "models/items/keys/red_key/tris.md2", EF_ROTATE,
1999 "key_commander_head",
2005 "models/monsters/commandr/head/tris.md2", EF_GIB,
2023 "key_airstrike_target",
2029 "models/items/keys/target/tris.md2", EF_ROTATE,
2061 "items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"
2078 self->model =
"models/items/healing/medium/tris.md2";
2081 gi.soundindex(
"items/n_health.wav");
2093 self->model =
"models/items/healing/stimpack/tris.md2";
2097 gi.soundindex(
"items/s_health.wav");
2109 self->model =
"models/items/healing/large/tris.md2";
2112 gi.soundindex(
"items/l_health.wav");
2124 self->model =
"models/items/mega_h/tris.md2";
2127 gi.soundindex(
"items/m_health.wav");