コード例 #1
0
        private void MessageReceiver_FMD_CS_CHATMESSAGE(ClientConnection client, AllegianceInterop.FMD_CS_CHATMESSAGE message)
        {
            var ship = client.GetCore().GetShip(message.cd.sidSender);

            if (ship != null && (PilotType)ship.GetPilotType() == PilotType.c_ptBuilder && ship.GetSide().GetObjectID() == client.GetSide().GetObjectID())
            {
                if (ship.GetStationType().GetConstructorNeedRockSound() == message.cd.voiceOver && ship.GetCluster() != null)
                {
                    // Clear previous destination.
                    if (_constuctorsInFlightToClusterObjectIDByShipObjectID.ContainsKey(ship.GetObjectID()) == true)
                    {
                        Log($"Constructor {ship.GetName()} needs a new target rock.");
                        _constuctorsInFlightToClusterObjectIDByShipObjectID.Remove(ship.GetObjectID());
                    }

                    if (ship.GetCluster() != null)
                    {
                        PlaceStation(ship, ship.GetCluster().GetObjectID());
                    }
                    else
                    {
                        //  Waiting on FMD_S_SHIP_STATUS to update this ship's current position. (This happens when a constructor first launches.).
                        Log($"Constructor {ship.GetName()} is waiting for rock, but it doesn't have a cluster yet. Will use current Home Cluster {GetHomeCluster().GetName()} for starting point.");
                        PlaceStation(ship, GetHomeCluster().GetObjectID());
                    }
                }
                else
                {
                }
            }
        }
コード例 #2
0
        private void MessageReceiver_FMD_CS_CHATMESSAGE(ClientConnection client, AllegianceInterop.FMD_CS_CHATMESSAGE message)
        {
            var ship = ClientConnection.GetShip();

            if (message.Message.Equals("die") == true)
            {
                AllegianceInterop.FMD_C_SUICIDE suicide = new AllegianceInterop.FMD_C_SUICIDE();
                client.SendMessageServer(suicide);
            }
        }
