Advertisement
Guest User

Untitled

a guest
May 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. //Spawn helper function
  2. void SpawnObject( string type, vector position, vector orientation )
  3. {
  4. auto obj = GetGame().CreateObject( type, position );
  5. obj.SetPosition( position );
  6. obj.SetOrientation( orientation );
  7. //Force collision update
  8. vector roll = obj.GetOrientation();
  9. roll [ 2 ] = roll [ 2 ] - 1;
  10. obj.SetOrientation( roll );
  11. roll [ 2 ] = roll [ 2 ] + 1;
  12. obj.SetOrientation( roll );
  13. }
  14.  
  15. void main()
  16. {
  17. //INIT WEATHER BEFORE ECONOMY INIT------------------------
  18. Weather weather = g_Game.GetWeather();
  19.  
  20. weather.MissionWeather(false); // false = use weather controller from Weather.c
  21.  
  22. weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
  23. weather.GetRain().Set( 0, 0, 1);
  24. weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
  25.  
  26. //INIT ECONOMY--------------------------------------
  27. Hive ce = CreateHive();
  28. if ( ce )
  29. ce.InitOffline();
  30.  
  31. //Your custom spawned objects
  32.  
  33. //GetTesting().ExportProxyData( "7500 0 7500", 10000 ); //Center of map, radius of how far to go out and find buildings.
  34.  
  35. //DATE RESET AFTER ECONOMY INIT-------------------------
  36. int year, month, day, hour, minute;
  37. int reset_month = 9, reset_day = 20;
  38. GetGame().GetWorld().GetDate(year, month, day, hour, minute);
  39.  
  40. if ((month == reset_month) && (day < reset_day))
  41. {
  42. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  43. }
  44. else
  45. {
  46. if ((month == reset_month + 1) && (day > reset_day))
  47. {
  48. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  49. }
  50. else
  51. {
  52. if ((month < reset_month) || (month > reset_month + 1))
  53. {
  54. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  55. }
  56. }
  57. }
  58. }
  59.  
  60. class CustomMission: MissionServer
  61. {
  62. void SetRandomHealth(EntityAI itemEnt)
  63. {
  64. if ( itemEnt )
  65. {
  66. int rndHlt = Math.RandomInt(55,100);
  67. itemEnt.SetHealth("","",rndHlt);
  68. }
  69. }
  70.  
  71. override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
  72. {
  73. Entity playerEnt;
  74. playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
  75. Class.CastTo(m_player, playerEnt);
  76.  
  77. GetGame().SelectPlayer(identity, m_player);
  78.  
  79. return m_player;
  80. }
  81.  
  82. override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
  83. {
  84. EntityAI itemTop;
  85. EntityAI itemEnt;
  86. ItemBase itemBs;
  87. float rand;
  88.  
  89. itemTop = player.FindAttachmentBySlotName("Body");
  90.  
  91. if ( itemTop )
  92. {
  93. itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
  94. if ( Class.CastTo(itemBs, itemEnt ) )
  95. itemBs.SetQuantity(4);
  96.  
  97. SetRandomHealth(itemEnt);
  98.  
  99. itemEnt = itemTop.GetInventory().CreateInInventory("RoadFlare");
  100. SetRandomHealth(itemEnt);
  101.  
  102. rand = Math.RandomFloatInclusive(0.0, 1.0);
  103. if ( rand < 0.35 )
  104. itemEnt = player.GetInventory().CreateInInventory("Apple");
  105. else if ( rand > 0.65 )
  106. itemEnt = player.GetInventory().CreateInInventory("Pear");
  107. else
  108. itemEnt = player.GetInventory().CreateInInventory("Plum");
  109.  
  110. SetRandomHealth(itemEnt);
  111. }
  112. }
  113. };
  114.  
  115. Mission CreateCustomMission(string path)
  116. {
  117. return new CustomMission();
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement