public override void Start(GameLiving target)
        {
            base.Start(target);
            if (target is GamePlayer)
            {
                EffectOwner = target as GamePlayer;
                stun = ScriptMgr.CreateSpellHandler(EffectOwner, spiritSpell, spiritSpellLine);

                int targetCount = 0;
                foreach (GamePlayer targetPlayer in EffectOwner.GetPlayersInRadius((ushort)RealmAbilities.MinionRescueAbility.SpellRadius))
                {
                    if (targetCount == spiritCount) return;
                    if (targetPlayer.IsAlive && GameServer.ServerRules.IsAllowedToAttack(EffectOwner, targetPlayer, true))
                    {
                        SummonSpirit(targetCount, targetPlayer);
                        targetCount++;
                    }
                }
            }
        }
 public override void Start(GameLiving target)
 {
     base.Start(target);
     if (target is GameNPC)
     {
         pet = target as GameNPC;
         pbaoe = ScriptMgr.CreateSpellHandler(EffectOwner, petSpell, petSpellLine);
         pulseTimer = new RegionTimer(EffectOwner, new RegionTimerCallback(PulseTimer), 1000);
         GameEventMgr.AddHandler(EffectOwner, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld));
     }
 }
 /// <summary>
 /// Creates a new game spell effect
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="duration"></param>
 /// <param name="pulseFreq"></param>
 /// <param name="effectiveness"></param>
 public GameSpellAndImmunityEffect(ISpellHandler handler, int duration, int pulseFreq, double effectiveness)
     : base(handler, duration, pulseFreq, effectiveness)
 {
     m_startedCount = 0;
 }
Example #4
1
		/// <summary>
		/// Called when a Players picks up a Relic
		/// </summary>
		/// <param name="player"></param>
		protected virtual void PlayerTakesRelic(GamePlayer player)
		{
			if (player == null) return;
			RemoveFromWorld();
			SetHandlers(player, true);
			player.MinotaurRelic = this;
			Owner = player;

			foreach (GamePlayer pl in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
				pl.Out.SendMinotaurRelicWindow(player, Effect, true);

			player.Out.SendMinotaurRelicBarUpdate(player, (int)XP);

			m_spellHandler = ScriptMgr.CreateSpellHandler(m_owner, RelicSpell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
			if (m_spellHandler != null)
				m_gameSpellEffect = new GameSpellEffect(m_spellHandler, RelicSpell.Duration, 0);

			timer = new Timer(new TimerCallback(XPTimerCallBack), null, 3000, 0);

			ApplyRelicEffect();
		}
Example #5
0
        private void OnSlotHandlerStateChanged(int slotIndex, ISpellHandler handler, SpellEvent e, ISubSpellHandler subHandler)
        {
            var slotState = GetSpellSlotState(slotIndex);

            if (e == SpellEvent.StartedFiring)
            {
                slotState.State = SlotState.Firing;
            }
            else if (e == SpellEvent.FinishedFire || e == SpellEvent.Aborted || e == SpellEvent.Ended)
            {
                // If we are ending spell that has not yet started
                if (slotState.State == SlotState.Preparing)
                {
                    slotState.RemainingCooldown = 0.1f;
                }
                else
                {
                    slotState.RemainingCooldown = slotState.Spell.Cooldown.GetValue(slotState.NumStacks);
                }

                // Remove handler from state and start recharging
                slotState.SpellHandler = null;
                slotState.State        = SlotState.Recharging;

                if (NoCooldowns)
                {
                    slotState.RemainingCooldown = 0.1f;
                }
            }
        }
Example #6
0
        private void HandlerOnStateChanged(ISpellHandler handler, SpellEvent e, ISubSpellHandler subHandler)
        {
            // Even when event if from spell that is already not in slot - decrease hp for cast
            if (e == SpellEvent.SubSpellCasted && subHandler != null)
            {
                _characterState.ApplyModifier(
                    ModificationParameter.HpFlat,
                    -subHandler.SubSpell.BloodCost.GetValue(subHandler.Stacks),
                    _characterState,
                    null);
            }


            for (var i = 0; i < SpellSlots.Length; i++)
            {
                if (handler.Equals(SpellSlots[i].SpellHandler))
                {
                    OnSlotHandlerStateChanged(i, handler, e, subHandler);
                    return;
                }
            }

            // If the handler (finished or aborted state) is inactive - unsubscribe
            if (!handler.IsActive)
            {
                // Unsubscribe
                handler.Event -= HandlerOnStateChanged;
            }
        }
Example #7
0
        /// <summary>
        /// Overwrites the effect
        /// concentration based effects should never be overwritten
        /// </summary>
        /// <param name="effect">the new effect</param>
        public virtual void Overwrite(GameSpellEffect effect)
        {
            if (Spell.Concentration > 0)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn(effect.Name + " (" + effect.Spell.Name + ") is trying to overwrite " + Spell.Name + " which has concentration " + Spell.Concentration);
                }
                return;
            }

            lock (m_LockObject)
            {
                // immunity effects in immunity state are already expired
                if (!m_expired)
                {
                    m_expired = true;
                    m_handler.OnEffectExpires(this, true);
                }
                StopTimers();
                m_handler       = effect.m_handler;
                m_duration      = effect.m_duration;
                m_pulseFreq     = effect.m_pulseFreq;
                m_effectiveness = effect.m_effectiveness;
                StartTimers();
                if (Spell.Concentration > 0)
                {
                    SpellHandler.Caster.ConcentrationEffects.Add(this);
                }
                m_owner.EffectList.OnEffectsChanged(this);
                m_handler.OnEffectStart(this);
                m_handler.OnEffectPulse(this);
                m_expired = false;
            }
        }
        public void OnCommand(GameClient client, string[] args)
        {
            GamePlayer player     = client.Player as GamePlayer;
            long       BuffTick   = player.TempProperties.getProperty(Summon_Buff, 0L);
            long       changeTime = player.CurrentRegion.Time - BuffTick;

            if (changeTime < 30000)
            {
                player.Out.SendMessage("You must wait " + ((30000 - changeTime) / 1000).ToString() + " more second to attempt to use this command!", eChatType.CT_System, eChatLoc.CL_ChatWindow);
                return;
            }
            player.TempProperties.setProperty(Summon_Buff, player.CurrentRegion.Time);

            #endregion Command timer

            #region Command spell Loader
            if (client.Player.BountyPoints >= 100) // how many bps are need to summon the buffbot
            {
                SpellLine     line         = new SpellLine("BuffBotCast", "BuffBot Cast", "unknown", false);
                ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, BuffBotSpell, line);
                if (spellHandler != null)
                {
                    spellHandler.StartSpell(client.Player);
                }
                client.Player.RemoveBountyPoints(100); // removes the amount of bps from the player
                client.Player.Out.SendMessage("You have summoned a Buffbot!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                client.Player.SaveIntoDatabase();      // saves new amount of bps
                client.Player.Out.SendUpdatePlayer();  // updates players bps
            }
            #endregion command spell loader
            else
            {
                client.Player.Out.SendMessage("You don't have enough Bounty Pounts to summon a Buffbot!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
Example #9
0
        /// <summary>
        /// Find effect by spell handler
        /// </summary>
        /// <param name="target">Living to find effect on</param>
        /// <param name="spellHandler">Spell Handler to find (Exact Object Match)</param>
        /// <returns>first occurance of effect in target's effect list or null</returns>
        public static GameSpellEffect FindEffectOnTarget(GameLiving target, ISpellHandler spellHandler)
        {
            lock (target.EffectList)
            {
                foreach (IGameEffect effect in target.EffectList)
                {
                    GameSpellEffect gsp = effect as GameSpellEffect;
                    if (gsp == null)
                    {
                        continue;
                    }

                    if (gsp.SpellHandler != spellHandler)
                    {
                        continue;
                    }

                    // ignore immunity effects
                    if (gsp is GameSpellAndImmunityEffect && ((GameSpellAndImmunityEffect)gsp).ImmunityState)
                    {
                        continue;
                    }

                    return(gsp);
                }
            }
            return(null);
        }
Example #10
0
        /// <summary>
        /// Body or another living has been attacked.
        /// </summary>
        /// <param name="living"></param>
        /// <param name="attackData"></param>
        protected virtual void OnAttacked(AttackData attackData)
        {
            if (attackData == null)
            {
                return;
            }

            if (attackData.Target == Body)
            {
                if (Body.IsReturningToSpawnPoint)
                {
                    Body.CancelWalkToSpawn();
                }

                if (!attackData.IsMeleeAttack)
                {
                    ISpellHandler spellhandler = attackData.SpellHandler;

                    if (spellhandler != null && spellhandler is TauntSpellHandler)
                    {
                        OnTaunted(attackData);
                        return;
                    }
                }

                Aggression.Raise(attackData.Attacker, attackData.Damage);

                // TODO: Process attack data and change the amount of aggro
                //       accordingly.
            }
            else
            {
                OnLivingAttacked(attackData.Target, attackData.Attacker);
            }
        }
        /// <summary>
        /// Action
        /// </summary>
        /// <param></param>
        public override void Execute(GameLiving living)
        {
            if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED))
            {
                return;
            }

            if (!(living is GamePlayer player))
            {
                return;
            }

            Spell         subspell     = SkillBase.GetSpellByID(7063);
            ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(player, subspell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));

            if (player.Group == null)
            {
                spellhandler.StartSpell(player);
            }
            else
            {
                foreach (GamePlayer member in player.Group.GetPlayersInTheGroup())
                {
                    if (member != null)
                    {
                        spellhandler.StartSpell(member);
                    }
                }
            }

            DisableSkill(living);
        }
