script 800-899

This commit is contained in:
Nikolay Korolev 2020-01-03 19:48:13 +03:00
parent 42ff0f7c58
commit 0723dade76
24 changed files with 1329 additions and 132 deletions

View file

@ -953,7 +953,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
if (visibilityAngle > PI)
visibilityAngle = TWOPI - visibilityAngle;
if (visibilityAngle < HALFPI || pVehicle->m_nCarHornTimer){
/* if ped sees the danger of if car horn is on */
/* if ped sees the danger or if car horn is on */
pPed->SetFlee(pVehicle, 2000);
pPed->bUsePedNodeSeek = false;
pPed->SetMoveState(PEDMOVE_RUN);

View file

@ -4,6 +4,7 @@
#include "Vehicle.h"
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
#define METERS_PER_SECOND_TO_GAME_SPEED (1.0f / GAME_SPEED_TO_METERS_PER_SECOND)
#define GAME_SPEED_TO_CARAI_SPEED 60.0f
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500

View file

@ -6,7 +6,9 @@
#include "Timer.h"
#include "Font.h"
#include "Messages.h"
#include "PlayerPed.h"
#include "Text.h"
#include "World.h"
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
@ -25,6 +27,8 @@ bool &CGarages::PlayerInGarage = *(bool *)0x95CD83;
int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444;
uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570;
CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])(uintptr*)0x72BCD0;
WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); }
WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); }
@ -86,8 +90,27 @@ int32 CGarages::QueryCarsCollected(int16 garage)
return 0;
}
void CGarages::GivePlayerDetonator()
{
FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
FindPlayerPed()->m_weapons[FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)].m_eWeaponState = WEAPONSTATE_READY;
}
WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
WRAPPER void CGarages::ChangeGarageType(int16 garage, int8 type) { EAXJMP(0x4222A0); }
WRAPPER void CGarages::ChangeGarageType(int16 garage, eGarageType type) { EAXJMP(0x4222A0); }
WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
void CGarage::OpenThisGarage()
{
if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
m_eGarageState = GS_OPENING;
}
void CGarage::CloseThisGarage()
{
if (m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENING)
m_eGarageState = GS_CLOSING;
}
#if 0
WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }

View file

@ -1,7 +1,113 @@
#pragma once
#include "Automobile.h"
#include "audio_enums.h"
#include "config.h"
class CVehicle;
enum eGarageState : int8
{
GS_FULLYCLOSED,
GS_OPENED,
GS_CLOSING,
GS_OPENING,
GS_OPENEDCONTAINSCAR,
GS_CLOSEDCONTAINSCAR,
GS_AFTERDROPOFF,
};
enum eGarageType : int8
{
GARAGE_NONE,
GARAGE_MISSION,
GARAGE_BOMBSHOP1,
GARAGE_BOMBSHOP2,
GARAGE_BOMBSHOP3,
GARAGE_RESPRAY,
GARAGE_COLLECTORSITEMS,
GARAGE_COLLECTSPECIFICCARS,
GARAGE_COLLECTCARS_1,
GARAGE_COLLECTCARS_2,
GARAGE_COLLECTCARS_3,
GARAGE_FORCARTOCOMEOUTOF,
GARAGE_60SECONDS,
GARAGE_CRUSHER,
GARAGE_MISSION_KEEPCAR,
GARAGE_FOR_SCRIPT_TO_OPEN,
GARAGE_HIDEOUT_ONE,
GARAGE_HIDEOUT_TWO,
GARAGE_HIDEOUT_THREE,
GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE,
GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR,
GARAGE_MISSION_KEEPCAR_REMAINCLOSED,
};
class CStoredCar
{
int32 m_nModelIndex;
CVector m_vecPos;
CVector m_vecAngle;
int32 m_bBulletproof : 1;
int32 m_bFireproof : 1;
int32 m_bExplosionproof : 1;
int32 m_bCollisionproof : 1;
int32 m_bMeleeproof : 1;
int8 m_nPrimaryColor;
int8 m_nSecondaryColor;
int8 m_nRadioStation;
int8 m_nVariationA;
int8 m_nVariationB;
int8 m_nCarBombType;
};
static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
class CGarage
{
eGarageType m_eGarageType;
eGarageState m_eGarageState;
char field_2;
char m_bClosingWithoutTargetCar;
char m_bDeactivated;
char m_bResprayHappened;
char field_6;
char field_7;
int m_nTargetModelIndex;
CEntity *m_pDoor1;
CEntity *m_pDoor2;
char m_bDoor1PoolIndex;
char m_bDoor2PoolIndex;
char m_bIsDoor1Object;
char m_bIsDoor2Object;
char field_24;
char m_bRotatedDoor;
char m_bCameraFollowsPlayer;
char field_27;
CVector m_vecInf;
CVector m_vecSup;
float m_fDoorPos;
float m_fDoorHeight;
float m_fDoor1X;
float m_fDoor1Y;
float m_fDoor2X;
float m_fDoor2Y;
float m_fDoor1Z;
float m_fDoor2Z;
int m_nDoorOpenTime;
char m_bCollectedCarsState;
char field_89;
char field_90;
char field_91;
CVehicle *m_pTarget;
int field_96;
CStoredCar m_sStoredCar;
public:
void OpenThisGarage();
void CloseThisGarage();
};
static_assert(sizeof(CGarage) == 140, "CGarage");
class CGarages
{
public:
@ -21,6 +127,7 @@ public:
static bool &PlayerInGarage;
static int32 &PoliceCarsCollected;
static uint32 &GarageToBeTidied;
static CGarage(&Garages)[NUM_GARAGES];
public:
static bool IsModelIndexADoor(uint32 id);
@ -39,5 +146,7 @@ public:
static void DeActivateGarage(int16);
static int32 QueryCarsCollected(int16);
static bool HasThisCarBeenCollected(int16, uint8);
static void ChangeGarageType(int16, int8); //TODO: eGarageType
static void ChangeGarageType(int16, eGarageType);
static bool HasResprayHappened(int16);
static void GivePlayerDetonator();
};

View file

@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "Game.h"
#include "General.h"
#include "World.h"
#include "Entity.h"
#include "Population.h"
@ -79,6 +80,12 @@ CPopulation::RemovePed(CEntity* ent)
delete ent;
}
int32
CPopulation::ChooseCivilianOccupation(int32 group)
{
return ms_pPedGroups[group].models[CGeneral::GetRandomNumberInRange(0, 8)];
}
STARTPATCHES
InjectHook(0x4F3770, CPopulation::Initialise, PATCH_JUMP);
ENDPATCHES

View file

@ -47,4 +47,5 @@ public:
static CPed *AddPedInCar(CVehicle *vehicle);
static bool IsPointInSafeZone(CVector *coors);
static void RemovePed(CEntity* ent);
static int32 ChooseCivilianOccupation(int32);
};

View file

@ -10,4 +10,6 @@ WRAPPER void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0
WRAPPER void CRecordDataForChase::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0x4347F0); }
WRAPPER void CRecordDataForChase::ProcessControlCars(void) { EAXJMP(0x435540); }
WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); }
WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); }
WRAPPER void CRecordDataForChase::StartChaseScene(float) { EAXJMP(0x435690); }
WRAPPER void CRecordDataForChase::CleanUpChaseScene() { EAXJMP(0x4357C0); }

View file

@ -14,6 +14,8 @@ public:
static void SaveOrRetrieveDataForThisFrame(void);
static void ProcessControlCars(void);
static void SaveOrRetrieveCarPositions(void);
static void StartChaseScene(float);
static void CleanUpChaseScene();
};

File diff suppressed because it is too large Load diff

View file

@ -114,6 +114,8 @@ public:
}
}
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
@ -374,6 +376,7 @@ public:
static void HighlightImportantArea(uint32, float, float, float, float, float);
static void DrawDebugSquare(float, float, float, float);
static void DrawDebugCube(float, float, float, float, float, float);
static void AddToInvisibilitySwapArray(CEntity*, bool);
static int32 Read4BytesFromScript(uint32* pIp){
int32 retval = 0;

View file

@ -33,6 +33,8 @@ WRAPPER void CCamera::LoadPathSplines(int file) { EAXJMP(0x46D1D0); }
WRAPPER uint32 CCamera::GetCutSceneFinishTime(void) { EAXJMP(0x46B920); }
WRAPPER void CCamera::FinishCutscene(void) { EAXJMP(0x46B560); }
WRAPPER void CCamera::RestoreWithJumpCut(void) { EAXJMP(0x46FAE0); };
WRAPPER void CCamera::SetZoomValueFollowPedScript(int16) { EAXJMP(0x46FF30); }
WRAPPER void CCamera::SetZoomValueCamStringScript(int16) { EAXJMP(0x46FF90); }
bool
CCamera::GetFading()
@ -1357,6 +1359,14 @@ void CCamera::SetCameraDirectlyInFrontForFollowPed_CamOnAString()
m_PedOrientForBehindOrInFront = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y);
}
void CCamera::SetCameraDirectlyBehindForFollowPed_CamOnAString()
{
m_bCamDirectlyBehind = true;
CPlayerPed *player = FindPlayerPed();
if (player)
m_PedOrientForBehindOrInFront = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y);
}
void
CCamera::SetWideScreenOn(void)
{

View file

@ -491,6 +491,9 @@ int m_iModeObbeCamIsInForCar;
void TakeControlWithSpline(short);
void RestoreWithJumpCut(void);
void SetCameraDirectlyInFrontForFollowPed_CamOnAString(void);
void SetCameraDirectlyBehindForFollowPed_CamOnAString(void);
void SetZoomValueFollowPedScript(int16);
void SetZoomValueCamStringScript(int16);
void dtor(void) { this->CCamera::~CCamera(); }
};

View file

@ -4,6 +4,7 @@
WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); }
WRAPPER void CExplosion::RemoveAllExplosionsInArea(CVector, float) { EAXJMP(0x55AD40); }
WRAPPER bool CExplosion::TestForExplosionInArea(eExplosionType, float, float, float, float, float, float) { EAXJMP(0x55AC80); }
WRAPPER
int8 CExplosion::GetExplosionActiveCounter(uint8 id)

View file

@ -28,4 +28,5 @@ public:
static uint8 GetExplosionType(uint8 id);
static void ResetExplosionActiveCounter(uint8 id);
static void RemoveAllExplosionsInArea(CVector, float);
static bool TestForExplosionInArea(eExplosionType, float, float, float, float, float, float);
};

View file

@ -5,6 +5,7 @@ int32 &CStats::DaysPassed = *(int32*)0x8F2BB8;
int32 &CStats::HeadsPopped = *(int32*)0x8F647C;
bool& CStats::CommercialPassed = *(bool*)0x8F4334;
bool& CStats::IndustrialPassed = *(bool*)0x8E2A68;
bool& CStats::SuburbanPassed = *(bool*)0x8F2740;
int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C;
int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50;
int32 &CStats::HelisDestroyed = *(int32*)0x8E2A64;

View file

@ -7,6 +7,7 @@ public:
static int32 &HeadsPopped;
static bool& CommercialPassed;
static bool& IndustrialPassed;
static bool& SuburbanPassed;
static int32 &NumberKillFrenziesPassed;
static int32 &PeopleKilledByOthers;
static int32 &HelisDestroyed;

View file

@ -44,6 +44,10 @@ WRAPPER void CWorld::RemoveStaticObjects() { EAXJMP(0x4B4D50); }
WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); }
WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); }
WRAPPER void CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8) { EAXJMP(0x4B4E70) };
WRAPPER void CWorld::FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B2E70); }
WRAPPER void CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B3280); }
WRAPPER void CWorld::FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool) { EAXJMP(0x4B2600); }
WRAPPER void CWorld::FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**) { EAXJMP(0x4B2960); }
void
CWorld::Initialise()
@ -960,7 +964,7 @@ CWorld::RemoveFallenPeds(void)
for(int poolIndex = poolSize-1; poolIndex >= 0; poolIndex--) {
CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped) {
if (ped->GetPosition().z < -100.0f) {
if (ped->GetPosition().z < MAP_Z_LOW_LIMIT) {
if (ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) {
int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED, 999999.9f, false, false);
CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
@ -982,7 +986,7 @@ CWorld::RemoveFallenCars(void)
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh) {
if (veh->GetPosition().z < -100.0f) {
if (veh->GetPosition().z < MAP_Z_LOW_LIMIT) {
if (veh->VehicleCreatedBy == MISSION_VEHICLE || veh == FindPlayerVehicle() || (veh->pDriver && veh->pDriver->IsPlayer())) {
int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR, 999999.9f, false, false);
CVector newPos = ThePaths.m_pathNodes[closestNode].pos;

View file

@ -22,6 +22,8 @@
#define WORLD_MAX_X (WORLD_MIN_X + WORLD_SIZE_X)
#define WORLD_MAX_Y (WORLD_MIN_Y + WORLD_SIZE_Y)
#define MAP_Z_LOW_LIMIT -100.0f
enum
{
ENTITYLIST_BUILDINGS,
@ -103,11 +105,15 @@ public:
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 void FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**);
static void FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
static float FindGroundZForCoord(float x, float y);
static float FindGroundZFor3DCoord(float x, float y, float z, bool *found);
static float FindRoofZFor3DCoord(float x, float y, float z, bool *found);
static void RemoveReferencesToDeletedObject(CEntity*);
static void FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool);
static void FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool);
static void FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool);
static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); }
static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); }

View file

@ -85,6 +85,7 @@ enum Config {
NUM_ACCIDENTS = 20,
NUM_FIRES = 40,
NUM_GARAGES = 32,
NUMPEDROUTES = 200,
NUMPHONES = 50,

View file

@ -340,7 +340,7 @@ public:
uint8 bWanderPathAfterExitingCar : 1;
uint8 bIsLeader : 1;
uint8 bDontDragMeOutCar : 1;
uint8 bDontDragMeOutCar : 1; // unfinished feature
uint8 m_ped_flagF8 : 1;
uint8 bWillBeQuickJacked : 1;
uint8 bCancelEnteringCar : 1; // after door is opened or couldn't be opened due to it's locked

View file

@ -7,6 +7,7 @@
#include "World.h"
#include "RpAnimBlend.h"
#include "General.h"
#include "Pools.h"
CPlayerPed::~CPlayerPed()
{
@ -73,6 +74,17 @@ CPlayerPed::SetWantedLevelNoDrop(int32 level)
m_pWanted->SetWantedLevelNoDrop(level);
}
void
CPlayerPed::MakeObjectTargettable(int32 handle)
{
for (int i = 0; i < ARRAY_SIZE(m_nTargettableObjects); i++) {
if (CPools::GetObjectPool()->GetAt(m_nTargettableObjects[i]) == nil) {
m_nTargettableObjects[i] = handle;
return;
}
}
}
// I don't know the actual purpose of parameter
void
CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)

View file

@ -56,6 +56,7 @@ public:
void UseSprintEnergy(void);
class CPlayerInfo *GetPlayerInfoForThisPlayerPed();
void SetRealMoveAnim(void);
void MakeObjectTargettable(int32);
static void SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32);

View file

@ -0,0 +1,5 @@
#include "common.h"
#include "patcher.h"
#include "BulletInfo.h"
WRAPPER bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2) { EAXJMP(0x558D40); }

7
src/weapons/BulletInfo.h Normal file
View file

@ -0,0 +1,7 @@
#pragma once
class CBulletInfo
{
public:
static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2);
};