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

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

Checks if target has Defense skill activated and makes the necessary changes to the actions, stun times, and damage.
public static Handle ( AttackerAction aAction, TargetAction tAction, float &damage ) : bool
aAction AttackerAction
tAction TargetAction
damage float
Результат bool
		public static bool Handle(AttackerAction aAction, TargetAction tAction, ref float damage)
		{
			var defendingCreature = tAction.Creature;

			var activeSkill = defendingCreature.Skills.ActiveSkill;
			if (activeSkill == null || activeSkill.Info.Id != SkillId.Defense || activeSkill.State != SkillState.Ready)
				return false;

			activeSkill.State = SkillState.Used;

			// Update actions
			tAction.Flags = CombatActionType.Defended;
			tAction.Stun = DefenseTargetStun;
			aAction.Stun = DefenseAttackerStun;

			// Reduce damage
			damage = Math.Max(1, damage - activeSkill.RankData.Var3);

			// Proficiency
			var shield = defendingCreature.LeftHand;
			if (shield != null && shield.IsShield && shield.Durability != 0)
			{
				var amount = Item.GetProficiencyGain(defendingCreature.Age, ProficiencyGainType.Defend);
				defendingCreature.Inventory.AddProficiency(shield, amount);
			}

			// Updating unlock because of the updating lock for pre-renovation
			// Other skills actually unlock automatically on the client,
			// I guess this isn't the case for Defense because it's never
			// *explicitly* used.
			if (!AuraData.FeaturesDb.IsEnabled("TalentRenovationCloseCombat"))
			{
				defendingCreature.Unlock(Locks.Run, true);

				// For some reason the client won't actually unlock Run,
				// unless the unlock is sent twice.
				defendingCreature.Unlock(Locks.Run, true);
			}

			Send.SkillUseStun(defendingCreature, SkillId.Defense, DefenseTargetStun, 0);

			return true;
		}

Usage Example

Пример #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);
            }

            // "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)
            }

            // Update current weapon
            SkillHelper.UpdateWeapon(attacker, target, ProficiencyGainType.Ranged, attacker.RightHand);

            // 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);
        }
All Usage Examples Of Aura.Channel.Skills.Combat.Defense::Handle