Skip to content

Commit

Permalink
Fix spell targeting to use NPC index instead of ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Apr 18, 2022
1 parent 07b9f5e commit 8272314
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions EOLib/Domain/Character/Character.cs
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion EOLib/Domain/Character/CharacterActions.cs
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions EOLib/Domain/Interact/MapNPCActions.cs
Expand Up @@ -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);
Expand All @@ -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();

Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions EOLib/Domain/NPC/INPC.cs
Expand Up @@ -5,8 +5,6 @@ namespace EOLib.Domain.NPC
{
public interface INPC : ISpellTargetable
{
byte Index { get; }

byte X { get; }

byte Y { get; }
Expand Down
4 changes: 2 additions & 2 deletions EOLib/Domain/NPC/NPC.cs
Expand Up @@ -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; }

Expand All @@ -19,7 +19,7 @@ public class NPC : INPC

public Option<short> OpponentID { get; private set; }

public NPC(int id, byte index)
public NPC(int id, int index)
{
ID = id;
Index = index;
Expand Down
2 changes: 2 additions & 0 deletions EOLib/Domain/Spells/ISpellTargetable.cs
Expand Up @@ -3,5 +3,7 @@
public interface ISpellTargetable
{
int ID { get; }

int Index { get; }
}
}

0 comments on commit 8272314

Please sign in to comment.