-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ForestJ316/Fix1stPerson
Fix for SetAlpha not working correctly for first person
- Loading branch information
Showing
6 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "Fixes.h" | ||
|
||
//Bandaid fix for SetAlpha not working properly for first person | ||
namespace Fixes::FirstPersonAlpha | ||
{ | ||
struct FirstPersonAlpha | ||
{ | ||
static void Install() | ||
{ | ||
REL::Relocation<std::uintptr_t> target { REL_ID(37777, 38722), 0x55 }; | ||
|
||
auto& trampoline = SKSE::GetTrampoline(); | ||
SKSE::AllocTrampoline(14); | ||
|
||
_SetFPAlpha = trampoline.write_call<6>(target.address(), SetFPAlpha); | ||
} | ||
|
||
private: | ||
static RE::NiAVObject* SetFPAlpha(RE::PlayerCharacter* player, float alpha_value) | ||
{ | ||
// fade == false -> alpha_value = 2 to 3 | ||
// fade == true -> alpha_value = 0 to 1 | ||
if (alpha_value >= 2) { | ||
alpha_value -= 2; | ||
} | ||
player->Get3D(true)->UpdateMaterialAlpha(alpha_value, false); | ||
return nullptr; // Return null so that the original fade function for 1st person doesn't execute | ||
} | ||
static inline REL::Relocation<decltype(SetFPAlpha)> _SetFPAlpha; | ||
}; | ||
|
||
void Install() | ||
{ | ||
FirstPersonAlpha::Install(); | ||
logger::info("\t\tInstalled first person alpha fix"sv); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters