Quake II RTX doxygen  1.0 dev
g_items.c File Reference
#include "g_local.h"

Go to the source code of this file.

Macros

#define HEALTH_IGNORE_MAX   1
 
#define HEALTH_TIMED   2
 

Functions

qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
 
void Use_Weapon (edict_t *ent, gitem_t *inv)
 
void Drop_Weapon (edict_t *ent, gitem_t *inv)
 
void Weapon_Blaster (edict_t *ent)
 
void Weapon_Shotgun (edict_t *ent)
 
void Weapon_SuperShotgun (edict_t *ent)
 
void Weapon_Machinegun (edict_t *ent)
 
void Weapon_Chaingun (edict_t *ent)
 
void Weapon_HyperBlaster (edict_t *ent)
 
void Weapon_RocketLauncher (edict_t *ent)
 
void Weapon_Grenade (edict_t *ent)
 
void Weapon_GrenadeLauncher (edict_t *ent)
 
void Weapon_Railgun (edict_t *ent)
 
void Weapon_BFG (edict_t *ent)
 
void Weapon_FlareGun (edict_t *ent)
 
void Use_Quad (edict_t *ent, gitem_t *item)
 
gitem_tGetItemByIndex (int index)
 
gitem_tFindItemByClassname (char *classname)
 
gitem_tFindItem (char *pickup_name)
 
void DoRespawn (edict_t *ent)
 
void SetRespawn (edict_t *ent, float delay)
 
qboolean Pickup_Powerup (edict_t *ent, edict_t *other)
 
void Drop_General (edict_t *ent, gitem_t *item)
 
qboolean Pickup_Adrenaline (edict_t *ent, edict_t *other)
 
qboolean Pickup_AncientHead (edict_t *ent, edict_t *other)
 
qboolean Pickup_Bandolier (edict_t *ent, edict_t *other)
 
qboolean Pickup_Pack (edict_t *ent, edict_t *other)
 
void Use_Breather (edict_t *ent, gitem_t *item)
 
void Use_Envirosuit (edict_t *ent, gitem_t *item)
 
void Use_Invulnerability (edict_t *ent, gitem_t *item)
 
void Use_Silencer (edict_t *ent, gitem_t *item)
 
qboolean Pickup_Key (edict_t *ent, edict_t *other)
 
qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count)
 
qboolean Pickup_Ammo (edict_t *ent, edict_t *other)
 
void Drop_Ammo (edict_t *ent, gitem_t *item)
 
void MegaHealth_think (edict_t *self)
 
qboolean Pickup_Health (edict_t *ent, edict_t *other)
 
int ArmorIndex (edict_t *ent)
 
qboolean Pickup_Armor (edict_t *ent, edict_t *other)
 
int PowerArmorType (edict_t *ent)
 
void Use_PowerArmor (edict_t *ent, gitem_t *item)
 
qboolean Pickup_PowerArmor (edict_t *ent, edict_t *other)
 
void Drop_PowerArmor (edict_t *ent, gitem_t *item)
 
void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
 
void drop_temp_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
 
void drop_make_touchable (edict_t *ent)
 
edict_t * Drop_Item (edict_t *ent, gitem_t *item)
 
void Use_Item (edict_t *ent, edict_t *other, edict_t *activator)
 
void droptofloor (edict_t *ent)
 
void PrecacheItem (gitem_t *it)
 
void SpawnItem (edict_t *ent, gitem_t *item)
 
void SP_item_health (edict_t *self)
 
void SP_item_health_small (edict_t *self)
 
void SP_item_health_large (edict_t *self)
 
void SP_item_health_mega (edict_t *self)
 
void InitItems (void)
 
void SetItemNames (void)
 

Variables

gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET}
 
gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT}
 
gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY}
 
static int jacket_armor_index
 
static int combat_armor_index
 
static int body_armor_index
 
static int power_screen_index
 
static int power_shield_index
 
static int quad_drop_timeout_hack
 
gitem_t itemlist []
 

Macro Definition Documentation

◆ HEALTH_IGNORE_MAX

#define HEALTH_IGNORE_MAX   1

Definition at line 48 of file g_items.c.

◆ HEALTH_TIMED

#define HEALTH_TIMED   2

Definition at line 49 of file g_items.c.

Function Documentation

◆ Add_Ammo()

qboolean Add_Ammo ( edict_t *  ent,
gitem_t item,
int  count 
)

Definition at line 426 of file g_items.c.

427 {
428  int index;
429  int max;
430 
431  if (!ent->client)
432  return qfalse;
433 
434  if (item->tag == AMMO_BULLETS)
435  max = ent->client->pers.max_bullets;
436  else if (item->tag == AMMO_SHELLS)
437  max = ent->client->pers.max_shells;
438  else if (item->tag == AMMO_ROCKETS)
439  max = ent->client->pers.max_rockets;
440  else if (item->tag == AMMO_GRENADES)
441  max = ent->client->pers.max_grenades;
442  else if (item->tag == AMMO_CELLS)
443  max = ent->client->pers.max_cells;
444  else if (item->tag == AMMO_SLUGS)
445  max = ent->client->pers.max_slugs;
446  else
447  return qfalse;
448 
449  index = ITEM_INDEX(item);
450 
451  if (ent->client->pers.inventory[index] == max)
452  return qfalse;
453 
454  ent->client->pers.inventory[index] += count;
455 
456  if (ent->client->pers.inventory[index] > max)
457  ent->client->pers.inventory[index] = max;
458 
459  return qtrue;
460 }

Referenced by Cmd_Give_f(), Pickup_Ammo(), and Pickup_Weapon().

◆ ArmorIndex()

int ArmorIndex ( edict_t *  ent)

Definition at line 563 of file g_items.c.

564 {
565  if (!ent->client)
566  return 0;
567 
568  if (ent->client->pers.inventory[jacket_armor_index] > 0)
569  return jacket_armor_index;
570 
571  if (ent->client->pers.inventory[combat_armor_index] > 0)
572  return combat_armor_index;
573 
574  if (ent->client->pers.inventory[body_armor_index] > 0)
575  return body_armor_index;
576 
577  return 0;
578 }

Referenced by CheckArmor(), G_SetStats(), and Pickup_Armor().

◆ DoRespawn()

void DoRespawn ( edict_t *  ent)

Definition at line 116 of file g_items.c.

117 {
118  if (ent->team) {
119  edict_t *master;
120  int count;
121  int choice;
122 
123  master = ent->teammaster;
124 
125  for (count = 0, ent = master; ent; ent = ent->chain, count++)
126  ;
127 
128  choice = rand() % count;
129 
130  for (count = 0, ent = master; count < choice; ent = ent->chain, count++)
131  ;
132  }
133 
134  ent->svflags &= ~SVF_NOCLIENT;
135  ent->solid = SOLID_TRIGGER;
136  gi.linkentity(ent);
137 
138  // send an effect
139  ent->s.event = EV_ITEM_RESPAWN;
140 }

Referenced by droptofloor(), and SetRespawn().

◆ Drop_Ammo()

void Drop_Ammo ( edict_t *  ent,
gitem_t item 
)

Definition at line 491 of file g_items.c.

492 {
493  edict_t *dropped;
494  int index;
495 
496  index = ITEM_INDEX(item);
497  dropped = Drop_Item(ent, item);
498  if (ent->client->pers.inventory[index] >= item->quantity)
499  dropped->count = item->quantity;
500  else
501  dropped->count = ent->client->pers.inventory[index];
502 
503  if (ent->client->pers.weapon &&
504  ent->client->pers.weapon->tag == AMMO_GRENADES &&
505  item->tag == AMMO_GRENADES &&
506  ent->client->pers.inventory[index] - dropped->count <= 0) {
507  gi.cprintf(ent, PRINT_HIGH, "Can't drop current weapon\n");
508  G_FreeEdict(dropped);
509  return;
510  }
511 
512  ent->client->pers.inventory[index] -= dropped->count;
514 }

◆ Drop_General()

void Drop_General ( edict_t *  ent,
gitem_t item 
)

Definition at line 181 of file g_items.c.

182 {
183  Drop_Item(ent, item);
184  ent->client->pers.inventory[ITEM_INDEX(item)]--;
186 }

Referenced by Drop_PowerArmor().

◆ Drop_Item()

edict_t* Drop_Item ( edict_t *  ent,
gitem_t item 
)

Definition at line 798 of file g_items.c.

799 {
800  edict_t *dropped;
801  vec3_t forward, right;
802  vec3_t offset;
803 
804  dropped = G_Spawn();
805 
806  dropped->classname = item->classname;
807  dropped->item = item;
808  dropped->spawnflags = DROPPED_ITEM;
809  dropped->s.effects = item->world_model_flags;
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;
815  dropped->movetype = MOVETYPE_TOSS;
816  dropped->touch = drop_temp_touch;
817  dropped->owner = ent;
818 
819  if (ent->client) {
820  trace_t trace;
821 
822  AngleVectors(ent->client->v_angle, forward, right, NULL);
823  VectorSet(offset, 24, 0, -16);
824  G_ProjectSource(ent->s.origin, offset, forward, right, dropped->s.origin);
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);
828  } else {
829  AngleVectors(ent->s.angles, forward, right, NULL);
830  VectorCopy(ent->s.origin, dropped->s.origin);
831  }
832 
833  VectorScale(forward, 100, dropped->velocity);
834  dropped->velocity[2] = 300;
835 
836  dropped->think = drop_make_touchable;
837  dropped->nextthink = level.time + 1;
838 
839  gi.linkentity(dropped);
840 
841  return dropped;
842 }

Referenced by Drop_Ammo(), Drop_General(), Drop_Weapon(), monster_death_use(), and TossClientWeapon().

◆ drop_make_touchable()

void drop_make_touchable ( edict_t *  ent)

Definition at line 789 of file g_items.c.

790 {
791  ent->touch = Touch_Item;
792  if (deathmatch->value) {
793  ent->nextthink = level.time + 29;
794  ent->think = G_FreeEdict;
795  }
796 }

Referenced by Drop_Item().

◆ Drop_PowerArmor()

void Drop_PowerArmor ( edict_t *  ent,
gitem_t item 
)

Definition at line 709 of file g_items.c.

710 {
711  if ((ent->flags & FL_POWER_ARMOR) && (ent->client->pers.inventory[ITEM_INDEX(item)] == 1))
712  Use_PowerArmor(ent, item);
713  Drop_General(ent, item);
714 }

◆ drop_temp_touch()

void drop_temp_touch ( edict_t *  ent,
edict_t *  other,
cplane_t *  plane,
csurface_t *  surf 
)

Definition at line 781 of file g_items.c.

782 {
783  if (other == ent->owner)
784  return;
785 
786  Touch_Item(ent, other, plane, surf);
787 }

Referenced by Drop_Item().

◆ Drop_Weapon()

void Drop_Weapon ( edict_t *  ent,
gitem_t inv 
)

Definition at line 322 of file p_weapon.c.

323 {
324  int index;
325 
326  if ((int)(dmflags->value) & DF_WEAPONS_STAY)
327  return;
328 
329  index = ITEM_INDEX(item);
330  // see if we're already using it
331  if (((item == ent->client->pers.weapon) || (item == ent->client->newweapon)) && (ent->client->pers.inventory[index] == 1)) {
332  gi.cprintf(ent, PRINT_HIGH, "Can't drop current weapon\n");
333  return;
334  }
335 
336  Drop_Item(ent, item);
337  ent->client->pers.inventory[index]--;
338 }

◆ droptofloor()

void droptofloor ( edict_t *  ent)

Definition at line 867 of file g_items.c.

868 {
869  trace_t tr;
870  vec3_t dest;
871  float *v;
872 
873  v = tv(-15, -15, -15);
874  VectorCopy(v, ent->mins);
875  v = tv(15, 15, 15);
876  VectorCopy(v, ent->maxs);
877 
878  if (ent->model)
879  gi.setmodel(ent, ent->model);
880  else
881  gi.setmodel(ent, ent->item->world_model);
882  ent->solid = SOLID_TRIGGER;
883  ent->movetype = MOVETYPE_TOSS;
884  ent->touch = Touch_Item;
885 
886  v = tv(0, 0, -128);
887  VectorAdd(ent->s.origin, v, dest);
888 
889  tr = gi.trace(ent->s.origin, ent->mins, ent->maxs, dest, ent, MASK_SOLID);
890  if (tr.startsolid) {
891  gi.dprintf("droptofloor: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin));
892  G_FreeEdict(ent);
893  return;
894  }
895 
896  VectorCopy(tr.endpos, ent->s.origin);
897 
898  if (ent->team) {
899  ent->flags &= ~FL_TEAMSLAVE;
900  ent->chain = ent->teamchain;
901  ent->teamchain = NULL;
902 
903  ent->svflags |= SVF_NOCLIENT;
904  ent->solid = SOLID_NOT;
905  if (ent == ent->teammaster) {
906  ent->nextthink = level.time + FRAMETIME;
907  ent->think = DoRespawn;
908  }
909  }
910 
911  if (ent->spawnflags & ITEM_NO_TOUCH) {
912  ent->solid = SOLID_BBOX;
913  ent->touch = NULL;
914  ent->s.effects &= ~EF_ROTATE;
915  ent->s.renderfx &= ~RF_GLOW;
916  }
917 
918  if (ent->spawnflags & ITEM_TRIGGER_SPAWN) {
919  ent->svflags |= SVF_NOCLIENT;
920  ent->solid = SOLID_NOT;
921  ent->use = Use_Item;
922  }
923 
924  gi.linkentity(ent);
925 }

Referenced by SpawnItem().

◆ FindItem()

gitem_t* FindItem ( char *  pickup_name)

Definition at line 98 of file g_items.c.

99 {
100  int i;
101  gitem_t *it;
102 
103  it = itemlist;
104  for (i = 0 ; i < game.num_items ; i++, it++) {
105  if (!it->pickup_name)
106  continue;
107  if (!Q_stricmp(it->pickup_name, pickup_name))
108  return it;
109  }
110 
111  return NULL;
112 }

Referenced by ChangeWeapon(), CheckPowerArmor(), Cmd_Drop_f(), Cmd_Give_f(), Cmd_Use_f(), G_SetStats(), InitClientPersistant(), NoAmmoWeaponChange(), Pickup_Ammo(), Pickup_Bandolier(), Pickup_Pack(), Pickup_Weapon(), PrecacheItem(), SetItemNames(), SP_item_health(), SP_item_health_large(), SP_item_health_mega(), SP_item_health_small(), SP_worldspawn(), Use_PowerArmor(), and Use_Weapon().

◆ FindItemByClassname()

gitem_t* FindItemByClassname ( char *  classname)

Definition at line 76 of file g_items.c.

77 {
78  int i;
79  gitem_t *it;
80 
81  it = itemlist;
82  for (i = 0 ; i < game.num_items ; i++, it++) {
83  if (!it->classname)
84  continue;
85  if (!Q_stricmp(it->classname, classname))
86  return it;
87  }
88 
89  return NULL;
90 }

Referenced by monster_start(), SP_trigger_key(), SP_turret_driver(), and TossClientWeapon().

◆ GetItemByIndex()

gitem_t* GetItemByIndex ( int  index)

Definition at line 61 of file g_items.c.

62 {
63  if (index == 0 || index >= game.num_items)
64  return NULL;
65 
66  return &itemlist[index];
67 }

Referenced by CheckArmor(), and G_SetStats().

◆ InitItems()

void InitItems ( void  )

Definition at line 2132 of file g_items.c.

2133 {
2134  game.num_items = sizeof(itemlist) / sizeof(itemlist[0]) - 1;
2135 }

Referenced by InitGame().

◆ MegaHealth_think()

void MegaHealth_think ( edict_t *  self)

Definition at line 519 of file g_items.c.

520 {
521  if (self->owner->health > self->owner->max_health) {
522  self->nextthink = level.time + 1;
523  self->owner->health -= 1;
524  return;
525  }
526 
527  if (!(self->spawnflags & DROPPED_ITEM) && (deathmatch->value))
528  SetRespawn(self, 20);
529  else
530  G_FreeEdict(self);
531 }

Referenced by Pickup_Health().

◆ Pickup_Adrenaline()

qboolean Pickup_Adrenaline ( edict_t *  ent,
edict_t *  other 
)

Definition at line 191 of file g_items.c.

192 {
193  if (!deathmatch->value)
194  other->max_health += 1;
195 
196  if (other->health < other->max_health)
197  other->health = other->max_health;
198 
199  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
200  SetRespawn(ent, ent->item->quantity);
201 
202  return qtrue;
203 }

Referenced by SpawnItem().

◆ Pickup_Ammo()

qboolean Pickup_Ammo ( edict_t *  ent,
edict_t *  other 
)

Definition at line 462 of file g_items.c.

463 {
464  int oldcount;
465  int count;
466  qboolean weapon;
467 
468  weapon = (ent->item->flags & IT_WEAPON);
469  if ((weapon) && ((int)dmflags->value & DF_INFINITE_AMMO))
470  count = 1000;
471  else if (ent->count)
472  count = ent->count;
473  else
474  count = ent->item->quantity;
475 
476  oldcount = other->client->pers.inventory[ITEM_INDEX(ent->item)];
477 
478  if (!Add_Ammo(other, ent->item, count))
479  return qfalse;
480 
481  if (weapon && !oldcount) {
482  if (other->client->pers.weapon != ent->item && (!deathmatch->value || other->client->pers.weapon == FindItem("blaster")))
483  other->client->newweapon = ent->item;
484  }
485 
486  if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value))
487  SetRespawn(ent, 30);
488  return qtrue;
489 }

◆ Pickup_AncientHead()

qboolean Pickup_AncientHead ( edict_t *  ent,
edict_t *  other 
)

Definition at line 205 of file g_items.c.

206 {
207  other->max_health += 2;
208 
209  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
210  SetRespawn(ent, ent->item->quantity);
211 
212  return qtrue;
213 }

Referenced by SpawnItem().

◆ Pickup_Armor()

qboolean Pickup_Armor ( edict_t *  ent,
edict_t *  other 
)

Definition at line 580 of file g_items.c.

581 {
582  int old_armor_index;
583  gitem_armor_t *oldinfo;
584  gitem_armor_t *newinfo;
585  int newcount;
586  float salvage;
587  int salvagecount;
588 
589  // get info on new armor
590  newinfo = (gitem_armor_t *)ent->item->info;
591 
592  old_armor_index = ArmorIndex(other);
593 
594  // handle armor shards specially
595  if (ent->item->tag == ARMOR_SHARD) {
596  if (!old_armor_index)
597  other->client->pers.inventory[jacket_armor_index] = 2;
598  else
599  other->client->pers.inventory[old_armor_index] += 2;
600  }
601 
602  // if player has no armor, just use it
603  else if (!old_armor_index) {
604  other->client->pers.inventory[ITEM_INDEX(ent->item)] = newinfo->base_count;
605  }
606 
607  // use the better armor
608  else {
609  // get info on old armor
610  if (old_armor_index == jacket_armor_index)
611  oldinfo = &jacketarmor_info;
612  else if (old_armor_index == combat_armor_index)
613  oldinfo = &combatarmor_info;
614  else // (old_armor_index == body_armor_index)
615  oldinfo = &bodyarmor_info;
616 
617  if (newinfo->normal_protection > oldinfo->normal_protection) {
618  // calc new armor values
619  salvage = oldinfo->normal_protection / newinfo->normal_protection;
620  salvagecount = salvage * other->client->pers.inventory[old_armor_index];
621  newcount = newinfo->base_count + salvagecount;
622  if (newcount > newinfo->max_count)
623  newcount = newinfo->max_count;
624 
625  // zero count of old armor so it goes away
626  other->client->pers.inventory[old_armor_index] = 0;
627 
628  // change armor to new item with computed value
629  other->client->pers.inventory[ITEM_INDEX(ent->item)] = newcount;
630  } else {
631  // calc new armor values
632  salvage = newinfo->normal_protection / oldinfo->normal_protection;
633  salvagecount = salvage * newinfo->base_count;
634  newcount = other->client->pers.inventory[old_armor_index] + salvagecount;
635  if (newcount > oldinfo->max_count)
636  newcount = oldinfo->max_count;
637 
638  // if we're already maxed out then we don't need the new armor
639  if (other->client->pers.inventory[old_armor_index] >= newcount)
640  return qfalse;
641 
642  // update current armor value
643  other->client->pers.inventory[old_armor_index] = newcount;
644  }
645  }
646 
647  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
648  SetRespawn(ent, 20);
649 
650  return qtrue;
651 }

Referenced by SpawnItem().

◆ Pickup_Bandolier()

qboolean Pickup_Bandolier ( edict_t *  ent,
edict_t *  other 
)

Definition at line 215 of file g_items.c.

216 {
217  gitem_t *item;
218  int index;
219 
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;
228 
229  item = FindItem("Bullets");
230  if (item) {
231  index = ITEM_INDEX(item);
232  other->client->pers.inventory[index] += item->quantity;
233  if (other->client->pers.inventory[index] > other->client->pers.max_bullets)
234  other->client->pers.inventory[index] = other->client->pers.max_bullets;
235  }
236 
237  item = FindItem("Shells");
238  if (item) {
239  index = ITEM_INDEX(item);
240  other->client->pers.inventory[index] += item->quantity;
241  if (other->client->pers.inventory[index] > other->client->pers.max_shells)
242  other->client->pers.inventory[index] = other->client->pers.max_shells;
243  }
244 
245  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
246  SetRespawn(ent, ent->item->quantity);
247 
248  return qtrue;
249 }

◆ Pickup_Health()

qboolean Pickup_Health ( edict_t *  ent,
edict_t *  other 
)

Definition at line 533 of file g_items.c.

534 {
535  if (!(ent->style & HEALTH_IGNORE_MAX))
536  if (other->health >= other->max_health)
537  return qfalse;
538 
539  other->health += ent->count;
540 
541  if (!(ent->style & HEALTH_IGNORE_MAX)) {
542  if (other->health > other->max_health)
543  other->health = other->max_health;
544  }
545 
546  if (ent->style & HEALTH_TIMED) {
547  ent->think = MegaHealth_think;
548  ent->nextthink = level.time + 5;
549  ent->owner = other;
550  ent->flags |= FL_RESPAWN;
551  ent->svflags |= SVF_NOCLIENT;
552  ent->solid = SOLID_NOT;
553  } else {
554  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
555  SetRespawn(ent, 30);
556  }
557 
558  return qtrue;
559 }

Referenced by SpawnItem(), and Touch_Item().

◆ Pickup_Key()

qboolean Pickup_Key ( edict_t *  ent,
edict_t *  other 
)

Definition at line 405 of file g_items.c.

406 {
407  if (coop->value) {
408  if (strcmp(ent->classname, "key_power_cube") == 0) {
409  if (other->client->pers.power_cubes & ((ent->spawnflags & 0x0000ff00) >> 8))
410  return qfalse;
411  other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
412  other->client->pers.power_cubes |= ((ent->spawnflags & 0x0000ff00) >> 8);
413  } else {
414  if (other->client->pers.inventory[ITEM_INDEX(ent->item)])
415  return qfalse;
416  other->client->pers.inventory[ITEM_INDEX(ent->item)] = 1;
417  }
418  return qtrue;
419  }
420  other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
421  return qtrue;
422 }

◆ Pickup_Pack()

qboolean Pickup_Pack ( edict_t *  ent,
edict_t *  other 
)

Definition at line 251 of file g_items.c.

252 {
253  gitem_t *item;
254  int index;
255 
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;
268 
269  item = FindItem("Bullets");
270  if (item) {
271  index = ITEM_INDEX(item);
272  other->client->pers.inventory[index] += item->quantity;
273  if (other->client->pers.inventory[index] > other->client->pers.max_bullets)
274  other->client->pers.inventory[index] = other->client->pers.max_bullets;
275  }
276 
277  item = FindItem("Shells");
278  if (item) {
279  index = ITEM_INDEX(item);
280  other->client->pers.inventory[index] += item->quantity;
281  if (other->client->pers.inventory[index] > other->client->pers.max_shells)
282  other->client->pers.inventory[index] = other->client->pers.max_shells;
283  }
284 
285  item = FindItem("Cells");
286  if (item) {
287  index = ITEM_INDEX(item);
288  other->client->pers.inventory[index] += item->quantity;
289  if (other->client->pers.inventory[index] > other->client->pers.max_cells)
290  other->client->pers.inventory[index] = other->client->pers.max_cells;
291  }
292 
293  item = FindItem("Grenades");
294  if (item) {
295  index = ITEM_INDEX(item);
296  other->client->pers.inventory[index] += item->quantity;
297  if (other->client->pers.inventory[index] > other->client->pers.max_grenades)
298  other->client->pers.inventory[index] = other->client->pers.max_grenades;
299  }
300 
301  item = FindItem("Rockets");
302  if (item) {
303  index = ITEM_INDEX(item);
304  other->client->pers.inventory[index] += item->quantity;
305  if (other->client->pers.inventory[index] > other->client->pers.max_rockets)
306  other->client->pers.inventory[index] = other->client->pers.max_rockets;
307  }
308 
309  item = FindItem("Slugs");
310  if (item) {
311  index = ITEM_INDEX(item);
312  other->client->pers.inventory[index] += item->quantity;
313  if (other->client->pers.inventory[index] > other->client->pers.max_slugs)
314  other->client->pers.inventory[index] = other->client->pers.max_slugs;
315  }
316 
317  if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
318  SetRespawn(ent, ent->item->quantity);
319 
320  return qtrue;
321 }

◆ Pickup_PowerArmor()

qboolean Pickup_PowerArmor ( edict_t *  ent,
edict_t *  other 
)

Definition at line 690 of file g_items.c.

691 {
692  int quantity;
693 
694  quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)];
695 
696  other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
697 
698  if (deathmatch->value) {
699  if (!(ent->spawnflags & DROPPED_ITEM))
700  SetRespawn(ent, ent->item->quantity);
701  // auto-use for DM only if we didn't already have one
702  if (!quantity)
703  ent->item->use(other, ent->item);
704  }
705 
706  return qtrue;
707 }

Referenced by SpawnItem().

◆ Pickup_Powerup()

qboolean Pickup_Powerup ( edict_t *  ent,
edict_t *  other 
)

Definition at line 155 of file g_items.c.

156 {
157  int quantity;
158 
159  quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)];
160  if ((skill->value == 1 && quantity >= 2) || (skill->value >= 2 && quantity >= 1))
161  return qfalse;
162 
163  if ((coop->value) && (ent->item->flags & IT_STAY_COOP) && (quantity > 0))
164  return qfalse;
165 
166  other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
167 
168  if (deathmatch->value) {
169  if (!(ent->spawnflags & DROPPED_ITEM))
170  SetRespawn(ent, ent->item->quantity);
171  if (((int)dmflags->value & DF_INSTANT_ITEMS) || ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM))) {
172  if ((ent->item->use == Use_Quad) && (ent->spawnflags & DROPPED_PLAYER_ITEM))
173  quad_drop_timeout_hack = (ent->nextthink - level.time) / FRAMETIME;
174  ent->item->use(other, ent->item);
175  }
176  }
177 
178  return qtrue;
179 }

Referenced by SpawnItem().

◆ Pickup_Weapon()

qboolean Pickup_Weapon ( edict_t *  ent,
edict_t *  other 
)

Definition at line 110 of file p_weapon.c.

