| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- using Server.MirEnvir;
- namespace Server.MirDatabase
- {
- public class IntelligentCreatureInfo
- {
- protected static Envir Envir
- {
- get { return Envir.Main; }
- }
- public static List<IntelligentCreatureInfo> Creatures = new List<IntelligentCreatureInfo>();
- public IntelligentCreatureType PetType;
- public int Icon;
- public int MinimalFullness = 1000;
- public bool MousePickupEnabled = false;
- public int MousePickupRange = 0;
- public bool AutoPickupEnabled = false;
- public int AutoPickupRange = 0;
- public bool SemiAutoPickupEnabled = false;
- public int SemiAutoPickupRange = 0;
- public bool CanProduceBlackStone = false;
- static IntelligentCreatureInfo()
- {
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BabyPig, Icon = 500, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 3, MinimalFullness = 4000 };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Chick, Icon = 501, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 7, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 7, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Kitten, Icon = 502, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 3, MinimalFullness = 6000 };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BabySkeleton, Icon = 503, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 7, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 7, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Baekdon, Icon = 504, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 7, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 7, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Wimaen, Icon = 505, MousePickupEnabled = true, MousePickupRange = 7, AutoPickupEnabled = true, AutoPickupRange = 5, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 5, MinimalFullness = 5000 };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BlackKitten, Icon = 506, MousePickupEnabled = true, MousePickupRange = 7, AutoPickupEnabled = true, AutoPickupRange = 5, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 5, MinimalFullness = 5000 };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BabyDragon, Icon = 507, MousePickupEnabled = true, MousePickupRange = 7, AutoPickupEnabled = true, AutoPickupRange = 5, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 5, MinimalFullness = 7000 };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.OlympicFlame, Icon = 508, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BabySnowMan, Icon = 509, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Frog, Icon = 510, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.BabyMonkey, Icon = 511, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.AngryBird, Icon = 512, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.Foxey, Icon = 513, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- new IntelligentCreatureInfo { PetType = IntelligentCreatureType.MedicalRat, Icon = 514, MousePickupEnabled = true, MousePickupRange = 11, AutoPickupEnabled = true, AutoPickupRange = 11, SemiAutoPickupEnabled = true, SemiAutoPickupRange = 11, CanProduceBlackStone = true };
- }
- public IntelligentCreatureInfo()
- {
- Creatures.Add(this);
- }
- public static IntelligentCreatureInfo GetCreatureInfo(IntelligentCreatureType petType)
- {
- for (int i = 0; i < Creatures.Count; i++)
- {
- IntelligentCreatureInfo info = Creatures[i];
- if (info.PetType != petType) continue;
- return info;
- }
- return null;
- }
- }
- public class UserIntelligentCreature
- {
- protected static Envir Envir
- {
- get { return Envir.Main; }
- }
- public IntelligentCreatureType PetType;
- public IntelligentCreatureInfo Info;
- public IntelligentCreatureItemFilter Filter;
- public IntelligentCreaturePickupMode petMode = IntelligentCreaturePickupMode.SemiAutomatic;
- public string CustomName;
- public int Fullness;
- public int SlotIndex;
- public DateTime Expire;
- public long BlackstoneTime = 0;
- public long MaintainFoodTime = 0;
- public UserIntelligentCreature(IntelligentCreatureType creatureType, int slot, byte effect = 0)
- {
- PetType = creatureType;
- Info = IntelligentCreatureInfo.GetCreatureInfo(PetType);
- CustomName = Envir.Main.GetMonsterInfo(64, (byte)PetType)?.Name ?? PetType.ToString();
- Fullness = 7500;//starts at 75% food
- SlotIndex = slot;
- if (effect > 0) Expire = Envir.Now.AddDays(effect);//effect holds the amount in days
- else Expire = DateTime.MinValue;//permanent
- BlackstoneTime = 0;
- MaintainFoodTime = 0;
- Filter = new IntelligentCreatureItemFilter();
- }
- public UserIntelligentCreature(BinaryReader reader, int version, int customVersion)
- {
- PetType = (IntelligentCreatureType)reader.ReadByte();
- Info = IntelligentCreatureInfo.GetCreatureInfo(PetType);
- CustomName = reader.ReadString();
- Fullness = reader.ReadInt32();
- SlotIndex = reader.ReadInt32();
- var expireTime = reader.ReadInt64();
- if (expireTime == -9999)
- {
- Expire = DateTime.MinValue;
- }
- else
- {
- Expire = Envir.Now.AddSeconds(expireTime);
- }
- BlackstoneTime = reader.ReadInt64();
- petMode = (IntelligentCreaturePickupMode)reader.ReadByte();
- Filter = new IntelligentCreatureItemFilter(reader);
- if (version > 48)
- {
- Filter.PickupGrade = (ItemGrade)reader.ReadByte();
- MaintainFoodTime = reader.ReadInt64();//maintain food buff
- }
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write((byte)PetType);
- writer.Write(CustomName);
- writer.Write(Fullness);
- writer.Write(SlotIndex);
- if (Expire == DateTime.MinValue)
- {
- writer.Write((long)-9999);
- }
- else
- {
- writer.Write((long)(Expire - Envir.Now).TotalSeconds);
- }
- writer.Write(BlackstoneTime);
- writer.Write((byte)petMode);
- Filter.Save(writer);
- writer.Write((byte)Filter.PickupGrade);//since Envir.Version 49
- writer.Write(MaintainFoodTime);//maintain food buff
- }
- public Packet GetInfo()
- {
- return new ServerPackets.NewIntelligentCreature
- {
- Creature = CreateClientIntelligentCreature()
- };
- }
- public ClientIntelligentCreature CreateClientIntelligentCreature()
- {
- return new ClientIntelligentCreature
- {
- PetType = PetType,
- Icon = Info.Icon,
- CustomName = CustomName,
- Fullness = Fullness,
- SlotIndex = SlotIndex,
- Expire = Expire,
- BlackstoneTime = BlackstoneTime,
- MaintainFoodTime = MaintainFoodTime,
- petMode = petMode,
- CreatureRules = new IntelligentCreatureRules
- {
- MinimalFullness = Info.MinimalFullness,
- MousePickupEnabled = Info.MousePickupEnabled,
- MousePickupRange = Info.MousePickupRange,
- AutoPickupEnabled = Info.AutoPickupEnabled,
- AutoPickupRange = Info.AutoPickupRange,
- SemiAutoPickupEnabled = Info.SemiAutoPickupEnabled,
- SemiAutoPickupRange = Info.SemiAutoPickupRange,
- CanProduceBlackStone = Info.CanProduceBlackStone
- },
- Filter = Filter
- };
- }
- }
- }
|