‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gadget_drone.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\flagsys_shared;
5 #using scripts\shared\util_shared;
6 #using scripts\shared\vehicle_shared;
7 #using scripts\shared\vehicles\_escort_drone;
8 
9 #using scripts\shared\abilities\_ability_player;
10 #using scripts\shared\abilities\_ability_power;
11 #using scripts\shared\abilities\_ability_util;
12 
13 #insert scripts\shared\shared.gsh;
14 #insert scripts\shared\version.gsh;
15 #insert scripts\shared\abilities\_ability_util.gsh;
16 
17 
18 #using scripts\shared\system_shared;
19 
20 #precache( "fx", "vehicle/fx_elec_teleport_escort_drone" );
21 
22 ‪REGISTER_SYSTEM( "gadget_drone", &‪__init__, undefined )
23 
24 function ‪__init__()
25 {
32 
34 
35 }
36 
38 {
39  level._effect["drone_spawn_fx"] = "vehicle/fx_elec_teleport_escort_drone";
40 }
41 
42 function ‪gadget_drone_is_inuse( slot )
43 {
44  // returns true when the gadget is on
45  return self ‪flagsys::get( "gadget_drone_on" );
46 }
47 
49 {
50  // returns true when the gadget is flickering
51  return self GadgetFlickering( slot );
52 }
53 
55 {
56  // excuted when the gadget flickers
57  self thread ‪gadget_drone_flicker( slot );
58 }
59 
60 function ‪gadget_drone_on_give( slot, weapon )
61 {
62  // executed when gadget is added to the players inventory
63 }
64 
65 function ‪gadget_drone_on_take( slot )
66 {
67  // executed when gadget is removed from the players inventory
68 }
69 
70 //self is the player
72 {
73  // setup up stuff on player connect
74 }
75 
76 function ‪gadget_drone_on( slot )
77 {
78  // excecutes when the gadget is turned on
79  self ‪flagsys::set( "gadget_drone_on" );
80 
81  self thread ‪gadget_drone_spawn();
82 }
83 
84 function ‪gadget_drone_off( slot )
85 {
86  self notify( "gadget_drone_off" );
87  // excecutes when the gadget is turned off
88  self ‪flagsys::clear( "gadget_drone_on" );
89 
90  if ( IsDefined( self.escort ) )
91  {
92  self thread ‪gadget_drone_despawn();
93  }
94 }
95 
96 function ‪set_gadget_status( status, time )
97 {
98  timeStr = "";
99 
100  if ( IsDefined( time ) )
101  {
102  timeStr = "^3" + ", time: " + time;
103  }
104 
105  if ( GetDvarInt( "scr_cpower_debug_prints" ) > 0 )
106  self IPrintlnBold( "Gadget Drone:" + status + timeStr );
107 }
108 
109 function ‪gadget_drone_flicker( slot )
110 {
111  self endon( "disconnect" );
112 
113  if ( !self ‪gadget_drone_is_inuse( slot ) )
114  {
115  return;
116  }
117 
118  eventTime = self._gadgets_player[slot].gadget_flickertime;
119 
120  self ‪set_gadget_status( "Flickering", eventTime );
121 
122  while( 1 )
123  {
124  if ( !self GadgetFlickering( slot ) )
125  {
126  self ‪set_gadget_status( "Normal" );
127  return;
128  }
129 
130  wait( 0.5 );
131  }
132 }
133 
135 {
136  self endon( "disconnect" );
137  self endon( "gadget_drone_off" );
138 
139  n_above_head = 40;
140  n_ahead_dist = self._gadgets_player.escortLaunchDistance;
141 
142  v_player_angles = self GetPlayerAngles();
143 
144  self.escort = ‪vehicle::spawn( "veh_t7_drone_escort", "ed", "escort_drone", (0,0,0), v_player_angles );
145  self.escort.owner = self;
146  self.escort.ignoreme = true;
147 
148  self.escort ‪escort_drone::escort_drone_think( self );
149 
150  ‪vehicle::init( self.escort );
152 
153  v_offset = self GetPlayerViewHeight() + n_above_head;
154 
155  self.escort.origin = ( self.origin[0], self.origin[1], self.origin[2] + v_offset );
156 
157  self.escort.goal = self.escort.origin + ( AnglesToForward( v_player_angles ) * n_ahead_dist );
158 
159  if ( self.escort SetVehGoalPos( self.escort.goal, true, 2 ) )
160  {
161  self.escort ‪util::waittill_any_timeout( 2, "near_goal", "force_goal", "reached_end_node" );
162 
164  }
165 }
166 
168 {
169  //TODO - temp
170  PlayFX( level._effect["drone_spawn_fx"], self.escort.origin );
171 
172  self.escort Delete();
173 }
‪register_gadget_is_flickering_callbacks
‪function register_gadget_is_flickering_callbacks(type, flickering_func)
Definition: _ability_player.gsc:299
‪register_gadget_possession_callbacks
‪function register_gadget_possession_callbacks(type, on_give, on_take)
Definition: _ability_player.gsc:221
‪escort_drone_start_ai
‪function escort_drone_start_ai()
Definition: _escort_drone.gsc:164
‪gadget_drone_on_take
‪function gadget_drone_on_take(slot)
Definition: _gadget_drone.gsc:65
‪gadget_drone_flicker
‪function gadget_drone_flicker(slot)
Definition: _gadget_drone.gsc:109
‪clear
‪function clear(str_flag)
Definition: flag_shared.csc:130
‪register_gadget_is_inuse_callbacks
‪function register_gadget_is_inuse_callbacks(type, inuse_func)
Definition: _ability_player.gsc:289
‪gadget_drone_on_flicker
‪function gadget_drone_on_flicker(slot)
Definition: _gadget_drone.gsc:54
‪gadget_drone_off
‪function gadget_drone_off(slot)
Definition: _gadget_drone.gsc:84
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪waittill_any_timeout
‪function waittill_any_timeout(n_timeout, string1, string2, string3, string4, string5)
Definition: util_shared.csc:423
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪register_gadget_flicker_callbacks
‪function register_gadget_flicker_callbacks(type, on_flicker)
Definition: _ability_player.gsc:253
‪gadget_drone_is_inuse
‪function gadget_drone_is_inuse(slot)
Definition: _gadget_drone.gsc:42
‪gadget_drone_on
‪function gadget_drone_on(slot)
Definition: _gadget_drone.gsc:76
‪gadget_drone_spawn
‪function gadget_drone_spawn()
Definition: _gadget_drone.gsc:134
‪gadget_drone_is_flickering
‪function gadget_drone_is_flickering(slot)
Definition: _gadget_drone.gsc:48
‪GADGET_TYPE_DRONE
‪#define GADGET_TYPE_DRONE
Definition: _ability_util.gsh:9
‪set_gadget_status
‪function set_gadget_status(status, time)
Definition: _gadget_drone.gsc:96
‪register_gadget_activation_callbacks
‪function register_gadget_activation_callbacks(type, turn_on, turn_off)
Definition: _ability_player.gsc:237
‪gadget_drone_on_connect
‪function gadget_drone_on_connect()
Definition: _gadget_drone.gsc:71
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪drone_precache
‪function drone_precache()
Definition: _gadget_drone.gsc:37
‪__init__
‪function __init__()
Definition: _gadget_drone.gsc:24
‪init
‪function init()
Definition: struct.csc:1
‪gadget_drone_despawn
‪function gadget_drone_despawn()
Definition: _gadget_drone.gsc:167
‪set
‪function set(str_field_name, n_value)
Definition: clientfield_shared.gsc:34
‪gadget_drone_on_give
‪function gadget_drone_on_give(slot, weapon)
Definition: _gadget_drone.gsc:60
‪on_connect
‪function on_connect()
Definition: _arena.gsc:20
‪escort_drone_start_scripted
‪function escort_drone_start_scripted()
Definition: _escort_drone.gsc:135
‪escort_drone_think
‪function escort_drone_think(player)
Definition: _escort_drone.gsc:33