This commit is contained in:
Fire-Head
2020-08-27 19:52:43 +03:00
parent 265b07a8d9
commit a38702a7d2
12 changed files with 592 additions and 303 deletions

View File

@ -113,7 +113,7 @@ void CBulletInfo::Update(void)
CEntity* pHitEntity;
if (CWorld::ProcessLineOfSight(vecOldPos, vecNewPos, point, pHitEntity, true, true, true, true, true, false, false, true)) {
if (pBullet->m_pSource && (pHitEntity->IsPed() || pHitEntity->IsVehicle()))
CStats::InstantHitsHitByPlayer++;
CStats::BulletsThatHit++;
CWeapon::CheckForShootingVehicleOccupant(&pHitEntity, &point, pBullet->m_eWeaponType, vecOldPos, vecNewPos);
if (pHitEntity->IsPed()) {

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,9 @@ public:
int32 m_nAmmoTotal;
uint32 m_nTimer;
bool m_bAddRotOffset;
static bool bPhotographHasBeenTaken;
CWeapon() {
m_bAddRotOffset = false;
}
@ -41,6 +43,7 @@ public:
bool FireMelee (CEntity *shooter, CVector &fireSource);
bool FireInstantHit(CEntity *shooter, CVector *fireSource);
static void AddGunFlashBigGuns(CVector start, CVector end);
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);
@ -50,13 +53,15 @@ public:
static void GenerateFlameThrowerParticles(CVector pos, CVector dir);
bool FireAreaEffect (CEntity *shooter, CVector *fireSource);
bool LaserScopeDot (CVector *pOutPos, float *pOutSize);
bool FireSniper (CEntity *shooter);
bool TakePhotograph (CEntity *shooter);
bool FireM16_1stPerson (CEntity *shooter);
bool FireInstantHitFromCar(CVehicle *shooter, bool left, bool right);
static void DoDoomAiming (CEntity *shooter, CVector *source, CVector *target);
static void DoTankDoomAiming (CEntity *shooter, CEntity *driver, CVector *source, CVector *target);
static void DoDriveByAutoAiming(CEntity *driver, CVehicle *vehicle, CVector *source, CVector *target);
static void DoDoomAiming (CEntity *shooter, CVector *source, CVector *target);
static void DoTankDoomAiming (CEntity *shooter, CEntity *driver, CVector *source, CVector *target);
static void DoDriveByAutoAiming(CEntity *driver, CVehicle *vehicle, CVector *source, CVector *target);
void Reload(void);
void Update(int32 audioEntity, CPed *pedToAdjustSound);
@ -68,14 +73,12 @@ public:
bool HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo);
static void BlowUpExplosiveThings(CEntity *thing);
bool HasWeaponAmmoToBeUsed(void);
static void AddGunFlashBigGuns(CVector, CVector);
static bool IsShotgun(int weapon) { return weapon == WEAPONTYPE_SHOTGUN || weapon == WEAPONTYPE_SPAS12_SHOTGUN || weapon == WEAPONTYPE_STUBBY_SHOTGUN; }
// TODO(Miami): Is that still used?
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 void CheckForShootingVehicleOccupant(CEntity**, CColPoint*, eWeaponType, CVector const&, CVector const&);
static void CheckForShootingVehicleOccupant(CEntity **victim, CColPoint *point, eWeaponType weapon, CVector const& source, CVector const& target);
#ifdef COMPATIBLE_SAVES
void Save(uint8*& buf);

View File

