Advertisement
Guest User

init.c

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