CWeapon done, ps2 cheats fix

This commit is contained in:
Fire-Head 2020-04-15 08:03:53 +03:00
parent 6473778c47
commit daed13485e
22 changed files with 2331 additions and 60 deletions

View File

@ -117,7 +117,7 @@ enum eScriptSounds : int16
SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106, SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106,
SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107, SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107,
SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108, SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108,
SCRIPT_SOUND_109 = 109, SCRIPT_SOUND_BULLET_HIT_WATER = 109, //no sound
SCRIPT_SOUND_110 = 110, SCRIPT_SOUND_110 = 110,
SCRIPT_SOUND_111 = 111, SCRIPT_SOUND_111 = 111,
SCRIPT_SOUND_PAYPHONE_RINGING = 112, SCRIPT_SOUND_PAYPHONE_RINGING = 112,

View File

@ -35,7 +35,7 @@ void CAutoPilot::ModifySpeed(float speed)
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(uint32)(positionBetweenNodes * m_nTimeToSpendOnCurrentCurve); (uint32)(positionBetweenNodes * m_nTimeToSpendOnCurrentCurve);
#else #else
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nSpeedScaleFactor; m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nTimeToSpendOnCurrentCurve;
#endif #endif
} }

View File

@ -426,7 +426,7 @@ CCarCtrl::GenerateOneRandomCar()
(uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve); (uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
#else #else
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nSpeedScaleFactor; (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
#endif #endif
CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f); CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f);
CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f); CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f);

View File

@ -1082,7 +1082,7 @@ void CGarage::Update()
#ifdef FIX_BUGS #ifdef FIX_BUGS
bool bCreatedAllCars = false; bool bCreatedAllCars = false;
#else #else
bool bCraetedAllCars; bool bCreatedAllCars;
#endif #endif
switch (m_eGarageType) { switch (m_eGarageType) {
case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break; case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break;

View File

@ -90,6 +90,11 @@ public:
return -Atan2(x / y, 1.0f); return -Atan2(x / y, 1.0f);
} }
} }
static float GetAngleBetweenPoints(float x1, float y1, float x2, float y2)
{
return RADTODEG(GetRadianAngleBetweenPoints(x1, y1, x2, y2));
}
// should return direction in 0-8 range. fits perfectly to peds' path directions. // should return direction in 0-8 range. fits perfectly to peds' path directions.
static int GetNodeHeadingFromVector(float x, float y) static int GetNodeHeadingFromVector(float x, float y)

View File

@ -642,6 +642,8 @@ void CPad::AddToCheatString(char c)
{ {
for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- ) for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- )
CheatString[i + 1] = CheatString[i]; CheatString[i + 1] = CheatString[i];
CheatString[0] = c;
#define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1) #define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1)
// "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP // "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP

View File

@ -58,6 +58,7 @@ WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float)
WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); }
WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); } WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); }
WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); }
WRAPPER void CWorld::UseDetonator(CEntity *) { EAXJMP(0x4B4650); }
void void
CWorld::Initialise() CWorld::Initialise()

View File

@ -142,6 +142,8 @@ public:
static void RemoveStaticObjects(); static void RemoveStaticObjects();
static void Process(); static void Process();
static void TriggerExplosion(const CVector &, float, float, CEntity*, bool); static void TriggerExplosion(const CVector &, float, float, CEntity*, bool);
static void UseDetonator(CEntity *);
}; };
extern CColPoint *gaTempSphereColPoints; extern CColPoint *gaTempSphereColPoints;

View File

@ -1557,8 +1557,9 @@ void SystemInit()
// //
#endif #endif
#ifdef GTA_PS2_STUFF
CPad::Initialise(); CPad::Initialise();
#endif
CPad::GetPad(0)->Mode = 0; CPad::GetPad(0)->Mode = 0;
CGame::frenchGame = false; CGame::frenchGame = false;

View File

@ -612,7 +612,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){ if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true); CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else if(B->IsObject() && model != MI_EXPLODINGBARREL && model != MI_PETROLPUMP) }else if(B->IsObject() && !IsExplosiveThingModel(model))
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else{ }else{
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))

View File

@ -46,6 +46,13 @@ public:
y *= invsqrt; y *= invsqrt;
z *= invsqrt; z *= invsqrt;
} }
void Normalise2D(void) {
float sq = MagnitudeSqr2D();
float invsqrt = RecipSqrt(sq);
x *= invsqrt;
y *= invsqrt;
}
const CVector &operator+=(CVector const &right) { const CVector &operator+=(CVector const &right) {
x += right.x; x += right.x;

View File

@ -13,13 +13,14 @@ public:
void Normalise(void){ void Normalise(void){
float sq = MagnitudeSqr(); float sq = MagnitudeSqr();
if(sq > 0.0f){ //if(sq > 0.0f){
float invsqrt = RecipSqrt(sq); float invsqrt = RecipSqrt(sq);
x *= invsqrt; x *= invsqrt;
y *= invsqrt; y *= invsqrt;
}else //}else
x = 1.0f; // x = 1.0f;
} }
const CVector2D &operator+=(CVector2D const &right) { const CVector2D &operator+=(CVector2D const &right) {
x += right.x; x += right.x;
y += right.y; y += right.y;

View File

@ -490,3 +490,10 @@ IsPoliceVehicleModel(int16 id)
id == MI_POLICE || id == MI_POLICE ||
id == MI_ENFORCER; id == MI_ENFORCER;
} }
inline bool
IsExplosiveThingModel(int16 id)
{
return id == MI_EXPLODINGBARREL ||
id == MI_PETROLPUMP;
}

View File

@ -1231,7 +1231,7 @@ CPed::Attack(void)
weaponAnimAssoc->SetCurrentTime(0.0f); weaponAnimAssoc->SetCurrentTime(0.0f);
if (IsPlayer()) { if (IsPlayer()) {
((CPlayerPed*)this)->field_1376 = 0.0f; ((CPlayerPed*)this)->m_fAttackButtonCounter = 0.0f;
((CPlayerPed*)this)->m_bHaveTargetSelected = false; ((CPlayerPed*)this)->m_bHaveTargetSelected = false;
} }
} }

View File

@ -796,7 +796,12 @@ public:
PedState GetPedState(void) { return m_nPedState; } PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; } void SetPedState(PedState state) { m_nPedState = state; }
bool Dead(void) { return m_nPedState == PED_DEAD; }
bool Dying(void) { return m_nPedState == PED_DIE; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool Driving(void) { return m_nPedState == PED_DRIVING; }
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.
bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; } bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; }

View File

@ -43,8 +43,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_fStaminaProgress = 0.0f; m_fStaminaProgress = 0.0f;
m_nEvadeAmount = 0; m_nEvadeAmount = 0;
field_1367 = 0; field_1367 = 0;
m_nShotDelay = 0; m_nHitAnimDelayTimer = 0;
field_1376 = 0.0f; m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false; m_bHaveTargetSelected = false;
m_bHasLockOnTarget = false; m_bHasLockOnTarget = false;
m_bCanBeDamaged = true; m_bCanBeDamaged = true;
@ -1024,10 +1024,10 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (padUsed->WeaponJustDown()) { if (padUsed->WeaponJustDown()) {
m_bHaveTargetSelected = true; m_bHaveTargetSelected = true;
} else if (!m_bHaveTargetSelected) { } else if (!m_bHaveTargetSelected) {
field_1376 += CTimer::GetTimeStepNonClipped(); m_fAttackButtonCounter += CTimer::GetTimeStepNonClipped();
} }
} else { } else {
field_1376 = 0.0f; m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false; m_bHaveTargetSelected = false;
} }
SetAttack(nil); SetAttack(nil);

View File

@ -20,8 +20,8 @@ public:
uint8 m_nEvadeAmount; uint8 m_nEvadeAmount;
int8 field_1367; int8 field_1367;
uint32 m_nSpeedTimer; uint32 m_nSpeedTimer;
int32 m_nShotDelay; uint32 m_nHitAnimDelayTimer;
float field_1376; // m_fAttackButtonCounter? float m_fAttackButtonCounter; // m_fAttackButtonCounter?
bool m_bHaveTargetSelected; // may have better name bool m_bHaveTargetSelected; // may have better name
int8 field_1381; int8 field_1381;
int8 field_1382; int8 field_1382;