111 {
112  int index;
113  gitem_t *ammo;
114 
115  index = ITEM_INDEX(ent->item);
116 
117  if ((((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value)
118  && other->client->pers.inventory[index]) {
119  if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
120  return qfalse; // leave the weapon for others to pickup
121  }
122 
123  other->client->pers.inventory[index]++;
124 
125  if (!(ent->spawnflags & DROPPED_ITEM)) {
126  // give them some ammo with it
127  ammo = FindItem(ent->item->ammo);
128  if ((int)dmflags->value & DF_INFINITE_AMMO)
129  Add_Ammo(other, ammo, 1000);
130  else
131  Add_Ammo(other, ammo, ammo->quantity);
132 
133  if (!(ent->spawnflags & DROPPED_PLAYER_ITEM)) {
134  if (deathmatch->value) {
135  if ((int)(dmflags->value) & DF_WEAPONS_STAY)
136  ent->flags |= FL_RESPAWN;
137  else
138  SetRespawn(ent, 30);
139  }
140  if (coop->value)
141  ent->flags |= FL_RESPAWN;
142  }
143  }
144 
145  if (other->client->pers.weapon != ent->item &&
146  (other->client->pers.inventory[index] == 1) &&
147  (!deathmatch->value || other->client->pers.weapon == FindItem("blaster")))
148  other->client->newweapon = ent->item;
149 
150  return qtrue;
151 }

◆ PowerArmorType()

int PowerArmorType ( edict_t *  ent)

Definition at line 655 of file g_items.c.

656 {
657  if (!ent->client)
658  return POWER_ARMOR_NONE;
659 
660  if (!(ent->flags & FL_POWER_ARMOR))
661  return POWER_ARMOR_NONE;
662 
663  if (ent->client->pers.inventory[power_shield_index] > 0)
664  return POWER_ARMOR_SHIELD;
665 
666  if (ent->client->pers.inventory[power_screen_index] > 0)
667  return POWER_ARMOR_SCREEN;
668 
669  return POWER_ARMOR_NONE;
670 }

Referenced by CheckPowerArmor(), G_SetClientEffects(), and G_SetStats().

◆ PrecacheItem()

void PrecacheItem ( gitem_t it)

Definition at line 937 of file g_items.c.

938 {
939  char *s, *start;
940  char data[MAX_QPATH];
941  int len;
942  gitem_t *ammo;
943 
944  if (!it)
945  return;
946 
947  if (it->pickup_sound)
948  gi.soundindex(it->pickup_sound);
949  if (it->world_model)
950  gi.modelindex(it->world_model);
951  if (it->view_model)
952  gi.modelindex(it->view_model);
953  if (it->icon)
954  gi.imageindex(it->icon);
955 
956  // parse everything for its ammo
957  if (it->ammo && it->ammo[0]) {
958  ammo = FindItem(it->ammo);
959  if (ammo != it)
960  PrecacheItem(ammo);
961  }
962 
963  // parse the space seperated precache string for other items
964  s = it->precaches;
965  if (!s || !s[0])
966  return;
967 
968  while (*s) {
969  start = s;
970  while (*s && *s != ' ')
971  s++;
972 
973  len = s - start;
974  if (len >= MAX_QPATH || len < 5)
975  gi.error("PrecacheItem: %s has bad precache string", it->classname);
976  memcpy(data, start, len);
977  data[len] = 0;
978  if (*s)
979  s++;
980 
981  // determine type based on extension
982  if (!strcmp(data + len - 3, "md2"))
983  gi.modelindex(data);
984  else if (!strcmp(data + len - 3, "sp2"))
985  gi.modelindex(data);
986  else if (!strcmp(data + len - 3, "wav"))
987  gi.soundindex(data);
988  if (!strcmp(data + len - 3, "pcx"))
989  gi.imageindex(data);
990  }
991 }

Referenced by PrecacheItem(), SP_worldspawn(), and SpawnItem().

◆ SetItemNames()

void SetItemNames ( void  )

Definition at line 2146 of file g_items.c.

2147 {
2148  int i;
2149  gitem_t *it;
2150 
2151  for (i = 0 ; i < game.num_items ; i++) {
2152  it = &itemlist[i];
2153  gi.configstring(CS_ITEMS + i, it->pickup_name);
2154  }
2155 
2156  jacket_armor_index = ITEM_INDEX(FindItem("Jacket Armor"));
2157  combat_armor_index = ITEM_INDEX(FindItem("Combat Armor"));
2158  body_armor_index = ITEM_INDEX(FindItem("Body Armor"));
2159  power_screen_index = ITEM_INDEX(FindItem("Power Screen"));
2160  power_shield_index = ITEM_INDEX(FindItem("Power Shield"));
2161 }

Referenced by SP_worldspawn().

◆ SetRespawn()

void SetRespawn ( edict_t *  ent,
float  delay 
)

Definition at line 142 of file g_items.c.

143 {
144  ent->flags |= FL_RESPAWN;
145  ent->svflags |= SVF_NOCLIENT;
146  ent->solid = SOLID_NOT;
147  ent->nextthink = level.time + delay;
148  ent->think = DoRespawn;
149  gi.linkentity(ent);
150 }

Referenced by MegaHealth_think(), Pickup_Adrenaline(), Pickup_Ammo(), Pickup_AncientHead(), Pickup_Armor(), Pickup_Bandolier(), Pickup_Health(), Pickup_Pack(), Pickup_PowerArmor(), Pickup_Powerup(), and Pickup_Weapon().

◆ SP_item_health()

void SP_item_health ( edict_t *  self)

Definition at line 2071 of file g_items.c.

2072 {
2073  if (deathmatch->value && ((int)dmflags->value & DF_NO_HEALTH)) {
2074  G_FreeEdict(self);
2075  return;
2076  }
2077 
2078  self->model = "models/items/healing/medium/tris.md2";
2079  self->count = 10;
2080  SpawnItem(self, FindItem("Health"));
2081  gi.soundindex("items/n_health.wav");
2082 }

◆ SP_item_health_large()

void SP_item_health_large ( edict_t *  self)

Definition at line 2102 of file g_items.c.

2103 {
2104  if (deathmatch->value && ((int)dmflags->value & DF_NO_HEALTH)) {
2105  G_FreeEdict(self);
2106  return;
2107  }
2108 
2109  self->model = "models/items/healing/large/tris.md2";
2110  self->count = 25;
2111  SpawnItem(self, FindItem("Health"));
2112  gi.soundindex("items/l_health.wav");
2113 }

◆ SP_item_health_mega()

void SP_item_health_mega ( edict_t *  self)

Definition at line 2117 of file g_items.c.

2118 {
2119  if (deathmatch->value && ((int)dmflags->value & DF_NO_HEALTH)) {
2120  G_FreeEdict(self);
2121  return;
2122  }
2123 
2124  self->model = "models/items/mega_h/tris.md2";
2125  self->count = 100;
2126  SpawnItem(self, FindItem("Health"));
2127  gi.soundindex("items/m_health.wav");
2128  self->style = HEALTH_IGNORE_MAX | HEALTH_TIMED;
2129 }

◆ SP_item_health_small()

void SP_item_health_small ( edict_t *  self)

Definition at line 2086 of file g_items.c.

2087 {
2088  if (deathmatch->value && ((int)dmflags->value & DF_NO_HEALTH)) {
2089  G_FreeEdict(self);
2090  return;
2091  }
2092 
2093  self->model = "models/items/healing/stimpack/tris.md2";
2094  self->count = 2;
2095  SpawnItem(self, FindItem("Health"));
2096  self->style = HEALTH_IGNORE_MAX;
2097  gi.soundindex("items/s_health.wav");
2098 }

◆ SpawnItem()

void SpawnItem ( edict_t *  ent,
gitem_t item 
)

Definition at line 1003 of file g_items.c.

1004 {
1005  PrecacheItem(item);
1006 
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));
1011  }
1012  }
1013 
1014  // some items will be prevented in deathmatch
1015  if (deathmatch->value) {
1016  if ((int)dmflags->value & DF_NO_ARMOR) {
1017  if (item->pickup == Pickup_Armor || item->pickup == Pickup_PowerArmor) {
1018  G_FreeEdict(ent);
1019  return;
1020  }
1021  }
1022  if ((int)dmflags->value & DF_NO_ITEMS) {
1023  if (item->pickup == Pickup_Powerup) {
1024  G_FreeEdict(ent);
1025  return;
1026  }
1027  }
1028  if ((int)dmflags->value & DF_NO_HEALTH) {
1029  if (item->pickup == Pickup_Health || item->pickup == Pickup_Adrenaline || item->pickup == Pickup_AncientHead) {
1030  G_FreeEdict(ent);
1031  return;
1032  }
1033  }
1034  if ((int)dmflags->value & DF_INFINITE_AMMO) {
1035  if ((item->flags == IT_AMMO) || (strcmp(ent->classname, "weapon_bfg") == 0)) {
1036  G_FreeEdict(ent);
1037  return;
1038  }
1039  }
1040  }
1041 
1042  if (coop->value && (strcmp(ent->classname, "key_power_cube") == 0)) {
1043  ent->spawnflags |= (1 << (8 + level.power_cubes));
1044  level.power_cubes++;
1045  }
1046 
1047  // don't let them drop items that stay in a coop game
1048  if ((coop->value) && (item->flags & IT_STAY_COOP)) {
1049  item->drop = NULL;
1050  }
1051 
1052  ent->item = item;
1053  ent->nextthink = level.time + 2 * FRAMETIME; // items start after other solids
1054  ent->think = droptofloor;
1055  ent->s.effects = item->world_model_flags;
1056  ent->s.renderfx = RF_GLOW;
1057  if (ent->model)
1058  gi.modelindex(ent->model);
1059 }

Referenced by Cmd_Give_f(), ED_CallSpawn(), SP_item_health(), SP_item_health_large(), SP_item_health_mega(), and SP_item_health_small().

◆ Touch_Item()

void Touch_Item ( edict_t *  ent,
edict_t *  other,
cplane_t *  plane,
csurface_t *  surf 
)

Definition at line 723 of file g_items.c.

724 {
725  qboolean taken;
726 
727  if (!other->client)
728  return;
729  if (other->health < 1)
730  return; // dead people can't pickup
731  if (!ent->item->pickup)
732  return; // not a grabbable item?
733 
734  taken = ent->item->pickup(ent, other);
735 
736  if (taken) {
737  // flash the screen
738  other->client->bonus_alpha = 0.25;
739 
740  // show icon and name on status bar
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);
743  other->client->pickup_msg_time = level.time + 3.0;
744 
745  // change selected item
746  if (ent->item->use)
747  other->client->pers.selected_item = other->client->ps.stats[STAT_SELECTED_ITEM] = ITEM_INDEX(ent->item);
748 
749  if (ent->item->pickup == Pickup_Health) {
750  if (ent->count == 2)
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);
756  else // (ent->count == 100)
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);
760  }
761  }
762 
763  if (!(ent->spawnflags & ITEM_TARGETS_USED)) {
764  G_UseTargets(ent, other);
765  ent->spawnflags |= ITEM_TARGETS_USED;
766  }
767 
768  if (!taken)
769  return;
770 
771  if (!((coop->value) && (ent->item->flags & IT_STAY_COOP)) || (ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM))) {
772  if (ent->flags & FL_RESPAWN)
773  ent->flags &= ~FL_RESPAWN;
774  else
775  G_FreeEdict(ent);
776  }
777 }

Referenced by Cmd_Give_f(), drop_make_touchable(), drop_temp_touch(), droptofloor(), TossClientWeapon(), and Use_Item().

◆ Use_Breather()

void Use_Breather ( edict_t *  ent,
gitem_t item 
)

Definition at line 349 of file g_items.c.

350 {
351  ent->client->pers.inventory[ITEM_INDEX(item)]--;
353 
354  if (ent->client->breather_framenum > level.framenum)
355  ent->client->breather_framenum += 300;
356  else
357  ent->client->breather_framenum = level.framenum + 300;
358 
359 // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
360 }

◆ Use_Envirosuit()

void Use_Envirosuit ( edict_t *  ent,
gitem_t item 
)

Definition at line 364 of file g_items.c.

365 {
366  ent->client->pers.inventory[ITEM_INDEX(item)]--;
368 
369  if (ent->client->enviro_framenum > level.framenum)
370  ent->client->enviro_framenum += 300;
371  else
372  ent->client->enviro_framenum = level.framenum + 300;
373 
374 // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
375 }

◆ Use_Invulnerability()

void Use_Invulnerability ( edict_t *  ent,
gitem_t item 
)

Definition at line 379 of file g_items.c.

380 {
381  ent->client->pers.inventory[ITEM_INDEX(item)]--;
383 
384  if (ent->client->invincible_framenum > level.framenum)
385  ent->client->invincible_framenum += 300;
386  else
387  ent->client->invincible_framenum = level.framenum + 300;
388 
389  gi.sound(ent, CHAN_ITEM, gi.soundindex("items/protect.wav"), 1, ATTN_NORM, 0);
390 }

◆ Use_Item()

void Use_Item ( edict_t *  ent,
edict_t *  other,
edict_t *  activator 
)

Definition at line 844 of file g_items.c.

845 {
846  ent->svflags &= ~SVF_NOCLIENT;
847  ent->use = NULL;
848 
849  if (ent->spawnflags & ITEM_NO_TOUCH) {
850  ent->solid = SOLID_BBOX;
851  ent->touch = NULL;
852  } else {
853  ent->solid = SOLID_TRIGGER;
854  ent->touch = Touch_Item;
855  }
856 
857  gi.linkentity(ent);
858 }

Referenced by droptofloor().

◆ Use_PowerArmor()

void Use_PowerArmor ( edict_t *  ent,
gitem_t item 
)

Definition at line 672 of file g_items.c.

673 {
674  int index;
675 
676  if (ent->flags & FL_POWER_ARMOR) {
677  ent->flags &= ~FL_POWER_ARMOR;
678  gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0);
679  } else {
680  index = ITEM_INDEX(FindItem("cells"));
681  if (!ent->client->pers.inventory[index]) {
682  gi.cprintf(ent, PRINT_HIGH, "No cells for power armor.\n");
683  return;
684  }
685  ent->flags |= FL_POWER_ARMOR;
686  gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/power1.wav"), 1, ATTN_NORM, 0);
687  }
688 }

Referenced by Drop_PowerArmor().

◆ Use_Quad()

void Use_Quad ( edict_t *  ent,
gitem_t item 
)

Definition at line 325 of file g_items.c.

326 {
327  int timeout;
328 
329  ent->client->pers.inventory[ITEM_INDEX(item)]--;
331 
333  timeout = quad_drop_timeout_hack;
335  } else {
336  timeout = 300;
337  }
338 
339  if (ent->client->quad_framenum > level.framenum)
340  ent->client->quad_framenum += timeout;
341  else
342  ent->client->quad_framenum = level.framenum + timeout;
343 
344  gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
345 }

Referenced by Pickup_Powerup().

◆ Use_Silencer()

void Use_Silencer ( edict_t *  ent,
gitem_t item 
)

Definition at line 394 of file g_items.c.

395 {
396  ent->client->pers.inventory[ITEM_INDEX(item)]--;
398  ent->client->silencer_shots += 30;
399 
400 // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
401 }

◆ Use_Weapon()

void Use_Weapon ( edict_t *  ent,
gitem_t inv 
)

Definition at line 287 of file p_weapon.c.

288 {
289  int ammo_index;
290  gitem_t *ammo_item;
291 
292  // see if we're already using it
293  if (item == ent->client->pers.weapon)
294  return;
295 
296  if (item->ammo && !g_select_empty->value && !(item->flags & IT_AMMO)) {
297  ammo_item = FindItem(item->ammo);
298  ammo_index = ITEM_INDEX(ammo_item);
299 
300  if (!ent->client->pers.inventory[ammo_index]) {
301  gi.cprintf(ent, PRINT_HIGH, "No %s for %s.\n", ammo_item->pickup_name, item->pickup_name);
302  return;
303  }
304 
305  if (ent->client->pers.inventory[ammo_index] < item->quantity) {
306  gi.cprintf(ent, PRINT_HIGH, "Not enough %s for %s.\n", ammo_item->pickup_name, item->pickup_name);
307  return;
308  }
309  }
310 
311  // change to this weapon when down
312  ent->client->newweapon = item;
313 }

◆ Weapon_BFG()

void Weapon_BFG ( edict_t *  ent)

Definition at line 1294 of file p_weapon.c.

1295 {
1296  static int pause_frames[] = {39, 45, 50, 55, 0};
1297  static int fire_frames[] = {9, 17, 0};
1298 
1299  Weapon_Generic(ent, 8, 32, 55, 58, pause_frames, fire_frames, weapon_bfg_fire);
1300 }

◆ Weapon_Blaster()

void Weapon_Blaster ( edict_t *  ent)

Definition at line 774 of file p_weapon.c.

775 {
776  static int pause_frames[] = {19, 32, 0};
777  static int fire_frames[] = {5, 0};
778 
779  Weapon_Generic(ent, 4, 8, 52, 55, pause_frames, fire_frames, Weapon_Blaster_Fire);
780 }

◆ Weapon_Chaingun()

void Weapon_Chaingun ( edict_t *  ent)

Definition at line 1044 of file p_weapon.c.

1045 {
1046  static int pause_frames[] = {38, 43, 51, 61, 0};
1047  static int fire_frames[] = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0};
1048 
1049  Weapon_Generic(ent, 4, 31, 61, 64, pause_frames, fire_frames, Chaingun_Fire);
1050 }

◆ Weapon_FlareGun()

void Weapon_FlareGun ( edict_t *  ent)

Definition at line 1364 of file p_weapon.c.

1365 {
1366  static int pause_frames[] = { 39, 45, 50, 53, 0 };
1367  static int fire_frames[] = { 9, 17, 0 };
1368  // Check the top of p_weapon.c for definition of Weapon_Generic
1369  //
1370  Weapon_Generic(ent, 8, 13, 49, 53,
1371  pause_frames,
1372  fire_frames,
1374 }

◆ Weapon_Grenade()

void Weapon_Grenade ( edict_t *  ent)

Definition at line 530 of file p_weapon.c.

531 {
532  if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY)) {
533  ChangeWeapon(ent);
534  return;
535  }
536 
537  if (ent->client->weaponstate == WEAPON_ACTIVATING) {
538  ent->client->weaponstate = WEAPON_READY;
539  ent->client->ps.gunframe = 16;
540  return;
541  }
542 
543  if (ent->client->weaponstate == WEAPON_READY) {
544  if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK)) {
545  ent->client->latched_buttons &= ~BUTTON_ATTACK;
546  if (ent->client->pers.inventory[ent->client->ammo_index]) {
547  ent->client->ps.gunframe = 1;
548  ent->client->weaponstate = WEAPON_FIRING;
549  ent->client->grenade_time = 0;
550  } else {
551  if (level.time >= ent->pain_debounce_time) {
552  gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0);
553  ent->pain_debounce_time = level.time + 1;
554  }
555  NoAmmoWeaponChange(ent);
556  }
557  return;
558  }
559 
560  if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48)) {
561  if (rand() & 15)
562  return;
563  }
564 
565  if (++ent->client->ps.gunframe > 48)
566  ent->client->ps.gunframe = 16;
567  return;
568  }
569 
570  if (ent->client->weaponstate == WEAPON_FIRING) {
571  if (ent->client->ps.gunframe == 5)
572  gi.sound(ent, CHAN_WEAPON, gi.soundindex("weapons/hgrena1b.wav"), 1, ATTN_NORM, 0);
573 
574  if (ent->client->ps.gunframe == 11) {
575  if (!ent->client->grenade_time) {
576  ent->client->grenade_time = level.time + GRENADE_TIMER + 0.2;
577  ent->client->weapon_sound = gi.soundindex("weapons/hgrenc1b.wav");
578  }
579 
580  // they waited too long, detonate it in their hand
581  if (!ent->client->grenade_blew_up && level.time >= ent->client->grenade_time) {
582  ent->client->weapon_sound = 0;
583  weapon_grenade_fire(ent, qtrue);
584  ent->client->grenade_blew_up = qtrue;
585  }
586 
587  if (ent->client->buttons & BUTTON_ATTACK)
588  return;
589 
590  if (ent->client->grenade_blew_up) {
591  if (level.time >= ent->client->grenade_time) {
592  ent->client->ps.gunframe = 15;
593  ent->client->grenade_blew_up = qfalse;
594  } else {
595  return;
596  }
597  }
598  }
599 
600  if (ent->client->ps.gunframe == 12) {
601  ent->client->weapon_sound = 0;
602  weapon_grenade_fire(ent, qfalse);
603  }
604 
605  if ((ent->client->ps.gunframe == 15) && (level.time < ent->client->grenade_time))
606  return;
607 
608  ent->client->ps.gunframe++;
609 
610  if (ent->client->ps.gunframe == 16) {
611  ent->client->grenade_time = 0;
612  ent->client->weaponstate = WEAPON_READY;
613  }
614  }
615 }

