Skip to content

Commit

Permalink
refactoring, entity rework
Browse files Browse the repository at this point in the history
  • Loading branch information
TalicZealot committed May 17, 2023
1 parent a7b2d60 commit 844c443
Show file tree
Hide file tree
Showing 24 changed files with 743 additions and 699 deletions.
2 changes: 1 addition & 1 deletion SotnApi/ActorApiTests/SpawnActorShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CallsWriteByteRangeMethodOfMemAPI_ExactlyOnce()
//Act
classUnderTest.SpawnEntity(blankActor);
//Assert
mockedMemAPI.Received(1).WriteByteRange(Arg.Any<long>(), blankActor.Value);
mockedMemAPI.Received(1).WriteByteRange(Arg.Any<long>(), blankActor.Data);
}
}
}
11 changes: 8 additions & 3 deletions SotnApi/SotnApi/AlucardApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@ public uint StunTimer
memAPI.WriteU16(Timers.Stun, value);
}
}

public uint ContactDamage
{
get
Expand Down Expand Up @@ -1321,7 +1320,7 @@ public void TakeOneItemByName(string name)

public bool IsInvincible()
{
return memAPI.ReadByte(Timers.Invincibility) > 0 || memAPI.ReadByte(Timers.KnockbackInvincibility) > 0 || memAPI.ReadByte(Timers.PotionInvincibility) > 0 || memAPI.ReadByte(Timers.FreezeInvincibility) > 0;
return memAPI.ReadU16(Timers.Invincibility) > 0 || memAPI.ReadByte(Timers.KnockbackInvincibility) > 0 || memAPI.ReadByte(Timers.PotionInvincibility) > 0 || memAPI.ReadByte(Timers.FreezeInvincibility) > 0;
}

public bool HasControl()
Expand All @@ -1332,7 +1331,7 @@ public bool HasControl()

public bool HasHitbox()
{
return memAPI.ReadByte(Entity.Address + Entities.HitboxWidthOffset) > 0 && memAPI.ReadByte(Entity.Address + Entities.HitboxHeightOffset) > 0;
return memAPI.ReadByte(Entity.Address + Entities.HitboxWidth) > 0 && memAPI.ReadByte(Entity.Address + Entities.HitboxHeight) > 0;
}

public void Heal(uint amount)
Expand All @@ -1341,6 +1340,12 @@ public void Heal(uint amount)
memAPI.WriteByte(Effects.HealTrigger, 1);
}

public void InstantDeath()
{
memAPI.WriteS16(Constants.Addresses.Alucard.Entity.Step, 0x10);
memAPI.WriteS16(Constants.Addresses.Alucard.Entity.Step2, 0);
}