View File

@ -404,6 +404,7 @@ CGlass::AskForObjectToBeRenderedInGlass(CEntity *entity)
void void
CGlass::RenderEntityInGlass(CEntity *entity) CGlass::RenderEntityInGlass(CEntity *entity)
{ {
ASSERT(entity!=NULL);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( object->bGlassBroken ) if ( object->bGlassBroken )
@ -419,7 +420,7 @@ CGlass::RenderEntityInGlass(CEntity *entity)
uint8 alpha = CalcAlphaWithNormal(&fwdNorm); uint8 alpha = CalcAlphaWithNormal(&fwdNorm);
CColModel *col = object->GetColModel(); CColModel *col = object->GetColModel();
ASSERT(col!=NULL);
if ( col->numTriangles >= 2 ) if ( col->numTriangles >= 2 )
{ {
CVector a = object->GetMatrix() * col->vertices[0]; CVector a = object->GetMatrix() * col->vertices[0];
@ -523,6 +524,8 @@ CGlass::RenderEntityInGlass(CEntity *entity)
int32 int32
CGlass::CalcAlphaWithNormal(CVector *normal) CGlass::CalcAlphaWithNormal(CVector *normal)
{ {
ASSERT(normal!=NULL);
float fwdDir = 2.0f * DotProduct(*normal, TheCamera.GetForward()); float fwdDir = 2.0f * DotProduct(*normal, TheCamera.GetForward());
float fwdDot = DotProduct(TheCamera.GetForward()-fwdDir*(*normal), CVector(0.57f, 0.57f, -0.57f)); float fwdDot = DotProduct(TheCamera.GetForward()-fwdDir*(*normal), CVector(0.57f, 0.57f, -0.57f));
return int32(lerp(fwdDot*fwdDot*fwdDot*fwdDot*fwdDot*fwdDot, 20.0f, 255.0f)); return int32(lerp(fwdDot*fwdDot*fwdDot*fwdDot*fwdDot*fwdDot, 20.0f, 255.0f));
@ -597,6 +600,8 @@ CGlass::RenderReflectionPolys(void)
void void
CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion) CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion)
{ {
ASSERT(entity!=NULL);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( object->bGlassBroken ) if ( object->bGlassBroken )
@ -605,7 +610,8 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
object->bGlassCracked = true; object->bGlassCracked = true;
CColModel *col = object->GetColModel(); CColModel *col = object->GetColModel();
ASSERT(col!=NULL);
CVector a = object->GetMatrix() * col->vertices[0]; CVector a = object->GetMatrix() * col->vertices[0];
CVector b = object->GetMatrix() * col->vertices[1]; CVector b = object->GetMatrix() * col->vertices[1];
CVector c = object->GetMatrix() * col->vertices[2]; CVector c = object->GetMatrix() * col->vertices[2];
@ -647,6 +653,8 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
void void
CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount) CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount)
{ {
ASSERT(entity!=NULL);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( amount > 50.0f && !object->bGlassCracked ) if ( amount > 50.0f && !object->bGlassCracked )
@ -659,6 +667,8 @@ CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount)
void void
CGlass::WasGlassHitByBullet(CEntity *entity, CVector point) CGlass::WasGlassHitByBullet(CEntity *entity, CVector point)
{ {
ASSERT(entity!=NULL);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( IsGlass(object->GetModelIndex()) ) if ( IsGlass(object->GetModelIndex()) )
@ -679,6 +689,8 @@ CGlass::WasGlassHitByBullet(CEntity *entity, CVector point)
void void
CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point) CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point)
{ {
ASSERT(entity!=NULL);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
CVector distToGlass = object->GetPosition() - point; CVector distToGlass = object->GetPosition() - point;

View File

@ -2,4 +2,8 @@
#include "patcher.h" #include "patcher.h"
#include "BulletInfo.h" #include "BulletInfo.h"
WRAPPER void CBulletInfo::Initialise(void) { EAXJMP(0x558220); }
WRAPPER void CBulletInfo::Shutdown(void) { EAXJMP(0x558450); }
WRAPPER void CBulletInfo::AddBullet(CEntity *firingEntity, eWeaponType type, CVector pos, CVector velocity) { EAXJMP(0x558470); }
WRAPPER void CBulletInfo::Update(void) { EAXJMP(0x558550); }
WRAPPER bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2) { EAXJMP(0x558D40); } WRAPPER bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2) { EAXJMP(0x558D40); }

View File

@ -1,7 +1,14 @@
#pragma once #pragma once
class CEntity;
enum eWeaponType;
class CBulletInfo class CBulletInfo
{ {
public: public:
static void Initialise(void);
static void Shutdown(void);
static void AddBullet(CEntity *firingEntity, eWeaponType type, CVector pos, CVector velocity);
static void Update(void);
static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2); static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#define DRIVEBYAUTOAIMING_MAXDIST (2.5f)
#define DOOMAUTOAIMING_MAXDIST (9000.0f)
enum eWeaponType enum eWeaponType
{ {
WEAPONTYPE_UNARMED, WEAPONTYPE_UNARMED,
@ -49,7 +52,10 @@ enum eWeaponState
}; };
class CEntity; class CEntity;
class CPhysical;
class CAutomobile; class CAutomobile;
struct CColPoint;
class CWeaponInfo;
class CWeapon class CWeapon
{ {
@ -64,22 +70,50 @@ public:
CWeapon() { CWeapon() {
m_bAddRotOffset = false; m_bAddRotOffset = false;
} }
CWeaponInfo *GetInfo();
static void ShutdownWeapons(void);
void Initialise(eWeaponType type, int ammo);
void Update(int32 audioEntity);
void Reload(void);
bool Fire(CEntity*, CVector*);
void FireFromCar(CAutomobile *car, bool left);
void AddGunshell(CEntity*, CVector const&, CVector2D const&, float);
bool IsTypeMelee(void);
bool IsType2Handed(void);
static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end);
bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo);
bool HasWeaponAmmoToBeUsed(void);
static void InitialiseWeapons(void); static void InitialiseWeapons(void);
static void UpdateWeapons(void); static void ShutdownWeapons (void);
static void UpdateWeapons (void);
void Initialise(eWeaponType type, int32 ammo);
bool Fire (CEntity *shooter, CVector *fireSource);
bool FireFromCar (CAutomobile *shooter, bool left);
bool FireMelee (CEntity *shooter, CVector &fireSource);
bool FireInstantHit(CEntity *shooter, CVector *fireSource);
void AddGunshell (CEntity *shooter, CVector const &source, CVector2D const &direction, float size);
void DoBulletImpact(CEntity *shooter, CEntity *victim, CVector *source, CVector *target, CColPoint *point, CVector2D ahead);
bool FireShotgun (CEntity *shooter, CVector *fireSource);
bool FireProjectile(CEntity *shooter, CVector *fireSource, float power);
static void GenerateFlameThrowerParticles(CVector pos, CVector dir);
bool FireAreaEffect (CEntity *shooter, CVector *fireSource);
bool FireSniper (CEntity *shooter);
bool FireM16_1stPerson (CEntity *shooter);
bool FireInstantHitFromCar(CAutomobile *shooter, bool left);
static void DoDoomAiming (CEntity *shooter, CVector *source, CVector *target);
static void DoTankDoomAiming (CEntity *shooter, CEntity *driver, CVector *source, CVector *target);
static void DoDriveByAutoAiming(CEntity *shooter, CVector *source, CVector *target);
void Reload(void);
void Update(int32 audioEntity);
bool IsTypeMelee (void);
bool IsType2Handed(void);
static void MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target);
bool HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo);
static void BlowUpExplosiveThings(CEntity *thing);
bool HasWeaponAmmoToBeUsed(void);
static bool ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects);
}; };
static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error"); VALIDATE_SIZE(CWeapon, 0x18);
void FireOneInstantHitRound(CVector* shotSource, CVector* shotTarget, int32 damage); void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage);