feat: Adds leather/metal food, fixes weapons/armors with wrong materials (#1718)

### Summary
- Fixes the name `Vegies` to `Veggies`
- Adds feeding leather to goats
- Adds metal for Lava Lizards
- Fixes Bone Helm being classified as plate instead of bone.
- Fixes wooden shields not classified as wood.

### Note
On OSI, the preferred foods on the animal lore gump doesn't contain all possible favorite food categories. Furthermore, the one listed is not necessarily always the "first" in the list of possible categories. We aren't going to try and fix that since it isn't important.
This commit is contained in:
Kamron Batman 2024-04-04 19:43:02 -07:00 • committed by GitHub
parent 29ea813242
commit 974062b0d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 266 additions and 128 deletions

View file

@ -67,11 +67,13 @@ namespace Server.Mobiles
{
None = 0x0000,
Meat = 0x0001,
FruitsAndVegies = 0x0002,
FruitsAndVeggies = 0x0002,
GrainsAndHay = 0x0004,
Fish = 0x0008,
Eggs = 0x0010,
Gold = 0x0020
Gold = 0x0020,
Leather = 0x0040,
Metal = 0x0080
}
[Flags]
@ -205,22 +207,22 @@ namespace Server.Mobiles
private static readonly bool EnableRummaging = true;
public static readonly TimeSpan ShoutDelay = TimeSpan.FromMinutes(1);
private static readonly Type[] m_Eggs =
private static readonly Type[] _eggs =
{
typeof(FriedEggs), typeof(Eggs)
};
private static readonly Type[] m_Fish =
private static readonly Type[] _fish =
{
typeof(FishSteak), typeof(RawFishSteak)
};
private static readonly Type[] m_GrainsAndHay =
private static readonly Type[] _grainsAndHay =
{
typeof(BreadLoaf), typeof(FrenchBread), typeof(SheafOfHay)
};
private static readonly Type[] m_Meat =
private static readonly Type[] _meat =
{
/* Cooked */
typeof(Bacon), typeof(CookedBird), typeof(Sausage),
@ -236,7 +238,7 @@ namespace Server.Mobiles
typeof(Torso), typeof(RightArm), typeof(RightLeg)
};
private static readonly Type[] m_FruitsAndVegies =
private static readonly Type[] _fruitsAndVeggies =
{
typeof(HoneydewMelon), typeof(YellowGourd), typeof(GreenGourd),
typeof(Banana), typeof(Bananas), typeof(Lemon), typeof(Lime),
@ -246,12 +248,31 @@ namespace Server.Mobiles
typeof(Onion), typeof(Lettuce), typeof(Pumpkin)
};
private static readonly Type[] m_Gold =
private static readonly Type[] _gold =
{
// white wyrms eat gold..
typeof(Gold)
};
private static readonly Type[] _metal =
{
// Materials
typeof(BaseIngot), typeof(BaseOre),
// Containers
typeof(MetalChest), typeof(MetalGoldenChest), typeof(MetalBox),
// Crafting
typeof(Gears), typeof(Saw), typeof(Axle), typeof(AxleGears),
typeof(ClockParts), typeof(Hinge), typeof(Springs), typeof(Spyglass),
typeof(Fork), typeof(ForkLeft), typeof(ForkRight), typeof(Spoon),
typeof(SpoonLeft), typeof(SpoonRight), typeof(Knife), typeof(KnifeLeft),
typeof(KnifeRight), typeof(DrawKnife), typeof(Hammer), typeof(Froe), typeof(Inshave),
typeof(Nails), typeof(RunicDovetailSaw), typeof(RunicHammer), typeof(Skillet),
typeof(SledgeHammer), typeof(Tongs), typeof(TinkerTools), typeof(SmithHammer),
typeof(AncientSmithyHammer), typeof(Scorp)
};
private bool _summoned;
private bool m_bTamable;
@ -4155,40 +4176,107 @@ namespace Server.Mobiles
}
public virtual bool CheckFoodPreference(Item f) =>
CheckFoodPreference(f, FoodType.Eggs, m_Eggs) ||
CheckFoodPreference(f, FoodType.Fish, m_Fish) ||
CheckFoodPreference(f, FoodType.GrainsAndHay, m_GrainsAndHay) ||
CheckFoodPreference(f, FoodType.Meat, m_Meat) ||
CheckFoodPreference(f, FoodType.FruitsAndVegies, m_FruitsAndVegies) ||
CheckFoodPreference(f, FoodType.Gold, m_Gold);
CheckFoodPreference(f, FoodType.Eggs) ||
CheckFoodPreference(f, FoodType.Fish) ||
CheckFoodPreference(f, FoodType.GrainsAndHay) ||
CheckFoodPreference(f, FoodType.Meat) ||
CheckFoodPreference(f, FoodType.FruitsAndVeggies) ||
CheckFoodPreference(f, FoodType.Gold) ||
CheckFoodPreference(f, FoodType.Metal) ||
CheckFoodPreference(f, FoodType.Leather);
public virtual bool CheckFoodPreference(Item fed, FoodType type, Type[] types)
private bool CheckFoodPreference(Item fed, FoodType type)
{
if ((FavoriteFood & type) == 0)
{
return false;
}
var fedType = fed.GetType();
var contains = false;
for (var i = 0; !contains && i < types.Length; ++i)
// Goat special case
if (type == FoodType.Leather)
{
contains = fedType == types[i];
if (fed is BaseLeather or Bag or Pouch or Server.Items.Backpack or StrongBackpack)
{
return true;
}
if (fed is BaseArmor armor)
{
return armor.MaterialType
is ArmorMaterialType.Leather
or ArmorMaterialType.Studded
or ArmorMaterialType.Spined
or ArmorMaterialType.Horned
or ArmorMaterialType.Barbed;
}
CraftResource craftResource;
if (fed is BaseWeapon weapon)
{
craftResource = weapon.Resource;
}
else if (fed is BaseClothing clothing)
{
craftResource = clothing.Resource;
}
else
{
return false;
}
return CraftResources.GetType(craftResource) == CraftResourceType.Leather;
}
return contains;
if (type == FoodType.Metal)
{
if (fed is BaseArmor armor)
{
return armor.MaterialType
is ArmorMaterialType.Ringmail
or ArmorMaterialType.Chainmail
or ArmorMaterialType.Plate;
}
CraftResource craftResource;
if (fed is BaseWeapon weapon)
{
craftResource = weapon.Resource;
}
else if (fed is BaseClothing clothing)
{
craftResource = clothing.Resource;
}
else
{
return fed.GetType().InTypeList(_metal);
}
return CraftResources.GetType(craftResource) == CraftResourceType.Metal;
}
var types = type switch
{
FoodType.Eggs => _eggs,
FoodType.Fish => _fish,
FoodType.GrainsAndHay => _grainsAndHay,
FoodType.Meat => _meat,
FoodType.FruitsAndVeggies => _fruitsAndVeggies,
FoodType.Gold => _gold,
};
return fed.GetType().InTypeList(types);
}
public virtual bool CheckFeed(Mobile from, Item dropped)
{
if (IsDeadPet || !Controlled || (ControlMaster != from && !IsPetFriend(from)))
if (IsDeadPet || !Controlled || ControlMaster != from && !IsPetFriend(from))
{
return false;
}
if (!CheckFoodPreference(dropped))
{
PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1043257, from.NetState); // The animal shies away.
return false;
}
@ -4219,7 +4307,6 @@ namespace Server.Mobiles
m_Loyalty = Math.Min(MaxLoyalty, Utility.CoinFlips(amount, MaxLoyaltyIncrease) * 10);
}
/* if (happier )*/
// looks like in OSI pets say they are happier even if they are at maximum loyalty
SayTo(from, 502060); // Your pet looks happier.