Advertisement
Guest User

Untitled

a guest
Dec 30th, 2018
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void main()
  3. {
  4.     //INIT WEATHER BEFORE ECONOMY INIT------------------------
  5.     Weather weather = g_Game.GetWeather();
  6.  
  7.     weather.MissionWeather(false);    // false = use weather controller from Weather.c
  8.  
  9.     weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
  10.     weather.GetRain().Set( 0, 0, 1);
  11.     weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
  12.    
  13.     weather.GetRain().SetLimits( 0, 0.1 );
  14.  
  15.     //INIT ECONOMY--------------------------------------
  16.     Hive ce = CreateHive();
  17.     if ( ce )
  18.         ce.InitOffline();
  19.  
  20.     //DATE RESET AFTER ECONOMY INIT-------------------------
  21.     int year;
  22.     int month;
  23.     int day;
  24.     int hour;
  25.     int minute;
  26.  
  27.     GetGame().GetWorld().GetDate(year, month, day, hour, minute);
  28.  
  29.     if (((month <= 9) && (day < 20)) || ((month >= 10) && (day > 20)))
  30.     {
  31.         month = 9;
  32.         day = 20;
  33.        
  34.         GetGame().GetWorld().SetDate(year, month, day, hour, minute);
  35.     }
  36.    
  37.     //-----------------------X-mas
  38.     array<vector> treePositions = { "6560.29 0 2462.12",
  39.                                     "1652.66 0 14230.71",
  40.                                     "3801.06 0 8847.76",
  41.                                     "9442.32 0 8829.03",
  42.                                     "7903.16 0 12576.52",
  43.                                     "11617.75 0 14663.98",
  44.                                     "12830.08 0 10115.18",
  45.                                     "11221.94 0 12225.89",
  46.                                     "3471.93 0 12988.33",
  47.                                     "13933.42 0 13228.44",
  48.                                     "12022.64 0 9082.89",
  49.                                     "10468.54 0 2373.16",
  50.                                     "2725.48 0 5288.75",
  51.     };
  52.    
  53.  
  54.     Object treeEntity;
  55.     for ( int i=0; i < treePositions.Count(); i++ )
  56.     {
  57.         vector treePos = treePositions[i];
  58.         float posY = GetGame().SurfaceY(treePos[0], treePos[2]);
  59.         treeEntity = GetGame().CreateObject("ChristmasTree", Vector( treePos[0], posY, treePos[2]), false);
  60.  
  61.     }
  62.  
  63.     Timer timer = new Timer();
  64.     timer.Run(5, null, "PrintMsg", null, true);
  65.     new MyClass();
  66.  
  67. }
  68.  
  69. void PrintMsg()
  70. {
  71.     GetGame().ChatPlayer(1, "Hello!");
  72.     Print("Log TETSTSSTS");
  73. }
  74.  
  75. class CustomMission: MissionServer
  76. {  
  77.    
  78.  
  79.     void SetRandomHealth(EntityAI itemEnt)
  80.     {
  81.         if ( itemEnt )
  82.         {
  83.             int rndHlt = Math.RandomInt(55,100);
  84.             itemEnt.SetHealth("","",rndHlt);
  85.         }
  86.     }
  87.  
  88.     override void OnInit()
  89.     {
  90.        
  91.         Print("This is Server mission");
  92.         GetGame().ChatPlayer(1, "Blblblblbl");
  93.     }
  94.  
  95.     override void MissionServer()
  96.     {
  97.         new MyClass();
  98.     }
  99.  
  100.     override void TickScheduler(float timeSplice)
  101.     {
  102.         new MyClass();
  103.        
  104.     }
  105.  
  106.     override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
  107.     {
  108.         Entity playerEnt;
  109.         playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
  110.         Class.CastTo(m_player, playerEnt);
  111.        
  112.         GetGame().SelectPlayer(identity, m_player);
  113.         return m_player;
  114.     }
  115.    
  116.     override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
  117.     {
  118. /*
  119.         player.RemoveAllItems();
  120.  
  121.         EntityAI item = player.GetInventory().CreateInInventory(topsMissionArray.GetRandomElement());
  122.         EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
  123.         EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
  124. */
  125.         EntityAI itemTop;
  126.         EntityAI itemEnt;
  127.         ItemBase itemBs;
  128.         float rand;
  129.        
  130.         itemTop = player.FindAttachmentBySlotName("Body");
  131.        
  132.         if ( itemTop )
  133.         {
  134.             itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
  135.             if ( Class.CastTo(itemBs, itemEnt ) )
  136.                 itemBs.SetQuantity(4);
  137.  
  138.             SetRandomHealth(itemEnt);
  139.            
  140.             itemEnt = itemTop.GetInventory().CreateInInventory("RoadFlare");
  141.             SetRandomHealth(itemEnt);
  142.        
  143.             itemEnt = itemTop.GetInventory().CreateInInventory("StoneKnife");
  144.             SetRandomHealth(itemEnt);
  145.         }
  146.        
  147.        
  148.        
  149.         rand = Math.RandomFloatInclusive(0.0, 1.0);
  150.         if ( rand < 0.25 )
  151.             itemEnt = player.GetInventory().CreateInInventory("SodaCan_Cola");
  152.         else if ( rand > 0.75 )
  153.             itemEnt = player.GetInventory().CreateInInventory("SodaCan_Spite");
  154.         else
  155.             itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
  156.        
  157.         SetRandomHealth(itemEnt);
  158.  
  159.         rand = Math.RandomFloatInclusive(0.0, 1.0);
  160.         if ( rand < 0.35 )
  161.             itemEnt = player.GetInventory().CreateInInventory("Apple");
  162.         else if ( rand > 0.65 )
  163.             itemEnt = player.GetInventory().CreateInInventory("Pear");
  164.         else
  165.             itemEnt = player.GetInventory().CreateInInventory("Plum");
  166.        
  167.         SetRandomHealth(itemEnt);
  168.        
  169.        
  170.     }
  171. };
  172.  
  173. Mission CreateCustomMission(string path)
  174. {
  175.     return new CustomMission();
  176. }
  177.  
  178. class MyClass: Managed
  179. {
  180.     ref Timer timer;
  181.    
  182.     void MyClass()
  183.     {
  184.         Timer timer = new Timer(CALL_CATEGORY_GAMEPLAY);
  185.         timer.Run(5, this, "PrintMsg", null, true);
  186.     }
  187.    
  188.     void PrintMsg()
  189.     {
  190.         GetGame().ChatPlayer(1, "Hello!");
  191.         Print("Log TETSTSSTS");
  192.        
  193.     }
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement