98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
|
|
|
using Wonderking.Game.Data.Item;
|
|
|
|
namespace Wonderking.Game.Reader;
|
|
|
|
public static class ItemReaderExtensions
|
|
{
|
|
public static Stats ReadStats(this BinaryReader reader)
|
|
{
|
|
return new Stats
|
|
{
|
|
Strength = reader.ReadInt32(), //125
|
|
Dexterity = reader.ReadInt32(), //129
|
|
Intelligence = reader.ReadInt32(), //133
|
|
Vitality = reader.ReadInt32(), //137
|
|
Luck = reader.ReadInt32(), //141
|
|
Wisdom = reader.ReadInt32() //145
|
|
};
|
|
}
|
|
|
|
public static ElementalStats ReadElementalStats(this BinaryReader reader)
|
|
{
|
|
return new ElementalStats
|
|
{
|
|
MinimumFireDamage = reader.ReadInt32(), //149
|
|
MinimumWaterDamage = reader.ReadInt32(), //153
|
|
MinimumDarkDamage = reader.ReadInt32(), //157
|
|
MinimumHolyDamage = reader.ReadInt32(), //161
|
|
MaximumFireDamage = reader.ReadInt32(), //165
|
|
MaximumWaterDamage = reader.ReadInt32(), //169
|
|
MaximumDarkDamage = reader.ReadInt32(), //173
|
|
MaximumHolyDamage = reader.ReadInt32(), //177
|
|
ElementFire = reader.ReadUInt32(), //181
|
|
ElementWater = reader.ReadUInt32(), //185
|
|
ElementDark = reader.ReadUInt32(), //189
|
|
ElementHoly = reader.ReadUInt32(), //193
|
|
FireResistance = reader.ReadInt32(), //197
|
|
WaterResistance = reader.ReadInt32(), //201
|
|
DarkResistance = reader.ReadInt32(), //205
|
|
HolyResistance = reader.ReadInt32() //209
|
|
};
|
|
}
|
|
|
|
public static ContainedItem[] ReadContainedItems(this BinaryReader reader)
|
|
{
|
|
var list = new ContainedItem[5];
|
|
//893
|
|
for (var i = 0; i < 5; i++)
|
|
{
|
|
list[i].ID = reader.ReadInt16();
|
|
}
|
|
|
|
//903
|
|
for (var i = 0; i < 5; i++)
|
|
{
|
|
list[i].ObtainChance = reader.ReadSingle();
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
public static CraftMaterial[] ReadCraftMaterial(this BinaryReader reader)
|
|
{
|
|
var mats = new CraftMaterial[4];
|
|
//329
|
|
for (var i = 0; i < 4; ++i)
|
|
{
|
|
mats[i].ID = reader.ReadUInt32();
|
|
}
|
|
|
|
//345
|
|
for (var i = 0; i < 4; ++i)
|
|
{
|
|
mats[i].ID = reader.ReadUInt32();
|
|
}
|
|
|
|
return mats;
|
|
}
|
|
|
|
public static ItemOptions ReadItemOptions(this BinaryReader reader)
|
|
{
|
|
var options = new ItemOptions();
|
|
|
|
options.OptionAvailable = reader.ReadInt32() == 1; //819
|
|
|
|
var optionIDs = new List<uint>(4);
|
|
//823
|
|
for (var i = 0; i < 3; i++)
|
|
{
|
|
optionIDs.Add(reader.ReadUInt32());
|
|
}
|
|
|
|
options.OptionIDs = optionIDs.ToArray();
|
|
|
|
return options;
|
|
}
|
|
}
|