Guest User

Untitled

a guest
Jun 29th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #include "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\SkalistyBridge.c"
  2. //Spawn helper function
  3. void SpawnObject( string type, vector position, vector orientation )
  4. {
  5. auto obj = GetGame().CreateObject( type, position );
  6. obj.SetPosition( position );
  7. obj.SetOrientation( orientation );
  8.  
  9. // Force update collisions
  10. if ( obj.CanAffectPathgraph() )
  11. {
  12. obj.SetAffectPathgraph( true, false );
  13. GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( GetGame().UpdatePathgraphRegionByObject, 100, false, obj );
  14. }
  15. }
  16.  
  17. void main()
  18. {
  19. //INIT ECONOMY--------------------------------------
  20. Hive ce = CreateHive();
  21. if ( ce )
  22. ce.InitOffline();
  23.  
  24.  
  25.  
  26. //INIT WEATHER BEFORE ECONOMY INIT------------------------
  27. Weather weather = g_Game.GetWeather();
  28.  
  29. weather.MissionWeather(false); // false = use weather controller from Weather.c
  30.  
  31. weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
  32. weather.GetRain().Set( 0, 0, 1);
  33. weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
  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. SkalistyBridge();
  59. }
  60.  
  61. class CustomMission: MissionServer
  62. {
  63. void SetRandomHealth(EntityAI itemEnt)
  64. {
  65. if ( itemEnt )
  66. {
  67. int rndHlt = Math.RandomInt(55,100);
  68. itemEnt.SetHealth("","",rndHlt);
  69. }
  70. }
  71.  
  72. override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
  73. {
  74. Entity playerEnt;
  75. playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
  76. Class.CastTo(m_player, playerEnt);
  77.  
  78. GetGame().SelectPlayer(identity, m_player);
  79.  
  80. return m_player;
  81. }
  82.  
  83. override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
  84. {
  85. EntityAI itemTop;
  86. EntityAI itemEnt;
  87. ItemBase itemBs;
  88. float rand;
  89.  
  90. itemTop = player.FindAttachmentBySlotName("Body");
  91.  
  92. if ( itemTop )
  93. {
  94. itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
  95. if ( Class.CastTo(itemBs, itemEnt ) )
  96. itemBs.SetQuantity(4);
  97.  
  98. SetRandomHealth(itemEnt);
  99.  
  100. itemEnt = itemTop.GetInventory().CreateInInventory("RoadFlare");
  101. SetRandomHealth(itemEnt);
  102.  
  103. rand = Math.RandomFloatInclusive(0.0, 1.0);
  104. if ( rand < 0.35 )
  105. itemEnt = player.GetInventory().CreateInInventory("Apple");
  106. else if ( rand > 0.65 )
  107. itemEnt = player.GetInventory().CreateInInventory("Pear");
  108. else
  109. itemEnt = player.GetInventory().CreateInInventory("Plum");
  110.  
  111. SetRandomHealth(itemEnt);
  112. }
  113. }
  114. };
  115.  
  116. Mission CreateCustomMission(string path)
  117. {
  118. return new CustomMission();
  119. }
Advertisement
Add Comment
Please, Sign In to add comment