예제 #1
0
        private void PlayerAbsence(DOLEvent e, object sender, EventArgs args)
        {
            if (!(sender is GamePlayer player))
            {
                return;
            }

            if (e == GamePlayerEvent.AcceptGroup)
            {
                if (player.Group == null)
                {
                    return;
                }

                foreach (GamePlayer pl in player.Group.GetPlayersInTheGroup())
                {
                    if (pl.MinotaurRelic != null)
                    {
                        player.Out.SendMessage("Someone in your group already has a Relic!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        PlayerLoosesRelic(player, false);
                        return;
                    }
                }

                if (RelicTarget.ToLower() != "self")
                {
                    return;
                }
            }

            PlayerLoosesRelic(player, false);
        }
예제 #2
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;
            }
        }