public void ActivateStopwatch()
{
memAPI.WriteByte(Effects.Activator, SotnApi.Constants.Values.Alucard.Effects.Stopwatch);
Expand Down
2 changes: 2 additions & 0 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public static class Entity
public const long AttackHitboxHeight_2 = 0x07409B;
public const long HorizontalVelocityWhole = 0x0733E2;
public const long HorizontalVelocityFract = 0x0733E1;
public const long Step = 0x073404;
public const long Step2 = 0x073406;
}
}
1 change: 1 addition & 0 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public static class Stats
public const long State = 0x073404;
public const long Action = 0x073406;
public const long ContactDamage = 0x073418;
public const long ArmorResistance = 0x097C28;
}
}
6 changes: 3 additions & 3 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Timers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
public static class Timers
{
public const long Stun = 0x072EFC; //Size: 2 Byte
public const long Stun = 0x072EFC; //Size: 4 Byte
public const long Poison = 0x072F00; //Size: 2 Byte
public const long Curse = 0x072F03; //Size: 2 Byte
public const long Shine = 0x072F09; //Size: 2 Byte
public const long VisualEffectTimer = 0x072F04;
public const long VisualEffectTimer = 0x072F04; //Size: 2 Byte
public const long DarkMetamorphasis = 0x072F17;
public const long AttackPotion = 0x13982D;
public const long StrengthPotion = 0x139838;
public const long DefencePotion = 0x139829;
public const long Invincibility = 0x072F1B;
public const long Invincibility = 0x072F1A;
public const long PotionInvincibility = 0x072F1C;
public const long KnockbackInvincibility = 0x13B5E8;
public const long FreezeInvincibility = 0x097420;
Expand Down
5 changes: 3 additions & 2 deletions SotnApi/SotnApi/Constants/Addresses/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static class Game
public const long MapYPos = 0x0730B4;
public const long Room = 0x1375BC;
public const long Area = 0x1375BD;
public const long Zone2 = 0x0974A0;
public const long StageId = 0x0974A0;
public const long Hours = 0x097C30;
public const long Minutes = 0x097C34;
public const long Seconds = 0x097C38;
Expand All @@ -106,7 +106,8 @@ public static class Game
public const long CanWarp = 0x03C710;
public const long MapItemsCollectedStart = 0x03BEE0;
public const long UnderwaterPhysics = 0x097448;
public const long MusicTrack = 0x138458;
public const long MusicTrack = 0x13901C;
public const long LastLoadedMusicTrack = 0x138458;
public const long MusicVolume = 0x13B668;
public const long TrackVolume = 0x139820;
public const long VolumeSetInstruction = 0x136280;
Expand Down
120 changes: 60 additions & 60 deletions SotnApi/SotnApi/Constants/Addresses/ZoneTransitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,93 @@ namespace SotnApi.Constants.Addresses
{
public static class ZoneTransitionAddresses
{
public static readonly Dictionary<Zone, long> CastleEntrance = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> CastleEntrance = new Dictionary<Stage, long>
{
{ Zone.MarbleGallery, 0x0A268C },
{ Zone.UndergroundCaverns, 0x0A2696 },
{ Zone.AlchemyLaboratory, 0x0A26A0 },
{ Zone.Warp, 0x0A26AA },
{ Stage.MarbleGallery, 0x0A268C },
{ Stage.UndergroundCaverns, 0x0A2696 },
{ Stage.AlchemyLaboratory, 0x0A26A0 },
{ Stage.Warp, 0x0A26AA },
};
public static readonly Dictionary<Zone, long> AlchemyLaboratory = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> AlchemyLaboratory = new Dictionary<Stage, long>
{
{ Zone.CastleEntrance, 0x0A252E },
{ Zone.MarbleGallery, 0x0A2538 },
{ Zone.RoyalChapel, 0x0A2542 },
{ Stage.CastleEntrance, 0x0A252E },
{ Stage.MarbleGallery, 0x0A2538 },
{ Stage.RoyalChapel, 0x0A2542 },
};
public static readonly Dictionary<Zone, long> Colosseum = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> Colosseum = new Dictionary<Stage, long>
{
{Zone.RoyalChapel, 0x0A2664},
{Zone.OlroxsQuarters, 0x0A266E},
{Stage.RoyalChapel, 0x0A2664},
{Stage.OlroxsQuarters, 0x0A266E},
};
public static readonly Dictionary<Zone, long> OlroxsQuarters = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> OlroxsQuarters = new Dictionary<Stage, long>
{
{ Zone.MarbleGallery, 0x0A254C },
{ Zone.RoyalChapel, 0x0A2556 },
{ Zone.Colosseum, 0x0A2560 },
{ Zone.Warp, 0x0A256A },
{ Stage.MarbleGallery, 0x0A254C },
{ Stage.RoyalChapel, 0x0A2556 },
{ Stage.Colosseum, 0x0A2560 },
{ Stage.Warp, 0x0A256A },
};
public static readonly Dictionary<Zone, long> RoyalChapel = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> RoyalChapel = new Dictionary<Stage, long>
{
{ Zone.OlroxsQuarters, 0x0A25A6 },
{ Zone.Colosseum, 0x0A25B0 },
{ Zone.AlchemyLaboratory, 0x0A25BA },
{ Zone.CastleKeep, 0x0A25C4 },
{ Stage.OlroxsQuarters, 0x0A25A6 },
{ Stage.Colosseum, 0x0A25B0 },
{ Stage.AlchemyLaboratory, 0x0A25BA },
{ Stage.CastleKeep, 0x0A25C4 },
};
public static readonly Dictionary<Zone, long> Warp = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> Warp = new Dictionary<Stage, long>
{
{ Zone.CastleKeep, 0x0A2574 },
{ Zone.OuterWall, 0x0A257E },
{ Zone.OlroxsQuarters, 0x0A2588 },
{ Zone.CastleEntrance, 0x0A2592 },
{ Zone.AbandonedMine, 0x0A259C },
{ Stage.CastleKeep, 0x0A2574 },
{ Stage.OuterWall, 0x0A257E },
{ Stage.OlroxsQuarters, 0x0A2588 },
{ Stage.CastleEntrance, 0x0A2592 },
{ Stage.AbandonedMine, 0x0A259C },
};
public static readonly Dictionary<Zone, long> MarbleGallery = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> MarbleGallery = new Dictionary<Stage, long>
{
{ Zone.AlchemyLaboratory, 0x0A245C },
{ Zone.OlroxsQuarters, 0x0A2466 },
{ Zone.OuterWall, 0x0A2470 },
{ Zone.CastleEntrance, 0x0A247A },
{ Zone.UndergroundCaverns, 0x0A2484 },
{ Zone.CenterCube, 0x0A248E },
{ Stage.AlchemyLaboratory, 0x0A245C },
{ Stage.OlroxsQuarters, 0x0A2466 },
{ Stage.OuterWall, 0x0A2470 },
{ Stage.CastleEntrance, 0x0A247A },
{ Stage.UndergroundCaverns, 0x0A2484 },
{ Stage.CenterCube, 0x0A248E },
};
public static readonly Dictionary<Zone, long> LongLibrary = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> LongLibrary = new Dictionary<Stage, long>
{
{ Zone.OuterWall, 0x0A2498 },
{ Stage.OuterWall, 0x0A2498 },
};
public static readonly Dictionary<Zone, long> ClockTower = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> ClockTower = new Dictionary<Stage, long>
{
{ Zone.CastleKeep, 0x0A24B6 },
{ Zone.OuterWall, 0x0A24C0 },
{ Stage.CastleKeep, 0x0A24B6 },
{ Stage.OuterWall, 0x0A24C0 },
};
public static readonly Dictionary<Zone, long> CastleKeep = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> CastleKeep = new Dictionary<Stage, long>
{
{ Zone.ClockTower, 0x0A261E },
{ Zone.Warp, 0x0A2628 },
{ Zone.RoyalChapel, 0x0A2632 },
{ Stage.ClockTower, 0x0A261E },
{ Stage.Warp, 0x0A2628 },
{ Stage.RoyalChapel, 0x0A2632 },
};
public static readonly Dictionary<Zone, long> UndergroundCaverns = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> UndergroundCaverns = new Dictionary<Stage, long>
{
{ Zone.AbandonedMine, 0x0A2650 },
{ Zone.MarbleGallery, 0x0A2646 },
{ Zone.Nightmare, 0x0A265A },
{ Zone.CastleEntrance, 0x0A263C },
{ Stage.AbandonedMine, 0x0A2650 },
{ Stage.MarbleGallery, 0x0A2646 },
{ Stage.Nightmare, 0x0A265A },
{ Stage.CastleEntrance, 0x0A263C },
};
public static readonly Dictionary<Zone, long> AbandonedMine = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> AbandonedMine = new Dictionary<Stage, long>
{
{ Zone.UndergroundCaverns, 0x0A251A },
{ Zone.Warp, 0x0A2524 },
{ Zone.Catacombs, 0x0A2510 },
{ Stage.UndergroundCaverns, 0x0A251A },
{ Stage.Warp, 0x0A2524 },
{ Stage.Catacombs, 0x0A2510 },
};
public static readonly Dictionary<Zone, long> Catacombs = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> Catacombs = new Dictionary<Stage, long>
{
{ Zone.AbandonedMine, 0x0A24FC },
{ Stage.AbandonedMine, 0x0A24FC },
};
public static readonly Dictionary<Zone, long> OuterWall = new Dictionary<Zone, long>
public static readonly Dictionary<Stage, long> OuterWall = new Dictionary<Stage, long>
{
{ Zone.MarbleGallery, 0x0A25EC },
{ Zone.LongLibrary, 0x0A25F6 },
{ Zone.Warp, 0x0A2600 },
{ Zone.ClockTower, 0x0A260A },
{ Stage.MarbleGallery, 0x0A25EC },
{ Stage.LongLibrary, 0x0A25F6 },
{ Stage.Warp, 0x0A2600 },
{ Stage.ClockTower, 0x0A260A },
};
}
}
33 changes: 33 additions & 0 deletions SotnApi/SotnApi/Constants/Values/Alucard/Equipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,39 @@ public static class Equipment
"Secret boots",
"Alucart mail"
};
public static readonly List<string> Relics = new List<string>
{
"Soul of Bat",
"Fire of Bat",
"Echo of Bat",
"Force of Echo",
"Soul of Wolf",
"Power of Wolf",
"Skill of Wolf",
"Form of Mist",
"Power of Mist",
"Gas Cloud",
"Cube of Zoe",
"Spirit Orb",
"Gravity Boots",
"Leap Stone",
"Holy Symbol",
"Faerie Scroll",
"Jewel of Open",
"Merman Statue",
"Bat Card",
"Ghost Card",
"Faerie Card",
"Demon Card",
"Sword Card",
"Sprite Card",
"Nose Devil Card",
"Heart of Vlad",
"Tooth of Vlad",
"Rib of Vlad",
"Ring of Vlad",
"Eye of Vlad",
};
public const uint HelmStart = 0x1A;
public const uint CloakStart = 0x30;
public const uint AccessoryStart = 0x39;
Expand Down
69 changes: 37 additions & 32 deletions SotnApi/SotnApi/Constants/Values/Game/Entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,49 @@ public static class Entities
{
public const int EnemyEntitiesCount = 131;
public const int FriendEntitiesCount = 6;
public const int Size = 146;
public const int Poison = 0x81;
public const int Curse = 1;
public const int Stone = 2;
public const int LockedOn = 2;
public const int Curse = 0x1;
public const int Stone = 0x2;
public const int LockedOn = 0x2;
public const int Slam = 0x25;
public const int Offset = 0xBC;
public const int Size = 0xBC;

public const int XposOffset = 0x02;
public const int YposOffset = 0x06;
public const int Xpos = 0x00;
public const int Ypos = 0x06;
public const int AccelerationX = 0x08;
public const int AccelerationY = 0x0C;
public const int SpeedFractOffset = 0x09;
public const int SpeedWholeOffset = 0xA;
public const int SpeedVerticalFractOffset = 0xD;
public const int SpeedVerticalWholeOffset = 0xE;
public const int SpeedVerticalNegativeOffset = 0xF;
public const int FacingOffset = 0x14;
public const int PaletteOffset = 0x16;
public const int ColorModeOffset = 0x18;
public const int AiIdOffset = 0x28;
public const int LockOnOffset = 0x2C;
public const int ItemIndexOffset = 0x30; //RelicIndex
public const int EnemyNameIndex = 0x3A;
public const int DefOffset = 0x3A;
public const int HitboxAutoToggleOffset = 0x3C;
public const int HpOffset = 0x3E;
public const int DamageOffset = 0x40;
public const int DamageTypeAOffset = 0x42;
public const int DamageTypeBOffset = 0x43;
public const int HitboxWidthOffset = 0x46;
public const int HitboxHeightOffset = 0x47;
public const int InvincibilityFramesOffset = 0x49;
public const int AnimationFrameIndexOffset = 0x50;
public const int AnimationFrameDurationOffset = 0x52;
public const int AnimationSetOffset = 0x54;
public const int AnimationFrameOffset = 0x58;
public const int Facing = 0x14;
//public const int Unk = 0x16; display mode?
public const int Palette = 0x17;
public const int BlendMode = 0x18;
public const int ZPriority = 0x24;
public const int ObjectId = 0x26;
public const int UpdateFunctionAddress = 0x28;
public const int Step = 0x2C;
public const int Step2 = 0x2E;
public const int SubId = 0x30; // Item/Relic Index
public const int ObjectRoomIndex = 0x32;
public const int Flags = 0x34;
public const int Unk38 = 0x38;
public const int EnemyIndex = 0x3A; // determines display name and XP and in some cases Defense
public const int Defense = 0x3A;
public const int HitboxAutoToggle = 0x3C;
public const int Hp = 0x3E;
public const int Damage = 0x40;
public const int DamageTypeA = 0x42;
public const int DamageTypeB = 0x43;
public const int HitboxWidth = 0x46;
public const int HitboxHeight = 0x47;
public const int InvincibilityFrames = 0x49;
public const int AnimationFrameIndex = 0x50;
public const int AnimationFrameDuration = 0x52;
public const int AnimationSet = 0x54;
public const int AnimationCurrentFrame = 0x58;
//* 0x64 */ s32 firstPolygonIndex;

/// <summary>
/// Spawning entities in these can cause relics not to spawn.
/// </summary>
public static readonly long[] ReservedSlots =
{
0x076e98,
Expand Down
Loading

0 comments on commit 844c443

Please sign in to comment.