1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-25 11:36:26 -05:00

Render body parts based on torso (#54)

* Update

* Partial work

* More stuff

* Shield rendering

* tmp

* Update

* WeaponCode

* Cleanup

* Fix build

* Initial inventory cleanup and sync

* Update

* Render body parts based on equipped torso
This commit is contained in:
Diego M 2018-12-15 19:40:23 -03:00 committed by Tim Sarbin
parent be29a0017e
commit 3dc1af294c
4 changed files with 53 additions and 16 deletions

View File

@ -9,25 +9,56 @@ using System.Threading.Tasks;
namespace OpenDiablo2.Common.Models
{
public sealed class Armor : Item
public sealed class Armor : Item
{
public string Type { get; internal set; } = "FIXME"; // TODO: Fix this please
public string Type { get; internal set; }
public Dictionary<eCompositType, eArmorType> ArmorTypes = new Dictionary<eCompositType, eArmorType>() {
{eCompositType.RightArm, eArmorType.Lite},
{eCompositType.LeftArm, eArmorType.Lite},
{eCompositType.Torso, eArmorType.Lite},
{eCompositType.Legs, eArmorType.Lite},
{eCompositType.Special1, eArmorType.Lite},
{eCompositType.Special2, eArmorType.Lite},
};
}
public static class ArmorHelper
{
public static Armor ToArmor(this string[] row)
=> new Armor
public static Armor ToArmor(this string[] row)
{
var Armor = new Armor
{
Name = row[0],
Code = row[17],
InvFile = row[34]
InvFile = row[34],
Type = row[48]
};
if(Armor.Type == "tors")
{
Armor.ArmorTypes[eCompositType.RightArm] = (eArmorType)Enum.Parse(typeof(eArmorType), row[37]);
Armor.ArmorTypes[eCompositType.LeftArm] = (eArmorType)Enum.Parse(typeof(eArmorType), row[38]);
Armor.ArmorTypes[eCompositType.Torso] = (eArmorType)Enum.Parse(typeof(eArmorType), row[39]);
Armor.ArmorTypes[eCompositType.Legs] = (eArmorType)Enum.Parse(typeof(eArmorType), row[40]);
Armor.ArmorTypes[eCompositType.Special1] = (eArmorType)Enum.Parse(typeof(eArmorType), row[41]);
Armor.ArmorTypes[eCompositType.Special2] = (eArmorType)Enum.Parse(typeof(eArmorType), row[42]);
}
return Armor;
}
public static void Write(this BinaryWriter binaryWriter, Armor armor)
{
(armor as Item).Write(binaryWriter);
binaryWriter.Write(armor.Type);
// Assuming order will be fine
foreach(var armorType in armor.ArmorTypes)
{
binaryWriter.Write((byte)armorType.Value);
}
}
public static Armor ReadItemArmor(this BinaryReader binaryReader)
@ -35,6 +66,14 @@ namespace OpenDiablo2.Common.Models
var result = new Armor();
Item.Read(binaryReader, result);
result.Type = binaryReader.ReadString();
result.ArmorTypes[eCompositType.RightArm] = (eArmorType)binaryReader.ReadByte();
result.ArmorTypes[eCompositType.LeftArm] = (eArmorType)binaryReader.ReadByte();
result.ArmorTypes[eCompositType.Torso] = (eArmorType)binaryReader.ReadByte();
result.ArmorTypes[eCompositType.Legs] = (eArmorType)binaryReader.ReadByte();
result.ArmorTypes[eCompositType.Special1] = (eArmorType)binaryReader.ReadByte();
result.ArmorTypes[eCompositType.Special2] = (eArmorType)binaryReader.ReadByte();
return result;
}
}

View File

@ -35,15 +35,6 @@ namespace OpenDiablo2.Common.Models.Mobs
}
}
public eArmorType ArmorType
{
get
{
// TODO: Make things happen here
return eArmorType.Lite;
}
}
public string HashKey
=> $"{Head?.Item.Name}{Neck?.Item.Name}{Torso?.Item.Name}{RightArm?.Item.Name}{LeftArm?.Item.Name}" +
$"{RightRing?.Item.Name}{LeftRing?.Item.Name}{Feet?.Item.Name}{Belt?.Item.Name}{Gloves?.Item.Name}";

View File

@ -124,6 +124,11 @@ namespace OpenDiablo2.Core
public string GetCharacterDccPath(eHero hero, eMobMode mobMode, eCompositType compositType, PlayerEquipment equipment)
{
var fileName = $@"{ResourcePaths.PlayerAnimationBase}\{hero.ToToken()}\{compositType.ToToken()}\{hero.ToToken()}{compositType.ToToken()}".ToLower();
var armorType = eArmorType.Lite;
// Override default armor type based on equipped torso
if(equipment.Torso != null && (equipment.Torso.Item as Armor).ArmorTypes.ContainsKey(compositType))
armorType = (equipment.Torso.Item as Armor).ArmorTypes[compositType];
switch (compositType)
{
@ -136,7 +141,7 @@ namespace OpenDiablo2.Core
case eCompositType.Legs:
case eCompositType.RightArm:
case eCompositType.LeftArm:
fileName += $"{equipment.ArmorType.ToToken()}{mobMode.ToToken()}";
fileName += $"{armorType.ToToken()}{mobMode.ToToken()}";
return _mpqLookup.ContainsKey($"{fileName}{equipment.WeaponClass.ToToken()}.dcc".ToLower())
? $"{fileName}{equipment.WeaponClass.ToToken()}.dcc".ToLower()
: $"{fileName}{eWeaponClass.HandToHand.ToToken()}.dcc".ToLower();
@ -160,7 +165,7 @@ namespace OpenDiablo2.Core
// TODO: Figure these out...
case eCompositType.Special1:
case eCompositType.Special2:
fileName += $"{equipment.ArmorType.ToToken()}{mobMode.ToToken()}{equipment.WeaponClass}.dcc".ToLower();
fileName += $"{armorType.ToToken()}{mobMode.ToToken()}{equipment.WeaponClass}.dcc".ToLower();
return _mpqLookup.ContainsKey(fileName)
? fileName
: null; // TODO: Should we silence this?

View File

@ -76,6 +76,8 @@ namespace OpenDiablo2.GameServer_
}
}
// TODO: Default torso for testing. Remove when... we're done testing.
newPlayer.UpdateEquipment("tors", itemManager.getItemInstance("aar"));
mobManager.AddPlayer(newPlayer);
return newPlayer.Id;