‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
beam_shared.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\util_shared;
5 #using scripts\shared\system_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 
9 #namespace beam;
10 
11 function ‪launch( ent_1, str_tag1, ent_2, str_tag2, str_beam_type )
12 {
13  s_beam = ‪_get_beam( ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
14 
15  if ( !isdefined( s_beam ) )
16  {
17  s_beam = ‪_new_beam( ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
18  }
19 
20  if ( self == level )
21  {
22  if ( isdefined( level.localplayers ) )
23  {
24  foreach ( player in level.localplayers )
25  {
26  if ( isdefined( player ) )
27  {
28  player ‪launch( ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
29  }
30  }
31  }
32  }
33  else if ( isdefined( s_beam ) )
34  {
35  s_beam.beam_id = BeamLaunch( self.localclientnum, ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
36  self thread ‪_kill_on_ent_death( s_beam, ent_1, ent_2 );
37  return s_beam.beam_id;
38  }
39 }
40 
41 function ‪kill( ent_1, str_tag1, ent_2, str_tag2, str_beam_type )
42 {
43  if ( isdefined( self.active_beams ) )
44  {
45  s_beam = ‪_get_beam( ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
46  ArrayRemoveValue( self.active_beams, s_beam, false );
47  }
48 
49  if ( self == level )
50  {
51  if ( isdefined( level.localplayers ) )
52  {
53  foreach ( player in level.localplayers )
54  {
55  if ( isdefined( player ) )
56  {
57  player ‪kill( ent_1, str_tag1, ent_2, str_tag2, str_beam_type );
58  }
59  }
60  }
61  }
62  else if ( isdefined( s_beam ) )
63  {
64  s_beam notify( "kill" );
65  BeamKill( self.localclientnum, s_beam.beam_id );
66  }
67 }
68 
70 // Private //////////////////////////////////////////////////////////////////////////////////////////
72 
73 function private ‪_new_beam( ent_1, str_tag1, ent_2, str_tag2, str_beam_type )
74 {
75  ‪DEFAULT( self.active_beams, [] );
76 
77  s_beam = SpawnStruct();
78  s_beam.ent_1 = ent_1;
79  s_beam.str_tag1 = str_tag1;
80  s_beam.ent_2 = ent_2;
81  s_beam.str_tag2 = str_tag2;
82  s_beam.str_beam_type = str_beam_type;
83 
84  ‪ARRAY_ADD( self.active_beams, s_beam );
85 
86  return s_beam;
87 }
88 
89 function private ‪_get_beam( ent_1, str_tag1, ent_2, str_tag2, str_beam_type )
90 {
91  if ( isdefined( self.active_beams ) )
92  {
93  foreach ( s_beam in self.active_beams )
94  {
95  if ( ( s_beam.ent_1 == ent_1 )
96  && ( s_beam.str_tag1 == str_tag1 )
97  && ( s_beam.ent_2 == ent_2 )
98  && ( s_beam.str_tag2 == str_tag2 )
99  && ( s_beam.str_beam_type == str_beam_type ) )
100  {
101  return s_beam;
102  }
103  }
104  }
105 }
106 
107 function private ‪_kill_on_ent_death( s_beam, ent_1, ent_2 )
108 {
109  s_beam endon( "kill" );
110  self endon( "death" );
111 
112  ‪util::waittill_any_ents( ent_1, "entityshutdown", ent_2, "entityshutdown", s_beam, "kill", self, "death" );
113 
114  if ( isdefined( self ) )
115  {
116  ArrayRemoveValue( self.active_beams, s_beam, false );
117  BeamKill( self.localclientnum, s_beam.beam_id );
118  }
119 }
‪_get_beam
‪function private _get_beam(ent_1, str_tag1, ent_2, str_tag2, str_beam_type)
Definition: beam_shared.csc:89
‪_new_beam
‪function private _new_beam(ent_1, str_tag1, ent_2, str_tag2, str_beam_type)
Definition: beam_shared.csc:73
‪launch
‪function launch(ent_1, str_tag1, ent_2, str_tag2, str_beam_type)
Definition: beam_shared.csc:11
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪kill
‪function kill(ent_1, str_tag1, ent_2, str_tag2, str_beam_type)
Definition: beam_shared.csc:41
‪_kill_on_ent_death
‪function private _kill_on_ent_death(s_beam, ent_1, ent_2)
Definition: beam_shared.csc:107
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪waittill_any_ents
‪function waittill_any_ents(ent1, string1, ent2, string2, ent3, string3, ent4, string4, ent5, string5, ent6, string6, ent7, string7)
Definition: util_shared.csc:496