‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
floor_collapse_shared.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\system_shared;
4 #using scripts\shared\array_shared;
5 #using scripts\shared\util_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 
9 #precache( "fx", "destruct/fx_dest_k_rail" );
10 
11 // ============================================================================
12 // Utility
13 // ============================================================================
14 
15 ‪REGISTER_SYSTEM( "floor_collapse", &‪__init__, undefined )
16 
17 function ‪__init__()
18 {
19  level thread ‪precache_destruct_fx();
20 
21  positions = ‪struct::get_array("dest_floor_panels","script_noteworthy");
22 
23  level.floor_models = [];
24 
25  foreach(struct in positions)
26  {
27  if(IsDefined(struct.model))
28  {
29  ‪array::add(level.floor_models, struct.model, false);
30  struct.modelname = struct.model;
31  }
32  else
33  {
34  ‪array::add(level.floor_models, "p6_dest_floor", false);
35  struct.modelname = "p6_dest_floor";
36  }
37  }
38 
39  if(level.floor_models.size == 0)
40  {
41  level.floor_models = ‪array("p6_dest_floor");
42  }
43 
44  level thread ‪floor_collapse_init(positions);
45 }
46 
47 // ============================================================================
48 function ‪floor_collapse_init(positions)
49 {
50  if(!IsDefined(level.floor_damage_percentage))
51  {
52  level.floor_damage_percentage = randomfloatrange(.4,.6);
53  }
54 
55  //positions = struct::get_array("dest_floor_panels","targetname");
56  positions = array::randomize(positions);
57  flr_model = [];
58 
59  for( i = 0; i < positions.size; i++)
60  {
61  if(!IsDefined(positions[i].angles))
62  {
63  positions[i].angles = (0, 0, 0);
64  }
65 
66 
67  if(level.floor_damage_percentage >= ((i+1) / positions.size))
68  {
69  if(!IsDefined(positions[i].script_width))
70  {
71  positions[i].script_width = 128;
72  }
73  if(!IsDefined(positions[i].script_length))
74  {
75  positions[i].script_length = 128;
76  }
77  if(!IsDefined(positions[i].hlth))
78  {
79  if(IsDefined(positions[i].script_float))
80  {
81  positions[i].hlth = positions[i].script_float;
82  }
83  else
84  {
85  //will take 2 seconds to collapse unless sprinting
86  positions[i].hlth = 20;
87  }
88  }
89 
90  flr_model[i] = ‪spawn( "script_model", positions[i].origin, 1 );
91  flr_model[i].angles = positions[i].angles;
92  flr_model[i] SetModel( positions[i].modelname + "_damaged" );
93  flr_model[i].modelname = positions[i].modelname;
94 
95  if(IsDefined(positions[i].target))
96  {
97  flr_model[i].clip = GetEnt(positions[i].target, "targetname");
98  flr_model[i].clip SetMovingPlatformEnabled( true );
99  }
100  //flr_model[i] ConnectPaths();
101 
102  flr_model[i].trig = ‪Spawn( "trigger_box", positions[i].origin, 0, positions[i].script_width, positions[i].script_length, 64);
103  flr_model[i].hlth = positions[i].hlth;
104 
105  if(!Isdefined(flr_model[i].break_fx))
106  flr_model[i].break_fx = level._effect[ "floor_destruct" ];
107 
108  flr_model[i] thread ‪damage_floor_watcher();
109  flr_model[i] thread ‪walk_floor_watcher();
110  }
111  else
112  {
113  flr_model[i] = ‪spawn( "script_model", positions[i].origin, 1 );
114  flr_model[i].angles = positions[i].angles;
115  flr_model[i] SetModel( positions[i].modelname );
116 
117  if(IsDefined(positions[i].target))
118  {
119  flr_model[i].clip = GetEnt(positions[i].target, "targetname");
120  flr_model[i].clip SetMovingPlatformEnabled( true );
121  }
122  //flr_model[i] ConnectPaths();
123  }
124  }
125 
126 }
127 
128 // ============================================================================
130 {
131  self endon("destroyed");
132 
133  level waittill( "prematch_over" );
134 
135  waittime = 1.0;
136 
137  while(true)
138  {
139  self.trig waittill("trigger", who);
140 
141  //points of damage per second player in trigger
142  amount = 10;
143 
144  if(who GetStance() == "prone")
145  {
146  amount = 0;
147  }
148  else if(who GetStance() == "crouch")
149  {
150  amount = 1; //may add some damage for crouch.
151  }
152 
153  //if sprinting collapse immediately.
154  if(isdefined( who.sprinting ) && who.sprinting == 1 )
155  {
156  amount = self.hlth;
157  //do_shake = 1;
158  }
159 
160  self.hlth = self.hlth - amount;
161 
162  if(amount > 0)
163  {
164  if(self.hlth <=0)
165  {
166  nduration = (amount / 10);
167  }
168  else
169  {
170  nduration = waittime;
171  }
172 
173  // Earthquake
174  nMagnitude = (0.04 * amount);
175  nRadius = 500;
176  v_pos = self.origin;
177  Earthquake( nMagnitude, nDuration, v_pos, nRadius );
178  }
179 
180  if (self.hlth <= 0)
181  {
182  self SetModel( self.modelname + "_destroyed" );
183 
184  Self.trig Delete();
185 
186  ‪PlayFx(self.break_fx, self.origin);
187  //self playsound(self.break_sound);
188 
189  Self NotSolid();
190  if(IsDefined(self.clip))
191  {
192  self.clip Delete();
193  }
194  Self DisconnectPaths();
195 
196  self notify("destroyed");
197  return;
198  }
199  wait(waittime);
200  }
201 }
202 
204 {
205  self endon("destroyed");
206 
207  self setcandamage(true);
208 
209  while(true)
210  {
211 
212  self waittill( "damage", amount, who, direction_vec, point, type, modelName, tagName, partName );
213 
214  self.hlth = self.hlth - amount;
215  if (self.hlth <= 0)
216  {
217  self SetModel( self.modelname + "_destroyed" );
218 
219  Self.trig Delete();
220 
221  ‪PlayFx(self.break_fx, self.origin);
222  //self playsound(self.break_sound);
223 
224  Self NotSolid();
225  if(IsDefined(self.clip))
226  {
227  self.clip Delete();
228  }
229  Self DisconnectPaths();
230 
231  self notify("destroyed");
232  return;
233  }
234  wait(1);
235  }
236 }
237 
238 
239 // ============================================================================
241 {
242  level._effect[ "floor_destruct" ] = "destruct/fx_dest_k_rail";
243 }
‪precache_destruct_fx
‪function precache_destruct_fx()
Definition: floor_collapse_shared.gsc:240
‪floor_collapse_init
‪function floor_collapse_init(positions)
Definition: floor_collapse_shared.gsc:48
‪__init__
‪function __init__()
Definition: floor_collapse_shared.gsc:17
‪get_array
‪function get_array(kvp_value, kvp_key="targetname")
Definition: struct.csc:34
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪add
‪function add(entity, dyingplayer, team, timeout)
Definition: _deathicons.gsc:43
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪array
‪function filter array
Definition: array_shared.csc:16
‪Spawn
‪function Spawn(parent, onDeathCallback)
Definition: _flak_drone.gsc:427
‪walk_floor_watcher
‪function walk_floor_watcher()
Definition: floor_collapse_shared.gsc:129
‪damage_floor_watcher
‪function damage_floor_watcher()
Definition: floor_collapse_shared.gsc:203
‪PlayFx
‪function PlayFx(name)
Definition: _counteruav.gsc:390