コード例 #1
0
ファイル: ManaShield.cs プロジェクト: KroneckerX/WCell
		public override void OnDefend(DamageAction action)
		{
			var defender = Owner;	// same as action.Victim
			var power = defender.Power;
			var damage = action.Damage;

			var drainAmount = Math.Min(damage, (int)(power * factorInverse));	// figure out how much to drain
			if (remaining < drainAmount)
			{
				// shield is used up
				drainAmount = remaining;
				remaining = 0;
				m_aura.Remove(false);
			}
			else
			{
				remaining -= drainAmount;
			}

			drainAmount = (int)(drainAmount * factor);

			var caster = Aura.CasterUnit;
			if (caster != null)
			{
				// see MageArcaneArcaneShielding
				drainAmount = caster.Auras.GetModifiedInt(SpellModifierType.HealingOrPowerGain, m_spellEffect.Spell, drainAmount);
			}
			defender.Power = power - drainAmount;					// drain power
			damage -= drainAmount;									// reduce damage

			action.Damage = damage;
		}
コード例 #2
0
 public override void OnDefend(DamageAction action)
 {
     if (m_spellEffect.Spell.SchoolMask.HasAnyFlag(action.UsedSchool))
     {
         action.ModDamagePercent(EffectValue);
     }
 }
コード例 #3
0
ファイル: RageGenerator.cs プロジェクト: ebakkedahl/WCell
        /// <summary>
        /// Rage for the attacker of an AttackAction
        /// </summary>
        public static void GenerateDefaultAttackerRage(DamageAction action)
        {
            var attacker = action.Attacker;

            // only generate Rage for white damage
            if (action.IsWeaponAttack)
            {
                double hitFactor;
                if (action.Weapon == attacker.OffHandWeapon)
                {
                    hitFactor = 1.75;
                }
                else
                {
                    hitFactor = 3.5;
                }
                if (action.IsCritical)
                {
                    hitFactor *= 2;
                }

                hitFactor *= action.Weapon.AttackTime;

                var lvl = attacker.Level;
                var c = 0.0092f * lvl * lvl + 3.23f * lvl + 4.27f;
                var rageRight = ((15 * action.ActualDamage / (4f * c)) + (hitFactor / 2000));
                var rageLeft = 15 * action.ActualDamage / c;

                var rage = rageRight;
                if (rageRight <= rageLeft)
                    rage = rageLeft;
                // Multiplied by 2 to match an approximate value, check the formula instead.
                attacker.Power += (int)(rage) * 10;
            }
        }
コード例 #4
0
ファイル: RageGenerator.cs プロジェクト: ebakkedahl/WCell
        /// <summary>
        /// Rage for the victim of an AttackAction
        /// </summary>
        public static void GenerateDefaultVictimRage(DamageAction action)
        {
            var victim = action.Victim;

            var lvl = victim.Level;
            var c = (int)(0.0092 * lvl * lvl + 3.23f * lvl + 4.27f);			// polynomial rage co-efficient
            victim.Power += (5 / 2 * action.ActualDamage / c) * 10;
        }
コード例 #5
0
		public override void OnAttack(DamageAction action)
		{
			//if (!action.IsDot)
			{
				var amount = action.GetDamagePercent(EffectValue);
				Owner.Heal(amount, m_aura.CasterUnit, m_spellEffect);
			}
		}
コード例 #6
0
ファイル: SchoolAbsorb.cs プロジェクト: NVN/WCell
		public override void OnDefend(DamageAction action)
		{
			RemainingValue = action.Absorb(RemainingValue, (DamageSchoolMask)m_spellEffect.MiscValue);
			if (RemainingValue <= 0)
			{
				Owner.AddMessage(m_aura.Cancel);
			}
		}
コード例 #7
0
 public override void OnAttack(DamageAction action)
 {
     if (action.Victim is NPC && ((NPC)action.Victim).CheckCreatureType(Mask))
     {
         // crit this guy
         action.IsCritical = true;
         action.SetCriticalDamage();
     }
 }
コード例 #8
0
 public override void OnDefend(DamageAction action)
 {
     // if damage was blocked and we are lucky, we double the block amount
     if (action.Blocked > 0 && EffectValue > Utility.Random(1, 101))
     {
         // crit block
         action.Blocked *= 2;
     }
 }
コード例 #9
0
		public override void OnDefend(DamageAction action)
		{
			action.Victim.AddMessage(() =>
			{
				if (action.Victim.MayAttack(action.Attacker))
				{
					action.Attacker.DealSpellDamage(action.Victim, SpellEffect, EffectValue);
				}
			});
		}
コード例 #10
0
ファイル: WarriorFixes.cs プロジェクト: KroneckerX/WCell
		public override void OnDefend(DamageAction action)
		{
			// strike back
			var victim = action.Victim;
			var atk = action.Attacker;
			if (!atk.IsBehind(victim))
			{
				victim.AddMessage(() =>
				{
					if (atk.IsInWorld && victim.MayAttack(atk))
					{
						victim.Strike(atk);
					}
				});
			}
		}
コード例 #11
0
ファイル: MageArcaneFixes.cs プロジェクト: remixod/netServer
			/// <summary>
			/// Register with OnAttack, since it's executed right after OnDefend, which is where
			/// Absorption handlers are handled.
			/// "When your Mana Shield, Frost Ward, Fire Ward, or Ice Barrier absorbs damage
			///  your spell damage is increased by $s1% of the amount absorbed for $44413d."
			/// </summary>
			public override void OnAttack(DamageAction action)
			{
				if (action.Absorbed > 0)
				{
					// apply aura
					Owner.SpellCast.TriggerSelf(SpellId.EffectClassSkillIncantersAbsorption);

					// retreive aura & handler
					var aura = Owner.Auras[SpellId.EffectClassSkillIncantersAbsorption];
					if (aura != null)
					{
						var handler = aura.GetHandler(AuraType.ModDamageDone) as ModDamageDoneHandler;
						if (handler != null)
						{
							// override effect value
							handler.BaseEffectValue = EffectValue;
						}
					}
				}
			}
コード例 #12
0
ファイル: ManaShield.cs プロジェクト: NVN/WCell
		public override void OnDefend(DamageAction action)
		{
			var defender = Owner;	// same as action.Victim
			var power = defender.Power;
			var damage = action.Damage;

			var amount = Math.Min(damage, (int)(power / factor));	// figure out how much to drain
			if (remaining < amount)
			{
				// shield is used up
				amount = remaining;
				remaining = 0;
				m_aura.Remove(false);
			}
			else
			{
				remaining -= amount;
			}
			defender.Power = power - (int)(amount * factor);	// drain power
			damage -= amount;									// reduce damage

			action.Damage = damage;
		}
コード例 #13
0
ファイル: DamageAction.cs プロジェクト: uvbs/Asda2-Server
        /// <summary>Strikes the target</summary>
        public void DoStrike()
        {
            if (this.Damage > 0)
            {
                this.ResistPct = DamageAction.CalcResistPrc(this.Victim.Asda2Defence, this.Damage, 0.0f);
                if ((double)this.ResistPct > 95.0)
                {
                    this.ResistPct = 95f;
                }
                if ((double)this.ResistPct < 0.0)
                {
                    this.ResistPct = 0.0f;
                }
                ++this.Victim.DeathPrevention;
                ++this.Attacker.DeathPrevention;
                try
                {
                    this.AddDamageMods();
                    this.Victim.OnDefend(this);
                    this.Attacker.OnAttack(this);
                    this.Resisted = MathUtil.RoundInt((float)((double)this.ResistPct * (double)this.Damage / 100.0));
                    this.Victim.DoRawDamage((IDamageAction)this);
                }
                finally
                {
                    --this.Victim.DeathPrevention;
                    --this.Attacker.DeathPrevention;
                }
            }

            if (this.SpellEffect == null)
            {
                Asda2CombatHandler.SendAttackerStateUpdate(this);
            }
            this.TriggerProcOnStrike();
        }
