‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_rotating_object.csc
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\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 
10 #namespace rotating_object;
11 
12 ‪REGISTER_SYSTEM( "rotating_object", &‪__init__, undefined )
13 
14 /*
15 This script sets up functionality in multiplayer where an object can be rotated. It must be given the "rotating_object" targetname.
16 It must also have a script_float, which determines how many seconds it take for the object to complete a full 360 degree rotation.
17 This script is called by the _load.csc
18 */
19 
20 function ‪__init__()
21 {
23 }
24 
25 //Start a rotation thread on each object with the appropriate targetname and set a rotation speed dvar.
26 function ‪init( localClientNum )
27 {
28  rotating_objects = GetEntArray( localClientNum, "rotating_object", "targetname" );
29  array::thread_all( rotating_objects,&‪rotating_object_think );
30 }
31 
32 //Set up rotation behvahior. 'Self' is the rotating object.
34 {
35  self endon ("entityshutdown");
36 
38 
39  //I create this variable to manage what kind of rotate I want to use
40  axis = "yaw";
41  direction = 360;
42  revolutions = 100;
43  rotate_time = 12;
44 
45  if( isdefined( self.script_noteworthy ) )
46  {
47  axis = self.script_noteworthy;
48  }
49 
50  if( isdefined( self.script_float ) )
51  {
52  //The script_float on the object determines how fast it spins, if it is defined
53  rotate_time = self.script_float;
54  }
55 
56  //Prevent SRE if zero were to be passed as a time value in the rotate function
57  if ( rotate_time == 0 )
58  {
59  //Default spin speed
60  rotate_time = 12;
61  }
62 
63  if ( rotate_time < 0 )
64  {
65  direction *= -1;
66  rotate_time *= -1;
67  }
68 
69  angles = self.angles;
70 
71  while( 1 )
72  {
73  switch( axis )
74  {
75  case "roll":
76  self RotateRoll( direction * revolutions, rotate_time * revolutions );
77  break;
78 
79  case "pitch":
80  self RotatePitch( direction * revolutions, rotate_time * revolutions );
81  break;
82 
83  case "yaw":
84  default:
85  self RotateYaw( direction * revolutions, rotate_time * revolutions );
86  break;
87  }
88 
89  self waittill( "rotatedone" );
90  self.angles = angles;
91  }
92 }
‪rotating_object_think
‪function rotating_object_think()
Definition: _rotating_object.csc:33
‪__init__
‪function __init__()
Definition: _rotating_object.csc:20
‪on_localclient_connect
‪function on_localclient_connect(localClientNum)
Definition: ctf.csc:20
‪init
‪function init(localClientNum)
Definition: _rotating_object.csc:26
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪waitforallclients
‪function waitforallclients()
Definition: util_shared.csc:36