public void DamageCommand(Player player, PendingDamage pendingDamage) { var attackerId = 0; if (pendingDamage.Attacker != null) { attackerId = pendingDamage.Attacker.Id; } if (GetSession(player, out var session)) { if (pendingDamage.Damage + pendingDamage.AbsorbDamage == 0) { PrebuiltLegacyCommands.Instance.ServerMessage(player, "Missed!!!"); Packet.Builder.BuildCommand(session.GameClient, Commands.ATTACK_MISS_COMMAND, false, pendingDamage.AttackType, pendingDamage.Target.Id, 0); } else { Packet.Builder.BuildCommand(session.GameClient, Commands.ATTACK_HIT_COMMAND, false, pendingDamage.AttackType, attackerId, pendingDamage.Target.Id, pendingDamage.Target.CurrentHealth, pendingDamage.Target.CurrentShield, pendingDamage.Target.CurrentNanoHull, pendingDamage.Damage + pendingDamage.AbsorbDamage); } } }
private void ProcessEntityDamage(PendingDamage pendingDamage) { if (pendingDamage.Target.IsDead) { Out.WriteLog("Trying to damage a dead entity", LogKeys.ERROR_LOG, pendingDamage.Attacker.Id); return; } if (pendingDamage.Attacker.Invisible) { //todo: uncloak } pendingDamage.Attacker.LastCombatTime = DateTime.Now; //To avoid repairing and logging off | My' own logging is set to off in the correspondent handlers if (pendingDamage.Target.Invincible) { // to all selected send that shit //PrebuiltCombatCommands.Instance.DamageCommand(); return; } DamageAttackable(pendingDamage.Target, pendingDamage.Attacker, pendingDamage.Damage, pendingDamage.AbsorbDamage); AnnounceDamage(pendingDamage); }
protected override void OnDamageReceived(object sender, PendingDamage e) { PrebuiltCombatCommands.Instance.DamageCommand(Player, e); var selectors = Player.Controller.GetInstance <CharacterSelectionController>().FindAllSelectors(); foreach (var selector in selectors) { if (selector is Player playerSelector) { PrebuiltCombatCommands.Instance.DamageCommand(playerSelector, e); } } }
private void RandomiseDamage(PendingDamage pendingDamage) { if (pendingDamage.Attacker == null) { Out.WriteLog("Trying to randomise a damage without attacker", LogKeys.ERROR_LOG); throw new Exception("Trying to randomise a damage where there is no attacker"); } var attacker = pendingDamage.Attacker; var random = RandomInstance.getInstance(attacker).NextDouble(); if (pendingDamage.Damage > 0) { if (random > attacker.HitRate) { pendingDamage.Damage = 0; } else { var randomDamage = Convert.ToInt32(RandomInstance.getInstance(attacker).Next(pendingDamage.Damage - attacker.MaximalDamageReduce, attacker.MaximalDamageIncrease + pendingDamage.Damage)); pendingDamage.Damage = randomDamage; } } if (pendingDamage.AbsorbDamage > 0) { if (random > attacker.HitRate) { pendingDamage.AbsorbDamage = 0; } else { var randomDamage = Convert.ToInt32(RandomInstance.getInstance(attacker).Next(pendingDamage.AbsorbDamage - attacker.MaximalDamageReduce, attacker.MaximalDamageIncrease + pendingDamage.AbsorbDamage)); pendingDamage.AbsorbDamage = randomDamage; } } }
/// <summary> /// Called to execute damage receive event /// </summary> /// <param name="pendingDamage"></param> public void OnDamaged(PendingDamage pendingDamage) { OnDamageReceived?.Invoke(this, pendingDamage); }
protected virtual void OnDamageReceived(object sender, PendingDamage e) { }
private void AnnounceDamage(PendingDamage pendingDamage) { pendingDamage.Target?.OnDamaged(pendingDamage); }
private void ProcessAreaDamage(PendingDamage pendingDamage) { }