public MetaStoneUI(PlayerMobile user, BaseMetaPet pet, MetaStone stone, Gump parent = null) : base(user, parent, 0, 0) { CanDispose = true; CanMove = true; EntriesPerPage = 4; MetaPet = pet; MetaStone = stone; AutoRefresh = true; ForceRecompile = true; AutoRefreshRate = TimeSpan.FromSeconds(5.0); }
public void GetMeta(Mobile User, Mobile target) { var metapet = target as BaseMetaPet; if (metapet != null && metapet.Controlled && metapet.ControlMaster == User) { Pet = metapet; Hue = Pet.Hue; User.SendMessage(54, "You have successfully bound this meta stone to your Meta-Pet."); } else { User.SendMessage(54, "This can only be used on a Meta-Pet that you own!"); } }
protected override void OnTick() { if ( DateTime.UtcNow >= m_NextHourlyCheck ) { m_NextHourlyCheck = DateTime.UtcNow + TimeSpan.FromHours( 1.0 ); List<BaseCreature> toRelease = new List<BaseCreature>(); // added array for wild creatures in house regions to be removed List<BaseCreature> toRemove = new List<BaseCreature>(); foreach ( Mobile m in World.Mobiles.Values ) { if ( m is BaseMount && ((BaseMount)m).Rider != null ) { ((BaseCreature)m).OwnerAbandonTime = DateTime.MinValue; continue; } if ( m is BaseCreature ) { BaseCreature c = (BaseCreature)m; if (c is SkeletalMount) { c.Loyalty = BaseCreature.MaxLoyalty; continue; // skeletal mounts don't go untame } if ( c.IsDeadPet ) { Mobile owner = c.ControlMaster; if ( owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange( c, 12 ) || !c.CanSee( owner ) || !c.InLOS( owner ) ) { if ( c.OwnerAbandonTime == DateTime.MinValue ) c.OwnerAbandonTime = DateTime.UtcNow; else if ( (c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.UtcNow ) toRemove.Add( c ); } else c.OwnerAbandonTime = DateTime.MinValue; } else if ( c.Controlled && c.Commandable ) { c.OwnerAbandonTime = DateTime.MinValue; if ( c.Map != Map.Internal && !c.IsStabled ) { c.Loyalty -= (BaseCreature.MaxLoyalty / 10); if( c.Loyalty < (BaseCreature.MaxLoyalty / 10) ) { c.Say( 1043270, c.Name ); // * ~1_NAME~ looks around desperately * c.PlaySound( c.GetIdleSound() ); } if ( c.Loyalty <= 0) toRelease.Add( c ); } } // added lines to check if a wild creature in a house region has to be removed or not if ( !c.Controlled && !c.IsStabled && ( (c.Region.IsPartOf( typeof(HouseRegion) ) && c.CanBeDamaged()) || (c.RemoveIfUntamed && c.Spawner == null) ) ) { c.RemoveStep++; if ( c.RemoveStep >= 48 ) toRemove.Add( c ); } else c.RemoveStep = 0; } } foreach ( BaseCreature c in toRelease ) { try { string toWrite = DateTime.Now + "\t" + c + "\t" + this.GetType() + "\tBonded=" + c.IsBonded + "\tOwner=" + c.ControlMaster + "\tLoyalty:" + c.Loyalty + "\tIsStabled:" + c.IsStabled + "\tStabledDate:" + c.StabledDate; toWrite += "\n" + (new System.Diagnostics.StackTrace()).ToString(); LoggingCustom.Log("LOG_PetLoyaltyRelease.txt", toWrite); } catch { } c.Say( 1043255, c.Name ); // ~1_NAME~ appears to have decided that is better off without a master! c.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully Happy c.IsBonded = false; c.BondingBegin = DateTime.MinValue; c.OwnerAbandonTime = DateTime.UtcNow; c.ControlTarget = null; //c.ControlOrder = OrderType.Release; if (c is MetaDragon) { c.Say("The evolution dragon reverts back to its egg form."); var egg = new EvolutionEgg(c.Hue); egg.MoveToWorld(c.Location, c.Map); c.Delete(); } else c.AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers) } // added code to handle removing of wild creatures in house regions foreach (BaseCreature c in toRemove) { if (!c.IsStabled) { if (c is EvolutionDragon) { c.Say("The evolution dragon reverts back to its egg form."); var egg = new BaseMetaPet(); egg.MoveToWorld(c.Location, c.Map); } c.Delete(); } } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.GetVersion(); switch (version) { case 1: Pet = reader.ReadMobile<BaseMetaPet>(); goto case 0; case 0: break; } }