Skip to content

Commit

Permalink
Add MonsterDistanceMultiplier, allows increasing monster visible di…
Browse files Browse the repository at this point in the history
…stance
  • Loading branch information
emoose committed Oct 3, 2021
1 parent 5ac9440 commit 094c98f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Arise-SDK.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
; (set this to -1 to disable the NPC distance changes)
MinimumNPCDistance = 50000

; MonsterDistanceMultiplier: allows increasing the distance of monster spawns
; the larger this is, the larger the distance monsters will spawn at & stay visible for
; this hasn't been tested much yet, not sure if there's any kind of monster (bosses?) that this has issues with
; doesn't seem to cause much perf hit for me at least
; (can be controlled ingame via sdk.MonsterDistanceMultiplier cvar)
; (game default: 1)
MonsterDistanceMultiplier = 10

; CharaLODMultiplier: how much to multiply AriseCharacter LOD distances
; affects both NPCs & monsters, game defaults can be pretty low, a multiplier of 3 or above is recommended
; if set to -1, the AriseCharacter LOD system will be disabled, making them all use LOD0
Expand Down
33 changes: 28 additions & 5 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "pch.h"

#define SDK_VERSION "0.1.24b"
#define SDK_VERSION "0.1.25"

const uint32_t Addr_Timestamp = 0x1E0;
const uint32_t Value_Timestamp = 1626315361; // 2021/07/15 02:16:01
Expand Down Expand Up @@ -43,6 +43,7 @@ WCHAR IniPath[4096];
struct
{
float MinNPCDistance = 50000;
float MonsterDistanceMultiplier = 1;
bool SkipIntroLogos = true;
bool DisableCutsceneCA = false;
bool EnableResolutionFix = true;
Expand Down Expand Up @@ -75,6 +76,7 @@ bool TryLoadINIOptions(const WCHAR* IniFilePath)
Options.EnableResolutionFix = INI_GetBool(IniPath, L"Patches", L"EnableResolutionFix", Options.EnableResolutionFix);

Options.MinNPCDistance = INI_GetFloat(IniPath, L"Graphics", L"MinimumNPCDistance", Options.MinNPCDistance);
Options.MonsterDistanceMultiplier = INI_GetFloat(IniPath, L"Graphics", L"MonsterDistanceMultiplier", Options.MonsterDistanceMultiplier);
Options.OverrideCharaSharpenFilterStrength = INI_GetFloat(IniPath, L"Graphics", L"OverrideCharaSharpenFilterStrength", Options.OverrideCharaSharpenFilterStrength);
Options.OverrideStageSharpenFilterStrength = INI_GetFloat(IniPath, L"Graphics", L"OverrideStageSharpenFilterStrength", Options.OverrideStageSharpenFilterStrength);
Options.MinStageEdgeBaseDistance = INI_GetFloat(IniPath, L"Graphics", L"MinStageEdgeBaseDistance", Options.MinStageEdgeBaseDistance);
Expand Down Expand Up @@ -132,6 +134,21 @@ void BP_PF_NPC_Walk_AIController__InitNPCDistance_Hook(void* a1, void* a2, float
// which is then checked at 0x140E2AC96 to see if NPC should be deleted or not
}

const uint32_t Addr_AEncountGroup__IsWithinRange = 0xDE6AE0;
typedef bool(*AEncountGroup__IsWithinRange_Fn)(AEncountGroup* thisptr, struct FEncountAreaInfo* AreaInfo);
AEncountGroup__IsWithinRange_Fn AEncountGroup__IsWithinRange_Orig;
bool AEncountGroup__IsWithinRange_Hook(AEncountGroup* thisptr, struct FEncountAreaInfo* AreaInfo)
{
// Only mess with SpawnAreaInfo - seems BattleAreaInfo also goes through this func
if (AreaInfo != &thisptr->SpawnAreaInfo)
return AEncountGroup__IsWithinRange_Orig(thisptr, AreaInfo);

FEncountAreaInfo NewAreaInfo(*AreaInfo);
NewAreaInfo.Range *= Options.MonsterDistanceMultiplier;
// todo: should we update NewAreaInfo.HalfHeight?
return AEncountGroup__IsWithinRange_Orig(thisptr, &NewAreaInfo);
}

bool InitGame()
{
printf("\nArise-SDK " SDK_VERSION " - https://github.com/emoose/Arise-SDK\n");
Expand Down Expand Up @@ -230,6 +247,8 @@ void CVarSystemResolution_ctor_Hook()
CVarSystemResolution_ctor_Orig();
auto consoleManager = *(IConsoleManager**)(mBaseAddress + Addr_IConsoleManager__Singleton);

CVarPointers.push_back(consoleManager->RegisterConsoleVariableRef(L"sdk.MonsterDistanceMultiplier", Options.MonsterDistanceMultiplier, L"MonsterDistanceMultiplier", 0));

CVarPointers.push_back(consoleManager->RegisterConsoleVariableRef(L"sdk.CharaSharpenFilterStrength", Options.OverrideCharaSharpenFilterStrength, L"Adjust sharpen filter applied to characters", 0));
CVarPointers.push_back(consoleManager->RegisterConsoleVariableRef(L"sdk.StageSharpenFilterStrength", Options.OverrideStageSharpenFilterStrength, L"Adjust sharpen filter applied to the game world", 0));
CVarPointers.push_back(consoleManager->RegisterConsoleVariableRef(L"sdk.MinStageEdgeBaseDistance", Options.MinStageEdgeBaseDistance, L"Allows increasing the distance that cel-shading is applied for", 0));
Expand Down Expand Up @@ -586,17 +605,21 @@ void InitPlugin()
{
MH_GameHook(APFNpcManager__InitsDistances);
MH_GameHook(BP_PF_NPC_Walk_AIController__InitNPCDistance);
// Patch fade distances used by BP_PF_NPC_Walk_System / BP_PF_NPC_Walk_AIController

// UPFNpcCameraFadeComponent fade distances
// (used by BP_PF_NPC_Walk_System / BP_PF_NPC_Walk_AIController)
SafeWriteModule(0x116BD47 + 6, Options.MinNPCDistance - FadeInDelta);
SafeWriteModule(0x116BD51 + 6, Options.MinNPCDistance);
SafeWriteModule(0x116BD83 + 6, Options.MinNPCDistance - FadeInDelta);
SafeWriteModule(0x116BD8D + 6, Options.MinNPCDistance);

// These have same value as the ones patched above, but don't seem to be used by walking NPCs, unsure what uses them
// SafeWriteModule(0x1180595 + 3, Options.MinNPCDistance - FadeInDelta);
// SafeWriteModule(0x118059C + 3, Options.MinNPCDistance);
// FPFNpcCameraSettingsData ICppStructOps::Construct
SafeWriteModule(0x1180595 + 3, Options.MinNPCDistance - FadeInDelta);
SafeWriteModule(0x118059C + 3, Options.MinNPCDistance);
}

MH_GameHook(AEncountGroup__IsWithinRange);

// Prevent resolution change on game launch
// (requires r.SetRes = 2560x1440f line inside Engine.ini to work properly, change with your desired resolution)
// TODO: find a way so setres isn't required
Expand Down
8 changes: 4 additions & 4 deletions src/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,24,2
PRODUCTVERSION 0,1,24,0
FILEVERSION 0,1,25,0
PRODUCTVERSION 0,1,25,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "emoose"
VALUE "FileDescription", "Arise-SDK - improvement extension for Tales of Arise"
VALUE "FileVersion", "0.1.24.2"
VALUE "FileVersion", "0.1.25.0"
VALUE "InternalName", "Arise-SDK.dll"
VALUE "LegalCopyright", "emoose - 2021"
VALUE "OriginalFilename", "Arise-SDK.dll"
VALUE "ProductName", "Arise-SDK"
VALUE "ProductVersion", "0.1.24.2"
VALUE "ProductVersion", "0.1.25.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 094c98f

Please sign in to comment.