Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Sandbox.Game;
- using Sandbox.Game.Entities;
- using Sandbox.ModAPI;
- using Sandbox.ModAPI.Contracts;
- using VRage.Game;
- using VRage.Game.Components;
- using VRage.Game.ModAPI;
- using VRage.Utils;
- using VRageMath;
- namespace Axebeard.CargoContractGenerator
- {
- class CargoContractGen
- {
- [MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
- public class Klime : MySessionComponentBase
- {
- public override void BeforeStart()
- {
- MyAPIGateway.Utilities.MessageEntered += Utilities_MessageRecieved;
- }
- private void Utilities_MessageRecieved(string message_text, ref bool sendToOthers)
- {
- if (MyAPIGateway.Session.IsServer && message_text == "/roll")
- {
- IMyPlayer player = MyAPIGateway.Session.Player;
- if (player != null && player.Character != null)
- {
- Random rnd = new Random();
- int chance = rnd.Next(0, 100);
- int chanceForContract = 35; //chance a cargo contract is generated
- int chanceStation = 70; // chance destination is a station
- int chanceEasyDest = 50; // space > space or planet > planet contracts
- bool easyContract = false; //did we get an easy contract?
- int resetTime = 3600; //time to allow new contract to possibly generate on same contract block
- bool startOnPlanet = false; //is the contract block on a planet?
- bool contractMade = false; // was a contract successfully created?
- //rnd = new Random();
- chance = rnd.Next(0, 100);
- string strchance = "Roll for contract chance - " + chance;
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage(strchance);
- if (chance < chanceForContract)
- {
- //rnd = new Random();
- chance = rnd.Next(0, 100);
- sendToOthers = false;
- strchance = "Roll for chance of easy contract - " + chance;
- MyVisualScriptLogicProvider.SendChatMessage(strchance);
- if (chance < chanceEasyDest) //should this be an easy contract?
- {
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage("Easy contract!");
- easyContract = true;
- }
- //rnd = new Random();
- chance = rnd.Next(0, 100);
- strchance = "Roll for chance of station - " + chance;
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage(strchance);
- if ((chance < chanceStation) && (!easyContract)) //station and NOT easy
- {
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage("Station contract!");
- //station based contract
- //try to find an eligible station
- //if no eligible stations found, go to random contract
- //if suitable destination found: contractMade =
- }
- if (!contractMade) //if no contract has been made up to this point...
- {
- //random contract
- if (easyContract)
- {
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage("Easy contract 2!");
- //Easy contract - space to space or planet to planet
- return;
- }
- sendToOthers = false;
- MyVisualScriptLogicProvider.SendChatMessage("Random contract!");
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement