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); } }
private void HandleDependencies(EntityControllerBase attacker, bool affectEffects = true) { if (affectEffects) { if (attacker is PlayerController enemyPlayerController && enemyPlayerController.IsInLogoutProcess) { enemyPlayerController.CancelLogout(); } if (attacker.EffectsAssembly.HasProtection && attacker is PlayerController) // loose protection { attacker.EffectsAssembly.MakeVincible(); } if (attacker.EffectsAssembly.Cloaked) { attacker.EffectsAssembly.UnCloak(); } } if (Controller is PlayerController ownPlayerController && ownPlayerController.IsInLogoutProcess) { ownPlayerController.CancelLogout(); } }
public AttackTraceAssembly(EntityControllerBase controller) : base(controller) { _trace = new Dictionary <int, AttackTraceEntry>(); _lock = new object(); _validationTimer = new TickInterval(CheckChanges, 500); controller.OnTick += _validationTimer.Tick; }
public override void Lock(EntityControllerBase entity) { if (Locked != null && (entity == null || Locked.ID != entity.ID)) { PlayerAbilityAssembly.CheckOrStopSingularity(true); } base.Lock(entity); }
public static AttackHitCommand AttackCommand(EntityControllerBase initiator, EntityControllerBase target, short attackType, int damage) { if (target == null) { return(null); } return(new AttackHitCommand(new AttackTypeModule(attackType), initiator.ID, target.ID, target.HangarAssembly.Hitpoints, target.HangarAssembly.Shield, 0, damage, false)); // letzter parameter muss noch adaptiert werden (pilot sheet) }
public static LegacyModule AttackRocketCommand(EntityControllerBase initiator, EntityControllerBase target, int rocketType) { int effectID = 0; if (initiator is PlayerController playerController && playerController.PlayerTechAssembly.PrecisionTargeterActive) { effectID = 2; } return(Legacy($"0|v|{initiator.ID}|{target.ID}|H|{rocketType}|{effectID}|1")); }
public IEnumerable <EntityControllerBase> EntitiesOnMap(EntityControllerBase controller) { using (_lock.ObtainReadLock()) { foreach (var entity in _entities) { if (entity.Value.ID != controller.ID) { yield return(entity.Value); } } } }
public NpcHangarAssembly(EntityControllerBase controller, Ship ship, Map map, Position position, int hitpoints, int shield) : base(controller) { Ship = ship; Map = map; Position = position; _hp = hitpoints; _shd = shield; Shield = MaxShield; Hitpoints = MaxHitpoints; }
public IEnumerable <MineObject> MinesInRange(EntityControllerBase controller) { const int range = 850; using (_mineLock.ObtainReadLock()) { foreach (var mine in _mines) { if (mine.Value.Position.DistanceTo(controller.MovementAssembly.ActualPosition()) <= range) { yield return(mine.Value); } } } }
private void CalculateLaserDamage(Ammuninition ammo, EntityControllerBase target, out double damage, out double shieldDamage) { if (PlayerController.Locked is PlayerController) // pvp { damage = ammo.DamageMultiplier * PlayerController.PlayerHangarAssembly.DamagePVP; shieldDamage = ammo.ShieldMultiplier * PlayerController.PlayerHangarAssembly.DamagePVP; } else { damage = ammo.DamageMultiplier * PlayerController.PlayerHangarAssembly.DamagePVE; shieldDamage = ammo.ShieldMultiplier * PlayerController.PlayerHangarAssembly.DamagePVE; } damage = Noise(damage) * Math.Max(0, target.BoosterAssembly.Get(BoosterType.ENEMY_DAMAGE_LASER)); // normal damage shieldDamage = Noise(shieldDamage) * Math.Max(0, target.BoosterAssembly.Get(BoosterType.ENEMY_DAMAGE_LASER)); // sab damage (sab / cbo) }
public MineObject(EntityControllerBase initiator, SpacemapController spacemap, Position position, Mine mine, bool radiusSkilled, double radiusBoost, bool damageSkilled, double damageBoost, TimeSpan readyIn) { Owner = initiator; Spacemap = spacemap; Position = position; Item = mine; RadiusSkilled = radiusSkilled; RadiusBoost = radiusBoost; DamageSkilled = damageSkilled; DamageBoost = damageBoost; _armTime = readyIn; _activateableTime = DateTime.Now.Add(_armTime); }
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 Remove(EntityControllerBase controller) { bool updateEnemyCounter = false; using (_lock.ObtainUpgradeableReadLock()) { if (_entities.ContainsKey(controller.ID)) { using (_lock.ObtainWriteLock()) { if (MapInfo.IsStarter && controller.Faction.ID > 0 && controller.Faction.ID != MapInfo.OwnerFaction.ID) { _enemyCounter--; updateEnemyCounter = true; } _entities.Remove(controller.ID); } } } if (controller is PlayerController playerController && playerController.PlayerAbilityAssembly.WeakenShieldsActive) { playerController.PlayerAbilityAssembly.CheckOrStopWeakenShields(true); } ICommand warnBoxCommand = PacketBuilder.MapWarnCountCommand(_enemyCounter); foreach (var other in EntitiesOnMap(controller).ToList()) { if (MapInfo.IsStarter && updateEnemyCounter && other.Faction.ID == MapInfo.OwnerFaction.ID) { other.Send(warnBoxCommand); } if (other is PlayerController playerController2 && playerController2.PlayerAbilityAssembly.WeakenShieldsActive && playerController2.PlayerAbilityAssembly.WeakenShieldsVictim.ID == controller.ID) { playerController2.PlayerAbilityAssembly.CheckOrStopWeakenShields(true); } } }
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); } }
// In range or have me in lock or i have them in lock public IEnumerable <EntityControllerBase> InRange(EntityControllerBase controller, int range = -1) { if (range < MapInfo.ViewRange) { range = MapInfo.ViewRange; } using (_lock.ObtainReadLock()) { foreach (var entity in _entities) { if (IsInRange(controller, entity.Value, range)) { yield return(entity.Value); } else if (entity.Value.ID != controller.ID && (entity.Value.Locked != null && entity.Value.Locked.ID == controller.ID || controller.Locked != null && controller.Locked.ID == entity.Value.ID || entity.Value.MovementAssembly.ActualPosition().DistanceTo(controller.MovementAssembly.ActualPosition()) <= range)) { yield return(entity.Value); } } } }
public override void EntityAddedToMap(EntityControllerBase entity) { switch (entity) { case PlayerController playerEntity: Send( PacketBuilder.CreateShipCommand(this, playerEntity), PacketBuilder.DroneCommand(playerEntity), playerEntity.MovementAssembly.MovementCommand() ); Send(playerEntity.PlayerTechAssembly.EffectsCommand() .Concat(playerEntity.PlayerAbilityAssembly.EffectsCommand())); break; default: Send( PacketBuilder.CreateShipCommand(this, entity), entity.MovementAssembly.MovementCommand()); break; } Send(entity.EffectsAssembly.EffectsCommand()); }
public void LogAttack(EntityControllerBase attacker, int shieldDamage, int hitpointsDamage, bool affectEffects = true) { HandleDependencies(attacker, affectEffects); long currentTime = Controller.CurrentClock.ElapsedMilliseconds; // set time LastAttackTime = currentTime; if (_trace.TryGetValue(attacker.ID, out AttackTraceEntry traceEntry)) { traceEntry.LastAttackTime = currentTime; traceEntry.ShieldDamageDealt += shieldDamage; traceEntry.HitpointsDamageDealt += hitpointsDamage; } else { _trace.Add(attacker.ID, new AttackTraceEntry(currentTime, shieldDamage, hitpointsDamage)); } if (CurrentMainAttacker == -1) { ChangeMainAttacker(attacker.ID); } }
public AttackAssemblyBase(EntityControllerBase controller) : base(controller) { _attackTimer = new TickInterval(AttackTimer, 1000, 1000); // set initial value to 1000, so the first tick is an attack Controller.OnTick += Tick; }
public static MoveCommand MoveCommand(EntityControllerBase initiator, Position destination, int time) { return(new MoveCommand(initiator.ID, destination.X, destination.Y, time)); }
public NpcAttackAssembly(EntityControllerBase controller) : base(controller) { }
public static AttributeHitpointUpdateCommand HitpointsChangeCommand(EntityControllerBase initiator) { return(new AttributeHitpointUpdateCommand(initiator.HangarAssembly.Hitpoints, initiator.HangarAssembly.MaxHitpoints, 0, 0)); }
public AssemblyBase(EntityControllerBase controller) { Controller = controller ?? throw GameContext.Logger.LogError(new ArgumentNullException(nameof(controller))); }
public static ShipSelectionCommand SelectCommand(EntityControllerBase target) { // wtf is shipType? maybe the group icon??? return(new ShipSelectionCommand(target.ID, 1, target.HangarAssembly.Shield, target.HangarAssembly.MaxShield, target.HangarAssembly.Hitpoints, target.HangarAssembly.MaxHitpoints, 0, 0, true)); // letzter param, pilot sheet }
public static KillCommand KillCommand(EntityControllerBase initiator) { return(new KillCommand(initiator.ID)); }
public static ShipSelectionCommand TargetHealthBaseChangedCommand(EntityControllerBase target) { return(SelectCommand(target)); }
public BoosterAssembly(EntityControllerBase controller) : base(controller) { _boosts = new Dictionary <BoosterType, double>(); _lock = new object(); }
public EffectsAssembly(EntityControllerBase controller) : base(controller) { _checkTick = new TickInterval(CheckDuration, 100, 0); controller.OnTick += _checkTick.Tick; }
private bool _isMoving, _isStuck; // isStuck = if speed is 0 / slow mine / ice rocket #endregion #region {[ CONSTRUCTOR ]} public MovementAssembly(EntityControllerBase controller) : base(controller) { _destination = Controller.HangarAssembly.Position; _timeElapsed = new Stopwatch(); }
public ZoneAssembly(EntityControllerBase controller) : base(controller) { _beaconCommand = new BeaconCommand(0, 0, 0, 0, false, false, false, "equipment_extra_repbot_rep-4", false); }
public override void EntityAddedToMap(EntityControllerBase entity) { }