Exemplo n.º 1
0
        public override void OnEffectStart(GameSpellEffect effect)
        {
            base.OnEffectStart(effect);
            m_effect = effect;
            if (effect.Owner == null || !effect.Owner.IsAlive)
            {
                return;
            }

            if ((effect.Owner is GamePlayer))
            {
                GamePlayer casterPlayer = effect.Owner as GamePlayer;
                if (casterPlayer.GroundTarget != null && casterPlayer.GroundTargetInView)
                {
                    GameEventMgr.AddHandler(casterPlayer, GamePlayerEvent.Moving, new DOLEventHandler(PlayerMoves));
                    GameEventMgr.AddHandler(warder, GameLivingEvent.Dying, new DOLEventHandler(BattleWarderDie));
                    GameEventMgr.AddHandler(casterPlayer, GamePlayerEvent.CastStarting, new DOLEventHandler(PlayerMoves));
                    GameEventMgr.AddHandler(casterPlayer, GamePlayerEvent.AttackFinished, new DOLEventHandler(PlayerMoves));
                    warder.X = casterPlayer.GroundTarget.X;
                    warder.Y = casterPlayer.GroundTarget.Y;
                    warder.Z = casterPlayer.GroundTarget.Z;
                    warder.AddBrain(new MLBrain());
                    warder.AddToWorld();
                }
                else
                {
                    MessageToCaster("Your area target is out of range.  Set a closer ground position.", eChatType.CT_SpellResisted);
                    effect.Cancel(false);
                }
            }
        }
        /// <summary>
        /// called when spell effect has to be started and applied to targets
        /// </summary>
        public override bool StartSpell(GameLiving target)
        {
            if (target == null)
            {
                return(false);
            }

            IList targets      = SelectTargets(target);
            IList realmtargets = SelectRealmTargets(target);

            foreach (GameLiving t in targets)
            {
                if (t.Level <= m_spell.Value)
                {
                    GameNPC mob = (GameNPC)t;
                    if (mob.Brain is StandardMobBrain)
                    {
                        StandardMobBrain sBrain = (StandardMobBrain)mob.Brain;
                        //mob.StopAttack();

                        foreach (GamePlayer player in realmtargets)
                        {
                            sBrain.RemoveFromAggroList(player);
                        }
                    }

                    mob.AddBrain(new FriendBrain(this));
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public override void OnEffectStart(GameSpellEffect effect)
        {
            base.OnEffectStart(effect);

            GamePlayer player = Caster as GamePlayer;
            GameNPC    npc    = effect.Owner as GameNPC;

            if (player != null && npc != null)
            {
                if (m_controlledBrain == null)
                {
                    m_controlledBrain = new ControlledNpcBrain(player);
                }

                if (!m_isBrainSet)
                {
                    npc.AddBrain(m_controlledBrain);
                    m_isBrainSet = true;

                    GameEventMgr.AddHandler(npc, GameLivingEvent.PetReleased, new DOLEventHandler(ReleaseEventHandler));
                }

                if (player.ControlledBrain != m_controlledBrain)
                {
                    // sorc: "The slough serpent is enthralled!" ct_spell
                    Message.SystemToArea(effect.Owner, Util.MakeSentence(Spell.Message1, npc.GetName(0, false)), eChatType.CT_Spell);
                    MessageToCaster(npc.GetName(0, true) + " is now under your control.", eChatType.CT_Spell);

                    player.SetControlledBrain(m_controlledBrain);

                    foreach (GamePlayer ply in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                    {
                        ply.Out.SendNPCCreate(npc);
                        if (npc.Inventory != null)
                        {
                            ply.Out.SendLivingEquipmentUpdate(npc);
                        }

                        ply.Out.SendObjectGuildID(npc, player.Guild);
                    }
                }
            }
            else
            {
                // something went wrong.
                if (log.IsWarnEnabled)
                {
                    log.Warn(string.Format("charm effect start: Caster={0} effect.Owner={1}",
                                           (Caster == null ? "(null)" : Caster.GetType().ToString()),
                                           (effect.Owner == null ? "(null)" : effect.Owner.GetType().ToString())));
                }
            }
        }
Exemplo n.º 4
0
        public override int OnEffectExpires(GameSpellEffect effect, bool noMessages)
        {
            GameNPC mob = (GameNPC)effect.Owner;

            mob.RemoveBrain(mob.Brain);

            if (mob.Brain == null)
            {
                mob.AddBrain(new StandardMobBrain());
            }

            return(base.OnEffectExpires(effect, noMessages));
        }