Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Sandbox.Game;
  4. using Sandbox.Game.Entities;
  5. using Sandbox.ModAPI;
  6. using Sandbox.ModAPI.Contracts;
  7. using VRage.Game;
  8. using VRage.Game.Components;
  9. using VRage.Game.ModAPI;
  10. using VRage.Utils;
  11. using VRageMath;
  12.  
  13. namespace Axebeard.CargoContractGenerator
  14. {
  15.     class CargoContractGen
  16.     {
  17.         [MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
  18.        public class Klime : MySessionComponentBase
  19.         {
  20.              public override void BeforeStart()
  21.             {
  22.               MyAPIGateway.Utilities.MessageEntered += Utilities_MessageRecieved;
  23.             }
  24.             private void Utilities_MessageRecieved(string message_text, ref bool sendToOthers)
  25.             {
  26.             if (MyAPIGateway.Session.IsServer && message_text == "/roll")
  27.             {
  28.             IMyPlayer player = MyAPIGateway.Session.Player;
  29.             if (player != null && player.Character != null)
  30.             {
  31.             Random rnd = new Random();
  32.             int chance = rnd.Next(0, 100);
  33.             int chanceForContract = 35; //chance a cargo contract is generated
  34.             int chanceStation = 70; // chance destination is a station
  35.             int chanceEasyDest = 50; // space > space or planet > planet contracts
  36.             bool easyContract = false; //did we get an easy contract?
  37.             int resetTime = 3600; //time to allow new contract to possibly generate on same contract block    
  38.             bool startOnPlanet = false; //is the contract block on a planet?
  39.             bool contractMade = false; // was a contract successfully created?
  40.            
  41.                 //rnd = new Random();
  42.                 chance = rnd.Next(0, 100);
  43.                 string strchance = "Roll for contract chance -  " + chance;
  44.                 sendToOthers = false;
  45.                 MyVisualScriptLogicProvider.SendChatMessage(strchance);
  46.                 if (chance < chanceForContract)
  47.                 {
  48.                     //rnd = new Random();
  49.                     chance = rnd.Next(0, 100);
  50.                     sendToOthers = false;
  51.                     strchance = "Roll for chance of easy contract -  " + chance;
  52.                     MyVisualScriptLogicProvider.SendChatMessage(strchance);
  53.  
  54.                     if (chance < chanceEasyDest) //should this be an easy contract?
  55.                     {
  56.                         sendToOthers = false;
  57.                         MyVisualScriptLogicProvider.SendChatMessage("Easy contract!");
  58.                         easyContract = true;
  59.                     }
  60.                     //rnd = new Random();
  61.                     chance = rnd.Next(0, 100);
  62.                     strchance = "Roll for chance of station -  " + chance;
  63.                     sendToOthers = false;
  64.                     MyVisualScriptLogicProvider.SendChatMessage(strchance);
  65.  
  66.                     if ((chance < chanceStation) && (!easyContract)) //station and NOT easy
  67.                     {
  68.                         sendToOthers = false;
  69.                         MyVisualScriptLogicProvider.SendChatMessage("Station contract!");
  70.                         //station based contract
  71.                         //try to find an eligible station
  72.                         //if no eligible stations found, go to random contract
  73.                         //if suitable destination found: contractMade =
  74.                     }
  75.                     if (!contractMade) //if no contract has been made up to this point...
  76.                     {
  77.                         //random contract
  78.                         if (easyContract)
  79.                         {
  80.                             sendToOthers = false;
  81.                             MyVisualScriptLogicProvider.SendChatMessage("Easy contract 2!");
  82.                             //Easy contract - space to space or planet to planet
  83.                             return;
  84.                         }
  85.                         sendToOthers = false;
  86.                         MyVisualScriptLogicProvider.SendChatMessage("Random contract!");
  87.                     }
  88.  
  89.                 }
  90.            
  91.             }
  92.             }
  93.             }
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement