From ebbcd92de28d37f1dd36c9120f92c958e394ff75 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 3 Aug 2019 16:01:13 +0300 Subject: RunningScript, part 4, plus some fixes --- src/core/Camera.cpp | 10 ++++++++++ src/core/Camera.h | 5 +++++ src/core/Radar.cpp | 16 ++++++++-------- src/core/Radar.h | 8 ++++---- 4 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index b5ba76db..f3582c67 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -24,6 +24,16 @@ WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); } WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); } WRAPPER void CCamera::SetWidescreenOff(void) { EAXJMP(0x46FF10); } WRAPPER void CamShakeNoPos(CCamera*, float) { EAXJMP(0x46B100); } +WRAPPER void CCamera::TakeControl(CEntity*, int16, int16, int32) { EAXJMP(0x471500); } +WRAPPER void CCamera::TakeControlNoEntity(const CVector&, int16, int32) { EAXJMP(0x4715B0); } +WRAPPER void CCamera::SetCamPositionForFixedMode(const CVector&, const CVector&) { EAXJMP(0x46FCC0); } + + +bool +CCamera::GetFading() +{ + return m_bFading; +} bool CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat) diff --git a/src/core/Camera.h b/src/core/Camera.h index 3ce0d9a6..97ed79f4 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -471,6 +471,11 @@ int m_iModeObbeCamIsInForCar; float Find3rdPersonQuickAimPitch(void); + void TakeControl(CEntity*, int16, int16, int32); + void TakeControlNoEntity(const CVector&, int16, int32); + void SetCamPositionForFixedMode(const CVector&, const CVector&); + bool GetFading(); + void dtor(void) { this->CCamera::~CCamera(); } }; static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error"); diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index ea7a7ffa..f04e14d1 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -100,9 +100,9 @@ void CRadar::ChangeBlipBrightness(int32 i, int32 bright) #endif #if 1 -WRAPPER void CRadar::ChangeBlipColour(int32) { EAXJMP(0x4A5770); } +WRAPPER void CRadar::ChangeBlipColour(int32, int32) { EAXJMP(0x4A5770); } #else -void CRadar::ChangeBlipColour(int32 i) +void CRadar::ChangeBlipColour(int32 i, int32) { } @@ -571,9 +571,9 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float #endif #if 1 -WRAPPER int32 CRadar::GetActualBlipArray(int32) { EAXJMP(0x4A41C0); } +WRAPPER int32 CRadar::GetActualBlipArrayIndex(int32) { EAXJMP(0x4A41C0); } #else -int32 CRadar::GetActualBlipArray(int32 i) +int32 CRadar::GetActualBlipArrayIndex(int32 i) { return int32(); } @@ -737,18 +737,18 @@ void CRadar::SetBlipSprite(int32 i, int32 icon) #endif #if 1 -WRAPPER int CRadar::SetCoordBlip(int32, CVector, int32) { EAXJMP(0x4A5590); } +WRAPPER int32 CRadar::SetCoordBlip(eBlipType, CVector, int32, eBlipDisplay) { EAXJMP(0x4A5590); } #else -int CRadar::SetCoordBlip(int32 type, CVector pos, int32 flag) +int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 flag, eBlipDisplay) { return 0; } #endif #if 1 -WRAPPER int CRadar::SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag) { EAXJMP(0x4A5640); } +WRAPPER int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) { EAXJMP(0x4A5640); } #else -int CRadar::SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag) +int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) { return 0; } diff --git a/src/core/Radar.h b/src/core/Radar.h index e5396a50..1ec28070 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -98,7 +98,7 @@ public: public: static int CalculateBlipAlpha(float dist); static void ChangeBlipBrightness(int32 i, int32 bright); - static void ChangeBlipColour(int32 i); + static void ChangeBlipColour(int32 i, int32); static void ChangeBlipDisplay(int32 i, int16 flag); static void ChangeBlipScale(int32 i, int16 scale); static void ClearBlip(int32 i); @@ -113,7 +113,7 @@ public: static void DrawRadarSection(int32 x, int32 y); static void DrawRadarSprite(int32 sprite, float x, float y, int32 alpha); static void DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha); - static int32 GetActualBlipArray(int32 i); + static int32 GetActualBlipArrayIndex(int32 i); static int32 GetNewUniqueBlipIndex(int32 i); static int32 GetRadarTraceColour(int32 color, bool bright); static void Initialise(); @@ -125,8 +125,8 @@ public: static void RequestMapSection(int32 x, int32 y); static void SaveAllRadarBlips(int32); static void SetBlipSprite(int32 i, int32 icon); - static int SetCoordBlip(int32 type, CVector pos, int32 flag); - static int SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag); + static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay flag); + static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay); static void SetRadarMarkerState(int32 i, int32 flag); static void ShowRadarMarker(CVector pos, int16 color, float radius); static void ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha); -- cgit v1.2.3 From d3ddfd8e408c7a8bef92f1276ae4e433b5d0af5d Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 3 Aug 2019 21:43:07 +0300 Subject: fixed collision --- src/core/Collision.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index df1dcd63..66b29d9f 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -144,7 +144,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) if(veh && veh->IsTrain()){ if(((CTrain*)veh)->m_nDoorState != TRAIN_DOOR_OPEN) return; - }else if(playerCoors.z < 4.0f && !CCullZones::DoINeedToLoadCollision()) + }else if(playerCoors.z < -4.0f && !CCullZones::DoINeedToLoadCollision()) return; // Figure out whose level's collisions we're most likely to be interested in -- cgit v1.2.3 From a3e3527a3b8f260db285c76dc1044baab8a2f773 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 4 Aug 2019 00:31:00 +0200 Subject: implemented CHeli --- src/core/Stats.cpp | 4 +++- src/core/Stats.h | 2 ++ src/core/Wanted.h | 2 ++ src/core/World.cpp | 2 +- src/core/World.h | 4 ++-- src/core/re3.cpp | 34 +++++++--------------------------- 6 files changed, 17 insertions(+), 31 deletions(-) (limited to 'src/core') diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 01bbf82e..9d0e7df1 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -7,8 +7,10 @@ bool& CStats::CommercialPassed = *(bool*)0x8F4334; bool& CStats::IndustrialPassed = *(bool*)0x8E2A68; int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C; int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50; +int32 &CStats::HelisDestroyed = *(int32*)0x8E2A64; +int32 *CStats::PedsKilledOfThisType = (int32*)0x880DBC; void CStats::AnotherKillFrenzyPassed() { ++NumberKillFrenziesPassed; -} \ No newline at end of file +} diff --git a/src/core/Stats.h b/src/core/Stats.h index c536465f..90db25e8 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -9,6 +9,8 @@ public: static bool& IndustrialPassed; static int32 &NumberKillFrenziesPassed; static int32 &PeopleKilledByOthers; + static int32 &HelisDestroyed; + static int32 *PedsKilledOfThisType; //[NUM_PEDTYPES] public: static void AnotherKillFrenzyPassed(); diff --git a/src/core/Wanted.h b/src/core/Wanted.h index 7cd89b7e..34a4b58d 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -77,6 +77,8 @@ public: void ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesntCare); void UpdateWantedLevel(); + bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; } + static int32 WorkOutPolicePresence(CVector posn, float radius); static void SetMaximumWantedLevel(int32 level); }; diff --git a/src/core/World.cpp b/src/core/World.cpp index 0440a951..c6eb831c 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -646,7 +646,7 @@ CWorld::FindObjectsInRange(CVector ¢re, float distance, bool ignoreZ, short } CEntity* -CWorld::TestSphereAgainstWorld(CVector centre, float distance, CEntity* entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects) +CWorld::TestSphereAgainstWorld(CVector centre, float distance, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects) { CEntity* foundE = nil; diff --git a/src/core/World.h b/src/core/World.h index e4f46589..6c52da5a 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -95,8 +95,8 @@ public: static bool GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, bool ignoreSomeObjects = false); - static CEntity* TestSphereAgainstWorld(CVector, float, CEntity*, bool, bool, bool, bool, bool, bool); - static CEntity* TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool); + static CEntity *TestSphereAgainstWorld(CVector centre, float distance, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects); + static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool); static void FindObjectsInRangeSectorList(CPtrList&, CVector&, float, bool, short*, short, CEntity**); static void FindObjectsInRange(CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool); static float FindGroundZForCoord(float x, float y); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 35b3cfa4..9681160f 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -14,6 +14,7 @@ #include "Streaming.h" #include "PathFind.h" #include "Boat.h" +#include "Heli.h" #include "Automobile.h" #include "debugmenu_public.h" @@ -318,6 +319,12 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy); DebugMenuAddCmd("Debug", "Place Car on Road", PlaceOnRoad); + DebugMenuAddVarBool8("Debug", "Catalina Heli On", (int8*)&CHeli::CatalinaHeliOn, nil); + DebugMenuAddCmd("Debug", "Catalina Fly By", CHeli::StartCatalinaFlyBy); + DebugMenuAddCmd("Debug", "Catalina Take Off", CHeli::CatalinaTakeOff); + DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); + DebugMenuAddVarBool8("Debug", "Script Heli On", (int8*)0x95CD43, nil); + DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", (int8*)&gbShowPedRoadGroups, nil); DebugMenuAddVarBool8("Debug", "Show Car Road Groups", (int8*)&gbShowCarRoadGroups, nil); DebugMenuAddVarBool8("Debug", "Show Collision Lines", (int8*)&gbShowCollisionLines, nil); @@ -347,29 +354,6 @@ delayedPatches10(int a, int b) } */ -void __declspec(naked) HeadlightsFix() -{ - static const float fMinusOne = -1.0f; - _asm - { - fld [esp+708h-690h] - fcomp fMinusOne - fnstsw ax - and ah, 5 - cmp ah, 1 - jnz HeadlightsFix_DontLimit - fld fMinusOne - fstp [esp+708h-690h] - -HeadlightsFix_DontLimit: - fld [esp+708h-690h] - fabs - fld st - push 0x5382F2 - retn - } -} - const int re3_buffsize = 1024; static char re3_buff[re3_buffsize]; @@ -454,10 +438,6 @@ patch() InjectHook(0x475E00, printf, PATCH_JUMP); // _Error - // stolen from silentpatch (sorry) - Patch(0x5382BF, 0x0EEB); - InjectHook(0x5382EC, HeadlightsFix, PATCH_JUMP); - // InterceptCall(&open_script_orig, open_script, 0x438869); // InterceptCall(&RsEventHandler_orig, delayedPatches10, 0x58275E); -- cgit v1.2.3 From 2fc69a0aa51e2fc73a42bec9d4bcf3d38e6b3af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 5 Aug 2019 16:07:10 +0300 Subject: CPed part 218 --- src/core/re3.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9681160f..9fe53579 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -16,6 +16,7 @@ #include "Boat.h" #include "Heli.h" #include "Automobile.h" +#include "Ped.h" #include "debugmenu_public.h" #include @@ -334,6 +335,9 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil); DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); +#ifndef FINAL + DebugMenuAddVarBool8("Debug", "Toggle unused fight feature", (int8*)&CPed::bUnusedFightThingOnPlayer, nil); +#endif DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); -- cgit v1.2.3 From 4ae4bc94c692d9fe5781d36a7be6ab72803f6162 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Wed, 7 Aug 2019 00:32:19 +0300 Subject: CCarCtrl::GenerateOneRandomVehicle! --- src/core/IniFile.cpp | 28 ++++++++++++++++++++++++++++ src/core/IniFile.h | 10 ++++++++++ src/core/common.h | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/core/IniFile.cpp create mode 100644 src/core/IniFile.h (limited to 'src/core') diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp new file mode 100644 index 00000000..08b30876 --- /dev/null +++ b/src/core/IniFile.cpp @@ -0,0 +1,28 @@ +#include "common.h" +#include "patcher.h" +#include "IniFile.h" + +#include "CarCtrl.h" +#include "FileMgr.h" +#include "main.h" +#include "Population.h" + +float &CIniFile::PedNumberMultiplier = *(float*)0x6182F4; +float &CIniFile::CarNumberMultiplier = *(float*)0x6182F8; + +void CIniFile::LoadIniFile() +{ + CFileMgr::SetDir(""); + int f = CFileMgr::OpenFile("gta3.ini", "r"); + if (f){ + CFileMgr::ReadLine(f, gString, 200); + sscanf(gString, "%f", &PedNumberMultiplier); + PedNumberMultiplier = min(3.0f, max(0.5f, PedNumberMultiplier)); + CFileMgr::ReadLine(f, gString, 200); + sscanf(gString, "%f", &CarNumberMultiplier); + CarNumberMultiplier = min(3.0f, max(0.5f, CarNumberMultiplier)); + CFileMgr::CloseFile(f); + } + CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier; + CCarCtrl::MaxNumberOfCarsInUse = 12.0f * CarNumberMultiplier; +} \ No newline at end of file diff --git a/src/core/IniFile.h b/src/core/IniFile.h new file mode 100644 index 00000000..9a98151b --- /dev/null +++ b/src/core/IniFile.h @@ -0,0 +1,10 @@ +#pragma once + +class CIniFile +{ +public: + static void LoadIniFile(); + + static float& PedNumberMultiplier; + static float& CarNumberMultiplier; +}; diff --git a/src/core/common.h b/src/core/common.h index 97a25a3f..2b4c466a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -179,7 +179,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) -#define ABS(a) (((a) < 0) ? (-a) : (a)) +#define ABS(a) (((a) < 0) ? (-(a)) : (a)) #define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min))))) -- cgit v1.2.3 From 0bd681abc514d5a3627edea40b24347696ac8908 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 9 Aug 2019 19:42:18 +0200 Subject: finished CPathFind --- src/core/General.h | 1 + src/core/config.h | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/core') diff --git a/src/core/General.h b/src/core/General.h index 7c0c9562..fe277689 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -74,6 +74,7 @@ public: return result; } + // Returns an angle such that x2/y2 looks at x1/y1 with its forward vector if rotated by that angle static float GetRadianAngleBetweenPoints(float x1, float y1, float x2, float y2) { float x = x2 - x1; diff --git a/src/core/config.h b/src/core/config.h index 52d1dab8..8eda6187 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -33,6 +33,12 @@ enum Config { NUMTEMPOBJECTS = 30, + // Path data + NUM_PATHNODES = 4930, + NUM_CARPATHLINKS = 2076, + NUM_MAPOBJECTS = 1250, + NUM_PATHCONNECTIONS = 10260, + // Link list lengths // TODO: alpha list NUMCOLCACHELINKS = 200, -- cgit v1.2.3 From 0303955de32876860bea8ed0db31f398d73c2073 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 10 Aug 2019 10:44:19 +0300 Subject: More CCarCtrl --- src/core/General.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/General.h b/src/core/General.h index 7c0c9562..351243be 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -98,6 +98,8 @@ public: // not too sure about all these... static uint16 GetRandomNumber(void) { return myrand() & MYRAND_MAX; } + static bool GetRandomTrueFalse(void) + { return GetRandomNumber() < MYRAND_MAX / 2; } // Probably don't want to ever reach high static float GetRandomNumberInRange(float low, float high) { return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); } -- cgit v1.2.3 From be1c7b0761c2de0362a47ecfff616a8931b54805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 10 Aug 2019 18:15:22 +0300 Subject: P.e.d.s. and fixes --- src/core/General.h | 15 +++++++++++++++ src/core/re3.cpp | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src/core') diff --git a/src/core/General.h b/src/core/General.h index fe277689..12f781d4 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -96,6 +96,21 @@ public: } } + // should return direction in 0-8 range. fits perfectly to peds' path directions. + static int CGeneral::GetNodeHeadingFromVector(float x, float y) + { + float angle = CGeneral::GetRadianAngleBetweenPoints(x, y, 0.0f, 0.0f); + if (angle < 0.0f) + angle += TWOPI; + + angle = DEGTORAD(22.5f) + TWOPI - angle; + + if (angle >= TWOPI) + angle -= TWOPI; + + return (int)floorf(angle / DEGTORAD(45.0f)); + } + // not too sure about all these... static uint16 GetRandomNumber(void) { return myrand() & MYRAND_MAX; } diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9fe53579..dc501075 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -139,6 +139,20 @@ SpawnCar(int id) } } +static void +LetThemFollowYou(void) { + CPed* player = (CPed*) FindPlayerPed(); + for (int i = 0; i < player->m_numNearPeds; i++) { + + CPed* nearPed = player->m_nearPeds[i]; + if (nearPed && !nearPed->IsPlayer()) { + nearPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, (void*)player); + nearPed->m_pedFormation = rand() & 7; + nearPed->bScriptObjectiveCompleted = false; + } + } +} + static void FixCar(void) { @@ -335,6 +349,8 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil); DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); + + DebugMenuAddCmd("Debug", "Make peds around you follow you", LetThemFollowYou); #ifndef FINAL DebugMenuAddVarBool8("Debug", "Toggle unused fight feature", (int8*)&CPed::bUnusedFightThingOnPlayer, nil); #endif -- cgit v1.2.3