◆ Weapon_GrenadeLauncher()

void Weapon_GrenadeLauncher ( edict_t *  ent)

Definition at line 659 of file p_weapon.c.

660 {
661  static int pause_frames[] = {34, 51, 59, 0};
662  static int fire_frames[] = {6, 0};
663 
664  Weapon_Generic(ent, 5, 16, 59, 64, pause_frames, fire_frames, weapon_grenadelauncher_fire);
665 }

◆ Weapon_HyperBlaster()

void Weapon_HyperBlaster ( edict_t *  ent)

Definition at line 841 of file p_weapon.c.

842 {
843  static int pause_frames[] = {0};
844  static int fire_frames[] = {6, 7, 8, 9, 10, 11, 0};
845 
846  Weapon_Generic(ent, 5, 20, 49, 53, pause_frames, fire_frames, Weapon_HyperBlaster_Fire);
847 }

◆ Weapon_Machinegun()

void Weapon_Machinegun ( edict_t *  ent)

Definition at line 934 of file p_weapon.c.

935 {
936  static int pause_frames[] = {23, 45, 0};
937  static int fire_frames[] = {4, 5, 0};
938 
939  Weapon_Generic(ent, 3, 5, 45, 49, pause_frames, fire_frames, Machinegun_Fire);
940 }

◆ Weapon_Railgun()

void Weapon_Railgun ( edict_t *  ent)

Definition at line 1221 of file p_weapon.c.

1222 {
1223  static int pause_frames[] = {56, 0};
1224  static int fire_frames[] = {4, 0};
1225 
1226  Weapon_Generic(ent, 3, 18, 56, 61, pause_frames, fire_frames, weapon_railgun_fire);
1227 }

◆ Weapon_RocketLauncher()

void Weapon_RocketLauncher ( edict_t *  ent)

Definition at line 714 of file p_weapon.c.

715 {
716  static int pause_frames[] = {25, 33, 42, 50, 0};
717  static int fire_frames[] = {5, 0};
718 
719  Weapon_Generic(ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_RocketLauncher_Fire);
720 }

◆ Weapon_Shotgun()

void Weapon_Shotgun ( edict_t *  ent)

Definition at line 1105 of file p_weapon.c.

1106 {
1107  static int pause_frames[] = {22, 28, 34, 0};
1108  static int fire_frames[] = {8, 9, 0};
1109 
1110  Weapon_Generic(ent, 7, 18, 36, 39, pause_frames, fire_frames, weapon_shotgun_fire);
1111 }

◆ Weapon_SuperShotgun()

void Weapon_SuperShotgun ( edict_t *  ent)

Definition at line 1158 of file p_weapon.c.

1159 {
1160  static int pause_frames[] = {29, 42, 57, 0};
1161  static int fire_frames[] = {7, 0};
1162 
1163  Weapon_Generic(ent, 6, 17, 57, 61, pause_frames, fire_frames, weapon_supershotgun_fire);
1164 }

Variable Documentation

◆ body_armor_index

int body_armor_index
static

Definition at line 44 of file g_items.c.

Referenced by ArmorIndex(), and SetItemNames().

◆ bodyarmor_info

gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY}

Definition at line 40 of file g_items.c.

Referenced by Pickup_Armor().

◆ combat_armor_index

int combat_armor_index
static

Definition at line 43 of file g_items.c.

Referenced by ArmorIndex(), Pickup_Armor(), and SetItemNames().

◆ combatarmor_info

gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT}

Definition at line 39 of file g_items.c.

Referenced by Pickup_Armor().

◆ itemlist

◆ jacket_armor_index

int jacket_armor_index
static

Definition at line 42 of file g_items.c.

Referenced by ArmorIndex(), Pickup_Armor(), and SetItemNames().

◆ jacketarmor_info

gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET}

Definition at line 38 of file g_items.c.

Referenced by Pickup_Armor().

◆ power_screen_index

int power_screen_index
static

Definition at line 45 of file g_items.c.

Referenced by PowerArmorType(), and SetItemNames().

◆ power_shield_index

int power_shield_index
static

Definition at line 46 of file g_items.c.

Referenced by PowerArmorType(), and SetItemNames().

◆ quad_drop_timeout_hack

int quad_drop_timeout_hack
static

Definition at line 52 of file g_items.c.

Referenced by Pickup_Powerup(), and Use_Quad().

FindItem
gitem_t * FindItem(char *pickup_name)
Definition: g_items.c:98
gi
game_import_t gi
Definition: g_main.c:23
IT_AMMO
#define IT_AMMO
Definition: g_local.h:212
gitem_armor_t::max_count
int max_count
Definition: g_local.h:203
deathmatch
cvar_t * deathmatch
Definition: g_main.c:33
G_ProjectSource
void G_ProjectSource(const vec3_t point, const vec3_t distance, const vec3_t forward, const vec3_t right, vec3_t result)
Definition: g_utils.c:23
Pickup_Armor
qboolean Pickup_Armor(edict_t *ent, edict_t *other)
Definition: g_items.c:580
AMMO_ROCKETS
@ AMMO_ROCKETS
Definition: g_local.h:102
G_Spawn
edict_t * G_Spawn(void)
Definition: g_utils.c:391
gitem_armor_t::normal_protection
float normal_protection
Definition: g_local.h:204
AMMO_BULLETS
@ AMMO_BULLETS
Definition: g_local.h:100
gitem_s::precaches
char * precaches
Definition: g_local.h:257
weapon_supershotgun_fire
void weapon_supershotgun_fire(edict_t *ent)
Definition: p_weapon.c:1114
FRAMETIME
#define FRAMETIME
Definition: g_local.h:75
combatarmor_info
gitem_armor_t combatarmor_info
Definition: g_items.c:39
WEAPON_READY
@ WEAPON_READY
Definition: g_local.h:93
ITEM_TARGETS_USED
#define ITEM_TARGETS_USED
Definition: g_local.h:559
Add_Ammo
qboolean Add_Ammo(edict_t *ent, gitem_t *item, int count)
Definition: g_items.c:426
weapon_flaregun_fire
void weapon_flaregun_fire(edict_t *ent)
Definition: p_weapon.c:1319
AMMO_SHELLS
@ AMMO_SHELLS
Definition: g_local.h:101
Use_PowerArmor
void Use_PowerArmor(edict_t *ent, gitem_t *item)
Definition: g_items.c:672
combat_armor_index
static int combat_armor_index
Definition: g_items.c:43
gitem_s::pickup
qboolean(* pickup)(struct edict_s *ent, struct edict_s *other)
Definition: g_local.h:234
bodyarmor_info
gitem_armor_t bodyarmor_info
Definition: g_items.c:40
ITEM_INDEX
#define ITEM_INDEX(x)
Definition: g_local.h:600
FL_POWER_ARMOR
#define FL_POWER_ARMOR
Definition: g_local.h:71
weapon_grenade_fire
void weapon_grenade_fire(edict_t *ent, qboolean held)
Definition: p_weapon.c:485
gitem_s::world_model_flags
int world_model_flags
Definition: g_local.h:240
NoAmmoWeaponChange
void NoAmmoWeaponChange(edict_t *ent)
Definition: p_weapon.c:218
SpawnItem
void SpawnItem(edict_t *ent, gitem_t *item)
Definition: g_items.c:1003
Pickup_Health
qboolean Pickup_Health(edict_t *ent, edict_t *other)
Definition: g_items.c:533
DoRespawn
void DoRespawn(edict_t *ent)
Definition: g_items.c:116
level_locals_t::power_cubes
int power_cubes
Definition: g_local.h:335
Pickup_PowerArmor
qboolean Pickup_PowerArmor(edict_t *ent, edict_t *other)
Definition: g_items.c:690
GRENADE_TIMER
#define GRENADE_TIMER
Definition: p_weapon.c:481
WEAPON_ACTIVATING
@ WEAPON_ACTIVATING
Definition: g_local.h:94
Weapon_HyperBlaster_Fire
void Weapon_HyperBlaster_Fire(edict_t *ent)
Definition: p_weapon.c:783
tv
float * tv(float x, float y, float z)
Definition: g_utils.c:248
body_armor_index
static int body_armor_index
Definition: g_items.c:44
ArmorIndex
int ArmorIndex(edict_t *ent)
Definition: g_items.c:563
other
@ other
Definition: ogg.c:63
IT_WEAPON
#define IT_WEAPON
Definition: g_local.h:211
itemlist
gitem_t itemlist[]
Definition: g_items.c:1063
PrecacheItem
void PrecacheItem(gitem_t *it)
Definition: g_items.c:937
weapon_railgun_fire
void weapon_railgun_fire(edict_t *ent)
Definition: p_weapon.c:1176
MegaHealth_think
void MegaHealth_think(edict_t *self)
Definition: g_items.c:519
gitem_s::icon
char * icon
Definition: g_local.h:244
drop_make_touchable
void drop_make_touchable(edict_t *ent)
Definition: g_items.c:789
jacket_armor_index
static int jacket_armor_index
Definition: g_items.c:42
POWER_ARMOR_SHIELD
#define POWER_ARMOR_SHIELD
Definition: g_local.h:158
POWER_ARMOR_SCREEN
#define POWER_ARMOR_SCREEN
Definition: g_local.h:157
Pickup_Adrenaline
qboolean Pickup_Adrenaline(edict_t *ent, edict_t *other)
Definition: g_items.c:191
gitem_s::world_model
char * world_model
Definition: g_local.h:239
Chaingun_Fire
void Chaingun_Fire(edict_t *ent)
Definition: p_weapon.c:942
FL_RESPAWN
#define FL_RESPAWN
Definition: g_local.h:72
G_FreeEdict
void G_FreeEdict(edict_t *e)
Definition: g_utils.c:421
ITEM_TRIGGER_SPAWN
#define ITEM_TRIGGER_SPAWN
Definition: g_local.h:553
gitem_s::ammo
char * ammo
Definition: g_local.h:249
droptofloor
void droptofloor(edict_t *ent)
Definition: g_items.c:867
DROPPED_PLAYER_ITEM
#define DROPPED_PLAYER_ITEM
Definition: g_local.h:558
game_locals_t::num_items
int num_items
Definition: g_local.h:287
HEALTH_TIMED
#define HEALTH_TIMED
Definition: g_items.c:49
forward
static vec3_t forward
Definition: p_view.c:27
gitem_armor_t
Definition: g_local.h:201
vtos
char * vtos(vec3_t v)
Definition: g_utils.c:275
Touch_Item
void Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
Definition: g_items.c:723
game
game_locals_t game
Definition: g_main.c:21
WEAPON_FIRING
@ WEAPON_FIRING
Definition: g_local.h:96
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: shared.c:23
gitem_s::pickup_name
char * pickup_name
Definition: g_local.h:245
Use_Quad
void Use_Quad(edict_t *ent, gitem_t *item)
Definition: g_items.c:325
weapon_shotgun_fire
void weapon_shotgun_fire(edict_t *ent)
Definition: p_weapon.c:1061
AMMO_GRENADES
@ AMMO_GRENADES
Definition: g_local.h:103
SetRespawn
void SetRespawn(edict_t *ent, float delay)
Definition: g_items.c:142
Use_Item
void Use_Item(edict_t *ent, edict_t *other, edict_t *activator)
Definition: g_items.c:844
skill
cvar_t * skill
Definition: g_main.c:36
gitem_s::quantity
int quantity
Definition: g_local.h:248
level_locals_t::framenum
int framenum
Definition: g_local.h:298
Drop_General
void Drop_General(edict_t *ent, gitem_t *item)
Definition: g_items.c:181
Weapon_RocketLauncher_Fire
void Weapon_RocketLauncher_Fire(edict_t *ent)
Definition: p_weapon.c:675
level_locals_t::time
float time
Definition: g_local.h:299
DROPPED_ITEM
#define DROPPED_ITEM
Definition: g_local.h:557
gitem_s::pickup_sound
char * pickup_sound
Definition: g_local.h:238
ValidateSelectedItem
void ValidateSelectedItem(edict_t *ent)
Definition: g_cmds.c:125
coop
cvar_t * coop
Definition: g_main.c:34
g_select_empty
cvar_t * g_select_empty
Definition: g_main.c:45
drop_temp_touch
void drop_temp_touch(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
Definition: g_items.c:781
ARMOR_SHARD
#define ARMOR_SHARD
Definition: g_local.h:153
HEALTH_IGNORE_MAX
#define HEALTH_IGNORE_MAX
Definition: g_items.c:48
power_screen_index
static int power_screen_index
Definition: g_items.c:45
right
static vec3_t right
Definition: p_view.c:27
ChangeWeapon
void ChangeWeapon(edict_t *ent)
Definition: p_weapon.c:162
G_UseTargets
void G_UseTargets(edict_t *ent, edict_t *activator)
Definition: g_utils.c:166
IT_STAY_COOP
#define IT_STAY_COOP
Definition: g_local.h:214
Drop_Item
edict_t * Drop_Item(edict_t *ent, gitem_t *item)
Definition: g_items.c:798
weapon_grenadelauncher_fire
void weapon_grenadelauncher_fire(edict_t *ent)
Definition: p_weapon.c:625
FL_TEAMSLAVE
#define FL_TEAMSLAVE
Definition: g_local.h:69
gitem_s::drop
void(* drop)(struct edict_s *ent, struct gitem_s *item)
Definition: g_local.h:236
Weapon_Blaster_Fire
void Weapon_Blaster_Fire(edict_t *ent)
Definition: p_weapon.c:762
level
level_locals_t level
Definition: g_main.c:22
quad_drop_timeout_hack
static int quad_drop_timeout_hack
Definition: g_items.c:52
MOVETYPE_TOSS
@ MOVETYPE_TOSS
Definition: g_local.h:194
Weapon_Generic
void Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, int *fire_frames, void(*fire)(edict_t *ent))
Definition: p_weapon.c:352
ITEM_NO_TOUCH
#define ITEM_NO_TOUCH
Definition: g_local.h:554
dmflags
cvar_t * dmflags
Definition: g_main.c:35
power_shield_index
static int power_shield_index
Definition: g_items.c:46
int
CONST PIXELFORMATDESCRIPTOR int
Definition: wgl.c:26
weapon_bfg_fire
void weapon_bfg_fire(edict_t *ent)
Definition: p_weapon.c:1238
gitem_s::view_model
char * view_model
Definition: g_local.h:241
gitem_armor_t::base_count
int base_count
Definition: g_local.h:202
Pickup_AncientHead
qboolean Pickup_AncientHead(edict_t *ent, edict_t *other)
Definition: g_items.c:205
gitem_s::flags
int flags
Definition: g_local.h:250
Machinegun_Fire
void Machinegun_Fire(edict_t *ent)
Definition: p_weapon.c:857
POWER_ARMOR_NONE
#define POWER_ARMOR_NONE
Definition: g_local.h:156
gitem_s::tag
int tag
Definition: g_local.h:255
Pickup_Powerup
qboolean Pickup_Powerup(edict_t *ent, edict_t *other)
Definition: g_items.c:155
AMMO_CELLS
@ AMMO_CELLS
Definition: g_local.h:104
gitem_s::classname
char * classname
Definition: g_local.h:233
jacketarmor_info
gitem_armor_t jacketarmor_info
Definition: g_items.c:38
gitem_s
Definition: g_local.h:232
AMMO_SLUGS
@ AMMO_SLUGS
Definition: g_local.h:105