コード例 #14
0
ファイル: MageFireFixes.cs プロジェクト: remixod/netServer
			public override void OnAttack(DamageAction action)
			{
				if (action.IsMagic && TriggerSpells.Contains(action.Spell.Line.LineId))
				{
					if (!action.IsCritical)
					{
						critCount = 0;				// reset critCount
					}
					else
					{
						critCount++;
						if (critCount == 2)
						{
							// 2 crits in a row
							critCount = 0;			// reset critCount
							if (Utility.Random(0, 101) < EffectValue)
							{
								// we have a Hot Streak
								Owner.SpellCast.TriggerSelf(SpellId.HotStreak);
							}
						}
					}
				}
			}
コード例 #15
0
			public override void OnAttack(DamageAction action)
			{
				// "Your spells and abilities deal 4% more damage to targets infected with Blood Plague."
				if (action.SpellEffect != null && action.Victim.Auras.Contains(SpellId.EffectBloodPlague))
				{
					action.ModDamagePercent(EffectValue);
				}
			}
コード例 #16
0
			public override void OnDefend(DamageAction action)
			{
				// absorb EffectValue % from the damage
				var absorbed = Math.Min(action.GetDamagePercent(EffectValue), RemainingValue);

				// RemainingValue corresponds to AMZ's health, when it reaches 0, AMZ will be destroyed
				RemainingValue = action.Absorb(absorbed, (DamageSchoolMask)m_spellEffect.MiscValue);
			}
コード例 #17
0
			public override void OnAttack(DamageAction action)
			{
			}
コード例 #18
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		/// <summary>
		/// Do a single attack on the target using given weapon, ability and action.
		/// </summary>
		public ProcHitFlags Strike(IWeapon weapon, DamageAction action, Unit target, SpellCast ability)
		{
			ProcHitFlags procHitFlags = ProcHitFlags.None;

			EnsureContext();
			if (!IsAlive)
			{
				return procHitFlags;
			}

			if (!target.IsInContext || !target.IsAlive)
			{
				return procHitFlags;
			}

			if (weapon == null)
			{
				log.Error("Trying to strike without weapon: " + this);
				return procHitFlags;
			}

			//if (IsMovementControlled)
			//{
			//    // stop running when landing a hit
			//    m_Movement.Stop();
			//}

			target.IsInCombat = true;

			action.Victim = target;
			action.Attacker = this;
			action.Weapon = weapon;

			if (ability != null)
			{
				action.Schools = ability.Spell.SchoolMask;
				action.SpellEffect = ability.Spell.Effects[0];

				// calc damage
				GetWeaponDamage(action, weapon, ability);
				procHitFlags = action.DoAttack();
				if (ability.Spell.AttributesExC.HasFlag(SpellAttributesExC.RequiresTwoWeapons) && m_offhandWeapon != null)
				{
					// also strike with offhand
					action.Reset(this, target, m_offhandWeapon);
					GetWeaponDamage(action, m_offhandWeapon, ability);
					procHitFlags |= action.DoAttack();
					m_lastOffhandStrike = Environment.TickCount;
				}
			}
			else
			{
				// no combat ability
				m_extraAttacks += 1;
				do
				{
					// calc damage
					GetWeaponDamage(action, weapon, null);

					action.Schools = weapon.Damages.AllSchools();
					if (action.Schools == DamageSchoolMask.None)
					{
						action.Schools = DamageSchoolMask.Physical;
					}

					// normal attack
					action.DoAttack();
				} while (--m_extraAttacks > 0);
			}
			action.OnFinished();
			return procHitFlags;
		}
コード例 #19
0
			public override void OnAttack(DamageAction action)
			{
				// do nothing
			}
コード例 #20
0
ファイル: CombatHandler.cs プロジェクト: MeaNone/WCell
		public static void SendAttackerStateUpdate(DamageAction action)
		{
			if (!action.Attacker.IsAreaActive)
			{
				return;
			}
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ATTACKERSTATEUPDATE, 100))
			{
				var evade = action.VictimState == VictimState.Evade;
				if (evade)
				{
					//action.HitFlags |= HitFlags.HitFlag_0x800 | HitFlags.Absorb_1;
				}
				packet.Write((uint)action.HitFlags);
				action.Attacker.EntityId.WritePacked(packet);
				action.Victim.EntityId.WritePacked(packet);

				var dmg = action.ActualDamage;

				packet.Write(dmg);
				packet.Write(0);					// unknown (overkill?)

				//damage count
				const byte damageCount = 1;
				packet.Write(damageCount);

				for (byte i = 0; i < damageCount; i++)
				{
					packet.Write((uint)action.Schools);
					packet.Write((float)dmg);
					packet.Write(dmg);
				}

				if (action.HitFlags.HasAnyFlag(HitFlags.Absorb_1 | HitFlags.Absorb_2))
				{
					for (byte i = 0; i < damageCount; i++)
					{
						packet.Write(action.Absorbed);
					}
				}

				if (action.HitFlags.HasAnyFlag(HitFlags.Resist_1 | HitFlags.Resist_2))
				{
					for (byte i = 0; i < damageCount; i++)
					{
						packet.Write(action.Resisted);
					}
				}

				packet.Write((byte)action.VictimState);
				if (evade)
				{
					packet.Write(0x1000002);
				}
				else
				{
					packet.Write(dmg > 0 ? -1 : 0); // 0 if no damage, else -1 or 1000 or very rarely something else (eg when evading)
				}

				packet.Write(0);// this is a spell id

				if (action.HitFlags.HasAnyFlag(HitFlags.Block))
				{
					packet.Write(action.Blocked);
				}

				//if ((hitFlags & HitFlags.HitFlag_0x800000) != 0)
				//{
				//    packet.Write(0);
				//}

				//if ((hitFlags & HitFlags.HitFlag_0x1) != 0)
				//{
				//    packet.Write(0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    packet.Write((float)0);
				//    for (int i = 0; i < 5; i++)
				//    {
				//        packet.Write(0);
				//        packet.Write(0);
				//    }
				//    packet.Write(0);
				//}

				action.Victim.SendPacketToArea(packet, true);
			}
		}
コード例 #21
0
 public override void OnDefend(DamageAction action)
 {
 }
コード例 #22
0
ファイル: Character.cs プロジェクト: Skizot/WCell
		/// <summary>
		/// Adds all damage boni and mali
		/// </summary>
		public override void AddDamageMods(DamageAction action)
		{
			base.AddDamageMods(action);
			var dmg = UnitUpdates.GetMultiMod(GetInt32(PlayerFields.MOD_DAMAGE_DONE_PCT + (int)action.UsedSchool) / 100f, action.Damage);
			if (action.Spell != null)
			{
				dmg = PlayerSpells.GetModifiedInt(SpellModifierType.SpellPower, action.Spell, dmg);
			}

			dmg += GetDamageDoneMod(action.UsedSchool);
			action.Damage = dmg;
		}
コード例 #23
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		/// <summary>
		/// Adds damage mods to the given AttackAction
		/// </summary>
		public virtual void OnDefend(DamageAction action)
		{
			for (var i = AttackEventHandlers.Count - 1; i >= 0; i--)
			{
				var mod = AttackEventHandlers[i];
				mod.OnDefend(action);
			}
		}
コード例 #24
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		public void Strike(DamageAction action, Unit target)
		{
			Strike(MainWeapon, action, target);
		}
コード例 #25
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		/// <summary>
		/// Returns random damage for the given weapon
		/// </summary>
		public void GetWeaponDamage(DamageAction action, IWeapon weapon, SpellCast usedAbility, int targetNo = 0)
		{
			int damage;
			if (weapon == m_offhandWeapon)
			{
				damage = Utility.Random((int)MinOffHandDamage, (int)MaxOffHandDamage + 1);
			}
			else
			{
				if (weapon.IsRanged)
				{
					damage = Utility.Random((int)MinRangedDamage, (int)MaxRangedDamage + 1);
				}
				else
				{
					damage = Utility.Random((int)MinDamage, (int)MaxDamage + 1);
				}
			}

			if (this is NPC)
			{
				damage = (int)(damage * NPCMgr.DefaultNPCDamageFactor + 0.999999f);
			}

			if (usedAbility != null && usedAbility.IsCasting)
			{
				// get damage modifiers from spell
				var multiplier = 0;

				foreach (var effectHandler in usedAbility.Handlers)
				{
					if (effectHandler.Effect.IsStrikeEffectFlat)
					{
						damage += effectHandler.CalcDamageValue(targetNo);
					}
					else if (effectHandler.Effect.IsStrikeEffectPct)
					{
						multiplier += effectHandler.CalcDamageValue(targetNo);
					}
				}
				if (multiplier > 0)
				{
					action.Damage = (damage * multiplier + 50) / 100;
				}
				else
				{
					action.Damage = damage;
				}

				foreach (var effectHandler in usedAbility.Handlers)
				{
					if (effectHandler is WeaponDamageEffectHandler)
					{
						((WeaponDamageEffectHandler)effectHandler).OnHit(action);
					}
				}
			}
			else
			{
				action.Damage = damage;
			}
		}
コード例 #26
0
ファイル: MageFireFixes.cs プロジェクト: remixod/netServer
			public override void OnAttack(DamageAction action)
			{
				if (action.IsMagic)
				{
					// "Increases damage of all spells against targets with less than 35% health by $s1%."
					if (action.Victim.HealthPct <= 35)
					{
						action.Damage += action.GetDamagePercent(EffectValue);
					}
				}
			}
コード例 #27
0
ファイル: DruidFeralCombatFixes.cs プロジェクト: primax/WCell
		public override void OnHit(DamageAction action)
		{
			// "Effects which increase Bleed damage also increase Maul damage."
			var bleedBonusPct = action.Attacker.Auras.GetBleedBonusPercent();
			action.ModDamagePercent(bleedBonusPct);
		}
コード例 #28
0
ファイル: MageFireFixes.cs プロジェクト: remixod/netServer
			public override void OnAttack(DamageAction action)
			{
				if (action.IsMagic && action.IsCritical)
				{
					var owner = m_aura.CasterUnit;
					if (owner == null) return;

					// refund some of the mana
					owner.Power += (action.Spell.CalcPowerCost(owner, action.UsedSchool) * 100 + 50) / EffectValue;
				}
			}
コード例 #29
0
			public override void OnAttack(DamageAction action)
			{
				var attacker = action.Attacker;		// same as Owner
				var victim = action.Victim;
				var dmg = action.GetDamagePercent(EffectValue);
				victim.AddMessage(() => victim.DealSpellDamage(attacker, m_spellEffect, dmg, false, false));	// may not crit
			}
コード例 #30
0
			public override void OnDefend(DamageAction action)
			{
				// inflict damage upon block
				if (action.Blocked > 0)
				{
					var dmg = (action.Blocked * EffectValue + 50) / 100;
					var victim = action.Victim;
					var attacker = action.Attacker;

					victim.AddMessage(() =>
					{
						if (victim.MayAttack(attacker))
						{
							attacker.DealSpellDamage(victim, SpellEffect, dmg);
						}
					});
				}
			}
コード例 #31
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		/// <summary>
		/// Do a single attack using the given weapon and action on the target
		/// </summary>
		public void Strike(IWeapon weapon, DamageAction action, Unit target)
		{
			IsInCombat = true;
			if (UsesPendingAbility(weapon))
			{
				m_spellCast.Perform();
			}
			else
			{
				Strike(weapon, action, target, null);
			}
		}