Inheritance: Server.Items.LockableContainer
Ejemplo n.º 1
0
		public override bool OnBeforeDeath()
		{
			int treasureLevel = TreasureMapLevel;

            // you can live forever!! mwahaha
            if (XmlScript.HasTrigger(this, TriggerName.onBeforeDeath) && UberScriptTriggers.Trigger(this, this.LastKiller, TriggerName.onBeforeDeath))
            {
                return false;
            }

/*
			if ( treasureLevel == 1 && this.Map == Map.Trammel && TreasureMap.IsInHavenIsland( this ) )
			{
				Mobile killer = this.LastKiller;

				if ( killer is BaseCreature )
					killer = ((BaseCreature)killer).GetMaster();

				if ( killer is PlayerMobile && ((PlayerMobile)killer).Young )
					treasureLevel = 0;
			}
*/

            // ALAN MOD: for pseudoseer controlled mobs
            if (Party != null && Party is Party)
            {
                try
                {
                    ((Party)Party).Remove(this);
                }
                catch { }
            }
            // END ALAN MOD

            // if they are controlled by a pseudoseer, attempt to reconnect:

            if (this.NetState != null && !CreaturePossession.AttemptReturnToOriginalBody(this.NetState))
            {
                this.NetState.Dispose();
            }

			if ( !Summoned && !NoKillAwards && !IsBonded && treasureLevel >= 0 )
			{
				if ( m_Paragon || m_Corrupt)
                {
                    if (m_Paragon)
                    {
                        if (Fame < 10000)
                            ForceAddLoot(LootPack.Rich, 2);
                        else if (Fame < 20000)
                            ForceAddLoot(LootPack.FilthyRich, 2);
                        else
                            ForceAddLoot(LootPack.FilthyRich, 4);
                    }


                    if (m_Paragon && Paragon.ChestChance > Utility.RandomDouble())
                    {
                        var chest = new ParagonChest(Name, treasureLevel);
                        PackItem(chest);

                        if (Utility.RandomDouble() < PseudoSeerStone.MobStatueChance*2)
                        {
                            MonsterStatuette.TryAddStatue(chest, GetType(), 1157);
                        }
                    }

                    if (m_Corrupt && HalloweenEventController.Instance != null && HalloweenEventController.CostumeChance > Utility.RandomDouble())
                        PackItem(HalloweenMask.Randomize());

                    if (m_Corrupt && HalloweenEventController.Instance != null && HalloweenEventController.HalloweenSkinDyeChance > Utility.RandomDouble())
                        PackItem(Utility.RandomBool() ? new HalloweenPaint(1358) : new HalloweenPaint(1378));

                    if (m_Corrupt && Paragon.ChestChance > Utility.RandomDouble())
                    {
                        var chest = new ParagonChest(Name, treasureLevel);
                        chest.Hue = Hue;
                        PackItem(chest);
                        chest.Name = "Chest of Goodies";

                        if (Utility.RandomDouble() < 0.01)
                        {
                            MonsterStatuette.TryAddStatue(chest, GetType(), Hue);
                        }
                    }

                }
				else if ( (Map == Map.Felucca) && TreasureMap.LootChance >= Utility.RandomDouble() )
					PackItem( new TreasureMap( treasureLevel, Map ) );

			    var metapet = LastKiller as BaseMetaPet;
			    if (metapet != null)
			    {
                    metapet.DoAbility(MetaSkillType.GoldFind, this);
			    }
			}

			if ( !Summoned && !NoKillAwards && !m_HasGeneratedLoot )
			{
				m_HasGeneratedLoot = true;
				GenerateLoot( false );
			}

			if ( !NoKillAwards && ( Region != null && Region.IsPartOf( "Doom" ) ) )
			{
				int bones = Engines.Quests.Doom.TheSummoningQuest.GetDaemonBonesFor( this );

				if ( bones > 0 )
					PackItem( new DaemonBone( bones ) );
			}

            if (Invasion != null)
            {
                Invasion.HandleInvaderDeath(this);
            }

            if (Portal != null)
            {
                Portal.HandleMobDeath(this);
            }

			if ( IsAnimatedDead )
				Effects.SendLocationEffect( Location, Map, 0x3728, 13, 1, 0x461, 4 );

			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null && Speaks)
				speechType.OnDeath( this );

            
			return base.OnBeforeDeath();
		}