Skip to content

Commit

Permalink
CTheScripts::Process
Browse files Browse the repository at this point in the history
  • Loading branch information
Pirulax committed Jul 16, 2023
1 parent 84d72bb commit c406452
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 48 deletions.
67 changes: 64 additions & 3 deletions source/game_sa/Scripts/TheScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "PedGroups.h"
#include "Checkpoint.h"
#include "Checkpoints.h"
#include "LoadingScreen.h"
// #include "Scripted2dEffects.h"
#include "Shadows.h"

Expand All @@ -28,6 +29,7 @@ void CTheScripts::InjectHooks() {
RH_ScopedInstall(IsPedStopped, 0x486110);
RH_ScopedInstall(HasCarModelBeenSuppressed, 0x46A810);
RH_ScopedInstall(HasVehicleModelBeenBlockedByScript, 0x46A890);
RH_ScopedInstall(Process, 0x46A000);
}

// 0x468D50
Expand Down Expand Up @@ -376,14 +378,72 @@ void CTheScripts::StartTestScript() {
void CTheScripts::Process() {
ZoneScoped;

plugin::Call<0x46A000>();
if (CReplay::Mode == 1) {
return;
}

CommandsExecuted = 0;

UpsideDownCars.UpdateTimers();
StuckCars.Process();
MissionCleanUp.CheckIfCollisionHasLoadedForMissionObjects();
CTheScripts::DrawScriptSpheres();
CTheScripts::ProcessAllSearchLights();
CTheScripts::ProcessWaitingForScriptBrainArray();

if (CTheScripts::FailCurrentMission) {
--CTheScripts::FailCurrentMission;
}

if (CTheScripts::UseTextCommands) {
rng::fill(IntroTextLines, tScriptText{});
NumberOfIntroTextLinesThisFrame = 0;

rng::fill(IntroRectangles, tScriptRectangle{});
NumberOfIntroRectanglesThisFrame = 0;

CTheScripts::UseTextCommands = false;
}

const auto timeStepMS = (int32)CTimer::GetTimeStepInMS();
LocalVariablesForCurrentMission[32].iParam += timeStepMS;
LocalVariablesForCurrentMission[33].iParam += timeStepMS;

CLoadingScreen::NewChunkLoaded();

for (auto it = pActiveScripts; it;) {
const auto next = it->m_pNext;

for (auto& t : it->m_anTimers) {
t += timeStepMS;
}
it->Process();

it = next;
}

CLoadingScreen::NewChunkLoaded();

for (auto& ped : GetPedPool()->GetAllValid()) {
if (ped.IsCreatedByMission()) {
ped.GetIntelligence()->RecordEventForScript(0, 0);
}
}
}

// 0x4939F0
void CTheScripts::ProcessAllSearchLights() {
ZoneScoped;

return plugin::Call<0x4939F0>();
}

void CTheScripts::ProcessWaitingForScriptBrainArray() {
ZoneScoped;

plugin::Call<0x46CF00>();
}

// 0x4812D0
void CTheScripts::UndoEntityInvisibilitySettings() {
plugin::Call<0x4812D0>();
Expand Down Expand Up @@ -534,8 +594,9 @@ void CTheScripts::ScriptDebugCircle2D(float x, float y, float width, float heigh
}

// 0x4810E0
void CTheScripts::DrawScriptSpheres()
{
void CTheScripts::DrawScriptSpheres() {
ZoneScoped;

return plugin::Call<0x4810E0>();
for (auto& script : ScriptSphereArray) {
if (script.m_bUsed) {
Expand Down
67 changes: 22 additions & 45 deletions source/game_sa/Scripts/TheScripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,51 +124,28 @@ struct tScriptSequence {
VALIDATE_SIZE(tScriptSequence, 0x4);

struct tScriptText {
float m_fLetterWidth;
float m_fLetterHeight;
CRGBA m_Color;
bool m_bJustify;
bool m_bCentered;
bool m_bWithBackground;
bool m_bUnk;
float m_fLineHeight;
float m_fLineWidth;
CRGBA m_BackgroundBoxColor;
bool m_bProportional;
CRGBA m_BackgroundColor;
int8 m_nShadowType;
int8 m_nOutlineType;
bool m_bDrawBeforeFade;
bool m_bRightJustify;
int32 m_nFont;
CVector2D m_Pos;
char m_szGxtEntry[8];
int32 param1;
int32 param2;

tScriptText() { // 0x4690A8
m_fLetterWidth = 0.48f;
m_fLetterHeight = 1.12f;
m_Color = CRGBA(225, 225, 225, 255);
m_fLineHeight = SCREEN_WIDTH;
m_fLineWidth = SCREEN_WIDTH;
m_bJustify = false;
m_bRightJustify = false;
m_bCentered = false;
m_bWithBackground = false;
m_bUnk = false;
m_BackgroundBoxColor = CRGBA(128, 128, 128, 128);
m_bProportional = true;
m_BackgroundColor = CRGBA(0, 0, 0, 255);
m_nShadowType = 2;
m_nOutlineType = 0;
m_bDrawBeforeFade = false;
m_nFont = 1;
m_Pos = CVector2D();
param1 = -1;
param2 = -1;
memset(&m_szGxtEntry, 0, sizeof(m_szGxtEntry));
}
// values from 0x4690A8
float m_fLetterWidth{ 0.48f };
float m_fLetterHeight{ 1.12f };
CRGBA m_Color{ 225, 225, 225, 255 };
bool m_bJustify{ false };
bool m_bCentered{ false };
bool m_bWithBackground{ false };
bool m_bUnk{ false };
float m_fLineHeight{ SCREEN_HEIGHT };
float m_fLineWidth{ SCREEN_WIDTH };
CRGBA m_BackgroundBoxColor{ 128, 128, 128, 128 };
bool m_bProportional{ true };
CRGBA m_BackgroundColor{ 0, 0, 0, 255 };
int8 m_nShadowType{ 2 };
int8 m_nOutlineType{ 0 };
bool m_bDrawBeforeFade{ false };
bool m_bRightJustify{ false };
int32 m_nFont{ 1 };
CVector2D m_Pos{};
char m_szGxtEntry[8]{};
int32 param1{ -1 };
int32 param2{ -1 };
};
VALIDATE_SIZE(tScriptText, 0x44);

Expand Down

0 comments on commit c406452

Please sign in to comment.