‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_weapons.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\gameobjects_shared;
6 #using scripts\shared\killstreaks_shared;
7 #using scripts\shared\system_shared;
8 #using scripts\shared\util_shared;
9 #using scripts\shared\weapons_shared;
10 #using scripts\shared\weapons\_weapons;
11 
12 #insert scripts\shared\shared.gsh;
13 
14 #using scripts\mp\gametypes\_globallogic_utils;
15 #using scripts\mp\gametypes\_loadout;
16 #using scripts\mp\gametypes\_shellshock;
17 #using scripts\mp\gametypes\_weapon_utils;
18 #using scripts\mp\gametypes\_weaponobjects;
19 
20 #using scripts\mp\_challenges;
21 #using scripts\mp\_scoreevents;
22 #using scripts\mp\_util;
23 #using scripts\mp\killstreaks\_dogs;
24 #using scripts\mp\killstreaks\_killstreaks;
25 #using scripts\mp\killstreaks\_killstreak_weapons;
26 #using scripts\mp\killstreaks\_supplydrop;
27 
28 #namespace weapons;
29 
30 ‪REGISTER_SYSTEM( "weapons", &‪__init__, undefined )
31 
32 function ‪__init__()
33 {
35 }
36 
37 
38 function ‪bestweapon_kill( weapon )
39 {
40 
41 }
42 
43 function ‪bestweapon_spawn( weapon, options, acvi )
44 {
45 }
46 
47 
48 function ‪bestweapon_init( weapon, options, acvi )
49 {
50  weapon_data = [];
51  weapon_data["weapon"] = weapon;
52  weapon_data["options"] = options;
53  weapon_data["acvi"] = acvi;
54  weapon_data["kill_count"] = 0;
55  weapon_data["spawned_with"] = 0;
56  key = self.pers["bestWeapon"][weapon.name].size;
57  self.pers["bestWeapon"][weapon.name][key] = weapon_data;
58 
59  return key;
60 }
61 
62 function ‪bestweapon_find( weapon, options, acvi )
63 {
64  if ( !isDefined( self.pers["bestWeapon"] ) )
65  {
66  self.pers["bestWeapon"] = [];
67  }
68  if ( !IsDefined( self.pers["bestWeapon"][weapon.name] ) )
69  {
70  self.pers["bestWeapon"][weapon.name] = [];
71  }
72 
73  ‪name = weapon.name;
74  size = self.pers["bestWeapon"][‪name].size;
75  for( index = 0; index < size; index++ )
76  {
77  if ( self.pers["bestWeapon"][‪name][index]["weapon"] == weapon
78  && self.pers["bestWeapon"][‪name][index]["options"] == options &&
79  self.pers["bestWeapon"][‪name][index]["acvi"] == acvi )
80  {
81  return index;
82  }
83  }
84 
85  return undefined;
86 }
87 
88 
90 {
91  most_kills = 0;
92  most_spawns = 0;
93 
94  if ( !IsDefined( self.pers["bestWeapon"] ) )
95  {
96  return;
97  }
98 
99  best_key = 0;
100  best_index = 0;
101  weapon_keys = GetArrayKeys( self.pers["bestWeapon"] );
102  for( key_index = 0; key_index < weapon_keys.size; key_index++ )
103  {
104  key = weapon_keys[key_index];
105  size = self.pers["bestWeapon"][key].size;
106  for( index = 0; index < size; index++ )
107  {
108  kill_count = self.pers["bestWeapon"][key][index]["kill_count"];
109  spawned_with = self.pers["bestWeapon"][key][index]["spawned_with"];
110 
111  if ( kill_count > most_kills )
112  {
113  best_index = index;
114  best_key = key;
115  most_kills = kill_count;
116  most_spawns = spawned_with;
117  }
118  else if ( kill_count == most_kills && spawned_with > most_spawns )
119  {
120  best_index = index;
121  best_key = key;
122  most_kills = kill_count;
123  most_spawns = spawned_with;
124  }
125  }
126  }
127 
128  return self.pers["bestWeapon"][best_key][best_index];
129 }
130 
132 {
133  showcaseWeaponData = self GetPlayerShowcaseWeapon();
134 
135  if ( !isdefined( showcaseWeaponData ) )
136  {
137  return undefined;
138  }
139 
140  showcase_weapon = [];
141 
142  showcase_weapon["weapon"] = showcaseWeaponData.weapon;
143 
144  attachmentNames = [];
145  attachmentIndices = [];
146  tokenizedAttachmentInfo = strtok( showcaseWeaponData.attachmentInfo, "," );
147  for ( index = 0; index + 1 < tokenizedAttachmentInfo.size; index += 2 )
148  {
149  attachmentNames[ attachmentNames.size ] = tokenizedAttachmentInfo[ index ];
150  attachmentIndices[ attachmentIndices.size ] = int( tokenizedAttachmentInfo[ index + 1 ] );
151  }
152  for ( index = tokenizedAttachmentInfo.size; index + 1 < 16; index += 2 )
153  {
154  attachmentNames[ attachmentNames.size ] = "none";
155  attachmentIndices[ attachmentIndices.size ] = 0;
156  }
157  showcase_weapon["acvi"] = GetAttachmentCosmeticVariantIndexes( showcaseWeaponData.weapon,
158  attachmentNames[ 0 ], attachmentIndices[ 0 ],
159  attachmentNames[ 1 ], attachmentIndices[ 1 ],
160  attachmentNames[ 2 ], attachmentIndices[ 2 ],
161  attachmentNames[ 3 ], attachmentIndices[ 3 ],
162  attachmentNames[ 4 ], attachmentIndices[ 4 ],
163  attachmentNames[ 5 ], attachmentIndices[ 5 ],
164  attachmentNames[ 6 ], attachmentIndices[ 6 ],
165  attachmentNames[ 7 ], attachmentIndices[ 7 ] );
166 
167  camoIndex = 0;
170  showPaintshop = false;
171  tokenizedWeaponRenderOptions = strtok( showcaseWeaponData.weaponRenderOptions, "," );
172  if ( tokenizedWeaponRenderOptions.size > 2 )
173  {
174  camoIndex = int( tokenizedWeaponRenderOptions[ 0 ] );
175  paintjobSlot = int( tokenizedWeaponRenderOptions[ 1 ] );
176  paintjobIndex = int( tokenizedWeaponRenderOptions[ 2 ] );
177  showPaintshop = paintjobSlot != ‪CUSTOMIZATION_INVALID_PAINTJOB_SLOT && paintjobIndex != ‪CUSTOMIZATION_INVALID_PAINTJOB_INDEX;
178  }
179 
180  showcase_weapon["options"] = self CalcWeaponOptions( camoIndex, 0, 0, false, false, showPaintshop, true );
181 
182  return showcase_weapon;
183 }
‪bestweapon_get
‪function bestweapon_get()
Definition: _weapons.gsc:89
‪bestweapon_find
‪function bestweapon_find(weapon, options, acvi)
Definition: _weapons.gsc:62
‪CUSTOMIZATION_INVALID_PAINTJOB_INDEX
‪#define CUSTOMIZATION_INVALID_PAINTJOB_INDEX
Definition: shared.gsh:896
‪showcaseweapon_get
‪function showcaseweapon_get()
Definition: _weapons.gsc:131
‪bestweapon_init
‪function bestweapon_init(weapon, options, acvi)
Definition: _weapons.gsc:48
‪CUSTOMIZATION_INVALID_PAINTJOB_SLOT
‪#define CUSTOMIZATION_INVALID_PAINTJOB_SLOT
Definition: shared.gsh:897
‪init_shared
‪function init_shared()
Definition: _weapons.gsc:34
‪bestweapon_spawn
‪function bestweapon_spawn(weapon, options, acvi)
Definition: _weapons.gsc:43
‪__init__
‪function __init__()
Definition: _weapons.gsc:32
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪bestweapon_kill
‪function bestweapon_kill(weapon)
Definition: _weapons.gsc:38
‪name
‪class GroundFx name