Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include common_scripts\_destructible;
  3.  
  4. main()
  5. {
  6. /#
  7. level.created_destructibles = [];
  8. #/
  9.  
  10. if ( !isdefined( level.func ) )
  11. {
  12. // this array will be filled with code commands that SP or MP may use but doesn't exist in the other.
  13. level.func = [];
  14. }
  15.  
  16. //---------------------------------------------------------------------
  17. // Find all new DLC destructibles by their targetnames and run the setup
  18. //---------------------------------------------------------------------
  19.  
  20. // array_thread( GetEntArray( "destructible_vehicle", "targetname" ), ::setup_destructibles );
  21.  
  22. //assuring orders -nate
  23. vehicles = GetEntArray( "destructible_vehicle", "targetname" );
  24. foreach ( vehicle in vehicles )
  25. vehicle setup_destructibles_dlc();
  26.  
  27. destructible_toy = GetEntArray( "destructible_toy", "targetname" );
  28. foreach ( toy in destructible_toy )
  29. toy setup_destructibles_dlc();
  30.  
  31. /#
  32. total = 0;
  33. if ( GetDvarInt( "destructibles_locate" ) > 0 )
  34. {
  35. // Print out the destructibles we created and where they are all located
  36. PrintLn( "##################" );
  37. PrintLn( "DESTRUCTIBLE LIST:" );
  38. PrintLn( "##################" );
  39. PrintLn( "" );
  40.  
  41. keys = GetArrayKeys( level.created_destructibles );
  42. foreach ( key in keys )
  43. {
  44. PrintLn( key + ": " + level.created_destructibles[ key ].size );
  45. total += level.created_destructibles[ key ].size;
  46. }
  47. PrintLn( "" );
  48. PrintLn( "Total: " + total );
  49. PrintLn( "" );
  50. PrintLn( "Locations:" );
  51.  
  52. foreach ( key in keys )
  53. {
  54. foreach ( destructible in level.created_destructibles[ key ] )
  55. {
  56. PrintLn( key + ": " + destructible.origin );
  57. //destructible thread maps\_debug::drawOrgForever();
  58. }
  59. }
  60.  
  61. PrintLn( "" );
  62. PrintLn( "##################" );
  63. PrintLn( "##################" );
  64. PrintLn( "##################" );
  65.  
  66. level.created_destructibles = undefined;
  67. }
  68. #/
  69.  
  70. }
  71.  
  72.  
  73. setup_destructibles_dlc( cached )
  74. {
  75. if ( !isdefined( cached ) )
  76. cached = false;
  77.  
  78. //---------------------------------------------------------------------
  79. // Figure out what destructible information this entity should use
  80. //---------------------------------------------------------------------
  81. destuctableInfo = undefined;
  82. AssertEx( IsDefined( self.destructible_type ), "Destructible object with targetname 'destructible' does not have a 'destructible_type' key / value" );
  83.  
  84. self.modeldummyon = false;// - nate added for vehicle dummy stuff. This is so I can turn a destructible into a dummy and throw it around on jeepride.
  85. self add_damage_owner_recorder(); // Mackey added to track who is damaging the car
  86.  
  87. self.destuctableInfo = common_scripts\_destructible_types_dlc::makeType_dlc( self.destructible_type );
  88.  
  89. if ( !isdefined( self.destuctableInfo ) )
  90. {
  91. // must be old destructible
  92. return;
  93. }
  94.  
  95. //println( "### DESTRUCTIBLE ### assigned infotype index: " + self.destuctableInfo );
  96. if ( self.destuctableInfo < 0 )
  97. return;
  98.  
  99. // change the targetname so the real _destructible script doesn't try to process the new destructibles
  100. self.targetname = self.targetname + "_dlc";
  101.  
  102. /#
  103. // Store what destructibles we create and where they are located so we can get a list in the console
  104. if ( !isdefined( level.created_destructibles[ self.destructible_type ] ) )
  105. level.created_destructibles[ self.destructible_type ] = [];
  106. nextIndex = level.created_destructibles[ self.destructible_type ].size;
  107. level.created_destructibles[ self.destructible_type ][ nextIndex ] = self;
  108. #/
  109.  
  110. if ( !cached )
  111. precache_destructibles();
  112.  
  113. add_destructible_fx();
  114.  
  115. //---------------------------------------------------------------------
  116. // Attach all parts to the entity
  117. //---------------------------------------------------------------------
  118. if ( IsDefined( level.destructible_type[ self.destuctableInfo ].parts ) )
  119. {
  120. self.destructible_parts = [];
  121. for ( i = 0; i < level.destructible_type[ self.destuctableInfo ].parts.size; i++ )
  122. {
  123. // create the struct where the info for each entity will be held
  124. self.destructible_parts[ i ] = SpawnStruct();
  125.  
  126. // set it's current state to 0 since it has never taken damage yet and will be on it's first state
  127. self.destructible_parts[ i ].v[ "currentState" ] = 0;
  128.  
  129. // if it has a health value then store it's value
  130. if ( IsDefined( level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "health" ] ) )
  131. self.destructible_parts[ i ].v[ "health" ] = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "health" ];
  132.  
  133. // find random attachements such as random advertisements on taxi cabs and attach them now
  134. if ( IsDefined( level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "random_dynamic_attachment_1" ] ) )
  135. {
  136. randAttachmentIndex = RandomInt( level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "random_dynamic_attachment_1" ].size );
  137. attachTag = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "random_dynamic_attachment_tag" ][ randAttachmentIndex ];
  138. attach_model_1 = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "random_dynamic_attachment_1" ][ randAttachmentIndex ];
  139. attach_model_2 = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "random_dynamic_attachment_2" ][ randAttachmentIndex ];
  140. clipToRemove = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "clipToRemove" ][ randAttachmentIndex ];
  141. self thread do_random_dynamic_attachment( attachTag, attach_model_1, attach_model_2, clipToRemove );
  142. }
  143.  
  144. // continue if it's the base model since its not an attached part
  145. if ( i == 0 )
  146. continue;
  147.  
  148. // attach the part now
  149. modelName = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "modelName" ];
  150. tagName = level.destructible_type[ self.destuctableInfo ].parts[ i ][ 0 ].v[ "tagName" ];
  151.  
  152. stateIndex = 1;
  153. while ( IsDefined( level.destructible_type[ self.destuctableInfo ].parts[ i ][ stateIndex ] ) )
  154. {
  155. stateTagName = level.destructible_type[ self.destuctableInfo ].parts[ i ][ stateIndex ].v[ "tagName" ];
  156. stateModelName = level.destructible_type[ self.destuctableInfo ].parts[ i ][ stateIndex ].v[ "modelName" ];
  157. if ( IsDefined( stateTagName ) && stateTagName != tagName )
  158. {
  159. self hideapart( stateTagName );
  160. if ( self.modeldummyon )
  161. self.modeldummy hideapart( stateTagName );
  162. }
  163. stateIndex++;
  164. }
  165. }
  166. }
  167.  
  168. // some destructibles have collision that needs to change due to the large change in the destructible when it blows pu
  169. if ( IsDefined( self.target ) )
  170. thread destructible_handles_collision_brushes();
  171.  
  172. //---------------------------------------------------------------------
  173. // Make this entity take damage and wait for events
  174. //---------------------------------------------------------------------
  175. if ( self.code_classname != "script_vehicle" )
  176. self SetCanDamage( true );
  177. if ( isSP() )
  178. self thread connectTraverses();
  179. self thread destructible_think();
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement