public void Deploy()
 {
     foreach (var gun in Guns)
     {
         TerminalPropertiesHelper.SetValue(gun, "Shoot", true);
     }
     deploying = 12;
 }
Beispiel #2
0
 public void HoldFire()
 {
     Guns.Items.ForEach(gun => TerminalPropertiesHelper.SetValue(gun, "Shoot", false));
     if (WCAPI != null)
     {
         WCGuns.Items.ForEach(gun => WCAPI.ToggleWeaponFire(gun, false, true));
     }
     fireCounter = -1;
 }
Beispiel #3
0
 void Fire()
 {
     if (fireTicks <= 0)
     {
         foreach (var gat in Gats)
         {
             TerminalPropertiesHelper.SetValue(gat, "Shoot", true);
         }
     }
     fireTicks = 4;
 }
        public void Update(TimeSpan timestamp, UpdateFrequency updateFlags)
        {
            if (deploying > 0)
            {
                deploying--;

                if (deploying <= 0)
                {
                    foreach (var gun in Guns)
                    {
                        TerminalPropertiesHelper.SetValue(gun, "Shoot", false);
                    }
                }
            }
        }
Beispiel #5
0
        public void Fire()
        {
            if (fireCounter == -1)
            {
                if (FireSalvoMS == 0)
                {
                    Guns.Items.ForEach(gun => { gun.Enabled = true; TerminalPropertiesHelper.SetValue(gun, "Shoot", true); });
                    if (WCAPI != null)
                    {
                        WCGuns.Items.ForEach(gun => { gun.Enabled = true; WCAPI.ToggleWeaponFire(gun, true, true); });
                    }
                }
                else
                {
                    NextSalvoFire = Context.LocalTime;
                }
            }
            fireCounter = 3;

            if (fireCounter > 0 &&
                Context.LocalTime >= NextSalvoFire)
            {
                NextSalvoFire += ScriptTime.FromMilliseconds(FireSalvoMS);
                var gun = Guns.GetAndAdvance();
                if (gun != null)
                {
                    gun.Enabled = true;
                    TerminalPropertiesHelper.SetValue(gun, "Shoot", true);
                }
                if (WCAPI != null)
                {
                    var wcGun = WCGuns.GetAndAdvance();
                    if (wcGun != null)
                    {
                        wcGun.Enabled = true;
                        WCAPI.ToggleWeaponFire(wcGun, true, true);
                    }
                }
            }
        }
        void MiningAdjust()
        {
            if (adjustStartPosition == Vector3D.Zero)
            {
                adjustStartPosition = Me.GetPosition();
            }

            for (int i = 0; i < wheels.Count; i++)
            {
                var propulsionMult = -Math.Sign(Math.Round(Vector3D.Dot(wheels[i].WorldMatrix.Up, shipController.WorldMatrix.Right), 2));
                TerminalPropertiesHelper.SetValue(wheels[i], "Propulsion override", adjustWheelSpeed * propulsionMult);
                wheels[i].Brake = false;
            }
            double dist = Vector3D.Distance(Me.GetPosition(), adjustStartPosition);

            echoBuilder.AppendLine($"Adjusting: Distance = {dist}/{adjustDist} m");
            echoBuilder.AppendLine($"MINING: Reps = {repsRemaining}");

            if (adjustDist < dist)
            {
                for (int i = 0; i < wheels.Count; i++)
                {
                    TerminalPropertiesHelper.SetValue(wheels[i], "Propulsion override", 0f);
                    wheels[i].Brake = true;
                }
                if (repsRemaining == 0)
                {
                    ChangeState(ScriptState.Standby);
                }
                else
                {
                    ChangeState(ScriptState.MiningDown);
                }
                adjustStartPosition = Vector3D.Zero;
            }
        }
Beispiel #7
0
        public void Update()
        {
            LifeTimeTicks++;

            // Startup Subroutine
            if (LifeTimeTicks == 1)
            {
                foreach (var engine in Drive.HoverEngines)
                {
                    engine.AltitudeMin = 1;
                    engine.PushOnly    = true;
                }
            }

            if (LifeTimeTicks == 60)
            {
                foreach (var engine in Drive.HoverEngines)
                {
                    engine.AltitudeMin = 2;
                }
            }

            if (LifeTimeTicks == 120)
            {
                foreach (var engine in Drive.HoverEngines)
                {
                    engine.AltitudeMin = 7;
                }
            }

            if (LifeTimeTicks % kRunEveryXUpdates == 0)
            {
                Vector3D PlanetDir = PlanetPos - Controller.WorldMatrix.Translation;
                PlanetDir.Normalize();

                // Orient Self
                Drive.Turn(Gats.Count > 0 ? Gats[0].WorldMatrix : Controller.WorldMatrix, target);

                // Aim Turret
                if (TurretRotor != null)
                {
                    if (target != Vector3D.Zero && Drive.GravAngle < Math.PI * 0.1)
                    {
                        var TurretAngle = TrigHelpers.FastAsin(Gats[0].WorldMatrix.Forward.Dot(PlanetDir));

                        Vector3D TargetDir  = target - Gats[0].WorldMatrix.Translation;
                        var      targetDist = TargetDir.Length();
                        TargetDir.Normalize();
                        var TargetAngle = TrigHelpers.FastAsin(TargetDir.Dot(PlanetDir));

                        var angleDiff = TargetAngle - TurretAngle;

                        if (VectorHelpers.VectorAngleBetween(Gats[0].WorldMatrix.Forward, TargetDir) < 0.05 && targetDist < 800)
                        {
                            Fire();
                        }

                        TurretRotor.TargetVelocityRPM = (float)TurretPID.Control(angleDiff);
                    }
                    else
                    {
                        TurretPID.Reset();
                        TurretRotor.TargetVelocityRPM = 0;
                    }
                }

                // Check your fire
                fireTicks--;
                if (fireTicks == -1)
                {
                    foreach (var gat in Gats)
                    {
                        TerminalPropertiesHelper.SetValue(gat, "Shoot", false);
                    }
                }

                // Check Movement
                if (Destination != Vector3D.Zero)
                {
                    Drive.Drive(Destination);
                    if (Drive.Arrived)
                    {
                        Destination = Vector3D.Zero;
                        Drive.Flush();
                    }
                }
            }
        }
        public void Update(int ticks = 1)
        {
            salvoTickCounter -= ticks;
            fireTicks        -= ticks;

            //statusBuilder.Clear();
            if (Weapons.Items.Count == 0)
            {
                return;
            }

            //statusBuilder.AppendLine("TGTS: " + targets.Count.ToString());
            while (Weapons.Items[0].Closed)
            {
                Weapons.Items.RemoveAtFast(0);
                if (Weapons.Items.Count == 0)
                {
                    return;
                }
            }

            if (fireTicks > 0)
            {
                if (salvoTicks <= 0)
                {
                    foreach (var weapon in Weapons.Items)
                    {
                        if (WCAPI != null)
                        {
                            Weapons.Items.ForEach(gun => { WCAPI.ToggleWeaponFire(gun, true, true); });
                        }
                        else
                        {
                            Weapons.Items.ForEach(gun => { TerminalPropertiesHelper.SetValue(gun, "Shoot", true); });
                        }
                    }
                }
                else
                {
                    if (salvoTickCounter < 0)
                    {
                        if (WCAPI != null)
                        {
                            var gun = Weapons.GetAndAdvance();
                            WCAPI.ToggleWeaponFire(gun, true, true);
                        }
                        else
                        {
                            var gun = Weapons.GetAndAdvance();
                            TerminalPropertiesHelper.SetValue(gun, "Shoot", true);
                        }

                        salvoTickCounter = salvoTicks;
                    }
                }
            }
            else
            {
                foreach (var weapon in Weapons.Items)
                {
                    if (WCAPI != null)
                    {
                        Weapons.Items.ForEach(gun => { WCAPI.ToggleWeaponFire(gun, false, true); });
                    }
                    else
                    {
                        Weapons.Items.ForEach(gun => { TerminalPropertiesHelper.SetValue(gun, "Shoot", false); });
                    }
                }
            }
        }