‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
ammo_shared.gsc
Go to the documentation of this file.
1 #using scripts\shared\array_shared;
2 #using scripts\shared\throttle_shared;
3 #using scripts\shared\ai\systems\shared;
4 #using scripts\shared\weapons\_weaponobjects;
5 #using scripts\shared\weapons\_weapons;
6 
7 #insert scripts\shared\shared.gsh;
8 #insert scripts\shared\archetype_shared\archetype_shared.gsh;
9 
10 #namespace ammo;
11 
12 #define NUM_CLIPS_SCAVENGED 3 //How many clips of ammo the player gets for their primaries for each scavenge
13 
14 function autoexec ‪main()
15 {
16  level.ai_ammo_throttle = new ‪Throttle();
17  [[ level.ai_ammo_throttle ]]->Initialize( 1, 0.1 );
18 }
19 
20 function ‪DropAIAmmo()
21 {
22  self endon("death");
23 
24  if ( !IsDefined( self.ammoPouch ) )
25  {
26  return;
27  }
28 
29  if ( ‪IS_TRUE( self.disableAmmoDrop ) )
30  {
31  return;
32  }
33 
34  [[ level.ai_ammo_throttle ]]->WaitInQueue( self );
35 
36  droppedWeapon = ‪shared::ThrowWeapon( self.ammoPouch, "tag_stowed_back", true );
37 
38  if ( IsDefined( droppedWeapon ) )
39  {
40  droppedWeapon thread ‪ammo::ammo_pouch_think();
41  droppedWeapon SetContents( droppedWeapon SetContents( 0 ) & ~( ‪CONTENTS_ACTOR | ‪CONTENTS_CORPSE | ‪CONTENTS_VEHICLE | ‪CONTENTS_PLAYER ) );
42  }
43 }
44 
46 {
47  self endon( "death" );
48  self waittill( "scavenger", player );
49 
50  primary_weapons = player GetWeaponsListPrimaries();
51  offhand_weapons_and_alts = array::exclude( player GetWeaponsList( true ), primary_weapons );
52 
53  ArrayRemoveValue( offhand_weapons_and_alts, level.weaponBaseMelee );
54  offhand_weapons_and_alts = ‪array::reverse( offhand_weapons_and_alts ); // Prioritize tacticals over lethals
55 
56  player playsound( "wpn_ammo_pickup" );
57  player playlocalsound( "wpn_ammo_pickup" );
58 
59  //TODO: remove this override after the demo
60 
61  if( ‪IS_TRUE( level.b_disable_scavenger_icon ) )
62  {
64  }
65 
66  for ( i = 0; i < offhand_weapons_and_alts.size; i++ )
67  {
68  weapon = offhand_weapons_and_alts[i];
69 
70  maxAmmo = 0;
71  b_is_primary_or_secondary_grenade = false;
72 
73  if ( weapon == player.grenadeTypePrimary && isdefined( player.grenadeTypePrimaryCount ) && player.grenadeTypePrimaryCount > 0 )
74  {
75  maxAmmo = player.grenadeTypePrimaryCount;
76  b_is_primary_or_secondary_grenade = true;
77  }
78  else if ( weapon == player.grenadeTypeSecondary && isdefined( player.grenadeTypeSecondaryCount ) && player.grenadeTypeSecondaryCount > 0 )
79  {
80  maxAmmo = player.grenadeTypeSecondaryCount;
81  b_is_primary_or_secondary_grenade = true;
82  }
83  else if ( weapon.inventorytype == "hero" && ‪IS_TRUE( level.overrideAmmoDropHeroWeapon ) )
84  {
85  maxAmmo = weapon.maxammo;
86  }
87 
88  if ( isdefined( level.customLoadoutScavenge ) )
89  {
90  maxAmmo = self [[level.customLoadoutScavenge]]( weapon );
91  }
92 
93  if ( maxAmmo == 0 )
94  {
95  continue;
96  }
97 
98  if ( weapon.rootWeapon == level.weaponSatchelCharge )
99  {
100  if ( player ‪weaponobjects::anyObjectsInWorld( weapon.rootWeapon ) )
101  {
102  continue;
103  }
104  }
105 
106  stock = player GetWeaponAmmoStock( weapon );
107 
108  if ( weapon.inventorytype == "hero" && ‪IS_TRUE( level.overrideAmmoDropHeroWeapon ) )
109  {
110  ammo = stock + weapon.clipsize;
111  ‪CLAMP_MAX( ammo, maxAmmo );
112  player SetWeaponAmmoStock( weapon, ammo );
113  player.scavenged = true;
114  }
115  else if ( stock < maxAmmo )
116  {
117  // just give 1 for each scavenger pick up
118  ammo = stock + 1;
119  if ( ammo > maxAmmo )
120  {
121  ammo = maxAmmo;
122  }
123  else
124  {
125  if ( weapon == player.grenadeTypePrimary )
126  {
127  player notify( "scavenged_primary_grenade" );
128  }
129  }
130 
131  player SetWeaponAmmoStock( weapon, ammo );
132  player.scavenged = true;
133 
134  }
135  }
136 
137  for ( i = 0; i < primary_weapons.size; i++ )
138  {
139  weapon = primary_weapons[i];
140 
141  stock = player GetWeaponAmmoStock( weapon );
142  start = player GetFractionStartAmmo( weapon );
143  clip = weapon.clipSize;
144  clip *= GetDvarFloat( "scavenger_clip_multiplier", 1 );
145  clip = Int( clip );
146  maxAmmo = weapon.maxAmmo;
147 
148  //give the player multiple clips when ammo is scavenged
149  if( stock < maxAmmo - (clip * ‪NUM_CLIPS_SCAVENGED) )
150  {
151  ammo = stock + (clip * ‪NUM_CLIPS_SCAVENGED);
152  player SetWeaponAmmoStock( weapon, ammo );
153  }
154  else
155  {
156  player SetWeaponAmmoStock( weapon, maxAmmo );
157  }
158  }
159 }
‪CONTENTS_ACTOR
‪#define CONTENTS_ACTOR
Definition: shared.gsh:112
‪NUM_CLIPS_SCAVENGED
‪#define NUM_CLIPS_SCAVENGED
Definition: ammo_shared.gsc:12
‪CONTENTS_VEHICLE
‪#define CONTENTS_VEHICLE
Definition: shared.gsh:119
‪Throttle
Definition: throttle_shared.gsc:15
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪reverse
‪function reverse()
Definition: traps_shared.gsc:1071
‪main
‪function autoexec main()
Definition: ammo_shared.gsc:14
‪DropAIAmmo
‪function DropAIAmmo()
Definition: ammo_shared.gsc:20
‪CONTENTS_CORPSE
‪#define CONTENTS_CORPSE
Definition: shared.gsh:122
‪ammo_pouch_think
‪function ammo_pouch_think()
Definition: ammo_shared.gsc:45
‪CONTENTS_PLAYER
‪#define CONTENTS_PLAYER
Definition: shared.gsh:121
‪CLAMP_MAX
‪#define CLAMP_MAX(__var, __max)
Definition: shared.gsh:282
‪anyObjectsInWorld
‪function anyObjectsInWorld(weapon)
Definition: _weaponobjects.gsc:1690
‪flash_scavenger_icon
‪function flash_scavenger_icon()
Definition: _weapons.gsc:1464
‪ThrowWeapon
‪function ThrowWeapon(weapon, positionTag, scavenger)
Definition: shared.gsc:196