Aura.Channel.Skills.Combat.HeavyStander.Handle C# (CSharp) Метод

Handle() публичный статический Метод

Handles Heavy Stander bonuses and auto-defense, reducing damage and setting the appropriate options on tAction. Returns whether or not Heavy Stander pinged.
All active and passive Heavy Standers are checked in sequence, followed by the equipment, with the passive damage reduction stacking. It's unknown whether this is official, and assumedly no monsters have multiple Heavy Stander skills. The ping reduction is only applied once, no matter where it came from.
public static Handle ( Creature attacker, Creature target, float &damage, TargetAction tAction ) : bool
attacker Aura.Channel.World.Entities.Creature
target Aura.Channel.World.Entities.Creature
damage float
tAction TargetAction
Результат bool
		public static bool Handle(Creature attacker, Creature target, ref float damage, TargetAction tAction)
		{
			var pinged = false;
			var rank = DefaultMsgRank;
			var rnd = RandomProvider.Get();

			// Dark Lord is immune to melee and magic damage,
			// like a R1 passive defense, but he doesn't ping.
			if (target.HasTag("/darklord/") && !target.HasTag("/darklord/darklord2/"))
			{
				damage = 1;
				return false;
			}

			// Monsters with the /beatable_only/ tag don't take damage from
			// anything but pillows. Pillows on the other hand do 3x damage.
			// (Guessed, based on event information and client data.)
			if (target.HasTag("/beatable_only/"))
			{
				var rightHand = attacker.RightHand;
				if (rightHand == null || !rightHand.HasTag("/pillow/"))
					damage = 1;
				else
					damage *= 3;
			}

			// Check skills
			for (int i = 0; i < Skills.Length; ++i)
			{
				// Check if skill exists and it's either in use or passive
				var skill = target.Skills.Get(Skills[i]);
				if (skill != null && (skill.Info.Id == SkillId.HeavyStanderPassive || skill.Has(SkillFlags.InUse)))
				{
					var damageReduction = skill.RankData.Var1;
					var activationChance = skill.RankData.Var3;

					// Apply damage reduction
					if (damageReduction > 0)
						damage = Math.Max(1, damage - (damage / 100 * damageReduction));

					// Apply auto defense
					if (!pinged && rnd.Next(100) < activationChance)
					{
						pinged = true;
						rank = skill.Info.Rank;
					}
				}
			}

			// Check equipment
			if (!pinged)
			{
				var equipment = target.Inventory.GetMainEquipment();
				for (int i = 0; i < equipment.Length; ++i)
				{
					var activationChance = equipment[i].Data.AutoDefenseMelee;

					// Add upgrades
					activationChance += equipment[i].MetaData1.GetFloat("IM_MLE") * 100;

					if (activationChance > 0 && rnd.Next(100) < activationChance)
					{
						pinged = true;
						break;
					}
				}
			}

			// Notice, flag, and damage reduction
			if (pinged)
			{
				damage = Math.Max(1, damage / 2);

				tAction.EffectFlags |= EffectFlags.HeavyStander;

				var msg = "";
				if (rank >= SkillRank.Novice && rank <= SkillRank.RA)
					msg = rnd.Rnd(Lv1Msgs);
				else if (rank >= SkillRank.R9 && rank <= SkillRank.R5)
					msg = rnd.Rnd(Lv2Msgs);
				else if (rank >= SkillRank.R4 && rank <= SkillRank.R1)
					msg = rnd.Rnd(Lv3Msgs);

				Send.Notice(attacker, msg);
			}

			return pinged;
		}
	}

Usage Example

Пример #1
0
        /// <summary>
        /// Uses WM, attacking targets.
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="skill"></param>
        /// <param name="targetAreaId"></param>
        /// <param name="unkInt1"></param>
        /// <param name="unkInt2"></param>
        public void Use(Creature attacker, Skill skill, long targetAreaId, int unkInt1, int unkInt2)
        {
            var range   = this.GetRange(attacker, skill);
            var targets = attacker.GetTargetableCreaturesInRange(range, TargetableOptions.AddAttackRange);

            // Check targets
            if (targets.Count == 0)
            {
                Send.Notice(attacker, Localization.Get("There isn't a target nearby to use that on."));
                Send.SkillUseSilentCancel(attacker);
                return;
            }

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

            var aAction = new AttackerAction(CombatActionType.SpecialHit, attacker, targetAreaId);

            aAction.Set(AttackerOptions.Result);
            aAction.Stun = CombatMastery.GetAttackerStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);

            cap.Add(aAction);

            var survived = new List <Creature>();
            var rnd      = RandomProvider.Get();

            // Check crit
            var crit = false;

            if (attacker.Skills.Has(SkillId.CriticalHit, SkillRank.RF))
            {
                crit = (rnd.Next(100) < attacker.GetTotalCritChance(0));
            }

            // Handle all targets
            foreach (var target in targets)
            {
                target.StopMove();

                var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
                tAction.Delay = 300;                 // Usually 300, sometimes 350?

                // Calculate damage
                var damage = attacker.GetRndTotalDamage();
                damage *= skill.RankData.Var1 / 100f;

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

                // Crit bonus
                if (crit)
                {
                    CriticalHit.Handle(attacker, 100, ref damage, tAction);
                }

                // Handle skills and reductions
                SkillHelper.HandleDefenseProtection(target, ref damage);
                SkillHelper.HandleConditions(attacker, target, ref damage);
                Defense.Handle(aAction, tAction, ref damage);
                ManaShield.Handle(target, ref damage, tAction);
                HeavyStander.Handle(attacker, target, ref damage, tAction);

                // Clean Hit if not defended nor critical
                if (tAction.SkillId != SkillId.Defense && !tAction.Has(TargetOptions.Critical))
                {
                    tAction.Set(TargetOptions.CleanHit);
                }

                // Take damage if any is left
                if (damage > 0)
                {
                    target.TakeDamage(tAction.Damage = damage, attacker);
                }

                // Knock down on deadly
                if (target.Conditions.Has(ConditionsA.Deadly))
                {
                    tAction.Set(TargetOptions.KnockDown);
                    tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
                }

                // Finish if dead, knock down if not defended
                if (target.IsDead)
                {
                    tAction.Set(TargetOptions.KnockDownFinish);
                }
                else if (tAction.SkillId != SkillId.Defense)
                {
                    tAction.Set(TargetOptions.KnockDown);
                }

                // Anger Management
                if (!target.IsDead)
                {
                    survived.Add(target);
                }

                // Stun and shove if not defended
                if (target.IsDead || tAction.SkillId != SkillId.Defense || target.Conditions.Has(ConditionsA.Deadly))
                {
                    tAction.Stun     = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
                    target.Stability = Creature.MinStability;
                    attacker.Shove(target, KnockbackDistance);
                }

                // Add action
                cap.Add(tAction);
            }

            // Update current weapon
            SkillHelper.UpdateWeapon(attacker, targets.FirstOrDefault(), ProficiencyGainType.Melee, attacker.RightHand, attacker.LeftHand);

            // Only select a random aggro if there is no aggro yet,
            // WM only aggroes one target at a time.
            if (survived.Count != 0 && attacker.Region.CountAggro(attacker) < 1)
            {
                var aggroTarget = survived.Random();
                aggroTarget.Aggro(attacker);
            }

            // Reduce life in old combat system
            if (!AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal"))
            {
                var amount = (attacker.LifeMax < 10 ? 2 : attacker.LifeMax / 10);
                attacker.ModifyLife(-amount);

                // TODO: Invincibility
            }

            // Spin it~
            Send.UseMotion(attacker, 8, 4);

            cap.Handle();

            Send.SkillUse(attacker, skill.Info.Id, targetAreaId, unkInt1, unkInt2);

            skill.Stacks = 0;
        }
All Usage Examples Of Aura.Channel.Skills.Combat.HeavyStander::Handle