Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #include common_scripts\utility;
  2.  
  3. #using_animtree( "animated_props" );
  4. main()
  5. {
  6. level.init_animatedmodels_dump = false;
  7.  
  8. if ( !isdefined( level.anim_prop_models ) )
  9. level.anim_prop_models = []; // this is what the LD puts in their map
  10.  
  11. // Do special MP anim precaching
  12. model_keys = GetArrayKeys( level.anim_prop_models );
  13. foreach ( model_key in model_keys )
  14. {
  15. anim_keys = GetArrayKeys( level.anim_prop_models[model_key] );
  16. foreach ( anim_key in anim_keys )
  17. PrecacheMpAnim( level.anim_prop_models[model_key][anim_key] );
  18. //PrecacheMpAnim( level.anim_prop_models[ "foliage_tree_palm_bushy_1" ][ "strong" ] );
  19. }
  20.  
  21. // wait until the end of the frame so that maps can init their trees
  22. // in their _anim instead of only above _load
  23. waittillframeend;
  24.  
  25. level.init_animatedmodels = [];
  26.  
  27. animated_models = getentarray( "animated_model", "targetname" );
  28. array_thread( animated_models, ::model_init );
  29.  
  30. // one or more of the models initialized by model_init() was not setup by the map
  31. // so print this helpful note so the designer can see how to add it ot their level
  32. if ( level.init_animatedmodels_dump )
  33. assertmsg( "anims not cached for animated prop model, Repackage Zones and Rebuild Precache Script in Launcher:" );
  34.  
  35. array_thread( animated_models, ::animateModel );
  36.  
  37. level.init_animatedmodels = undefined;
  38. }
  39.  
  40. model_init()
  41. {
  42. if ( !isdefined( level.anim_prop_models[ self.model ] ) )
  43. level.init_animatedmodels_dump = true;
  44. }
  45.  
  46. // TODO: When we have multiple animations, instead of choosing randomly, do round-robin to get an even spread
  47. animateModel()
  48. {
  49. keys = GetArrayKeys( level.anim_prop_models[ self.model ] );
  50. animkey = keys[ RandomInt( keys.size ) ];
  51.  
  52. //wait( RandomFloatRange( 0, 5 ) ); // TODO: get a way to play animations at random starting points
  53. self ScriptModelPlayAnim( level.anim_prop_models[ self.model ][ animkey ] );
  54. self willNeverChange();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement