Skip to content

Commit

Permalink
Added support for the High Chaos Engine, as well as a conditional aut…
Browse files Browse the repository at this point in the history
…o reset (based on character position)
  • Loading branch information
Som1Lse committed Jan 3, 2017
1 parent 0b3b5ce commit aeb97c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
20 changes: 16 additions & 4 deletions GameMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace LiveSplit.Dishonored
{
class GameData : MemoryWatcherList
{
public MemoryWatcher<float> PlayerPosX { get; }
public MemoryWatcher<bool> IsLoading { get; }
public MemoryWatcher<int> CurrentLevel { get; }
public StringWatcher CurrentBikMovie { get; }
Expand All @@ -25,6 +26,7 @@ public GameData(GameVersion version)
{
if (version == GameVersion.v12)
{
this.PlayerPosX = new MemoryWatcher<float>(new DeepPointer(0xFCCBDC, 0xC4));
this.CurrentLevel = new MemoryWatcher<int>(new DeepPointer(0xFB7838, 0x2c0, 0x314, 0, 0x38));
this.CurrentBikMovie = new StringWatcher(new DeepPointer(0xFC6AD4, 0x48, 0), 64);
this.CutsceneActive = new MemoryWatcher<bool>(new DeepPointer(0xFB51CC, 0x744));
Expand All @@ -33,6 +35,7 @@ public GameData(GameVersion version)
}
else if (version == GameVersion.v14)
{
this.PlayerPosX = new MemoryWatcher<float>(new DeepPointer(0x1052DE8, 0xC4));
this.CurrentLevel = new MemoryWatcher<int>(new DeepPointer(0x103D878, 0x2c0, 0x314, 0, 0x38));
this.CurrentBikMovie = new StringWatcher(new DeepPointer(0x104CB18, 0x48, 0), 64);
this.CutsceneActive = new MemoryWatcher<bool>(new DeepPointer(0x103B20C, 0x744));
Expand Down Expand Up @@ -130,7 +133,7 @@ public void Update()
string currentLevelStr = this.GetEngineStringByID(_data.CurrentLevel.Current);
Debug.WriteLine($"Level Changed - {_data.CurrentLevel.Old} -> {_data.CurrentLevel.Current} '{currentLevelStr}'");

if (currentLevelStr == "l_tower_p" || currentLevelStr == "L_DLC07_BaseIntro_P" || currentLevelStr == "DLC06_Tower_P")
if (currentLevelStr == "L_DLC07_BaseIntro_P" || currentLevelStr == "DLC06_Tower_P")
this.OnFirstLevelLoading?.Invoke(this, EventArgs.Empty);

_oncePerLevelFlag = true;
Expand All @@ -145,8 +148,8 @@ public void Update()
{
Debug.WriteLine($"Load Start - {currentMovie + "|" + currentLevelStr}");

// ignore the beginning load screen and the dishonored logo screen
if (currentMovie != "LoadingEmpressTower" && currentMovie != "Dishonored" && currentMovie != "INTRO_LOC")
// ignore the intro sequence and the dishonored logo screen
if (currentMovie != "INTRO_LOC" && currentMovie != "Dishonored")
{
// ignore intro end if it happens, see special case above
if (!(currentMovie == "LoadingPrison" && currentLevelStr.ToLower().StartsWith("L_Tower_")))
Expand Down Expand Up @@ -178,12 +181,21 @@ public void Update()
}
}

if (_data.PlayerPosX.Changed && _data.PlayerPosX.Old == 0.0f && _loadingStarted &&
_data.PlayerPosX.Current<9826.5f && _data.PlayerPosX.Current>9826.0f)
{
string currentLevelStr = this.GetEngineStringByID(_data.CurrentLevel.Current);

if(currentLevelStr == "l_tower_p")
this.OnFirstLevelLoading?.Invoke(this, EventArgs.Empty);
}

if (_data.CutsceneActive.Changed)
{
string currentLevelStr = this.GetEngineStringByID(_data.CurrentLevel.Current);
Debug.WriteLine($"In-Game Cutscene {(_data.CutsceneActive.Current ? "Start" : "End")}");

if (_data.CutsceneActive.Current && currentLevelStr == "L_LightH_LowChaos_P")
if (_data.CutsceneActive.Current && (currentLevelStr == "L_LightH_LowChaos_P" || currentLevelStr == "L_LightH_HighChaos_P"))
{
this.OnPlayerLostControl?.Invoke(this, EventArgs.Empty);
}
Expand Down
9 changes: 6 additions & 3 deletions LiveSplit.Dishonored.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LiveSplit.Dishonored</RootNamespace>
<AssemblyName>LiveSplit.Dishonored</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -20,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,10 +30,11 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiveSplit.Core">
<HintPath>..\..\public\LiveSplit\LiveSplit\bin\Debug\LiveSplit.Core.dll</HintPath>
<HintPath>..\..\..\Second Desktop\LiveSplit\LiveSplit.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -41,7 +44,7 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="UpdateManager">
<HintPath>..\..\public\LiveSplit\LiveSplit\bin\Debug\UpdateManager.dll</HintPath>
<HintPath>..\..\..\Second Desktop\LiveSplit\UpdateManager.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down

0 comments on commit aeb97c8

Please sign in to comment.