public void Execute(IClient initiator, RocketAttackStartRequest command)
        {
            int dummyLapNumber      = 0;
            RocketAmmunition rocket = initiator.Controller.Account.CurrentHangar.Selection.Rocket.FromRocketAmmunitions();

            (initiator.Controller.AttackAssembly as PlayerAttackAssembly).RocketAttack(ref dummyLapNumber, rocket, true);
        }
Example #2
0
        private async void RocketDelayedAttack(EntityControllerBase target, RocketAmmunition rocket)
        {
            await Task.Delay(500);

            try {
                if (target == null || PlayerController.Locked == null || PlayerController.Locked.ID != target.ID)
                {
                    return;
                }

                double damage = Noise(rocket.Damage * PlayerController.BoosterAssembly.Get(BoosterType.DAMAGE_ROCKETS));
                if (damage > 0)
                {
                    double shieldAbsorption = Math.Max(0, Math.Min(1, target.BoosterAssembly.Get(BoosterType.SHIELD_ABSORBATION)));
                    int    damageShield     = Math.Abs(target.HangarAssembly.ChangeShield(-(int)(damage * shieldAbsorption), false));
                    int    damageHitpoints  = Math.Abs(target.HangarAssembly.ChangeHitpoints(-(int)(damage - damageShield), false));

                    // set stats
                    target.AttackTraceAssembly.LogAttack(PlayerController, damageShield, damageHitpoints);
                    target.HangarAssembly.CheckDeath();

                    if (target != null)
                    {
                        ICommand damageCommand = PacketBuilder.AttackCommand(PlayerController, target, AttackTypeModule.ROCKET, (int)damage);
                        target.Send(damageCommand);                        // send to player
                        target.EntitiesLocked(y => y.Send(damageCommand)); // send to all who have him in lock
                    }
                }

                ActivateRocketSpecialAttack(target, rocket); // initialize special attack
            } catch (Exception e) {
                GameContext.Logger.LogError(e);
            }
        }
Example #3
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);
            }
        }
Example #4
0
        private bool RocketCooldown(ref int lapCount, RocketAmmunition rocket)
        {
            if (rocket.ID == RocketAmmunition.PLD_8.ID)
            {
                return(RocketPLD8Counter(ref lapCount));
            }
            else if (rocket.ID == RocketAmmunition.DCR_250.ID)
            {
                return(RocketDCR250Counter(ref lapCount));
            }
            else if (rocket.ID == RocketAmmunition.R_IC3.ID)
            {
                return(RocketRIC3Counter(ref lapCount));
            }

            return(RocketCounter(ref lapCount));
        }
Example #5
0
        private bool CheckRocketCount(RocketAmmunition rocket, bool deduct, out int currentCount)
        {
            PlayerController.Account.Vault.RocketAmmunitions.TryGetValue(rocket.ID, out currentCount);
            if (rocket.ID == RocketAmmunition.R310.ID || rocket.ID == RocketAmmunition.PLT_2026.ID)
            {
                return(true); // munitionen, die vom zählen ausgeschlossen werden
            }

            if (currentCount >= 1)
            {
                if (deduct)
                {
                    PlayerController.Account.Vault.RocketAmmunitions[rocket.ID] = --currentCount;
                }
                return(true);
            }
            return(false);
        }
Example #6
0
        private void ActivateRocketSpecialAttack(EntityControllerBase target, RocketAmmunition rocket)
        {
            if (target == null || PlayerController.Locked == null || PlayerController.Locked.ID != target.ID)
            {
                return;
            }

            if (rocket == RocketAmmunition.DCR_250)   // slow opponent by 30% for 5 seconds
            {
                target.EffectsAssembly.SlowRocket(5000);
            }
            else if (rocket == RocketAmmunition.PLD_8)
            {
                target.EffectsAssembly.PLDRocket(5000);
            }
            else if (rocket == RocketAmmunition.R_IC3)
            {
                target.EffectsAssembly.IceRocket(3000);
            }
        }