Example #12
0
        /// <summary>
        /// Called when a Players picks up a Relic
        /// </summary>
        /// <param name="player"></param>
        private void PlayerTakesRelic(GamePlayer player)
        {
            if (player == null)
            {
                return;
            }

            RemoveFromWorld();
            SetHandlers(player, true);
            player.MinotaurRelic = this;
            Owner = player;

            foreach (GamePlayer pl in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                pl.Out.SendMinotaurRelicWindow(player, Effect, true);
            }

            player.Out.SendMinotaurRelicBarUpdate(player, (int)Xp);

            _spellHandler = ScriptMgr.CreateSpellHandler(Owner, RelicSpell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
            if (_spellHandler != null)
            {
                _gameSpellEffect = new GameSpellEffect(_spellHandler, RelicSpell.Duration, 0);
            }

            _timer = new Timer(XpTimerCallBack, null, 3000, 0);

            ApplyRelicEffect();
        }
Example #13
0
        /// <summary>
        /// Restore All Effect From PlayerXEffect Data Table
        /// </summary>
        public virtual void RestoreAllEffects()
        {
            GamePlayer player = m_owner as GamePlayer;

            if (player == null || player.DBCharacter == null || GameServer.Database == null)
            {
                return;
            }

            var effs = GameServer.Database.SelectObjects <PlayerXEffect>("`ChardID` = @ChardID", new QueryParameter("@ChardID", player.ObjectId));

            if (effs == null)
            {
                return;
            }

            foreach (PlayerXEffect eff in effs)
            {
                if (eff.SpellLine == GlobalSpellsLines.Reserved_Spells)
                {
                    continue;
                }

                bool  good  = true;
                Spell spell = SkillBase.GetSpellByID(eff.Var1);

                if (spell == null)
                {
                    good = false;
                }

                SpellLine line = null;

                if (!Util.IsEmpty(eff.SpellLine))
                {
                    line = SkillBase.GetSpellLine(eff.SpellLine, false);
                    if (line == null)
                    {
                        good = false;
                    }
                }
                else
                {
                    good = false;
                }

                if (good)
                {
                    ISpellHandler   handler = ScriptMgr.CreateSpellHandler(player, spell, line);
                    GameSpellEffect e;
                    e = new GameSpellEffect(handler, eff.Duration, spell.Frequency);
                    e.RestoredEffect = true;
                    int[] vars = { eff.Var1, eff.Var2, eff.Var3, eff.Var4, eff.Var5, eff.Var6 };
                    e.RestoreVars = vars;
                    e.Start(player);
                }

                GameServer.Database.DeleteObject(eff);
            }
        }
        public override void Notify(DOLEvent e, object sender, EventArgs args)
        {
            if (Player.ControlledBrain != null)
            {
                GameNPC pet = Player.ControlledBrain.Body;

                if (pet != null && sender == pet && e == GameLivingEvent.CastStarting && args is CastingEventArgs)
                {
                    ISpellHandler spellHandler = (args as CastingEventArgs).SpellHandler;

                    if (spellHandler != null)
                    {
                        int powerCost = spellHandler.PowerCost(Player);

                        if (powerCost > 0)
                        {
                            Player.ChangeMana(Player, GameLiving.eManaChangeType.Spell, -powerCost);
                        }
                    }

                    return;
                }
            }

            base.Notify(e, sender, args);
        }
 /// <summary>
 /// Constructs new pulsing spell effect
 /// </summary>
 /// <param name="spellHandler">the spell handler doing the pulsing</param>
 public PulsingSpellEffect(ISpellHandler spellHandler)
 {
     if (spellHandler == null)
     {
         throw new ArgumentNullException("spellHandler");
     }
     m_spellHandler = spellHandler;
 }
Example #16
0
        public SongDelve(int id)
        {
            Spell spell = SkillBase.GetSpellByTooltipID((ushort)id);

            spellHandler = ScriptMgr.CreateSpellHandler(null, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
            DelveType    = "Song";
            Index        = unchecked ((short)spellHandler.Spell.InternalID);
        }
Example #17
0
 /// <summary>
 /// Creates a new game spell effect
 /// </summary>
 /// <param name="handler">the spell handler</param>
 /// <param name="duration">the spell duration in milliseconds</param>
 /// <param name="pulseFreq">the pulse frequency in milliseconds</param>
 /// <param name="effectiveness">the effectiveness</param>
 public GameSpellEffect(ISpellHandler handler, int duration, int pulseFreq, double effectiveness)
 {
     m_handler       = handler;
     m_duration      = duration;
     m_pulseFreq     = pulseFreq;
     m_effectiveness = effectiveness;
     m_expired       = true;       // not started = expired
 }
 protected void CastSpell(GameLiving target)
 {
     if (target.IsAlive && _spell != null)
     {
         ISpellHandler dd = ScriptMgr.CreateSpellHandler(_player, _spell, _spellline);
         dd.IgnoreDamageCap = true;
         dd.StartSpell(target);
     }
 }
Example #19
0
        /// <summary>
        /// Find effect by spell handler
        /// </summary>
        /// <param name="target">Living to find effect on</param>
        /// <param name="spellHandler">Spell Handler to find (Exact Object Match)</param>
        /// <returns>First occurence of GameSpellEffect in target's effect list or null</returns>
        public static GameSpellEffect FindEffectOnTarget(this GameLiving target, ISpellHandler spellHandler)
        {
            GameSpellEffect effect = null;

            lock (target.EffectList)
            {
                effect = target.EffectsOnTarget(spellHandler).FirstOrDefault();
            }
            return(effect);
        }
        protected override void ResurrectLiving(GameLiving living)
        {
            base.ResurrectLiving(living);

            SpellLine line      = SkillBase.GetSpellLine("Summon Monster");
            Spell     castSpell = SkillBase.GetSpellByID(14078);

            ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_caster, castSpell, line);

            spellhandler.StartSpell(living);
        }
Example #21
0
 public override void Start(GameLiving target)
 {
     base.Start(target);
     if (target is GameNPC)
     {
         pet        = target as GameNPC;
         pbaoe      = ScriptMgr.CreateSpellHandler(EffectOwner, petSpell, petSpellLine);
         pulseTimer = new RegionTimer(EffectOwner, new RegionTimerCallback(PulseTimer), 1000);
         GameEventMgr.AddHandler(EffectOwner, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld));
     }
 }
        public void EventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            AttackFinishedEventArgs args = arguments as AttackFinishedEventArgs;

            if (args == null || args.AttackData == null)
            {
                return;
            }
            AttackData ad = args.AttackData;

            if (ad.AttackResult != GameLiving.eAttackResult.HitUnstyled && ad.AttackResult != GameLiving.eAttackResult.HitStyle)
            {
                return;
            }

            int baseChance = 0;

            if (ad.AttackType == AttackData.eAttackType.Ranged)
            {
                baseChance = (int)(Spell.Frequency * .0001);
            }
            else if (ad.IsMeleeAttack)
            {
                baseChance = ((int)Spell.Frequency);
                if (sender is GamePlayer)
                {
                    GamePlayer    player     = (GamePlayer)sender;
                    InventoryItem leftWeapon = player.Inventory.GetItem(eInventorySlot.LeftHandWeapon);
                    // if we can use left weapon, we have currently a weapon in left hand and we still have endurance,
                    // we can assume that we are using the two weapons.
                    if (player.CanUseLefthandedWeapon && leftWeapon != null && leftWeapon.Object_Type != (int)eObjectType.Shield)
                    {
                        baseChance /= 2;
                    }
                }
            }

            if (Util.Chance(15))
            {
                Spell         m_procSpell = SkillBase.GetSpellByID((int)Spell.Value);
                ISpellHandler handler     = ScriptMgr.CreateSpellHandler((GameLiving)sender, m_procSpell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                if (handler != null)
                {
                    if (m_procSpell.Target == "Enemy")
                    {
                        handler.StartSpell(ad.Target);
                    }
                    else if (m_procSpell.Target == "Self")
                    {
                        handler.StartSpell(ad.Attacker);
                    }
                }
            }
        }
Example #23
0
 public static void ExecuteSpell(BaseGame game, Player player, ItemInfo item)
 {
     try
     {
         ISpellHandler spellHandler = SpellMgr.LoadSpellHandler(item.Template.Property3);
         spellHandler.Execute(game, player, item);
     }
     catch (Exception ex)
     {
         SpellMgr.log.Error("Execute Spell Error:", ex);
     }
 }
Example #24
0
        /// <summary>
        /// Action
        /// </summary>
        /// <param></param>
        public override void Execute(GameLiving living)
        {
            if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED))
            {
                return;
            }

            GamePlayer player = living as GamePlayer;

            if (player?.Group != null)
            {
                foreach (GamePlayer member in player.Group.GetPlayersInTheGroup())
                {
                    if (member.CharacterClass.ID == 1 || member.CharacterClass.ID == 2) // Plate
                    {
                        Spell         spell1        = SkillBase.GetSpellByID(36005);    // 34 % Absorb-Spell
                        ISpellHandler spellhandler1 = ScriptMgr.CreateSpellHandler(player, spell1, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler1.StartSpell(member);
                    }
                    else if (member.CharacterClass.ID == 9 || member.CharacterClass.ID == 10 || member.CharacterClass.ID == 23 || member.CharacterClass.ID == 49 || member.CharacterClass.ID == 58) // Leather
                    {
                        Spell         spell2        = SkillBase.GetSpellByID(36002);                                                                                                                // 10 % Absorb-Spell
                        ISpellHandler spellhandler2 = ScriptMgr.CreateSpellHandler(player, spell2, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler2.StartSpell(member);
                    }
                    else if (member.CharacterClass.ID == 3 || member.CharacterClass.ID == 25 || member.CharacterClass.ID == 31 || member.CharacterClass.ID == 32 || member.CharacterClass.ID == 43 || member.CharacterClass.ID == 48 || member.CharacterClass.ID == 50 || member.CharacterClass.ID == 25) // Studderd
                    {
                        Spell         spell3        = SkillBase.GetSpellByID(36003);                                                                                                                                                                                                                      // 19 % Absorb-Spell
                        ISpellHandler spellhandler3 = ScriptMgr.CreateSpellHandler(player, spell3, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler3.StartSpell(member);
                    }
                    else if (member.CharacterClass.ID == 4 || member.CharacterClass.ID == 6 || member.CharacterClass.ID == 11 || member.CharacterClass.ID == 19 || member.CharacterClass.ID == 21 || member.CharacterClass.ID == 22 || member.CharacterClass.ID == 24 || member.CharacterClass.ID == 26 || member.CharacterClass.ID == 28 || member.CharacterClass.ID == 34 || member.CharacterClass.ID == 44 || member.CharacterClass.ID == 45 || member.CharacterClass.ID == 46 || member.CharacterClass.ID == 47) // Chain
                    {
                        Spell         spell4        = SkillBase.GetSpellByID(36004);                                                                                                                                                                                                                                                                                                                                                                                                                                 // 24 % Absorb-Spell
                        ISpellHandler spellhandler4 = ScriptMgr.CreateSpellHandler(player, spell4, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler4.StartSpell(member);
                    }
                    else
                    {
                        Spell         spell5        = SkillBase.GetSpellByID(36001); // 0 % Absorb-Spell
                        ISpellHandler spellhandler5 = ScriptMgr.CreateSpellHandler(player, spell5, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler5.StartSpell(member);
                    }
                }
            }
            else
            {
                player?.Out.SendMessage("You need a group for this Ability!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow);
                return;
            }

            DisableSkill(living);
        }
Example #25
0
 protected override void CastSpell(GameLiving target)
 {
     if (!target.IsAlive)
     {
         return;
     }
     if (GameServer.ServerRules.IsAllowedToAttack(m_caster, target, true))
     {
         ISpellHandler stun = ScriptMgr.CreateSpellHandler(m_caster, s, sl);
         stun.StartSpell(target);
     }
 }
Example #26
0
 public override void FinishSpellCast(GameLiving target)
 {
     if (m_spell.SubSpellID > 0)
     {
         Spell spell = SkillBase.GetSpellByID(m_spell.SubSpellID);
         if (spell != null && spell.SubSpellID == 0)
         {
             ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_caster, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
             spellhandler.StartSpell(Caster);
         }
     }
     base.FinishSpellCast(target);
 }
Example #27
0
        protected override void CastSpell(GameLiving target)
        {
            if (!target.IsAlive)
            {
                return;
            }

            if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true))
            {
                ISpellHandler damage = ScriptMgr.CreateSpellHandler(Caster, _spell, _spellLine);
                damage.StartSpell(target);
            }
        }
        /// <summary>
        /// Handles attacks on player/by player
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        private void OnAttack(DOLEvent e, object sender, EventArgs arguments)
        {
            GameLiving living = sender as GameLiving;

            if (living == null)
            {
                return;
            }
            AttackedByEnemyEventArgs attackedByEnemy = arguments as AttackedByEnemyEventArgs;
            AttackFinishedEventArgs  attackFinished  = arguments as AttackFinishedEventArgs;
            CastingEventArgs         castFinished    = arguments as CastingEventArgs;
            AttackData    ad = null;
            ISpellHandler sp = null;

            if (attackedByEnemy != null)
            {
                ad = attackedByEnemy.AttackData;
            }
            else if (attackFinished != null)
            {
                ad = attackFinished.AttackData;
            }
            else if (castFinished != null)
            {
                sp = castFinished.SpellHandler;
                ad = castFinished.LastAttackData;
            }

            // Speed should drop if the player casts an offensive spell
            if (sp == null && ad == null)
            {
                return;
            }
            else if (sp == null && (ad.AttackResult != GameLiving.eAttackResult.HitStyle && ad.AttackResult != GameLiving.eAttackResult.HitUnstyled))
            {
                return;
            }
            else if (sp != null && (sp.HasPositiveEffect || ad == null))
            {
                return;
            }

            GameSpellEffect speed = SpellHandler.FindEffectOnTarget(living, this);

            if (speed != null)
            {
                speed.Cancel(false);
            }
        }
        public void CastBuffs()
        {
            Container con = null;

            while (m_buffs.Count > 0)
            {
                con = (Container)m_buffs.Dequeue();

                ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(this, con.Spell, con.SpellLine);

                if (spellHandler != null)
                {
                    spellHandler.StartSpell(con.Target);
                }
            }
        }
Example #30
0
        /// <summary>
        /// Handler fired whenever effect target is attacked
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        protected override void EventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            AttackedByEnemyEventArgs args = arguments as AttackedByEnemyEventArgs;

            if (args == null || args.AttackData == null || args.AttackData.AttackType == AttackData.eAttackType.Spell)
            {
                return;
            }

            AttackData ad = args.AttackData;

            if (ad.AttackResult != GameLiving.eAttackResult.HitUnstyled && ad.AttackResult != GameLiving.eAttackResult.HitStyle)
            {
                return;
            }

            int baseChance = Spell.Frequency / 100;

            if (ad.AttackType == AttackData.eAttackType.MeleeDualWield)
            {
                baseChance /= 2;
            }

            if (baseChance < 1)
            {
                baseChance = 1;
            }

            if (Util.Chance(baseChance))
            {
                ISpellHandler handler = ScriptMgr.CreateSpellHandler((GameLiving)sender, m_procSpell, m_procSpellLine);
                if (handler != null)
                {
                    switch (m_procSpell.Target.ToLower())
                    {
                    case "enemy":
                        handler.StartSpell(ad.Attacker);
                        break;

                    default:
                        handler.StartSpell(ad.Target);
                        break;
                    }
                }
            }
        }
Example #31
0
        protected void EventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            if (!(arguments is AttackFinishedEventArgs args) || args.AttackData == null)
            {
                return;
            }

            if (_trap == null)
            {
                _trap = MakeTrap();
            }

            if (Util.Chance(99))
            {
                _trap.CastSpell(args.AttackData.Target);
            }
        }
Example #32
0
            protected override void OnTick()
            {
                GameLiving target = m_boltTarget;
                GameLiving caster = (GameLiving)m_actionSource;

                if (target == null)
                {
                    return;
                }
                if (target.CurrentRegion.ID != caster.CurrentRegion.ID)
                {
                    return;
                }
                if (target.ObjectState != GameObject.eObjectState.Active)
                {
                    return;
                }
                if (!target.IsAlive)
                {
                    return;
                }
                if (target == null)
                {
                    return;
                }
                if (!target.IsAlive || target.ObjectState != GameLiving.eObjectState.Active)
                {
                    return;
                }

                AttackData ad = m_handler.CalculateDamageToTarget(target, 1);

                ad.Damage = (int)m_handler.Spell.Damage;
                m_handler.SendDamageMessages(ad);
                m_handler.DamageTarget(ad, false);

                //if (m_handler.Spell.SubSpellID != 0) Spell subspell = m_handler.SkillBase.GetSpellByID(m_handler.Spell.SubSpellID);
                if (m_handler.Spell.SubSpellID != 0 && SkillBase.GetSpellByID(m_handler.Spell.SubSpellID) != null)
                {
                    ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(caster, SkillBase.GetSpellByID(m_handler.Spell.SubSpellID), SkillBase.GetSpellLine("Mob Spells"));
                    spellhandler.StartSpell(target);
                }

                target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, caster);
            }
        protected void EventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            AttackFinishedEventArgs args = arguments as AttackFinishedEventArgs;

            if (args == null || args.AttackData == null)
            {
                return;
            }
            // Spirit procs lifetap when hitting ennemy
            if (_trap == null)
            {
                _trap = MakeTrap();
            }
            if (Util.Chance(50))
            {
                _trap.CastSpell(args.AttackData.Target);
            }
        }
Example #34
0
        public override int OnEffectExpires(GameSpellEffect effect, bool noMessages)
        {
            if (effect.Owner is GamePlayer)
            {
                GamePlayer player   = effect.Owner as GamePlayer;
                Spell      subspell = SkillBase.GetSpellByID(Spell.ResurrectMana);
                if (subspell != null)
                {
                    subspell.Level = Spell.Level;
                    ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(Caster, subspell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                    spellhandler?.StartSpell(Caster);
                }

                GameEventMgr.RemoveHandler(player, GameLivingEvent.AttackedByEnemy, new DOLEventHandler(OnAttack));
            }

            return(base.OnEffectExpires(effect, noMessages));
        }
Example #35
0
 public GameSpellEffect(ISpellHandler handler, int duration, int pulsefreq, bool mino)
     : this(handler, duration, pulsefreq, 1)
 {
     m_minotaur = mino;
 }
Example #36
0
		/// <summary>
		/// Constructs arguments for a cast failed event.
		/// </summary>
		public CastFailedEventArgs(ISpellHandler handler, Reasons reason) 
			: base(handler)
		{
			this.m_reason = reason;
		}
Example #37
0
		/// <summary>
		/// Constructs new pulsing spell effect
		/// </summary>
		/// <param name="spellHandler">the spell handler doing the pulsing</param>
		public PulsingSpellEffect(ISpellHandler spellHandler)
		{
			if (spellHandler == null)
				throw new ArgumentNullException("spellHandler");
			m_spellHandler = spellHandler;
		}
Example #38
0
 /// <summary>
 /// Find pulsing spell effect by spell handler
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="handler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>First occurence of PulsingSpellEffect in targets' concentration list or null</returns>
 public static PulsingSpellEffect FindPulsingSpellOnTarget(this GameLiving target, ISpellHandler handler)
 {
     PulsingSpellEffect effect = null;
     lock (target.ConcentrationEffects)
     {
         effect = target.PulsingSpellsOnTarget(handler).FirstOrDefault();
     }
     return effect;
 }
Example #39
0
		/// <summary>
		/// Called when spell has finished casting.
		/// </summary>
		/// <param name="handler"></param>
		public override void OnAfterSpellCastSequence(ISpellHandler handler)
		{
			base.OnAfterSpellCastSequence(handler);
			Brain.Notify(GameNPCEvent.CastFinished, this, new CastingEventArgs(handler));
		}
        public override void OnEffectPulse(GameSpellEffect effect)
        {
            if (storm == null || storm.ObjectState == GameObject.eObjectState.Deleted)
            {
                effect.Cancel(false);
                return;
            }
            if (tempest == null || s == null)
            {
                return;
            }
            int ranged = storm.GetDistanceTo(new Point3D((int)effect.Owner.X, (int)effect.Owner.Y, (int)effect.Owner.Z));
            if (ranged > 3000) return;

            if (s.Name == "Dazzling Array")
            {
                foreach (GamePlayer player in storm.GetPlayersInRadius(sRadius))
                {
                    tempest = ScriptMgr.CreateSpellHandler(m_caster, s, sl);
                    if ((player.IsAlive) && (GameServer.ServerRules.IsSameRealm(storm, player, true))) tempest.StartSpell((GameLiving)player);
                }
            }
            else
            {
                foreach (GamePlayer player in storm.GetPlayersInRadius(sRadius))
                {
                    tempest = ScriptMgr.CreateSpellHandler(m_caster, s, sl);
                    if ((player.IsAlive) && (GameServer.ServerRules.IsAllowedToAttack(storm, player, true))) tempest.StartSpell((GameLiving)player);
                }
            }
        }
Example #41
0
		/// <summary>
		/// Create a new portal effect.
		/// </summary>
		public UniPortalEffect(ISpellHandler handler, int duration)
			: base(handler, duration, 0) { }
Example #42
0
 /// <summary>
 /// Find pulsing spell by spell handler
 /// </summary>
 /// <param name="living"></param>
 /// <param name="handler"></param>
 /// <returns>first occurance of spellhandler in targets' conc list or null</returns>
 public static PulsingSpellEffect FindPulsingSpellOnTarget(GameLiving living, ISpellHandler handler)
 {
     lock (living.ConcentrationEffects)
     {
         foreach (IConcentrationEffect concEffect in living.ConcentrationEffects)
         {
             PulsingSpellEffect pulsingSpell = concEffect as PulsingSpellEffect;
             if (pulsingSpell == null) continue;
             if (pulsingSpell.SpellHandler == handler)
                 return pulsingSpell;
         }
         return null;
     }
 }
Example #43
0
 protected static void RegisterSpellHandler(int type, ISpellHandler handle)
 {
     handles.Add(type, handle);
 }
Example #44
0
		/// <summary>
		/// Overwrites the effect
		/// concentration based effects should never be overwritten
		/// </summary>
		/// <param name="effect">the new effect</param>
		public void Overwrite(GameSpellEffect effect)
		{
			if (Spell.Concentration > 0) 
			{

				if (log.IsWarnEnabled)
					log.Warn(effect.Name + " (" + effect.Spell.Name + ") is trying to overwrite " + Spell.Name + " which has concentration " + Spell.Concentration);
				return;
			}

			lock (m_LockObject)
			{
				// immunity effects in immunity state are already expired
				if (!m_expired)
				{
					m_expired = true;
					m_handler.OnEffectExpires(this, true);
				}
				StopTimers();
				m_handler = effect.m_handler;
				m_duration = effect.m_duration;
				m_pulseFreq = effect.m_pulseFreq;
				m_effectiveness = effect.m_effectiveness;
				StartTimers();
				if (Spell.Concentration > 0) 
				{
					SpellHandler.Caster.ConcentrationEffects.Add(this);
				}
				m_owner.EffectList.OnEffectsChanged(this);
				m_handler.OnEffectStart(this);
				m_handler.OnEffectPulse(this);
				m_expired = false;
			}
		}
Example #45
0
 public void Reset()
 {
     //MapType = 0;
     TurnNum = 0;
     _turnNumFlag = 0;
     FireLogin = false;
     _bombs = 0;
     PhyID = 0;
     Arks = 0;
     _currentIndex = null;
     _currentFire = null;
     _currentWind = 0;
     IsFirst = true;
     BlastX = -1;
     BlastY = -1;
     CurrentSpell = null;
     CurrentPorp = null;
     TempBox.Clear();
     StartedGameClass = 1;
     //ConsortiaID1 = 0;
     //ConsortiaID2 = 0;
     killFlag = false;
 }
Example #46
0
 /// <summary>
 /// Find effect by spell handler
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="spellHandler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>First occurence of GameSpellEffect in target's effect list or null</returns>
 public static GameSpellEffect FindEffectOnTarget(this GameLiving target, ISpellHandler spellHandler)
 {
     GameSpellEffect effect = null;
     lock (target.EffectList)
     {
         effect = target.EffectsOnTarget(spellHandler).FirstOrDefault();
     }
     return effect;
 }
Example #47
0
 /// <summary>
 /// Find pulsing spells effect by spell handler
 /// Inner Method to get Enumerable For LINQ.
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="handler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>All PulsingSpellEffect Matching SpellHandler in targets' concentration list</returns>
 private static IEnumerable<PulsingSpellEffect> PulsingSpellsOnTarget(this GameLiving target, ISpellHandler handler)
 {
     return target.ConcentrationEffects.OfType<PulsingSpellEffect>().Where(pfx => pfx.SpellHandler == handler);
 }
Example #48
0
		/// <summary>
		/// Creates a new game spell effect
		/// </summary>
		/// <param name="handler">the spell handler</param>
		/// <param name="duration">the spell duration in milliseconds</param>
		/// <param name="pulseFreq">the pulse frequency in milliseconds</param>
		/// <param name="effectiveness">the effectiveness</param>
		public GameSpellEffect(ISpellHandler handler, int duration, int pulseFreq, double effectiveness)
		{
			m_handler = handler;
			m_duration = duration;
			m_pulseFreq = pulseFreq;
			m_effectiveness = effectiveness;
			m_expired = true; // not started = expired
		}
 public FocusShellEffect(ISpellHandler handler, int duration, int pulseFreq, double effectiveness) : base(handler, duration, pulseFreq, effectiveness) { }
Example #50
0
		/// <summary>
		/// Constructs a new cast event args
		/// </summary>
		public CastingEventArgs(ISpellHandler handler)
		{
			this.m_handler = handler;
		}
		/// <summary>
		/// Callback after spell execution finished and next spell can be processed
		/// </summary>
		/// <param name="handler"></param>
		public override void OnAfterSpellCastSequence(ISpellHandler handler)
		{
			if (SpellTimer != null)
			{
				if (this == null || this.ObjectState != eObjectState.Active || !this.IsAlive || this.TargetObject == null || (this.TargetObject is GameLiving && this.TargetObject.ObjectState != eObjectState.Active || !(this.TargetObject as GameLiving).IsAlive))
					SpellTimer.Stop();
				else
				{
					int interval = 1500;

					if (Brain != null)
					{
						interval = Math.Min(interval, Brain.ThinkInterval);
					}

					SpellTimer.Start(interval);
				}
			}

			if (m_runningSpellHandler != null)
			{
				//prevent from relaunch
				base.OnAfterSpellCastSequence(handler);
			}
			
			// Notify Brain of Cast Finishing.
			if(Brain != null)
				Brain.Notify(GameNPCEvent.CastFinished, this, new CastingEventArgs(handler));
		}
Example #52
0
		/// <summary>
		/// Constructs a new cast event args
		/// </summary>
		public CastingEventArgs(ISpellHandler handler, GameLiving target)
		{
			this.m_handler = handler;
			this.m_target = target;
		}
Example #53
0
 protected void EventHandler(DOLEvent e, object sender, EventArgs arguments)
 {
     AttackFinishedEventArgs args = arguments as AttackFinishedEventArgs;
     if(args == null || args.AttackData == null)
         return;
     // Spirit procs lifetap when hitting ennemy
     if(_trap == null)
     {
         _trap = MakeTrap();
     }
     if(Util.Chance(50))
     {
         _trap.CastSpell(args.AttackData.Target);
     }
 }
Example #54
0
		public CastingEventArgs(ISpellHandler handler, GameLiving target, AttackData ad)
		{
			this.m_handler = handler;
			this.m_target = target;
			m_lastAttackData = ad;
		}
Example #55
0
 /// <summary>
 /// Find pulsing spell effect by spell handler
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="handler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>First occurence of PulsingSpellEffect in targets' concentration list or null</returns>
 public static List<PulsingSpellEffect> FindPulsingSpellsOnTarget(this GameLiving target, ISpellHandler handler)
 {
     List<PulsingSpellEffect> effects = null;
     lock (target.ConcentrationEffects)
     {
         effects = target.PulsingSpellsOnTarget(handler).ToList();
     }
     return effects;
 }
Example #56
0
 /// <summary>
 /// Find effect by spell handler
 /// </summary>
 /// <param name="target"></param>
 /// <param name="spellHandler"></param>
 /// <returns>first occurance of effect in target's effect list or null</returns>
 public static GameSpellEffect FindEffectOnTarget(GameLiving target, ISpellHandler spellHandler)
 {
     lock (target.EffectList)
     {
         foreach (IGameEffect effect in target.EffectList)
         {
             GameSpellEffect gsp = effect as GameSpellEffect;
             if (gsp == null)
                 continue;
             if (gsp.SpellHandler != spellHandler)
                 continue;
             if (gsp is GameSpellAndImmunityEffect && ((GameSpellAndImmunityEffect)gsp).ImmunityState)
                 continue; // ignore immunity effects
             return gsp;
         }
     }
     return null;
 }
 /// <summary>
 /// Creates a new game spell effect
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="duration"></param>
 /// <param name="pulseFreq"></param>
 public GameSpellAndImmunityEffect(ISpellHandler handler, int duration, int pulseFreq)
     : this(handler, duration, pulseFreq, 1)
 {
 }
Example #58
0
 /// <summary>
 /// Find effects by spell handler
 /// Inner Method to get Enumerable For LINQ.
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="spellHandler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>All GameSpellEffect matching SpellHandler in target's effect list</returns>
 private static IEnumerable<GameSpellEffect> EffectsOnTarget(this GameLiving target, ISpellHandler spellHandler)
 {
     return target.EffectList.OfType<GameSpellEffect>().Where(fx => !(fx is GameSpellAndImmunityEffect && ((GameSpellAndImmunityEffect)fx).ImmunityState)
                                                              && fx.SpellHandler == spellHandler);
 }
Example #59
0
		public override void OnAfterSpellCastSequence(ISpellHandler handler)
		{
			if (SpellTimer != null)
			{
				if (this == null || this.ObjectState != eObjectState.Active || !this.IsAlive || this.TargetObject == null || (this.TargetObject is GameLiving && this.TargetObject.ObjectState != eObjectState.Active || !(this.TargetObject as GameLiving).IsAlive))
					SpellTimer.Stop();
				else
					SpellTimer.Start(1);
			}
			if (m_runningSpellHandler != null)
			{
				//prevent from relaunch
				m_runningSpellHandler.CastingCompleteEvent -= new CastingCompleteCallback(OnAfterSpellCastSequence);
				m_runningSpellHandler = null;
			}

			Brain.Notify(GameNPCEvent.CastFinished, this, new CastingEventArgs(handler));
		}
Example #60
0
 /// <summary>
 /// Find effects by spell handler
 /// </summary>
 /// <param name="target">Living to find effect on</param>
 /// <param name="spellHandler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>All GameSpellEffect matching spellhandler in target's effect list or null</returns>
 public static List<GameSpellEffect> FindEffectsOnTarget(this GameLiving target, ISpellHandler spellHandler)
 {
     List<GameSpellEffect> effects = null;
     lock (target.EffectList)
     {
         effects = target.EffectsOnTarget(spellHandler).ToList();
     }
     return effects;
 }