Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.60 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include common_scripts\_createfx;
  3.  
  4. initFX()
  5. {
  6. if ( !isdefined( level.func ) )
  7. {
  8. // this array will be filled with code commands that SP or MP may use but doesn't exist in the other.
  9. level.func = [];
  10. }
  11. if( !isdefined( level.func[ "create_triggerfx" ] ) )
  12. level.func[ "create_triggerfx" ] = ::create_triggerfx;
  13.  
  14. // wrapper for the exploder function so we dont have to use flags and do ifs/waittills on every exploder call
  15. level.exploderFunction = ::exploder_before_load;
  16. waittillframeend;// Wait one frame so the effects get setup by the maps fx thread
  17. waittillframeend;// Wait another frame so effects can be loaded based on start functions. Without this FX are initialiazed before they are defined by start functions.
  18. level.exploderFunction = ::exploder_after_load;
  19.  
  20. /# setDevDvarIfUninitialized( "scr_map_exploder_dump", 0 ); #/
  21.  
  22. for ( i = 0; i < level.createFXent.size; i++ )
  23. {
  24. ent = level.createFXent[ i ];
  25. ent set_forward_and_up_vectors();
  26.  
  27. if ( ent.v[ "type" ] == "loopfx" )
  28. ent thread loopfxthread();
  29. if ( ent.v[ "type" ] == "oneshotfx" )
  30. ent thread oneshotfxthread();
  31. if ( ent.v[ "type" ] == "soundfx" )
  32. ent thread create_loopsound();
  33. }
  34. }
  35.  
  36. print_org( fxcommand, fxId, fxPos, waittime )
  37. {
  38. if ( GetDvar( "debug" ) == "1" )
  39. {
  40. println( "{" );
  41. println( "\"origin\" \"" + fxPos[ 0 ] + " " + fxPos[ 1 ] + " " + fxPos[ 2 ] + "\"" );
  42. println( "\"classname\" \"script_model\"" );
  43. println( "\"model\" \"fx\"" );
  44. println( "\"script_fxcommand\" \"" + fxcommand + "\"" );
  45. println( "\"script_fxid\" \"" + fxId + "\"" );
  46. println( "\"script_delay\" \"" + waittime + "\"" );
  47. println( "}" );
  48. }
  49. }
  50.  
  51. OneShotfx( fxId, fxPos, waittime, fxPos2 )
  52. {
  53. // level thread print_org ("OneShotfx", fxId, fxPos, waittime);
  54. // level thread OneShotfxthread (fxId, fxPos, waittime, fxPos2);
  55. }
  56.  
  57. exploderfx( num, fxId, fxPos, waittime, fxPos2, fireFx, fireFxDelay, fireFxSound, fxSound, fxQuake, fxDamage, soundalias, repeat, delay_min, delay_max, damage_radius, fireFxTimeout, exploder_group )
  58. {
  59. if ( 1 )
  60. {
  61. ent = createExploder( fxId );
  62. ent.v[ "origin" ] = fxPos;
  63. ent.v[ "angles" ] = ( 0, 0, 0 );
  64. if ( isdefined( fxPos2 ) )
  65. ent.v[ "angles" ] = vectortoangles( fxPos2 - fxPos );
  66. ent.v[ "delay" ] = waittime;
  67. ent.v[ "exploder" ] = num;
  68. // deprecated
  69. return;
  70. }
  71. fx = spawn( "script_origin", ( 0, 0, 0 ) );
  72. // println ("total ", getentarray ("script_origin","classname").size);
  73. fx.origin = fxPos;
  74. fx.angles = vectortoangles( fxPos2 - fxPos );
  75. // fx.targetname = "exploder";
  76. fx.script_exploder = num;
  77. fx.script_fxid = fxId;
  78. fx.script_delay = waittime;
  79.  
  80. fx.script_firefx = fireFx;
  81. fx.script_firefxdelay = ( fireFxDelay );// for awhile the script exported strings for this value so we cast it to float
  82. fx.script_firefxsound = fireFxSound;
  83.  
  84. fx.script_sound = fxSound;
  85. fx.script_earthquake = fxQuake;
  86. fx.script_damage = ( fxDamage );
  87. fx.script_radius = ( damage_radius );
  88. fx.script_soundalias = soundalias;
  89. fx.script_firefxtimeout = ( fireFxTimeout );
  90. fx.script_repeat = ( repeat );
  91. fx.script_delay_min = ( delay_min );
  92. fx.script_delay_max = ( delay_max );
  93. fx.script_exploder_group = exploder_group;
  94.  
  95. forward = anglestoforward( fx.angles );
  96. forward = vector_multiply( forward, 150 );
  97. fx.targetPos = fxPos + forward;
  98.  
  99. if ( !isdefined( level._script_exploders ) )
  100. level._script_exploders = [];
  101. level._script_exploders[ level._script_exploders.size ] = fx;
  102.  
  103. createfx_showOrigin( fxid, fxPos, waittime, fxpos2, "exploderfx", fx, undefined, fireFx, fireFxDelay,
  104. fireFxSound, fxSound, fxQuake, fxDamage, soundalias, repeat, delay_min, delay_max, damage_radius, fireFxTimeout );
  105. }
  106.  
  107.  
  108. /*
  109. loopfxRotate(fxId, fxPos, waittime, angle, fxStart, fxStop, timeout)
  110. {
  111. level thread print_org ("loopfx", fxId, fxPos, waittime);
  112. level thread loopfxthread (fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout);
  113. }
  114. */
  115.  
  116.  
  117. loopfx( fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout )
  118. {
  119. println( "Loopfx is deprecated!" );
  120. ent = createLoopEffect( fxId );
  121. ent.v[ "origin" ] = fxPos;
  122. ent.v[ "angles" ] = ( 0, 0, 0 );
  123. if ( isdefined( fxPos2 ) )
  124. ent.v[ "angles" ] = vectortoangles( fxPos2 - fxPos );
  125. ent.v[ "delay" ] = waittime;
  126. }
  127.  
  128. /*
  129. loopfx(fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout)
  130. {
  131. level thread print_org ("loopfx", fxId, fxPos, waittime);
  132. level thread loopfxthread (fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout);
  133. }
  134. */
  135.  
  136. create_looper()
  137. {
  138. //assert (isdefined(self.looper));
  139. self.looper = playLoopedFx( level._effect[ self.v[ "fxid" ] ], self.v[ "delay" ], self.v[ "origin" ], 0, self.v[ "forward" ], self.v[ "up" ] );
  140. create_loopsound();
  141. }
  142.  
  143. create_loopsound()
  144. {
  145. self notify( "stop_loop" );
  146. if ( isdefined( self.v[ "soundalias" ] ) && ( self.v[ "soundalias" ] != "nil" ) )
  147. {
  148. if ( isdefined( self.v[ "stopable" ] ) && self.v[ "stopable" ] )
  149. {
  150. if ( isdefined( self.looper ) )
  151. self.looper thread loop_fx_sound( self.v[ "soundalias" ], self.v[ "origin" ], "death" );
  152. else
  153. thread loop_fx_sound( self.v[ "soundalias" ], self.v[ "origin" ], "stop_loop" );
  154. }
  155. else
  156. {
  157. if ( isdefined( self.looper ) )
  158. self.looper thread loop_fx_sound( self.v[ "soundalias" ], self.v[ "origin" ] );
  159. else
  160. thread loop_fx_sound( self.v[ "soundalias" ], self.v[ "origin" ] );
  161. }
  162. }
  163. }
  164.  
  165. loopfxthread()
  166. {
  167. waitframe();
  168. // println ( "fx testing running Id: ", fxId );
  169. // if ((isdefined (level.scr_sound)) && (isdefined (level.scr_sound[fxId])))
  170. // loopSound(level.scr_sound[fxId], fxPos);
  171.  
  172. if ( isdefined( self.fxStart ) )
  173. level waittill( "start fx" + self.fxStart );
  174.  
  175. while ( 1 )
  176. {
  177. /*
  178. if (isdefined (ent.org2))
  179. {
  180. fxAngle = vectorNormalize (ent.org2 - ent.org);
  181. looper = playLoopedFx( level._effect[fxId], ent.delay, ent.org, 0, fxAngle );
  182. }
  183. else
  184. looper = playLoopedFx( level._effect[fxId], ent.delay, ent.org, 0 );
  185. */
  186. create_looper();
  187.  
  188. if ( isdefined( self.timeout ) )
  189. thread loopfxStop( self.timeout );
  190.  
  191. if ( isdefined( self.fxStop ) )
  192. level waittill( "stop fx" + self.fxStop );
  193. else
  194. return;
  195.  
  196. if ( isdefined( self.looper ) )
  197. self.looper delete();
  198.  
  199. if ( isdefined( self.fxStart ) )
  200. level waittill( "start fx" + self.fxStart );
  201. else
  202. return;
  203. }
  204. }
  205.  
  206. loopfxChangeID( ent )
  207. {
  208. self endon( "death" );
  209. ent waittill( "effect id changed", change );
  210. }
  211.  
  212. loopfxChangeOrg( ent )
  213. {
  214. self endon( "death" );
  215. for ( ;; )
  216. {
  217. ent waittill( "effect org changed", change );
  218. self.origin = change;
  219. }
  220. }
  221.  
  222. loopfxChangeDelay( ent )
  223. {
  224. self endon( "death" );
  225. ent waittill( "effect delay changed", change );
  226. }
  227.  
  228. loopfxDeletion( ent )
  229. {
  230. self endon( "death" );
  231. ent waittill( "effect deleted" );
  232. self delete();
  233. }
  234.  
  235. loopfxStop( timeout )
  236. {
  237. self endon( "death" );
  238. wait( timeout );
  239. self.looper delete();
  240. }
  241.  
  242. loopSound( sound, Pos, waittime )
  243. {
  244. // level thread print_org ("loopSound", sound, Pos, waittime);
  245. level thread loopSoundthread( sound, Pos, waittime );
  246. }
  247.  
  248. loopSoundthread( sound, pos, waittime )
  249. {
  250. org = spawn( "script_origin", ( pos ) );
  251.  
  252. org.origin = pos;
  253. // println ("hello1 ", org.origin, sound);
  254. org playLoopSound( sound );
  255. }
  256.  
  257. gunfireloopfx( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
  258. {
  259. thread gunfireloopfxthread( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax );
  260. }
  261.  
  262. gunfireloopfxthread( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
  263. {
  264. level endon( "stop all gunfireloopfx" );
  265. waitframe();
  266.  
  267. if ( betweenSetsMax < betweenSetsMin )
  268. {
  269. temp = betweenSetsMax;
  270. betweenSetsMax = betweenSetsMin;
  271. betweenSetsMin = temp;
  272. }
  273.  
  274. betweenSetsBase = betweenSetsMin;
  275. betweenSetsRange = betweenSetsMax - betweenSetsMin;
  276.  
  277. if ( shotdelayMax < shotdelayMin )
  278. {
  279. temp = shotdelayMax;
  280. shotdelayMax = shotdelayMin;
  281. shotdelayMin = temp;
  282. }
  283.  
  284. shotdelayBase = shotdelayMin;
  285. shotdelayRange = shotdelayMax - shotdelayMin;
  286.  
  287. if ( shotsMax < shotsMin )
  288. {
  289. temp = shotsMax;
  290. shotsMax = shotsMin;
  291. shotsMin = temp;
  292. }
  293.  
  294. shotsBase = shotsMin;
  295. shotsRange = shotsMax - shotsMin;
  296.  
  297. fxEnt = spawnFx( level._effect[ fxId ], fxPos );
  298. fxEnt willNeverChange();
  299. for ( ;; )
  300. {
  301. shotnum = shotsBase + randomint( shotsRange );
  302. for ( i = 0;i < shotnum;i++ )
  303. {
  304. triggerFx( fxEnt );
  305.  
  306. wait( shotdelayBase + randomfloat( shotdelayRange ) );
  307. }
  308. wait( betweenSetsBase + randomfloat( betweenSetsRange ) );
  309. }
  310. }
  311.  
  312. gunfireloopfxVec( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
  313. {
  314. thread gunfireloopfxVecthread( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax );
  315. }
  316.  
  317. gunfireloopfxVecthread( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
  318. {
  319. level endon( "stop all gunfireloopfx" );
  320. waitframe();
  321.  
  322. if ( betweenSetsMax < betweenSetsMin )
  323. {
  324. temp = betweenSetsMax;
  325. betweenSetsMax = betweenSetsMin;
  326. betweenSetsMin = temp;
  327. }
  328.  
  329. betweenSetsBase = betweenSetsMin;
  330. betweenSetsRange = betweenSetsMax - betweenSetsMin;
  331.  
  332. if ( shotdelayMax < shotdelayMin )
  333. {
  334. temp = shotdelayMax;
  335. shotdelayMax = shotdelayMin;
  336. shotdelayMin = temp;
  337. }
  338.  
  339. shotdelayBase = shotdelayMin;
  340. shotdelayRange = shotdelayMax - shotdelayMin;
  341.  
  342. if ( shotsMax < shotsMin )
  343. {
  344. temp = shotsMax;
  345. shotsMax = shotsMin;
  346. shotsMin = temp;
  347. }
  348.  
  349. shotsBase = shotsMin;
  350. shotsRange = shotsMax - shotsMin;
  351.  
  352. fxPos2 = vectornormalize( fxPos2 - fxPos );
  353.  
  354. fxEnt = spawnFx( level._effect[ fxId ], fxPos, fxPos2 );
  355. fxEnt willNeverChange();
  356. for ( ;; )
  357. {
  358. shotnum = shotsBase + randomint( shotsRange );
  359. for ( i = 0;i < int( shotnum / level.fxfireloopmod );i++ )
  360. {
  361. triggerFx( fxEnt );
  362. delay = ( ( shotdelayBase + randomfloat( shotdelayRange ) ) * level.fxfireloopmod );
  363. if ( delay < .05 )
  364. delay = .05;
  365. wait delay;
  366. }
  367. wait( shotdelayBase + randomfloat( shotdelayRange ) );
  368. wait( betweenSetsBase + randomfloat( betweenSetsRange ) );
  369. }
  370. }
  371.  
  372. setfireloopmod( value )
  373. {
  374. level.fxfireloopmod = 1 / value;
  375. }
  376.  
  377. setup_fx()
  378. {
  379. if ( ( !isdefined( self.script_fxid ) ) || ( !isdefined( self.script_fxcommand ) ) || ( !isdefined( self.script_delay ) ) )
  380. {
  381. // println (self.script_fxid);
  382. // println (self.script_fxcommand);
  383. // println (self.script_delay);
  384. // println ("Effect at origin ", self.origin," doesn't have script_fxid/script_fxcommand/script_delay");
  385. // self delete();
  386. return;
  387. }
  388.  
  389. // println ("^a Command:", self.script_fxcommand, " Effect:", self.script_fxID, " Delay:", self.script_delay, " ", self.origin);
  390. if ( isdefined( self.model ) )
  391. if ( self.model == "toilet" )
  392. {
  393. self thread burnville_paratrooper_hack();
  394. return;
  395. }
  396.  
  397. org = undefined;
  398. if ( isdefined( self.target ) )
  399. {
  400. ent = getent( self.target, "targetname" );
  401. if ( isdefined( ent ) )
  402. org = ent.origin;
  403. }
  404.  
  405. fxStart = undefined;
  406. if ( isdefined( self.script_fxstart ) )
  407. fxStart = self.script_fxstart;
  408.  
  409. fxStop = undefined;
  410. if ( isdefined( self.script_fxstop ) )
  411. fxStop = self.script_fxstop;
  412.  
  413. if ( self.script_fxcommand == "OneShotfx" )
  414. OneShotfx( self.script_fxId, self.origin, self.script_delay, org );
  415. if ( self.script_fxcommand == "loopfx" )
  416. loopfx( self.script_fxId, self.origin, self.script_delay, org, fxStart, fxStop );
  417. if ( self.script_fxcommand == "loopsound" )
  418. loopsound( self.script_fxId, self.origin, self.script_delay );
  419.  
  420. self delete();
  421. }
  422.  
  423. burnville_paratrooper_hack()
  424. {
  425. normal = ( 0, 0, self.angles[ 1 ] );
  426. // println ("z: paratrooper fx hack: ", normal);
  427. id = level._effect[ self.script_fxId ];
  428. origin = self.origin;
  429.  
  430. // if (isdefined (self.script_delay))
  431. // wait (self.script_delay);
  432.  
  433. wait 1;
  434. level thread burnville_paratrooper_hack_loop( normal, origin, id );
  435. self delete();
  436. }
  437.  
  438. burnville_paratrooper_hack_loop( normal, origin, id )
  439. {
  440. while ( 1 )
  441. {
  442. // iprintln ("z: playing paratrooper fx", origin);
  443.  
  444. playfx( id, origin );
  445. wait( 30 + randomfloat( 40 ) );
  446. }
  447. }
  448.  
  449. create_triggerfx()
  450. {
  451. //assert (isdefined(self.looper));
  452. if( ! verify_effects_assignment( self.v[ "fxid" ] ) )
  453. return;
  454.  
  455. self.looper = spawnFx( level._effect[ self.v[ "fxid" ] ], self.v[ "origin" ], self.v[ "forward" ], self.v[ "up" ] );
  456. triggerFx( self.looper, self.v[ "delay" ] );
  457. self.looper willNeverChange();
  458. create_loopsound();
  459. }
  460.  
  461. verify_effects_assignment( effectID )
  462. {
  463. if( isdefined ( level._effect[ effectID ] ) )
  464. return true;
  465. if( ! isdefined( level._missing_FX ) )
  466. level._missing_FX = [];
  467. level._missing_FX[ self.v[ "fxid" ] ] = effectID;
  468. verify_effects_assignment_print( effectID );
  469. return false;
  470. }
  471.  
  472. verify_effects_assignment_print( effectID )
  473. {
  474.  
  475. level notify ( "verify_effects_assignment_print" );
  476. level endon ( "verify_effects_assignment_print" );
  477. wait .05; //allow errors on the same frame to que up before printing
  478.  
  479. println("Error:");
  480. println("Error:**********MISSING EFFECTS IDS**********");
  481. keys = getarraykeys( level._missing_FX );
  482. foreach( key in keys )
  483. {
  484. println( "Error: Missing Effects ID assignment for: "+ key );
  485. }
  486. println("Error:");
  487.  
  488. assertmsg( "Missing Effects ID assignments ( see console )" );
  489. }
  490.  
  491. OneShotfxthread()
  492. {
  493. waitframe();
  494.  
  495. if ( self.v[ "delay" ] > 0 )
  496. wait self.v[ "delay" ];
  497.  
  498. /*
  499. if ( isdefined( self.v[ "fire_range" ] ) )
  500. {
  501. thread fire_radius( self.v[ "origin" ], self.v[ "fire_range" ] );
  502. }
  503. */
  504.  
  505. [[ level.func[ "create_triggerfx" ] ]]();
  506. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement