Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fake wasted busted state more realistic #309

Open
wants to merge 1 commit into
base: 3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions src/gtasa/effects/custom/player/GetWastedBustedFakeEffect.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "util/EffectBase.h"
#include "util/GenericUtil.h"
#include "util/hooks/HookMacros.h"

#include <extensions/ScriptCommands.h>

enum class FakeEffectType
Expand All @@ -8,7 +10,7 @@ enum class FakeEffectType
BUSTED
};

constexpr int FADE_IN_TIME = 5000;
constexpr int FADE_IN_TIME = 5000;
constexpr float FADE_IN_TIME_FLOAT = FADE_IN_TIME * 0.001f;
constexpr float FADE_OUT_TIME_FLOAT = 1.0f;
constexpr int WAIT_TO_FADE_OUT_START = FADE_IN_TIME + 500;
Expand All @@ -20,6 +22,8 @@ class GetWastedBustedFake : public EffectBase
FakeEffectType type;
int wait = 0;

static inline bool skipBlipRender{};

public:
GetWastedBustedFake () = delete;

Expand All @@ -28,11 +32,23 @@ class GetWastedBustedFake : public EffectBase
void
OnStart (EffectInstance *inst) override
{
HOOK_ARGS (inst, Hooked_CRadar_ShowRadarTraceWithHeight,
void (float, float, std::uint32_t, std::uint32_t,
std::uint32_t, std::uint32_t, std::uint32_t,
std::uint8_t),
0x584070);

inst->SetIsOneTimeEffect ();
inst->SetTimerVisible (false);

skipBlipRender = true;
std::string msg (type == FakeEffectType::WASTED ? "DEAD" : "BUSTED");
Command<Commands::CLEAR_SMALL_PRINTS> ();
Command<Commands::SET_EVERYONE_IGNORE_PLAYER> (0, true);
Command<Commands::SET_POLICE_IGNORE_PLAYER> (0, true);
Command<Commands::CLEAR_MISSION_AUDIO> (1);
Command<Commands::CLEAR_MISSION_AUDIO> (2);
Command<Commands::CLEAR_HELP> ();
Command<eScriptCommands::COMMAND_PRINT_BIG> (msg.data (), FADE_IN_TIME,
3);

Expand All @@ -43,7 +59,7 @@ class GetWastedBustedFake : public EffectBase
}

TheCamera.Fade (FADE_IN_TIME_FLOAT, 0);

auto *player = FindPlayerPed ();
if (!player) return;

Expand All @@ -69,7 +85,7 @@ class GetWastedBustedFake : public EffectBase

auto *pad = player->GetPadFromPlayer ();
if (!pad) return;

pad->DisablePlayerControls = true;

wait += int (GenericUtil::CalculateTick ());
Expand All @@ -84,16 +100,32 @@ class GetWastedBustedFake : public EffectBase

Command<eScriptCommands::COMMAND_RESTORE_CAMERA> ();

TheCamera.Fade (FADE_OUT_TIME_FLOAT, 1);
TheCamera.Fade (FADE_OUT_TIME_FLOAT, 1);

pad->DisablePlayerControls = false;
Command<Commands::SET_EVERYONE_IGNORE_PLAYER> (0, false);
Command<Commands::SET_POLICE_IGNORE_PLAYER> (0, false);

wait = 0;
pad->DisablePlayerControls = false;

wait = 0;
skipBlipRender = false;

inst->OverrideName (std::string (inst->GetName ()) + "?");
inst->Disable ();
}
}

static void
Hooked_CRadar_ShowRadarTraceWithHeight (auto &&cb, float x, float y,
std::uint32_t size, std::uint32_t R,
std::uint32_t G, std::uint32_t B,
std::uint32_t A,
std::uint8_t height)
{
if (skipBlipRender) return;

cb ();
}
};

DEFINE_EFFECT (GetWastedBustedFake, "effect_get_busted_fake", GROUP_VISION,
Expand Down
Loading