Skip to content

Commit

Permalink
added speed properties to AlucardApi, added method to change Library …
Browse files Browse the repository at this point in the history
…card destination
  • Loading branch information
TalicZealot committed Sep 6, 2022
1 parent 935d2de commit 7fac956
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 26 deletions.
23 changes: 17 additions & 6 deletions SotnApi/SotnApi/AlucardApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,17 @@ public uint WalkingFractSpeed
memAPI.WriteByte(Speeds.WalkingFract, value);
}
}
public int BackdashWholeSpeed
{
get
{
return memAPI.ReadS16(Speeds.BackdashWhole);
}
set
{
memAPI.WriteS16(Speeds.BackdashWhole, value);
}
}
public uint JumpingHorizontalWholeSpeed
{
get
Expand Down Expand Up @@ -955,26 +966,26 @@ public Subweapon Subweapon
memAPI.WriteByte(Inventory.Subweapon, (uint)value);
}
}
public int CurrentHorizontalSpeedWhole
public int HorizontalVelocityWhole
{
get
{
return (int)memAPI.ReadByte(Stats.CurrentHorizontalSpeedWhole);
return memAPI.ReadS16(Entity.HorizontalVelocityWhole);
}
set
{
memAPI.WriteByte(Stats.CurrentHorizontalSpeedWhole, (uint)value);
memAPI.WriteS16(Entity.HorizontalVelocityWhole, value);
}
}
public int CurrentHorizontalSpeedFractional
public uint HorizontalVelocityFractional
{
get
{
return (int)memAPI.ReadByte(Stats.CurrentHorizontalSpeedFractional);
return memAPI.ReadByte(Entity.HorizontalVelocityFract);
}
set
{
memAPI.WriteByte(Stats.CurrentHorizontalSpeedFractional, (uint)value);
memAPI.WriteByte(Entity.HorizontalVelocityFract, value);
}
}
public uint State
Expand Down
7 changes: 4 additions & 3 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Effects.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SotnApi.Constants.Addresses.Alucard
{
internal static class Effects
public static class Effects
{
public const long HealTrigger = 0x072F76;
public const long HealAmount = 0x072F78;
Expand All @@ -10,10 +10,11 @@ internal static class Effects
public const long WingsmashSpriteGlow = 0x116BA4;
public const long WingsmashEffect = 0x116BA6;
public const long WingsmashDuration = 0x116BDC;
public const long BombEffect = 0x07407A;
public const long BombActivateor = 0x074090;
public const long BombDamageInterval = 0x07409D;
public const long BombDamage = 0x074094;
public const long BombDamageInterval = 0x07409D;
public const long BombDamagesNeutral = 0x0740BE;
public const long BombEffect = 0x07407A;
public const long VisualEffectPalette = 0x072F60;
}
}
8 changes: 7 additions & 1 deletion SotnApi/SotnApi/Constants/Addresses/Alucard/Entity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
namespace SotnApi.Constants.Addresses.Alucard
{
internal static class Entity
public static class Entity
{
public const long Address = 0x0733D8;
public const long AttackHitboxWidth_1 = 0x073FDE;
public const long AttackHitboxHeight_1 = 0x073FDF;
public const long AttackHitboxWidth_2 = 0x07409A;
public const long AttackHitboxHeight_2 = 0x07409B;
public const long HorizontalVelocityWhole = 0x0733E2;
public const long HorizontalVelocityFract = 0x0733E1;
}
}
10 changes: 9 additions & 1 deletion SotnApi/SotnApi/Constants/Addresses/Alucard/Relics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SotnApi.Constants.Addresses.Alucard
{
internal static class Relics
public static class Relics
{
public static readonly Dictionary<string, long> AllRelics = new Dictionary<string, long>
{
Expand Down Expand Up @@ -68,5 +68,13 @@ internal static class Relics
public const long RibOfVlad = 0x9797F;
public const long RingOfVlad = 0x97980;
public const long EyeOfVlad = 0x97981;

public const long BatCardXp = 0x097C48;
public const long GhostCardXp = 0x097C54;
public const long FaerieCardXp = 0x097C60;
public const long DemonCardXp = 0x097C6C;
public const long SwordCardXp = 0x097C78;
public const long SpriteCardXp = 0x097C84;
public const long NoseDevilCardXp = 0x097C90;
}
}
1 change: 1 addition & 0 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Speeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal static class Speeds
public const long BatHorizontalLeftFract = 0x117109;
public const long WolfDashTopRight = 0x12D6D0;
public const long WolfDashTopLeft = 0x12D73C;
public const long BackdashWhole = 0x10FD8C;
public const long BackdashDecel = 0x11213D;

public const long AxeJumpVerticalMoving = 0x17AD34;
Expand Down
4 changes: 1 addition & 3 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Stats.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SotnApi.Constants.Addresses.Alucard
{
internal static class Stats
public static class Stats
{
public const long Experience = 0x097BEC;
public const long Level = 0x097BE8;
Expand Down Expand Up @@ -31,8 +31,6 @@ internal static class Stats
public const long ScreenY = 0x072F9E;
public const long MapX = 0x0730B0;
public const long MapY = 0x0730B4;
public const long CurrentHorizontalSpeedWhole = 0x0733E1;
public const long CurrentHorizontalSpeedFractional = 0x0733E1;
public const long Facing = 0x0733EC;
public const long State = 0x073404;
public const long Action = 0x073406;
Expand Down
7 changes: 3 additions & 4 deletions SotnApi/SotnApi/Constants/Addresses/Alucard/Timers.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
namespace SotnApi.Constants.Addresses.Alucard
{
internal static class Timers
public static class Timers
{
public const long Stun = 0x072EFC; //Size: 2 Byte
public const long Poison = 0x072F00; //Size: 2 Byte
public const long Curse = 0x072F02; //Size: 2 Byte
public const long Curse = 0x072F03; //Size: 2 Byte
public const long Shine = 0x072F09; //Size: 2 Byte
public const long VisualEffectTimer = 0x072F05;
public const long VisualEffectPalette = 0x072F60;
public const long VisualEffectTimer = 0x072F04;
public const long DarkMetamorphasis = 0x072F17;
public const long AttackPotion = 0x13982D;
public const long DefencePotion = 0x139829;
Expand Down
6 changes: 6 additions & 0 deletions SotnApi/SotnApi/Constants/Addresses/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,11 @@ public static class Game
public const long UnderwaterPhysics = 0x097448;
public const long Music = 0x138458;
public const long TeleportDestination = 0x097C98;
public const long SavePalette = 0x03C4E6;
public const long MovementSpeedDirectionInstruction = 0x010e3a4;
public const long LibraryCardDestinationZone = 0x0f1724;
public const long LibraryCardDestinationXpos = 0x0A25E2;
public const long LibraryCardDestinationYpos = 0x0A25E4;
public const long LibraryCardDestinationRoom = 0x0A25E6; //base 8
}
}
3 changes: 2 additions & 1 deletion SotnApi/SotnApi/Constants/Addresses/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ public static class Strings
{"Skelerang", 0xe0d14},
{"SwordLord", 0xe0d20},
};
public static readonly Dictionary<string, long> WeaponNameAddresses = new Dictionary<string, long>
public static readonly Dictionary<string, long> ItemNameAddresses = new Dictionary<string, long>
{
{"Library card", 0x0DD200},
{"Gurthang", 0x0DD998}
};
}
Expand Down
1 change: 1 addition & 0 deletions SotnApi/SotnApi/Constants/Values/Alucard/DefaultSpeeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class DefaultSpeeds
public const uint BatLeftFract = 0xC0;
public const uint WolfDashTopRight = 0x03;
public const uint WolfDashTopLeft = 0xFD;
public const int BackdashWhole = 0xFFFC;
public const uint BackdashDecel = 0x20;
public const uint BackdashDecelSlow = 0x30;
}
Expand Down
2 changes: 2 additions & 0 deletions SotnApi/SotnApi/Constants/Values/Alucard/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ public static class Effects
public const uint Potion = 0x27;
public const uint Stopwatch = 0x29;
public const uint Bible = 0x2B;
public const uint AutoSummonSpirit = 0x3D;
public const uint SummonSpirit = 0x3F;
public const uint LibraryCard = 0x41;
public const uint RedGlowValue = 0x8166;
public const uint DefaultWingsmashAnimation = 0x0C;
public const uint DefaultWingsmashSpriteGlow = 0x5C;
public const uint DefaultWingsmashEffect = 0x05;
Expand Down
49 changes: 49 additions & 0 deletions SotnApi/SotnApi/Constants/Values/Game/Enums/Zone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace SotnApi.Constants.Values.Game.Enums
{
public enum Zone
{
MarbleGallery = 0,
OuterWall = 1,
LongLibrary = 2,
Catacombs = 3,
OlroxsQuarters = 4,
AbandonedMine = 5,
RoyalChapel = 6,
CastleEntrance = 7,
CenterCube = 8,
UndergroundCaverns = 9,
Colosseum = 0xA,
CastleKeep = 0xB,
AlchemyLaboratory = 0xC,
ClockTower = 0xD,
Warp = 0xE,
Nightmare = 0x12,
SlograGaibon = 0x13,
Karasuman = 0x14,
LesserDemon = 0x15,
Cerberus = 0x16,
ClockRoomCutscene = 0x17,
RichterFight = 0x18,
Hippogryph = 0x19,
Doppleganger10 = 0x1A,
Scylla = 0x1B,
MinotaurWerewolf = 0x1C,
Granfaloon = 0x1D,
Olrox = 0x1E,
BlackMarbleGallery = 0x20,
ReverseOuterWall = 0x21,
ForbiddenLibrary = 0x22,
FloatingCatacombs = 0x23,
DeathWingsLair = 0x24,
Cave = 0x25, //Inverted Mines
AntiChapel = 0x26,
ReverseEntrance = 0x27,
ReverseCaverns = 0x29,
ReverseColosseum = 0x2A,
ReverseCastleKeep = 0x2B,
NecromancyLaboratory = 0x2C,
ReverseClockTower = 0x2D,
ReverseWarp = 0x2E,
//ThirdOuterWall = 0x2F,
}
}
52 changes: 50 additions & 2 deletions SotnApi/SotnApi/Constants/Values/Game/Various.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using SotnApi.Constants.Values.Game.Enums;
using SotnApi.Models;
using System.Collections.Generic;

namespace SotnApi.Constants.Values.Game
{
Expand All @@ -15,6 +17,9 @@ public static class Various
public const uint CanSave = 0x20;
public const uint CanWarp = 0x0E;
public const int MapItemsCollectedSize = 143;
public const int UnderwaterPhysicsOn = 0x0090;
public const int DefaultMovementSpeedDirectionInstruction = 0x14620002; //BNE v1 v0 0x2
public const int FlippedMovementSpeedDirectionInstruction = 0x10620002; //BEQ v1 v0 0x2

public static readonly Dictionary<uint, char> CharacterMap = new Dictionary<uint, char> {
{0x43, ','},
Expand Down Expand Up @@ -196,6 +201,49 @@ public static class Various
"Shaft",
"Dracula"
};

public static readonly List<TeleportZone> SafeLibraryCardZones = new List<TeleportZone>()
{
new TeleportZone { Zone = (ushort)Zone.MarbleGallery, Xpos = 125, Ypos = 125, Room = 40},
new TeleportZone { Zone = (ushort)Zone.OuterWall, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.LongLibrary, Xpos = 132, Ypos = 16, Room = 40},
new TeleportZone { Zone = (ushort)Zone.Catacombs, Xpos = 125, Ypos = 125, Room = 40},
new TeleportZone { Zone = (ushort)Zone.OlroxsQuarters, Xpos = 125, Ypos = 125, Room = 40},
new TeleportZone { Zone = (ushort)Zone.AbandonedMine, Xpos = 125, Ypos = 125, Room = 24},
new TeleportZone { Zone = (ushort)Zone.RoyalChapel, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.CastleEntrance, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.CenterCube, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.UndergroundCaverns, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.Colosseum, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.CastleKeep, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.AlchemyLaboratory, Xpos = 125, Ypos = 125, Room = 48},
//new TeleportZone { Zone = (ushort)Zone.ClockTower, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.Warp, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.Nightmare, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.SlograGaibon, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Karasuman, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.LesserDemon, Xpos = 500, Ypos = 500, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Cerberus, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Hippogryph, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Doppleganger10, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Scylla, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.MinotaurWerewolf, Xpos = 255, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Granfaloon, Xpos = 225, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.Olrox, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.BlackMarbleGallery, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.ReverseOuterWall, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.ForbiddenLibrary, Xpos = 125, Ypos = 125, Room = 8},
new TeleportZone { Zone = (ushort)Zone.FloatingCatacombs, Xpos = 125, Ypos = 125, Room = 32},
new TeleportZone { Zone = (ushort)Zone.DeathWingsLair, Xpos = 125, Ypos = 125, Room = 16},
new TeleportZone { Zone = (ushort)Zone.Cave, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.AntiChapel, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.ReverseEntrance, Xpos = 125, Ypos = 125, Room = 16},
new TeleportZone { Zone = (ushort)Zone.ReverseCaverns, Xpos = 125, Ypos = 125, Room = 0},
new TeleportZone { Zone = (ushort)Zone.ReverseColosseum, Xpos = 125, Ypos = 125, Room = 8},
new TeleportZone { Zone = (ushort)Zone.ReverseCastleKeep, Xpos = 125, Ypos = 125, Room = 40},
new TeleportZone { Zone = (ushort)Zone.NecromancyLaboratory, Xpos = 125, Ypos = 125, Room = 40},
//new TeleportZone { Zone = (ushort)Zone.ReverseClockTower, Xpos = 125, Ypos = 125, Room = 0}, //Darkwing
//new TeleportZone { Zone = (ushort)Zone.ReverseClockTower, Xpos = 125, Ypos = 125, Room = 48},
new TeleportZone { Zone = (ushort)Zone.ReverseWarp, Xpos = 125, Ypos = 125, Room = 8},
};
}
}
24 changes: 24 additions & 0 deletions SotnApi/SotnApi/GameApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SotnApi.Interfaces;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text.RegularExpressions;

namespace SotnApi
Expand Down Expand Up @@ -279,6 +280,29 @@ public bool CanWarp()
return (memAPI.ReadByte(Game.CanWarp) & Various.CanWarp) == Various.CanWarp;
}

/// <summary>
/// Room is an index that goes in increments of 8. Setting XY outside of the room will cause a large amount of delay before gaining control.
/// </summary>
public void SetLibraryCardDestination(uint zone, int xpos, int ypos, uint room)
{
memAPI.WriteByte(Game.LibraryCardDestinationZone, zone);
memAPI.WriteS16(Game.LibraryCardDestinationXpos, xpos);
memAPI.WriteS16(Game.LibraryCardDestinationYpos, ypos);
memAPI.WriteU16(Game.LibraryCardDestinationRoom, room);
}

public void SetMovementSpeedDirection(bool flipped = false)
{
if (flipped)
{
memAPI.WriteS32(Constants.Addresses.Game.MovementSpeedDirectionInstruction, Constants.Values.Game.Various.FlippedMovementSpeedDirectionInstruction);
}
else
{
memAPI.WriteS32(Constants.Addresses.Game.MovementSpeedDirectionInstruction, Constants.Values.Game.Various.DefaultMovementSpeedDirectionInstruction);
}
}

public void OverwriteString(long address, string text, bool safe)
{
if (text == null) throw new ArgumentNullException(nameof(text));
Expand Down
6 changes: 4 additions & 2 deletions SotnApi/SotnApi/Interfaces/IAlucardApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public interface IAlucardApi
uint WalkingWholeSpeed { get; set; }
/// <summary> Alucard walking fractional speed. </summary>
uint WalkingFractSpeed { get; set; }
/// <summary> Alucard backdash whole speed in pixels per frame.. </summary>
int BackdashWholeSpeed { get; set; }
/// <summary> Alucard jumping horizontal speed in pixels per frame. </summary>
uint JumpingHorizontalWholeSpeed { get; set; }
/// <summary> Alucard jumping horizontal fractional speed. </summary>
Expand Down Expand Up @@ -103,9 +105,9 @@ public interface IAlucardApi
/// <summary> Index of the held subweapon.</summary>
Subweapon Subweapon { get; set; }
/// <summary> Real-time horizontal speed in pixels per frame. </summary>
public int CurrentHorizontalSpeedWhole { get; set; }
public int HorizontalVelocityWhole { get; set; }
/// <summary> Real-time horizontal fractional speed.</summary>
public int CurrentHorizontalSpeedFractional { get; set; }
public uint HorizontalVelocityFractional { get; set; }
uint State { get; set; }
uint Action { get; set; }
/// <summary>Horizontal coordinate of Alucard on the screen.</summary>
Expand Down
8 changes: 8 additions & 0 deletions SotnApi/SotnApi/Interfaces/IGameApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public interface IGameApi
/// </summary>
bool IsInMenu();
/// <summary>
/// Changes where the Library Card teleports the user to.
/// </summary>
void SetLibraryCardDestination(uint zone, int xpos, int ypos, uint room);
/// <summary>
/// Flips or resets the direction in which Alucard walks or jumps.
/// </summary>
void SetMovementSpeedDirection(bool flipped = false);
/// <summary>
/// Overwrites a string in the game.
/// </summary>
void OverwriteString(long address, string text, bool safe);
Expand Down
10 changes: 10 additions & 0 deletions SotnApi/SotnApi/Models/TeleportZone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SotnApi.Models
{
public class TeleportZone
{
public ushort Zone { get; set; }
public int Xpos { get; set; }
public int Ypos { get; set; }
public uint Room { get; set; }
}
}
Loading

0 comments on commit 7fac956

Please sign in to comment.