From 82723141a2308df3fe033fbf7be782733232e19c Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Mon, 18 Apr 2022 08:31:22 -0700 Subject: [PATCH] Fix spell targeting to use NPC index instead of ID --- EOLib/Domain/Character/Character.cs | 2 ++ EOLib/Domain/Character/CharacterActions.cs | 2 +- EOLib/Domain/Interact/MapNPCActions.cs | 6 +++--- EOLib/Domain/NPC/INPC.cs | 2 -- EOLib/Domain/NPC/NPC.cs | 4 ++-- EOLib/Domain/Spells/ISpellTargetable.cs | 2 ++ 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/EOLib/Domain/Character/Character.cs b/EOLib/Domain/Character/Character.cs index b954d907a..7319442f5 100644 --- a/EOLib/Domain/Character/Character.cs +++ b/EOLib/Domain/Character/Character.cs @@ -6,6 +6,8 @@ public class Character : ICharacter { public int ID { get; private set; } + public int Index => ID; + public string Name { get; private set; } public string Title { get; private set; } diff --git a/EOLib/Domain/Character/CharacterActions.cs b/EOLib/Domain/Character/CharacterActions.cs index 6c1f455a9..957648703 100644 --- a/EOLib/Domain/Character/CharacterActions.cs +++ b/EOLib/Domain/Character/CharacterActions.cs @@ -138,7 +138,7 @@ public void CastSpell(int spellId, ISpellTargetable target) .AddChar(1) // unknown .AddShort(1) // unknown .AddShort((short)spellId) - .AddShort((short)target.ID) + .AddShort((short)target.Index) .AddThree(DateTime.Now.ToEOTimeStamp()); } else diff --git a/EOLib/Domain/Interact/MapNPCActions.cs b/EOLib/Domain/Interact/MapNPCActions.cs index c56efe22c..1a7c40d56 100644 --- a/EOLib/Domain/Interact/MapNPCActions.cs +++ b/EOLib/Domain/Interact/MapNPCActions.cs @@ -26,7 +26,7 @@ public class MapNPCActions : IMapNPCActions public void RequestShop(INPC npc) { var packet = new PacketBuilder(PacketFamily.Shop, PacketAction.Open) - .AddShort(npc.Index) + .AddShort((short)npc.Index) .Build(); _packetSendService.SendPacket(packet); @@ -39,7 +39,7 @@ public void RequestQuest(INPC npc) var data = _enfFileProvider.ENFFile[npc.ID]; var packet = new PacketBuilder(PacketFamily.Quest, PacketAction.Use) - .AddShort(npc.Index) + .AddShort((short)npc.Index) .AddShort(data.VendorID) .Build(); @@ -49,7 +49,7 @@ public void RequestQuest(INPC npc) public void RequestBank(INPC npc) { var packet = new PacketBuilder(PacketFamily.Bank, PacketAction.Open) - .AddShort(npc.Index) + .AddShort((short)npc.Index) .Build(); _packetSendService.SendPacket(packet); diff --git a/EOLib/Domain/NPC/INPC.cs b/EOLib/Domain/NPC/INPC.cs index 2c5bbd0e2..f5086802d 100644 --- a/EOLib/Domain/NPC/INPC.cs +++ b/EOLib/Domain/NPC/INPC.cs @@ -5,8 +5,6 @@ namespace EOLib.Domain.NPC { public interface INPC : ISpellTargetable { - byte Index { get; } - byte X { get; } byte Y { get; } diff --git a/EOLib/Domain/NPC/NPC.cs b/EOLib/Domain/NPC/NPC.cs index 0a196d54c..0db602411 100644 --- a/EOLib/Domain/NPC/NPC.cs +++ b/EOLib/Domain/NPC/NPC.cs @@ -7,7 +7,7 @@ public class NPC : INPC { public int ID { get; } - public byte Index { get; } + public int Index { get; } public byte X { get; private set; } @@ -19,7 +19,7 @@ public class NPC : INPC public Option OpponentID { get; private set; } - public NPC(int id, byte index) + public NPC(int id, int index) { ID = id; Index = index; diff --git a/EOLib/Domain/Spells/ISpellTargetable.cs b/EOLib/Domain/Spells/ISpellTargetable.cs index 2ab9182d0..e1d79430b 100644 --- a/EOLib/Domain/Spells/ISpellTargetable.cs +++ b/EOLib/Domain/Spells/ISpellTargetable.cs @@ -3,5 +3,7 @@ public interface ISpellTargetable { int ID { get; } + + int Index { get; } } }