Пример #1
0
        protected override void OnDeath()
        {
            if (m_brain != null)
            {
                m_brain.IsRunning = false;
            }

            if (m_Map != null || this != null)
            {
                var       rcvrs  = this.GetNearbyClients(false);
                var       looter = CalcLooter();
                Asda2Loot loot   = null;
                if (looter != null && m_Map.DefenceTownEvent == null)
                {
                    loot = Asda2LootMgr.GetOrCreateLoot(this, looter,
                                                        Asda2LootEntryType.Npc);
                    if (loot != null && Template != null)
                    {
                        loot.MonstrId = (short?)Template.Id;
                    }
                }



                Loot = null;
                var map = m_Map;
                m_Map.CallDelayed(LastDamageDelay, () =>
                {
                    Asda2CombatHandler.SendMostrDeadToAreaResponse(rcvrs,
                                                                   (short)
                                                                   UniqIdOnMap,
                                                                   (short)
                                                                   Asda2Position.
                                                                   X,
                                                                   (short)
                                                                   Asda2Position.
                                                                   Y);
                    map.OnNPCDied(this);

                    var chr = LastKiller as Character;
                    if (chr != null)
                    {
                        Asda2TitleChecker.OnNpcDeath(this, chr);
                        if (chr.IsInGroup)
                        {
                            chr.Group.ForeachCharacter(x => KillMonsterEventManager.TryGiveReward(x, Template.Id));
                        }
                        else
                        {
                            KillMonsterEventManager.TryGiveReward(chr, Template.Id);
                        }
                    }
                    if (loot != null && loot.Lootable is NPC)
                    {
                        var npc = ((NPC)loot.Lootable);
                        if (npc != null && npc.Map != null)
                        {
                            npc.Map.SpawnLoot(loot);
                        }
                    }

                    if (m_entry != null && Entry != null && Template != null)
                    {
                        if (Entry.Rank >= CreatureRank.Boss)
                        {
                            if (LastKiller != null)
                            {
                                ChatMgr.SendGlobalMessageResponse(LastKiller.Name,
                                                                  ChatMgr.Asda2GlobalMessageType
                                                                  .HasDefeated, 0, 0,
                                                                  (short)Template.Id);
                            }
                            if (chr != null)
                            {
                                chr.GuildPoints += m_entry.MinLevel * CharacterFormulas.BossKillingGuildPointsPerLevel;
                            }
                        }
                        else
                        {
                            if (chr != null && chr.Level < m_entry.MinLevel + 3)
                            {
                                chr.GuildPoints += CharacterFormulas.MobKillingGuildPoints;
                            }
                        }
                        // notify events
                        m_entry.NotifyDied(this);
                    }
                    EnterFinalState();
                });
            }


            //UnitFlags |= UnitFlags.SelectableNotAttackable;

            // send off the tamer
            if (m_currentTamer != null)
            {
                PetHandler.SendTameFailure(m_currentTamer, TameFailReason.TargetDead);
                CurrentTamer.SpellCast.Cancel(SpellFailedReason.Ok);
            }

            // reset spawn timer
            if (m_spawnPoint != null)
            {
                m_spawnPoint.SignalSpawnlingDied(this);
            }
        }
Пример #2
0
        protected override void OnDeath()
        {
            m_brain.IsRunning = false;

            // hand out experience
            bool heroic;

            if (m_Map != null)
            {
                m_Map.OnNPCDied(this);
                heroic = m_Map.IsHeroic;
            }
            else
            {
                heroic = false;
            }

            var looter = m_FirstAttacker;

            if (!HasPlayerMaster)               // not player-owned NPC
            {
                var playerLooter = looter != null ? looter.PlayerOwner : null;
                if (playerLooter != null &&
                    LootMgr.GetOrCreateLoot(this, playerLooter, LootEntryType.NPCCorpse, heroic) != null)
                {
                    // NPCs don't have Corpse objects -> Spawning NPC Corpses will cause client to crash
                    //RemainingDecayDelay = m_entry.DefaultDecayDelay * 10;
                    EnterLootableState();
                }
                else
                {
                    // no loot
                    EnterFinalState();
                }
            }

            // notify events
            m_entry.NotifyDied(this);

            UnitFlags |= UnitFlags.SelectableNotAttackable;

            // send off the tamer
            if (m_currentTamer != null)
            {
                PetHandler.SendTameFailure(m_currentTamer, TameFailReason.TargetDead);
                CurrentTamer.SpellCast.Cancel(SpellFailedReason.Ok);
            }

            // reset spawn timer
            if (m_spawnPoint != null)
            {
                m_spawnPoint.SignalSpawnlingDied(this);
            }

            if (m_master != null)
            {
                // notify master
                if (m_master.IsInWorld)
                {
                    m_master.OnMinionDied(this);
                }
                else
                {
                    Delete();
                }
            }
        }