/// <summary> /// Creating a combat with player /// </summary> /// <param name="attacker">Attacker</param> /// <param name="target">Target</param> /// <param name="type">Type of attack</param> /// <param name="lootId">LootId</param> public void CreateCombat(Player attacker, AbstractAttackable target, AttackTypes type, string lootId) { var amount = 0; switch (type) { case AttackTypes.LASER: var laserCount = GameItemManager.Instance.CountLasers(attacker); if (laserCount == 0) { PrebuiltLegacyCommands.Instance.ServerMessage(attacker, "No lasers equipped on board."); PrebuiltCombatCommands.Instance.AbortAttackCommand(attacker); return; } amount = laserCount; break; case AttackTypes.ROCKET: amount = 1; break; } CreateCombat(attacker, target, type, lootId, amount); }
public PendingAttack(AbstractAttacker from, AbstractAttackable to, AttackTypes attackType, string lootId, int amount) { From = from; To = to; AttackType = attackType; LootId = lootId; Amount = amount; }
/// <summary> /// Creating a different laser combat designed for player where it calculates the lasers equipped for amount /// </summary> /// <param name="target"></param> protected override void OnLaserCombat(AbstractAttackable target) { var currentLaserSelected = Player.Settings.GetSettings <SlotbarSettings>().SelectedLaserAmmo; Console.WriteLine("OnLaserCombat: " + currentLaserSelected); CombatManager.Instance.CreateCombat(Player, target, AttackTypes.LASER, currentLaserSelected); }
private void DamageAttackable(AbstractAttackable target, int damage, int shieldDamage) { if (target.CurrentShield > 0) { int healthDamage; if (target.CurrentShield <= damage || target.CurrentShield <= shieldDamage) { healthDamage = Math.Abs(target.CurrentShield - damage); target.CurrentShield = 0; target.CurrentHealth -= healthDamage; } else { target.CurrentShield -= shieldDamage; //Correspondent shield damage healthDamage = damage; } if (target.CurrentNanoHull > 0) { //If the player can receive some damage on the nanohull if (target.CurrentNanoHull - healthDamage < 0) { var nanoDamage = healthDamage - target.CurrentNanoHull; target.CurrentNanoHull = 0; target.CurrentHealth -= nanoDamage; } else { target.CurrentNanoHull -= healthDamage; } } else { target.CurrentHealth -= healthDamage; //80% shield abs => 20% life } } else //NO SHIELD { if (target.CurrentNanoHull > 0) { //If the player can receive some damage on the nanohull if (target.CurrentNanoHull - damage < 0) { var nanoDamage = damage - target.CurrentNanoHull; target.CurrentNanoHull = 0; target.CurrentHealth -= nanoDamage; } else { target.CurrentNanoHull -= damage; //Full dmg to nanohull } } else { target.CurrentHealth -= damage; //Full dmg to health } } }
/// <summary> /// Primary constructor /// </summary> /// <param name="target"></param> /// <param name="damage"></param> /// <param name="absorbDamage"></param> /// <param name="calculationType"></param> /// <param name="attackType"></param> public PendingDamage(AbstractAttackable target, int damage, int absorbDamage, DamageCalculationTypes calculationType, AttackTypes attackType) { Target = target; Damage = damage; AbsorbDamage = absorbDamage; CalculationType = calculationType; AttackType = attackType; DamageType = DamageTypes.ENTITY; }
/// <summary> /// Trying to select an attackable /// </summary> /// <param name="abstractAttackable">Attackable trying to select</param> /// <exception cref="Exception">If it doesnt exist in range</exception> public virtual void SelectAttackable(AbstractAttackable abstractAttackable) { if (!Character.RangeView.CharactersInRenderRange.ContainsKey(abstractAttackable.Id)) { Out.QuickLog("Something went wrong in select attackable, attackable not rendered", LogKeys.ERROR_LOG); throw new Exception("Something went wrong in select attackable, trying to select something that is not rendered"); } Character.Selected = abstractAttackable; }
/// <summary> /// Creating the laser attack /// </summary> /// <param name="target"></param> /// <exception cref="Exception"></exception> public void OnLaserAttackStart(AbstractAttackable target) { if (InLaserCombat) { Out.QuickLog("Currently ongoing laser attack and trying to re-enable it", LogKeys.ERROR_LOG); throw new Exception("Laser attack is already ongoing"); } Character.OnLaserShot += OnLaserShotComplete; Character.OnLaserAmmunitionChange += OnLaserAmmunitionChanged; InLaserCombat = true; OnLaserCombat(target); }
/// <summary> /// Selecting an attackable /// </summary> /// <param name="abstractAttackable">Attackable</param> /// <exception cref="NotImplementedException">Soon to be removed</exception> public override void SelectAttackable(AbstractAttackable abstractAttackable) { base.SelectAttackable(abstractAttackable); if (abstractAttackable is Character attackableAsCharacter) { PrebuiltRangeCommands.Instance.SelectShipCommand(Player, attackableAsCharacter); } else { Out.QuickLog("Trying to select something other than Character", LogKeys.ERROR_LOG); throw new NotImplementedException("Trying to select something other than Character"); } }
/// <summary> /// Enforcing a damage where there is no attacker (ag: Fell on a mine or some sort of shit) /// </summary> /// <param name="target">Target</param> /// <param name="damage">Damage (if percentage 1-100)</param> /// <param name="absorbDamage">Damage absorb = shield transfer (if percentage 1-100)</param> /// <param name="calculationType">Calculation type (defined or percentage)</param> /// <param name="attackType">Type of attack</param> public void EnforceDamage(AbstractAttackable target, int damage, int absorbDamage, DamageCalculationTypes calculationType, AttackTypes attackType) { if (target == null) { Out.QuickLog("Something went wrong enforcing damage, target is null", LogKeys.ERROR_LOG); throw new Exception("Target is null, cannot damage"); } if (damage == 0 && absorbDamage == 0) { // damage finished return; } _pendingDamages.Enqueue(new PendingDamage(target, damage, absorbDamage, calculationType, attackType)); }
public void BuildToRange(AbstractAttackable parent, Commands key, object[] oldClientParameters, object[] newClientParameters) { foreach (var character in parent.Spacemap.Entities) { if (!(character.Value is Player player)) { continue; } var session = GameStorageManager.Instance.FindSession(player); if (player.UsingNewClient) { BuildCommand(session.GameClient, key, true, newClientParameters); } else { BuildCommand(session.GameClient, key, false, oldClientParameters); } } }
/// <summary> /// Creating an attack for every sort of entity /// </summary> /// <param name="attacker">Attacker</param> /// <param name="target">Target</param> /// <param name="type">Type</param> /// <param name="lootId">Optional</param> /// <param name="amount">Optional</param> public void CreateCombat(AbstractAttacker attacker, AbstractAttackable target, AttackTypes type, string lootId = "", int amount = 0) { CreateAttackCombat(new PendingAttack(attacker, target, type, lootId, amount)); }
/// <summary> /// Secondary constructor /// </summary> /// <param name="target"></param> /// <param name="attacker"></param> /// <param name="damage"></param> /// <param name="absorbDamage"></param> /// <param name="calculationType"></param> /// <param name="attackType"></param> public PendingDamage(AbstractAttackable target, AbstractAttacker attacker, int damage, int absorbDamage, DamageCalculationTypes calculationType, AttackTypes attackType) : this(target, damage, absorbDamage, calculationType, attackType) { Attacker = attacker; }
/// <summary> /// Creating the combat - can be overriden for Player for instance /// </summary> /// <param name="target"></param> protected virtual void OnLaserCombat(AbstractAttackable target) { CombatManager.Instance.CreateCombat(Character, target, AttackTypes.LASER); }
//todo: ... public void OnRocketLauncherAttack(AbstractAttackable target) { }
private void DamageAttackable(AbstractAttackable target, AbstractAttacker attacker, int hpDamage, int shieldDamage) { if (target.CurrentShield > 0) { //if (totalAbsDamage > 0) // totalDamage += totalAbsDamage; //For example => Target has 80% abs but you' have moth (+20% penetration) :> damage * 0.6 var totalAbs = Math.Abs(attacker.ShieldPenetration - target.ShieldAbsorption); if (totalAbs > 0) { var _absDmg = (int)(totalAbs * shieldDamage); target.CurrentShield -= _absDmg; if (target.CurrentShield < 0) { target.CurrentShield = 0; } if (attacker != null) { attacker.CurrentShield += _absDmg; } } int healthDamage; if (target.CurrentShield <= hpDamage || target.CurrentShield <= shieldDamage) { healthDamage = Math.Abs(target.CurrentShield - hpDamage); target.CurrentShield = 0; target.CurrentHealth -= healthDamage; } else { target.CurrentShield -= (int)shieldDamage; //Correspondent shield damage healthDamage = (int)(hpDamage * (1 - totalAbs)); } if (target.CurrentNanoHull > 0) { //If the player can receive some damage on the nanohull if (target.CurrentNanoHull - healthDamage < 0) { var nanoDamage = healthDamage - target.CurrentNanoHull; target.CurrentNanoHull = 0; target.CurrentHealth -= nanoDamage; } else { target.CurrentNanoHull -= healthDamage; } } else { target.CurrentHealth -= healthDamage; //80% shield abs => 20% life } } else //NO SHIELD { if (target.CurrentNanoHull > 0) { //If the player can receive some damage on the nanohull if (target.CurrentNanoHull - hpDamage < 0) { var nanoDamage = hpDamage - target.CurrentNanoHull; target.CurrentNanoHull = 0; target.CurrentHealth -= nanoDamage; } else { target.CurrentNanoHull -= hpDamage; //Full dmg to nanohull } } else { target.CurrentHealth -= hpDamage; //Full dmg to health } } }