mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
fixed some player variables issues, implemented camera teleportation
This commit is contained in:
@ -46,4 +46,16 @@ namespace Engine {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseCamera::SetPosition(const Vector3* pos) {
|
||||
__try {
|
||||
void* (*pSetPosition)(LPVOID pCBaseCamera, const Vector3* pos) = (decltype(pSetPosition))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?SetPosition@IBaseCamera@@QEAAXAEBVvec3@@@Z");
|
||||
if (!pSetPosition)
|
||||
return;
|
||||
|
||||
pSetPosition(this, pos);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,5 +15,7 @@ namespace Engine {
|
||||
Vector3* GetUpVector(Vector3* outUpVec);
|
||||
Vector3* GetLeftVector(Vector3* outLeftVec);
|
||||
Vector3* GetPosition(Vector3* outPos);
|
||||
|
||||
void SetPosition(const Vector3* pos);
|
||||
};
|
||||
}
|
@ -203,6 +203,9 @@ namespace GamePH {
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
std::unordered_map<std::string, std::any> PlayerVariables::prevPlayerVarValueMap{};
|
||||
std::unordered_map<std::string, bool> PlayerVariables::prevOptionValueMap{};
|
||||
|
||||
PlayerVariables* PlayerVariables::Get() {
|
||||
__try {
|
||||
PlayerState* pPlayerState = PlayerState::Get();
|
||||
|
@ -81,13 +81,13 @@ namespace GamePH {
|
||||
*(varValue + 1) = value;
|
||||
}
|
||||
}
|
||||
static std::unordered_map<std::string, std::any> prevPlayerVarValueMap;
|
||||
static std::unordered_map<std::string, bool> prevOptionValueMap;
|
||||
|
||||
template <typename T> static void ManagePlayerVarOption(const std::string& playerVar, const T valueIfTrue, const T valueIfFalse, Option* option, const bool& usePreviousVal = true) {
|
||||
if (!gotPlayerVars)
|
||||
return;
|
||||
|
||||
static std::unordered_map<std::string, T> prevPlayerVarValueMap;
|
||||
static std::unordered_map<std::string, bool> prevOptionValueMap;
|
||||
|
||||
if (prevPlayerVarValueMap.find(playerVar) == prevPlayerVarValueMap.end())
|
||||
prevPlayerVarValueMap[playerVar] = GamePH::PlayerVariables::GetPlayerVar<T>(playerVar);
|
||||
if (prevOptionValueMap.find(playerVar) == prevOptionValueMap.end())
|
||||
@ -101,7 +101,7 @@ namespace GamePH {
|
||||
prevOptionValueMap[playerVar] = true;
|
||||
} else if (prevOptionValueMap[playerVar]) {
|
||||
prevOptionValueMap[playerVar] = false;
|
||||
GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? prevPlayerVarValueMap[playerVar] : valueIfFalse);
|
||||
GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? std::any_cast<T>(prevPlayerVarValueMap[playerVar]) : valueIfFalse);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,27 +140,23 @@ namespace Menu {
|
||||
|
||||
Engine::CBulletPhysicsCharacter* playerCharacter = Engine::CBulletPhysicsCharacter::Get();
|
||||
|
||||
if (Player::freezePlayer.GetValue()) {
|
||||
if (!playerCharacter)
|
||||
return false;
|
||||
|
||||
playerCharacter->posBeforeFreeze = pos;
|
||||
playerCharacter->MoveCharacter(pos);
|
||||
} else if (Camera::freeCam.GetValue()) {
|
||||
if (Camera::freeCam.GetValue()) {
|
||||
GamePH::FreeCamera* freeCam = GamePH::FreeCamera::Get();
|
||||
if (!freeCam)
|
||||
return false;
|
||||
|
||||
Vector3 camPos{};
|
||||
freeCam->GetPosition(&camPos);
|
||||
if (camPos.isDefault())
|
||||
return false;
|
||||
|
||||
// need to implement camera teleportation here :(
|
||||
freeCam->SetPosition(&pos);
|
||||
if (playerCharacter) {
|
||||
if (Player::freezePlayer.GetValue())
|
||||
playerCharacter->posBeforeFreeze = pos;
|
||||
playerCharacter->MoveCharacter(pos);
|
||||
}
|
||||
} else {
|
||||
if (!playerCharacter)
|
||||
return false;
|
||||
|
||||
if (Player::freezePlayer.GetValue())
|
||||
playerCharacter->posBeforeFreeze = pos;
|
||||
playerCharacter->MoveCharacter(pos);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user