Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        public override void CastSpell(Spell spell, SpellLine line)
        {
            if (IsStunned || IsMezzed)
            {
                Notify(GameLivingEvent.CastFailed, this, new CastFailedEventArgs(null, CastFailedEventArgs.Reasons.CrowdControlled));
                return;
            }

            if (m_runningSpellHandler != null && spell.CastTime > 0)
            {
                Notify(GameLivingEvent.CastFailed, this, new CastFailedEventArgs(null, CastFailedEventArgs.Reasons.AlreadyCasting));
                return;
            }

            ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(this, spell, line);

            if (spellhandler != null)
            {
                int power = spellhandler.PowerCost(Owner);

                if (Owner.Mana < power)
                {
                    Notify(GameLivingEvent.CastFailed, this, new CastFailedEventArgs(null, CastFailedEventArgs.Reasons.NotEnoughPower));
                    return;
                }

                m_runningSpellHandler              = spellhandler;
                spellhandler.CastingCompleteEvent += new CastingCompleteCallback(OnAfterSpellCastSequence);
                spellhandler.CastSpell();
            }
            else
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn(Name + " wants to cast but spell " + spell.Name + " not implemented yet");
                }

                return;
            }
        }
Exemplo n.º 3
0
        private void ApplyRelicEffect()
        {
            if (RelicSpell == null || _spellHandler == null || _gameSpellEffect == null)
            {
                return;
            }

            IList <GamePlayer> newPlayerlist = new List <GamePlayer>();

            if (Owner != null)
            {
                switch (RelicTarget.ToLower())
                {
                case "self":
                    newPlayerlist.Add(Owner);
                    break;

                case "group":
                    if (Owner.Group == null)
                    {
                        newPlayerlist.Add(Owner);
                    }
                    else
                    {
                        foreach (GamePlayer plr in Owner.Group.GetPlayersInTheGroup())
                        {
                            if (plr != null && !newPlayerlist.Contains(plr) && Owner.IsWithinRadius(plr, WorldMgr.VISIBILITY_DISTANCE))
                            {
                                newPlayerlist.Add(plr);
                            }
                        }
                    }

                    break;

                case "realm":
                    foreach (GamePlayer plr in Owner.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                    {
                        if (plr != null && GameServer.ServerRules.IsAllowedToAttack(Owner, plr, true) == false && !newPlayerlist.Contains(plr))
                        {
                            newPlayerlist.Add(plr);
                        }
                    }

                    break;
                }
            }

            lock (Playerlist)
            {
                foreach (GamePlayer plr in Playerlist)
                {
                    if (plr == null)
                    {
                        continue;
                    }

                    if (!newPlayerlist.Contains(plr))
                    {
                        try
                        {
                            lock (plr.EffectList)
                            {
                                GameSpellEffect check = SpellHandler.FindEffectOnTarget(plr, _gameSpellEffect.Spell.SpellType);
                                check?.Cancel(false);
                            }
                        }
                        catch (Exception e)
                        {
                            if (Log.IsErrorEnabled)
                            {
                                Log.Error($"Minotaur Relics : Effect Cancel : {e}");
                            }
                        }
                    }
                }

                foreach (GamePlayer plr in newPlayerlist)
                {
                    if (plr == null)
                    {
                        continue;
                    }

                    try
                    {
                        lock (plr.EffectList)
                        {
                            GameSpellEffect check = SpellHandler.FindEffectOnTarget(plr, _gameSpellEffect.Spell.SpellType);
                            if (check == null)
                            {
                                ISpellHandler   handler   = ScriptMgr.CreateSpellHandler(plr, RelicSpell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                                GameSpellEffect plreffect = null;
                                if (handler != null)
                                {
                                    plreffect = new GameSpellEffect(handler, RelicSpell.Duration, 0);
                                }

                                plreffect?.Start(plr);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (Log.IsErrorEnabled)
                        {
                            Log.Error($"Minotaur Relics : Effect Start : {e}");
                        }
                    }
                }

                Playerlist = newPlayerlist;
            }
        }