@ -3,6 +3,9 @@
#include "WeaponEffects.h"
#include "TxdStore.h"
#include "Sprite.h"
#include "PlayerPed.h"
#include "World.h"
#include "WeaponType.h"
RwTexture *gpCrossHairTex;
RwRaster *gpCrossHairRaster;
@ -24,10 +27,10 @@ CWeaponEffects::Init(void)
{
gCrossHair.m_bActive = false;
gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
gCrossHair.m_nRed = 0;
gCrossHair.m_nRed = 255;
gCrossHair.m_nGreen = 0;
gCrossHair.m_nBlue = 0;
gCrossHair.m_nAlpha = 255;
gCrossHair.m_nAlpha = 127;
gCrossHair.m_fSize = 1.0f;
gCrossHair.m_fRotation = 0.0f;
@ -46,9 +49,7 @@ void
CWeaponEffects::Shutdown(void)
{
RwTextureDestroy(gpCrossHairTex);
#ifdef GTA3_1_1_PATCH
gpCrossHairTex = nil;
#endif
}
void
@ -56,10 +57,6 @@ CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint
{
gCrossHair.m_bActive = true;
gCrossHair.m_vecPos = pos;
gCrossHair.m_nRed = red;
gCrossHair.m_nGreen = green;
gCrossHair.m_nBlue = blue;
gCrossHair.m_nAlpha = alpha;
gCrossHair.m_fSize = size;
}
@ -72,12 +69,32 @@ CWeaponEffects::ClearCrossHair(void)
void
CWeaponEffects::Render(void)
{
static float aCrossHairSize[WEAPONTYPE_TOTALWEAPONS] =
{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
0.4f, 0.4f,
0.5f,
0.3f,
0.9f, 0.9f, 0.9f,
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
0.1f, 0.1f,
1.0f,
0.6f,
0.7f,
0.0f, 0.0f
};
if ( gCrossHair.m_bActive )
{
float size = aCrossHairSize[FindPlayerPed()->GetWeapon()->m_eWeaponType];
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVDESTALPHA);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster);
RwV3d pos;
@ -85,15 +102,25 @@ CWeaponEffects::Render(void)
if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) )
{
float recipz = 1.0f / pos.z;
CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z,
gCrossHair.m_fSize * w, gCrossHair.m_fSize * h,
gCrossHair.m_nRed, gCrossHair.m_nGreen, gCrossHair.m_nBlue, 255,
recipz, 255);
CSprite::RenderOneXLUSprite_Rotate_Aspect(pos.x, pos.y, pos.z,
w, h,
255, 88, 100, 158,
recipz, gCrossHair.m_fRotation, gCrossHair.m_nAlpha);
float recipz2 = 1.0f / pos.z;
CSprite::RenderOneXLUSprite_Rotate_Aspect(pos.x, pos.y, pos.z,
size*w, size*h,
107, 134, 247, 158,
recipz2, TWOPI - gCrossHair.m_fRotation, gCrossHair.m_nAlpha);
gCrossHair.m_fRotation += 0.02f;
if ( gCrossHair.m_fRotation > TWOPI )
gCrossHair.m_fRotation = 0.0;
}
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)TRUE);
}
}

View File

@ -9,16 +9,57 @@
#include "ModelInfo.h"
#include "ModelIndices.h"
uint16 CWeaponInfo::ms_aReloadSampleTime[WEAPONTYPE_TOTALWEAPONS] =
{
0, // UNARMED
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, // GRENADE
0, // DETONATEGRENADE
0, // TEARGAS
0, // MOLOTOV
0, // ROCKET
250, // COLT45
250, // PYTHON
650, // SHOTGUN
650, // SPAS12 SHOTGUN
650, // STUBBY SHOTGUN
400, // TEC9
400, // UZIhec
400, // SILENCED_INGRAM
400, // MP5
300, // M16
300, // AK47
423, // SNIPERRIFLE
423, // LASERSCOPE
400, // ROCKETLAUNCHER
0, // FLAMETHROWER
0, // M60
0, // MINIGUN
0, // DETONATOR
0, // HELICANNON
0 // CAMERA
};
// Yeah...
int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] = {
int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1
};
CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
// --MIAMI: Todo
static char ms_aWeaponNames[][32] = {
char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] =
{
"Unarmed",
"BrassKnuckle",
"ScrewDriver",
@ -61,7 +102,7 @@ static char ms_aWeaponNames[][32] = {
CWeaponInfo*
CWeaponInfo::GetWeaponInfo(eWeaponType weaponType)
{
return &CWeaponInfo::ms_apWeaponInfos[weaponType];
return &ms_apWeaponInfos[weaponType];
}
// --MIAMI: done except WEAPONTYPE_TOTALWEAPONS value

View File

@ -8,7 +8,9 @@ enum AssocGroupId;
class CWeaponInfo {
static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
static char ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32];
public:
static uint16 ms_aReloadSampleTime[WEAPONTYPE_TOTALWEAPONS];
static int32 ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS];
eWeaponFire m_eWeaponFire;