Esempio n. 1
0
        /// <summary>
        /// Called whenever the dragon's body sends something to its brain.
        /// </summary>
        /// <param name="e">The event that occured.</param>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The event details.</param>
        public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args)
        {
            base.Notify(e, sender, args);
            if (sender == Body)
            {
                GameDragon dragon = sender as GameDragon;
                if (e == GameObjectEvent.TakeDamage)
                {
                    if (CheckHealth())
                    {
                        return;
                    }

                    // Someone hit the dragon. If the attacker is in melee range, there
                    // is a chance the dragon will cast a debuff specific to melee
                    // classes on him, if not, well, dragon will try to get its Glare off...
                    GameObject source = (args as TakeDamageEventArgs).DamageSource;
                    if (source != null)
                    {
                        if (dragon.IsWithinRadius(source, dragon.AttackRange))
                        {
                            dragon.CheckMeleeDebuff(source as GamePlayer);
                        }
                        else
                        {
                            dragon.CheckGlare(source as GamePlayer);
                        }
                    }
                    else
                    {
                        log.Error("Dragon takes damage from null source. args = " + (args == null ? "null" : args.ToString()));
                    }
                }
                else if (e == GameLivingEvent.EnemyHealed)
                {
                    // Someone healed an enemy. If the healer is in melee range, there
                    // is a chance the dragon will cast a debuff specific to ranged
                    // classes on him, if not, there's still Glare...
                    GameObject source = (args as EnemyHealedEventArgs).HealSource;

                    if (source != null)
                    {
                        if (dragon.IsWithinRadius(source, dragon.AttackRange))
                        {
                            dragon.CheckRangedDebuff(source as GamePlayer);
                        }
                        else
                        {
                            dragon.CheckGlare(source as GamePlayer);
                        }
                    }
                    else
                    {
                        log.Error("Dragon heal source null. args = " + (args == null ? "null" : args.ToString()));
                    }
                }
            }
            else if (e == GameNPCEvent.ArriveAtTarget && sender != null)
            {
                // Message from another NPC, such as a retriever,
                // for example.
                log.Info(string.Format("DragonBrain.Notify: ArriveAtTarget({0})", (sender as GameObject).Name));
                (Body as GameDragon).OnRetrieverArrived(sender as GameNPC);
            }
        }