コード例 #3
0
        private void MessageReceiver_FMD_CS_CHATMESSAGE(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_CS_CHATMESSAGE message)
        {
            var ship = client.GetShip();

            if (ship.GetCommandTarget((sbyte)CommandType.c_cmdCurrent) != null)
            {
                Log($"\tcommandCurrent: {ship.GetCommandID((sbyte)CommandType.c_cmdCurrent)}, commandTarget: {ship.GetCommandTarget((sbyte)CommandType.c_cmdCurrent).GetName()}");
                Log($"\tcommandPlan: {ship.GetCommandID((sbyte)CommandType.c_cmdPlan)}, commandTarget: {ship.GetCommandTarget((sbyte)CommandType.c_cmdPlan).GetName()}");
                Log($"\tship.GetAutopilot() = {ship.GetAutopilot()}");
            }

            if (message.Message == "go")
            {
                var side      = client.GetSide();
                var mission   = side.GetMission();
                var hullTypes = mission.GetHullTypes();

                var station = ship.GetStation();

                if (station == null)
                {
                    // Works!
                    //{
                    //    var buoy = client.CreateBuoy((sbyte)BuoyType.c_buoyWaypoint, _random.Next(-1000, 1000), _random.Next(-1000, 1000), _random.Next(-1000, 1000), ship.GetCluster().GetObjectID(), true);
                    //    var command = ship.GetDefaultOrder(buoy);
                    //    ship.SetCommand((sbyte)CommandType.c_cmdCurrent, buoy, command);
                    //    ship.SetAutopilot(true);
                    //}


                    // Works!
                    {
                        var warps = ship.GetCluster().GetWarps();
                        var warp  = warps[_random.Next(0, warps.Count)];
                        //var warp = ship.GetCluster().GetWarps().First();
                        CommandID command = (CommandID)ship.GetDefaultOrder(warp);

                        Log($"moving to point: {warp.GetName()}, command: {command.ToString()}");

                        // This should be it.
                        ship.SetCommand((sbyte)CommandType.c_cmdCurrent, warp, (sbyte)CommandID.c_cidGoto);
                        ship.SetAutopilot(true);
                    }

                    return;
                }

                List <AllegianceInterop.IhullTypeIGCWrapper> buyableHullTypes = new List <AllegianceInterop.IhullTypeIGCWrapper>();

                foreach (var hullType in hullTypes)
                {
                    if (hullType.GetGroupID() >= 0 && station.CanBuy(hullType) == true && station.IsObsolete(hullType) == false)
                    {
                        Log("buyable hullType: " + hullType.GetName());
                        buyableHullTypes.Add(hullType);
                    }
                }



                // Get a scout.
                var scoutHull = buyableHullTypes.FirstOrDefault(p => p.GetName().Contains("Scout"));
                if (scoutHull == null)
                {
                    return;
                }

                Log($"Found Scout: {scoutHull.GetName()}");

                var partTypes = mission.GetPartTypes();
                List <AllegianceInterop.IpartTypeIGCWrapper> buyablePartTypes = new List <AllegianceInterop.IpartTypeIGCWrapper>();
                foreach (var partType in partTypes)
                {
                    if (partType.GetGroupID() >= 0 && station.CanBuy(partType) == true && station.IsObsolete(partType) == false)
                    {
                        short equipmentTypeID = partType.GetEquipmentType();

                        bool isIncluded = false;

                        switch ((EquipmentType)equipmentTypeID)
                        {
                        case EquipmentType.NA:
                            isIncluded = true;
                            break;

                        case EquipmentType.ET_Weapon:
                        case EquipmentType.ET_Turret:
                            for (sbyte i = 0; i < scoutHull.GetMaxFixedWeapons(); i++)
                            {
                                isIncluded |= scoutHull.GetPartMask(equipmentTypeID, i) != 0 && scoutHull.CanMount(partType, i) == true;
                            }
                            break;

                        default:
                            isIncluded |= scoutHull.GetPartMask(equipmentTypeID, 0) != 0 && scoutHull.CanMount(partType, 0) == true;

                            break;
                        }

                        if (isIncluded == true)
                        {
                            buyablePartTypes.Add(partType);
                            Log($"\tFound part: {partType.GetName()}, capacity for part: {scoutHull.GetCapacity(partType.GetEquipmentType())}");
                        }
                    }
                }

                var mines = buyablePartTypes.FirstOrDefault(p => p.GetName().Contains("Prox Mine") == true);

                //scoutHull.

                // Creating the empty ship adds the ship object to the core so that it will receive updates when the core.Update() is called.
                //var ship = client.CreateEmptyShip();
                ship.SetBaseHullType(scoutHull);
                client.BuyDefaultLoadout(ship, station, scoutHull, client.GetMoney());

                // Clear the cargo.
                for (sbyte i = -5; i < 0; i++)
                {
                    var currentPart = ship.GetMountedPart((short)EquipmentType.NA, i);
                    if (currentPart != null)
                    {
                        currentPart.Terminate();
                    }
                }

                if (mines != null)
                {
                    for (sbyte i = -5; i < 0; i++)
                    {
                        int amount = client.BuyPartOnBudget(ship, mines, i, client.GetMoney());
                        Log("Bought: " + amount + " mines.");
                    }

                    var dispenser = ship.GetMountedPart((short)EquipmentType.ET_Dispenser, 0);
                    dispenser.Terminate();

                    client.BuyPartOnBudget(ship, mines, 0, client.GetMoney());
                }

                client.BuyLoadout(ship, true);

                // Clean up the newShip.
                //newShip.Terminate();

                //ship = client.Get

                Task.Run(() =>
                {
                    // Wait for the ship to enter the cluster.
                    while (ship.GetCluster() == null)
                    {
                        Thread.Sleep(100);
                    }

                    client.FireDispenser(ship);

                    //var buoy = client.CreateBuoy((sbyte)BuoyType.c_buoyWaypoint, 3000, 0, 0, ship.GetCluster().GetObjectID(), true);

                    //ship.SetAutopilot(true);
                    //ship.SetCommand((sbyte)CommandType.c_cmdAccepted, buoy, (sbyte)CommandID.c_cidGoto);
                    //ship.SetAutopilot(true);

                    //// Drop mines!
                    //var launcher = AllegianceInterop.IdispenserIGCWrapper.GetDispenserForPart(ship.GetMountedPart((short)EquipmentType.ET_Dispenser, 0));

                    ////var launcher = (AllegianceInterop.IdispenserIGCWrapper) ship.GetMountedPart((short) EquipmentType.ET_Dispenser, 0);
                    //client.FireExpendable(ship, launcher, (uint)DateTime.Now.Ticks);
                });
            }

            if (message.Message == "miner")
            {
                var side    = client.GetSide();
                var buckets = side.GetBuckets();
                var money   = client.GetMoney();

                foreach (var bucket in buckets)
                {
                    if (bucket.GetName() == ".Miner")
                    {
                        if (money > bucket.GetPrice() && bucket.GetCompleteF() == false)
                        {
                            Log("Adding money to bucket. Bucket wants: " + bucket.GetPrice() + ", we have: " + money);
                            client.AddMoneyToBucket(bucket, bucket.GetPrice());
                        }
                        else
                        {
                            Log("Already building: " + bucket.GetPercentComplete());
                        }
                    }
                }
            }
        }