fix(Spectate & FreeCam): Dying while going far away from our ped (#458)

This commit is contained in:
Yimura 2022-09-29 20:54:08 +01:00 committed by GitHub
parent 0597d8728e
commit ca7906141f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 7 deletions

View File

@ -1,6 +1,7 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "services/players/player_service.hpp" #include "services/players/player_service.hpp"
#include "util/globals.hpp"
namespace big namespace big
{ {
@ -21,20 +22,30 @@ namespace big
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1); NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1);
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1);
ENTITY::FREEZE_ENTITY_POSITION(ped, false); ENTITY::FREEZE_ENTITY_POSITION(ped, false);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false); ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
STREAMING::SET_FOCUS_ENTITY(ped);
globals::disable_kill_trigger(false);
} }
return; return;
} }
const Ped target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id()); const auto target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id());
globals::disable_kill_trigger(true);
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target); NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target);
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target);
ENTITY::FREEZE_ENTITY_POSITION(ped, true); ENTITY::FREEZE_ENTITY_POSITION(ped, true);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true); ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
STREAMING::SET_FOCUS_ENTITY(target);
bReset = false; bReset = false;
} }
} }

View File

@ -1,6 +1,7 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "gta/enums.hpp" #include "gta/enums.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "util/globals.hpp"
#include "util/math.hpp" #include "util/math.hpp"
namespace big namespace big
@ -32,12 +33,12 @@ namespace big
{ {
if (g_local_player == nullptr) return; if (g_local_player == nullptr) return;
if (g->self.free_cam && !bLastFreeCam) if (g->self.free_cam)
{ {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0); PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
for (const auto& control : controls) for (const auto& control : controls)
PAD::DISABLE_CONTROL_ACTION(0, static_cast<int>(control), true); PAD::ENABLE_CONTROL_ACTION(0, static_cast<int>(control), true);
} }
} }
@ -45,8 +46,8 @@ namespace big
{ {
if (g_local_player == nullptr) return; if (g_local_player == nullptr) return;
Vehicle vehicle = self::veh; const auto vehicle = self::veh;
Ped ped = self::ped; const auto ped = self::ped;
if (!g->self.free_cam && !bLastFreeCam) return; if (!g->self.free_cam && !bLastFreeCam) return;
if (g->self.free_cam && !bLastFreeCam) if (g->self.free_cam && !bLastFreeCam)
@ -56,7 +57,9 @@ namespace big
vecPosition = CAM::GET_GAMEPLAY_CAM_COORD(); vecPosition = CAM::GET_GAMEPLAY_CAM_COORD();
vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2); vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2);
globals::disable_kill_trigger(true);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true); ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
CAM::SET_CAM_COORD(cCam, vecPosition.x, vecPosition.y, vecPosition.z); CAM::SET_CAM_COORD(cCam, vecPosition.x, vecPosition.y, vecPosition.z);
CAM::SET_CAM_ROT(cCam, vecRot.x, vecRot.y, vecRot.z, 2); CAM::SET_CAM_ROT(cCam, vecRot.x, vecRot.y, vecRot.z, 2);
CAM::SET_CAM_ACTIVE(cCam, true); CAM::SET_CAM_ACTIVE(cCam, true);
@ -66,12 +69,14 @@ namespace big
} }
else if (!g->self.free_cam && bLastFreeCam) else if (!g->self.free_cam && bLastFreeCam)
{ {
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
CAM::SET_CAM_ACTIVE(cCam, false); CAM::SET_CAM_ACTIVE(cCam, false);
CAM::RENDER_SCRIPT_CAMS(false, true, 500, true, true, 0); CAM::RENDER_SCRIPT_CAMS(false, true, 500, true, true, 0);
CAM::DESTROY_CAM(cCam, false); CAM::DESTROY_CAM(cCam, false);
STREAMING::SET_FOCUS_ENTITY(ped); STREAMING::SET_FOCUS_ENTITY(ped);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
globals::disable_kill_trigger(false);
bLastFreeCam = false; bLastFreeCam = false;
return; return;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "pointers.hpp"
#include "script_global.hpp" #include "script_global.hpp"
#include "util/system.hpp"
namespace big::globals namespace big::globals
{ {
@ -15,4 +15,9 @@ namespace big::globals
g_pointers->m_trigger_script_event(1, args, arg_count, 1 << target); g_pointers->m_trigger_script_event(1, args, arg_count, 1 << target);
} }
inline void disable_kill_trigger(bool toggle)
{
*script_global(2815059).at(6753).as<int*>() = toggle; // "TRI_WARP" 2nd nested if statement below this text in freemode.c
}
} }