Merge pull request #67 from xCENTx/Code-Modularity

Enhance Code Modularity and Readability
This commit is contained in:
swordbluesword 2024-01-30 23:19:05 +08:00 committed by GitHub
commit 114ba1693c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 19 deletions

View File

@ -311,6 +311,24 @@ void RespawnLocalPlayer(bool bIsSafe)
bIsSafe ? pPalPlayerController->TeleportToSafePoint_ToServer() : pPalPlayerState->RequestRespawn(); bIsSafe ? pPalPlayerController->TeleportToSafePoint_ToServer() : pPalPlayerState->RequestRespawn();
} }
void SetPlayerHealth(__int32 newHealth)
{
APalPlayerCharacter* pPalPlayerCharacter = Config.GetPalPlayerCharacter();
if (!pPalPlayerCharacter)
return;
UPalCharacterParameterComponent* pParams = pPalPlayerCharacter->CharacterParameterComponent;
if (!pParams)
return;
FFixedPoint64 maxHP = pParams->GetMaxHP();
if (newHealth > maxHP.Value)
newHealth = maxHP.Value;
FFixedPoint newHealthPoint = FFixedPoint(newHealth);
pPalPlayerCharacter->ReviveCharacter_ToServer(newHealthPoint);
}
// //
void ReviveLocalPlayer() void ReviveLocalPlayer()
{ {
@ -318,10 +336,16 @@ void ReviveLocalPlayer()
if (!pPalPlayerCharacter) if (!pPalPlayerCharacter)
return; return;
FFixedPoint newHealthPoint = FFixedPoint(99999999); UPalCharacterParameterComponent* pParams = pPalPlayerCharacter->CharacterParameterComponent;
if (Config.GetPalPlayerCharacter()->CharacterParameterComponent->IsDying()) if (!pParams)
Config.GetPalPlayerCharacter()->CharacterParameterComponent->ReviveFromDying(); return;
pPalPlayerCharacter->ReviveCharacter_ToServer(newHealthPoint);
if (pParams->IsDying())
pParams->ReviveFromDying();
FFixedPoint64 maxHP = pParams->GetMaxHP();
FFixedPoint newHealth = FFixedPoint(maxHP.Value);
pPalPlayerCharacter->ReviveCharacter_ToServer(newHealth);
} }
// //

View File

@ -29,6 +29,8 @@ void SetDemiGodMode(bool bIsSet);
void RespawnLocalPlayer(bool bIsSafe); void RespawnLocalPlayer(bool bIsSafe);
void SetPlayerHealth(__int32 newHealth);
void ReviveLocalPlayer(); void ReviveLocalPlayer();
void ResetStamina(); void ResetStamina();

View File

@ -72,7 +72,8 @@ namespace DX11_Base
ImGui::Checkbox("InfStamina", &Config.IsInfStamina); ImGui::Checkbox("InfStamina", &Config.IsInfStamina);
ImGui::Checkbox("InfAmmo", &Config.IsInfinAmmo); if (ImGui::Checkbox("InfAmmo", &Config.IsInfinAmmo))
SetInfiniteAmmo(Config.IsInfinAmmo);
ImGui::Checkbox("Godmode", &Config.IsGodMode); ImGui::Checkbox("Godmode", &Config.IsGodMode);
@ -782,23 +783,11 @@ namespace DX11_Base
if (Config.IsDeathAura) if (Config.IsDeathAura)
DeathAura(Config.mDeathAuraAmount, Config.mDeathAuraDistance, true); DeathAura(Config.mDeathAuraAmount, Config.mDeathAuraDistance, true);
// //
// SetDemiGodMode(Config.IsMuteki); // SetDemiGodMode(Config.IsMuteki);
if (Config.GetPalPlayerCharacter() != NULL)
{
if (Config.GetPalPlayerCharacter()->ShooterComponent != NULL && Config.GetPalPlayerCharacter()->ShooterComponent->GetHasWeapon() != NULL && Config.GetPalPlayerCharacter()->ShooterComponent->CanShoot())
{
Config.GetPalPlayerCharacter()->ShooterComponent->GetHasWeapon()->IsRequiredBullet = !Config.IsInfinAmmo;
}
}
if (Config.IsGodMode) if (Config.IsGodMode)
{ SetPlayerHealth(INT_MAX);
if (Config.GetPalPlayerCharacter() && Config.GetPalPlayerCharacter()->CharacterParameterComponent && Config.GetPalPlayerCharacter()->CharacterParameterComponent->IndividualParameter)
{
if (Config.GetPalPlayerCharacter()->CharacterParameterComponent->IndividualParameter->GetHP().Value < INT_MAX)
Config.GetPalPlayerCharacter()->ReviveCharacter_ToServer(SDK::FFixedPoint(INT_MAX));
}
}
} }
} }