/// <summary> /// Heals hit points of one target and sends needed messages, no spell effects /// </summary> /// <param name="target"></param> /// <param name="amount">amount of hit points to heal</param> /// <returns>true if heal was done</returns> public virtual bool HealTarget(GameLiving target, int amount) { if (target == null || target.ObjectState != GameObject.eObjectState.Active) { return(false); } // we can't heal people we can attack if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true)) { return(false); } if (!target.IsAlive) { // "You cannot heal the dead!" sshot550.tga MessageToCaster($"{target.GetName(0, true)} is dead!", eChatType.CT_SpellResisted); return(false); } int heal = target.ChangeMana(Caster, GameLiving.eManaChangeType.Spell, amount); if (heal == 0) { if (Spell.Pulse == 0) { if (target == Caster) { MessageToCaster("Your power is full.", eChatType.CT_SpellResisted); } else { MessageToCaster($"{target.GetName(0, true)} power is full.", eChatType.CT_SpellResisted); } } return(false); } if (Caster == target) { MessageToCaster($"You restore {heal} power points.", eChatType.CT_Spell); if (heal < amount) { MessageToCaster("Your power is full.", eChatType.CT_Spell); } } else { MessageToCaster($"You restore {target.GetName(0, false)} for {heal} power points!", eChatType.CT_Spell); MessageToLiving(target, $"Your power was restored by {Caster.GetName(0, false)} for {heal} points.", eChatType.CT_Spell); if (heal < amount) { MessageToCaster($"{target.GetName(0, true)} mana is full.", eChatType.CT_Spell); } } return(true); }
/// <summary> /// Heals hit points of one target and sends needed messages, no spell effects /// </summary> /// <param name="target"></param> /// <param name="amount">amount of hit points to heal</param> /// <returns>true if heal was done</returns> public virtual bool HealTarget(GameLiving target, int amount) { if (target == null || target.ObjectState != GameLiving.eObjectState.Active) { return(false); } // we can't heal people we can attack if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true)) { return(false); } if (!target.IsAlive) { //"You cannot heal the dead!" sshot550.tga MessageToCaster(target.GetName(0, true) + " is dead!", eChatType.CT_SpellResisted); return(false); } int heal = target.ChangeEndurance(Caster, GameLiving.eEnduranceChangeType.Spell, amount); if (heal == 0) { if (Spell.Pulse == 0) { if (target == m_caster) { MessageToCaster("Your endurance is full.", eChatType.CT_SpellResisted); } else { MessageToCaster(target.GetName(0, true) + " endurance is full.", eChatType.CT_SpellResisted); } } return(false); } if (m_caster == target) { MessageToCaster("You restore " + heal + " endurance points.", eChatType.CT_Spell); if (heal < amount) { MessageToCaster("Your endurance is full.", eChatType.CT_Spell); } } else { MessageToCaster("You restore " + target.GetName(0, false) + " for " + heal + " ednurance points!", eChatType.CT_Spell); MessageToLiving(target, "Your endurance was restored by " + m_caster.GetName(0, false) + " for " + heal + " points.", eChatType.CT_Spell); if (heal < amount) { MessageToCaster(target.GetName(0, true) + " endurance is full.", eChatType.CT_Spell); } } return(true); }
public override bool CasterIsAttacked(GameLiving attacker) { if (Spell.Uninterruptible) { return(false); } if (IsCasting && Stage < 2) { double mod = Caster.GetConLevel(attacker); double chance = 65; chance += mod * 10; chance = Math.Max(1, chance); chance = Math.Min(99, chance); if (attacker is GamePlayer) { chance = 100; } if (Util.Chance((int)chance)) { Caster.TempProperties.setProperty(INTERRUPT_TIMEOUT_PROPERTY, Caster.CurrentRegion.Time + Caster.SpellInterruptDuration); MessageToLiving(Caster, attacker.GetName(0, true) + " attacks you and your shot is interrupted!", eChatType.CT_SpellResisted); InterruptCasting(); return(true); } } return(true); }
public override void DoDamage() { GameLiving target = (TargetObject as GameLiving); if (target == null) { Owner.Out.SendMessage("Select a target first.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } //todo good distance check if (!this.IsWithinRadius(target, AttackRange)) { Owner.Out.SendMessage("You are too far away to attack " + target.Name, eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int damageAmount = RamDamage; //TODO: dps change by number target.TakeDamage(this, eDamageType.Crush, damageAmount, 0); Owner.Out.SendMessage("The Ram hits " + target.Name + " for " + damageAmount + " dmg!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); Message.SystemToArea(this, GetName(0, false) + " hits " + target.GetName(0, true), eChatType.CT_OthersCombat, Owner); base.DoDamage(); }
protected virtual void OnSpellResist(GameLiving target) { m_lastdamage -= m_lastdamage / 4; SendEffectAnimation(target, 0, false, 0); if (target is GameNPC) { IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); //Worthless checks if (owner != null /* && owner.ControlledNpc != null && target == owner.ControlledNpc.Body*/) { MessageToLiving(owner, "Your " + target.Name + " resists the effect!", eChatType.CT_SpellResisted); } } } else { MessageToLiving(target, "You resist the effect!", eChatType.CT_SpellResisted); } MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); if (Spell.Damage != 0) { // notify target about missed attack for spells with damage AttackData ad = new AttackData(); ad.Attacker = Caster; ad.Target = target; ad.AttackType = AttackData.eAttackType.Spell; ad.AttackResult = GameLiving.eAttackResult.Missed; ad.SpellHandler = this; target.OnAttackedByEnemy(ad); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, Caster); } else if (Spell.CastTime > 0) { target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); } if (target is GameNPC) { IOldAggressiveBrain aggroBrain = ((GameNPC)target).Brain as IOldAggressiveBrain; if (aggroBrain != null) { aggroBrain.AddToAggroList(Caster, 1); } } if (target.Realm == 0 || Caster.Realm == 0) { target.LastAttackedByEnemyTickPvE = target.CurrentRegion.Time; Caster.LastAttackTickPvE = Caster.CurrentRegion.Time; } else { target.LastAttackedByEnemyTickPvP = target.CurrentRegion.Time; Caster.LastAttackTickPvP = Caster.CurrentRegion.Time; } }
/// <summary> /// called when spell effect has to be started and applied to targets /// </summary> public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { var npcTarget = target as GameNPC; if (npcTarget == null) return; if (npcTarget.Level > Spell.Value) { // Resisted SendSpellResistAnimation(target); this.MessageToCaster(eChatType.CT_SpellResisted, "{0} is too strong for you to charm!", target.GetName(0, true)); return; } if (npcTarget.Brain is IControlledBrain) { SendSpellResistAnimation(target); this.MessageToCaster(eChatType.CT_SpellResisted, "{0} is already under control.", target.GetName(0, true)); return; } base.ApplyEffectOnTarget(target, effectiveness); }
/// <summary> /// Sends a message to all group members /// </summary> /// <param name="msg">message string</param> /// <param name="type">message type</param> /// <param name="loc">message location</param> public virtual void SendMessageToGroupMembers(GameLiving from, string msg, eChatType type, eChatLoc loc) { string message = msg; if (from != null) { message = "[Party] " + from.GetName(0, true) + ": \"" + message + "\""; } else { message = "[Party] " + message; } SendMessageToGroupMembers(message, type, loc); }
/// <summary> /// Sends a message to all group members with an object from /// </summary> /// <param name="from">GameLiving source of the message</param> /// <param name="msg">message string</param> /// <param name="type">message type</param> /// <param name="loc">message location</param> public virtual void SendMessageToGroupMembers(GameLiving from, string msg, eChatType type, eChatLoc loc) { string message; if (from != null) { message = string.Format("[Party] {0}: \"{1}\"", from.GetName(0, true), msg); } else { message = string.Format("[Party] {0}", msg); } SendMessageToGroupMembers(message, type, loc); }
/// <summary> /// Heals hit points of one target and sends needed messages, no spell effects /// </summary> /// <param name="target"></param> /// <param name="amount">amount of hit points to heal</param> /// <returns>true if heal was done</returns> public virtual bool HealTarget(GameLiving target, int amount) { if (target == null || target.ObjectState != GameLiving.eObjectState.Active) return false; // we can't heal people we can attack if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true)) return false; if (!target.IsAlive) { //"You cannot heal the dead!" sshot550.tga MessageToCaster(target.GetName(0, true) + " is dead!", eChatType.CT_SpellResisted); return false; } int heal = target.ChangeMana(Caster, GameLiving.eManaChangeType.Spell, amount); if (heal == 0) { if (Spell.Pulse == 0) { if (target == m_caster) MessageToCaster("Your power is full.", eChatType.CT_SpellResisted); else MessageToCaster(target.GetName(0, true) + " power is full.", eChatType.CT_SpellResisted); } return false; } if (m_caster == target) { MessageToCaster("You restore " + heal + " power points.", eChatType.CT_Spell); if (heal < amount) MessageToCaster("Your power is full.", eChatType.CT_Spell); } else { MessageToCaster("You restore " + target.GetName(0, false) + " for " + heal + " power points!", eChatType.CT_Spell); MessageToLiving(target, "Your power was restored by " + m_caster.GetName(0, false) + " for " + heal + " points.", eChatType.CT_Spell); if (heal < amount) MessageToCaster(target.GetName(0, true) + " mana is full.", eChatType.CT_Spell); } return true; }
/// <summary> /// Start the effect. /// </summary> /// <param name="target"></param> public override void Start(GameLiving target) { base.Start(target); GamePlayer petOwner = null; if (target is GameNPC && (target as GameNPC).Brain is IControlledBrain) petOwner = ((target as GameNPC).Brain as IControlledBrain).Owner as GamePlayer; foreach (GamePlayer player in target.GetPlayersInRadius(WorldMgr.INFO_DISTANCE)) { if (player == null) continue; player.Out.SendSpellEffectAnimation(target, target, 1073, 0, false, 1); eChatType chatType = (player != null && player == petOwner) ? eChatType.CT_Spell : eChatType.CT_System; player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Effects.Necro.TauntEffect.SeemsChange", target.GetName(0, true)), chatType, eChatLoc.CL_SystemWindow); } }
public override bool CasterIsAttacked(GameLiving attacker) { if (Spell.Uninterruptible && Caster.GetDistanceTo(attacker) > 200) { return(false); } if (Caster.EffectList.CountOfType(typeof(QuickCastEffect), typeof(MasteryofConcentrationEffect), typeof(FacilitatePainworkingEffect)) > 0) { return(false); } if (IsCasting && Stage < 2) { if (Caster.ChanceSpellInterrupt(attacker)) { Caster.LastInterruptMessage = attacker.GetName(0, true) + " attacks you and your spell is interrupted!"; MessageToLiving(Caster, Caster.LastInterruptMessage, eChatType.CT_SpellResisted); InterruptCasting(); // always interrupt at the moment return(true); } } return(false); }
/// <summary> /// Start the berserk on player /// </summary> public override void Start(GameLiving engageSource) { base.Start(engageSource); m_engageTarget = engageSource.TargetObject as GameLiving; engageSource.IsEngaging = true; if (m_owner is GamePlayer) (m_owner as GamePlayer).Out.SendMessage(LanguageMgr.GetTranslation((m_owner as GamePlayer).Client, "Effects.EngageEffect.ConcOnBlockingX", m_engageTarget.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); /* // only emulate attack mode so it works more like on live servers // entering real attack mode while engaging someone stops engage // other players will see attack mode after pos update packet is sent if (!m_owner.AttackState) { m_owner.StartAttack(m_engageTarget); if (m_owner is GamePlayer) (m_owner as GamePlayer).Out.SendAttackMode(true); //m_engageSource.Out.SendMessage("You enter combat mode to engage your target!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); //m_engageSource.Out.SendMessage("You enter combat mode and target ["+engageTarget.GetName(0, false)+"]", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow); } */ }
/// <summary> /// When spell was resisted /// </summary> /// <param name="target">the target that resisted the spell</param> protected virtual void OnSpellResisted(GameLiving target) { SendEffectAnimation(target, 0, false, 0); // Deliver message to the target, if the target is a pet, to its // owner instead. if (target is GameNPC) { IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); if (owner != null) { MessageToLiving(owner, "Your " + target.Name + " resists the effect!", eChatType.CT_SpellResisted); } } } else { MessageToLiving(target, "You resist the effect!", eChatType.CT_SpellResisted); } // Deliver message to the caster as well. MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); // Report resisted spell attack data to any type of living object, no need // to decide here what to do. For example, NPCs will use their brain. // "Just the facts, ma'am, just the facts." AttackData ad = new AttackData(); ad.Attacker = Caster; ad.Target = target; ad.AttackType = AttackData.eAttackType.Spell; ad.SpellHandler = this; ad.AttackResult = GameLiving.eAttackResult.Missed; ad.IsSpellResisted = true; target.OnAttackedByEnemy(ad); // Spells that would have caused damage or are not instant will still // interrupt a casting player. /*if (target is GamePlayer) { if (target.IsCasting && (Spell.Damage > 0 || Spell.CastTime > 0)) target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, Caster); }*/ if(!(Spell.SpellType.ToLower().IndexOf("debuff")>=0 && Spell.CastTime==0)) target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, Caster); if (target.Realm == 0 || Caster.Realm == 0) { target.LastAttackedByEnemyTickPvE = target.CurrentRegion.Time; Caster.LastAttackTickPvE = Caster.CurrentRegion.Time; } else { target.LastAttackedByEnemyTickPvP = target.CurrentRegion.Time; Caster.LastAttackTickPvP = Caster.CurrentRegion.Time; } }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) { return(false); } // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) { target = controlled.GetLivingOwner(); } } if (source == target) { return(true); } // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) { return(true); } // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) { return(true); } // mobs can heal mobs, players heal players/NPC if (source.Realm == 0 && target.Realm == 0) { return(true); } //keep guards if (source is GameKeepGuard && target is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(source as GameKeepGuard, target as GamePlayer)) { return(true); } } if (target is GameKeepGuard && source is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(target as GameKeepGuard, source as GamePlayer)) { return(true); } } //doors need special handling if (target is GameKeepDoor && source is GamePlayer) { return(GameServer.KeepManager.IsEnemy(target as GameKeepDoor, source as GamePlayer)); } if (source is GameKeepDoor && target is GamePlayer) { return(GameServer.KeepManager.IsEnemy(source as GameKeepDoor, target as GamePlayer)); } //components need special handling if (target is GameKeepComponent && source is GamePlayer) { return(GameServer.KeepManager.IsEnemy(target as GameKeepComponent, source as GamePlayer)); } //Peace flag NPCs are same realm if (target is GameNPC) { if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GameNPC) { if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GamePlayer && target is GamePlayer) { return(true); } if (source is GamePlayer && target is GameNPC && target.Realm != 0) { return(true); } if (quiet == false) { MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); } return(false); }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; switch (text) { case "song": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Bard, "Welcome then, " + source.GetName(0, false) + ", to the Bard's life. Here, take this. Keep it well, " + source.GetName(0, false) + ", for the tools of our trade can be quite expensive.", null); player.ReceiveItem(this,WEAPON_ID1); } break; } return true; }
//If mez resisted, just rupt, dont demez protected override void OnSpellResisted(GameLiving target) { // WHRIA // Flute Mez (pulse>0) if (this.Spell.Pulse > 0) { if (target != null && (!target.IsAlive)) { GameSpellEffect effect = SpellHandler.FindEffectOnTarget(target, this); if (effect != null) { effect.Cancel(false);//call OnEffectExpires CancelPulsingSpell(Caster, this.Spell.SpellType); MessageToCaster("You stop playing your song.", eChatType.CT_Spell); } return; } if (this.Spell.Range != 0) { if (!Caster.IsWithinRadius(target, this.Spell.Range)) { return; } } if (target != Caster.TargetObject) { return; } } GameSpellEffect mezz = SpellHandler.FindEffectOnTarget(target, "Mesmerize"); if (mezz != null) { MessageToCaster("Your target is already mezzed!!!", eChatType.CT_SpellResisted); return; } lock (target.EffectList) { foreach (IGameEffect effect in target.EffectList) { if (effect is GameSpellEffect) { GameSpellEffect gsp = (GameSpellEffect)effect; if (gsp is GameSpellAndImmunityEffect) { GameSpellAndImmunityEffect immunity = (GameSpellAndImmunityEffect)gsp; if (immunity.ImmunityState && target == immunity.Owner) { MessageToCaster(immunity.Owner.GetName(0, true) + " can't have that effect again yet!!!", eChatType.CT_SpellPulse); return; } } } } } // END SendEffectAnimation(target, 0, false, 0); MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); }
protected static void RemoveItem(GameLiving target, GamePlayer player, ItemTemplate itemTemplate, bool notify) { if (itemTemplate == null) { log.Error("itemtemplate is null in RemoveItem:" + Environment.StackTrace); return; } lock (player.Inventory) { InventoryItem item = player.Inventory.GetFirstItemByID(itemTemplate.Id_nb, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack); if (item != null) { player.Inventory.RemoveItem(item); InventoryLogging.LogInventoryAction(player, target, eInventoryActionType.Quest, item.Template, item.Count); if (target != null) { player.Out.SendMessage("You give the " + itemTemplate.Name + " to " + target.GetName(0, false), eChatType.CT_System, eChatLoc.CL_SystemWindow); } } else if (notify) { player.Out.SendMessage("You cannot remove the \"" + itemTemplate.Name + "\" because you don't have it.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } } }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) { return(false); } GamePlayer player = source as GamePlayer; switch (text) { case "Nightshade": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Nightshade, "Some would think you mad, choosing to walk through life as a Nightshade. It is not meant for everyone, but I think it will suit you, " + source.GetName(0, false) + ". Here, from me, a small gift to aid you in your journeys.", null); // TODO: gifts //"You receive Nightshade Initiate Boots from Lierna!" } break; } return(true); }
private bool SameRealm(GameClient client, GameLiving livingToCheck, bool usePvEPvPRule) { if (usePvEPvPRule) { if (livingToCheck.Realm != 0) { return(true); } } else { if (livingToCheck.Realm == client.Player.Realm) { return(true); } } // We cannot assist livings of an enemy realm. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.NoRealmMember", livingToCheck.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return(false); }
/// <summary> /// Apply effect on target or do spell action if non duration spell /// </summary> /// <param name="target">target that gets the effect</param> /// <param name="effectiveness">factor from 0..1 (0%-100%)</param> public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { // This prevent most of type casting errors if(target is GameNPC == false) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // check only if brain wasn't changed at least once if (m_controlledBrain == null) { // Target is already controlled if(((GameNPC)target).Brain != null && ((GameNPC)target).Brain is IControlledBrain && (((IControlledBrain)((GameNPC)target).Brain).Owner as GamePlayer) != Caster) { // TODO: proper message MessageToCaster("Your target is not valid.", eChatType.CT_SpellResisted); return; } // Already have a pet... if(Caster.ControlledBrain != null) { MessageToCaster("You already have a charmed creature, release it first!", eChatType.CT_SpellResisted); return; } // Body Type None (0) is used to make mobs un-charmable , Realm Guards or NPC cannot be charmed. if (target.Realm != 0 || ((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.None) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // If server properties prevent Named charm. if(ServerProperties.Properties.SPELL_CHARM_NAMED_CHECK != 0 && !target.Name[0].ToString().ToLower().Equals(target.Name[0].ToString())) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // Check if Body type applies if (m_spell.AmnesiaChance != (ushort)eCharmType.All) { bool charmable = false; // gets true only for charm-able mobs for this spell type switch((eCharmType)m_spell.AmnesiaChance) { case eCharmType.HumanoidAnimalInsectMagicalUndead : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Undead) charmable = true; goto case eCharmType.HumanoidAnimalInsectMagical; case eCharmType.HumanoidAnimalInsectMagical : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Magical) charmable = true; if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Plant) charmable = true; if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Elemental) charmable = true; goto case eCharmType.HumanoidAnimalInsect; case eCharmType.HumanoidAnimalInsect : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Insect) charmable = true; if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Reptile) charmable = true; goto case eCharmType.HumanoidAnimal; case eCharmType.HumanoidAnimal : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Animal) charmable = true; goto case eCharmType.Humanoid; case eCharmType.Humanoid : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Humanoid) charmable = true; break; case eCharmType.Animal : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Animal) charmable = true; break; case eCharmType.Insect : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Insect) charmable = true; break; case eCharmType.Reptile : if(((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Reptile) charmable = true; break; } // The NPC type doesn't match spell charm types. if(!charmable) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } } } // Spell.Value == Max Level this spell can charm, Spell.Damage == Max percent of the caster level this spell can charm if (target.Level > Spell.Value || target.Level > Caster.Level * Spell.Damage / 100) { MessageToCaster(target.GetName(0, true) + " is too strong for you to charm!", eChatType.CT_SpellResisted); return; } if (Caster is GamePlayer) { // base resists for all charm spells int resistChance = 100 - (85 + ((Caster.Level - target.Level) / 2)); if (this.Spell.Pulse != 0) // not permanent { /* * The Minstrel/Mentalist has an almost certain chance to charm/retain control of * a creature his level or lower, although there is a small random chance that it * could fail. The higher the level of the charmed creature compared to the * Minstrel/Mentalist, the greater the chance the monster has of breaking the charm. * Please note that your specialization level in the magic skill that contains the * charm spell will modify your base chance of charming and retaining control. * The higher your spec level, the greater your chance of controlling. */ int diffLevel = (int)(Caster.Level / 1.5 + Caster.GetModifiedSpecLevel(m_spellLine.Spec) / 3) - target.Level; if (diffLevel >= 0) { resistChance = 10 - diffLevel * 3; resistChance = Math.Max(resistChance, 1); } else { resistChance = 10 + diffLevel * diffLevel * 3; resistChance = Math.Min(resistChance, 99); } } if (Util.Chance(resistChance)) { MessageToCaster(target.GetName(0, true) + " resists the charm!", eChatType.CT_SpellResisted); return; } } base.ApplyEffectOnTarget(target, effectiveness); }
/// <summary> /// Apply effect on target or do spell action if non duration spell /// </summary> /// <param name="target">target that gets the effect</param> /// <param name="effectiveness">factor from 0..1 (0%-100%)</param> public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { // check only if brain wasn't changed at least once if (m_controlledBrain == null) { if (target.Realm != 0 || target is GameNPC == false) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } if (m_spell.AmnesiaChance != 0) { if (((GameNPC)target).BodyType != m_spell.AmnesiaChance) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } } else { //ToDo: Proper check for bodytypes but for now allowing ability to charm all bodytypes if amnesiachance is 0 so can have Bodytypes implemented without breaking charming - Sand if (target.Name != target.Name.ToLower()) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } } if (Caster.ControlledBrain != null) { MessageToCaster("You already have a charmed creature, release it first!", eChatType.CT_SpellResisted); return; } IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null && (brain.Owner as GamePlayer)!=Caster) { // TODO: proper message MessageToCaster("Your target is not valid.", eChatType.CT_SpellResisted); return; } } if (target.Level > Spell.Value || target.Level > Caster.Level * Spell.Damage / 100) { MessageToCaster(target.GetName(0, true) + " is too strong for you to charm!", eChatType.CT_SpellResisted); return; } if (Caster is GamePlayer) { int resistChance = 100 - (85 + ((Caster.Level - target.Level) / 2)); if (this.Spell.Pulse > 0) // not permanent { /* * The Minstrel/Mentalist has an almost certain chance to charm/retain control of * a creature his level or lower, although there is a small random chance that it * could fail. The higher the level of the charmed creature compared to the * Minstrel/Mentalist, the greater the chance the monster has of breaking the charm. * Please note that your specialization level in the magic skill that contains the * charm spell will modify your base chance of charming and retaining control. * The higher your spec level, the greater your chance of controlling. */ int diffLevel = (int)(Caster.Level / 1.5 + Caster.GetModifiedSpecLevel(m_spellLine.Spec) / 3) - target.Level; if (diffLevel >= 0) { resistChance = 10 - diffLevel * 3; resistChance = Math.Max(resistChance, 1); } else { resistChance = 10 + diffLevel * diffLevel * 3; resistChance = Math.Min(resistChance, 99); } } if (Util.Chance(resistChance)) { MessageToCaster(target.GetName(0, true) + " resists the charm!", eChatType.CT_SpellResisted); return; } } base.ApplyEffectOnTarget(target, effectiveness); }
public override void Execute(GameLiving living) { if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED)) return; GamePlayer player = living as GamePlayer; if (player == null) return; GamePlayer targetPlayer = null; bool isGoodTarget = true; if (player.TargetObject == null) { isGoodTarget = false; } else { targetPlayer = player.TargetObject as GamePlayer; if (targetPlayer == null || targetPlayer.IsAlive || GameServer.ServerRules.IsSameRealm(living, player.TargetObject as GameLiving, true) == false) { isGoodTarget = false; } } if (isGoodTarget == false) { player.Out.SendMessage("You have to target a dead member of your realm!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } switch (Level) { case 2: m_resurrectValue = 50; break; case 3: m_resurrectValue = 100; break; } GameLiving resurrectionCaster = targetPlayer.TempProperties.getProperty<object>(RESURRECT_CASTER_PROPERTY, null) as GameLiving; if (resurrectionCaster != null) { player.Out.SendMessage("Your target is already considering a resurrection!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if( !player.IsWithinRadius( targetPlayer, (int)( 1500 * player.GetModified(eProperty.SpellRange) * 0.01 ) ) ) { player.Out.SendMessage("You are too far away from your target to use this ability!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if (targetPlayer != null) { SendCasterSpellEffectAndCastMessage(living, 7019, true); DisableSkill(living); //Lifeflight: //don't rez just yet //ResurrectLiving(targetPlayer, player); //we need to add a dialogue response to the rez, copying from the rez spellhandler targetPlayer.TempProperties.setProperty(RESURRECT_CASTER_PROPERTY, living); RegionTimer resurrectExpiredTimer = new RegionTimer(targetPlayer); resurrectExpiredTimer.Callback = new RegionTimerCallback(ResurrectExpiredCallback); resurrectExpiredTimer.Properties.setProperty("targetPlayer", targetPlayer); resurrectExpiredTimer.Start(15000); lock (m_resTimersByLiving.SyncRoot) { m_resTimersByLiving.Add(player.TargetObject, resurrectExpiredTimer); } //send resurrect dialog targetPlayer.Out.SendCustomDialog("Do you allow " + living.GetName(0, true) + " to resurrect you\nwith " + m_resurrectValue +" percent hits?", new CustomDialogResponse(ResurrectResponceHandler)); } }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) { return(false); } GamePlayer player = source as GamePlayer; if (player == null) { return(false); } switch (text) { case "Vampiir": // promote player to other class if (CanPromotePlayer(player)) { player.RemoveAllSpellLines(); player.RemoveAllSpecs(); player.RemoveAllStyles(); player.Out.SendUpdatePlayerSkills(); PromotePlayer(player, (int)eCharacterClass.Vampiir, "Very well, " + source.GetName(0, false) + ". I gladly take your training into my hands. Congratulations, from this day forth, you are a Vampiir. Here, take this gift to aid you.", null); foreach (GamePlayer plr in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) // inform nearest clients about this player now is vampire (can fly) { if (plr != null) { plr.Out.SendVampireEffect(player, true); } } // drop any equiped-non usable item, in inventory or on the ground if full CheckAbilityToUseItem(player); } break; } return(true); }
public void ResurrectLiving(GamePlayer resurrectedPlayer, GameLiving rezzer) { if (rezzer.ObjectState != GameObject.eObjectState.Active) return; if (rezzer.CurrentRegionID != resurrectedPlayer.CurrentRegionID) return; resurrectedPlayer.Health = (int)(resurrectedPlayer.MaxHealth * m_resurrectValue / 100); resurrectedPlayer.Mana = (int)(resurrectedPlayer.MaxMana * m_resurrectValue / 100); resurrectedPlayer.Endurance = (int)(resurrectedPlayer.MaxEndurance * m_resurrectValue / 100); //no endurance after any rez resurrectedPlayer.MoveTo(rezzer.CurrentRegionID, rezzer.X, rezzer.Y, rezzer.Z, rezzer.Heading); GameLiving living = resurrectedPlayer as GameLiving; GameTimer resurrectExpiredTimer = null; lock (m_resTimersByLiving.SyncRoot) { resurrectExpiredTimer = (GameTimer)m_resTimersByLiving[living]; m_resTimersByLiving.Remove(living); } if (resurrectExpiredTimer != null) { resurrectExpiredTimer.Stop(); } resurrectedPlayer.StopReleaseTimer(); resurrectedPlayer.Out.SendPlayerRevive(resurrectedPlayer); resurrectedPlayer.UpdatePlayerStatus(); GameSpellEffect effect = SpellHandler.FindEffectOnTarget(resurrectedPlayer, GlobalSpells.PvERessurectionIllnessSpellType); if (effect != null) effect.Cancel(false); resurrectedPlayer.Out.SendMessage("You have been resurrected by " + rezzer.GetName(0, false) + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow); //Lifeflight: this should make it so players who have been ressurected don't take damage for 5 seconds RezDmgImmunityEffect rezImmune = new RezDmgImmunityEffect(); rezImmune.Start(resurrectedPlayer); //Lifeflight: We need to reward rez RPs GamePlayer casterPlayer = rezzer as GamePlayer; if (casterPlayer != null) { long rezRps = resurrectedPlayer.LastDeathRealmPoints * (m_resurrectValue + 50) / 1000; if (rezRps > 0) { casterPlayer.GainRealmPoints(rezRps); } else { casterPlayer.Out.SendMessage("The player you resurrected was not worth realm points on death.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); casterPlayer.Out.SendMessage("You thus get no realm points for the resurrect.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); } } }
/// <summary> /// Start the guarding on player /// </summary> /// <param name="guardSource">The guarder</param> /// <param name="guardTarget">The player guarded by guarder</param> public void Start(GameLiving guardSource, GameLiving guardTarget) { if (guardSource == null || guardTarget == null) { return; } if (guardSource is GamePlayer && guardTarget is GamePlayer) { m_playerGroup = ((GamePlayer)guardSource).Group; if (m_playerGroup == null) { return; } if (m_playerGroup != guardTarget.Group) { return; } GameEventMgr.AddHandler(m_playerGroup, GroupEvent.MemberDisbanded, new DOLEventHandler(GroupDisbandCallback)); } m_guardSource = guardSource; m_guardTarget = guardTarget; m_owner = m_guardSource; if (!guardSource.IsWithinRadius(guardTarget, GuardAbilityHandler.GUARD_DISTANCE)) { if (guardSource is GamePlayer) { ((GamePlayer)guardSource).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)guardSource).Client, "Effects.GuardEffect.YouAreNowGuardingYBut", guardTarget.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } if (guardSource is GamePlayer && guardTarget is GamePlayer) { ((GamePlayer)guardTarget).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)guardTarget).Client, "Effects.GuardEffect.XIsNowGuardingYouBut", guardSource.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } } else { if (guardSource is GamePlayer) { ((GamePlayer)guardSource).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)guardSource).Client, "Effects.GuardEffect.YouAreNowGuardingY", guardTarget.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } if (guardSource is GamePlayer && guardTarget is GamePlayer) { ((GamePlayer)guardTarget).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)guardTarget).Client, "Effects.GuardEffect.XIsNowGuardingYou", guardSource.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } } m_guardSource.EffectList.Add(this); m_guardTarget.EffectList.Add(this); }
/// <summary> /// Called when effect must be canceled /// </summary> public override void Cancel(bool playerCancel) { if (m_guardSource is GamePlayer && m_guardTarget is GamePlayer) { GameEventMgr.RemoveHandler(m_playerGroup, GroupEvent.MemberDisbanded, new DOLEventHandler(GroupDisbandCallback)); m_playerGroup = null; } m_guardSource.EffectList.Remove(this); m_guardTarget.EffectList.Remove(this); if (m_guardSource is GamePlayer) { ((GamePlayer)m_guardSource).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)m_guardSource).Client, "Effects.GuardEffect.YourNoLongerGuardingY", m_guardTarget.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } if (m_guardSource is GamePlayer && m_guardTarget is GamePlayer) { ((GamePlayer)m_guardTarget).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)m_guardTarget).Client, "Effects.GuardEffect.XNoLongerGuardingYoy", m_guardSource.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) { return(false); } if (!(source is GamePlayer player)) { return(false); } switch (text) { case "Path of Affinity": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Valewalker, "Welcome, then, to the Path of Affinity. Here is a gift. Consider it a welcoming gesture. Welcome, " + source.GetName(0, false) + ".", null); player.ReceiveItem(this, WeaponId1); } break; } return(true); }
/// <summary> /// Start the effect. /// </summary> /// <param name="target"></param> public override void Start(GameLiving target) { base.Start(target); GamePlayer petOwner = null; if (target is GameNPC && (target as GameNPC).Brain is IControlledBrain) { petOwner = ((target as GameNPC).Brain as IControlledBrain).Owner as GamePlayer; } foreach (GamePlayer player in target.GetPlayersInRadius(WorldMgr.INFO_DISTANCE)) { if (player == null) { continue; } player.Out.SendSpellEffectAnimation(target, target, 1073, 0, false, 1); eChatType chatType = (player != null && player == petOwner) ? eChatType.CT_Spell : eChatType.CT_System; player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Effects.Necro.TauntEffect.SeemsChange", target.GetName(0, true)), chatType, eChatLoc.CL_SystemWindow); } }
//If mez resisted, just rupt, dont demez protected override void OnSpellResisted(GameLiving target) { // WHRIA // Flute Mez (pulse>0) if (this.Spell.Pulse > 0) { if (target != null && (!target.IsAlive)) { GameSpellEffect effect = SpellHandler.FindEffectOnTarget(target, this); if (effect != null) { effect.Cancel(false);//call OnEffectExpires CancelPulsingSpell(Caster, this.Spell.SpellType); MessageToCaster("You stop playing your song.", eChatType.CT_Spell); } return; } if (this.Spell.Range != 0) { if (!Caster.IsWithinRadius(target, this.Spell.Range)) return; } if (target != Caster.TargetObject) return; } GameSpellEffect mezz = SpellHandler.FindEffectOnTarget(target, "Mesmerize"); if (mezz != null) { MessageToCaster("Your target is already mezzed!!!", eChatType.CT_SpellResisted); return; } lock (target.EffectList) { foreach (IGameEffect effect in target.EffectList) { if (effect is GameSpellEffect) { GameSpellEffect gsp = (GameSpellEffect)effect; if (gsp is GameSpellAndImmunityEffect) { GameSpellAndImmunityEffect immunity = (GameSpellAndImmunityEffect)gsp; if (immunity.ImmunityState && target == immunity.Owner) { MessageToCaster(immunity.Owner.GetName(0, true) + " can't have that effect again yet!!!", eChatType.CT_SpellPulse); return; } } } } } // END SendEffectAnimation(target, 0, false, 0); MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); }
//If mez resisted, just rupt, dont demez protected override void OnSpellResisted(GameLiving target) { SendEffectAnimation(target, 0, false, 0); MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); }
private void NoValidTarget(GameClient client, GameLiving livingToAssist) { // Original live text: {0} is not a member of your realm! // // The original text sounds stupid if we use it for rams or other things: The battle ram is not a member of your realm! // // But the text is also used for rams that are a member of our realm, so we don't use it. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.NotValid", livingToAssist.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; }
private void NoValidTarget(GameClient client, GameLiving livingToAssist) { //Original live text: {0} is not a member of your realm! // //The original text sounds stupid if we use it for rams or other things: The battle ram is not a member of your realm! // //But the text is also used for rams that are a member of our realm, so we don't use it. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.NotValid", livingToAssist.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; switch (text) { case "Path of Affinity": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Valewalker, "Welcome, then, to the Path of Affinity. Here is a gift. Consider it a welcoming gesture. Welcome, " + source.GetName(0, false) + ".", null); player.ReceiveItem(this,WEAPON_ID1); } break; } return true; }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) return false; // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) target = controlled.GetLivingOwner(); } if (source == target) return true; // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) return true; // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) return true; // mobs can heal mobs, players heal players/NPC if (source.Realm == 0 && target.Realm == 0) return true; //keep guards if (source is GameKeepGuard && target is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(source as GameKeepGuard, target as GamePlayer)) return true; } if (target is GameKeepGuard && source is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(target as GameKeepGuard, source as GamePlayer)) return true; } //doors need special handling if (target is GameKeepDoor && source is GamePlayer) return GameServer.KeepManager.IsEnemy(target as GameKeepDoor, source as GamePlayer); if (source is GameKeepDoor && target is GamePlayer) return GameServer.KeepManager.IsEnemy(source as GameKeepDoor, target as GamePlayer); //components need special handling if (target is GameKeepComponent && source is GamePlayer) return GameServer.KeepManager.IsEnemy(target as GameKeepComponent, source as GamePlayer); //Peace flag NPCs are same realm if (target is GameNPC) if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) return true; if (source is GameNPC) if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) return true; if (source is GamePlayer && target is GamePlayer) return true; if (source is GamePlayer && target is GameNPC && target.Realm != 0) return true; if (quiet == false) MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); return false; }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; switch (text) { case "Druid": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Druid, "The path of the Druid suits you, " + source.GetName(0, false) + ". Welcome. Take this, " + source.GetName(0, false) + ". You are a Druid now. Stick to our ways, and you shall go far.", null); player.ReceiveItem(this,ARMOR_ID1); } break; } return true; }
public override bool CheckBeginCast(GameLiving selectedTarget) { if (m_caster.ObjectState != GameLiving.eObjectState.Active) return false; if (!m_caster.IsAlive) { MessageToCaster("You are dead and can't cast!", eChatType.CT_System); return false; } // Is PS ? GameSpellEffect Phaseshift = SpellHandler.FindEffectOnTarget(Caster, "Phaseshift"); if (Phaseshift != null && (Spell.InstrumentRequirement == 0 || Spell.SpellType == "Mesmerize")) { MessageToCaster("You're phaseshifted and can't cast a spell", eChatType.CT_System); return false; } // Is Shield Disarm ? ShieldTripDisarmEffect shieldDisarm = Caster.EffectList.GetOfType<ShieldTripDisarmEffect>(); if (shieldDisarm != null) { MessageToCaster("You're disarmed and can't cast a spell", eChatType.CT_System); return false; } // Is Mentalist RA5L ? SelectiveBlindnessEffect SelectiveBlindness = Caster.EffectList.GetOfType<SelectiveBlindnessEffect>(); if (SelectiveBlindness != null) { GameLiving EffectOwner = SelectiveBlindness.EffectSource; if(EffectOwner==selectedTarget) { if (m_caster is GamePlayer) ((GamePlayer)m_caster).Out.SendMessage(string.Format("{0} is invisible to you!", selectedTarget.GetName(0, true)), eChatType.CT_Missed, eChatLoc.CL_SystemWindow); return false; } } // Is immune ? if (selectedTarget!=null&&selectedTarget.HasAbility("DamageImmunity")) { MessageToCaster(selectedTarget.Name + " is immune to this effect!", eChatType.CT_SpellResisted); return false; } if (m_caster.IsSitting) { MessageToCaster("You can't cast while sitting!", eChatType.CT_SpellResisted); return false; } if (m_spell.RecastDelay > 0) { int left = m_caster.GetSkillDisabledDuration(m_spell); if (left > 0) { MessageToCaster("You must wait " + (left / 1000 + 1).ToString() + " seconds to use this spell!", eChatType.CT_System); return false; } } String targetType = m_spell.Target.ToLower(); if (targetType == "area") { if (!m_caster.IsWithinRadius(m_caster.GroundTarget, CalculateSpellRange())) { MessageToCaster("Your area target is out of range. Select a closer target.", eChatType.CT_SpellResisted); return false; } } if (targetType == "enemy") { if (m_caster.IsObjectInFront(selectedTarget, 180) == false) { MessageToCaster("Your target is not in view!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView)); return false; } if (m_caster.TargetInView == false) { MessageToCaster("Your target is not visible!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView)); return false; } } if (Caster != null && Caster is GamePlayer && Caster.AttackWeapon != null && GlobalConstants.IsBowWeapon((eObjectType)Caster.AttackWeapon.Object_Type)) { if (Spell.LifeDrainReturn == (int)eShotType.Critical && (!(Caster.IsStealthed))) { MessageToCaster("You must be stealthed and wielding a bow to use this ability!", eChatType.CT_SpellResisted); return false; } return true; } else { if (Spell.LifeDrainReturn == (int)eShotType.Critical) { MessageToCaster("You must be stealthed and wielding a bow to use this ability!", eChatType.CT_SpellResisted); return false; } MessageToCaster("You must be wielding a bow to use this ability!", eChatType.CT_SpellResisted); return false; } }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; if (player == null) return false; switch (text) { case "Vampiir": // promote player to other class if (CanPromotePlayer(player)) { player.RemoveAllSpellLines(); player.RemoveAllSkills(); player.RemoveAllSpecs(); player.RemoveAllStyles(); player.Out.SendUpdatePlayerSkills(); player.SkillSpecialtyPoints = 14;//lvl 5 skill points full PromotePlayer(player, (int)eCharacterClass.Vampiir, "Very well, " + source.GetName(0, false) + ". I gladly take your training into my hands. Congratulations, from this day forth, you are a Vampiir. Here, take this gift to aid you.", null); foreach (GamePlayer plr in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) // inform nearest clients about this player now is vampire (can fly) if (plr != null) plr.Out.SendVampireEffect(player, true); // drop any equiped-non usable item, in inventory or on the ground if full CheckAbilityToUseItem(player); } break; } return true; }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) return false; // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) target = controlled.GetLivingOwner(); } if (source == target) return true; // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) return true; // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) return true; //Peace flag NPCs are same realm if (target is GameNPC) if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) return true; if (source is GameNPC) if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) return true; if (source.Realm != target.Realm) { if (quiet == false) MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); return false; } return true; }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) { return(false); } if (!(source is GamePlayer player)) { return(false); } switch (text) { case "Champion": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Champion, "Welcome " + source.GetName(0, false) + ". Let us see if you will become a worthy Champion. Take this gift, " + source.GetName(0, false) + ". It is to aid you while you grow into a true Champion.", null); player.ReceiveItem(this, ArmorId1); } break; } return(true); }
/// <summary> /// Called on every timer tick /// </summary> protected override void OnTick() { GameLiving target = m_boltTarget; GameLiving caster = (GameLiving)m_actionSource; if (target == null) { return; } if (target.CurrentRegionID != caster.CurrentRegionID) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (!target.IsAlive) { return; } // Related to PvP hitchance // http://www.camelotherald.com/news/news_article.php?storyid=2444 // No information on bolt hitchance against npc's // Bolts are treated as physical attacks for the purpose of ABS only // Based on this I am normalizing the miss rate for npc's to be that of a standard spell int missrate = 0; if (caster is GamePlayer && target is GamePlayer) { if (target.InCombat) { foreach (GameLiving attacker in target.Attackers) { if (attacker != caster && target.GetDistanceTo(attacker) <= 200) { // each attacker within 200 units adds a 20% chance to miss missrate += 20; } } } } if (target is GameNPC || caster is GameNPC) { missrate += (int)(ServerProperties.Properties.PVE_SPELL_CONHITPERCENT * caster.GetConLevel(target)); } // add defence bonus from last executed style if any AttackData targetAD = (AttackData)target.TempProperties.getProperty <object>(GameLiving.LAST_ATTACK_DATA, null); if (targetAD != null && targetAD.AttackResult == GameLiving.eAttackResult.HitStyle && targetAD.Style != null) { missrate += targetAD.Style.BonusToDefense; } AttackData ad = m_handler.CalculateDamageToTarget(target, 0.5 - (caster.GetModified(eProperty.SpellDamage) * 0.01)); if (Util.Chance(missrate)) { ad.AttackResult = GameLiving.eAttackResult.Missed; m_handler.MessageToCaster("You miss!", eChatType.CT_YouHit); m_handler.MessageToLiving(target, caster.GetName(0, false) + " missed!", eChatType.CT_Missed); target.OnAttackedByEnemy(ad); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, caster); if (target is GameNPC) { IOldAggressiveBrain aggroBrain = ((GameNPC)target).Brain as IOldAggressiveBrain; if (aggroBrain != null) { aggroBrain.AddToAggroList(caster, 1); } } return; } ad.Damage = (int)((double)ad.Damage * (1.0 + caster.GetModified(eProperty.SpellDamage) * 0.01)); // Block bool blocked = false; if (target is GamePlayer) { // mobs left out yet GamePlayer player = (GamePlayer)target; InventoryItem lefthand = player.Inventory.GetItem(eInventorySlot.LeftHandWeapon); if (lefthand != null && (player.AttackWeapon == null || player.AttackWeapon.Item_Type == Slot.RIGHTHAND || player.AttackWeapon.Item_Type == Slot.LEFTHAND)) { if (target.IsObjectInFront(caster, 180) && lefthand.Object_Type == (int)eObjectType.Shield) { double shield = 0.5 * player.GetModifiedSpecLevel(Specs.Shields); double blockchance = ((player.Dexterity * 2) - 100) / 40.0 + shield + 5; // Removed 30% increased chance to block, can find no clear evidence this is correct - tolakram blockchance -= target.GetConLevel(caster) * 5; if (blockchance >= 100) { blockchance = 99; } if (blockchance <= 0) { blockchance = 1; } if (target.IsEngaging) { EngageEffect engage = target.EffectList.GetOfType <EngageEffect>(); if (engage != null && target.AttackState && engage.EngageTarget == caster) { // Engage raised block change to 85% if attacker is engageTarget and player is in attackstate // You cannot engage a mob that was attacked within the last X seconds... if (engage.EngageTarget.LastAttackedByEnemyTick > engage.EngageTarget.CurrentRegion.Time - EngageAbilityHandler.ENGAGE_ATTACK_DELAY_TICK) { if (engage.Owner is GamePlayer) { (engage.Owner as GamePlayer).Out.SendMessage(engage.EngageTarget.GetName(0, true) + " has been attacked recently and you are unable to engage.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } } // Check if player has enough endurance left to engage else if (engage.Owner.Endurance < EngageAbilityHandler.ENGAGE_DURATION_LOST) { engage.Cancel(false); // if player ran out of endurance cancel engage effect } else { engage.Owner.Endurance -= EngageAbilityHandler.ENGAGE_DURATION_LOST; if (engage.Owner is GamePlayer) { (engage.Owner as GamePlayer).Out.SendMessage("You concentrate on blocking the blow!", eChatType.CT_Skill, eChatLoc.CL_SystemWindow); } if (blockchance < 85) { blockchance = 85; } } } } if (blockchance >= Util.Random(1, 100)) { m_handler.MessageToLiving(player, "You partially block " + caster.GetName(0, false) + "'s spell!", eChatType.CT_Missed); m_handler.MessageToCaster(player.GetName(0, true) + " blocks!", eChatType.CT_YouHit); blocked = true; } } } } double effectiveness = 1.0 + (caster.GetModified(eProperty.SpellDamage) * 0.01); // simplified melee damage calculation if (blocked == false) { // TODO: armor resists to damage type double damage = m_handler.Spell.Damage / 2; // another half is physical damage if (target is GamePlayer) { ad.ArmorHitLocation = ((GamePlayer)target).CalculateArmorHitLocation(ad); } InventoryItem armor = null; if (target.Inventory != null) { armor = target.Inventory.GetItem((eInventorySlot)ad.ArmorHitLocation); } double ws = (caster.Level * 8 * (1.0 + (caster.GetModified(eProperty.Dexterity) - 50) / 200.0)); damage *= ((ws + 90.68) / (target.GetArmorAF(ad.ArmorHitLocation) + 20 * 4.67)); damage *= 1.0 - Math.Min(0.85, ad.Target.GetArmorAbsorb(ad.ArmorHitLocation)); ad.Modifier = (int)(damage * (ad.Target.GetResist(ad.DamageType) + SkillBase.GetArmorResist(armor, ad.DamageType)) / -100.0); damage += ad.Modifier; damage = damage * effectiveness; damage *= (1.0 + RelicMgr.GetRelicBonusModifier(caster.Realm, eRelicType.Magic)); if (damage < 0) { damage = 0; } ad.Damage += (int)damage; } if (m_handler is SiegeArrow == false) { ad.UncappedDamage = ad.Damage; ad.Damage = (int)Math.Min(ad.Damage, m_handler.DamageCap(effectiveness)); } ad.Damage = (int)(ad.Damage * caster.Effectiveness); if (blocked == false && ad.CriticalDamage > 0) { int critMax = (target is GamePlayer) ? ad.Damage / 2 : ad.Damage; ad.CriticalDamage = Util.Random(critMax / 10, critMax); } m_handler.SendDamageMessages(ad); m_handler.DamageTarget(ad, false, (blocked ? 0x02 : 0x14)); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, caster); }
public override bool CasterIsAttacked(GameLiving attacker) { if (Spell.Uninterruptible) return false; if (IsCasting && Stage < 2) { double mod = Caster.GetConLevel(attacker); double chance = 65; chance += mod * 10; chance = Math.Max(1, chance); chance = Math.Min(99, chance); if (attacker is GamePlayer) chance = 100; if (Util.Chance((int)chance)) { Caster.TempProperties.setProperty(INTERRUPT_TIMEOUT_PROPERTY, Caster.CurrentRegion.Time + Caster.SpellInterruptDuration); MessageToLiving(Caster, attacker.GetName(0, true) + " attacks you and your shot is interrupted!", eChatType.CT_SpellResisted); InterruptCasting(); return true; } } return true; }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) { return(false); } // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) { target = controlled.GetLivingOwner(); } } if (source == target) { return(true); } // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) { return(true); } // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) { return(true); } //Peace flag NPCs are same realm if (target is GameNPC) { if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GameNPC) { if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source.Realm != target.Realm) { if (quiet == false) { MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); } return(false); } return(true); }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; switch (text) { case "Ranger": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Ranger, "Good then. Your path as a Ranger is before you. Walk it with care, friend. Take these, " + source.GetName(0, false) + ", to help make walking the path a bit easier.", null); player.ReceiveItem(this,WEAPON_ID1); } break; } return true; }
protected override void OnTick() { GameLiving target = m_arrowTarget; GameLiving caster = (GameLiving)m_actionSource; if (target == null || !target.IsAlive || target.ObjectState != GameObject.eObjectState.Active || target.CurrentRegionID != caster.CurrentRegionID) { return; } int missrate = 100 - m_handler.CalculateToHitChance(target); // add defence bonus from last executed style if any AttackData targetAD = (AttackData)target.TempProperties.getProperty <object>(GameLiving.LAST_ATTACK_DATA, null); if (targetAD != null && targetAD.AttackResult == GameLiving.eAttackResult.HitStyle && targetAD.Style != null) { missrate += targetAD.Style.BonusToDefense; } // half of the damage is magical // subtract any spelldamage bonus and re-calculate after half damage is calculated AttackData ad = m_handler.CalculateDamageToTarget(target, 0.5 - (caster.GetModified(eProperty.SpellDamage) * 0.01)); // check for bladeturn miss if (ad.AttackResult == GameLiving.eAttackResult.Missed) { return; } if (Util.Chance(missrate)) { ad.AttackResult = GameLiving.eAttackResult.Missed; m_handler.MessageToCaster("You miss!", eChatType.CT_YouHit); m_handler.MessageToLiving(target, caster.GetName(0, false) + " missed!", eChatType.CT_Missed); target.OnAttackedByEnemy(ad); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, caster); if (target is GameNPC) { IOldAggressiveBrain aggroBrain = ((GameNPC)target).Brain as IOldAggressiveBrain; if (aggroBrain != null) { aggroBrain.AddToAggroList(caster, 1); } } return; } ad.Damage = (int)((double)ad.Damage * (1.0 + caster.GetModified(eProperty.SpellDamage) * 0.01)); bool arrowBlock = false; if (target is GamePlayer && !target.IsStunned && !target.IsMezzed && !target.IsSitting && m_handler.Spell.LifeDrainReturn != (int)Archery.eShotType.Critical) { GamePlayer player = (GamePlayer)target; InventoryItem lefthand = player.Inventory.GetItem(eInventorySlot.LeftHandWeapon); if (lefthand != null && (player.AttackWeapon == null || player.AttackWeapon.Item_Type == Slot.RIGHTHAND || player.AttackWeapon.Item_Type == Slot.LEFTHAND)) { if (target.IsObjectInFront(caster, 180) && lefthand.Object_Type == (int)eObjectType.Shield) { // TODO: shield size vs number of attackers not calculated double shield = 0.5 * player.GetModifiedSpecLevel(Specs.Shields); double blockchance = ((player.Dexterity * 2) - 100) / 40.0 + shield + (0 * 3) + 5; blockchance += 30; blockchance -= target.GetConLevel(caster) * 5; if (blockchance >= 100) { blockchance = 99; } if (blockchance <= 0) { blockchance = 1; } if (target.IsEngaging) { EngageEffect engage = target.EffectList.GetOfType <EngageEffect>(); if (engage != null && target.AttackState && engage.EngageTarget == caster) { // Engage raised block change to 85% if attacker is engageTarget and player is in attackstate // You cannot engage a mob that was attacked within the last X seconds... if (engage.EngageTarget.LastAttackedByEnemyTick > engage.EngageTarget.CurrentRegion.Time - EngageAbilityHandler.ENGAGE_ATTACK_DELAY_TICK) { if (engage.Owner is GamePlayer) { (engage.Owner as GamePlayer).Out.SendMessage(engage.EngageTarget.GetName(0, true) + " has been attacked recently and you are unable to engage.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } } // Check if player has enough endurance left to engage else if (engage.Owner.Endurance < EngageAbilityHandler.ENGAGE_DURATION_LOST) { engage.Cancel(false); // if player ran out of endurance cancel engage effect } else { engage.Owner.Endurance -= EngageAbilityHandler.ENGAGE_DURATION_LOST; if (engage.Owner is GamePlayer) { (engage.Owner as GamePlayer).Out.SendMessage("You concentrate on blocking the blow!", eChatType.CT_Skill, eChatLoc.CL_SystemWindow); } if (blockchance < 85) { blockchance = 85; } } } } if (blockchance >= Util.Random(1, 100)) { arrowBlock = true; m_handler.MessageToLiving(player, "You block " + caster.GetName(0, false) + "'s arrow!", eChatType.CT_System); if (m_handler.Spell.Target.ToLower() != "area") { m_handler.MessageToCaster(player.GetName(0, true) + " blocks your arrow!", eChatType.CT_System); m_handler.DamageTarget(ad, false, 0x02); } } } } } if (arrowBlock == false) { // now calculate the magical part of arrow damage (similar to bolt calculation). Part 1 Physical, Part 2 Magical double damage = m_handler.Spell.Damage / 2; // another half is physical damage if (target is GamePlayer) { ad.ArmorHitLocation = ((GamePlayer)target).CalculateArmorHitLocation(ad); } InventoryItem armor = null; if (target.Inventory != null) { armor = target.Inventory.GetItem((eInventorySlot)ad.ArmorHitLocation); } double ws = (caster.Level * 8 * (1.0 + (caster.GetModified(eProperty.Dexterity) - 50) / 200.0)); damage *= ((ws + 90.68) / (target.GetArmorAF(ad.ArmorHitLocation) + 20 * 4.67)); damage *= 1.0 - Math.Min(0.85, ad.Target.GetArmorAbsorb(ad.ArmorHitLocation)); ad.Modifier = (int)(damage * (ad.Target.GetResist(ad.DamageType) + SkillBase.GetArmorResist(armor, ad.DamageType)) / -100.0); damage += ad.Modifier; double effectiveness = caster.Effectiveness; effectiveness += (caster.GetModified(eProperty.SpellDamage) * 0.01); damage = damage * effectiveness; damage *= (1.0 + RelicMgr.GetRelicBonusModifier(caster.Realm, eRelicType.Magic)); if (damage < 0) { damage = 0; } ad.Damage += (int)damage; if (caster.AttackWeapon != null) { // Quality ad.Damage -= (int)(ad.Damage * (100 - caster.AttackWeapon.Quality) * .01); // Condition ad.Damage = (int)((double)ad.Damage * Math.Min(1.0, (double)caster.AttackWeapon.Condition / (double)caster.AttackWeapon.MaxCondition)); // Patch Note: http://support.darkageofcamelot.com/kb/article.php?id=931 // - The Damage Per Second (DPS) of your bow will have an effect on your damage for archery shots. If the effective DPS // of your equipped bow is less than that of your max DPS for the level of archery shot you are using, the damage of your // shot will be reduced. Max DPS for a particular level can be found by using this equation: (.3 * level) + 1.2 int spellRequiredDPS = 12 + 3 * m_handler.Spell.Level; if (caster.AttackWeapon.DPS_AF < spellRequiredDPS) { double percentReduction = (double)caster.AttackWeapon.DPS_AF / (double)spellRequiredDPS; ad.Damage = (int)(ad.Damage * percentReduction); } } if (ad.Damage < 0) { ad.Damage = 0; } ad.UncappedDamage = ad.Damage; ad.Damage = (int)Math.Min(ad.Damage, m_handler.DamageCap(effectiveness)); if (ad.CriticalDamage > 0) { if (m_handler.Spell.Target.ToLower() == "area") { ad.CriticalDamage = 0; } else { int critMax = (target is GamePlayer) ? ad.Damage / 2 : ad.Damage; ad.CriticalDamage = Util.Random(critMax / 10, critMax); } } target.ModifyAttack(ad); m_handler.SendDamageMessages(ad); m_handler.DamageTarget(ad, false, 0x14); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, caster); } if (m_handler.Spell.SubSpellID != 0) { Spell subspell = SkillBase.GetSpellByID(m_handler.Spell.SubSpellID); if (subspell != null) { subspell.Level = m_handler.Spell.Level; ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_handler.Caster, subspell, SkillBase.GetSpellLine(GlobalSpellsLines.Combat_Styles_Effect)); if (spellhandler != null) { spellhandler.StartSpell(target); } } } if (arrowBlock == false && m_handler.Caster.AttackWeapon != null && GlobalConstants.IsBowWeapon((eObjectType)m_handler.Caster.AttackWeapon.Object_Type)) { if (ad.AttackResult == GameLiving.eAttackResult.HitUnstyled || ad.AttackResult == GameLiving.eAttackResult.HitStyle) { caster.CheckWeaponMagicalEffect(ad, m_handler.Caster.AttackWeapon); } } }
private bool HasTarget(GameClient client, GameLiving livingToCheck) { if (livingToCheck.TargetObject != null) return true; //We cannot assist our target when it has no target. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.DoesntHaveTarget", livingToCheck.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return false; }
/// <summary> /// A heal generated by an item proc. /// </summary> /// <param name="target"></param> /// <param name="amount"></param> /// <returns></returns> public virtual bool ProcHeal(GameLiving target, int amount) { if (target == null || target.ObjectState != GameLiving.eObjectState.Active) { return(false); } // we can't heal people we can attack if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true)) { return(false); } if (!target.IsAlive) { return(false); } // no healing of keep components if (target is Keeps.GameKeepComponent || target is Keeps.GameKeepDoor) { return(false); } int heal = target.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, amount); if (m_caster == target && heal > 0) { MessageToCaster("You heal yourself for " + heal + " hit points.", eChatType.CT_Spell); if (heal < amount) { MessageToCaster("You are fully healed.", eChatType.CT_Spell); #region PVP DAMAGE if (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer) { if (target.DamageRvRMemory > 0) { target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps } } #endregion PVP DAMAGE } } else if (heal > 0) { MessageToCaster("You heal " + target.GetName(0, false) + " for " + heal + " hit points!", eChatType.CT_Spell); MessageToLiving(target, "You are healed by " + m_caster.GetName(0, false) + " for " + heal + " hit points.", eChatType.CT_Spell); #region PVP DAMAGE if (heal < amount) { if (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer) { if (target.DamageRvRMemory > 0) { target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps } } } else { if (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer) { if (target.DamageRvRMemory > 0) { target.DamageRvRMemory -= (long)Math.Max(heal, 0); } } } } #endregion PVP DAMAGE return(true); }
private bool SameRealm(GameClient client, GameLiving livingToCheck, bool usePvEPvPRule) { if (usePvEPvPRule) { if (livingToCheck.Realm != 0) return true; } else { if (livingToCheck.Realm == client.Player.Realm) return true; } //We cannot assist livings of an enemy realm. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.NoRealmMember", livingToCheck.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return false; }
/// <summary> /// casting sequence has a chance for interrupt through attack from enemy /// the final decision and the interrupt is done here /// TODO: con level dependend /// </summary> /// <param name="attacker">attacker that interrupts the cast sequence</param> /// <returns>true if casting was interrupted</returns> public virtual bool CasterIsAttacked(GameLiving attacker) { //[StephenxPimentel] Check if the necro has MoC effect before interrupting. if (Caster is NecromancerPet) { if ((Caster as NecromancerPet).Owner.EffectList.GetOfType<MasteryofConcentrationEffect>() != null) { return false; } } if (Spell.Uninterruptible) return false; if (Caster.EffectList.CountOfType(typeof(QuickCastEffect), typeof(MasteryofConcentrationEffect), typeof(FacilitatePainworkingEffect)) > 0) return false; if (IsCasting && Stage < 2) { if (Caster.ChanceSpellInterrupt(attacker)) { Caster.LastInterruptMessage = attacker.GetName(0, true) + " attacks you and your spell is interrupted!"; MessageToLiving(Caster, Caster.LastInterruptMessage, eChatType.CT_SpellResisted); InterruptCasting(); // always interrupt at the moment return true; } } return false; }
/// <summary> /// All checks before any casting begins /// </summary> /// <param name="selectedTarget"></param> /// <returns></returns> public virtual bool CheckBeginCast(GameLiving selectedTarget, bool quiet) { if (m_caster.ObjectState != GameLiving.eObjectState.Active) { return false; } if (!m_caster.IsAlive) { if(!quiet) MessageToCaster("You are dead and can't cast!", eChatType.CT_System); return false; } if (m_caster is GamePlayer) { long nextSpellAvailTime = m_caster.TempProperties.getProperty<long>(GamePlayer.NEXT_SPELL_AVAIL_TIME_BECAUSE_USE_POTION); if (nextSpellAvailTime > m_caster.CurrentRegion.Time) { ((GamePlayer)m_caster).Out.SendMessage(LanguageMgr.GetTranslation(((GamePlayer)m_caster).Client, "GamePlayer.CastSpell.MustWaitBeforeCast", (nextSpellAvailTime - m_caster.CurrentRegion.Time) / 1000), eChatType.CT_System, eChatLoc.CL_SystemWindow); return false; } if (((GamePlayer)m_caster).Steed != null && ((GamePlayer)m_caster).Steed is GameSiegeRam) { if (!quiet) MessageToCaster("You can't cast in a siegeram!.", eChatType.CT_System); return false; } GameSpellEffect naturesWomb = FindEffectOnTarget(Caster, typeof(NaturesWombEffect)); if (naturesWomb != null) { //[StephenxPimentel] //Get Correct Message for 1.108 update. MessageToCaster("You are silenced and cannot cast a spell right now.", eChatType.CT_SpellResisted); return false; } } GameSpellEffect Phaseshift = FindEffectOnTarget(Caster, "Phaseshift"); if (Phaseshift != null && (Spell.InstrumentRequirement == 0 || Spell.SpellType == "Mesmerize")) { if (!quiet) MessageToCaster("You're phaseshifted and can't cast a spell", eChatType.CT_System); return false; } // Apply Mentalist RA5L if (Spell.Range>0) { SelectiveBlindnessEffect SelectiveBlindness = Caster.EffectList.GetOfType<SelectiveBlindnessEffect>(); if (SelectiveBlindness != null) { GameLiving EffectOwner = SelectiveBlindness.EffectSource; if(EffectOwner==selectedTarget) { if (m_caster is GamePlayer && !quiet) ((GamePlayer)m_caster).Out.SendMessage(string.Format("{0} is invisible to you!", selectedTarget.GetName(0, true)), eChatType.CT_Missed, eChatLoc.CL_SystemWindow); return false; } } } if (selectedTarget!=null && selectedTarget.HasAbility("DamageImmunity") && Spell.SpellType == "DirectDamage" && Spell.Radius == 0) { if (!quiet) MessageToCaster(selectedTarget.Name + " is immune to this effect!", eChatType.CT_SpellResisted); return false; } if (m_spell.InstrumentRequirement != 0) { if (!CheckInstrument()) { if (!quiet) MessageToCaster("You are not wielding the right type of instrument!", eChatType.CT_SpellResisted); return false; } } else if (m_caster.IsSitting) // songs can be played if sitting { //Purge can be cast while sitting but only if player has negative effect that //don't allow standing up (like stun or mez) if (!quiet) MessageToCaster("You can't cast while sitting!", eChatType.CT_SpellResisted); return false; } if (m_caster.AttackState && m_spell.CastTime != 0) { if (m_caster.CanCastInCombat(Spell) == false) { m_caster.StopAttack(); return false; } } if (!m_spell.Uninterruptible && m_spell.CastTime > 0 && m_caster is GamePlayer && m_caster.EffectList.GetOfType<QuickCastEffect>() == null && m_caster.EffectList.GetOfType<MasteryofConcentrationEffect>() == null) { if (Caster.InterruptAction > 0 && Caster.InterruptAction + Caster.SpellInterruptRecastTime > Caster.CurrentRegion.Time) { if (!quiet) MessageToCaster("You must wait " + (((Caster.InterruptAction + Caster.SpellInterruptRecastTime) - Caster.CurrentRegion.Time) / 1000 + 1).ToString() + " seconds to cast a spell!", eChatType.CT_SpellResisted); return false; } } if (m_spell.RecastDelay > 0) { int left = m_caster.GetSkillDisabledDuration(m_spell); if (left > 0) { if (m_caster is NecromancerPet && ((m_caster as NecromancerPet).Owner as GamePlayer).Client.Account.PrivLevel > (int)ePrivLevel.Player) { // Ignore Recast Timer } else { if (!quiet) MessageToCaster("You must wait " + (left / 1000 + 1).ToString() + " seconds to use this spell!", eChatType.CT_System); return false; } } } String targetType = m_spell.Target.ToLower(); //[Ganrod] Nidel: Can cast pet spell on all Pet/Turret/Minion (our pet) if (targetType.Equals("pet")) { if (selectedTarget == null || !Caster.IsControlledNPC(selectedTarget as GameNPC)) { if (Caster.ControlledBrain != null && Caster.ControlledBrain.Body != null) { selectedTarget = Caster.ControlledBrain.Body; } else { if (!quiet) MessageToCaster("You must cast this spell on a creature you are controlling.", eChatType.CT_System); return false; } } } if (targetType == "area") { if (!m_caster.IsWithinRadius(m_caster.GroundTarget, CalculateSpellRange())) { if (!quiet) MessageToCaster("Your area target is out of range. Select a closer target.", eChatType.CT_SpellResisted); return false; } if (!Caster.GroundTargetInView) { MessageToCaster("Your ground target is not in view!", eChatType.CT_SpellResisted); return false; } } else if (targetType != "self" && targetType != "group" && targetType != "pet" && targetType != "controlled" && targetType != "cone" && m_spell.Range > 0) { // All spells that need a target. if (selectedTarget == null || selectedTarget.ObjectState != GameLiving.eObjectState.Active) { if (!quiet) MessageToCaster("You must select a target for this spell!", eChatType.CT_SpellResisted); return false; } if (!m_caster.IsWithinRadius(selectedTarget, CalculateSpellRange())) { if(Caster is GamePlayer && !quiet) MessageToCaster("That target is too far away!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetTooFarAway)); return false; } switch (m_spell.Target.ToLower()) { case "enemy": if (selectedTarget == m_caster) { if (!quiet) MessageToCaster("You can't attack yourself! ", eChatType.CT_System); return false; } if (FindStaticEffectOnTarget(selectedTarget, typeof(NecromancerShadeEffect)) != null) { if (!quiet) MessageToCaster("Invalid target.", eChatType.CT_System); return false; } if (m_spell.SpellType == "Charm" && m_spell.CastTime == 0 && m_spell.Pulse != 0) break; if (m_caster.IsObjectInFront(selectedTarget, 180) == false) { if (!quiet) MessageToCaster("Your target is not in view!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView)); return false; } if (m_caster.TargetInView == false) { if (!quiet) MessageToCaster("Your target is not visible!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView)); return false; } if (!GameServer.ServerRules.IsAllowedToAttack(Caster, selectedTarget, quiet)) { return false; } break; case "corpse": if (selectedTarget.IsAlive || !GameServer.ServerRules.IsSameRealm(Caster, selectedTarget, true)) { if (!quiet) MessageToCaster("This spell only works on dead members of your realm!", eChatType.CT_SpellResisted); return false; } break; case "realm": if (GameServer.ServerRules.IsAllowedToAttack(Caster, selectedTarget, true)) { return false; } break; } //heals/buffs/rez need LOS only to start casting if (!m_caster.TargetInView && m_spell.Target.ToLower() != "pet") { if (!quiet) MessageToCaster("Your target is not in visible!", eChatType.CT_SpellResisted); Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView)); return false; } if (m_spell.Target.ToLower() != "corpse" && !selectedTarget.IsAlive) { if (!quiet) MessageToCaster(selectedTarget.GetName(0, true) + " is dead!", eChatType.CT_SpellResisted); return false; } } //Ryan: don't want mobs to have reductions in mana if (Spell.Power != 0 && m_caster is GamePlayer && (m_caster as GamePlayer).CharacterClass.ID != (int)eCharacterClass.Savage && m_caster.Mana < PowerCost(selectedTarget) && Spell.SpellType != "Archery") { if (!quiet) MessageToCaster("You don't have enough power to cast that!", eChatType.CT_SpellResisted); return false; } if (m_caster is GamePlayer && m_spell.Concentration > 0) { if (m_caster.Concentration < m_spell.Concentration) { if (!quiet) MessageToCaster("This spell requires " + m_spell.Concentration + " concentration points to cast!", eChatType.CT_SpellResisted); return false; } if (m_caster.ConcentrationEffects.ConcSpellsCount >= 50) { if (!quiet) MessageToCaster("You can only cast up to 50 simultaneous concentration spells!", eChatType.CT_SpellResisted); return false; } } // Cancel engage if user starts attack if (m_caster.IsEngaging) { EngageEffect engage = m_caster.EffectList.GetOfType<EngageEffect>(); if (engage != null) { engage.Cancel(false); } } if (!(Caster is GamePlayer)) { Caster.Notify(GameLivingEvent.CastSucceeded, this, new PetSpellEventArgs(Spell, SpellLine, selectedTarget)); } return true; }
public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { // This prevent most of type casting errors if (target is GameNPC == false) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // check only if brain wasn't changed at least once if (m_controlledBrain == null) { // Target is already controlled if (((GameNPC)target).Brain != null && ((GameNPC)target).Brain is IControlledBrain && (((IControlledBrain)((GameNPC)target).Brain).Owner as GamePlayer) != Caster) { // TODO: proper message MessageToCaster("Your target is not valid.", eChatType.CT_SpellResisted); return; } // Already have a pet... if (Caster.ControlledBrain != null) { MessageToCaster("You already have a charmed creature, release it first!", eChatType.CT_SpellResisted); return; } // Body Type None (0) is used to make mobs un-charmable , Realm Guards or NPC cannot be charmed. if (target.Realm != 0 || ((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.None) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // If server properties prevent Named charm. if (ServerProperties.Properties.SPELL_CHARM_NAMED_CHECK != 0 && !target.Name[0].ToString().ToLower().Equals(target.Name[0].ToString())) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } // Check if Body type applies if (m_spell.AmnesiaChance != (ushort)eCharmType.All) { bool charmable = false; // gets true only for charm-able mobs for this spell type switch ((eCharmType)m_spell.AmnesiaChance) { case eCharmType.HumanoidAnimalInsectMagicalUndead: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Undead) { charmable = true; } goto case eCharmType.HumanoidAnimalInsectMagical; case eCharmType.HumanoidAnimalInsectMagical: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Magical) { charmable = true; } if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Plant) { charmable = true; } if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Elemental) { charmable = true; } goto case eCharmType.HumanoidAnimalInsect; case eCharmType.HumanoidAnimalInsect: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Insect) { charmable = true; } if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Reptile) { charmable = true; } goto case eCharmType.HumanoidAnimal; case eCharmType.HumanoidAnimal: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Animal) { charmable = true; } goto case eCharmType.Humanoid; case eCharmType.Humanoid: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Humanoid) { charmable = true; } break; case eCharmType.Animal: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Animal) { charmable = true; } break; case eCharmType.Insect: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Insect) { charmable = true; } break; case eCharmType.Reptile: if (((GameNPC)target).BodyType == (ushort)NpcTemplateMgr.eBodyType.Reptile) { charmable = true; } break; } // The NPC type doesn't match spell charm types. if (!charmable) { MessageToCaster("This spell does not charm this type of monster!", eChatType.CT_SpellResisted); return; } } } // Spell.Value == Max Level this spell can charm, Spell.Damage == Max percent of the caster level this spell can charm if (target.Level > Spell.Value || target.Level > Caster.Level * Spell.Damage / 100) { MessageToCaster(target.GetName(0, true) + " is too strong for you to charm!", eChatType.CT_SpellResisted); return; } if (Caster is GamePlayer) { // base resists for all charm spells int resistChance = 100 - (85 + ((Caster.Level - target.Level) / 2)); if (Spell.Pulse != 0) // not permanent { /* * The Minstrel/Mentalist has an almost certain chance to charm/retain control of * a creature his level or lower, although there is a small random chance that it * could fail. The higher the level of the charmed creature compared to the * Minstrel/Mentalist, the greater the chance the monster has of breaking the charm. * Please note that your specialization level in the magic skill that contains the * charm spell will modify your base chance of charming and retaining control. * The higher your spec level, the greater your chance of controlling. */ int diffLevel = (int)(Caster.Level / 1.5 + Caster.GetModifiedSpecLevel(m_spellLine.Spec) / 3) - target.Level; if (diffLevel >= 0) { resistChance = 10 - diffLevel * 3; resistChance = Math.Max(resistChance, 1); } else { resistChance = 10 + diffLevel * diffLevel * 3; resistChance = Math.Min(resistChance, 99); } } if (Util.Chance(resistChance)) { MessageToCaster(target.GetName(0, true) + " resists the charm!", eChatType.CT_SpellResisted); return; } } base.ApplyEffectOnTarget(target, effectiveness); }
/// <summary> /// Execute Duration Spell Effect on Target /// </summary> /// <param name="target"></param> /// <param name="effectiveness"></param> public virtual void OnDurationEffectApply(GameLiving target, double effectiveness) { if (!target.IsAlive || target.EffectList == null) return; eChatType noOverwrite = (Spell.Pulse == 0) ? eChatType.CT_SpellResisted : eChatType.CT_SpellPulse; GameSpellEffect neweffect = CreateSpellEffect(target, effectiveness); // Iterate through Overwritable Effect var overwritenEffects = target.EffectList.OfType<GameSpellEffect>().Where(effect => effect.SpellHandler != null && effect.SpellHandler.IsOverwritable(neweffect)); // Store Overwritable or Cancellable var enable = true; var cancellableEffects = new List<GameSpellEffect>(1); GameSpellEffect overwriteEffect = null; foreach (var ovEffect in overwritenEffects) { // If we can cancel spell effect we don't need to overwrite it if (ovEffect.SpellHandler.IsCancellable(neweffect)) { // Spell is better than existing "Cancellable" or it should start disabled if (IsCancellableEffectBetter(ovEffect, neweffect)) cancellableEffects.Add(ovEffect); else enable = false; } else { // Check for Overwriting. if (IsNewEffectBetter(ovEffect, neweffect)) { // New Spell is overwriting this one. overwriteEffect = ovEffect; } else { // Old Spell is Better than new one SendSpellResistAnimation(target); if (target == Caster) { if (ovEffect.ImmunityState) MessageToCaster("You can't have that effect again yet!", noOverwrite); else MessageToCaster("You already have that effect. Wait until it expires. Spell failed.", noOverwrite); } else { if (ovEffect.ImmunityState) { this.MessageToCaster(noOverwrite, "{0} can't have that effect again yet!", ovEffect.Owner != null ? ovEffect.Owner.GetName(0, true) : "(null)"); } else { this.MessageToCaster(noOverwrite, "{0} already has that effect.", target.GetName(0, true)); MessageToCaster("Wait until it expires. Spell Failed.", noOverwrite); } } // Prevent Adding. return; } } } // Register Effect list Changes target.EffectList.BeginChanges(); try { // Check for disabled effect foreach (var disableEffect in cancellableEffects) disableEffect.DisableEffect(false); if (overwriteEffect != null) { if (enable) overwriteEffect.Overwrite(neweffect); else overwriteEffect.OverwriteDisabled(neweffect); } else { if (enable) neweffect.Start(target); else neweffect.StartDisabled(target); } } finally { target.EffectList.CommitChanges(); } }
/// <summary> /// Heals hit points of one target and sends needed messages, no spell effects /// </summary> /// <param name="target"></param> /// <param name="amount">amount of hit points to heal</param> /// <returns>true if heal was done</returns> public virtual bool HealTarget(GameLiving target, int amount) { if (target == null || target.ObjectState != GameLiving.eObjectState.Active) { return(false); } // we can't heal people we can attack if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true)) { return(false); } // no healing of keep components if (target is Keeps.GameKeepComponent || target is Keeps.GameKeepDoor) { return(false); } if (!target.IsAlive) { //"You cannot heal the dead!" sshot550.tga MessageToCaster(target.GetName(0, true) + " is dead!", eChatType.CT_SpellResisted); return(false); } if (target is GamePlayer && (target as GamePlayer).NoHelp && Caster is GamePlayer) { //player not grouped, anyone else //player grouped, different group if ((target as GamePlayer).Group == null || (Caster as GamePlayer).Group == null || (Caster as GamePlayer).Group != (target as GamePlayer).Group) { MessageToCaster("That player does not want assistance", eChatType.CT_SpellResisted); return(false); } } //moc heal decrease double mocFactor = 1.0; MasteryofConcentrationEffect moc = Caster.EffectList.GetOfType <MasteryofConcentrationEffect>(); if (moc != null) { GamePlayer playerCaster = Caster as GamePlayer; MasteryofConcentrationAbility ra = playerCaster.GetAbility <MasteryofConcentrationAbility>(); if (ra != null) { mocFactor = System.Math.Round((double)ra.GetAmountForLevel(ra.Level) / 100, 2); } amount = (int)Math.Round(amount * mocFactor); } int criticalvalue = 0; int criticalchance = Caster.GetModified(eProperty.CriticalHealHitChance); double effectiveness = 0; if (Caster is GamePlayer) { effectiveness = ((GamePlayer)Caster).Effectiveness + Caster.GetModified(eProperty.HealingEffectiveness) * 0.01; } if (Caster is GameNPC) { effectiveness = 1.0; } //USE DOUBLE ! double cache = (double)amount * effectiveness; amount = (int)cache; if (Util.Chance(criticalchance)) { criticalvalue = Util.Random(amount / 10, amount / 2 + 1); } amount += criticalvalue; GamePlayer playerTarget = target as GamePlayer; if (playerTarget != null) { GameSpellEffect HealEffect = SpellHandler.FindEffectOnTarget(playerTarget, "EfficientHealing"); if (HealEffect != null) { double HealBonus = amount * ((int)HealEffect.Spell.Value * 0.01); amount += (int)HealBonus; playerTarget.Out.SendMessage("Your Efficient Healing buff grants you a additional" + HealBonus + " in the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow); } GameSpellEffect EndEffect = SpellHandler.FindEffectOnTarget(playerTarget, "EfficientEndurance"); if (EndEffect != null) { double EndBonus = amount * ((int)EndEffect.Spell.Value * 0.01); //600 / 10 = 60end playerTarget.Endurance += (int)EndBonus; playerTarget.Out.SendMessage("Your Efficient Endurance buff grants you " + EndBonus + " Endurance from the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow); } } GameSpellEffect flaskHeal = FindEffectOnTarget(target, "HealFlask"); if (flaskHeal != null) { amount += (int)((amount * flaskHeal.Spell.Value) * 0.01); } int heal = target.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, amount); #region PVP DAMAGE long healedrp = 0; if (target.DamageRvRMemory > 0 && (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer)) { healedrp = (long)Math.Max(heal, 0); target.DamageRvRMemory -= healedrp; } if (heal == 0) { if (Spell.Pulse == 0) { if (target == m_caster) { MessageToCaster("You are fully healed.", eChatType.CT_SpellResisted); } else { MessageToCaster(target.GetName(0, true) + " is fully healed.", eChatType.CT_SpellResisted); } } return(false); } if (m_caster is GamePlayer && target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer && healedrp > 0) { int POURCENTAGE_SOIN_RP = ServerProperties.Properties.HEAL_PVP_DAMAGE_VALUE_RP; // ...% de bonus RP pour les soins effectués if (m_spell.Pulse == 0 && m_caster.CurrentRegionID != 242 && // On Exclu zone COOP m_spell.SpellType.ToLower() != "spreadheal" && target != m_caster && m_spellLine.KeyName != GlobalSpellsLines.Item_Spells && m_spellLine.KeyName != GlobalSpellsLines.Potions_Effects && m_spellLine.KeyName != GlobalSpellsLines.Combat_Styles_Effect && m_spellLine.KeyName != GlobalSpellsLines.Reserved_Spells) { GamePlayer player = m_caster as GamePlayer; if (player != null) { long Bonus_RP_Soin = Convert.ToInt64((double)healedrp * POURCENTAGE_SOIN_RP / 100.0); if (Bonus_RP_Soin >= 1) { PlayerStatistics stats = player.Statistics as PlayerStatistics; if (stats != null) { stats.RPEarnedFromHitPointsHealed += (uint)Bonus_RP_Soin; stats.HitPointsHealed += (uint)healedrp; } player.GainRealmPoints(Bonus_RP_Soin, false); player.Out.SendMessage("Vous gagnez " + Bonus_RP_Soin.ToString() + " points de royaume pour avoir soigné un membre de votre royaume.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); } } } } #endregion PVP DAMAGE if (m_caster == target) { MessageToCaster("You heal yourself for " + heal + " hit points.", eChatType.CT_Spell); if (heal < amount) { #region PVP DAMAGE if (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer) { if (target.DamageRvRMemory > 0) { target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps } } #endregion PVP DAMAGE MessageToCaster("You are fully healed.", eChatType.CT_Spell); } } else { MessageToCaster("You heal " + target.GetName(0, false) + " for " + heal + " hit points!", eChatType.CT_Spell); MessageToLiving(target, "You are healed by " + m_caster.GetName(0, false) + " for " + heal + " hit points.", eChatType.CT_Spell); if (heal < amount) { #region PVP DAMAGE if (target is NecromancerPet && ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer) { if (target.DamageRvRMemory > 0) { target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps } } #endregion PVP DAMAGE MessageToCaster(target.GetName(0, true) + " is fully healed.", eChatType.CT_Spell); } if (heal > 0 && criticalvalue > 0) { MessageToCaster("Your heal criticals for an extra " + criticalvalue + " amount of hit points!", eChatType.CT_Spell); } } return(true); }
/// <summary> /// Send Spell Resist Messages to Caster and Target /// </summary> /// <param name="target"></param> public virtual void SendSpellResistMessages(GameLiving target) { // Deliver message to the target, if the target is a pet, to its // owner instead. if (target is GameNPC) { IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); if (owner != null) { this.MessageToLiving(owner, eChatType.CT_SpellResisted, "Your {0} resists the effect!", target.Name); } } } else { MessageToLiving(target, "You resist the effect!", eChatType.CT_SpellResisted); } // Deliver message to the caster as well. this.MessageToCaster(eChatType.CT_SpellResisted, "{0} resists the effect!", target.GetName(0, true)); }
protected virtual void OnSpellResist(GameLiving target) { m_lastdamage -= m_lastdamage / 4; SendEffectAnimation(target, 0, false, 0); if (target is GameNPC) { IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); //Worthless checks if (owner != null/* && owner.ControlledNpc != null && target == owner.ControlledNpc.Body*/) { MessageToLiving(owner, "Your " + target.Name + " resists the effect!", eChatType.CT_SpellResisted); } } } else { MessageToLiving(target, "You resist the effect!", eChatType.CT_SpellResisted); } MessageToCaster(target.GetName(0, true) + " resists the effect!", eChatType.CT_SpellResisted); if (Spell.Damage != 0) { // notify target about missed attack for spells with damage AttackData ad = new AttackData(); ad.Attacker = Caster; ad.Target = target; ad.AttackType = AttackData.eAttackType.Spell; ad.AttackResult = GameLiving.eAttackResult.Missed; ad.SpellHandler = this; target.OnAttackedByEnemy(ad); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, Caster); } else if (Spell.CastTime > 0) { target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); } if (target is GameNPC) { IOldAggressiveBrain aggroBrain = ((GameNPC)target).Brain as IOldAggressiveBrain; if (aggroBrain != null) aggroBrain.AddToAggroList(Caster, 1); } if (target.Realm == 0 || Caster.Realm == 0) { target.LastAttackedByEnemyTickPvE = target.CurrentRegion.Time; Caster.LastAttackTickPvE = Caster.CurrentRegion.Time; } else { target.LastAttackedByEnemyTickPvP = target.CurrentRegion.Time; Caster.LastAttackTickPvP = Caster.CurrentRegion.Time; } }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; if (player == null) return false; switch (text) { case "Vampiir": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Vampiir, "Very well, " + source.GetName(0, false) + ". I gladly take your training into my hands. Congratulations, from this day forth, you are a Vampiir. Here, take this gift to aid you.", null); foreach (GamePlayer plr in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) // inform nearest clients about this player now is vampire (can fly) if (plr != null) plr.Out.SendVampireEffect(player, true); } break; } return true; }
/// <summary> /// Talk to trainer /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) { return(false); } if (!(source is GamePlayer player)) { return(false); } switch (text) { case "Eldritch": // promote player to other class if (CanPromotePlayer(player)) { PromotePlayer(player, (int)eCharacterClass.Eldritch, "I can give you the gift of knowledge, but wisdom you must seek on your own. I welcome you, " + source.GetName(0, false) + ". Here, take this welcoming gift. Use it wisely.", null); player.ReceiveItem(this, WeaponId1); } break; } return(true); }
protected virtual void OnSpellResist(GameLiving target) { m_lastdamage -= Convert.ToInt32(m_lastdamage * 0.25); SendEffectAnimation(target, 0, false, 0); if (target is GameNPC npc) { if (npc.Brain is IControlledBrain brain) { GamePlayer owner = brain.GetPlayerOwner(); if (owner != null) { MessageToLiving(owner, $"Your {target.Name} resists the effect!", eChatType.CT_SpellResisted); } } } else { MessageToLiving(target, "You resist the effect!", eChatType.CT_SpellResisted); } MessageToCaster($"{target.GetName(0, true)} resists the effect!", eChatType.CT_SpellResisted); if (Spell.Damage != 0) { // notify target about missed attack for spells with damage AttackData ad = new AttackData { Attacker = Caster, Target = target, AttackType = AttackData.eAttackType.Spell, AttackResult = GameLiving.eAttackResult.Missed, SpellHandler = this }; target.OnAttackedByEnemy(ad); target.StartInterruptTimer(target.SpellInterruptDuration, ad.AttackType, Caster); } else if (Spell.CastTime > 0) { target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster); } if (target is GameNPC gameNpc) { if (gameNpc.Brain is IOldAggressiveBrain aggroBrain) { aggroBrain.AddToAggroList(Caster, 1); } } if (target.Realm == 0 || Caster.Realm == 0) { target.LastAttackedByEnemyTickPvE = target.CurrentRegion.Time; Caster.LastAttackTickPvE = Caster.CurrentRegion.Time; } else { target.LastAttackedByEnemyTickPvP = target.CurrentRegion.Time; Caster.LastAttackTickPvP = Caster.CurrentRegion.Time; } }
private bool HasTarget(GameClient client, GameLiving livingToCheck) { if (livingToCheck.TargetObject != null) { return(true); } // We cannot assist our target when it has no target. client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Assist.DoesntHaveTarget", livingToCheck.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return(false); }