Razorxd1993

Init.c

Aug 31st, 2021
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. void main()
  2. {
  3. //INIT WEATHER BEFORE ECONOMY INIT------------------------
  4. Weather weather = g_Game.GetWeather();
  5.  
  6. weather.MissionWeather(false); // false = use weather controller from Weather.c
  7.  
  8. weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
  9. weather.GetRain().Set( 0, 0, 1);
  10. weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
  11.  
  12. //INIT ECONOMY--------------------------------------
  13. Hive ce = CreateHive();
  14. if ( ce )
  15. ce.InitOffline();
  16.  
  17. //DATE RESET AFTER ECONOMY INIT-------------------------
  18. int year, month, day, hour, minute;
  19. int reset_month = 9, reset_day = 20;
  20. GetGame().GetWorld().GetDate(year, month, day, hour, minute);
  21.  
  22. if ((month == reset_month) && (day < reset_day))
  23. {
  24. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  25. }
  26. else
  27. {
  28. if ((month == reset_month + 1) && (day > reset_day))
  29. {
  30. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  31. }
  32. else
  33. {
  34. if ((month < reset_month) || (month > reset_month + 1))
  35. {
  36. GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
  37. }
  38. }
  39. }
  40. }
  41.  
  42. class CustomMission: MissionServer
  43. {
  44. void SetRandomHealth(EntityAI itemEnt)
  45. {
  46. if ( itemEnt )
  47. {
  48. float rndHlt = Math.RandomFloat( 0.45, 0.65 );
  49. itemEnt.SetHealth01( "", "", rndHlt );
  50. }
  51. }
  52.  
  53. override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
  54. {
  55. Entity playerEnt;
  56. playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
  57. Class.CastTo( m_player, playerEnt );
  58.  
  59. GetGame().SelectPlayer( identity, m_player );
  60.  
  61. return m_player;
  62. }
  63.  
  64. override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
  65. {
  66. EntityAI itemClothing;
  67. EntityAI itemEnt;
  68. ItemBase itemBs;
  69. float rand;
  70.  
  71. itemClothing = player.FindAttachmentBySlotName( "Body" );
  72. if ( itemClothing )
  73. {
  74. SetRandomHealth( itemClothing );
  75.  
  76. itemEnt = itemClothing.GetInventory().CreateInInventory( "BandageDressing" );
  77. if ( Class.CastTo( itemBs, itemEnt ) )
  78. itemBs.SetQuantity( 2 );
  79.  
  80. SetRandomHealth( itemEnt );
  81.  
  82. string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
  83. int rndIndex = Math.RandomInt( 0, 4 );
  84. itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
  85. SetRandomHealth( itemEnt );
  86.  
  87. rand = Math.RandomFloatInclusive( 0.0, 1.0 );
  88. if ( rand < 0.35 )
  89. itemEnt = player.GetInventory().CreateInInventory( "Apple" );
  90. else if ( rand > 0.65 )
  91. itemEnt = player.GetInventory().CreateInInventory( "Pear" );
  92. else
  93. itemEnt = player.GetInventory().CreateInInventory( "Plum" );
  94.  
  95. SetRandomHealth( itemEnt );
  96. }
  97.  
  98. itemClothing = player.FindAttachmentBySlotName( "Legs" );
  99. if ( itemClothing )
  100. SetRandomHealth( itemClothing );
  101.  
  102. itemClothing = player.FindAttachmentBySlotName( "Feet" );
  103. }
  104. };
  105.  
  106. Mission CreateCustomMission(string path)
  107. {
  108. return new CustomMission();
  109. }
  110. void SpawnObject(string objectName, vector position, vector orientation)
  111. {
  112. Object obj;
  113. obj = Object.Cast(GetGame().CreateObject(objectName, "0 0 0"));
  114. obj.SetPosition(position);
  115. obj.SetOrientation(orientation);
  116.  
  117. // Force update collisions
  118. if (obj.CanAffectPathgraph())
  119. {
  120. obj.SetAffectPathgraph(true, false);
  121. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, obj);
  122. }
  123. }
  124.  
  125. #include "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\Level19.c"
Advertisement
Add Comment
Please, Sign In to add comment