Skip to content

Commit

Permalink
Changes to Fake Teleport and Fake Fake Teleport (#3692)
Browse files Browse the repository at this point in the history
- Added Blimp Strats, Make Random Stunt Jump and Teleport To Random
Store to fake teleports
- Tidy up the code for fake teleports
- Fix CurrentEffect::OverrideEffectNameFromId

---------

Co-authored-by: Reguas <64607261+Reguas@users.noreply.github.com>
  • Loading branch information
Regynate and Regynate authored Jan 21, 2025
1 parent db872cb commit af936fd
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 143 deletions.
15 changes: 15 additions & 0 deletions ChaosMod/Components/EffectDispatchTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ void EffectDispatchTimer::ResetFakeTimerPercentage()
m_FakeTimerPercentage = 0.f;
}

bool EffectDispatchTimer::IsTimerPaused() const
{
return m_PauseTimer;
}

void EffectDispatchTimer::SetTimerPaused(bool pause)
{
m_PauseTimer = pause;
}

bool EffectDispatchTimer::IsUsingDistanceBasedDispatch() const
{
return m_DistanceChaosState.EnableDistanceBasedEffectDispatch;
}

void EffectDispatchTimer::OnRun()
{
auto curTime = GetTickCount64();
Expand Down
5 changes: 5 additions & 0 deletions ChaosMod/Components/EffectDispatchTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ class EffectDispatchTimer : public Component
void SetFakeTimerPercentage(float percentage);
void ResetFakeTimerPercentage();

bool IsTimerPaused() const;
void SetTimerPaused(bool pause);

bool IsUsingDistanceBasedDispatch() const;

virtual void OnRun() override;
};
4 changes: 2 additions & 2 deletions ChaosMod/Components/EffectDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ void EffectDispatcher::UpdateEffects(int deltaTime)
if (!effectSharedData->OverrideEffectName.empty())
{
activeEffect.FakeName = effectSharedData->OverrideEffectName;
effectSharedData->OverrideEffectId.clear();
effectSharedData->OverrideEffectName.clear();
}

if (!effectSharedData->OverrideEffectId.empty())
{
if (g_EnabledEffects.contains(effectSharedData->OverrideEffectId))
{
auto &fakeEffect = g_EnabledEffects.at(effectSharedData->OverrideEffectId);
activeEffect.FakeName = !fakeEffect.HasCustomName() ? "" : fakeEffect.CustomName;
activeEffect.FakeName = !fakeEffect.HasCustomName() ? fakeEffect.Name : fakeEffect.CustomName;
}
else
{
Expand Down
19 changes: 15 additions & 4 deletions ChaosMod/Effects/db/Player/PlayerBlimpStrats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

#include "Memory/Hooks/ScriptThreadRunHook.h"

static void OnStart()
#include "PlayerBlimpStrats.h"

void OnStartBlimpStrats(bool bHandleThreadBlock)
{
Hooks::EnableScriptThreadBlock();
if (bHandleThreadBlock)
Hooks::EnableScriptThreadBlock();

bool cutscenePlaying = IS_CUTSCENE_PLAYING();

Hash blimpHash = "blimp"_hash;
Expand Down Expand Up @@ -61,15 +65,22 @@ static void OnStart()
SET_PED_AS_NO_LONGER_NEEDED(&pedDave);
}

Hooks::DisableScriptThreadBlock();
if (bHandleThreadBlock)
Hooks::DisableScriptThreadBlock();

SET_VEHICLE_AS_NO_LONGER_NEEDED(&veh);
}

static void OnStart()
{
OnStartBlimpStrats(true);
}

// clang-format off
REGISTER_EFFECT(OnStart, nullptr, nullptr, EffectInfo
{
.Name = "Blimp Strats",
.Id = "player_blimp_strats",
.EffectGroupType = EffectGroupType::Teleport
}
);
);
3 changes: 3 additions & 0 deletions ChaosMod/Effects/db/Player/PlayerBlimpStrats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void OnStartBlimpStrats(bool bHandleThreadBlock);
6 changes: 4 additions & 2 deletions ChaosMod/Effects/db/Player/PlayerRandomStuntJump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Util/Player.h"
#include "Util/Vehicle.h"

#include "PlayerRandomStuntJump.h"

struct Location
{
Vector3 coordinates;
Expand Down Expand Up @@ -47,7 +49,7 @@ CHAOS_VAR std::vector<Location> allPossibleJumps = {
{ { -958.207, -2766.583, 13.693 }, 151.829, 45.f } // 30
};

static void OnStart()
void OnStartMakeRandomStuntJump()
{
Ped playerPed = PLAYER_PED_ID();
Vehicle veh;
Expand Down Expand Up @@ -76,7 +78,7 @@ static void OnStart()
}

// clang-format off
REGISTER_EFFECT(OnStart, nullptr, nullptr, EffectInfo
REGISTER_EFFECT(OnStartMakeRandomStuntJump, nullptr, nullptr, EffectInfo
{
.Name = "Make Random Stunt Jump",
.Id = "player_tp_stunt",
Expand Down
3 changes: 3 additions & 0 deletions ChaosMod/Effects/db/Player/PlayerRandomStuntJump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void OnStartMakeRandomStuntJump();
Loading

0 comments on commit af936fd

Please sign in to comment.