GetRndRangedDamage() публичный Метод

Returns random base damage for a ranged attack, e.g. Ranged Attack or Magnum Shot, based on race, weapon, etc.
public GetRndRangedDamage ( ) : float
Результат float
Пример #1
0
		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			if (target.IsNotReadyToBeHit)
				return CombatSkillResult.Okay;

			var targetPos = target.GetPosition();
			var attackerPos = attacker.GetPosition();

			// Check range
			//if (!attackerPos.InRange(targetPos, attacker.RightHand.OptionInfo.EffectiveRange + 100))
			//	return CombatSkillResult.OutOfRange;

			// Actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, skill.Info.Id, targetEntityId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = AttackerStun;
			cap.Add(aAction);

			// Hit by chance
			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get();
			if (rnd.NextDouble() * 100 < chance)
			{
				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Set(TargetOptions.Result);
				tAction.Stun = TargetStun;
				cap.Add(tAction);

				// Damage
				var damage = attacker.GetRndRangedDamage();

				// More damage with fire arrow
				if (attacker.Temp.FireArrow)
					damage *= FireBonus;

				// Critical Hit
				var critShieldReduction = (target.LeftHand != null ? target.LeftHand.Data.DefenseBonusCrit : 0);
				var critChance = attacker.GetRightCritChance(target.Protection + critShieldReduction);
				CriticalHit.Handle(attacker, critChance, ref damage, tAction);

				var maxDamage = damage; //Damage without Defense and Protection
				// Subtract target def/prot
				SkillHelper.HandleDefenseProtection(target, ref damage);

				// Defense
				Defense.Handle(aAction, tAction, ref damage, true);

				// Mana Shield
				ManaShield.Handle(target, ref damage, tAction, maxDamage);

				// Deal with it!
				if (damage > 0)
					target.TakeDamage(tAction.Damage = damage, attacker);

				// Aggro
				target.Aggro(attacker);

				// Death/Knockback
				if (target.IsDead)
				{
					tAction.Set(TargetOptions.FinishingKnockDown);
					attacker.Shove(target, KnockBackDistance);
				}
				else
				{
					// Insta-recover in knock down
					// TODO: Tied to stability?
					if (target.IsKnockedDown)
					{
						tAction.Stun = 0;
					}
					// Knock down if hit repeatedly
					else if (target.Stability < 30)
					{
						tAction.Set(TargetOptions.KnockDown);
					}
					// Normal stability reduction
					else
					{
						target.Stability -= StabilityReduction;
						if (target.IsUnstable)
						{
							tAction.Set(TargetOptions.KnockBack);
							attacker.Shove(target, KnockBackDistance);
						}
					}
				}
			}

			// Skill training
			if (skill.Info.Rank == SkillRank.Novice || skill.Info.Rank == SkillRank.RF)
				skill.Train(1); // Try ranged attack.

			// Reduce arrows
			if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows)
				attacker.Inventory.Decrement(attacker.Magazine);

			// Disable fire arrow effect
			if (attacker.Temp.FireArrow)
				Send.Effect(attacker, Effect.FireArrow, false);

			// "Cancels" the skill
			// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
			Send.SkillUse(attacker, skill.Info.Id, 800, 1);

			cap.Handle();

			return CombatSkillResult.Okay;
		}
Пример #2
0
		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			// "Cancels" the skill
			// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
			Send.SkillUse(attacker, skill.Info.Id, AttackerStun, 1);

			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get().NextDouble() * 100;
			var successfulHit = (rnd < chance);

			// Actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, targetEntityId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = AttackerStun;
			cap.Add(aAction);

			// Target action if hit
			if (successfulHit)
			{
				target.StopMove();

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Set(TargetOptions.Result);
				tAction.Stun = TargetStun;

				cap.Add(tAction);

				// Damage
				var damage = attacker.GetRndRangedDamage() * (skill.RankData.Var1 / 100f);

				// Elementals
				damage *= attacker.CalculateElementalDamageMultiplier(target);

				// More damage with fire arrow
				if (attacker.Temp.FireArrow)
					damage *= FireBonus;

				// Critical Hit
				var critChance = attacker.GetRightCritChance(target.Protection);
				CriticalHit.Handle(attacker, critChance, ref damage, tAction);

				// Subtract target def/prot
				SkillHelper.HandleDefenseProtection(target, ref damage);

				// Defense
				Defense.Handle(aAction, tAction, ref damage);

				// Mana Shield
				ManaShield.Handle(target, ref damage, tAction);

				// Natural Shield
				var delayReduction = NaturalShield.Handle(attacker, target, ref damage, tAction);

				// Deal with it!
				if (damage > 0)
				{
					target.TakeDamage(tAction.Damage = damage, attacker);
					SkillHelper.HandleInjury(attacker, target, damage);
				}

				// Aggro
				target.Aggro(attacker);

				// Knock down on deadly
				if (target.Conditions.Has(ConditionsA.Deadly))
					tAction.Set(TargetOptions.KnockDown);

				// Death/Knockback
				if (target.IsDead)
					tAction.Set(TargetOptions.FinishingKnockDown);

				// Knock Back
				if (tAction.IsKnockBack)
					attacker.Shove(target, KnockBackDistance);

				// Reduce stun, based on ping
				if (delayReduction > 0)
					tAction.Stun = (short)Math.Max(0, tAction.Stun - (tAction.Stun / 100 * delayReduction));

				// TODO: "Weakened" state (G12S2 gfSupportShotRenewal)
			}

			// Reduce arrows
			if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && !attacker.Magazine.HasTag("/unlimited_arrow/"))
				attacker.Inventory.Decrement(attacker.Magazine);

			cap.Handle();

			// Disable fire arrow effect
			if (attacker.Temp.FireArrow)
				Send.Effect(attacker, Effect.FireArrow, false);

			return CombatSkillResult.Okay;
		}
Пример #3
0
		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			var targetPos = target.GetPosition();
			var attackerPos = attacker.GetPosition();

			var actionType = (attacker.IsElf ? CombatActionPackType.ChainRangeAttack : CombatActionPackType.NormalAttack);
			var attackerStun = (short)(actionType == CombatActionPackType.ChainRangeAttack ? AttackerStunElf : AttackerStun);

			// "Cancels" the skill
			// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
			Send.SkillUse(attacker, skill.Info.Id, attackerStun, 1);

			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get().NextDouble() * 100;
			var successfulHit = (rnd < chance);

			var maxHits = (actionType == CombatActionPackType.ChainRangeAttack && successfulHit ? 2 : 1);
			var prevId = 0;

			for (byte i = 1; i <= maxHits; ++i)
			{
				target.StopMove();

				// Actions
				var cap = new CombatActionPack(attacker, skill.Info.Id);
				cap.Hit = i;
				cap.Type = actionType;
				cap.PrevId = prevId;
				prevId = cap.Id;

				var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, skill.Info.Id, targetEntityId);
				aAction.Set(AttackerOptions.Result);
				aAction.Stun = attackerStun;
				cap.Add(aAction);

				// Target action if hit
				if (successfulHit)
				{
					var targetSkillId = target.Skills.ActiveSkill != null ? target.Skills.ActiveSkill.Info.Id : SkillId.CombatMastery;

					var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, targetSkillId);
					tAction.Set(TargetOptions.Result);
					tAction.AttackerSkillId = skill.Info.Id;
					tAction.Stun = (short)(actionType == CombatActionPackType.ChainRangeAttack ? TargetStunElf : TargetStun);
					if (actionType == CombatActionPackType.ChainRangeAttack)
						tAction.EffectFlags = 0x20;
					cap.Add(tAction);

					// Damage
					var damage = attacker.GetRndRangedDamage();

					// More damage with fire arrow
					if (attacker.Temp.FireArrow)
						damage *= FireBonus;

					// Critical Hit
					var critChance = attacker.GetRightCritChance(target.Protection);
					CriticalHit.Handle(attacker, critChance, ref damage, tAction);

					// Subtract target def/prot
					SkillHelper.HandleDefenseProtection(target, ref damage);

					// Defense
					Defense.Handle(aAction, tAction, ref damage);

					// Mana Shield
					ManaShield.Handle(target, ref damage, tAction);

					// Deal with it!
					if (damage > 0)
						target.TakeDamage(tAction.Damage = damage, attacker);

					// Aggro
					target.Aggro(attacker);

					// Death/Knockback
					if (target.IsDead)
					{
						tAction.Set(TargetOptions.FinishingKnockDown);
						attacker.Shove(target, KnockBackDistance);
						maxHits = 1;
					}
					else
					{
						// Insta-recover in knock down
						// TODO: Tied to stability?
						if (target.IsKnockedDown)
						{
							tAction.Stun = 0;
						}
						// Knock down if hit repeatedly
						else if (target.Stability < 30)
						{
							tAction.Set(TargetOptions.KnockDown);
						}
						// Normal stability reduction
						else
						{
							target.Stability -= (actionType == CombatActionPackType.ChainRangeAttack ? StabilityReductionElf : StabilityReduction);
							if (target.IsUnstable)
							{
								tAction.Set(TargetOptions.KnockBack);
								attacker.Shove(target, KnockBackDistance);
							}
						}
						tAction.Creature.Stun = tAction.Stun;
					}
				}

				aAction.Creature.Stun = aAction.Stun;

				// Skill training
				if (skill.Info.Rank == SkillRank.Novice || skill.Info.Rank == SkillRank.RF)
					skill.Train(1); // Try ranged attack.

				// Reduce arrows
				if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && attacker.Magazine.Info.Id != 67220)
					attacker.Inventory.Decrement(attacker.Magazine);

				cap.Handle();
			}

			// Disable fire arrow effect
			if (attacker.Temp.FireArrow)
				Send.Effect(attacker, Effect.FireArrow, false);

			return CombatSkillResult.Okay;
		}
Пример #4
0
		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			var targetPos = target.GetPosition();
			var attackerPos = attacker.GetPosition();

			var actionType = (attacker.IsElf ? CombatActionPackType.ChainRangeAttack : CombatActionPackType.NormalAttack);
			var attackerStun = (short)(actionType == CombatActionPackType.ChainRangeAttack ? AttackerStunElf : AttackerStun);

			// "Cancels" the skill
			// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
			Send.SkillUse(attacker, skill.Info.Id, attackerStun, 1);

			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get().NextDouble() * 100;
			var successfulHit = (rnd < chance);

			var maxHits = (actionType == CombatActionPackType.ChainRangeAttack && successfulHit ? 2 : 1);
			var prevId = 0;

			for (byte i = 1; i <= maxHits; ++i)
			{
				target.StopMove();

				// Actions
				var cap = new CombatActionPack(attacker, skill.Info.Id);
				cap.Hit = i;
				cap.Type = actionType;
				cap.PrevId = prevId;
				prevId = cap.Id;

				var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, targetEntityId);
				aAction.Set(AttackerOptions.Result);
				aAction.Stun = attackerStun;
				cap.Add(aAction);

				// Target action if hit
				if (successfulHit)
				{
					var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
					tAction.Set(TargetOptions.Result);
					tAction.Stun = (short)(actionType == CombatActionPackType.ChainRangeAttack ? TargetStunElf : TargetStun);
					if (actionType == CombatActionPackType.ChainRangeAttack)
						tAction.EffectFlags = EffectFlags.Unknown;

					cap.Add(tAction);

					// Damage
					var damage = attacker.GetRndRangedDamage();

					// Elementals
					damage *= attacker.CalculateElementalDamageMultiplier(target);

					// More damage with fire arrow
					// XXX: Does this affect the element?
					if (attacker.Temp.FireArrow)
						damage *= FireBonus;

					// Critical Hit
					var critChance = attacker.GetRightCritChance(target.Protection);
					CriticalHit.Handle(attacker, critChance, ref damage, tAction);

					// Subtract target def/prot
					SkillHelper.HandleDefenseProtection(target, ref damage);

					// Defense
					Defense.Handle(aAction, tAction, ref damage);

					// Mana Shield
					ManaShield.Handle(target, ref damage, tAction);

					// Natural Shield
					var delayReduction = NaturalShield.Handle(attacker, target, ref damage, tAction);

					// Deal with it!
					if (damage > 0)
					{
						target.TakeDamage(tAction.Damage = damage, attacker);
						SkillHelper.HandleInjury(attacker, target, damage);
					}

					// Knock down on deadly
					if (target.Conditions.Has(ConditionsA.Deadly))
					{
						tAction.Set(TargetOptions.KnockDown);
						tAction.Stun = (short)(actionType == CombatActionPackType.ChainRangeAttack ? TargetStunElf : TargetStun);
					}

					// Aggro
					target.Aggro(attacker);

					// Death/Knockback
					if (target.IsDead)
					{
						tAction.Set(TargetOptions.FinishingKnockDown);
						maxHits = 1;
					}
					else
					{
						// Insta-recover in knock down
						// TODO: Tied to stability?
						if (target.IsKnockedDown)
						{
							tAction.Stun = 0;
						}
						// Knock down if hit repeatedly
						else if (target.Stability < 30)
						{
							tAction.Set(TargetOptions.KnockDown);
						}
						// Normal stability reduction
						else
						{
							var stabilityReduction = (actionType == CombatActionPackType.ChainRangeAttack ? StabilityReductionElf : StabilityReduction);

							// Reduce reduction, based on ping
							// According to the Wiki, "the Knockdown Gauge
							// [does not] build up", but it's still possible
							// to knock back with repeated hits. The stability
							// reduction is probably reduced, just like stun.
							if (delayReduction > 0)
								stabilityReduction = (short)Math.Max(0, stabilityReduction - (stabilityReduction / 100 * delayReduction));

							target.Stability -= stabilityReduction;
							if (target.IsUnstable)
							{
								tAction.Set(TargetOptions.KnockBack);
							}
						}
					}

					// Knock Back
					if (tAction.IsKnockBack)
						attacker.Shove(target, KnockBackDistance);

					// Reduce stun, based on ping
					if (delayReduction > 0)
						tAction.Stun = (short)Math.Max(0, tAction.Stun - (tAction.Stun / 100 * delayReduction));
				}

				// Skill training
				if (skill.Info.Rank == SkillRank.Novice || skill.Info.Rank == SkillRank.RF)
					skill.Train(1); // Try ranged attack.

				// Reduce arrows
				if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && !attacker.Magazine.HasTag("/unlimited_arrow/"))
					attacker.Inventory.Decrement(attacker.Magazine);

				cap.Handle();
			}

			// Disable fire arrow effect
			if (attacker.Temp.FireArrow)
				Send.Effect(attacker, Effect.FireArrow, false);

			return CombatSkillResult.Okay;
		}
Пример #5
0
		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			// "Cancels" the skill
			// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
			Send.SkillUse(attacker, skill.Info.Id, AttackerStun, 1);

			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get().NextDouble() * 100;
			var successfulHit = (rnd < chance);

			// Actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, targetEntityId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = AttackerStun;
			cap.Add(aAction);

			// Target action if hit
			if (successfulHit)
			{
				target.StopMove();

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Set(TargetOptions.Result);
				tAction.Stun = TargetStun;

				cap.Add(tAction);

				// Damage
				// Formula unofficial, but it kinda matches what you would
				// expect from the skill, and what players believed the damage
				// to be, back in G2.
				// bonus = (100 - (6 - stacks) * 5 + rank, +var2 on last shot
				// I'm using rank instead of Var1, which goes from 1-15 in
				// AR2, so AR1 gets a little bonus as well, as AR1's Var1 and
				// 2 are 0.
				// With this formula, the bonus range (1st shot rF vs 5th shot
				// r1) is 76~110% for AR1, and 76~140% for AR2.
				var bonus = 100f - (6 - skill.Stacks) * 5f + (byte)skill.Info.Rank;
				if (skill.Stacks == 1)
					bonus += skill.RankData.Var2;

				var damage = attacker.GetRndRangedDamage() * (bonus / 100f);

				// Elementals
				damage *= attacker.CalculateElementalDamageMultiplier(target);

				// More damage with fire arrow
				if (attacker.Temp.FireArrow)
					damage *= FireBonus;

				// Critical Hit
				var critChance = attacker.GetRightCritChance(target.Protection);
				CriticalHit.Handle(attacker, critChance, ref damage, tAction);

				// Subtract target def/prot
				SkillHelper.HandleDefenseProtection(target, ref damage);

				// Defense
				Defense.Handle(aAction, tAction, ref damage);

				// Mana Shield
				ManaShield.Handle(target, ref damage, tAction);

				// Natural Shield
				var delayReduction = NaturalShield.Handle(attacker, target, ref damage, tAction);

				// Deal with it!
				if (damage > 0)
				{
					target.TakeDamage(tAction.Damage = damage, attacker);
					SkillHelper.HandleInjury(attacker, target, damage);
				}

				// Aggro
				target.Aggro(attacker);

				// Knock down on deadly
				if (target.Conditions.Has(ConditionsA.Deadly))
					tAction.Set(TargetOptions.KnockDown);

				// Death/Knockback
				if (target.IsDead)
				{
					tAction.Set(TargetOptions.FinishingKnockDown);
				}
				else
				{
					// Insta-recover in knock down
					if (target.IsKnockedDown)
					{
						tAction.Stun = 0;
					}
					// Knock down if hit repeatedly
					else if (target.Stability < 30)
					{
						tAction.Set(TargetOptions.KnockDown);
					}
					// Normal stability reduction
					else
					{
						var stabilityReduction = StabilityReduction;

						// Reduce reduction, based on ping
						// According to the Wiki, "the Knockdown Gauge
						// [does not] build up", but it's still possible
						// to knock back with repeated hits. The stability
						// reduction is probably reduced, just like stun.
						if (delayReduction > 0)
							stabilityReduction = (short)Math.Max(0, stabilityReduction - (stabilityReduction / 100 * delayReduction));

						target.Stability -= stabilityReduction;
						if (target.IsUnstable)
						{
							tAction.Set(TargetOptions.KnockBack);
						}
					}
				}

				// Knock Back
				if (tAction.IsKnockBack)
					attacker.Shove(target, KnockBackDistance);

				// Reduce stun, based on ping
				if (delayReduction > 0)
					tAction.Stun = (short)Math.Max(0, tAction.Stun - (tAction.Stun / 100 * delayReduction));
			}

			// Skill training
			if (skill.Info.Rank == SkillRank.RF)
				skill.Train(1); // Try attacking with Arrow Revolver.

			// Reduce arrows
			if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && !attacker.Magazine.HasTag("/unlimited_arrow/"))
				attacker.Inventory.Decrement(attacker.Magazine);

			// Reduce stack
			skill.Stacks--;

			// Handle
			cap.Handle();

			// Disable fire arrow effect
			if (attacker.Temp.FireArrow)
				Send.Effect(attacker, Effect.FireArrow, false);

			return CombatSkillResult.Okay;
		}
Пример #6
0
		/// <summary>
		/// Returns the raw damage to be done.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <returns></returns>
		protected float GetDamage(Creature attacker, Skill skill)
		{
			var result = attacker.GetRndRangedDamage();
			result *= skill.RankData.Var1 / 100f;

			return result;
		}