Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.87 KB | None | 0 0
  1. #include common_scripts\utility;
  2.  
  3. main( painter_spmp )
  4. {
  5.  
  6. painter_setup_array = getentarray( "painter_setup", "targetname" );
  7.  
  8. if ( !painter_setup_array.size )
  9. return;
  10.  
  11. if ( !getdvarint( "painter" ) )
  12. {
  13. array_thread( painter_setup_array, ::painter_clean_me );
  14. return;
  15. }
  16.  
  17. painter_initvars( painter_spmp );
  18.  
  19. painter_groups = [];
  20.  
  21. groups = get_painter_groups( painter_setup_array );
  22.  
  23. foreach ( group in groups )
  24. setup_painter_group( group );
  25.  
  26. thread painter_init();
  27.  
  28. array_thread( level.spam_model_group, ::default_undefined );
  29. level.stop_load = true;
  30. level waittill( "forever" );
  31. }
  32.  
  33. painter_clean_me()
  34. {
  35. if( isdefined( self.target ) )
  36. {
  37. ent = getent(self.target,"targetname");
  38. ent delete();
  39. }
  40. self delete();
  41. }
  42.  
  43. default_undefined()
  44. {
  45. if ( !isdefined( self.bPosedstyle ) )
  46. self.bPosedstyle = false;
  47. if ( !isdefined( self.bOrienttoplayeryrot ) )
  48. self.bOrienttoplayeryrot = false;
  49. if ( !isdefined( self.bTreeOrient ) )
  50. self.bTreeOrient = false;
  51. if ( !isdefined( self.bFacade ) )
  52. self.bFacade = false;
  53. if ( !isdefined( self.density ) )
  54. self.density = 32;
  55. if ( !isdefined( self.radius ) )
  56. self.radius = 84;
  57. if ( !isdefined( self.maxdist ) )
  58. self.maxdist = 1000;
  59. if ( !isdefined( self.angleoffset ) )
  60. self.angleoffset = [];
  61.  
  62. }
  63.  
  64. setup_painter_group( group )
  65. {
  66. density = 100000001;
  67. group_copy = group;
  68. // figure out default radius and density for the group
  69. bTreeOrient = undefined;
  70. bFacade = undefined;
  71. radius = undefined;
  72. maxdist = undefined;
  73. offsetheight = undefined;
  74. bPosedstyle = undefined;
  75. bOrienttoplayeryrot = undefined;
  76. angleoffset = undefined;
  77.  
  78.  
  79. foreach ( obj in group )
  80. {
  81. angleoffset = get_angle_offset( obj );
  82. offsetheight = get_height_offset( obj );
  83. modeluseprefab = ( isdefined( obj.script_parameters ) && obj.script_parameters == "use_prefab_model" );
  84.  
  85.  
  86. if ( isdefined( obj.radius ) )
  87. radius = obj.radius;
  88. if ( isdefined( obj.script_painter_treeorient ) && obj.script_painter_treeorient )
  89. bTreeOrient = true;
  90. if ( isdefined( obj.script_painter_maxdist ) && obj.script_painter_maxdist )
  91. maxdist = obj.script_painter_maxdist;
  92. if ( isdefined( obj.script_painter_facade ) && obj.script_painter_facade )
  93. bFacade = true;
  94. foreach ( other_obj in group_copy )
  95. {
  96. if ( obj == other_obj )
  97. continue;
  98. dist = distance( obj.origin, other_obj.origin );
  99. assert( dist > 0 );
  100. if ( dist < density )
  101. density = dist;
  102. }
  103. if ( density == 100000001 )
  104. density = undefined;
  105. add_spammodel( obj.script_paintergroup, obj.model, bTreeOrient, bFacade, density, radius, maxdist, offsetheight, bPosedstyle, bOrienttoplayeryrot, angleoffset, modeluseprefab );
  106. }
  107. }
  108.  
  109. get_angle_offset( obj )
  110. {
  111. if( !isdefined( obj.target ) )
  112. return undefined;
  113.  
  114. targent = getent( obj.target, "targetname" );
  115. assert( isdefined ( targent ) );
  116. return targent.angles - obj.angles;
  117. }
  118.  
  119. get_height_offset( obj )
  120. {
  121. if( !isdefined( obj.target ) )
  122. return undefined;
  123.  
  124. targent = getent( obj.target, "targetname" );
  125. assert( isdefined ( targent ) );
  126. origin = targent.origin[2] - obj.origin[2];
  127. targent delete();
  128. return origin;
  129. }
  130.  
  131.  
  132.  
  133.  
  134. get_painter_groups( painter_setup_array )
  135. {
  136. groups = [];
  137. script_paintergroup = "";
  138. foreach ( paint_obj in painter_setup_array )
  139. {
  140. if ( !isdefined( paint_obj.script_paintergroup ) )
  141. {
  142. paint_obj.script_paintergroup = paint_obj.model;
  143. }
  144. script_paintergroup = paint_obj.script_paintergroup;
  145.  
  146. level.painter_startgroup = script_paintergroup;
  147.  
  148. if ( !isdefined( groups[ script_paintergroup ] ) || ! groups[ script_paintergroup ].size )
  149. groups[ script_paintergroup ] = [];
  150. groups[ script_paintergroup ][ groups[ script_paintergroup ].size ] = paint_obj;
  151. }
  152. return groups;
  153. }
  154.  
  155. painter_initvars( painter_spmp )
  156. {
  157. level._clearalltextafterhudelem = false;
  158. level.bPosedstyle = false;
  159. level.bOrienttoplayeryrot = false;
  160. level.spam_density_scale = 16;
  161. level.spaming_models = false;
  162. level.spam_model_group = [];
  163. level.spamed_models = [];
  164. level.spam_models_flowrate = .1;
  165. level.spam_model_radius = 31;
  166. level.spam_maxdist = 1000;
  167. level.previewmodels = [];
  168. level.spam_models_isCustomrotation = false;
  169. level.spam_models_isCustomheight = false;
  170. level.spam_models_customheight = 0;
  171. level.spam_model_circlescale_lasttime = 0;
  172. level.spam_model_circlescale_accumtime = 0;
  173. level.paintadd = ::add_spammodel;
  174. // level.geteyeoffset = (0,0,24);
  175. level.timeLimitOverride = true;
  176. thread hack_start( painter_spmp );
  177. thread hud_init();
  178. }
  179.  
  180. hack_start( painter_spmp )
  181. {
  182. if ( !isdefined( painter_spmp ) )
  183. painter_spmp = "painter";
  184.  
  185. precachemenu( painter_spmp );
  186.  
  187. //who knows what the mp scripts are doing I took a dive deep into them and discovered many hud elements being controled through code and not through a menu that can be easily disabled
  188. // here I simply automate some things to get the user up and running.
  189. // get the player going. I don't handle people dieing in this tool since they are in ufo mode anyway.
  190.  
  191. flag_init( "user_alive" );
  192. while ( !isdefined( get_player() ) )
  193. wait .05;
  194. level.painter_player = get_player();
  195. wait .05;
  196. menu = "team_marinesopfor";
  197. response = "autoassign";
  198. level.painter_player notify( "menuresponse", menu, response );
  199. wait .05;
  200. menu = "changeclass_offline";
  201. response = "offline_class1_mp, 0";
  202. level.painter_player notify( "menuresponse", menu, response );
  203. level.painter_player openpopupmenu( painter_spmp );// painter.menu execs some console commands( ufo mode ).. sneaky hacks.
  204. wait .05;
  205. level.painter_player closepopupmenu();
  206. flag_set( "user_alive" );
  207. }
  208.  
  209. painter_init()
  210. {
  211. array_call( getentarray( "script_model", "classname" ), ::delete );
  212. setcurrentgroup( level.painter_startgroup );
  213. level.painter_startgroup = undefined;
  214. playerInit();
  215. }
  216.  
  217. hud_update_placed_model_count()
  218. {
  219. level.hud_controler[ "helppm" ].description setvalue( level.spamed_models.size );
  220. whitecap = 256;
  221. if ( level.spamed_models.size < whitecap )
  222. {
  223. level.hud_controler[ "helppm" ].description.color = ( 1, 1, 1 );
  224. return;
  225. }
  226.  
  227. r = 1;
  228. g = 1 - ( ( level.spamed_models.size - whitecap ) / whitecap );
  229. b = g;
  230.  
  231. level.hud_controler[ "helppm" ].description.color = ( r, g, b );
  232.  
  233. }
  234.  
  235. hud_init()
  236. {
  237. flag_init( "user_hud_active" );
  238. flag_wait( "user_alive" );
  239.  
  240. //shorter list for mp cause it's got too many g_configstring somesuch. There is probably better check than substr on the mapname. I don't think this will bite me though, knock on wood.
  241. listsize = 7;
  242. if ( is_mp() )
  243. listsize = 7;
  244.  
  245. hudelems = [];
  246. spacer = 15;
  247. div = int( listsize / 2 );
  248. org = 240 + div * spacer;
  249. alphainc = .5 / div;
  250. alpha = alphainc;
  251.  
  252. for ( i = 0;i < listsize;i++ )
  253. {
  254. hudelems[ i ] = _newhudelem();
  255. hudelems[ i ].location = 0;
  256. hudelems[ i ].alignX = "left";
  257. hudelems[ i ].alignY = "middle";
  258. hudelems[ i ].foreground = 1;
  259. hudelems[ i ].fontScale = 2;
  260. hudelems[ i ].sort = 20;
  261. if ( i == div )
  262. hudelems[ i ].alpha = 1;
  263. else
  264. hudelems[ i ].alpha = alpha;
  265.  
  266. hudelems[ i ].x = 20;
  267. hudelems[ i ].y = org;
  268. hudelems[ i ] _settext( "." );
  269.  
  270. if ( i == div )
  271. alphainc *= -1;
  272.  
  273. alpha += alphainc;
  274.  
  275. org -= spacer;
  276. }
  277.  
  278. level.spam_group_hudelems = hudelems;
  279.  
  280. crossHair = _newhudelem();
  281. crossHair.location = 0;
  282. crossHair.alignX = "center";
  283. crossHair.alignY = "bottom";
  284. crossHair.foreground = 1;
  285. crossHair.fontScale = 2;
  286. crossHair.sort = 20;
  287. crossHair.alpha = 1;
  288. crossHair.x = 320;
  289. crossHair.y = 244;
  290. crossHair _settext( "." );
  291. level.crosshair = crossHair;
  292.  
  293. // setup "crosshair"
  294. crossHair = _newhudelem();
  295. crossHair.location = 0;
  296. crossHair.alignX = "center";
  297. crossHair.alignY = "bottom";
  298. crossHair.foreground = 1;
  299. crossHair.fontScale = 2;
  300. crossHair.sort = 20;
  301. crossHair.alpha = 0;
  302. crossHair.x = 320;
  303. crossHair.y = 244;
  304. crossHair setvalue( 0 );
  305. level.crosshair_value = crossHair;
  306.  
  307. controler_hud_add( "helppm", 1, "^5Placed Models: ", undefined, level.spamed_models.size );
  308. controler_hud_add( "helpdensity", 2, "^5Spacing: ", undefined, level.spam_density_scale );
  309. controler_hud_add( "helpradius", 3, "^5Radius: ", undefined, level.spam_model_radius );
  310. controler_hud_add( "helpxy", 6, "^4X / ^3Y: ", undefined, level.spam_model_radius );
  311. controler_hud_add( "helpab", 7, "^2A / ^1B^7: ", " - " );
  312. controler_hud_add( "helplsrs", 8, "^8L^7 / R Stick: ", " - " );
  313. controler_hud_add( "helplbrb", 9, "^8L^7 / R Shoulder: ", " - " );
  314. controler_hud_add( "helpdpu", 10, "^8DPad U / ^7D: ", " - " );
  315. controler_hud_add( "helpdpl", 11, "^8DPad L / ^7R: ", " - " );
  316. controler_hud_add( "helpF", 17, "^8F: ^7( dump ) ^3map_source/" + level.script + "_modeldump.map", "" );
  317.  
  318. hint_buttons_main();
  319.  
  320. flag_set( "user_hud_active" );
  321. }
  322.  
  323. hint_buttons_main()
  324. {
  325. controler_hud_update_text( "helpxy", "^4Select Set Up ^7 / ^3Down" );
  326. controler_hud_update_text( "helpab", "^2Spacing Down ^7 / ^1up " );
  327. controler_hud_update_text( "helplsrs", "^8Radius Down ^7 / Up" );
  328. controler_hud_update_text( "helplbrb", "^8Remove ^7 / Place" );
  329. controler_hud_update_text( "helpdpl", "^8zOffset Clear ^7 / Set" );
  330. controler_hud_update_text( "helpdpu", "^8Rotation Clear ^7 / Set" );
  331. // controler_hud_update_text( "helpF", text );
  332.  
  333. }
  334.  
  335. hint_buttons_zoffset()
  336. {
  337. controler_hud_update_text( "helpxy", "^4 - ^7 / ^3 - " );
  338. controler_hud_update_text( "helpab", "^2Height Down ^7 / ^1Up " );
  339. controler_hud_update_text( "helplsrs", "^8 - ^7 / - " );
  340. controler_hud_update_text( "helplbrb", "^8 - ^7 / - " );
  341. controler_hud_update_text( "helpdpl", "^8 - ^7 / Set" );
  342. controler_hud_update_text( "helpdpu", "^8 - ^7 / - " );
  343. controler_hud_update_text( "helpF", " - " );
  344. }
  345.  
  346. hint_buttons_rotation()
  347. {
  348. controler_hud_update_text( "helpxy", "^4 - ^7 / ^3 - " );
  349. controler_hud_update_text( "helpab", "^2RotateOther Up ^7 / ^1Down " );
  350. controler_hud_update_text( "helplsrs", "^8 - ^7 / - " );
  351. controler_hud_update_text( "helplbrb", "^8 - ^7 / - " );
  352. controler_hud_update_text( "helpdpl", "^8 - ^7 / - " );
  353. controler_hud_update_text( "helpdpu", "^8Set ^7 / - " );
  354. controler_hud_update_text( "helpF", " - " );
  355. }
  356.  
  357. setcurrentgroup( group )
  358. {
  359. flag_wait( "user_hud_active" );
  360. level.spam_model_current_group = group;
  361. keys = getarraykeys( level.spam_model_group );
  362. index = 0;
  363. div = int( level.spam_group_hudelems.size / 2 );
  364. for ( i = 0;i < keys.size;i++ )
  365. if ( keys[ i ] == group )
  366. {
  367. index = i;
  368. break;
  369. }
  370.  
  371. level.spam_group_hudelems[ div ] _settext( keys[ index ] );
  372.  
  373. for ( i = 1;i < level.spam_group_hudelems.size - div;i++ )
  374. {
  375. if ( index - i < 0 )
  376. {
  377. level.spam_group_hudelems[ div + i ] _settext( "." );
  378. continue;
  379. }
  380. level.spam_group_hudelems[ div + i ] _settext( keys[ index - i ] );
  381. }
  382.  
  383. for ( i = 1;i < level.spam_group_hudelems.size - div;i++ )
  384. {
  385. if ( index + i > keys.size - 1 )
  386. {
  387. // -- --
  388. level.spam_group_hudelems[ div - i ] _settext( "." );
  389. continue;
  390. }
  391. level.spam_group_hudelems[ div - i ] _settext( keys[ index + i ] );
  392. }
  393.  
  394. group = getcurrent_groupstruct();
  395.  
  396. level.bOrienttoplayeryrot = group.bOrienttoplayeryrot;
  397. level.bPosedstyle = group.bPosedstyle;
  398. level.spam_maxdist = group.maxdist;
  399. level.spam_model_radius = group.radius;
  400. level.hud_controler[ "helpradius" ].description setvalue( level.spam_model_radius );
  401.  
  402. level.spam_density_scale = group.density;
  403. level.hud_controler[ "helpdensity" ].description setvalue( level.spam_density_scale );
  404. }
  405.  
  406.  
  407. setgroup_up()
  408. {
  409. index = undefined;
  410. keys = getarraykeys( level.spam_model_group );
  411. for ( i = 0;i < keys.size;i++ )
  412. if ( keys[ i ] == level.spam_model_current_group )
  413. {
  414. index = i + 1;
  415. break;
  416. }
  417. if ( index == keys.size )
  418. return;
  419. setcurrentgroup( keys[ index ] );
  420. while ( level.painter_player buttonpressed( "BUTTON_Y" ) )
  421. wait .05;
  422. }
  423.  
  424. setgroup_down()
  425. {
  426. index = undefined;
  427. keys = getarraykeys( level.spam_model_group );
  428. for ( i = 0;i < keys.size;i++ )
  429. if ( keys[ i ] == level.spam_model_current_group )
  430. {
  431. index = i - 1;
  432. break;
  433. }
  434. if ( index < 0 )
  435. return;
  436. setcurrentgroup( keys[ index ] );
  437. while ( level.painter_player buttonpressed( "BUTTON_X" ) )
  438. wait .05;
  439. }
  440.  
  441. Add_Spammodel( group, model, bTreeOrient, bFacade, density, radius, maxdist, offsetheight, bPosedstyle, bOrienttoplayeryrot, angleoffset, modelusesprefab )
  442. {
  443. if ( !isdefined( level.spam_model_group[ group ] ) )
  444. {
  445. struct = spawnstruct();
  446. level.spam_model_group[ group ] = struct;
  447. level.spam_model_group[ group ].models = [];
  448. }
  449.  
  450. if( !isdefined( angleoffset ) )
  451. angleoffset = (0,0,0);
  452.  
  453. level.spam_model_group[ group ].bFacade = bFacade;
  454. level.spam_model_group[ group ].bTreeOrient = bTreeOrient;
  455. level.spam_model_group[ group ].density = density;
  456. level.spam_model_group[ group ].radius = radius;
  457. level.spam_model_group[ group ].maxdist = maxdist;
  458. level.spam_model_group[ group ].bPosedstyle = bPosedstyle;
  459. level.spam_model_group[ group ].bOrienttoplayeryrot = bOrienttoplayeryrot;
  460.  
  461. if( !isdefined( level.spam_model_group[ group ].angleoffset ) )
  462. level.spam_model_group[ group ].angleoffset = [];
  463. level.spam_model_group[ group ].angleoffset[ model ] = angleoffset;
  464.  
  465. if( !isdefined( level.spam_model_group[ group ].heightoffset ) )
  466. level.spam_model_group[ group ].heightoffset = [];
  467. level.spam_model_group[ group ].heightoffset[ model ] = offsetheight;
  468.  
  469. if( !isdefined( level.spam_model_group[ group ].modelusesprefab ) )
  470. level.spam_model_group[ group ].modelusesprefab = [];
  471. level.spam_model_group[ group ].modelusesprefab[ model ] = modelusesprefab;
  472.  
  473. level.spam_model_group[ group ].models[ level.spam_model_group[ group ].models.size ] = model;
  474. }
  475.  
  476.  
  477. playerInit()
  478. {
  479. level.painter_max = 700;
  480. level.painter_player takeAllWeapons();
  481.  
  482. flag_wait( "user_hud_active" );
  483. while ( 1 )
  484. {
  485. trace = player_view_trace();
  486. draw_placement_circle( trace );
  487. if ( level.painter_player buttonpressed( "f" ) )
  488. dump_models();
  489. if ( level.painter_player buttonpressed( "DPAD_UP" ) )
  490. customrotation_mode( trace, "DPAD_UP" );
  491. else if ( level.painter_player buttonpressed( "DPAD_DOWN" ) )
  492. customrotation_mode_off();
  493. else if ( level.painter_player buttonpressed( "DPAD_RIGHT" ) )
  494. customheight_mode( trace, "DPAD_RIGHT" );
  495. else if ( level.painter_player buttonpressed( "DPAD_LEFT" ) )
  496. customheight_mode_off();
  497. else if ( level.painter_player buttonpressed( "BUTTON_X" ) )
  498. setgroup_down();
  499. else if ( level.painter_player buttonpressed( "BUTTON_Y" ) )
  500. setgroup_up();
  501. else if ( level.painter_player buttonpressed( "BUTTON_LSTICK" ) )
  502. spam_model_circlescale( trace, -1 );
  503. else if ( level.painter_player buttonpressed( "BUTTON_RSTICK" ) )
  504. spam_model_circlescale( trace, 1 );
  505. else if ( level.painter_player buttonpressed( "BUTTON_A" ) )
  506. spam_model_densityscale( trace, -1 );
  507. else if ( level.painter_player buttonpressed( "BUTTON_B" ) )
  508. spam_model_densityscale( trace, 1 );
  509. else
  510. {
  511. if ( level.painter_player buttonpressed( "BUTTON_LSHLDR" ) )
  512. spam_model_erase( trace );
  513. if ( level.painter_player buttonpressed( "BUTTON_RSHLDR" ) )
  514. thread spam_model_place( trace );// threaded for delay
  515. }
  516. level notify( "clear_previews" );
  517. wait .05;
  518. hud_update_placed_model_count();
  519. }
  520. }
  521.  
  522. customheight_mode_off()
  523. {
  524. level.spam_models_isCustomheight = false;
  525. hint_buttons_main();
  526. }
  527.  
  528. customheight_mode( trace, button )
  529. {
  530. if ( trace[ "fraction" ] == 1 )
  531. return;
  532.  
  533. while ( level.painter_player buttonpressed( button ) )
  534. wait .05;
  535.  
  536. level.spam_models_isCustomheight = true;
  537. hint_buttons_zoffset();
  538. models = [];
  539. models = spam_models_atcircle( trace, false, true );
  540.  
  541. inc = 2;
  542. dir = 1;
  543.  
  544. origin = trace[ "position" ];
  545. while ( !level.painter_player buttonpressed( button ) )
  546. {
  547. height = level.spam_models_customheight;
  548. if ( level.painter_player buttonpressed( "BUTTON_A" ) )
  549. dir = -1;
  550. else if ( level.painter_player buttonpressed( "BUTTON_B" ) )
  551. dir = 1;
  552. else
  553. dir = 0;
  554. height += dir * inc;
  555. if ( height == 0 )
  556. height += dir * inc;
  557. level.spam_models_customheight = height;
  558.  
  559. array_thread( models, ::customheight_mode_offsetmodels, trace );
  560. draw_placement_circle( trace, ( 1, 1, 1 ) );
  561.  
  562. wait .05;
  563. }
  564. array_thread( models, ::deleteme );
  565. hint_buttons_main();
  566. while ( level.painter_player buttonpressed( button ) )
  567. wait .05;
  568. }
  569.  
  570. customheight_mode_offsetmodels( trace )
  571. {
  572. self.origin = self.orgorg + ( trace[ "normal" ] * level.spam_models_customheight );
  573. }
  574.  
  575. customrotation_mode_off()
  576. {
  577. level.spam_models_isCustomrotation = false;
  578. hint_buttons_main();
  579. }
  580.  
  581. customrotation_mode( trace, button )
  582. {
  583. if ( trace[ "fraction" ] == 1 )
  584. return;
  585.  
  586. while ( level.painter_player buttonpressed( button ) )
  587. wait .05;
  588.  
  589. hint_buttons_rotation();
  590.  
  591. level.spam_models_isCustomrotation = true;
  592. level.spam_models_customrotation = level.painter_player getplayerangles();
  593. models = [];
  594. models = spam_models_atcircle( trace, true, true );
  595.  
  596. otherangle = 0;
  597. otherangleinc = 1;
  598. dir = 0;
  599.  
  600. while ( !level.painter_player buttonpressed( button ) )
  601. {
  602. dir = 0;
  603. if ( level.painter_player buttonpressed( "BUTTON_A" ) )
  604. dir = -1;
  605. else if ( level.painter_player buttonpressed( "BUTTON_B" ) )
  606. dir = 1;
  607. otherangle += dir * otherangleinc;
  608. if ( otherangle > 360 )
  609. otherangle = 1;
  610. if ( otherangle < 0 )
  611. otherangle = 359;
  612. draw_placement_circle( trace, ( 0, 0, 1 ) );
  613. level.spam_models_customrotation = level.painter_player getplayerangles();
  614. level.spam_models_customrotation += ( 0, 0, otherangle );
  615. for ( i = 0;i < models.size;i++ )
  616. models[ i ].angles = level.spam_models_customrotation;
  617. wait .05;
  618. }
  619.  
  620. hint_buttons_main();
  621.  
  622. while ( level.painter_player buttonpressed( button ) )
  623. wait .05;
  624.  
  625. for ( i = 0;i < models.size;i++ )
  626. models[ i ] thread deleteme();
  627.  
  628. }
  629.  
  630. deleteme()
  631. {
  632. self delete();
  633. }
  634.  
  635. spam_model_clearcondition()
  636. {
  637. self endon( "death" );
  638. level waittill( "clear_previews" );
  639. level.previewmodels = array_remove( level.previewmodels, self );
  640. self delete();
  641. }
  642.  
  643. crosshair_fadetopoint()
  644. {
  645. level notify( "crosshair_fadetopoint" );
  646. level endon( "crosshair_fadetopoint" );
  647. wait 2;
  648. level.crosshair_value.alpha = 0;
  649. level.crosshair.alpha = 1;
  650. }
  651.  
  652. spam_model_circlescale( trace, dir )
  653. {
  654. if ( gettime() - level.spam_model_circlescale_lasttime > 60 )
  655. level.spam_model_circlescale_accumtime = 0;
  656.  
  657. level.spam_model_circlescale_accumtime += .05;
  658.  
  659. if ( level.spam_model_circlescale_accumtime < .5 )
  660. inc = 2;
  661. else
  662. inc = level.spam_model_circlescale_accumtime / .3;
  663.  
  664. radius = level.spam_model_radius;
  665. radius += dir * inc;
  666. if ( radius > 0 )
  667. level.spam_model_radius = radius;
  668.  
  669. level.hud_controler[ "helpradius" ].description setvalue( level.spam_model_radius );
  670.  
  671. level.spam_model_circlescale_lasttime = gettime();
  672. }
  673.  
  674. spam_model_densityscale( trace, dir )
  675. {
  676. // ghetto hack here. density scale used for distance on floating model types
  677. inc = 2;
  678. scale = level.spam_density_scale;
  679. scale += dir * inc;
  680. if ( scale > 0 )
  681. level.spam_density_scale = scale;
  682.  
  683.  
  684. level.crosshair_value.alpha = 1;
  685. level.crosshair.alpha = 0;
  686.  
  687. level.crosshair_value setvalue( level.spam_density_scale );
  688. level.hud_controler[ "helpdensity" ].description setvalue( level.spam_density_scale );
  689.  
  690. thread crosshair_fadetopoint();
  691. }
  692.  
  693. draw_placement_circle( trace, coloroverride )
  694. {
  695. if ( !isdefined( coloroverride ) )
  696. coloroverride = ( 0, 1, 0 );
  697. if ( trace[ "fraction" ] == 1 )
  698. return;
  699. // angles = vectortoangles( anglestoup( vectortoangles( trace[ "normal" ] ) ) );
  700. angles = vectortoangles( trace[ "normal" ] );
  701. origin = trace[ "position" ];
  702. radius = level.spam_model_radius;
  703. // plot_circle( origin, radius, angles, color, circleres );
  704. plot_circle( origin, radius, angles, coloroverride, 40, level.spam_model_radius );
  705.  
  706. if ( level.spam_models_isCustomrotation )
  707. draw_axis( origin, level.spam_models_customrotation );
  708. if ( level.spam_models_isCustomheight )
  709. draw_arrow( origin, origin + ( trace[ "normal" ] * level.spam_models_customheight ), ( 1, 1, 1 ) );
  710. }
  711.  
  712. player_view_trace()
  713. {
  714. maxdist = level.spam_maxdist;
  715. traceorg = level.painter_player geteye();
  716. return bullettrace( traceorg, traceorg + ( anglestoforward( level.painter_player getplayerangles() ) * maxdist ), 0, self );
  717. }
  718.  
  719. Orienttoplayeryrot()
  720. {
  721. self addyaw( level.painter_player getplayerangles()[ 1 ] - flat_angle( self.angles )[ 1 ] );
  722. // self.angles = ( x, y, z );
  723. }
  724.  
  725. getcurrent_groupstruct()
  726. {
  727. return level.spam_model_group[ level.spam_model_current_group ];
  728. }
  729.  
  730. orient_model()
  731. {
  732. group = getcurrent_groupstruct();
  733.  
  734. if ( level.spam_models_isCustomrotation )
  735. {
  736. self.angles = level.spam_models_customrotation;
  737. return;
  738. }
  739.  
  740. if ( level.bPosedstyle )
  741. self.angles = level.painter_player getplayerangles();
  742.  
  743. if ( level.bOrienttoplayeryrot )
  744. self Orienttoplayeryrot();
  745.  
  746. if ( group.bTreeOrient )
  747. self.angles = flat_angle( self.angles );
  748.  
  749. if ( ! level.bOrienttoplayeryrot && !level.bPosedstyle )
  750. self addyaw( randomint( 360 ) );
  751.  
  752. if ( group.bFacade )
  753. {
  754. self.angles = flat_angle( vectortoangles( self.origin - level.painter_player geteye() ) );
  755. self addyaw( 90 );
  756.  
  757. }
  758.  
  759. assert( isdefined( group.angleoffset ) && isdefined( group.angleoffset[ self.model] ) );
  760.  
  761. self addroll( group.angleoffset[self.model][ 0 ] );
  762. self addpitch( group.angleoffset[self.model][ 1 ] );
  763. self addyaw( group.angleoffset[self.model][ 2 ] );
  764.  
  765.  
  766.  
  767. }
  768.  
  769. spam_model_place( trace )
  770. {
  771. if ( level.spaming_models )
  772. return;
  773. if ( trace[ "fraction" ] == 1 && !level.bPosedstyle )
  774. return;
  775. level.spaming_models = true;
  776. models = spam_models_atcircle( trace, true );
  777. level.spamed_models = array_combine( level.spamed_models, models );
  778. level.spaming_models = false;
  779. }
  780.  
  781. getrandom_spammodel()
  782. {
  783. models = level.spam_model_group[ level.spam_model_current_group ].models;
  784. return models[ randomint( models.size ) ];
  785. }
  786.  
  787. spam_models_atcircle( trace, bRandomrotation, bForcedSpam )
  788. {
  789. if ( !isdefined( bForcedSpam ) )
  790. bForcedSpam = false;
  791. models = [];
  792. incdistance = level.spam_density_scale;
  793. radius = level.spam_model_radius;
  794. incs = int( radius / incdistance ) * 2;
  795. startpoint = 0;
  796. traceorg = trace[ "position" ];
  797. angles = vectortoangles( trace[ "normal" ] );
  798. if ( bRandomrotation )
  799. angles += ( 0, randomfloat( 360 ), 0 );
  800. xvect = vectornormalize( anglestoright( angles ) );
  801. yvect = vectornormalize( anglestoup( angles ) );
  802. startpos = traceorg;
  803. startpos -= ( xvect * radius );
  804. startpos -= ( yvect * radius );
  805. startpos += ( xvect * incdistance );
  806. startpos += ( yvect * incdistance );
  807.  
  808. modelpos = startpos;
  809. // special for when circle is too small for current density to place anything. Just place one in the center..
  810. if ( incs == 0 || level.bPosedstyle )
  811. {
  812. if ( !bForcedSpam )
  813. if ( is_too_dense( traceorg ) )
  814. return models;
  815. if ( !bForcedSpam )
  816. if ( level.spamed_models.size + models.size > level.painter_max )
  817. return models;
  818.  
  819. getmodel = getrandom_spammodel();
  820. models[ 0 ] = spam_modelattrace( trace, getmodel );
  821. models[ 0 ] orient_model();
  822.  
  823. return models;
  824. }
  825.  
  826. countourtrace = [];
  827. for ( x = startpoint;x < incs;x++ )
  828. for ( y = startpoint;y < incs;y++ )
  829. {
  830. if ( !bForcedSpam )
  831. if ( level.spamed_models.size + models.size > level.painter_max )
  832. return models;;
  833. modelpos = startpos;
  834. modelpos += ( xvect * x * incdistance );
  835. modelpos += ( yvect * y * incdistance );
  836. if ( distance( modelpos, traceorg ) > radius )
  837. continue;
  838. // if ( !bForcedSpam )
  839. countourtrace = contour_point( modelpos, angles, level.spam_model_radius );
  840.  
  841. if ( countourtrace[ "fraction" ] == 1 )
  842. continue;
  843. if ( is_too_dense( countourtrace[ "position" ] ) )
  844. continue;
  845. getmodel = getrandom_spammodel();
  846.  
  847. model = spam_modelattrace( countourtrace, getmodel );
  848. model orient_model();
  849. models[ models.size ] = model;
  850.  
  851. }
  852. return models;
  853. }
  854.  
  855. is_too_dense( testorg )
  856. {
  857. // going backwards will be faster
  858. for ( i = level.spamed_models.size - 1; i >= 0; i -- )
  859. if ( distance( level.spamed_models[ i ].orgorg, testorg ) < ( level.spam_density_scale - 1 ) )
  860. return true;
  861. return false;
  862. }
  863.  
  864. get_player()
  865. {
  866. return getentarray( "player", "classname" )[ 0 ];
  867. }
  868.  
  869. spam_modelattrace( trace, getmodel )
  870. {
  871. model = spawn( "script_model", level.painter_player.origin );
  872. model setmodel( getmodel );
  873. model notsolid();
  874. model.origin = trace[ "position" ];
  875. model.angles = vectortoangles( trace[ "normal" ] );
  876. model addpitch( 90 );
  877. model.orgorg = model.origin;
  878. group = getcurrent_groupstruct();
  879. if ( level.spam_models_isCustomheight )
  880. model.origin += ( trace[ "normal" ] * level.spam_models_Customheight );
  881.  
  882. group = getcurrent_groupstruct();
  883. if( isdefined( group.heightoffset[ getmodel ] ) )
  884. model.origin += ( trace[ "normal" ] * group.heightoffset[ getmodel ] );
  885. if( isdefined( group.modelusesprefab[ getmodel ] ) )
  886. model.modelusesprefab = group.modelusesprefab[ getmodel ];
  887.  
  888. return model;
  889. }
  890.  
  891. contour_point( origin, angles, height )
  892. {
  893. offset = height;
  894. vect = anglestoforward( angles );
  895. destorg = origin + ( vect * offset );
  896. targetorg = origin + ( vect * - 1 * offset );
  897. return bullettrace( destorg, targetorg, 0, level.painter_player );
  898. }
  899.  
  900. plot_circle( origin, radius, angles, color, circleres, contourdepth )
  901. {
  902. if ( !isdefined( color ) )
  903. color = ( 0, 1, 0 );
  904. if ( !isdefined( circleres ) )
  905. circleres = 16;
  906. hemires = circleres / 2;
  907. circleinc = 360 / circleres;
  908. circleres++ ;
  909. plotpoints = [];
  910. rad = 0;
  911. plotpoints = [];
  912. rad = 0.000;
  913. for ( i = 0;i < circleres;i++ )
  914. {
  915. baseorg = origin + ( anglestoup( ( angles + ( 0, 0, rad ) ) ) * radius );
  916. point = contour_point( baseorg, angles, level.spam_model_radius );
  917. if ( point[ "fraction" ] != 1 )
  918. plotpoints[ plotpoints.size ] = point[ "position" ];
  919. rad += circleinc;
  920. }
  921. plot_points( plotpoints, color[ 0 ], color[ 1 ], color[ 2 ] );
  922. plotpoints = [];
  923. }
  924.  
  925. spam_model_erase( trace )
  926. {
  927. traceorg = trace[ "position" ];
  928. keepmodels = [];
  929. deletemodels = [];
  930. for ( i = 0;i < level.spamed_models.size;i++ )
  931. {
  932. if ( distance( level.spamed_models[ i ].orgorg, traceorg ) > level.spam_model_radius )
  933. keepmodels[ keepmodels.size ] = level.spamed_models[ i ];
  934. else
  935. deletemodels[ deletemodels.size ] = level.spamed_models[ i ];
  936. }
  937. level.spamed_models = keepmodels;
  938.  
  939. for ( i = 0;i < deletemodels.size;i++ )
  940. deletemodels[ i ] delete();
  941. }
  942.  
  943. dump_models()
  944. {
  945. /#
  946. if ( ! level.spamed_models.size )
  947. return;
  948. fileprint_launcher_start_file();
  949. fileprint_map_start();
  950. for ( i = 0;i < level.spamed_models.size;i++ )
  951. {
  952. origin = fileprint_radiant_vec( level.spamed_models[ i ].origin );// convert these vectors to mapfile keypair format
  953. angles = fileprint_radiant_vec( level.spamed_models[ i ].angles );
  954.  
  955. fileprint_map_entity_start();
  956. if( isdefined ( level.spamed_models[ i ].modelusesprefab ) && level.spamed_models[ i ].modelusesprefab )
  957. {
  958. fileprint_map_keypairprint( "classname", "misc_prefab" );
  959. fileprint_map_keypairprint( "model", "prefabs/misc_models/" + level.spamed_models[ i ].model + ".map" );
  960. }
  961. else
  962. {
  963. fileprint_map_keypairprint( "classname", "misc_model" );
  964. fileprint_map_keypairprint( "model", level.spamed_models[ i ].model );
  965. }
  966. fileprint_map_keypairprint( "origin", origin );
  967. fileprint_map_keypairprint( "angles", angles );
  968. fileprint_map_keypairprint( "spammed_model", level.spam_model_current_group );
  969. fileprint_map_entity_end();
  970. }
  971. map_path = level.script+"_modeldump.map";
  972. if( !fileprint_launcher_end_file( "/map_source/"+map_path,false ) )
  973. return;
  974. launcher_write_clipboard( map_path );
  975. array_thread( level.spamed_models, ::deleteme );
  976. level.spamed_models = [];
  977. #/
  978. }
  979.  
  980. draw_axis( org, angles )
  981. {
  982. range = 32;
  983. forward = range * anglestoforward( angles );
  984. right = range * anglestoright( angles );
  985. up = range * anglestoup( angles );
  986. line( org, org + forward, ( 1, 0, 0 ), 1 );
  987. line( org, org + up, ( 0, 1, 0 ), 1 );
  988. line( org, org + right, ( 0, 0, 1 ), 1 );
  989. }
  990.  
  991. _newhudelem()
  992. {
  993. if ( !isdefined( level.scripted_elems ) )
  994. level.scripted_elems = [];
  995. elem = newhudelem();
  996. level.scripted_elems[ level.scripted_elems.size ] = elem;
  997. return elem;
  998. }
  999.  
  1000. _settext( text )
  1001. {
  1002. self.realtext = text;
  1003. self settext( "_" );
  1004. self thread _clearalltextafterhudelem();
  1005. sizeofelems = 0;
  1006. foreach ( elem in level.scripted_elems )
  1007. {
  1008. if ( isdefined( elem.realtext ) )
  1009. {
  1010. sizeofelems += elem.realtext.size;
  1011. elem settext( elem.realtext );
  1012. }
  1013. }
  1014. println( "SIze of elems: " + sizeofelems );
  1015. }
  1016.  
  1017. controler_hud_add( identifier, inc, initial_text, initial_description_text, initial_value )
  1018. {
  1019. startx = 520;
  1020. if ( is_mp() )
  1021. startx = 630;
  1022. starty = 120;
  1023. space = 18;
  1024. basealpha = .8;
  1025. denradoffset = 20;
  1026. descriptionscale = 1.4;
  1027. if ( !isdefined( initial_text ) )
  1028. initial_text = "";
  1029.  
  1030. if ( !isdefined( level.hud_controler ) || !isdefined( level.hud_controler[ identifier ] ) )
  1031. {
  1032. level.hud_controler[ identifier ] = _newhudelem();
  1033. description = _newhudelem();
  1034. }
  1035. else
  1036. description = level.hud_controler[ identifier ].description;
  1037.  
  1038. level.hud_controler[ identifier ].location = 0;
  1039. level.hud_controler[ identifier ].alignX = "right";
  1040. level.hud_controler[ identifier ].alignY = "middle";
  1041. level.hud_controler[ identifier ].foreground = 1;
  1042. level.hud_controler[ identifier ].fontscale = 1.5;
  1043. level.hud_controler[ identifier ].sort = 20;
  1044. level.hud_controler[ identifier ].alpha = basealpha;
  1045. level.hud_controler[ identifier ].x = startx + denradoffset;
  1046. level.hud_controler[ identifier ].y = starty + ( inc * space );
  1047. level.hud_controler[ identifier ] _settext( initial_text );
  1048. level.hud_controler[ identifier ].base_button_text = initial_text;
  1049.  
  1050. description.location = 0;
  1051. description.alignX = "left";
  1052. description.alignY = "middle";
  1053. description.foreground = 1;
  1054. description.fontscale = descriptionscale;
  1055. description.sort = 20;
  1056. description.alpha = basealpha;
  1057. description.x = startx + denradoffset;
  1058. description.y = starty + ( inc * space );
  1059. if ( isdefined( initial_value ) )
  1060. description setvalue( initial_value );
  1061. if ( isdefined( initial_description_text ) )
  1062. description _settext( initial_description_text );
  1063. level.hud_controler[ identifier ].description = description;
  1064. }
  1065.  
  1066. controler_hud_update_text( hudid, text )
  1067. {
  1068. if ( is_mp() )
  1069. {
  1070. level.hud_controler[ hudid ] _settext( level.hud_controler[ hudid ].base_button_text + text );
  1071. level.hud_controler[ hudid ].description _settext( "" );
  1072. }
  1073. else
  1074. level.hud_controler[ hudid ].description _settext( text );
  1075.  
  1076.  
  1077.  
  1078. }
  1079.  
  1080. controler_hud_update_button( hudid, text )
  1081. {
  1082. level.hud_controler[ hudid ] _settext( text );
  1083. }
  1084.  
  1085.  
  1086. _clearalltextafterhudelem()
  1087. {
  1088. if ( level._clearalltextafterhudelem )
  1089. return;
  1090. level._clearalltextafterhudelem = true;
  1091. self clearalltextafterhudelem();
  1092. wait .05;
  1093. level._clearalltextafterhudelem = false;
  1094.  
  1095. }
  1096.  
  1097. is_mp()
  1098. {
  1099. return issubstr( level.script, "mp_" );
  1100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement