‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_hacker_tool.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\duplicaterender_mgr;
6 #using scripts\shared\math_shared;
7 #using scripts\shared\system_shared;
8 #using scripts\shared\util_shared;
9 #using scripts\shared\visionset_mgr_shared;
10 #using scripts\shared\weapons\_flashgrenades;
11 
12 #insert scripts\shared\duplicaterender.gsh;
13 #insert scripts\shared\shared.gsh;
14 #insert scripts\shared\version.gsh;
15 
16 #define HACKING_PLAYER_WEAPON "pda_hack"
17 #define HACKER_MAX_RANGE 40
18 #define HACKER_SWEET_SPOT_RATIO 0.8
19 
20 #namespace hacker_tool;
21 
22 function ‪init_shared()
23 {
25  level.hackingSoundId = [];
26  level.hackingSweetSpotId = [];
27  level.friendlyHackingSoundId = [];
29 }
30 
31 function ‪on_localplayer_spawned( localClientNum )
32 {
33  if( self != GetLocalPlayer( localClientNum ) )
34  return;
35 
36  player = self;
37 
38  if ( isdefined( level.hackingSoundId[localclientnum] ) )
39  {
40  player stopLoopSound( level.hackingSoundId[localclientnum] );
41  level.hackingSoundId[localclientnum] = undefined;
42  }
43  if ( isdefined( level.hackingSweetSpotId[localclientnum] ) )
44  {
45  player stopLoopSound(level.hackingSweetSpotId[localclientnum] );
46  level.hackingSweetSpotId[localclientnum] = undefined;
47  }
48  if ( isdefined( level.friendlyHackingSoundId[localclientnum] ) )
49  {
50  player stopLoopSound( level.friendlyHackingSoundId[localclientnum] );
51  level.friendlyHackingSoundId[localclientnum] = undefined;
52  }
53 }
54 
55 
56 function ‪player_hacking( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
57 {
58  self notify( "player_hacking_callback" );
59  player = self;
60  if ( isdefined( level.hackingSoundId[localclientnum] ) )
61  {
62  player stopLoopSound( level.hackingSoundId[localclientnum] );
63  level.hackingSoundId[localclientnum] = undefined;
64  }
65  if ( isdefined( level.hackingSweetSpotId[localclientnum] ) )
66  {
67  player stopLoopSound(level.hackingSweetSpotId[localclientnum] );
68  level.hackingSweetSpotId[localclientnum] = undefined;
69  }
70  if ( isdefined( level.friendlyHackingSoundId[localclientnum] ) )
71  {
72  player stopLoopSound( level.friendlyHackingSoundId[localclientnum] );
73  level.friendlyHackingSoundId[localclientnum] = undefined;
74  }
75  if ( isdefined( player.targetEnt ) )
76  {
77  player.targetEnt ‪duplicate_render::set_hacker_tool_hacking( localClientNum, false );
78  player.targetEnt ‪duplicate_render::set_hacker_tool_breaching( localClientNum,false );
79  player.targetEnt.isbreachingfirewall = false;
80  player.targetEnt = undefined;
81  }
82 
83  if ( newVal == ‪HACKER_TOOL_HACKING )
84  {
85  player thread ‪watchHackSpeed( localClientNum, false );
86  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_HACKING );
87  }
88  else if ( newVal == ‪HACKER_TOOL_FIREWALL )
89  {
90  player thread ‪watchHackSpeed( localClientNum, true );
91  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_BREACHING );
92  }
93  else if ( newVal == ‪HACKER_TOOL_ACTIVE )
94  {
95  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_SCANNING );
96  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.perc" ), 0 );
97  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.offsetShaderValue" ), 0 + " " + 0 + " 0 0" );
98  self thread ‪watchForEMP( localClientNum );
99  }
100  else
101  {
102  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_SCANNING );
103  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.perc" ), 0 );
104  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.offsetShaderValue" ), 0 + " " + 0 + " 0 0" );
105  }
106 }
107 
108 
109 function ‪watchHackSpeed( localClientNum, isBreachingFirewall )
110 {
111  self endon( "entityshutdown" );
112  self endon( "player_hacking_callback" );
113  player = self;
114 
115  for ( ;; )
116  {
117  targetEntArray = self GetTargetLockEntityArray();
118  if ( targetEntArray.size > 0 )
119  {
120  targetEnt = targetEntArray[0];
121  break;
122  }
123  wait ( 0.02 );
124  }
125  targetEnt ‪watchTargetHack( localclientNum, player, isBreachingFirewall );
126 }
127 
128 function ‪watchTargetHack( localclientnum, player, isBreachingFirewall )
129 {
130  self endon( "entityshutdown" );
131  player endon( "entityshutdown" );
132  self endon( "player_hacking_callback" );
133 
134  targetEnt = self;
135  player.targetEnt = targetEnt;
136  if ( isBreachingFirewall )
137  {
138  targetEnt.isbreachingfirewall = true;
139  targetEnt ‪duplicate_render::set_hacker_tool_breaching( localclientnum, true );
140  }
141 
142  targetEnt thread ‪watchHackerPlayerShutdown( localclientnum, player, targetEnt );
143 
144  for( ;; )
145  {
146  distanceFromCenter = targetent getDistanceFromScreenCenter( localClientNum );
147  inverse = ‪HACKER_MAX_RANGE - distancefromcenter;
148  ratio = inverse / ‪HACKER_MAX_RANGE;
149  heatVal = GetWeaponHackRatio( localclientnum );
150  ratio = ratio * ratio * ratio * ratio;
151  if ( ratio > 1.0 || ratio < 0.001 )
152  {
153  ratio = 0;
154  horizontal = 0;
155  }
156  else
157  {
158  horizontal = targetent getHorizontalOffsetFromScreenCenter( localClientNum, ‪HACKER_MAX_RANGE );
159  }
160 
161  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.offsetShaderValue" ), horizontal + " " + ratio + " 0 0" );
162 
163  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.perc" ), heatVal );
164 
165  if ( ratio > ‪HACKER_SWEET_SPOT_RATIO )
166  {
167  if ( !isdefined( level.hackingSweetSpotId[localclientnum] ) )
168  {
169  level.hackingSweetSpotId[localclientnum] = player playloopsound( "evt_hacker_hacking_sweet" );
170  }
171  }
172  else
173  {
174  if ( isdefined( level.hackingSweetSpotId[localclientnum] ) )
175  {
176  player stopLoopSound( level.hackingSweetSpotId[localclientnum] );
177  level.hackingSweetSpotId[localclientnum] = undefined;
178  }
179  if ( !isdefined( level.hackingSoundId[localclientnum] ) )
180  {
181  level.hackingSoundId[localclientnum] = player playloopsound( "evt_hacker_hacking_loop" );
182  }
183  if ( isdefined( level.hackingSoundId[localclientnum] ) )
184  {
185  setSoundPitch( level.hackingSoundId[localclientnum], ratio );
186  }
187  }
188 
189  if ( !isBreachingFirewall )
190  {
191  friendlyHacking = WeaponFriendlyHacking( localclientnum );
192 
193  if ( friendlyHacking && !isdefined( level.friendlyHackingSoundId[localclientnum] ) )
194  {
195  level.friendlyHackingSoundId[localclientnum] = player playloopsound( "evt_hacker_hacking_loop_mult" );
196  }
197  else if ( !friendlyHacking && isdefined( level.friendlyHackingSoundId[localclientnum] ) )
198  {
199  player stopLoopSound( level.friendlyHackingSoundId[localclientnum] );
200  level.friendlyHackingSoundId[localclientnum] = undefined;
201  }
202  }
203 
204  wait ( 0.1 );
205  }
206 }
207 
208 function ‪watchHackerPlayerShutdown( localClientNum, hackerPlayer, targetEnt )
209 {
210  self endon( "entityshutdown" );
211  killstreakEntity = self;
212  hackerPlayer endon( "player_hacking_callback" );
213 
214  hackerPlayer waittill( "entityshutdown" );
215 
216  if ( isdefined( targetEnt ) )
217  {
218  targetEnt.isbreachingfirewall = true;
219  }
220  killstreakEntity ‪duplicate_render::set_hacker_tool_hacking( localClientNum, false );
221  killstreakEntity ‪duplicate_render::set_hacker_tool_breaching( localClientNum, false );
222 }
223 
224 
225 function ‪watchForEMP( localClientNum )
226 {
227  self endon( "entityshutdown" );
228  self endon( "player_hacking_callback" );
229 
230  while ( 1 )
231  {
232  if ( self IsEMPJammed() )
233  {
234  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_EMPED );
235  }
236  else
237  {
238  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "hudItems.blackhat.status" ), ‪HACKER_TOOL_STATUS_SCANNING );
239  }
240  wait( 0.1 );
241  }
242 
243 }
‪watchHackerPlayerShutdown
‪function watchHackerPlayerShutdown(localClientNum, hackerPlayer, targetEnt)
Definition: _hacker_tool.csc:208
‪watchHackSpeed
‪function watchHackSpeed(localClientNum, isBreachingFirewall)
Definition: _hacker_tool.csc:109
‪CF_CALLBACK_ZERO_ON_NEW_ENT
‪#define CF_CALLBACK_ZERO_ON_NEW_ENT
Definition: version.gsh:103
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪player_hacking
‪function player_hacking(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _hacker_tool.csc:56
‪HACKER_TOOL_STATUS_BREACHING
‪#define HACKER_TOOL_STATUS_BREACHING
Definition: shared.gsh:834
‪set_hacker_tool_breaching
‪function set_hacker_tool_breaching(localClientNum, on_off)
Definition: duplicaterender_mgr.csc:487
‪HACKER_TOOL_ACTIVE
‪#define HACKER_TOOL_ACTIVE
Definition: shared.gsh:829
‪HACKER_TOOL_STATUS_HACKING
‪#define HACKER_TOOL_STATUS_HACKING
Definition: shared.gsh:835
‪init_shared
‪function init_shared()
Definition: _hacker_tool.csc:22
‪on_localplayer_spawned
‪function on_localplayer_spawned(localClientNum)
Definition: _hacker_tool.csc:31
‪set_hacker_tool_hacking
‪function set_hacker_tool_hacking(localClientNum, on_off)
Definition: duplicaterender_mgr.csc:481
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪HACKER_SWEET_SPOT_RATIO
‪#define HACKER_SWEET_SPOT_RATIO
Definition: _hacker_tool.csc:18
‪watchForEMP
‪function watchForEMP(localClientNum)
Definition: _hacker_tool.csc:225
‪HACKER_TOOL_HACKING
‪#define HACKER_TOOL_HACKING
Definition: shared.gsh:830
‪HACKER_TOOL_FIREWALL
‪#define HACKER_TOOL_FIREWALL
Definition: shared.gsh:831
‪HACKER_TOOL_STATUS_SCANNING
‪#define HACKER_TOOL_STATUS_SCANNING
Definition: shared.gsh:833
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪HACKER_TOOL_STATUS_EMPED
‪#define HACKER_TOOL_STATUS_EMPED
Definition: shared.gsh:836
‪HACKER_MAX_RANGE
‪#define HACKER_MAX_RANGE
Definition: _hacker_tool.csc:17
‪watchTargetHack
‪function watchTargetHack(localclientnum, player, isBreachingFirewall)
Definition: _hacker_tool.csc:128