HasterPaster

Generate loot in custom buildings in DayZ starts at line 41

May 17th, 2021 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.95 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.     // 1. Uncomment the line below these instructions and save this file (init.c).
  42.     // 2. Start the server and let it run for a few minutes.
  43.     // 3. The server should now have created a folder called "export" in the folder "dayzOffline.chernarusplus\storage_1". In it should be a file called "mapgrouppos.xml".
  44.     // 4. Stop the server.
  45.     // 5. Copy the file "mapgrouppos.xml" to the folder "mpmissions\dayzOffline.chernarusplus" and replace the existing one.
  46.     // 6. Comment the line below these instructions and save this file (init.c) so it doesn't generate a new loot file every time the server starts up. You already have it.
  47.     // 7. Start the server and loot should now spawn in the new buildings.
  48.     // Info: The argument for the line below is the X, Y and Z coordinates to the center of the map ("7500 0 7500"), and the radius of how far to go out and find buildings (10000).
  49.    
  50.     //GetCEApi().ExportProxyData("7500 0 7500", 10000);
  51. }
  52.  
  53. class CustomMission: MissionServer
  54. {
  55.  
  56.        
  57.     void SetRandomHealth(EntityAI itemEnt)
  58.     {
  59.         if ( itemEnt )
  60.         {
  61.             float rndHlt = Math.RandomFloat( 0.45, 0.65 );
  62.             itemEnt.SetHealth01( "", "", rndHlt );
  63.         }
  64.     }
  65.  
  66.     override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
  67.     {
  68.         Entity playerEnt;
  69.         playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
  70.         Class.CastTo( m_player, playerEnt );
  71.  
  72.         GetGame().SelectPlayer( identity, m_player );
  73.  
  74.         return m_player;
  75.     }
  76.  
  77.     override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
  78.     {
  79.         EntityAI itemClothing;
  80.         EntityAI itemEnt;
  81.         ItemBase itemBs;
  82.         float rand;
  83.  
  84.         itemClothing = player.FindAttachmentBySlotName( "Body" );
  85.         if ( itemClothing )
  86.         {
  87.             SetRandomHealth( itemClothing );
  88.            
  89.             itemEnt = itemClothing.GetInventory().CreateInInventory( "Rag" );
  90.             if ( Class.CastTo( itemBs, itemEnt ) )
  91.                 itemBs.SetQuantity( 4 );
  92.  
  93.             SetRandomHealth( itemEnt );
  94.  
  95.             string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
  96.             int rndIndex = Math.RandomInt( 0, 4 );
  97.             itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
  98.             SetRandomHealth( itemEnt );
  99.  
  100.             rand = Math.RandomFloatInclusive( 0.0, 1.0 );
  101.             if ( rand < 0.35 )
  102.                 itemEnt = player.GetInventory().CreateInInventory( "Apple" );
  103.             else if ( rand > 0.65 )
  104.                 itemEnt = player.GetInventory().CreateInInventory( "Pear" );
  105.             else
  106.                 itemEnt = player.GetInventory().CreateInInventory( "Plum" );
  107.  
  108.             SetRandomHealth( itemEnt );
  109.         }
  110.        
  111.         itemClothing = player.FindAttachmentBySlotName( "Legs" );
  112.         if ( itemClothing )
  113.             SetRandomHealth( itemClothing );
  114.        
  115.         itemClothing = player.FindAttachmentBySlotName( "Feet" );
  116.     }
  117. };
  118.  
  119. Mission CreateCustomMission(string path)
  120. {
  121.     return new CustomMission();
  122. }
Add Comment
Please, Sign In to add comment