Beispiel #1
0
        public void RocketAttack(ref int lapCount, RocketAmmunition rocket, bool force = false)
        {
            lock (_rocketLock) {
                #region {[ CHECKING ]}
                if (PlayerController.Locked == null ||
                    (rocket.ID != RocketAmmunition.R_IC3.ID && PlayerController.Locked.MovementAssembly.ActualPosition()
                     .DistanceTo(PlayerController.MovementAssembly.ActualPosition()) > 650) ||
                    PlayerController.Locked.MovementAssembly.ActualPosition()
                    .DistanceTo(PlayerController.MovementAssembly.ActualPosition()) > 550 ||
                    (!force && !_attackRunning))
                {
                    return;
                }

                if (PlayerController.Locked.ZoneAssembly.IsInDMZ)
                {
                    PlayerController.Send(PacketBuilder.Messages.PeaceArea());
                    return;
                }

                if (!CheckRocketCount(rocket, false, out int currentCount))
                {
                    PlayerController.Send(PacketBuilder.Messages.NoRocketAmmo());
                    return;
                }

                if (!RocketCooldown(ref lapCount, rocket))
                {
                    return;
                }
                #endregion

                CheckRocketCount(rocket, true, out currentCount); // deduct count

                LastAttack = PlayerController.CurrentClock.ElapsedMilliseconds;
                ICommand attackCommand = PacketBuilder.AttackRocketCommand(PlayerController, PlayerController.Locked, rocket.ID);
                PlayerController.Send(attackCommand, PacketBuilder.Slotbar.RocketItemStatus(rocket.Name, currentCount, true));
                PlayerController.EntitesInRange(x => x.Send(attackCommand));

                if (PlayerController.Locked.EffectsAssembly.HasProtection ||
                    (PlayerController.Locked is PlayerController lockedPlayerController && lockedPlayerController.SpecialItemsAssembly.IsInvicible) ||
                    (!PlayerController.PlayerTechAssembly.PrecisionTargeterActive && Miss()))
                {
                    PlayerController.Locked.AttackTraceAssembly.LogAttack(PlayerController, 0, 0);
                    ICommand missCommand = new AttackMissedCommand(new AttackTypeModule(AttackTypeModule.LASER), PlayerController.Locked.ID, 0);
                    PlayerController.Locked.Send(new AttackMissedCommand(new AttackTypeModule(AttackTypeModule.LASER), PlayerController.Locked.ID, 1));
                    PlayerController.Locked.EntitiesLocked(x => x.Send(missCommand));
                    return;
                }

                RocketDelayedAttack(PlayerController.Locked, rocket);
            }
        }