‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_utility.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\util_shared;
4 
5 #insert scripts\shared\shared.gsh;
6 
7 #using scripts\zm\_zm_powerups;
8 #using scripts\zm\_zm_weapons;
9 
10 #namespace zm_utility;
11 
22 {
23  // ignore triggers for awhile so others can trigger the trigger we're in.
24  self endon( "death" );
25  self.ignoreTriggers = true;
26  if( IsDefined( ‪timer ) )
27  {
28  wait( ‪timer );
29  }
30  else
31  {
32  wait( 0.5 );
33  }
34  self.ignoreTriggers = false;
35 }
36 
38 
39 function ‪is_encounter()
40 {
41  return false;
42 }
43 
45 // MATH
47 
48 function ‪round_up_to_ten( score )
49 {
50  new_score = score - score % 10;
51  if( new_score < score )
52  {
53  new_score += 10;
54  }
55  return new_score;
56 }
57 
58 function ‪round_up_score( score, value )
59 {
60  score = int(score); // Make sure it's an int or modulus will die
61 
62  new_score = score - score % value;
63  if( new_score < score )
64  {
65  new_score += value;
66  }
67  return new_score;
68 }
69 
70 function ‪halve_score( n_score )
71 {
72  n_score = n_score / 2;
73  n_score = ‪zm_utility::round_up_score( n_score, 10 );
74 
75  return n_score;
76 }
77 
79 // WEAPONS
81 
82 function ‪spawn_weapon_model( localClientNum, weapon, model, origin, angles, options )
83 {
84  if ( !isdefined( model ) )
85  {
86  model = weapon.worldModel;
87  }
88 
89  weapon_model = ‪spawn( localClientNum, origin, "script_model" );
90  if ( isdefined( angles ) )
91  {
92  weapon_model.angles = angles;
93  }
94 
95  if (isdefined(options))
96  {
97  weapon_model useweaponmodel( weapon, model, options );
98  }
99  else
100  {
101  weapon_model useweaponmodel( weapon, model );
102  }
103 
104  return weapon_model;
105 }
106 
107 function ‪spawn_buildkit_weapon_model( localClientNum, weapon, camo, origin, angles )
108 {
109  weapon_model = ‪spawn( localClientNum, origin, "script_model" );
110  if ( isdefined( angles ) )
111  {
112  weapon_model.angles = angles;
113  }
114 
115  weapon_model UseBuildKitWeaponModel( localClientNum, weapon, camo, ‪zm_weapons::is_weapon_upgraded( weapon ) );
116 
117  return weapon_model;
118 }
119 
120 function ‪is_classic()
121 {
122  return true;
123 }
124 
125 function ‪is_gametype_active( a_gametypes )
126 {
127  b_is_gametype_active = false;
128 
129  if ( !IsArray( a_gametypes ) )
130  {
131  a_gametypes = Array( a_gametypes );
132  }
133 
134  for ( i = 0; i < a_gametypes.size; i++ )
135  {
136  if ( GetDvarString( "g_gametype" ) == a_gametypes[ i ] )
137  {
138  b_is_gametype_active = true;
139  }
140  }
141 
142  return b_is_gametype_active;
143 }
144 
146 // UI
148 
149 
150 function ‪setInventoryUIModels( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
151 {
152  if ( IsSpectating( localClientNum ) )
153  {
154  return;
155  }
156  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "zmInventory." + fieldName ), newVal );
157 }
158 
159 function ‪setSharedInventoryUIModels( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
160 {
161  // shared inventory models should show up even if you're spectating, so that they're there when you respawn.
162  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "zmInventory." + fieldName ), newVal );
163 }
164 
165 function ‪zm_ui_infotext( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
166 {
167  if ( newVal )
168  {
169  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "zmInventory.infoText" ), fieldName );
170  }
171  else
172  {
173  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "zmInventory.infoText" ), "" );
174  }
175 }
176 
177 function ‪umbra_fix_logic( localClientNum )
178 {
179  self endon( "disconnect" );
180  self endon( "entityshutdown" );
181 
182  umbra_settometrigger( localClientNum, "" ); //reset script umbra override
183  while( 1 )
184  {
185  in_fix_area = 0;
186 
187  if( isdefined( level.custom_umbra_hotfix ) )
188  {
189  in_fix_area = self thread [[level.custom_umbra_hotfix]]( localClientNum );
190  }
191 
192  //If not in any override volumns then set the script umbra override to empty (default behavour)
193  if( in_fix_area == 0 )
194  {
195  umbra_settometrigger( localClientNum, "" );
196  }
198  }
199 }
200 
201 function ‪umbra_fix_trigger( localClientNum, pos, height, radius, umbra_name )
202 {
203  bottomY = pos[2];
204  topY = pos[2] + height;
205 
206  if( (self.origin[2] > bottomY) && (self.origin[2] < topY) )
207  {
208  if( Distance2dSquared(self.origin, pos) < radius*radius )
209  {
210  //force draw umbra tome
211  umbra_settometrigger( localClientNum, umbra_name );
212  return true;
213  }
214  }
215  return false;
216 }
217 
218 
219 
‪spawn_weapon_model
‪function spawn_weapon_model(localClientNum, weapon, model, origin, angles, options)
Definition: _zm_utility.csc:82
‪round_up_to_ten
‪function round_up_to_ten(score)
Definition: _zm_utility.csc:48
‪timer
‪function timer(n_time, str_endon, x, y, height)
Definition: lui_shared.gsc:163
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪is_weapon_upgraded
‪function is_weapon_upgraded(weapon)
Definition: _zm_weapons.csc:155
‪is_encounter
‪function is_encounter()
Definition: _zm_utility.csc:39
‪is_gametype_active
‪function is_gametype_active(a_gametypes)
Definition: _zm_utility.csc:125
‪zm_ui_infotext
‪function zm_ui_infotext(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_utility.csc:165
‪round_up_score
‪function round_up_score(score, value)
Definition: _zm_utility.csc:58
‪umbra_fix_logic
‪function umbra_fix_logic(localClientNum)
Definition: _zm_utility.csc:177
‪umbra_fix_trigger
‪function umbra_fix_trigger(localClientNum, pos, height, radius, umbra_name)
Definition: _zm_utility.csc:201
‪halve_score
‪function halve_score(n_score)
Definition: _zm_utility.csc:70
‪setInventoryUIModels
‪function setInventoryUIModels(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_utility.csc:150
‪ignore_triggers
‪function ignore_triggers(timer)
Definition: _zm_utility.csc:21
‪spawn_buildkit_weapon_model
‪function spawn_buildkit_weapon_model(localClientNum, weapon, camo, origin, angles)
Definition: _zm_utility.csc:107
‪is_classic
‪function is_classic()
Definition: _zm_utility.csc:120
‪setSharedInventoryUIModels
‪function setSharedInventoryUIModels(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_utility.csc:159
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265