/// <summary> /// Calculates the effect duration in milliseconds /// </summary> /// <param name="target">The effect target</param> /// <param name="effectiveness">The effect effectiveness</param> /// <returns>The effect duration in milliseconds</returns> protected override int CalculateEffectDuration(GameLiving target, double effectiveness) { double duration = base.CalculateEffectDuration(target, effectiveness); duration -= duration * target.GetResist(Spell.DamageType) * 0.01; if (duration < 1) duration = 1; else if (duration > (Spell.Duration * 4)) duration = (Spell.Duration * 4); return (int)duration; }
private void DamageTarget(GameLiving target, GameLiving caster) { double modifier = 0.5 + (caster.GetModifiedSpecLevel("Soulrending") * 0.01); int basedamage = (int)(250 * modifier); int resist = basedamage * target.GetResist(eDamageType.Spirit) / -100; int damage = basedamage + resist; int heal = (int)(damage * 0.75); int modheal = caster.MaxHealth - caster.Health; if (modheal > heal) { modheal = heal; } caster.Health += modheal; if (caster is GamePlayer player) { player.Out.SendMessage($"You hit {target.Name} for {damage}({resist}) points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); } if (caster is GamePlayer gamePlayer && modheal > 0) { gamePlayer.Out.SendMessage($"Your Soul Quench returns {modheal} lifepoints to you", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); } if (target is GamePlayer targetPlayer) { if (targetPlayer.IsStealthed) { targetPlayer.Stealth(false); } } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 1145, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } // target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData { AttackResult = GameLiving.eAttackResult.HitUnstyled, Attacker = caster, Target = target, DamageType = eDamageType.Spirit, Damage = damage }; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); }
/// <summary> /// Calculates the effect duration in milliseconds /// </summary> /// <param name="target">The effect target</param> /// <param name="effectiveness">The effect effectiveness</param> /// <returns>The effect duration in milliseconds</returns> protected override int CalculateEffectDuration(GameLiving target, double effectiveness) { double duration = base.CalculateEffectDuration(target, effectiveness); duration -= duration * target.GetResist(Spell.DamageType) * 0.01; if (duration < 1) { duration = 1; } else if (duration > (Spell.Duration * 4)) { duration = (Spell.Duration * 4); } return((int)duration); }
private void DamageTarget(GameLiving target, GameLiving caster, double counter) { int level = caster.GetModifiedSpecLevel("Stormcalling"); if (level > 50) { level = 50; } modifier = 0.5 + (level * 0.01) * Math.Pow(0.75, counter); basedamage = (int)(450 * modifier); resist = basedamage * target.GetResist(eDamageType.Energy) / -100; damage = basedamage + resist; GamePlayer player = caster as GamePlayer; if (player != null) { player.Out.SendMessage("You hit " + target.Name + " for " + damage + "(" + resist + ") points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); } GamePlayer targetPlayer = target as GamePlayer; if (targetPlayer != null) { if (targetPlayer.IsStealthed) { targetPlayer.Stealth(false); } } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 3505, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } //target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData(); ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.Attacker = caster; ad.Target = target; ad.DamageType = eDamageType.Energy; ad.Damage = damage; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); }
private void DamageTarget(GameLiving target, GameLiving caster, double counter) { int level = caster.GetModifiedSpecLevel("Stormcalling"); if (level > 50) { level = 50; } _modifier = 0.5 + (level * 0.01) * Math.Pow(0.75, counter); _basedamage = (int)(450 * _modifier); _resist = _basedamage * target.GetResist(eDamageType.Energy) / -100; _damage = _basedamage + _resist; if (caster is GamePlayer player) { player.Out.SendMessage($"You hit {target.Name} for {_damage}({_resist}) points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); } if (target is GamePlayer targetPlayer) { if (targetPlayer.IsStealthed) { targetPlayer.Stealth(false); } } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 3505, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } // target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData { AttackResult = GameLiving.eAttackResult.HitUnstyled, Attacker = caster, Target = target, DamageType = eDamageType.Energy, Damage = _damage }; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); }
protected override int CalculateEffectDuration(GameLiving target, double effectiveness) { double duration = Spell.Duration; duration *= (1.0 + m_caster.GetModified(eProperty.SpellDuration) * 0.01); duration -= duration * target.GetResist(Spell.DamageType) * 0.01; if (duration < 1) { duration = 1; } else if (duration > (Spell.Duration * 4)) { duration = (Spell.Duration * 4); } return((int)duration); }
private void DamageTarget(GameLiving target, GameLiving caster) { int resist = 251 * target.GetResist(eDamageType.Crush) / -100; int damage = 251 + resist; GamePlayer player = caster as GamePlayer; if (player != null) { player.Out.SendMessage("You hit " + target.Name + " for " + damage + "(" + resist + ") points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); } GamePlayer targetPlayer = target as GamePlayer; if (targetPlayer != null) { if (targetPlayer.IsStealthed) { targetPlayer.Stealth(false); } } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 7043, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } //target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData(); ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.Attacker = caster; ad.Target = target; ad.DamageType = eDamageType.Crush; ad.Damage = damage; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); if (target.EffectList.GetOfType <WhirlingStaffEffect>() == null) { WhirlingStaffEffect effect = new WhirlingStaffEffect(); effect.Start(target); } }
/// <summary> /// Calculates the effect duration in milliseconds /// </summary> /// <param name="target">The effect target</param> /// <param name="effectiveness">The effect effectiveness</param> /// <returns>The effect duration in milliseconds</returns> protected override int CalculateEffectDuration(GameLiving target, double effectiveness) { //TODO: duration depends on target resists (maybe body resist for all) // int resist = target.GetResist(m_spell.DamageType); double duration = base.CalculateEffectDuration(target, effectiveness); duration -= duration * target.GetResist(eDamageType.Body) * 0.01; if (duration < 1) { duration = 1; } else if (duration > (Spell.Duration * 4)) { duration = (Spell.Duration * 4); } return((int)duration); }
private void DamageTarget(GameLiving target, GameLiving caster) { double modifier = 0.5 + (caster.GetModifiedSpecLevel("Soulrending") * 0.01); int basedamage = (int)(250 * modifier); int resist = basedamage * target.GetResist(eDamageType.Spirit) / -100; int damage = basedamage + resist; int heal = (int)(damage * 0.75); int modheal = caster.MaxHealth - caster.Health; if (modheal > heal) modheal = heal; caster.Health += modheal; GamePlayer player = caster as GamePlayer; if (player != null) player.Out.SendMessage("You hit " + target.Name + " for " + damage + "(" + resist + ") points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); if (caster is GamePlayer && modheal > 0) ((GamePlayer)caster).Out.SendMessage("Your Soul Quench returns " + modheal + " lifepoints to you", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); GamePlayer targetPlayer = target as GamePlayer; if (targetPlayer != null) { if (targetPlayer.IsStealthed) targetPlayer.Stealth(false); } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 1145, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } //target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData(); ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.Attacker = caster; ad.Target = target; ad.DamageType = eDamageType.Spirit; ad.Damage = damage; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); }
private void DamageTarget(GameLiving target, GameLiving caster) { int resist = 251 * target.GetResist(eDamageType.Crush) / -100; int damage = 251 + resist; GamePlayer player = caster as GamePlayer; if (player != null) player.Out.SendMessage("You hit " + target.Name + " for " + damage + "(" + resist + ") points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); GamePlayer targetPlayer = target as GamePlayer; if (targetPlayer != null) { if (targetPlayer.IsStealthed) targetPlayer.Stealth(false); } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 7043, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } //target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData(); ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.Attacker = caster; ad.Target = target; ad.DamageType = eDamageType.Crush; ad.Damage = damage; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); if (target.EffectList.GetOfType<WhirlingStaffEffect>() == null) { WhirlingStaffEffect effect = new WhirlingStaffEffect(); effect.Start(target); } }
protected const int REUSE_TIMER = 60 * 2000; // 2 minutes /// <summary> /// Execute the ability /// </summary> /// <param name="ab">The ability executed</param> /// <param name="player">The player that used the ability</param> public void Execute(Ability ab, GamePlayer player) { if (player == null) { if (log.IsWarnEnabled) { log.Warn("Could not retrieve player in FlurryAbilityHandler."); } return; } #region precheck if (!player.IsAlive) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotUseDead"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (player.IsMezzed) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotUseMezzed"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (player.IsStunned) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotUseStunned"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (player.IsSitting) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotUseStanding"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (player.TargetObject == null) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotUseNoTarget"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!(player.TargetObject is GamePlayer || player.TargetObject is GameKeepGuard)) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Flurry.TargetNotPlayerOrGuards"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!GameServer.ServerRules.IsAllowedToAttack(player, (GameLiving)player.TargetObject, true)) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotAttackTarget", player.TargetObject.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!player.IsObjectInFront(player.TargetObject, 180) || !player.TargetInView) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.CannotSeeTarget", player.TargetObject.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!player.IsWithinRadius(player.TargetObject, 135)) //Didn't use AttackRange cause of the fact that player could use a Bow { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.TargetIsWithinRadius"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (player.TargetObject is GamePlayer && SpellHandler.FindEffectOnTarget((GamePlayer)player.TargetObject, "Phaseshift") != null) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.TargetIsPhaseshifted", player.TargetObject.Name), eChatType.CT_Missed, eChatLoc.CL_SystemWindow); return; } if (player.TargetObject is GamePlayer) { SputinsLegacyEffect SputinLegacy = (player.TargetObject as GamePlayer).EffectList.GetOfType <SputinsLegacyEffect>(); if (SputinLegacy != null) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.TargetIsUnderSputinLegacy", player.TargetObject.Name), eChatType.CT_Missed, eChatLoc.CL_SystemWindow); return; } } #endregion GameLiving target = (GameLiving)player.TargetObject; int damage = 0; int specc = (player.CharacterClass is PlayerClass.ClassBlademaster) ? player.GetModifiedSpecLevel(Specs.Celtic_Dual) : player.GetModifiedSpecLevel(Specs.Dual_Wield); //damage = base HP / 100 * DWspec / 2.7 that would be the original calculation if (target is GamePlayer) { damage = (int)(target.MaxHealth / 100 * specc / 4.5); // prev 3.5 } else { damage = (int)(target.MaxHealth / 100 * specc / 4.6); } // prev 3.6 #region Resists int primaryResistModifier = target.GetResist(eDamageType.Slash); //Using the resist BuffBonusCategory2 - its unused in ResistCalculator int secondaryResistModifier = target.SpecBuffBonusCategory[(int)eProperty.Resist_Slash]; int resistModifier = 0; //primary resists resistModifier += (int)(damage * (double)primaryResistModifier * -0.01); //secondary resists resistModifier += (int)((damage + (double)resistModifier) * (double)secondaryResistModifier * -0.01); //apply resists damage += resistModifier; #endregion //flurry is slash damage target.TakeDamage(player, eDamageType.Slash, damage, 0); GameSpellEffect mez = SpellHandler.FindEffectOnTarget(target, "Mesmerize"); if (mez != null) { mez.Cancel(false); } //sending spell effect foreach (GamePlayer effPlayer in target.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { effPlayer.Out.SendSpellEffectAnimation(player, target, 7103, 0, false, 0x01); } player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Flurry.YouHit", target.GetName(0, false), damage), eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); if (target is GamePlayer) { (target as GamePlayer).Out.SendMessage(LanguageMgr.GetTranslation((target as GamePlayer).Client, "Skill.Ability.Flurry.HitYou", player.Name, damage), eChatType.CT_Damaged, eChatLoc.CL_SystemWindow); } player.LastAttackTickPvP = player.CurrentRegion.Time; target.LastAttackedByEnemyTickPvP = target.CurrentRegion.Time; player.DisableSkill(ab, REUSE_TIMER); }
private void DamageTarget(GameLiving target, GameLiving caster, double counter) { int level = caster.GetModifiedSpecLevel("Stormcalling"); if (level > 50) level = 50; modifier = 0.5 + (level * 0.01) * Math.Pow(0.75, counter); basedamage = (int)(450 * modifier); resist = basedamage * target.GetResist(eDamageType.Energy) / -100; damage = basedamage + resist; GamePlayer player = caster as GamePlayer; if (player != null) player.Out.SendMessage("You hit " + target.Name + " for " + damage + "(" + resist + ") points of damage!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); GamePlayer targetPlayer = target as GamePlayer; if (targetPlayer != null) { if (targetPlayer.IsStealthed) targetPlayer.Stealth(false); } foreach (GamePlayer p in target.GetPlayersInRadius(false, WorldMgr.VISIBILITY_DISTANCE)) { p.Out.SendSpellEffectAnimation(caster, target, 3505, 0, false, 1); p.Out.SendCombatAnimation(caster, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } //target.TakeDamage(caster, eDamageType.Spirit, damage, 0); AttackData ad = new AttackData(); ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.Attacker = caster; ad.Target = target; ad.DamageType = eDamageType.Energy; ad.Damage = damage; target.OnAttackedByEnemy(ad); caster.DealDamage(ad); }
/// <summary> /// Called when a player is inflicted in an combat action /// </summary> /// <param name="e">The event which was raised</param> /// <param name="sender">Sender of the event</param> /// <param name="args">EventArgs associated with the event</param> private void AttackFinished(DOLEvent e, object sender, EventArgs args) { if (!(args is AttackFinishedEventArgs atkArgs)) { return; } if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } GameLiving target = atkArgs.AttackData.Target; if (target?.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } if (!(sender is GameLiving attacker)) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } var dpsCap = (1.2 + 0.3 * attacker.Level) * 0.7; double dps = Math.Min(Value, dpsCap); double damage = dps * atkArgs.AttackData.WeaponSpeed * 0.1; double damageResisted = damage * target.GetResist(eDamageType.Heat) * -0.01; AttackData ad = new AttackData { Attacker = attacker, Target = target, Damage = (int)(damage + damageResisted), Modifier = (int)damageResisted, DamageType = eDamageType.Heat, AttackType = AttackData.eAttackType.Spell, AttackResult = GameLiving.eAttackResult.HitUnstyled }; target.OnAttackedByEnemy(ad); _effectCaster.ChangeMana(_effectOwner, GameLiving.eManaChangeType.Spell, ad.Damage); (attacker as GamePlayer)?.Out.SendMessage($"You hit {target.Name} for {ad.Damage} extra damage!", PacketHandler.eChatType.CT_Spell, PacketHandler.eChatLoc.CL_SystemWindow); attacker.DealDamage(ad); }
/// <summary> /// Handler fired on every melee attack by effect target /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected override void EventHandler(DOLEvent e, object sender, EventArgs arguments) { AttackFinishedEventArgs atkArgs = arguments as AttackFinishedEventArgs; if (atkArgs == null) { return; } if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } GameLiving target = atkArgs.AttackData.Target; if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } if (target is GameKeepComponent || target is GameKeepDoor) { return; } GameLiving attacker = sender as GameLiving; if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } int spread = m_minDamageSpread; spread += Util.Random(50); double dpsCap = DPSCap(attacker.Level); double dps = IgnoreDamageCap ? Spell.Damage : Math.Min(Spell.Damage, dpsCap); double damage = dps * atkArgs.AttackData.WeaponSpeed * spread * 0.001; // attack speed is 10 times higher (2.5spd=25) double damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; // log.DebugFormat("dps: {0}, damage: {1}, damageResisted: {2}, minDamageSpread: {3}, spread: {4}", dps, damage, damageResisted, m_minDamageSpread, spread); if (Spell.Damage < 0) { damage = atkArgs.AttackData.Damage * Spell.Damage / -100.0; damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; } AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = Spell.DamageType; ad.AttackType = AttackData.eAttackType.Spell; ad.SpellHandler = this; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; if (ad.Attacker is GameNPC) { IControlledBrain brain = ((GameNPC)ad.Attacker).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); if (owner != null) { MessageToLiving(owner, String.Format(LanguageMgr.GetTranslation(owner.Client, "DamageAddAndShield.EventHandlerDA.YourHitFor"), ad.Attacker.Name, target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } } else { GameClient attackerClient = null; if (attacker is GamePlayer) { attackerClient = ((GamePlayer)attacker).Client; } if (attackerClient != null) { MessageToLiving(attacker, String.Format(LanguageMgr.GetTranslation(attackerClient, "DamageAddAndShield.EventHandlerDA.YouHitExtra"), target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } GameClient targetClient = null; if (target is GamePlayer) { targetClient = ((GamePlayer)target).Client; } if (targetClient != null) { MessageToLiving(target, String.Format(LanguageMgr.GetTranslation(targetClient, "DamageAddAndShield.EventHandlerDA.DamageToYou"), attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell); } target.OnAttackedByEnemy(ad); attacker.DealDamage(ad); foreach (GamePlayer player in ad.Attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (player == null) { continue; } player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x0A, target.HealthPercent); } }
/// <summary> /// Handler fired whenever effect target is attacked /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected override void EventHandler(DOLEvent e, object sender, EventArgs arguments) { AttackedByEnemyEventArgs args = arguments as AttackedByEnemyEventArgs; if (args == null) { return; } if (args.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && args.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } if (!args.AttackData.IsMeleeAttack) { return; } GameLiving attacker = sender as GameLiving; //sender is target of attack, becomes attacker for damage shield if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } GameLiving target = args.AttackData.Attacker; //attacker becomes target for damage shield if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } int spread = m_minDamageSpread; spread += Util.Random(50); double damage = Spell.Damage * target.AttackSpeed(target.AttackWeapon) * spread * 0.00001; double damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; if (Spell.Damage < 0) { damage = args.AttackData.Damage * Spell.Damage / -100.0; damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; } AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = Spell.DamageType; ad.SpellHandler = this; ad.AttackType = AttackData.eAttackType.Spell; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; GamePlayer owner = null; GameClient attackerClient = null; if (attacker is GamePlayer) { attackerClient = ((GamePlayer)attacker).Client; } if (ad.Attacker is GameNPC) { IControlledBrain brain = ((GameNPC)ad.Attacker).Brain as IControlledBrain; if (brain != null) { owner = brain.GetPlayerOwner(); if (owner != null && owner.ControlledBrain != null && ad.Attacker == owner.ControlledBrain.Body) { MessageToLiving(owner, String.Format(LanguageMgr.GetTranslation(owner.Client, "DamageAddAndShield.EventHandlerDS.YourHitFor"), ad.Attacker.Name, target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } } else if (attackerClient != null) { MessageToLiving(attacker, String.Format(LanguageMgr.GetTranslation(attackerClient, "DamageAddAndShield.EventHandlerDS.YouHitFor"), target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } GameClient targetClient = null; if (target is GamePlayer) { targetClient = ((GamePlayer)target).Client; } if (targetClient != null) { MessageToLiving(target, String.Format(LanguageMgr.GetTranslation(targetClient, "DamageAddAndShield.EventHandlerDS.DamageToYou"), attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell); } target.OnAttackedByEnemy(ad); attacker.DealDamage(ad); foreach (GamePlayer player in attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (player == null) { continue; } player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } // Log.Debug(String.Format("spell damage: {0}; damage: {1}; resisted damage: {2}; damage type {3}; minSpread {4}.", Spell.Damage, ad.Damage, ad.Modifier, ad.DamageType, m_minDamageSpread)); // Log.Debug(String.Format("dmg {0}; spread: {4}; resDmg: {1}; atkSpeed: {2}; resist: {3}.", damage, damageResisted, target.AttackSpeed(null), ad.Target.GetResist(Spell.DamageType), spread)); }
public override void Execute(GameLiving living) { if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED)) { return; } caster = living as GamePlayer; if (caster == null) { return; } if (caster.TargetObject == null) { caster.Out.SendMessage("You need a target for this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow); caster.DisableSkill(this, 3 * 1000); return; } if (!caster.TargetInView) { caster.Out.SendMessage(caster.TargetObject.Name + " is not in view.", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); caster.DisableSkill(this, 3 * 1000); return; } if (!caster.IsWithinRadius(caster.TargetObject, 1875)) { caster.Out.SendMessage(caster.TargetObject.Name + " is too far away.", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); caster.DisableSkill(this, 3 * 1000); return; } if (m_expireTimerID != null && m_expireTimerID.IsAlive) { caster.Out.SendMessage("You are already casting this ability.", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); caster.DisableSkill(this, 3 * 1000); return; } if (ServerProperties.Properties.USE_NEW_ACTIVES_RAS_SCALING) { switch (Level) { case 1: dmgValue = 150; duration = 10000; break; case 2: dmgValue = 275; duration = 15000; break; case 3: dmgValue = 400; duration = 20000; break; case 4: dmgValue = 500; duration = 25000; break; case 5: dmgValue = 600; duration = 30000; break; default: return; } } //150 dam/10 sec || 400/20 || 600/30 switch (Level) { case 1: dmgValue = 150; duration = 10000; break; case 2: dmgValue = 400; duration = 20000; break; case 3: dmgValue = 600; duration = 30000; break; default: return; } #region resist and det GameLiving m_target = caster.TargetObject as GameLiving; int primaryResistModifier = m_target.GetResist(eDamageType.Spirit); int secondaryResistModifier = m_target.SpecBuffBonusCategory[(int)eProperty.Resist_Spirit]; int rootdet = ((m_target.GetModified(eProperty.SpeedDecreaseDurationReduction) - 100) * -1); int ResistModifier = 0; ResistModifier += (int)((dmgValue * (double)primaryResistModifier) * -0.01); ResistModifier += (int)((dmgValue + (double)ResistModifier) * (double)secondaryResistModifier * -0.01); if (m_target is GamePlayer) { dmgValue += ResistModifier; } if (m_target is GameNPC) { dmgValue += ResistModifier; } int rootmodifier = 0; rootmodifier += (int)((duration * (double)primaryResistModifier) * -0.01); rootmodifier += (int)((duration + (double)primaryResistModifier) * (double)secondaryResistModifier * -0.01); rootmodifier += (int)((duration + (double)rootmodifier) * (double)rootdet * -0.01); duration += rootmodifier; if (duration < 1) { duration = 1; } #endregion foreach (GamePlayer i_player in caster.GetPlayersInRadius(WorldMgr.INFO_DISTANCE)) { if (i_player == caster) { i_player.MessageToSelf("You cast " + this.Name + "!", eChatType.CT_Spell); } else { i_player.MessageFromArea(caster, caster.Name + " casts a spell!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); } i_player.Out.SendSpellCastAnimation(caster, 7029, 20); } m_expireTimerID = new RegionTimer(caster, new RegionTimerCallback(EndCast), 2000); }
/// <summary> /// Called when a player is inflicted in an combat action /// </summary> /// <param name="e">The event which was raised</param> /// <param name="sender">Sender of the event</param> /// <param name="args">EventArgs associated with the event</param> private void AttackFinished(DOLEvent e, object sender, EventArgs args) { AttackFinishedEventArgs atkArgs = args as AttackFinishedEventArgs; if (atkArgs == null) { return; } if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } if (atkArgs.AttackData.Target == null) { return; } GameLiving target = atkArgs.AttackData.Target; if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } GameLiving attacker = sender as GameLiving; if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } double dpsCap; dpsCap = (1.2 + 0.3 * attacker.Level) * 0.7; double dps = Math.Min(RealmAbilities.MarkOfPreyAbility.VALUE, dpsCap); double damage = dps * atkArgs.AttackData.WeaponSpeed * 0.1; double damageResisted = damage * target.GetResist(eDamageType.Heat) * -0.01; AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = eDamageType.Heat; ad.AttackType = AttackData.eAttackType.Spell; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; target.OnAttackedByEnemy(ad); EffectCaster.ChangeMana(EffectOwner, GameLiving.eManaChangeType.Spell, (int)ad.Damage); if (attacker is GamePlayer) { (attacker as GamePlayer).Out.SendMessage(string.Format("You hit {0} for {1} extra damage!", target.Name, ad.Damage), DOL.GS.PacketHandler.eChatType.CT_Spell, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow); } attacker.DealDamage(ad); }
/// <summary> /// Calculates the effect duration in milliseconds /// </summary> /// <param name="target">The effect target</param> /// <param name="effectiveness">The effect effectiveness</param> /// <returns>The effect duration in milliseconds</returns> protected override int CalculateEffectDuration(GameLiving target, double effectiveness) { //TODO: duration depends on target resists (maybe body resist for all) // int resist = target.GetResist(m_spell.DamageType); double duration = base.CalculateEffectDuration(target, effectiveness); duration -= duration * target.GetResist(eDamageType.Body) * 0.01; if (duration < 1) duration = 1; else if (duration > (Spell.Duration * 4)) duration = (Spell.Duration * 4); return (int)duration; }
/// <summary> /// Handler fired on every melee attack by effect target /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected void EventHandler(DOLEvent e, object sender, EventArgs arguments) { AttackFinishedEventArgs atkArgs = arguments as AttackFinishedEventArgs; if (atkArgs == null) { return; } if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } if (atkArgs.AttackData.Target == null) { return; } GameLiving target = atkArgs.AttackData.Target; if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } GameLiving attacker = sender as GameLiving; if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } if (atkArgs.AttackData.IsOffHand) { return; // only react to main hand } if (atkArgs.AttackData.Weapon == null) { return; // no weapon attack } int modifier = 100; // double dpsCap = (1.2 + 0.3 * attacker.Level) * 0.7; // double dps = Math.Min(atkArgs.AttackData.Weapon.DPS_AF/10.0, dpsCap); double baseDamage = atkArgs.AttackData.Weapon.DPS_AF / 10.0 * atkArgs.AttackData.WeaponSpeed; modifier += (int)(25 * atkArgs.AttackData.Target.GetConLevel(atkArgs.AttackData.Attacker)); modifier = Math.Min(300, modifier); modifier = Math.Max(75, modifier); double damage = baseDamage * modifier * 0.001; // attack speed is 10 times higher (2.5spd=25) double damageResisted = damage * target.GetResist(eDamageType.Body) * -0.01; AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = eDamageType.Body; ad.AttackType = AttackData.eAttackType.MeleeOneHand; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; ad.WeaponSpeed = atkArgs.AttackData.WeaponSpeed; GamePlayer owner = attacker as GamePlayer; if (owner != null) { owner.Out.SendMessage(LanguageMgr.GetTranslation(owner.Client, "Effects.TripleWieldEffect.MBHitsExtraDamage", target.GetName(0, false), ad.Damage), eChatType.CT_Spell, eChatLoc.CL_SystemWindow); GamePlayer playerTarget = target as GamePlayer; if (playerTarget != null) { playerTarget.Out.SendMessage(LanguageMgr.GetTranslation(playerTarget.Client, "Effects.TripleWieldEffect.XMBExtraDamageToYou", attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell, eChatLoc.CL_SystemWindow); } } target.OnAttackedByEnemy(ad); attacker.DealDamage(ad); foreach (GamePlayer player in ad.Attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x0A, target.HealthPercent); } }