Beispiel #1
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);
            }
        }
Beispiel #2
0
        private async void RocketLauncherDelayedAttack(EntityControllerBase target, RocketLauncherAmmunition rlAmmo, int hitCount)
        {
            await Task.Delay(750);

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

                CalculateHellstormDamage(rlAmmo, hitCount, out double damage, out double shieldDamage);

                if (shieldDamage > 0)
                {
                    shieldDamage = Math.Abs(target.HangarAssembly.ChangeShield(-(int)shieldDamage, false));
                    PlayerController.HangarAssembly.ChangeShield((int)shieldDamage);
                }

                double shieldDamageDealt    = shieldDamage;
                double hitpointsDamageDealt = 0;

                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));

                    shieldDamageDealt    += damageShield;
                    hitpointsDamageDealt += damageHitpoints;
                }

                // set stats
                target.AttackTraceAssembly.LogAttack(PlayerController, (int)shieldDamageDealt, (int)hitpointsDamageDealt);
                target.HangarAssembly.CheckDeath();

                if (target != null)
                {
                    ICommand damageCommand = PacketBuilder.AttackCommand(PlayerController, target, AttackTypeModule.ROCKET, (int)(shieldDamage + damage));
                    target.Send(damageCommand);                        // send to player
                    target.EntitiesLocked(y => y.Send(damageCommand)); // send to all who have him in lock
                }
            } catch (Exception e) {
                GameContext.Logger.LogError(e);
            }
        }
        public void CheckOrStopSingularity(bool force = false)
        {
            try {
                ShipAbility ability = ShipAbility.SINGULARITY;

                PlayerController.Account.Cooldown.AbilityCooldown.TryGetValue(ability.ID, out DateTime lastAbilityTime);
                if (_singularityActive && (_singularityCounter == (int)ability.Duration.TotalSeconds * 2 || force))
                {
                    _singularityActive = false;
                    PlayerController.Account.Cooldown.AbilityCooldown[ability.ID] = DateTime.Now - ability.Duration;

                    PlayerController.EffectsAssembly.DeactivateSingularity();
                    PlayerController.Locked.EffectsAssembly.DeactivateSingularity();

                    PlayerController.Send(PacketBuilder.Slotbar.ItemCooldownCommand(ability.Name, ability.Cooldown.TotalMilliseconds));
                }
                else if (_singularityActive)
                {
                    if (++_singularityCounter % 2 == 0)
                    {
                        if (PlayerController.Locked.EffectsAssembly.HasProtection ||
                            (PlayerController.Locked is PlayerController lockedPlayerController &&
                             lockedPlayerController.SpecialItemsAssembly.IsInvicible))
                        {
                            PlayerController.Locked.AttackTraceAssembly.LogAttack(PlayerController, 0, 0, false);
                            ICommand missCommand = new AttackMissedCommand(new AttackTypeModule(AttackTypeModule.SINGULARITY), PlayerController.Locked.ID, 0);
                            PlayerController.Locked.Send(new AttackMissedCommand(new AttackTypeModule(AttackTypeModule.SINGULARITY), PlayerController.Locked.ID, 1));
                            PlayerController.Locked.EntitiesLocked(x => x.Send(missCommand));
                        }
                        else
                        {
                            PlayerController.Locked.HangarAssembly.ChangeHitpoints(-_singularityLastDamage, false);
                            PlayerController.Locked.AttackTraceAssembly.LogAttack(PlayerController, 0, _singularityLastDamage, false);
                            PlayerController.Locked.HangarAssembly.CheckDeath();

                            ICommand damageCommand = PacketBuilder.AttackCommand(PlayerController, PlayerController.Locked, AttackTypeModule.SINGULARITY, _singularityLastDamage);
                            PlayerController.Locked.Send(damageCommand);                        // send to player
                            PlayerController.Locked.EntitiesLocked(y => y.Send(damageCommand)); // send to all who have him in lock
                        }

                        _singularityLastDamage += _singularityDamageIncrease;
                    }
                }
            } catch { }
Beispiel #4
0
        public void TriggerSMB()
        {
            SpecialItem item = SpecialItem.SMB_01;

            if (!PlayerController.Account.Vault.SpecialItems.TryGetValue(item.ID, out int currentCount) ||
                currentCount <= 0)
            {
                return;
            }
            PlayerController.Account.Vault.SpecialItems[item.ID] = --currentCount;

            PlayerController.Account.Cooldown.SpecialItemCooldown.TryGetValue(item.ID, out DateTime lastTrigger);
            if (lastTrigger.FromNow() < item.Cooldown)
            {
                return;
            }

            PlayerController.Account.Cooldown.SpecialItemCooldown[item.ID] = DateTime.Now;

            ICommand smbCommand = PacketBuilder.SpecialItems.Smartbomb(PlayerController);

            PlayerController.Send(
                PacketBuilder.Slotbar.ExplosiveItemStatus(item.Name, currentCount, false),
                PacketBuilder.Slotbar.ItemCooldownCommand(item.Name, item.Cooldown.TotalMilliseconds, currentCount > 0),
                smbCommand
                );

            PlayerController.EntitiesInRangeSafe(x => { // if performance does not meet demand, add async here
                if (x is PlayerController playerController && !playerController.SpecialItemsAssembly.IsInvicible &&
                    !x.EffectsAssembly.HasProtection && !x.ZoneAssembly.IsInDMZ &&
                    x.MovementAssembly.ActualPosition().DistanceTo(PlayerController.MovementAssembly.ActualPosition()) < 550)
                {
                    double damage       = x.HangarAssembly.Hitpoints * .2;
                    int shieldDamage    = Math.Abs(x.HangarAssembly.ChangeShield(-(int)(damage * x.BoosterAssembly.Get(BoosterType.SHIELD_ABSORBATION)), false));
                    int hitpointsDamage = Math.Abs(x.HangarAssembly.ChangeHitpoints(-(int)(damage - shieldDamage), false));

                    x.AttackTraceAssembly.LogAttack(PlayerController, shieldDamage, hitpointsDamage, false);
                    x.HangarAssembly.CheckDeath();

                    ICommand attackCommand = PacketBuilder.AttackCommand(PlayerController, x, AttackTypeModule.SMARTBOMB, shieldDamage + hitpointsDamage);
                    x.Send(smbCommand, attackCommand);            // send to player
                    x.EntitiesLocked(y => y.Send(attackCommand)); // send to all who have him in lock
                }
Beispiel #5
0
        public void StartChainImpulse()
        {
            TechFactory tech = TechFactory.CHAIN_IMPULSE;

            if (_lastCI.FromNow() > tech.Cooldown)
            {
                if (!PlayerController.Account.Vault.Techs.TryGetValue(tech.ID, out int currentCount) ||
                    currentCount <= 0)
                {
                    return;
                }
                PlayerController.Account.Vault.Techs[tech.ID] = --currentCount;

                bool          working      = false;
                double        toDeal       = Noise(10000);
                StringBuilder chainCommand = new StringBuilder($"0|TX|ECI||{PlayerController.ID}");
                foreach (EntityControllerBase entity in
                         PlayerController.Spacemap.InRange(PlayerController, 1000)
                         .OrderBy(x => x.MovementAssembly.ActualPosition().DistanceTo(PlayerController.MovementAssembly.ActualPosition()))
                         .Take(7))
                {
                    working = true;
                    chainCommand.Append($"|{entity.ID}");

                    int damage = Math.Abs(entity.HangarAssembly.ChangeHitpoints(-(int)toDeal, false));
                    toDeal = Noise(toDeal);

                    entity.AttackTraceAssembly.LogAttack(PlayerController, 0, damage, false);
                    entity.HangarAssembly.CheckDeath();

                    ICommand damageCommand = PacketBuilder.AttackCommand(PlayerController, entity, AttackTypeModule.LASER, damage);
                    entity.Send(damageCommand);           // send to player
                    PlayerController.Send(damageCommand); // send to player
                    entity.EntitiesLocked(y => {
                        if (y.ID == PlayerController.ID)
                        {
                            return;
                        }

                        y.Send(damageCommand);
                    }); // send to all who have him in lock
                }

                if (!working)
                {
                    return;
                }
                else
                {
                    _lastCI = DateTime.Now;
                    PlayerController.Account.Cooldown.TechCooldown[tech.ID] = _lastCI;
                }

                ICommand showEffectCommand = PacketBuilder.Legacy(chainCommand.ToString());
                PlayerController.Send(
                    showEffectCommand,
                    PacketBuilder.Slotbar.TechItemStatus(tech.Name, currentCount, false),
                    PacketBuilder.Slotbar.ItemCooldownCommand(tech.Name, tech.Cooldown.TotalMilliseconds)
                    );
                PlayerController.EntitesInRange(x => x.Send(showEffectCommand));
            }
        }
Beispiel #6
0
        public void LaserAttack(ref int lapCount, Ammuninition ammo)
        {
            lock (_laserLock) {
                #region {[ CHECKING ]}
                if (PlayerController.Locked == null ||
                    PlayerController.Locked.MovementAssembly.ActualPosition()
                    .DistanceTo(PlayerController.MovementAssembly.ActualPosition()) > 600 ||
                    !_attackRunning)
                {
                    return;
                }

                bool stopLoop   = true;
                bool stopAttack = false;
                if (PlayerController.Locked.ZoneAssembly.IsInDMZ)
                {
                    PlayerController.Send(PacketBuilder.Messages.PeaceArea());
                    stopAttack = true;
                }

                if (!PlayerController.Account.CurrentHangar.LaserEquipped)
                {
                    PlayerController.Send(PacketBuilder.Messages.NoLasersOnBoard());
                    stopAttack = true;
                }

                if (!stopAttack && !CheckLaserCount(ammo, false, out int currentCount))
                {
                    PlayerController.Send(PacketBuilder.Messages.NoLaserAmmo());
                    stopAttack = true;
                }

                if (!stopAttack && !LaserCooldown(ref lapCount, ammo))
                {
                    stopAttack = true;
                    stopLoop   = false;
                }

                if (stopAttack)
                {
                    if (stopLoop)
                    {
                        Stop();
                    }

                    return;
                }
                #endregion

                CheckLaserCount(ammo, true, out currentCount); // deduct

                LastAttack = PlayerController.CurrentClock.ElapsedMilliseconds;
                ICommand attackCommand = PacketBuilder.AttackLaserCommand(PlayerController, PlayerController.Locked, ammo.ID);
                PlayerController.Send(attackCommand, PacketBuilder.Slotbar.LaserItemStatus(ammo.Name, currentCount, true));
                PlayerController.EntitesInRange(x => x.Send(attackCommand));

                if (PlayerController.Locked.EffectsAssembly.HasProtection ||
                    (PlayerController.Locked is PlayerController lockedPlayerController && lockedPlayerController.SpecialItemsAssembly.IsInvicible) ||
                    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;
                }

                CalculateLaserDamage(ammo, PlayerController.Locked, out double damage, out double shieldDamage);

                if (shieldDamage > 0)
                {
                    shieldDamage = Math.Abs(PlayerController.Locked.HangarAssembly.ChangeShield(-(int)shieldDamage, false));
                    PlayerController.HangarAssembly.ChangeShield((int)shieldDamage);
                }

                double shieldDamageDealt    = shieldDamage;
                double hitpointsDamageDealt = 0;

                if (damage > 0)
                {
                    double shieldAbsorption = Math.Max(0, Math.Min(1, PlayerController.Locked.BoosterAssembly.Get(BoosterType.SHIELD_ABSORBATION) - (PlayerController.BoosterAssembly.Get(BoosterType.LASER_SHIELD_PENETRATION) - 1)));

                    double damageShield = damage * shieldAbsorption;
                    if (PlayerController.PlayerAbilityAssembly.WeakenShieldsActive &&
                        PlayerController.PlayerAbilityAssembly.WeakenShieldsVictim.ID == PlayerController.Locked.ID)
                    {
                        damageShield *= 1.6;
                    }

                    damageShield = Math.Abs(PlayerController.Locked.HangarAssembly.ChangeShield(-(int)damageShield, false));
                    int damageHitpoints = Math.Abs(PlayerController.Locked.HangarAssembly.ChangeHitpoints(-(int)(damage - Math.Min(damage * shieldAbsorption, damageShield)), false));

                    shieldDamageDealt    += damageShield;
                    hitpointsDamageDealt += damageHitpoints;

                    // energy transfer
                    double hitpointsRegain = PlayerController.BoosterAssembly.Get(BoosterType.DAMAGE_LASER_TO_HITPOINTS_TRANSFORMER) - 1.0;
                    if (hitpointsRegain > 0 && ammo.ID == Ammuninition.UCB_100.ID)
                    {
                        int regain = PlayerController.HangarAssembly.ChangeHitpoints(Math.Max(0, (int)((damageShield + damageHitpoints) * hitpointsRegain)));
                        if (regain > 0 && !PlayerController.PlayerTechAssembly.EnergyTransferActive && ++_healCounter % 2 == 0)
                        {
                            _healCounter = 0;

                            ICommand energyTransferCommand = PacketBuilder.AttackLaserCommand(PlayerController.Locked, PlayerController, 7);
                            PlayerController.Locked.Send(energyTransferCommand);                        // send to player
                            PlayerController.Locked.EntitesInRange(y => y.Send(energyTransferCommand)); // send to all who have him in lock
                        }
                    }
                }

                // set stats
                PlayerController.Locked.AttackTraceAssembly.LogAttack(PlayerController, (int)shieldDamageDealt, (int)hitpointsDamageDealt);
                PlayerController.Locked.HangarAssembly.CheckDeath();

                ActivateLaserSpecialAttack(ammo);    // initialize special attack

                if (PlayerController.Locked != null) // Locked kann nach der CheckDeath-Methode tot sein (wahrscheinlichkeit: hoch)
                {
                    ICommand damageCommand = PacketBuilder.AttackCommand(PlayerController, PlayerController.Locked, AttackTypeModule.LASER, (int)(shieldDamageDealt + hitpointsDamageDealt));
                    PlayerController.Locked.Send(damageCommand);                        // send to player
                    PlayerController.Locked.EntitiesLocked(y => y.Send(damageCommand)); // send to all who have him in lock
                }
            }
        }
Beispiel #7
0
        public void Handle()
        {
            if (Activated && !_detonated)
            {
                _detonated = true;

                foreach (var entity in Spacemap.InRange(Position, 1000).ToList())
                {
                    if (!(entity is PlayerController playerController))
                    {
                        continue;
                    }

                    if (playerController.TryRemoveMine(this))
                    {
                        playerController.Send(Explode());
                    }
                    else
                    {
                        playerController.Send(Render(), Explode());
                    }

                    if (playerController.MovementAssembly.ActualPosition().DistanceTo(Position) <= 300 * RadiusBoost)
                    {
                        if (!playerController.EffectsAssembly.HasProtection && !playerController.SpecialItemsAssembly.IsInvicible)
                        {
                            if (Item.ID == Mine.ACM_01.ID)
                            {
                                double damage          = playerController.HangarAssembly.Hitpoints * 0.2 * DamageBoost;
                                int    shieldDamage    = Math.Abs(playerController.HangarAssembly.ChangeShield(-(int)(damage * playerController.BoosterAssembly.Get(BoosterType.SHIELD_ABSORBATION)), false));
                                int    hitpointsDamage = Math.Abs(playerController.HangarAssembly.ChangeHitpoints(-(int)(damage - shieldDamage), false));

                                playerController.AttackTraceAssembly.LogAttack(Owner, shieldDamage, hitpointsDamage, false);
                                playerController.HangarAssembly.CheckDeath();

                                ICommand damageCommand = PacketBuilder.AttackCommand(Owner, playerController, AttackTypeModule.MINE, shieldDamage + hitpointsDamage);
                                playerController.Send(damageCommand);
                                playerController.EntitiesLocked(x => x.Send(damageCommand));
                            }
                            else if (Item.ID == Mine.DDM_01.ID)
                            {
                                int damage = Math.Abs(playerController.HangarAssembly.ChangeHitpoints(-(int)(playerController.HangarAssembly.MaxHitpoints * 0.2 * DamageBoost), false));
                                playerController.AttackTraceAssembly.LogAttack(Owner, 0, damage, false);
                                playerController.HangarAssembly.CheckDeath();

                                ICommand damageCommand = PacketBuilder.AttackCommand(Owner, playerController, AttackTypeModule.MINE, damage);
                                playerController.Send(damageCommand);
                                playerController.EntitiesLocked(x => x.Send(damageCommand));
                            }
                            else if (Item.ID == Mine.IM_01.ID)
                            {
                                playerController.PlayerEffectsAssembly.Infect(15 * 60000);

                                double damage          = playerController.HangarAssembly.Hitpoints * 0.2 * DamageBoost;
                                int    shieldDamage    = Math.Abs(playerController.HangarAssembly.ChangeShield(-(int)(damage * playerController.BoosterAssembly.Get(BoosterType.SHIELD_ABSORBATION)), false));
                                int    hitpointsDamage = Math.Abs(playerController.HangarAssembly.ChangeHitpoints(-(int)(damage - shieldDamage), false));

                                playerController.AttackTraceAssembly.LogAttack(Owner, shieldDamage, hitpointsDamage, false);
                                playerController.HangarAssembly.CheckDeath();

                                ICommand damageCommand = PacketBuilder.AttackCommand(Owner, playerController, AttackTypeModule.MINE, shieldDamage + hitpointsDamage);
                                playerController.Send(damageCommand);
                                playerController.EntitiesLocked(x => x.Send(damageCommand));
                            }
                            else if (Item.ID == Mine.SABM_01.ID)
                            {
                                int damage = Math.Abs(playerController.HangarAssembly.ChangeShield(-(int)(playerController.HangarAssembly.Shield * 0.5 * DamageBoost), false));
                                playerController.AttackTraceAssembly.LogAttack(Owner, damage, 0, false);

                                ICommand damageCommand = PacketBuilder.AttackCommand(Owner, playerController, AttackTypeModule.MINE, damage);
                                playerController.Send(damageCommand);
                                playerController.EntitiesLocked(x => x.Send(damageCommand));
                            }
                            else if (Item.ID == Mine.SLM_01.ID)
                            {
                                playerController.EffectsAssembly.SlowMine(3000);
                            }
                        }

                        if (Item.ID == Mine.EMPM_01.ID)
                        {
                            playerController.EffectsAssembly.UnCloak();
                        }
                    }
                }

                Spacemap.Remove(this);
            }
        }