2019-05-29 16:06:33 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-05-29 16:06:33 +00:00
|
|
|
#include "Weapon.h"
|
2020-04-15 05:03:53 +00:00
|
|
|
#include "AnimBlendAssociation.h"
|
|
|
|
#include "AudioManager.h"
|
|
|
|
#include "BulletInfo.h"
|
|
|
|
#include "Camera.h"
|
|
|
|
#include "Coronas.h"
|
|
|
|
#include "DMAudio.h"
|
|
|
|
#include "Explosion.h"
|
|
|
|
#include "General.h"
|
|
|
|
#include "Glass.h"
|
|
|
|
#include "Heli.h"
|
|
|
|
#include "ModelIndices.h"
|
|
|
|
#include "Object.h"
|
|
|
|
#include "Pad.h"
|
|
|
|
#include "Particle.h"
|
|
|
|
#include "Ped.h"
|
|
|
|
#include "PointLights.h"
|
|
|
|
#include "Pools.h"
|
|
|
|
#include "ProjectileInfo.h"
|
|
|
|
#include "RpAnimBlend.h"
|
|
|
|
#include "ShotInfo.h"
|
|
|
|
#include "SpecialFX.h"
|
|
|
|
#include "Stats.h"
|
|
|
|
#include "TempColModels.h"
|
2019-06-30 21:50:40 +00:00
|
|
|
#include "Timer.h"
|
2020-06-02 21:35:20 +00:00
|
|
|
#include "Automobile.h"
|
|
|
|
#include "Boat.h"
|
2020-04-15 05:03:53 +00:00
|
|
|
#include "WaterLevel.h"
|
2019-06-30 21:50:40 +00:00
|
|
|
#include "WeaponInfo.h"
|
2019-07-25 15:06:24 +00:00
|
|
|
#include "World.h"
|
2020-05-23 13:53:20 +00:00
|
|
|
#include "SurfaceTable.h"
|
2020-06-06 14:19:36 +00:00
|
|
|
#include "Bike.h"
|
2020-08-27 16:52:43 +00:00
|
|
|
#include "Glass.h"
|
|
|
|
#include "Sprite.h"
|
|
|
|
#include "Pickups.h"
|
2019-05-29 16:06:33 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
float fReloadAnimSampleFraction[5] = { 0.5f, 0.7f, 0.75f, 0.75f, 0.7f };
|
|
|
|
float fSeaSparrowAimingAngle = 10.0f;
|
|
|
|
float fHunterAimingAngle = 30.0f;
|
|
|
|
float fPlayerAimScaleDist = 5.0f;
|
|
|
|
float fPlayerAimScale = 2.5f;
|
|
|
|
|
|
|
|
bool CWeapon::bPhotographHasBeenTaken;
|
2020-04-15 05:03:53 +00:00
|
|
|
|
2021-01-14 22:16:42 +00:00
|
|
|
#ifdef SECUROM
|
|
|
|
int32 sniperPirateCheck = 0x00797743; // 'Cwy\0' ???
|
|
|
|
#endif
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *
|
|
|
|
CWeapon::GetInfo()
|
|
|
|
{
|
|
|
|
CWeaponInfo *info = CWeaponInfo::GetWeaponInfo(m_eWeaponType);
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(info!=nil);
|
2020-04-15 05:03:53 +00:00
|
|
|
return info;
|
|
|
|
}
|
2019-06-30 21:50:40 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWeapon::CWeapon(eWeaponType type, int32 ammo)
|
|
|
|
{
|
|
|
|
m_eWeaponType = type;
|
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
m_nAmmoTotal = Min(ammo, 99999);
|
|
|
|
m_nAmmoInClip = 0;
|
|
|
|
Reload();
|
|
|
|
m_nTimer = 0;
|
|
|
|
m_bAddRotOffset = false;
|
|
|
|
}
|
|
|
|
|
2019-06-30 21:50:40 +00:00
|
|
|
void
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeapon::InitialiseWeapons(void)
|
|
|
|
{
|
|
|
|
CWeaponInfo::Initialise();
|
|
|
|
CShotInfo::Initialise();
|
|
|
|
CExplosion::Initialise();
|
|
|
|
CProjectileInfo::Initialise();
|
|
|
|
CBulletInfo::Initialise();
|
2020-08-27 16:52:43 +00:00
|
|
|
bPhotographHasBeenTaken = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::ShutdownWeapons(void)
|
|
|
|
{
|
|
|
|
CWeaponInfo::Shutdown();
|
|
|
|
CShotInfo::Shutdown();
|
|
|
|
CExplosion::Shutdown();
|
|
|
|
CProjectileInfo::Shutdown();
|
|
|
|
CBulletInfo::Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::UpdateWeapons(void)
|
|
|
|
{
|
|
|
|
CShotInfo::Update();
|
|
|
|
CExplosion::Update();
|
|
|
|
CProjectileInfo::Update();
|
|
|
|
CBulletInfo::Update();
|
|
|
|
}
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
|
|
|
CWeapon::Initialise(eWeaponType type, int32 ammo)
|
2019-06-30 21:50:40 +00:00
|
|
|
{
|
|
|
|
m_eWeaponType = type;
|
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
2020-05-17 17:36:48 +00:00
|
|
|
m_nAmmoTotal = Min(ammo, 99999);
|
2019-06-30 21:50:40 +00:00
|
|
|
m_nAmmoInClip = 0;
|
|
|
|
Reload();
|
|
|
|
m_nTimer = 0;
|
2020-08-27 16:52:43 +00:00
|
|
|
int32 modelId = CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_nModelId;
|
|
|
|
int32 model2Id = CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_nModel2Id;
|
|
|
|
|
|
|
|
if ( modelId != -1 )
|
2020-05-15 14:30:25 +00:00
|
|
|
CModelInfo::GetModelInfo(modelId)->AddRef();
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( model2Id != -1 )
|
2020-05-15 14:30:25 +00:00
|
|
|
CModelInfo::GetModelInfo(model2Id)->AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::Shutdown()
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
int32 modelId = CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_nModelId;
|
2020-05-15 14:30:25 +00:00
|
|
|
if (modelId != -1)
|
|
|
|
CModelInfo::GetModelInfo(modelId)->RemoveRef();
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
int32 model2Id = CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_nModel2Id;
|
2020-05-15 14:30:25 +00:00
|
|
|
if (model2Id != -1)
|
|
|
|
CModelInfo::GetModelInfo(model2Id)->RemoveRef();
|
|
|
|
|
|
|
|
m_eWeaponType = WEAPONTYPE_UNARMED;
|
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
m_nAmmoInClip = 0;
|
|
|
|
m_nAmmoTotal = 0;
|
|
|
|
m_nTimer = 0;
|
2019-06-30 21:50:40 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
bool
|
|
|
|
CWeapon::Fire(CEntity *shooter, CVector *fireSource)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector fireOffset(0.0f, 0.0f, 0.6f);
|
|
|
|
CVector *source = fireSource;
|
2020-08-27 16:52:43 +00:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
static CVector shooterSource;
|
|
|
|
#else
|
|
|
|
CVector shooterSource;
|
|
|
|
#endif
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( !fireSource )
|
|
|
|
{
|
|
|
|
shooterSource = shooter->GetMatrix() * fireOffset;
|
|
|
|
source = &shooterSource;
|
2020-04-19 16:34:08 +00:00
|
|
|
}
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_bAddRotOffset )
|
|
|
|
{
|
|
|
|
float heading = RADTODEG(shooter->GetForward().Heading());
|
|
|
|
float angle = DEGTORAD(heading);
|
|
|
|
(*source).x += -Sin(angle) * 0.15f;
|
|
|
|
(*source).y += Cos(angle) * 0.15f;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_eWeaponState != WEAPONSTATE_READY && m_eWeaponState != WEAPONSTATE_FIRING )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool fired;
|
2020-05-19 14:39:19 +00:00
|
|
|
bool addFireRateAsDelay = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE )
|
|
|
|
{
|
2020-06-20 14:30:28 +00:00
|
|
|
if (m_nAmmoInClip <= 0) {
|
|
|
|
if (m_nAmmoTotal <= 0 || m_eWeaponState == WEAPONSTATE_RELOADING)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Reload();
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
switch ( m_eWeaponType )
|
|
|
|
{
|
|
|
|
case WEAPONTYPE_SHOTGUN:
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_SPAS12_SHOTGUN:
|
|
|
|
case WEAPONTYPE_STUBBY_SHOTGUN:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
addFireRateAsDelay = true;
|
2020-04-15 05:03:53 +00:00
|
|
|
fired = FireShotgun(shooter, source);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
case WEAPONTYPE_SNIPERRIFLE:
|
|
|
|
case WEAPONTYPE_LASERSCOPE:
|
|
|
|
{
|
|
|
|
if (shooter == FindPlayerPed())
|
|
|
|
fired = FireSniper(shooter);
|
|
|
|
else
|
|
|
|
fired = FireInstantHit(shooter, source);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_COLT45:
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_PYTHON:
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_UZI:
|
2020-05-15 14:30:25 +00:00
|
|
|
case WEAPONTYPE_TEC9:
|
|
|
|
case WEAPONTYPE_SILENCED_INGRAM:
|
|
|
|
case WEAPONTYPE_MP5:
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_M4:
|
|
|
|
case WEAPONTYPE_RUGER:
|
|
|
|
case WEAPONTYPE_M60:
|
|
|
|
case WEAPONTYPE_MINIGUN:
|
2020-05-15 14:30:25 +00:00
|
|
|
case WEAPONTYPE_HELICANNON:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-15 14:30:25 +00:00
|
|
|
if ((TheCamera.PlayerWeaponMode.Mode == CCam::MODE_HELICANNON_1STPERSON || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON)
|
2020-05-19 14:39:19 +00:00
|
|
|
&& shooter == FindPlayerPed()) {
|
2020-06-20 14:30:28 +00:00
|
|
|
addFireRateAsDelay = true;
|
2020-05-15 14:30:25 +00:00
|
|
|
fired = FireM16_1stPerson(shooter);
|
2020-05-19 14:39:19 +00:00
|
|
|
} else {
|
2020-06-20 14:30:28 +00:00
|
|
|
addFireRateAsDelay = false;
|
2020-05-15 14:30:25 +00:00
|
|
|
fired = FireInstantHit(shooter, source);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_ROCKETLAUNCHER:
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
if ( shooter->IsPed() && ((CPed*)shooter)->m_pSeekTarget != nil )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
float distToTarget = (shooter->GetPosition() - ((CPed*)shooter)->m_pSeekTarget->GetPosition()).Magnitude();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( distToTarget > 8.0f || ((CPed*)shooter)->IsPlayer() )
|
|
|
|
fired = FireProjectile(shooter, source, 0.0f);
|
|
|
|
else
|
|
|
|
fired = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fired = FireProjectile(shooter, source, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_MOLOTOV:
|
|
|
|
case WEAPONTYPE_GRENADE:
|
2020-05-15 14:30:25 +00:00
|
|
|
case WEAPONTYPE_DETONATOR_GRENADE:
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_TEARGAS:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
{
|
|
|
|
fired = FireProjectile(shooter, source, ((CPlayerPed*)shooter)->m_fAttackButtonCounter*0.0375f);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
else if ( shooter->IsPed() && ((CPed*)shooter)->m_pSeekTarget != nil )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
float distToTarget = (shooter->GetPosition() - ((CPed*)shooter)->m_pSeekTarget->GetPosition()).Magnitude();
|
|
|
|
float power = clamp((distToTarget-10.0f)*0.02f, 0.2f, 1.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
fired = FireProjectile(shooter, source, power);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fired = FireProjectile(shooter, source, 0.3f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-15 14:30:25 +00:00
|
|
|
if (m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE) {
|
|
|
|
((CPed*)shooter)->GiveWeapon(WEAPONTYPE_DETONATOR, 1, true);
|
|
|
|
((CPed*)shooter)->GetWeapon(((CPed*)shooter)->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
((CPed*)shooter)->SetCurrentWeapon(WEAPONTYPE_DETONATOR);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_FLAMETHROWER:
|
|
|
|
{
|
|
|
|
fired = FireAreaEffect(shooter, source);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_DETONATOR:
|
|
|
|
{
|
|
|
|
CWorld::UseDetonator(shooter);
|
|
|
|
m_nAmmoTotal = 1;
|
|
|
|
m_nAmmoInClip = m_nAmmoTotal;
|
|
|
|
fired = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
case WEAPONTYPE_CAMERA:
|
|
|
|
{
|
|
|
|
fired = TakePhotograph(shooter);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
debug("Unknown weapon type, Weapon.cpp");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (fired)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
bool isPlayer = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (shooter->IsPed())
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
CPed* shooterPed = (CPed*)shooter;
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( m_eWeaponType != WEAPONTYPE_CAMERA )
|
|
|
|
{
|
|
|
|
shooterPed->bIsShooting = true;
|
|
|
|
|
|
|
|
if (shooterPed->IsPlayer())
|
|
|
|
isPlayer = true;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(shooterPed->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( isPlayer )
|
|
|
|
{
|
|
|
|
CPed *aimPed = (CPed *)shooterPed->m_pSeekTarget;
|
|
|
|
if ( aimPed )
|
|
|
|
{
|
|
|
|
if ( aimPed->IsPed() )
|
|
|
|
shooterPed->Say(SOUND_PED_ON_FIRE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( m_eWeaponType )
|
|
|
|
{
|
|
|
|
case WEAPONTYPE_COLT45:
|
|
|
|
case WEAPONTYPE_PYTHON:
|
|
|
|
case WEAPONTYPE_SHOTGUN:
|
|
|
|
case WEAPONTYPE_SPAS12_SHOTGUN:
|
|
|
|
case WEAPONTYPE_STUBBY_SHOTGUN:
|
|
|
|
case WEAPONTYPE_TEC9:
|
|
|
|
case WEAPONTYPE_UZI:
|
|
|
|
case WEAPONTYPE_SILENCED_INGRAM:
|
|
|
|
case WEAPONTYPE_MP5:
|
|
|
|
case WEAPONTYPE_M4:
|
|
|
|
case WEAPONTYPE_RUGER:
|
|
|
|
case WEAPONTYPE_SNIPERRIFLE:
|
|
|
|
case WEAPONTYPE_LASERSCOPE:
|
|
|
|
case WEAPONTYPE_M60:
|
|
|
|
case WEAPONTYPE_MINIGUN:
|
|
|
|
CStats::RoundsFiredByPlayer++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WEAPONTYPE_GRENADE:
|
|
|
|
case WEAPONTYPE_DETONATOR_GRENADE:
|
|
|
|
case WEAPONTYPE_MOLOTOV:
|
|
|
|
case WEAPONTYPE_ROCKET:
|
|
|
|
case WEAPONTYPE_ROCKETLAUNCHER:
|
|
|
|
case WEAPONTYPE_DETONATOR:
|
|
|
|
case WEAPONTYPE_HELICANNON:
|
|
|
|
CStats::KgsOfExplosivesUsed++;
|
|
|
|
break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_nAmmoInClip > 0)
|
2020-05-17 17:36:48 +00:00
|
|
|
m_nAmmoInClip--;
|
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_nAmmoTotal > 0 && (m_nAmmoTotal < 25000 || isPlayer) && (!isPlayer || CStats::GetPercentageProgress() < 100.0f || m_eWeaponType == WEAPONTYPE_DETONATOR))
|
2020-05-17 17:36:48 +00:00
|
|
|
m_nAmmoTotal--;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_eWeaponState == WEAPONSTATE_READY && m_eWeaponType == WEAPONTYPE_FLAMETHROWER)
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)shooter)->m_audioEntityId, SOUND_WEAPON_FLAMETHROWER_FIRE, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_FIRING;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_nAmmoInClip == 0)
|
|
|
|
{
|
2020-06-20 14:30:28 +00:00
|
|
|
if (m_nAmmoTotal == 0) {
|
|
|
|
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_CAMERA)
|
|
|
|
CPad::GetPad(0)->Clear(false);
|
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
return true;
|
2020-06-20 14:30:28 +00:00
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_RELOADING;
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (shooter == FindPlayerPed())
|
|
|
|
{
|
|
|
|
if (CWorld::Players[CWorld::PlayerInFocus].m_bFastReload)
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload / 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( addFireRateAsDelay )
|
2020-05-19 14:39:19 +00:00
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nFiringRate;
|
|
|
|
else
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds();
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_eWeaponState != WEAPONSTATE_FIRING )
|
|
|
|
{
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
|
|
|
|
m_eWeaponState = WEAPONSTATE_FIRING;
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (shooter->IsPed() && m_eWeaponType != WEAPONTYPE_CHAINSAW)
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
DMAudio.PlayOneShot(((CPed*)shooter)->m_audioEntityId, SOUND_MELEE_ATTACK_START, m_eWeaponType << 8);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
fired = FireMelee(shooter, *source);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BASEBALLBAT )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return fired;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-06-06 22:01:48 +00:00
|
|
|
CWeapon::FireFromCar(CVehicle *shooter, bool left, bool right)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_eWeaponState != WEAPONSTATE_READY && m_eWeaponState != WEAPONSTATE_FIRING )
|
|
|
|
return false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_nAmmoInClip <= 0 )
|
|
|
|
return false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-06 22:01:48 +00:00
|
|
|
if ( FireInstantHitFromCar(shooter, left, right) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
DMAudio.PlayOneShot(shooter->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-20 13:23:32 +00:00
|
|
|
if ( m_nAmmoInClip > 0 )
|
|
|
|
m_nAmmoInClip--;
|
|
|
|
|
|
|
|
if ( m_nAmmoTotal < 25000 && m_nAmmoTotal > 0 && (!shooter || shooter->GetStatus() != STATUS_PLAYER || CStats::GetPercentageProgress() < 100.f))
|
|
|
|
m_nAmmoTotal--;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_FIRING;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_nAmmoInClip == 0 )
|
|
|
|
{
|
|
|
|
if ( m_nAmmoTotal == 0 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
m_eWeaponState = WEAPONSTATE_RELOADING;
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds() + 1000;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
bool anim2Playing = false;
|
|
|
|
|
|
|
|
if ( CPed::GetFireAnimGround(info, false) != (AnimationId)0 )
|
|
|
|
{
|
|
|
|
if ( RpAnimBlendClumpGetAssociation(shooter->GetClump(), CPed::GetFireAnimGround(info, false)) )
|
|
|
|
anim2Playing = true;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
ASSERT(shooter->IsPed());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CPed *shooterPed = (CPed*)shooter;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if (shooterPed == FindPlayerPed())
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_eWeaponType == WEAPONTYPE_GOLFCLUB || m_eWeaponType == WEAPONTYPE_NIGHTSTICK ||
|
2020-08-27 16:52:43 +00:00
|
|
|
(m_eWeaponType >= WEAPONTYPE_BASEBALLBAT && m_eWeaponType <= WEAPONTYPE_CHAINSAW))
|
|
|
|
{
|
|
|
|
CGlass::BreakGlassPhysically(fireSource, info->m_fRadius);
|
2020-05-19 14:39:19 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
2020-05-19 14:39:19 +00:00
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, FindPlayerPed(), FindPlayerPed(), 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int damageEntityRegistered = 0;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
for ( int32 i = 0; i < shooterPed->m_numNearPeds; i++ )
|
|
|
|
{
|
|
|
|
CPed *victimPed = shooterPed->m_nearPeds[i];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victimPed!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( (victimPed->m_nPedType != shooterPed->m_nPedType || victimPed == shooterPed->m_pSeekTarget)
|
2020-05-19 14:39:19 +00:00
|
|
|
&& victimPed != shooterPed->m_leader || !(CGeneral::GetRandomNumber() & 31)
|
|
|
|
&& (!shooterPed->IsGangMember() || victimPed->CanBeDamagedByThisGangMember(shooterPed)) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
bool collided = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (victimPed->m_nPedState == PED_DRIVING && (m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE
|
2020-12-26 12:22:02 +00:00
|
|
|
|| info->IsFlagSet(WEAPONFLAG_FIGHTMODE)))
|
2020-05-17 17:36:48 +00:00
|
|
|
continue;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float victimPedRadius = victimPed->GetBoundRadius() + info->m_fRadius;
|
|
|
|
if ( victimPed->bUsesCollision || victimPed->Dead() || victimPed->Driving() )
|
|
|
|
{
|
|
|
|
CVector victimPedPos = victimPed->GetPosition();
|
2020-12-18 00:58:09 +00:00
|
|
|
if ( SQR(victimPedRadius) > (victimPedPos-fireSource).MagnitudeSqr() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CVector collisionDist;
|
2020-05-17 17:36:48 +00:00
|
|
|
CColModel* victimPedCol = &CTempColModels::ms_colModelPed1;
|
|
|
|
bool useLocalPos = false;
|
|
|
|
if (victimPed->m_nPedState == PED_FALL
|
|
|
|
|| victimPed->m_nPedState == PED_DIE && victimPed->bIsPedDieAnimPlaying
|
|
|
|
|| victimPed->m_nWaitState == WAITSTATE_SIT_IDLE
|
|
|
|
|| victimPed->m_nWaitState == WAITSTATE_SUN_BATHE_IDLE)
|
|
|
|
{
|
|
|
|
useLocalPos = true;
|
|
|
|
victimPedCol = ((CPedModelInfo*)CModelInfo::GetModelInfo(victimPed->GetModelIndex()))->AnimatePedColModelSkinnedWorld(victimPed->GetClump());
|
|
|
|
} else if (victimPed->DyingOrDead()) {
|
|
|
|
victimPedCol = &CTempColModels::ms_colModelPedGroundHit;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int32 s = 0;
|
|
|
|
while ( s < victimPedCol->numSpheres )
|
|
|
|
{
|
|
|
|
CColSphere *sphere = &victimPedCol->spheres[s];
|
2020-05-17 17:36:48 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if (useLocalPos)
|
2020-12-18 00:58:09 +00:00
|
|
|
collisionDist = sphere->center - fireSource;
|
2020-08-27 16:52:43 +00:00
|
|
|
else
|
2020-12-18 00:58:09 +00:00
|
|
|
collisionDist = victimPedPos + sphere->center - fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( SQR(sphere->radius + info->m_fRadius) > collisionDist.MagnitudeSqr() )
|
|
|
|
{
|
|
|
|
collided = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s++;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !(victimPed->IsPlayer() && victimPed->GetPedState() == PED_GETUP) )
|
|
|
|
{
|
|
|
|
if ( collided )
|
|
|
|
{
|
|
|
|
float victimPedHealth = victimPed->m_fHealth;
|
2020-04-15 16:43:16 +00:00
|
|
|
CVector bloodPos = fireSource + (collisionDist*0.7f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D posOffset(shooterPed->GetPosition().x-victimPedPos.x, shooterPed->GetPosition().y-victimPedPos.y);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int32 localDir = victimPed->GetLocalDirection(posOffset);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
bool isHeavy = m_eWeaponType >= WEAPONTYPE_GOLFCLUB && m_eWeaponType <= WEAPONTYPE_KATANA && m_eWeaponType != WEAPONTYPE_HAMMER;
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if (shooterPed->m_fDamageImpulse == 0.0f)
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
shooterPed->m_pDamageEntity = victimPed;
|
|
|
|
victimPed->RegisterReference(&shooterPed->m_pDamageEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
damageEntityRegistered = 3;
|
2020-08-27 16:52:43 +00:00
|
|
|
if (victimPed->bInVehicle)
|
|
|
|
{
|
2020-06-06 14:19:36 +00:00
|
|
|
CVehicle *victimVeh = victimPed->m_pMyVehicle;
|
2020-08-27 16:52:43 +00:00
|
|
|
if (victimVeh)
|
|
|
|
{
|
|
|
|
if (victimVeh->IsBike())
|
|
|
|
{
|
2020-06-06 14:19:36 +00:00
|
|
|
CBike *victimBike = (CBike*)victimVeh;
|
|
|
|
victimBike->KnockOffRider(m_eWeaponType, localDir, victimPed, false);
|
2020-08-27 16:52:43 +00:00
|
|
|
if (victimBike->pDriver)
|
2020-06-06 14:19:36 +00:00
|
|
|
victimBike->pDriver->ReactToAttack(shooterPed);
|
2020-08-27 16:52:43 +00:00
|
|
|
else
|
|
|
|
{
|
2020-06-06 14:19:36 +00:00
|
|
|
if (victimVeh->pPassengers[0])
|
|
|
|
victimVeh->pPassengers[0]->ReactToAttack(shooterPed);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !victimPed->DyingOrDead() )
|
|
|
|
victimPed->ReactToAttack(shooterPed);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
uint8 hitLevel = HITLEVEL_HIGH;
|
2020-05-19 14:39:19 +00:00
|
|
|
if ( isHeavy && (victimPed->OnGround() || victimPed->m_nWaitState == WAITSTATE_SUN_BATHE_IDLE))
|
2020-04-15 05:03:53 +00:00
|
|
|
hitLevel = HITLEVEL_GROUND;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->StartFightDefend(localDir, hitLevel, 10);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !victimPed->DyingOrDead() )
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
if ( shooterPed->IsPlayer() && isHeavy && anim2Playing )
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->InflictDamage(shooterPed, m_eWeaponType, 100.0f, PEDPIECE_TORSO, localDir);
|
|
|
|
else if ( shooterPed->IsPlayer() && ((CPlayerPed*)shooterPed)->m_bAdrenalineActive )
|
|
|
|
victimPed->InflictDamage(shooterPed, m_eWeaponType, 3.5f*info->m_nDamage, PEDPIECE_TORSO, localDir);
|
|
|
|
else
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
if ( victimPed->IsPlayer() && isHeavy ) // wtf, it's not fair
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->InflictDamage(shooterPed, m_eWeaponType, 2.0f*info->m_nDamage, PEDPIECE_TORSO, localDir);
|
|
|
|
else
|
|
|
|
victimPed->InflictDamage(shooterPed, m_eWeaponType, info->m_nDamage, PEDPIECE_TORSO, localDir);
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if ( CGame::nastyGame && victimPed->GetIsOnScreen() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
CVector dir = collisionDist * RecipSqrt(1.0f, 10.0f*collisionDist.MagnitudeSqr());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
|
|
|
|
|
|
|
|
if ( isHeavy )
|
|
|
|
{
|
|
|
|
dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
|
|
|
|
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
|
2020-05-19 14:39:19 +00:00
|
|
|
|
|
|
|
dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
|
|
|
|
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
{
|
|
|
|
if (victimPed->m_nPedState != PED_DEAD && !((CTimer::GetFrameCounter() + 17) & 1)
|
|
|
|
|| victimPed->m_nPedState == PED_DEAD && !((CTimer::GetFrameCounter() + 17) & 3))
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_TEST, bloodPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.2f);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-05-19 14:39:19 +00:00
|
|
|
CVector newDir(dir);
|
|
|
|
newDir.z += 0.2f;
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, bloodPos, newDir);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, newDir);
|
|
|
|
newDir.z = dir.z + 0.1f;
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, newDir);
|
|
|
|
newDir.x = 0.0f;
|
|
|
|
newDir.y = 0.0f;
|
|
|
|
newDir.z = 0.01f;
|
|
|
|
CParticle::AddParticle(PARTICLE_DEBRIS2, bloodPos, newDir);
|
|
|
|
|
2020-06-15 20:43:20 +00:00
|
|
|
CVector dropDir(CGeneral::GetRandomNumberInRange(-0.15f, 0.15f), CGeneral::GetRandomNumberInRange(0.1f, 0.35f), 0.f);
|
|
|
|
CVector dropPos(CGeneral::GetRandomNumberInRange(SCREEN_STRETCH_X(50.0f), SCREEN_STRETCH_FROM_RIGHT(50.0f)),
|
|
|
|
CGeneral::GetRandomNumberInRange(SCREEN_STRETCH_Y(50.0f), SCREEN_STRETCH_FROM_BOTTOM(50.0f)), 1.f);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOODDROP, dropPos, dropDir, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.15f),
|
2020-05-19 14:39:19 +00:00
|
|
|
CRGBA(0, 0, 0, 0), 0, 0, CGeneral::GetRandomNumber() & 1, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (info->m_AnimToPlay == ASSOCGRP_KNIFE)
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
dir += 0.1f * shooterPed->GetUp() + 0.05f * shooterPed->GetRight();
|
2020-05-19 14:39:19 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !victimPed->OnGround() )
|
|
|
|
{
|
|
|
|
if ( victimPed->m_fHealth > 0.0f
|
2020-08-27 16:52:43 +00:00
|
|
|
&& (victimPed->m_fHealth < 30.0f && victimPedHealth > 30.0f ||
|
2020-05-19 14:39:19 +00:00
|
|
|
(isHeavy || m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE) && !victimPed->IsPlayer()) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
posOffset.Normalise();
|
|
|
|
victimPed->bIsStanding = false;
|
2020-05-19 14:39:19 +00:00
|
|
|
if(m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-2.0f, posOffset.y*-2.0f, 2.0f);
|
|
|
|
else
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if ( isHeavy && victimPed->IsPlayer() )
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->SetFall(3000, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
|
|
|
|
else
|
|
|
|
victimPed->SetFall(1500, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
shooterPed->m_pSeekTarget = victimPed;
|
|
|
|
shooterPed->m_pSeekTarget->RegisterReference(&shooterPed->m_pSeekTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (victimPed->Dying() && !anim2Playing)
|
|
|
|
{
|
|
|
|
posOffset.Normalise();
|
|
|
|
victimPed->bIsStanding = false;
|
2020-05-19 14:39:19 +00:00
|
|
|
if(m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-1.0f, posOffset.y*-1.0f, 1.0f);
|
|
|
|
else
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-19 14:39:19 +00:00
|
|
|
if (m_eWeaponType != WEAPONTYPE_KNIFE && m_eWeaponType != WEAPONTYPE_MACHETE
|
|
|
|
&& m_eWeaponType != WEAPONTYPE_KATANA && m_eWeaponType != WEAPONTYPE_CHAINSAW) {
|
|
|
|
|
|
|
|
if (victimPed->m_nPedType == PEDTYPE_COP)
|
|
|
|
CEventList::RegisterEvent(EVENT_ASSAULT_POLICE, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
|
|
|
|
else
|
|
|
|
CEventList::RegisterEvent(EVENT_ASSAULT, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
|
|
|
|
} else {
|
|
|
|
if (victimPed->m_nPedType == PEDTYPE_COP)
|
|
|
|
CEventList::RegisterEvent(EVENT_ASSAULT_NASTYWEAPON_POLICE, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
|
|
|
|
else
|
|
|
|
CEventList::RegisterEvent(EVENT_ASSAULT_NASTYWEAPON, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-19 14:39:19 +00:00
|
|
|
CVehicle *nearVeh = (CVehicle*)CWorld::TestSphereAgainstWorld(fireSource, info->m_fRadius, nil, false, true, false, false, false, false);
|
|
|
|
if (nearVeh && nearVeh->IsCar())
|
|
|
|
{
|
|
|
|
CAutomobile *nearCar = (CAutomobile*)nearVeh;
|
|
|
|
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
|
|
|
|
if (shooterPed == FindPlayerPed())
|
|
|
|
{
|
|
|
|
if (nearCar->IsLawEnforcementVehicle())
|
|
|
|
{
|
|
|
|
FindPlayerPed()->SetWantedLevelNoDrop(1);
|
|
|
|
}
|
|
|
|
CEventList::RegisterEvent(EVENT_ASSAULT, EVENT_ENTITY_VEHICLE, nearCar, shooterPed, 2000);
|
|
|
|
}
|
|
|
|
float oldHealth = nearCar->m_fHealth;
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
for( int32 i=0; i<4; i++ )
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.3f));
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, gaTempSphereColPoints[0].point, gaTempSphereColPoints[0].normal * 0.1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
{
|
|
|
|
nearCar->VehicleDamage(info->m_nDamage * (0.00075f * nearCar->pHandling->fMass), gaTempSphereColPoints[0].pieceB);
|
|
|
|
|
2020-06-15 20:43:20 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.0f), 0, 0.0f, 0, 0, 0, 0);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-30 14:50:03 +00:00
|
|
|
nearCar->VehicleDamage(info->m_nDamage* (0.01f * nearCar->pHandling->fMass), gaTempSphereColPoints[0].pieceB);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
|
|
|
if (nearCar->m_fHealth < oldHealth)
|
|
|
|
{
|
|
|
|
nearCar->m_nLastWeaponDamage = m_eWeaponType;
|
|
|
|
nearCar->m_pLastDamageEntity = shooterPed;
|
|
|
|
}
|
|
|
|
if (shooterPed->m_fDamageImpulse == 0.0f)
|
|
|
|
{
|
|
|
|
shooterPed->m_pDamageEntity = nearCar;
|
|
|
|
nearCar->RegisterReference(&shooterPed->m_pDamageEntity);
|
|
|
|
}
|
|
|
|
damageEntityRegistered = 2;
|
|
|
|
if (FindPlayerPed()->GetWeapon() == this && nearCar->VehicleCreatedBy != MISSION_VEHICLE)
|
|
|
|
{
|
|
|
|
if (nearCar->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_PLOUGH_THROUGH
|
|
|
|
&& (CGeneral::GetRandomTrueFalse() || nearCar->AutoPilot.m_nCarMission != MISSION_CRUISE))
|
|
|
|
{
|
|
|
|
int leaveCarDelay = 200;
|
|
|
|
CPed *driver = nearCar->pDriver;
|
|
|
|
if (driver && driver->CharCreatedBy != MISSION_CHAR)
|
|
|
|
{
|
|
|
|
if (driver->m_pedStats->m_temper <= driver->m_pedStats->m_fear)
|
|
|
|
{
|
2020-06-22 01:02:44 +00:00
|
|
|
driver->SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE);
|
2020-05-19 14:39:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
driver->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, FindPlayerPed());
|
|
|
|
driver->m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000;
|
|
|
|
driver->m_prevObjective = OBJECTIVE_KILL_CHAR_ON_FOOT;
|
|
|
|
}
|
|
|
|
driver->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + 200;
|
|
|
|
leaveCarDelay = 400;
|
|
|
|
}
|
|
|
|
for (int j = 0; j < nearCar->m_nNumPassengers; ++j)
|
|
|
|
{
|
|
|
|
CPed *passenger = nearCar->pPassengers[j];
|
|
|
|
if (passenger && passenger->CharCreatedBy != MISSION_CHAR)
|
|
|
|
{
|
2020-06-22 01:02:44 +00:00
|
|
|
nearCar->pPassengers[j]->SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE);
|
2020-05-19 14:39:19 +00:00
|
|
|
passenger->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + leaveCarDelay;
|
|
|
|
leaveCarDelay += 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CPed *driver = nearCar->pDriver;
|
|
|
|
if (driver)
|
|
|
|
{
|
2020-06-22 01:02:44 +00:00
|
|
|
if (driver->m_objective != OBJECTIVE_LEAVE_CAR && driver->m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT &&
|
|
|
|
driver->m_objective != OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE)
|
2020-05-19 14:39:19 +00:00
|
|
|
{
|
|
|
|
if (nearCar->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_PLOUGH_THROUGH)
|
|
|
|
nearCar->AutoPilot.m_nCruiseSpeed = nearCar->AutoPilot.m_nCruiseSpeed * 1.5f;
|
|
|
|
|
|
|
|
nearCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_PLOUGH_THROUGH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
|
|
|
|
{
|
|
|
|
CEntity *nearStatic = (CObject*)CWorld::TestSphereAgainstWorld(fireSource, info->m_fRadius, nil, true, false, false, true, false, false);
|
|
|
|
if (nearStatic)
|
|
|
|
{
|
|
|
|
for(int i=0; i < 4; i++) {
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.3f), 0, 0.0f, 0, 0, 0, 0);
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, gaTempSphereColPoints[0].point, 0.1f * gaTempSphereColPoints[0].normal, 0, 0.0f, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2020-06-15 20:43:20 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.0f), 0, 0.0f, 0, 0, 0, 0);
|
2020-05-19 14:39:19 +00:00
|
|
|
|
|
|
|
if (!damageEntityRegistered)
|
|
|
|
{
|
|
|
|
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
|
|
|
|
if (shooterPed->m_fDamageImpulse == 0.0f)
|
|
|
|
{
|
|
|
|
shooterPed->m_pDamageEntity = nearStatic;
|
|
|
|
nearStatic->RegisterReference(&shooterPed->m_pDamageEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nearStatic->IsObject() && ((CObject*)nearStatic)->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY)
|
|
|
|
((CObject*)nearStatic)->ObjectDamage(200.0f);
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(fireSource!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source, target;
|
|
|
|
CColPoint point;
|
2020-04-15 16:43:16 +00:00
|
|
|
CEntity *victim = nil;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float heading = RADTODEG(shooter->GetForward().Heading());
|
|
|
|
float angle = DEGTORAD(heading);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D ahead(-Sin(angle), Cos(angle));
|
|
|
|
ahead.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector vel = ((CPed *)shooter)->m_vecMoveSpeed;
|
|
|
|
int32 shooterMoving = false;
|
|
|
|
if ( Abs(vel.x) > 0.0f && Abs(vel.y) > 0.0f )
|
|
|
|
shooterMoving = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
{
|
|
|
|
static float prev_heading = 0.0f;
|
|
|
|
prev_heading = ((CPed*)shooter)->m_fRotationCur;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter->IsPed() && ((CPed *)shooter)->m_pPointGunAt )
|
|
|
|
{
|
|
|
|
CPed *shooterPed = (CPed *)shooter;
|
|
|
|
if ( shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY )
|
|
|
|
{
|
|
|
|
int32 accuracy = shooterPed->m_wepAccuracy;
|
|
|
|
int32 inaccuracy = 100-accuracy;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CPed *threatAttack = (CPed*)shooterPed->m_pPointGunAt;
|
|
|
|
if ( threatAttack->IsPed() )
|
|
|
|
{
|
2020-12-18 00:58:09 +00:00
|
|
|
threatAttack->m_pedIK.GetComponentPosition(target, PED_MID);
|
2020-04-15 05:03:53 +00:00
|
|
|
threatAttack->ReactToPointGun(shooter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
target = threatAttack->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
target -= *fireSource;
|
2020-08-27 16:52:43 +00:00
|
|
|
float distToTarget = Max(target.Magnitude(), 0.01f);
|
2020-06-15 22:38:26 +00:00
|
|
|
target *= info->m_fRange / distToTarget;
|
2020-04-15 05:03:53 +00:00
|
|
|
target += *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
if (shooter == FindPlayerPed() && inaccuracy != 0.f)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
float newInaccuracy = fPlayerAimScale * FindPlayerPed()->m_fAttackButtonCounter * (inaccuracy * Min(1.f, fPlayerAimScaleDist / distToTarget));
|
2020-06-15 22:38:26 +00:00
|
|
|
if (FindPlayerPed()->bIsDucking)
|
|
|
|
newInaccuracy *= 0.4f;
|
|
|
|
|
|
|
|
target.x += CGeneral::GetRandomNumberInRange(-0.15f, 0.15f) * newInaccuracy;
|
|
|
|
target.y += CGeneral::GetRandomNumberInRange(-0.15f, 0.15f) * newInaccuracy;
|
|
|
|
target.z += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f) * newInaccuracy;
|
|
|
|
FindPlayerPed()->m_fAttackButtonCounter += info->m_nDamage * 0.04f;
|
|
|
|
}
|
|
|
|
else if (inaccuracy > 0.f)
|
|
|
|
{
|
|
|
|
if (threatAttack == FindPlayerPed())
|
|
|
|
{
|
|
|
|
float speed = Min(0.33f, FindPlayerPed()->m_vecMoveSpeed.Magnitude());
|
|
|
|
inaccuracy *= (0.3f * speed * 100.f / 33.f + 0.8f);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
target.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f) * inaccuracy;
|
|
|
|
target.y += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f) * inaccuracy;
|
|
|
|
target.z += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * inaccuracy;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
if (shooter == FindPlayerPed())
|
|
|
|
CWorld::bIncludeDeadPeds = true;
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::bIncludeDeadPeds = false;
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target.x = info->m_fRange;
|
|
|
|
target.y = 0.0f;
|
|
|
|
target.z = 0.0f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-23 20:25:18 +00:00
|
|
|
shooterPed->TransformToNode(target, PED_HANDR);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() )
|
|
|
|
{
|
2020-10-20 23:04:51 +00:00
|
|
|
TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::bIncludeDeadPeds = true;
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeCarTyres = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::bIncludeDeadPeds = false;
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeCarTyres = false;
|
2020-06-15 22:38:26 +00:00
|
|
|
|
2020-06-20 13:23:32 +00:00
|
|
|
if (victim)
|
2020-10-20 23:04:51 +00:00
|
|
|
CheckForShootingVehicleOccupant(&victim, &point, m_eWeaponType, source, target);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int32 rotSpeed = 1;
|
2020-06-20 13:23:32 +00:00
|
|
|
if ( m_eWeaponType == WEAPONTYPE_M4 )
|
2020-04-15 05:03:53 +00:00
|
|
|
rotSpeed = 4;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector bulletPos;
|
2020-10-20 23:04:51 +00:00
|
|
|
if ( CHeli::TestBulletCollision(&source, &target, &bulletPos, 4) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 16; i++ )
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, bulletPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, rotSpeed);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-15 22:38:26 +00:00
|
|
|
uint32 model = shooter->GetModelIndex();
|
|
|
|
if (model == MI_HUNTER || model == MI_SEASPAR || model == MI_SPARROW)
|
|
|
|
{
|
|
|
|
float inaccuracyMult = 0.6f;
|
|
|
|
target = shooter->GetForward();
|
|
|
|
if (shooter->GetStatus() == STATUS_PLAYER)
|
|
|
|
{
|
|
|
|
target *= info->m_fRange;
|
|
|
|
target += *fireSource;
|
|
|
|
CWeapon::DoDriveByAutoAiming(FindPlayerPed(), (CVehicle*)shooter, fireSource, &target);
|
|
|
|
target -= *fireSource;
|
|
|
|
target.Normalise();
|
|
|
|
if (model == MI_SEASPAR || model == MI_SPARROW)
|
|
|
|
inaccuracyMult = 0.1f;
|
|
|
|
else
|
|
|
|
inaccuracyMult = 0.3f;
|
|
|
|
}
|
|
|
|
target.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f) * inaccuracyMult;
|
|
|
|
target.y += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f) * inaccuracyMult;
|
|
|
|
target.z += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * inaccuracyMult;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
target.Normalise();
|
|
|
|
target *= info->m_fRange;
|
|
|
|
target += *fireSource;
|
|
|
|
CWorld::pIgnoreEntity = shooter;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, true, false);
|
2020-06-15 22:38:26 +00:00
|
|
|
CWorld::pIgnoreEntity = nil;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
int32 rotSpeed = 1;
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_M4)
|
|
|
|
rotSpeed = 4;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
CVector bulletPos;
|
|
|
|
if (CHeli::TestBulletCollision(fireSource, &target, &bulletPos, 4))
|
|
|
|
{
|
|
|
|
for (int32 i = 0; i < 16; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, bulletPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, rotSpeed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float shooterHeading = RADTODEG(shooter->GetForward().Heading());
|
|
|
|
float shooterAngle = DEGTORAD(shooterHeading);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
CVector2D rotOffset(-Sin(shooterAngle), Cos(shooterAngle));
|
|
|
|
rotOffset.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
target = *fireSource;
|
|
|
|
target.x += rotOffset.x * info->m_fRange;
|
|
|
|
target.y += rotOffset.y * info->m_fRange;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
CParticle::HandleShootableBirdsStuff(shooter, *fireSource);
|
2020-12-26 12:22:02 +00:00
|
|
|
if (shooter->IsPed() && ((CPed*)shooter)->bDoomAim && (shooter != FindPlayerPed() || !info->IsFlagSet(WEAPONFLAG_CANAIM)))
|
2020-06-15 22:38:26 +00:00
|
|
|
{
|
|
|
|
CWeapon::DoDoomAiming(shooter, fireSource, &target);
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-06-15 22:38:26 +00:00
|
|
|
|
|
|
|
int32 rotSpeed = 1;
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_M4)
|
|
|
|
rotSpeed = 4;
|
|
|
|
|
|
|
|
CVector bulletPos;
|
|
|
|
if (CHeli::TestBulletCollision(fireSource, &target, &bulletPos, 4))
|
|
|
|
{
|
|
|
|
for (int32 i = 0; i < 16; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, bulletPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, rotSpeed);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( shooter->IsPed() && victim)
|
2020-06-03 13:16:31 +00:00
|
|
|
{
|
|
|
|
if (victim == ((CPed*)shooter)->m_leader)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (victim->IsPed() && ((CPed*)shooter)->IsGangMember() && !((CPed*)victim)->CanBeDamagedByThisGangMember((CPed*)shooter))
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
|
2020-06-03 13:16:31 +00:00
|
|
|
if (shooter->IsPed())
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, shooter, (CPed*)shooter, 1000);
|
|
|
|
else if (shooter->IsVehicle() && ((CVehicle*)shooter)->pDriver)
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_VEHICLE, shooter, ((CVehicle*)shooter)->pDriver, 1000);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
{
|
|
|
|
if ( !(CTimer::GetFrameCounter() & 3) )
|
|
|
|
MakePedsJumpAtShot((CPhysical*)shooter, fireSource, &target);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
switch ( m_eWeaponType )
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_M4:
|
|
|
|
case WEAPONTYPE_RUGER:
|
|
|
|
case WEAPONTYPE_M60:
|
|
|
|
case WEAPONTYPE_MINIGUN:
|
2020-05-17 17:36:48 +00:00
|
|
|
case WEAPONTYPE_HELICANNON:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
static uint8 counter = 0;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-20 14:30:28 +00:00
|
|
|
if ( info->m_nFiringRate >= 50 || !(++counter & 1) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-03 13:16:31 +00:00
|
|
|
AddGunFlashBigGuns(*fireSource, *fireSource + target);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunshellPos = *fireSource;
|
|
|
|
gunshellPos -= CVector(0.65f*ahead.x, 0.65f*ahead.y, 0.0f);
|
|
|
|
CVector dir = CrossProduct(CVector(ahead.x, ahead.y, 0.0f), CVector(0.0f, 0.0f, 5.0f));
|
|
|
|
dir.Normalise2D();
|
|
|
|
AddGunshell(shooter, gunshellPos, CVector2D(dir.x, dir.y), 0.02f);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_UZI:
|
2020-05-15 14:30:25 +00:00
|
|
|
case WEAPONTYPE_TEC9:
|
|
|
|
case WEAPONTYPE_SILENCED_INGRAM:
|
|
|
|
case WEAPONTYPE_MP5:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
*fireSource, CVector(0.0f, 0.0f, 0.0f), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunflashPos = *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooterMoving )
|
|
|
|
gunflashPos += CVector(1.5f*vel.x, 1.5f*vel.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.07f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.06f*ahead.x, 0.06f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.05f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.04f*ahead.x, 0.04f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.04f*ahead.x, 0.04f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.03f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.03f*ahead.x, 0.03f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.03f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.03f*ahead.x, 0.03f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.02f*ahead.x, 0.02f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.01f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunsmokePos = *fireSource;
|
|
|
|
float rnd = CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x*rnd, ahead.y*rnd, 0.0f));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunshellPos = *fireSource;
|
|
|
|
gunshellPos -= CVector(0.2f*ahead.x, 0.2f*ahead.y, 0.0f);
|
|
|
|
CVector dir = CrossProduct(CVector(ahead.x, ahead.y, 0.0f), CVector(0.0f, 0.0f, 5.0f));
|
|
|
|
dir.Normalise2D();
|
|
|
|
AddGunshell(shooter, gunshellPos, CVector2D(dir.x, dir.y), 0.015f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONTYPE_COLT45:
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_PYTHON:
|
|
|
|
case WEAPONTYPE_SNIPERRIFLE:
|
|
|
|
case WEAPONTYPE_LASERSCOPE:
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
*fireSource, CVector(0.0f, 0.0f, 0.0f), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunflashPos = *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooterMoving )
|
|
|
|
gunflashPos += CVector(1.5f*vel.x, 1.5f*vel.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.06f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.06f*ahead.x, 0.06f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(0.04f*ahead.x, 0.04f*ahead.y, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunsmokePos = *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x*0.10f, ahead.y*0.10f, 0.0f), nil, 0.005f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x*0.15f, ahead.y*0.15f, 0.0f), nil, 0.015f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x*0.20f, ahead.y*0.20f, 0.0f), nil, 0.025f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunshellPos = *fireSource;
|
|
|
|
gunshellPos -= CVector(0.2f*ahead.x, 0.2f*ahead.y, 0.0f);
|
|
|
|
CVector dir = CrossProduct(CVector(ahead.x, ahead.y, 0.0f), CVector(0.0f, 0.0f, 5.0f));
|
|
|
|
dir.Normalise2D();
|
|
|
|
AddGunshell(shooter, gunshellPos, CVector2D(dir.x, dir.y), 0.015f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
DoBulletImpact(shooter, victim, fireSource, &target, &point, ahead);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
void
|
|
|
|
CWeapon::AddGunFlashBigGuns(CVector start, CVector end)
|
|
|
|
{
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
start, CVector(0.0f, 0.0f, 0.0f), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
|
|
|
CVector gunflashPos = start;
|
|
|
|
|
|
|
|
CVector shootVec = end - start;
|
|
|
|
|
|
|
|
// Wtf did you do there R*?
|
|
|
|
shootVec.Normalise();
|
|
|
|
CVector2D ahead = shootVec;
|
|
|
|
ahead.Normalise();
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.08f);
|
|
|
|
gunflashPos += CVector(0.06f * ahead.x, 0.06f * ahead.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.06f);
|
|
|
|
gunflashPos += CVector(0.06f * ahead.x, 0.06f * ahead.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.06f);
|
|
|
|
|
|
|
|
gunflashPos = start;
|
|
|
|
gunflashPos += CVector(-0.1f * ahead.x, -0.1f * ahead.y, 0.0f);
|
|
|
|
gunflashPos.z += 0.04f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
|
|
|
gunflashPos.z += 0.04f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
gunflashPos.z += 0.03f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
|
|
|
|
gunflashPos = start;
|
|
|
|
gunflashPos += CVector(-0.1f * ahead.x, -0.1f * ahead.y, 0.0f);
|
|
|
|
gunflashPos.z -= 0.04f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
|
|
|
gunflashPos.z -= 0.04f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
gunflashPos.z -= 0.03f;
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
|
|
|
|
CVector offset = CrossProduct(CVector(ahead.x, ahead.y, 0.0f), CVector(0.0f, 0.0f, 5.0f));
|
|
|
|
offset.Normalise2D();
|
|
|
|
|
|
|
|
gunflashPos = start;
|
|
|
|
gunflashPos += CVector(-0.1f * ahead.x, -0.1f * ahead.y, 0.0f);
|
|
|
|
gunflashPos += CVector(0.06f * offset.x, 0.06f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
|
|
|
gunflashPos += CVector(0.04f * offset.x, 0.04f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.03f);
|
|
|
|
gunflashPos += CVector(0.03f * offset.x, 0.03f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
|
|
|
|
gunflashPos = start;
|
|
|
|
gunflashPos += CVector(-0.1f * ahead.x, -0.1f * ahead.y, 0.0f);
|
|
|
|
gunflashPos -= CVector(0.06f * offset.x, 0.06f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f);
|
|
|
|
gunflashPos -= CVector(0.04f * offset.x, 0.04f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.03f);
|
|
|
|
gunflashPos -= CVector(0.03f * offset.x, 0.03f * offset.y, 0.0f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.02f);
|
|
|
|
|
|
|
|
CVector gunsmokePos = start;
|
|
|
|
float rnd = CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x * rnd, ahead.y * rnd, 0.0f));
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
|
|
|
CWeapon::AddGunshell(CEntity *shooter, CVector const &source, CVector2D const &direction, float size)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
|
|
|
|
if ( shooter == nil)
|
2020-04-15 05:03:53 +00:00
|
|
|
return;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector dir(direction.x*0.05f, direction.y*0.05f, CGeneral::GetRandomNumberInRange(0.02f, 0.08f));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
static CVector prevEntityPosition(0.0f, 0.0f, 0.0f);
|
|
|
|
CVector entityPosition = shooter->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector diff = entityPosition - prevEntityPosition;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( Abs(diff.x)+Abs(diff.y)+Abs(diff.z) > 1.5f )
|
|
|
|
{
|
|
|
|
prevEntityPosition = entityPosition;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNSHELL_FIRST,
|
2020-04-15 16:43:16 +00:00
|
|
|
source, dir, nil, size, CGeneral::GetRandomNumberInRange(-20.0f, 20.0f));
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSHELL,
|
2020-04-15 16:43:16 +00:00
|
|
|
source, dir, nil, size, CGeneral::GetRandomNumberInRange(-20.0f, 20.0f));
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
|
|
|
CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
|
|
|
|
CVector *source, CVector *target, CColPoint *point, CVector2D ahead)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target!=nil);
|
|
|
|
ASSERT(point!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim )
|
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
if (shooter)
|
|
|
|
{
|
|
|
|
if (shooter && shooter->IsPed() && ((CPed*)shooter)->m_attachedTo == victim)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (shooter->IsPed() && !((CPed*)shooter)->IsPlayer())
|
|
|
|
{
|
|
|
|
CPed* shooterPed = (CPed*)shooter;
|
|
|
|
CEntity* guyWePointGun = shooterPed->m_pPointGunAt;
|
|
|
|
if (guyWePointGun)
|
|
|
|
{
|
|
|
|
if (victim != guyWePointGun)
|
|
|
|
{
|
|
|
|
float distWithAim = (guyWePointGun->GetPosition() - shooter->GetPosition()).Magnitude();
|
|
|
|
float distWithBullet = (point->point - shooter->GetPosition()).Magnitude();
|
|
|
|
if (distWithAim > 0.1f && distWithBullet > 0.1f)
|
|
|
|
{
|
|
|
|
// Normalize
|
|
|
|
CVector aimDir = (guyWePointGun->GetPosition() - shooter->GetPosition()) * (1.0f / distWithAim);
|
|
|
|
CVector bulletDir = (point->point - shooter->GetPosition()) * (1.0f / distWithBullet);
|
|
|
|
|
|
|
|
float dotProd = DotProduct(aimDir, bulletDir);
|
|
|
|
float aimAndBulletAngle;
|
|
|
|
if (dotProd <= 0.35f)
|
|
|
|
aimAndBulletAngle = PI;
|
|
|
|
else
|
|
|
|
aimAndBulletAngle = Acos(dotProd);
|
|
|
|
|
|
|
|
if (aimAndBulletAngle <= DEGTORAD(45.0f) && (aimAndBulletAngle <= DEGTORAD(15.0f) || distWithBullet / distWithAim >= 0.75f) && distWithBullet / distWithAim >= 0.99f)
|
|
|
|
{
|
|
|
|
shooterPed->bObstacleShowedUpDuringKillObjective = false;
|
|
|
|
shooterPed->m_shotTime = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shooterPed->bObstacleShowedUpDuringKillObjective = true;
|
|
|
|
shooterPed->m_shootTimer = 0;
|
|
|
|
shooterPed->m_shotTime = CTimer::GetTimeInMilliseconds();
|
|
|
|
if (distWithAim < 10.0f)
|
|
|
|
shooterPed->SetAttackTimer(1500);
|
|
|
|
else
|
|
|
|
shooterPed->SetAttackTimer(3000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
CGlass::WasGlassHitByBullet(victim, point->point);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 17:58:28 +00:00
|
|
|
CVector traceTarget = point->point;
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(source, &traceTarget, m_eWeaponType, shooter);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if (victim->IsPed() && shooter->IsVehicle() && ((CVehicle*)shooter)->pDriver)
|
|
|
|
shooter = ((CVehicle*)shooter)->pDriver;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( victim->IsPed() && shooter->IsPed() &&
|
|
|
|
(((CPed*)shooter)->m_nPedType != ((CPed*)victim)->m_nPedType || ((CPed*)shooter)->m_nPedType == PEDTYPE_PLAYER2 ||
|
|
|
|
!((CPed*)shooter)->IsGangMember() && ((CPed*)shooter)->m_nPedType != PEDTYPE_COP))
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CPed *victimPed = (CPed *)victim;
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( !victimPed->DyingOrDead() && victim != shooter )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector pos = victimPed->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector2D posOffset(source->x-pos.x, source->y-pos.y);
|
|
|
|
int32 localDir = victimPed->GetLocalDirection(posOffset);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
victimPed->ReactToAttack(shooter);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( !victimPed->IsPedInControl() || victimPed->bIsDucking )
|
|
|
|
{
|
|
|
|
victimPed->InflictDamage(shooter, m_eWeaponType, info->m_nDamage, (ePedPieceTypes)point->pieceB, localDir);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( victimPed->bCanBeShotInVehicle && (IsShotgun(m_eWeaponType) ||
|
|
|
|
(!victimPed->IsPlayer() && (m_eWeaponType == WEAPONTYPE_HELICANNON || m_eWeaponType == WEAPONTYPE_M60 || m_eWeaponType == WEAPONTYPE_PYTHON))))
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
posOffset.Normalise();
|
|
|
|
victimPed->bIsStanding = false;
|
|
|
|
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 5.0f);
|
|
|
|
victimPed->SetFall(1500, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->InflictDamage(shooter, m_eWeaponType, info->m_nDamage, (ePedPieceTypes)point->pieceB, localDir);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( victimPed->IsPlayer() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
CPlayerPed *victimPlayer = (CPlayerPed *)victimPed;
|
|
|
|
if ( victimPlayer->m_nHitAnimDelayTimer < CTimer::GetTimeInMilliseconds() && victimPed->m_nPedState != PED_DRIVING )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
victimPed->ClearAttackByRemovingAnim();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CAnimBlendAssociation *asoc = CAnimManager::AddAnimation(victimPed->GetClump(), ASSOCGRP_STD, AnimationId(ANIM_SHOT_FRONT_PARTIAL + localDir));
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(asoc!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
asoc->blendAmount = 0.0f;
|
|
|
|
asoc->blendDelta = 8.0f;
|
2020-06-17 18:24:59 +00:00
|
|
|
|
|
|
|
if ( m_eWeaponType == WEAPONTYPE_M4 )
|
|
|
|
victimPlayer->m_nHitAnimDelayTimer = CTimer::GetTimeInMilliseconds() + 2500;
|
|
|
|
else
|
|
|
|
victimPlayer->m_nHitAnimDelayTimer = CTimer::GetTimeInMilliseconds() + 1000;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-06-17 18:24:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
victimPed->ClearAttackByRemovingAnim();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
CAnimBlendAssociation *asoc = CAnimManager::AddAnimation(victimPed->GetClump(), ASSOCGRP_STD, AnimationId(ANIM_SHOT_FRONT_PARTIAL + localDir));
|
|
|
|
ASSERT(asoc!=nil);
|
|
|
|
|
|
|
|
asoc->blendAmount = 0.0f;
|
|
|
|
asoc->blendDelta = 8.0f;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-06-17 18:24:59 +00:00
|
|
|
|
|
|
|
victimPed->InflictDamage(shooter, m_eWeaponType, info->m_nDamage, (ePedPieceTypes)point->pieceB, localDir);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-06-17 18:24:59 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( victimPed->m_nPedType == PEDTYPE_COP )
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_COP, EVENT_ENTITY_PED, victim, (CPed*)shooter, 10000);
|
|
|
|
else
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_PED, EVENT_ENTITY_PED, victim, (CPed*)shooter, 10000);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( CGame::nastyGame )
|
|
|
|
{
|
|
|
|
uint8 bloodAmount = 8;
|
|
|
|
if ( IsShotgun(m_eWeaponType) || m_eWeaponType == WEAPONTYPE_HELICANNON )
|
|
|
|
bloodAmount = 32;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector dir = (point->point - victim->GetPosition()) * 0.01f;
|
|
|
|
dir.z = 0.01f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( victimPed->GetIsOnScreen() )
|
|
|
|
{
|
|
|
|
for ( uint8 i = 0; i < bloodAmount; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point->point, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_eWeaponType == WEAPONTYPE_MINIGUN)
|
|
|
|
{
|
|
|
|
CParticle::AddParticle(PARTICLE_TEST, point->point, CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
|
|
|
|
CParticle::AddParticle(PARTICLE_TEST, point->point + CVector(0.2f, -0.2f, 0.f), CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
|
|
|
|
CParticle::AddParticle(PARTICLE_TEST, point->point + CVector(-0.2f, 0.2f, 0.f), CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( CGame::nastyGame )
|
|
|
|
{
|
|
|
|
CVector dir = (point->point - victim->GetPosition()) * 0.01f;
|
|
|
|
dir.z = 0.01f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim->GetIsOnScreen() )
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 8; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point->point + CVector(0.0f, 0.0f, 0.15f), dir);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->Dead() )
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *asoc;
|
2020-05-09 07:50:00 +00:00
|
|
|
if ( RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FRONTAL) )
|
2020-04-15 05:03:53 +00:00
|
|
|
asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f);
|
|
|
|
else
|
|
|
|
asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( asoc )
|
|
|
|
{
|
|
|
|
asoc->SetCurrentTime(0.0f);
|
|
|
|
asoc->flags |= ASSOC_RUNNING;
|
|
|
|
asoc->flags &= ~ASSOC_FADEOUTWHENDONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 16; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-12 01:31:11 +00:00
|
|
|
#ifndef FIX_BUGS
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector dist = point->point - (*source);
|
2020-12-08 01:29:08 +00:00
|
|
|
float distMagnitude = dist.Magnitude();
|
|
|
|
CVector smokePos = point->point - Max(distMagnitude / 10.0f, 0.2f) * dist / distMagnitude;
|
2020-05-12 01:31:11 +00:00
|
|
|
#else
|
|
|
|
CVector smokePos = point->point;
|
|
|
|
#endif // !FIX_BUGS
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
|
|
|
smokePos.y += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
|
|
|
smokePos.z += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
2020-12-06 16:30:51 +00:00
|
|
|
if (point->pieceB >= CAR_PIECE_WHEEL_LF && point->pieceB <= CAR_PIECE_WHEEL_RR) {
|
2020-06-17 18:24:59 +00:00
|
|
|
((CVehicle*)victim)->BurstTyre(point->pieceB, true);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
for (int32 i = 0; i < 4; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, point->point, point->normal * 0.05f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
((CVehicle*)victim)->InflictDamage(shooter, m_eWeaponType, info->m_nDamage);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < 16; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal * 0.05f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-12 01:31:11 +00:00
|
|
|
#ifndef FIX_BUGS
|
2020-12-06 16:30:51 +00:00
|
|
|
CVector dist = point->point - (*source);
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector offset = dist - Max(0.2f * dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
|
2020-12-06 16:30:51 +00:00
|
|
|
CVector smokePos = *source + offset;
|
2020-05-12 01:31:11 +00:00
|
|
|
#else
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector smokePos = point->point;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter->IsPed() )
|
|
|
|
{
|
|
|
|
CPed *shooterPed = (CPed *)shooter;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooterPed->bNotAllowedToDuck )
|
|
|
|
{
|
|
|
|
if ( shooterPed->bKindaStayInSamePlace && victim != shooterPed->m_pPointGunAt )
|
|
|
|
{
|
|
|
|
shooterPed->bKindaStayInSamePlace = false;
|
|
|
|
shooterPed->m_duckAndCoverTimer = CTimer::GetTimeInMilliseconds() + 15000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 8; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CObject *victimObject = (CObject *)victim;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( !victimObject->bInfiniteMass && victimObject->m_fCollisionDamageMultiplier < 99.9f)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-10-18 14:15:49 +00:00
|
|
|
bool notStatic = !victimObject->GetIsStatic();
|
2020-06-17 18:24:59 +00:00
|
|
|
if (notStatic && victimObject->m_fUprootLimit <= 0.0f)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-10-18 13:40:06 +00:00
|
|
|
victimObject->SetIsStatic(false);
|
2020-04-15 05:03:53 +00:00
|
|
|
victimObject->AddToMovingList();
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-10-18 14:15:49 +00:00
|
|
|
notStatic = !victimObject->GetIsStatic();
|
2020-06-17 18:24:59 +00:00
|
|
|
if (!notStatic)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-17 18:24:59 +00:00
|
|
|
CVector moveForce = point->normal * -4.0f;
|
2020-04-15 05:03:53 +00:00
|
|
|
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
|
|
|
|
}
|
2020-06-17 18:24:59 +00:00
|
|
|
} else if (victimObject->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY) {
|
|
|
|
victimObject->ObjectDamage(50.f);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_1, point->point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_PED:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
|
|
|
|
((CPed*)victim)->Say(SOUND_PED_BULLET_HIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point->point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_DUMMY:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_3, point->point);
|
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(source, target, m_eWeaponType, shooter);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
CPad::GetPad(0)->StartShake_Distance(240, 128, FindPlayerPed()->GetPosition().x, FindPlayerPed()->GetPosition().y, FindPlayerPed()->GetPosition().z);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
BlowUpExplosiveThings(victim);
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
bool
|
|
|
|
CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(fireSource!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float heading = RADTODEG(shooter->GetForward().Heading());
|
|
|
|
float angle = DEGTORAD(heading);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D rotOffset(-Sin(angle), Cos(angle));
|
|
|
|
rotOffset.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunflashPos = *fireSource;
|
|
|
|
gunflashPos += CVector(rotOffset.x*0.1f, rotOffset.y*0.1f, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(rotOffset.x*0.1f, rotOffset.y*0.1f, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.15f);
|
2020-04-15 05:03:53 +00:00
|
|
|
gunflashPos += CVector(rotOffset.x*0.1f, rotOffset.y*0.1f, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.2f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, *fireSource, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector gunsmokePos = *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(rotOffset.x*0.10f, rotOffset.y*0.10f, 0.0f), nil, 0.1f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(rotOffset.x*0.15f, rotOffset.y*0.15f, 0.0f), nil, 0.1f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(rotOffset.x*0.20f, rotOffset.y*0.20f, 0.0f), nil, 0.1f);
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(rotOffset.x*0.25f, rotOffset.y*0.25f, 0.0f), nil, 0.1f);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, shooter, (CPed*)shooter, 1000);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT, *fireSource, CVector(0.0, 0.0, 0.0), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float shooterAngle;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
if ( shooter->IsPed() && ((CPed*)shooter)->m_pPointGunAt != nil )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CEntity *threatAttack = ((CPed*)shooter)->m_pPointGunAt;
|
|
|
|
shooterAngle = CGeneral::GetAngleBetweenPoints(threatAttack->GetPosition().x, threatAttack->GetPosition().y,
|
|
|
|
(*fireSource).x, (*fireSource).y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
shooterAngle = RADTODEG(shooter->GetForward().Heading());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
int shootsAtOnce;
|
|
|
|
int checkObstacleOnShootNo;
|
|
|
|
float angleRange;
|
|
|
|
switch (m_eWeaponType) {
|
|
|
|
case WEAPONTYPE_SHOTGUN:
|
|
|
|
angleRange = DEGTORAD(9.0f);
|
|
|
|
checkObstacleOnShootNo = 1;
|
|
|
|
shootsAtOnce = 3;
|
|
|
|
break;
|
|
|
|
case WEAPONTYPE_SPAS12_SHOTGUN:
|
|
|
|
angleRange = DEGTORAD(6.0f);
|
|
|
|
checkObstacleOnShootNo = 1;
|
|
|
|
shootsAtOnce = 3;
|
|
|
|
break;
|
|
|
|
case WEAPONTYPE_STUBBY_SHOTGUN:
|
|
|
|
angleRange = DEGTORAD(18.0f);
|
|
|
|
checkObstacleOnShootNo = 2;
|
|
|
|
shootsAtOnce = 5;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bool statUpdated = false;
|
|
|
|
float halfAngleRange = angleRange / 2.f;
|
|
|
|
float angleBetweenTwoShot = angleRange / (shootsAtOnce - 1.f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
for ( int32 i = 0; i < shootsAtOnce; i++ )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
float shootAngle = DEGTORAD(RADTODEG(halfAngleRange - angleBetweenTwoShot * i) + shooterAngle);
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D shootRot(-Sin(shootAngle), Cos(shootAngle));
|
2020-08-27 16:52:43 +00:00
|
|
|
shootRot.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source, target;
|
|
|
|
CColPoint point;
|
|
|
|
CEntity *victim;
|
|
|
|
|
|
|
|
if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() )
|
|
|
|
{
|
|
|
|
TheCamera.Find3rdPersonCamTargetVector(1.0f, *fireSource, source, target);
|
|
|
|
CVector Left = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Front, TheCamera.Cams[TheCamera.ActiveCam].Up);
|
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
float f = (i - (shootsAtOnce / 2)) * angleBetweenTwoShot;
|
2020-04-15 05:03:53 +00:00
|
|
|
target = f * Left + target - source;
|
|
|
|
target *= info->m_fRange;
|
|
|
|
target += source;
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeCarTyres = true;
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
|
|
|
CWorld::bIncludeDeadPeds = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-05-23 13:53:20 +00:00
|
|
|
CWorld::bIncludeDeadPeds = false;
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeCarTyres = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target = *fireSource;
|
|
|
|
target.x += shootRot.x * info->m_fRange;
|
|
|
|
target.y += shootRot.y * info->m_fRange;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter->IsPed() )
|
|
|
|
{
|
|
|
|
CPed *shooterPed = (CPed *)shooter;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
if ( shooterPed->m_pPointGunAt == nil )
|
2020-04-15 05:03:53 +00:00
|
|
|
DoDoomAiming(shooter, fireSource, &target);
|
|
|
|
else
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
CVector pos;
|
|
|
|
if (shooterPed->m_pPointGunAt->IsPed()) {
|
2020-12-18 00:58:09 +00:00
|
|
|
((CPed*)shooterPed->m_pPointGunAt)->m_pedIK.GetComponentPosition(pos, PED_MID);
|
2020-05-23 13:53:20 +00:00
|
|
|
} else {
|
|
|
|
pos = ((CPed*)shooterPed->m_pPointGunAt)->GetPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
float distToTarget = (pos - (*fireSource)).Magnitude2D();
|
|
|
|
target.z += info->m_fRange / distToTarget * (pos.z - target.z);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-23 13:53:20 +00:00
|
|
|
if (shooter == FindPlayerPed())
|
|
|
|
CWorld::bIncludeDeadPeds = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2021-01-13 19:09:53 +00:00
|
|
|
ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false);
|
2020-05-23 13:53:20 +00:00
|
|
|
CWorld::bIncludeDeadPeds = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim )
|
|
|
|
{
|
|
|
|
CGlass::WasGlassHitByBullet(victim, point.point);
|
2020-05-23 13:53:20 +00:00
|
|
|
CWeapon::BlowUpExplosiveThings(victim);
|
|
|
|
if (i == checkObstacleOnShootNo)
|
|
|
|
{
|
|
|
|
if (shooter)
|
|
|
|
{
|
|
|
|
if (shooter->IsPed() && !((CPed*)shooter)->IsPlayer())
|
|
|
|
{
|
|
|
|
CPed *shooterPed = (CPed*)shooter;
|
|
|
|
CEntity *guyWePointGun = shooterPed->m_pPointGunAt;
|
|
|
|
if (guyWePointGun)
|
|
|
|
{
|
|
|
|
if (victim != guyWePointGun)
|
|
|
|
{
|
|
|
|
float distWithAim = (guyWePointGun->GetPosition() - shooter->GetPosition()).Magnitude();
|
|
|
|
float distWithBullet = (point.point - shooter->GetPosition()).Magnitude();
|
|
|
|
if (distWithAim > 0.1f && distWithBullet > 0.1f)
|
|
|
|
{
|
|
|
|
// Normalize
|
|
|
|
CVector aimDir = (guyWePointGun->GetPosition() - shooter->GetPosition()) * (1.0f / distWithAim);
|
|
|
|
CVector bulletDir = (point.point - shooter->GetPosition()) * (1.0f / distWithBullet);
|
|
|
|
|
|
|
|
float dotProd = DotProduct(aimDir, bulletDir);
|
|
|
|
float aimAndBulletAngle;
|
|
|
|
if (dotProd <= 0.35f)
|
|
|
|
aimAndBulletAngle = PI;
|
|
|
|
else
|
|
|
|
aimAndBulletAngle = Acos(dotProd);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
if (aimAndBulletAngle <= DEGTORAD(45.0f) && (aimAndBulletAngle <= DEGTORAD(15.0f) || distWithBullet / distWithAim >= 0.75f) && distWithBullet / distWithAim >= 0.99f)
|
|
|
|
{
|
|
|
|
shooterPed->bObstacleShowedUpDuringKillObjective = false;
|
|
|
|
shooterPed->m_shotTime = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shooterPed->bObstacleShowedUpDuringKillObjective = true;
|
|
|
|
shooterPed->m_shootTimer = 0;
|
|
|
|
shooterPed->m_shotTime = CTimer::GetTimeInMilliseconds();
|
2020-06-17 18:24:59 +00:00
|
|
|
if (distWithAim < 10.0f)
|
2020-05-23 13:53:20 +00:00
|
|
|
shooterPed->SetAttackTimer(1500);
|
2020-06-17 18:24:59 +00:00
|
|
|
else
|
|
|
|
shooterPed->SetAttackTimer(3000);
|
2020-05-23 13:53:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(fireSource, &point.point, m_eWeaponType, shooter);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim->IsPed() )
|
|
|
|
{
|
|
|
|
CPed *victimPed = (CPed *)victim;
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( !victimPed->DyingOrDead() && victim != shooter )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
bool cantStandup = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector pos = victimPed->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D posOffset((*fireSource).x-pos.x, (*fireSource).y-pos.y);
|
|
|
|
int32 localDir = victimPed->GetLocalDirection(posOffset);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->ReactToAttack(FindPlayerPed());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
posOffset.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( victimPed->m_getUpTimer > (CTimer::GetTimeInMilliseconds() - 3000) ||
|
|
|
|
!victimPed->bCanBeShotInVehicle)
|
2020-04-15 05:03:53 +00:00
|
|
|
cantStandup = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->bIsStanding && cantStandup )
|
|
|
|
{
|
|
|
|
victimPed->bIsStanding = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-6.0f, posOffset.y*-6.0f, 5.0f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
victimPed->ApplyMoveForce(posOffset.x*-2.0f, posOffset.y*-2.0f, 0.0f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( cantStandup )
|
|
|
|
victimPed->SetFall(1500, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-12 19:48:28 +00:00
|
|
|
victimPed->InflictDamage(shooter, m_eWeaponType, info->m_nDamage, (ePedPieceTypes)point.pieceB, localDir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->m_nPedType == PEDTYPE_COP )
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_COP, EVENT_ENTITY_PED, victim, (CPed*)shooter, 10000);
|
|
|
|
else
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_PED, EVENT_ENTITY_PED, victim, (CPed*)shooter, 10000);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( CGame::nastyGame )
|
|
|
|
{
|
|
|
|
uint8 bloodAmount = 8;
|
2020-05-23 15:04:33 +00:00
|
|
|
if ( IsShotgun(m_eWeaponType) )
|
2020-04-15 05:03:53 +00:00
|
|
|
bloodAmount = 32;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector dir = (point.point - victim->GetPosition()) * 0.01f;
|
|
|
|
dir.z = 0.01f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->GetIsOnScreen() )
|
|
|
|
{
|
|
|
|
for ( uint8 i = 0; i < bloodAmount; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point.point, dir);
|
|
|
|
}
|
|
|
|
}
|
2020-05-23 13:53:20 +00:00
|
|
|
} else {
|
|
|
|
if (CGame::nastyGame)
|
|
|
|
{
|
|
|
|
CVector dir = (point.point - victim->GetPosition()) * 0.01f;
|
|
|
|
dir.z = 0.01f;
|
|
|
|
|
|
|
|
if (victimPed->GetIsOnScreen())
|
|
|
|
{
|
|
|
|
for (uint8 i = 0; i < 8; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point.point + CVector(0.0f, 0.0f, 0.15f), dir);
|
|
|
|
}
|
|
|
|
if (victimPed->Dead())
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *hitAssoc;
|
|
|
|
if (RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FRONTAL))
|
|
|
|
{
|
|
|
|
hitAssoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hitAssoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f);
|
|
|
|
}
|
|
|
|
if (hitAssoc)
|
|
|
|
{
|
|
|
|
hitAssoc->SetCurrentTime(0.0f);
|
|
|
|
hitAssoc->SetRun();
|
|
|
|
hitAssoc->flags &= ~ASSOC_DELETEFADEDOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-04-15 16:43:16 +00:00
|
|
|
{
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
2020-12-06 16:30:51 +00:00
|
|
|
if (point.pieceB >= CAR_PIECE_WHEEL_LF && point.pieceB <= CAR_PIECE_WHEEL_RR) {
|
2020-05-24 13:14:27 +00:00
|
|
|
((CVehicle*)victim)->BurstTyre(point.pieceB, true);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
for (int32 i = 0; i < 4; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, point.point, point.normal * 0.05f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
((CVehicle*)victim)->InflictDamage(shooter, m_eWeaponType, info->m_nDamage);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < 16; i++)
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal * 0.05f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-12 01:31:11 +00:00
|
|
|
#ifndef FIX_BUGS
|
2020-05-23 13:53:20 +00:00
|
|
|
CVector dist = point.point - (*fireSource);
|
|
|
|
CVector offset = dist - Max(0.2f * dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
|
|
|
|
CVector smokePos = *fireSource + offset;
|
2020-05-12 01:31:11 +00:00
|
|
|
#else
|
2020-05-23 13:53:20 +00:00
|
|
|
CVector smokePos = point.point;
|
2020-05-12 01:31:11 +00:00
|
|
|
#endif
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 16; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal*0.05f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-05-12 01:31:11 +00:00
|
|
|
#ifndef FIX_BUGS
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector dist = point.point - (*fireSource);
|
2020-04-19 16:34:08 +00:00
|
|
|
CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
|
2020-05-12 01:31:11 +00:00
|
|
|
CVector smokePos = *fireSource + offset;
|
|
|
|
#else
|
|
|
|
CVector smokePos = point.point;
|
|
|
|
#endif
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
|
|
|
smokePos.y += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
|
|
|
smokePos.z += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim->IsObject() )
|
|
|
|
{
|
|
|
|
CObject *victimObject = (CObject *)victim;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !victimObject->bInfiniteMass )
|
|
|
|
{
|
2020-10-18 14:15:49 +00:00
|
|
|
bool notStatic = !victimObject->GetIsStatic();
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( notStatic && victimObject->m_fUprootLimit <= 0.0f )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-10-18 13:40:06 +00:00
|
|
|
victimObject->SetIsStatic(false);
|
2020-04-15 05:03:53 +00:00
|
|
|
victimObject->AddToMovingList();
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-10-18 14:15:49 +00:00
|
|
|
notStatic = !victimObject->GetIsStatic();
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( !notStatic )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CVector moveForce = point.normal*-5.0f;
|
|
|
|
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_1, point.point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
if (!statUpdated) {
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-05-23 13:53:20 +00:00
|
|
|
statUpdated = true;
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_PED:
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
if (!statUpdated) {
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-05-23 13:53:20 +00:00
|
|
|
statUpdated = true;
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
|
|
|
|
((CPed*)victim)->Say(SOUND_PED_BULLET_HIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
if (!statUpdated) {
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-05-23 13:53:20 +00:00
|
|
|
statUpdated = true;
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point.point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_DUMMY:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_3, point.point);
|
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CVector traceTarget = *fireSource;
|
2020-04-19 16:34:08 +00:00
|
|
|
traceTarget += (target - (*fireSource)) * Min(info->m_fRange, 30.0f) / info->m_fRange;
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(fireSource, &traceTarget, m_eWeaponType, shooter);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
CPad::GetPad(0)->StartShake_Distance(240, 128, FindPlayerPed()->GetPosition().x, FindPlayerPed()->GetPosition().y, FindPlayerPed()->GetPosition().z);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CWeapon::FireProjectile(CEntity *shooter, CVector *fireSource, float power)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(fireSource!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source, target;
|
2020-05-15 14:30:25 +00:00
|
|
|
eWeaponType projectileType = m_eWeaponType;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER )
|
|
|
|
{
|
|
|
|
source = *fireSource;
|
2020-05-15 14:30:25 +00:00
|
|
|
projectileType = WEAPONTYPE_ROCKET;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter->IsPed() && ((CPed*)shooter)->IsPlayer() )
|
|
|
|
{
|
|
|
|
int16 mode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
|
|
|
|
if (!( mode == CCam::MODE_M16_1STPERSON
|
|
|
|
|| mode == CCam::MODE_SNIPER
|
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER
|
|
|
|
|| mode == CCam::MODE_M16_1STPERSON_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_SNIPER_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
*fireSource += TheCamera.Cams[TheCamera.ActiveCam].Front;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*fireSource += shooter->GetForward();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
target = *fireSource;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float dot = DotProduct(*fireSource-shooter->GetPosition(), shooter->GetForward());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( dot < 0.3f )
|
|
|
|
*fireSource += (0.3f-dot) * shooter->GetForward();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
target = *fireSource;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( target.z - shooter->GetPosition().z > 0.0f )
|
|
|
|
target += 0.6f*shooter->GetForward();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
source = *fireSource - shooter->GetPosition();
|
|
|
|
|
|
|
|
source = *fireSource - DotProduct(source, shooter->GetForward()) * shooter->GetForward();
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !CWorld::GetIsLineOfSightClear(source, target, true, true, false, true, false, false, false) )
|
|
|
|
{
|
|
|
|
if ( m_eWeaponType != WEAPONTYPE_GRENADE )
|
2020-05-15 14:30:25 +00:00
|
|
|
CProjectileInfo::RemoveNotAdd(shooter, projectileType, *fireSource);
|
2020-04-15 05:03:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( shooter->IsPed() )
|
|
|
|
{
|
|
|
|
source = shooter->GetPosition() - shooter->GetForward();
|
|
|
|
source.z -= 0.4f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
if ( !CWorld::TestSphereAgainstWorld(source, 0.5f, nil, false, false, true, false, false, false) )
|
2020-05-15 14:30:25 +00:00
|
|
|
CProjectileInfo::AddProjectile(shooter, WEAPONTYPE_GRENADE, source, 0.0f);
|
2020-04-15 05:03:53 +00:00
|
|
|
else
|
2020-05-15 14:30:25 +00:00
|
|
|
CProjectileInfo::RemoveNotAdd(shooter, WEAPONTYPE_GRENADE, *fireSource);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-05-15 14:30:25 +00:00
|
|
|
CProjectileInfo::AddProjectile(shooter, projectileType, *fireSource, power);
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
CWorld::pIgnoreEntity = nil;
|
|
|
|
|
|
|
|
if ( shooter->IsPed() )
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, shooter, (CPed *)shooter, 1000);
|
|
|
|
else if ( shooter->IsVehicle() && ((CVehicle*)shooter)->pDriver )
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_VEHICLE, shooter, ((CVehicle*)shooter)->pDriver, 1000);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::GenerateFlameThrowerParticles(CVector pos, CVector dir)
|
|
|
|
{
|
|
|
|
dir *= 0.7f;
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos, dir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
dir *= 0.7f;
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos, dir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
dir *= 0.7f;
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos, dir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
dir *= 0.7f;
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos, dir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
dir *= 0.7f;
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CWeapon::FireAreaEffect(CEntity *shooter, CVector *fireSource)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(fireSource!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float heading = RADTODEG(shooter->GetForward().Heading());
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source;
|
|
|
|
CVector target;
|
|
|
|
CVector dir;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() )
|
|
|
|
{
|
|
|
|
TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target);
|
|
|
|
float norm = (1.0f / info->m_fRange);
|
2020-04-15 16:43:16 +00:00
|
|
|
dir = (target - source) * norm;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float angle = DEGTORAD(heading);
|
|
|
|
dir = CVector(-Sin(angle)*0.5f, Cos(angle)*0.5f, 0.0f);
|
|
|
|
target = *fireSource + dir;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CShotInfo::AddShot(shooter, m_eWeaponType, *fireSource, target);
|
|
|
|
CWeapon::GenerateFlameThrowerParticles(*fireSource, dir);
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( shooter == (CEntity *)FindPlayerPed() )
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < FindPlayerPed()->m_numNearPeds; i++ )
|
|
|
|
{
|
|
|
|
if ( FindPlayerPed()->m_nearPeds[i]->CharCreatedBy == RANDOM_CHAR )
|
|
|
|
{
|
|
|
|
if ( FindPlayerPed()->m_nearPeds[i]->IsPedInControl() && FindPlayerPed()->m_nearPeds[i]->m_nPedState != PED_FLEE_ENTITY )
|
|
|
|
FindPlayerPed()->m_nearPeds[i]->SetFlee(shooter, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
bool
|
|
|
|
CWeapon::LaserScopeDot(CVector *pOutPos, float *pOutSize)
|
|
|
|
{
|
|
|
|
CWeaponInfo *info = GetInfo();
|
|
|
|
|
|
|
|
float range = info->m_fRange;
|
|
|
|
|
|
|
|
CVector source, target;
|
|
|
|
CEntity *foundEnt = nil;
|
|
|
|
CColPoint foundCol;
|
|
|
|
|
|
|
|
source = 0.5f * TheCamera.Cams[TheCamera.ActiveCam].Front + TheCamera.Cams[TheCamera.ActiveCam].Source;
|
|
|
|
target = TheCamera.Cams[TheCamera.ActiveCam].Front;
|
|
|
|
target.Normalise();
|
|
|
|
target *= range;
|
|
|
|
target += source;
|
|
|
|
|
|
|
|
if ( CWorld::ProcessLineOfSight(source, target, foundCol, foundEnt, true, true, true, true, false, false, false) )
|
|
|
|
{
|
|
|
|
CVector pos = foundCol.point;
|
|
|
|
float w, h;
|
|
|
|
|
2020-12-18 00:58:09 +00:00
|
|
|
if ( CSprite::CalcScreenCoors(foundCol.point, &pos, &w, &h, true) )
|
2020-08-27 16:52:43 +00:00
|
|
|
{
|
|
|
|
*pOutPos = pos;
|
|
|
|
*pOutSize = w * 0.05f;
|
|
|
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 7, 128, 0, 0, 255, pos, 1.2f, 50.0f, CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
bool
|
|
|
|
CWeapon::FireSniper(CEntity *shooter)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( (CEntity *)FindPlayerPed() == shooter )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
int16 mode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
|
|
|
|
if (!( mode == CCam::MODE_M16_1STPERSON
|
|
|
|
|| mode == CCam::MODE_SNIPER
|
|
|
|
|| mode == CCam::MODE_CAMERA
|
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER
|
|
|
|
|| mode == CCam::MODE_M16_1STPERSON_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_SNIPER_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2021-01-14 22:16:42 +00:00
|
|
|
#ifdef SECUROM
|
|
|
|
if (sniperPirateCheck){
|
|
|
|
// if not pirated game
|
|
|
|
// sniperPirateCheck = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
#ifndef FIX_BUGS
|
|
|
|
CWeaponInfo *info = GetInfo(); //unused
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CCam *cam = &TheCamera.Cams[TheCamera.ActiveCam];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(cam!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source = cam->Source;
|
|
|
|
CVector dir = cam->Front;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( DotProduct(dir, CVector(0.0f, -0.9894f, 0.145f)) > 0.997f )
|
2020-05-12 14:27:26 +00:00
|
|
|
CCoronas::MoonSize = (CCoronas::MoonSize+1) & 7;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
dir.Normalise();
|
|
|
|
dir *= 16.0f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2021-01-14 22:16:42 +00:00
|
|
|
#ifdef SECUROM
|
|
|
|
if (sniperPirateCheck) return true;
|
|
|
|
#endif
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CBulletInfo::AddBullet(shooter, m_eWeaponType, source, dir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
{
|
|
|
|
CPad::GetPad(0)->StartShake_Distance(240, 128,
|
|
|
|
FindPlayerPed()->GetPosition().x,
|
|
|
|
FindPlayerPed()->GetPosition().y,
|
|
|
|
FindPlayerPed()->GetPosition().z);
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
CParticle::HandleShootableBirdsStuff(shooter, source);
|
2020-04-15 05:03:53 +00:00
|
|
|
|
|
|
|
CamShakeNoPos(&TheCamera, 0.2f);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( shooter->IsPed() )
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, shooter, (CPed*)shooter, 1000);
|
|
|
|
else if ( shooter->IsVehicle() && ((CVehicle*)shooter)->pDriver )
|
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_VEHICLE, shooter, ((CVehicle*)shooter)->pDriver, 1000);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
bool
|
|
|
|
CWeapon::TakePhotograph(CEntity *shooter)
|
|
|
|
{
|
|
|
|
if ( TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_CAMERA )
|
|
|
|
{
|
|
|
|
CSpecialFX::bSnapShotActive = true;
|
|
|
|
CSpecialFX::SnapShotFrames = 0;
|
|
|
|
CStats::PhotosTaken++;
|
|
|
|
bPhotographHasBeenTaken = true;
|
|
|
|
|
|
|
|
for ( int32 i = CPools::GetPedPool()->GetSize() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
CPed *ped = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if ( ped )
|
|
|
|
{
|
|
|
|
if ( (ped->GetPosition() - TheCamera.GetPosition()).Magnitude() < 125.0f )
|
|
|
|
{
|
|
|
|
CVector pedPos = ped->GetPosition();
|
|
|
|
pedPos.z += 0.8f;
|
|
|
|
|
|
|
|
CVector pos;
|
|
|
|
float w, h;
|
|
|
|
|
2020-12-18 00:58:09 +00:00
|
|
|
if ( CSprite::CalcScreenCoors(pedPos, &pos, &w, &h, false) )
|
2020-08-27 16:52:43 +00:00
|
|
|
{
|
|
|
|
if ( SCREEN_WIDTH * 0.1f < pos.x && SCREEN_WIDTH * 0.9f > pos.x
|
|
|
|
&& SCREEN_HEIGHT * 0.1f < pos.y && SCREEN_HEIGHT * 0.9f > pos.y )
|
|
|
|
{
|
|
|
|
CVector source, target;
|
|
|
|
CEntity *foundEnt = nil;
|
|
|
|
CColPoint foundCol;
|
|
|
|
|
|
|
|
target = pedPos;
|
|
|
|
source = TheCamera.GetForward() * 2.0f + TheCamera.GetPosition();
|
|
|
|
|
|
|
|
if ( CWorld::ProcessLineOfSight(source, target, foundCol, foundEnt, true, true, true, true, true, true, false) )
|
|
|
|
{
|
|
|
|
if ( foundEnt != (CEntity*)ped )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ped->bHasBeenPhotographed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
bool
|
|
|
|
CWeapon::FireM16_1stPerson(CEntity *shooter)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int16 mode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if (!( mode == CCam::MODE_M16_1STPERSON
|
|
|
|
|| mode == CCam::MODE_SNIPER
|
2020-05-29 19:05:33 +00:00
|
|
|
|| mode == CCam::MODE_CAMERA
|
2020-04-15 05:03:53 +00:00
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER
|
|
|
|
|| mode == CCam::MODE_M16_1STPERSON_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_SNIPER_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT
|
|
|
|
|| mode == CCam::MODE_HELICANNON_1STPERSON) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeCarTyres = true;
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = true;
|
2020-06-20 13:23:32 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CColPoint point;
|
|
|
|
CEntity *victim;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::pIgnoreEntity = shooter;
|
|
|
|
CWorld::bIncludeDeadPeds = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CCam *cam = &TheCamera.Cams[TheCamera.ActiveCam];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(cam!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source = cam->Source;
|
|
|
|
CVector target = cam->Front*info->m_fRange + source;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2021-01-13 19:09:53 +00:00
|
|
|
if (ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, true, false)) {
|
2020-06-20 13:23:32 +00:00
|
|
|
CheckForShootingVehicleOccupant(&victim, &point, m_eWeaponType, source, target);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
CWorld::pIgnoreEntity = nil;
|
2020-06-20 13:23:32 +00:00
|
|
|
CWorld::bIncludeDeadPeds = false;
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::bIncludeCarTyres = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D front(cam->Front.x, cam->Front.y);
|
|
|
|
front.Normalise();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
DoBulletImpact(shooter, victim, &source, &target, &point, front);
|
|
|
|
|
|
|
|
CVector bulletPos;
|
2020-05-15 14:30:25 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( CHeli::TestBulletCollision(&source, &target, &bulletPos, (m_eWeaponType == WEAPONTYPE_M60 || m_eWeaponType == WEAPONTYPE_HELICANNON ? 20 : 4)) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 16; i++ )
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK, bulletPos, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerPed() )
|
|
|
|
{
|
2020-05-15 14:30:25 +00:00
|
|
|
float mult;
|
|
|
|
switch (m_eWeaponType) {
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_M4:
|
2020-05-15 14:30:25 +00:00
|
|
|
mult = 0.0003f;
|
|
|
|
break;
|
2020-05-23 13:53:20 +00:00
|
|
|
case WEAPONTYPE_RUGER:
|
2020-05-15 14:30:25 +00:00
|
|
|
mult = 0.00015f;
|
|
|
|
break;
|
2020-06-20 13:23:32 +00:00
|
|
|
case WEAPONTYPE_HELICANNON:
|
|
|
|
case WEAPONTYPE_M60:
|
|
|
|
mult = 0.0003f;
|
|
|
|
break;
|
2020-05-15 14:30:25 +00:00
|
|
|
default:
|
|
|
|
mult = 0.0002f;
|
|
|
|
break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-05-15 14:30:25 +00:00
|
|
|
|
|
|
|
if (FindPlayerPed()->bIsDucking || FindPlayerPed()->m_attachedTo)
|
|
|
|
mult *= 0.3f;
|
|
|
|
|
|
|
|
TheCamera.Cams[TheCamera.ActiveCam].Beta += float((CGeneral::GetRandomNumber() & 127) - 64) * mult;
|
|
|
|
TheCamera.Cams[TheCamera.ActiveCam].Alpha += float((CGeneral::GetRandomNumber() & 127) - 64) * mult;
|
2020-06-20 13:23:32 +00:00
|
|
|
|
|
|
|
// yes, double
|
|
|
|
double notFiringRate = (20.0 - info->m_nFiringRate) / 80.0;
|
|
|
|
double raisedNotFiringRate = Max(1.0, Max(0.0, notFiringRate));
|
|
|
|
|
|
|
|
uint8 shakeFreq = 80.0 * raisedNotFiringRate + 130.0;
|
|
|
|
CPad::GetPad(0)->StartShake(20000.0f * CTimer::GetTimeStep() / shakeFreq, shakeFreq);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-06-06 22:01:48 +00:00
|
|
|
CWeapon::FireInstantHitFromCar(CVehicle *shooter, bool left, bool right)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVehicleModelInfo *modelInfo = shooter->GetModelInfo();
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source, target;
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( shooter->IsBike() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( shooter->pDriver )
|
|
|
|
{
|
|
|
|
source = info->m_vecFireOffset;
|
|
|
|
|
|
|
|
shooter->pDriver->TransformToNode(source, PED_HANDR);
|
|
|
|
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
|
|
|
|
|
|
|
|
if ( left )
|
|
|
|
target = source - info->m_fRange * shooter->GetRight();
|
|
|
|
else if ( right )
|
|
|
|
target = source + info->m_fRange * shooter->GetRight();
|
|
|
|
else
|
2020-08-27 17:27:28 +00:00
|
|
|
target = source + info->m_fRange * shooter->GetForward();
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if ( left )
|
|
|
|
{
|
|
|
|
source = shooter->GetMatrix() * CVector(-shooter->GetColModel()->boundingBox.max.x + -0.25f,
|
|
|
|
float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y - 0.05f,
|
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.63f);
|
|
|
|
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
|
|
|
|
|
|
|
|
|
|
|
|
target = shooter->GetMatrix() * CVector(-info->m_fRange,
|
|
|
|
modelInfo->GetFrontSeatPosn().y,
|
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.6f);
|
|
|
|
}
|
|
|
|
else if ( right )
|
|
|
|
{
|
|
|
|
source = shooter->GetMatrix() * CVector(shooter->GetColModel()->boundingBox.max.x + 0.25f,
|
|
|
|
float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y - 0.18f,
|
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.52f);
|
|
|
|
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
|
|
|
|
|
|
|
|
target = shooter->GetMatrix() * CVector(info->m_fRange,
|
|
|
|
modelInfo->GetFrontSeatPosn().y,
|
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.5f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
source = shooter->GetMatrix() * CVector(float(CGeneral::GetRandomNumber() & 255) * 0.001f + -0.4f,
|
|
|
|
modelInfo->GetFrontSeatPosn().y + shooter->GetColModel()->boundingBox.max.y + 0.2f,
|
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.55f);
|
|
|
|
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
|
|
|
|
|
|
|
|
target = shooter->GetMatrix() * CVector(0.0f,
|
|
|
|
info->m_fRange,
|
2020-06-02 21:35:20 +00:00
|
|
|
modelInfo->GetFrontSeatPosn().z + 0.5f);
|
2020-08-27 16:52:43 +00:00
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
if ( left )
|
|
|
|
source = info->m_vecFireOffset;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
source = 1.8f * info->m_vecFireOffset;
|
|
|
|
source.z -= 0.1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
shooter->pDriver->TransformToNode(source, PED_HANDR);
|
2020-04-15 05:03:53 +00:00
|
|
|
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
if ( left )
|
|
|
|
target = source - info->m_fRange * shooter->GetRight();
|
|
|
|
else
|
|
|
|
target = source + info->m_fRange * shooter->GetRight();
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
target += CVector(float(CGeneral::GetRandomNumber()&255)*0.01f-1.28f,
|
|
|
|
float(CGeneral::GetRandomNumber()&255)*0.01f-1.28f,
|
|
|
|
float(CGeneral::GetRandomNumber()&255)*0.01f-1.28f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
DoDriveByAutoAiming(FindPlayerPed(), shooter, &source, &target);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, FindPlayerPed(), FindPlayerPed(), 1000);
|
|
|
|
|
|
|
|
if ( !TheCamera.GetLookingLRBFirstPerson() )
|
2020-08-27 16:52:43 +00:00
|
|
|
{
|
|
|
|
if ( !shooter->IsBike() )
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, source, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
else
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, source, 1.4f*shooter->m_vecMoveSpeed);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
else
|
2020-08-27 16:52:43 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, source, 1.6f*shooter->m_vecMoveSpeed, nil, 0.18f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_VEHICLE, shooter, FindPlayerPed(), 1000);
|
|
|
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT, source, CVector(0.0f, 0.0f, 0.0f), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
|
|
|
|
|
|
|
CColPoint point;
|
|
|
|
CEntity *victim;
|
2020-08-27 16:52:43 +00:00
|
|
|
|
|
|
|
CWorld::bIncludeBikers = true;
|
|
|
|
CWorld::pIgnoreEntity = shooter;
|
2020-04-15 05:03:53 +00:00
|
|
|
ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, true, false);
|
2020-08-27 16:52:43 +00:00
|
|
|
CWorld::pIgnoreEntity = NULL;
|
|
|
|
CWorld::bIncludeBikers = false;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !(CTimer::GetFrameCounter() & 3) )
|
|
|
|
MakePedsJumpAtShot(shooter, &source, &target);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim )
|
|
|
|
{
|
|
|
|
CVector traceTarget = point.point;
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(&source, &traceTarget, m_eWeaponType, shooter);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim->IsPed() )
|
|
|
|
{
|
|
|
|
CPed *victimPed = (CPed*)victim;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( !victimPed->DyingOrDead() && victim != (CEntity *)shooter )
|
|
|
|
{
|
|
|
|
CVector pos = victimPed->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D posOffset(source.x-pos.x, source.y-pos.y);
|
|
|
|
int32 localDir = victimPed->GetLocalDirection(posOffset);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->ReactToAttack(FindPlayerPed());
|
|
|
|
victimPed->ClearAttackByRemovingAnim();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CAnimBlendAssociation *asoc = CAnimManager::AddAnimation(victimPed->GetClump(), ASSOCGRP_STD, AnimationId(ANIM_SHOT_FRONT_PARTIAL + localDir));
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(asoc!=nil);
|
2020-04-15 05:03:53 +00:00
|
|
|
asoc->blendAmount = 0.0f;
|
|
|
|
asoc->blendDelta = 8.0f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->InflictDamage(shooter, WEAPONTYPE_UZI_DRIVEBY, 3*info->m_nDamage, (ePedPieceTypes)point.pieceB, localDir);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
pos.z += 0.8f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->GetIsOnScreen() )
|
|
|
|
{
|
|
|
|
if ( CGame::nastyGame )
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 4; i++ )
|
|
|
|
{
|
|
|
|
CVector dir;
|
|
|
|
dir.x = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
dir.y = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, pos, dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->m_nPedType == PEDTYPE_COP )
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_COP, EVENT_ENTITY_PED, victimPed, FindPlayerPed(), 10000);
|
|
|
|
else
|
|
|
|
CEventList::RegisterEvent(EVENT_SHOOT_PED, EVENT_ENTITY_PED, victimPed, FindPlayerPed(), 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( victim->IsVehicle() )
|
|
|
|
((CVehicle *)victim)->InflictDamage(FindPlayerPed(), WEAPONTYPE_UZI_DRIVEBY, info->m_nDamage);
|
|
|
|
else
|
|
|
|
CGlass::WasGlassHitByBullet(victim, point.point);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_1, point.point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_PED:
|
|
|
|
{
|
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
|
|
|
|
((CPed*)victim)->Say(SOUND_PED_BULLET_HIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point.point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_DUMMY:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_3, point.point);
|
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float norm = 30.0f/info->m_fRange;
|
|
|
|
CVector traceTarget = (target-source)*norm + source;
|
2020-08-27 16:52:43 +00:00
|
|
|
CBulletTraces::AddTrace(&source, &traceTarget, m_eWeaponType, shooter);
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter == FindPlayerVehicle() )
|
|
|
|
CPad::GetPad(0)->StartShake_Distance(240, 128, FindPlayerVehicle()->GetPosition().x, FindPlayerVehicle()->GetPosition().y, FindPlayerVehicle()->GetPosition().z);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::DoDoomAiming(CEntity *shooter, CVector *source, CVector *target)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target !=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
#ifndef FIX_BUGS
|
|
|
|
CEntity entity; // unused
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CPed *shooterPed = (CPed*)shooter;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int16 lastEntity;
|
|
|
|
CEntity *entities[16];
|
|
|
|
CWorld::FindObjectsInRange(*source, (*target-*source).Magnitude(), true, &lastEntity, 15, entities, false, true, true, false, false);
|
|
|
|
|
|
|
|
float closestEntityDist = 10000.0f;
|
|
|
|
int16 closestEntity;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
for ( int32 i = 0; i < lastEntity; i++ )
|
|
|
|
{
|
|
|
|
CEntity *victim = entities[i];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victim!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( (CEntity*)shooterPed != victim && shooterPed->CanSeeEntity(victim, DEGTORAD(22.5f)) )
|
|
|
|
{
|
2020-04-30 13:45:45 +00:00
|
|
|
if ( !(victim->GetStatus() == STATUS_TRAIN_MOVING
|
|
|
|
|| victim->GetStatus() == STATUS_TRAIN_NOT_MOVING
|
|
|
|
|| victim->GetStatus() == STATUS_HELI
|
2020-06-15 22:38:26 +00:00
|
|
|
|| victim->GetStatus() == STATUS_PLANE
|
|
|
|
|| victim->GetStatus() == STATUS_WRECKED) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
float distToVictim = (shooterPed->GetPosition()-victim->GetPosition()).Magnitude2D();
|
|
|
|
float distToVictimZ = Abs(shooterPed->GetPosition().z-victim->GetPosition().z);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( 1.5f*distToVictimZ < distToVictim )
|
|
|
|
{
|
|
|
|
float entityDist = Sqrt(SQR(distToVictim) + SQR(distToVictimZ));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( entityDist < closestEntityDist )
|
|
|
|
{
|
|
|
|
closestEntityDist = entityDist;
|
|
|
|
closestEntity = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
CColPoint foundCol;
|
|
|
|
CEntity *foundEnt;
|
|
|
|
if (closestEntityDist < DOOMAUTOAIMING_MAXDIST
|
|
|
|
&& !CWorld::ProcessLineOfSight(*source, entities[closestEntity]->GetPosition(), foundCol, foundEnt, true, false, false, false, false, false, false, true))
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
CEntity *victim = entities[closestEntity];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victim !=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float distToTarget = (*target - *source).Magnitude2D();
|
|
|
|
float distToSource = (victim->GetPosition() - *source).Magnitude2D();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float victimZ = victim->GetPosition().z + 0.3f;
|
|
|
|
if ( victim->IsPed() )
|
|
|
|
{
|
|
|
|
if ( ((CPed*)victim)->bIsDucking )
|
|
|
|
victimZ -= 0.8f;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
(*target).z = (distToTarget / distToSource) * (victimZ - (*source).z) + (*source).z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::DoTankDoomAiming(CEntity *shooter, CEntity *driver, CVector *source, CVector *target)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(driver!=nil);
|
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
#ifndef FIX_BUGS
|
|
|
|
CEntity entity; // unused
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int16 lastEntity;
|
|
|
|
CEntity *entities[16];
|
|
|
|
CWorld::FindObjectsInRange(*source, (*target-*source).Magnitude(), true, &lastEntity, 15, entities, false, true, false, false, false);
|
|
|
|
|
|
|
|
float closestEntityDist = 10000.0f;
|
|
|
|
int16 closestEntity;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float normZ = (target->z - source->z) / (*target-*source).Magnitude();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
for ( int32 i = 0; i < lastEntity; i++ )
|
|
|
|
{
|
|
|
|
CEntity *victim = entities[i];
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
ASSERT(victim!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( shooter != victim && driver != victim )
|
2020-04-15 16:43:16 +00:00
|
|
|
{
|
2020-04-30 13:45:45 +00:00
|
|
|
if ( !(victim->GetStatus() == STATUS_TRAIN_MOVING
|
|
|
|
|| victim->GetStatus() == STATUS_TRAIN_NOT_MOVING
|
|
|
|
|| victim->GetStatus() == STATUS_HELI
|
|
|
|
|| victim->GetStatus() == STATUS_PLANE) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
if ( !(victim->IsVehicle() && victim->bRenderScorched) )
|
|
|
|
{
|
|
|
|
float distToVictim = (shooter->GetPosition()-victim->GetPosition()).Magnitude2D();
|
|
|
|
float distToVictimZ = Abs(shooter->GetPosition().z - (distToVictim*normZ + victim->GetPosition().z));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( 3.0f*distToVictimZ < distToVictim )
|
|
|
|
{
|
2020-04-19 16:34:08 +00:00
|
|
|
CVector tmp = CVector(victim->GetPosition().x, victim->GetPosition().y, 0.0f);
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( CCollision::DistToLine(source, target,
|
2020-04-19 16:34:08 +00:00
|
|
|
&tmp) < victim->GetBoundRadius()*3.0f )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
float vehicleDist = Sqrt(SQR(distToVictim) + SQR(distToVictimZ));
|
|
|
|
if ( vehicleDist < closestEntityDist )
|
|
|
|
{
|
|
|
|
closestEntityDist = vehicleDist;
|
|
|
|
closestEntity = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( closestEntityDist < DOOMAUTOAIMING_MAXDIST )
|
|
|
|
{
|
|
|
|
CEntity *victim = entities[closestEntity];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victim!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float distToTarget = (*target - *source).Magnitude2D();
|
|
|
|
float distToSource = (victim->GetPosition() - *source).Magnitude2D();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
(*target).z = (distToTarget / distToSource) * (0.3f + victim->GetPosition().z - (*source).z) + (*source).z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
2020-06-15 22:38:26 +00:00
|
|
|
CWeapon::DoDriveByAutoAiming(CEntity *driver, CVehicle *vehicle, CVector *source, CVector *target)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-15 22:38:26 +00:00
|
|
|
ASSERT(driver!=nil);
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
#ifndef FIX_BUGS
|
|
|
|
CEntity entity; // unused
|
|
|
|
#endif
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
CPed *shooterPed = (CPed*)driver;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
int16 lastEntity;
|
2020-06-15 22:38:26 +00:00
|
|
|
CEntity *peds[16];
|
|
|
|
CWorld::FindObjectsInRange(*source, (*target-*source).Magnitude(), true, &lastEntity, 15, peds, false, false, true, false, false);
|
2020-04-15 05:03:53 +00:00
|
|
|
|
|
|
|
float closestEntityDist = 10000.0f;
|
|
|
|
int16 closestEntity;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
for ( int32 i = 0; i < lastEntity; i++ )
|
|
|
|
{
|
2020-06-15 22:38:26 +00:00
|
|
|
CPed *victim = (CPed*)peds[i];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victim!=nil);
|
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
if (driver != victim && !victim->DyingOrDead() && victim->m_attachedTo != vehicle)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
float lineDist = CCollision::DistToLine(source, target, &victim->GetPosition());
|
2020-06-15 22:38:26 +00:00
|
|
|
|
|
|
|
uint32 model = vehicle->GetModelIndex();
|
|
|
|
float pedDist;
|
|
|
|
if (model == MI_HUNTER || model == MI_SEASPAR || model == MI_SPARROW)
|
|
|
|
{
|
|
|
|
float distToVictim = (victim->GetPosition() - vehicle->GetPosition()).Magnitude();
|
|
|
|
pedDist = lineDist / Max(5.f, distToVictim);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float distToVictim = (victim->GetPosition() - driver->GetPosition()).Magnitude();
|
|
|
|
pedDist = 0.15f * distToVictim + lineDist;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( DotProduct((*target-*source), victim->GetPosition()-*source) > 0.0f && pedDist < closestEntityDist)
|
|
|
|
{
|
|
|
|
closestEntity = i;
|
|
|
|
closestEntityDist = pedDist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-15 22:38:26 +00:00
|
|
|
uint32 model = vehicle->GetModelIndex();
|
|
|
|
float maxAimDistance = CAR_DRIVEBYAUTOAIMING_MAXDIST;
|
|
|
|
if (model == MI_HUNTER)
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
maxAimDistance = Tan(DEGTORAD(fHunterAimingAngle));
|
2020-06-15 22:38:26 +00:00
|
|
|
}
|
|
|
|
else if (model == MI_SEASPAR || model == MI_SPARROW)
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
maxAimDistance = Tan(DEGTORAD(fSeaSparrowAimingAngle));
|
2020-06-15 22:38:26 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-06-15 22:38:26 +00:00
|
|
|
if ( closestEntityDist < maxAimDistance )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-06-15 22:38:26 +00:00
|
|
|
CEntity *victim = peds[closestEntity];
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(victim!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
float distToTarget = (*source - *target).Magnitude();
|
2020-06-15 22:38:26 +00:00
|
|
|
float distToSource = (*source - victim->GetPosition()).Magnitude();
|
2020-04-15 05:03:53 +00:00
|
|
|
*target = (distToTarget / distToSource) * (victim->GetPosition() - *source) + *source;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-30 21:50:40 +00:00
|
|
|
void
|
|
|
|
CWeapon::Reload(void)
|
|
|
|
{
|
|
|
|
if (m_nAmmoTotal == 0)
|
|
|
|
return;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2019-06-30 21:50:40 +00:00
|
|
|
|
|
|
|
if (m_nAmmoTotal >= info->m_nAmountofAmmunition)
|
|
|
|
m_nAmmoInClip = info->m_nAmountofAmmunition;
|
|
|
|
else
|
|
|
|
m_nAmmoInClip = m_nAmmoTotal;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
2020-05-17 17:36:48 +00:00
|
|
|
CWeapon::Update(int32 audioEntity, CPed *pedToAdjustSound)
|
2019-07-15 12:11:40 +00:00
|
|
|
{
|
2020-05-17 17:36:48 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
switch ( m_eWeaponState )
|
|
|
|
{
|
|
|
|
case WEAPONSTATE_MELEE_MADECONTACT:
|
|
|
|
{
|
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONSTATE_FIRING:
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( IsShotgun(m_eWeaponType) && AEHANDLE_IS_OK(audioEntity) )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
uint32 timePassed = m_nTimer - CWeaponInfo::ms_aReloadSampleTime[m_eWeaponType];
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( CTimer::GetPreviousTimeInMilliseconds() < timePassed && CTimer::GetTimeInMilliseconds() >= timePassed )
|
|
|
|
DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, 0.0f);
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( CTimer::GetTimeInMilliseconds() > m_nTimer )
|
|
|
|
{
|
2020-06-20 14:30:28 +00:00
|
|
|
if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE && m_nAmmoTotal == 0 ) {
|
2020-04-15 05:03:53 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO;
|
2020-08-27 16:52:43 +00:00
|
|
|
CPickups::RemoveAllPickupsOfACertainWeaponGroupWithNoAmmo(m_eWeaponType);
|
2020-06-20 14:30:28 +00:00
|
|
|
} else
|
2020-04-15 05:03:53 +00:00
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
case WEAPONSTATE_RELOADING:
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
if ( AEHANDLE_IS_OK(audioEntity) && m_eWeaponType < WEAPONTYPE_TOTALWEAPONS)
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-05-17 17:36:48 +00:00
|
|
|
CAnimBlendAssociation *reloadAssoc = nil;
|
|
|
|
if (pedToAdjustSound) {
|
|
|
|
if (CPed::GetReloadAnim(info) && (!CWorld::Players[CWorld::PlayerInFocus].m_bFastReload || !pedToAdjustSound->IsPlayer())) {
|
|
|
|
reloadAssoc = RpAnimBlendClumpGetAssociation(pedToAdjustSound->GetClump(), CPed::GetReloadAnim(info));
|
|
|
|
if (!reloadAssoc) {
|
|
|
|
reloadAssoc = RpAnimBlendClumpGetAssociation(pedToAdjustSound->GetClump(), CPed::GetCrouchReloadAnim(info));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reloadAssoc && reloadAssoc->IsRunning() && reloadAssoc->blendAmount > 0.2f) {
|
|
|
|
float soundStart = 0.75f;
|
|
|
|
switch (info->m_AnimToPlay) {
|
|
|
|
case ASSOCGRP_PYTHON:
|
2020-08-27 16:52:43 +00:00
|
|
|
soundStart = fReloadAnimSampleFraction[0];
|
2020-05-17 17:36:48 +00:00
|
|
|
break;
|
|
|
|
case ASSOCGRP_COLT:
|
|
|
|
case ASSOCGRP_TEC:
|
2020-08-27 16:52:43 +00:00
|
|
|
soundStart = fReloadAnimSampleFraction[1];
|
2020-05-17 17:36:48 +00:00
|
|
|
break;
|
|
|
|
case ASSOCGRP_UZI:
|
2020-08-27 16:52:43 +00:00
|
|
|
soundStart = fReloadAnimSampleFraction[2];
|
2020-05-17 17:36:48 +00:00
|
|
|
break;
|
|
|
|
case ASSOCGRP_RIFLE:
|
2020-08-27 16:52:43 +00:00
|
|
|
soundStart = fReloadAnimSampleFraction[3];
|
2020-05-17 17:36:48 +00:00
|
|
|
break;
|
|
|
|
case ASSOCGRP_M60:
|
2020-08-27 16:52:43 +00:00
|
|
|
soundStart = fReloadAnimSampleFraction[4];
|
2020-05-17 17:36:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-11-22 22:00:53 +00:00
|
|
|
if (reloadAssoc->GetProgress() >= soundStart && (reloadAssoc->currentTime - reloadAssoc->timeStep) / reloadAssoc->hierarchy->totalLength < soundStart)
|
2020-05-17 17:36:48 +00:00
|
|
|
DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, m_eWeaponType);
|
|
|
|
if (CTimer::GetTimeInMilliseconds() > m_nTimer && reloadAssoc->GetProgress() < 0.9f) {
|
|
|
|
m_nTimer = CTimer::GetTimeInMilliseconds();
|
|
|
|
}
|
|
|
|
} else {
|
2020-08-27 16:52:43 +00:00
|
|
|
uint32 timePassed = m_nTimer - CWeaponInfo::ms_aReloadSampleTime[m_eWeaponType];
|
|
|
|
if (CTimer::GetPreviousTimeInMilliseconds() < timePassed && CTimer::GetTimeInMilliseconds() >= timePassed)
|
2020-05-17 17:36:48 +00:00
|
|
|
DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, m_eWeaponType);
|
|
|
|
}
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( CTimer::GetTimeInMilliseconds() > m_nTimer )
|
|
|
|
{
|
|
|
|
Reload();
|
|
|
|
m_eWeaponState = WEAPONSTATE_READY;
|
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FireOneInstantHitRound(CVector *source, CVector *target, int32 damage)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, *source, CVector(0.0f, 0.0f, 0.0f));
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
*source, CVector(0.0f, 0.0f, 0.0f), 5.0f,
|
|
|
|
1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CColPoint point;
|
|
|
|
CEntity *victim;
|
|
|
|
CWorld::ProcessLineOfSight(*source, *target, point, victim, true, true, true, true, true, true, false);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 18:29:00 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_HELI_ATTACK, *source, ((*target) - (*source)) * 0.15f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victim )
|
|
|
|
{
|
|
|
|
if ( victim->IsPed() )
|
|
|
|
{
|
|
|
|
CPed *victimPed = (CPed *)victim;
|
|
|
|
if ( !victimPed->DyingOrDead() )
|
|
|
|
{
|
|
|
|
CVector pos = victimPed->GetPosition();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector2D posOffset((*source).x-pos.x, (*source).y-pos.y);
|
|
|
|
int32 localDir = victimPed->GetLocalDirection(posOffset);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
victimPed->ClearAttackByRemovingAnim();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CAnimBlendAssociation *asoc = CAnimManager::AddAnimation(victimPed->GetClump(), ASSOCGRP_STD, AnimationId(ANIM_SHOT_FRONT_PARTIAL + localDir));
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(asoc!=nil);
|
2020-04-15 05:03:53 +00:00
|
|
|
asoc->blendAmount = 0.0f;
|
|
|
|
asoc->blendDelta = 8.0f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
|
|
|
victimPed->InflictDamage(nil, WEAPONTYPE_UZI, damage, (ePedPieceTypes)point.pieceB, localDir);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
pos.z += 0.8f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( victimPed->GetIsOnScreen() )
|
|
|
|
{
|
|
|
|
if ( CGame::nastyGame )
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 4; i++ )
|
|
|
|
{
|
|
|
|
CVector dir;
|
|
|
|
dir.x = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
dir.y = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD, pos, dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( victim->IsVehicle() )
|
2020-04-15 16:43:16 +00:00
|
|
|
((CVehicle *)victim)->InflictDamage(nil, WEAPONTYPE_UZI, damage);
|
2020-04-15 05:03:53 +00:00
|
|
|
//BUG ? no CGlass::WasGlassHitByBullet
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
switch ( victim->GetType() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
case ENTITY_TYPE_BUILDING:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_1, point.point);
|
|
|
|
CParticle::AddParticle(PARTICLE_SMOKE, point.point, CVector(0.0f, 0.0f, 0.01f));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_VEHICLE:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_PED:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
|
|
|
|
((CPed*)victim)->Say(SOUND_PED_BULLET_HIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_OBJECT:
|
|
|
|
{
|
2020-08-27 16:52:43 +00:00
|
|
|
CStats::BulletsThatHit++;
|
2020-04-15 05:03:53 +00:00
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point.point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENTITY_TYPE_DUMMY:
|
|
|
|
{
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_3, point.point);
|
|
|
|
break;
|
|
|
|
}
|
2020-05-11 23:24:57 +00:00
|
|
|
default: break;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float waterLevel;
|
|
|
|
if ( CWaterLevel::GetWaterLevel((*target).x, (*target).y, (*target).z + 10.0f, &waterLevel, false) )
|
|
|
|
{
|
|
|
|
CParticle::AddParticle(PARTICLE_BOAT_SPLASH, CVector((*target).x, (*target).y, waterLevel), CVector(0.0f, 0.0f, 0.01f));
|
|
|
|
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_WATER, point.point); // no sound(empty)
|
|
|
|
}
|
|
|
|
}
|
2019-07-15 12:11:40 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 22:44:49 +00:00
|
|
|
bool
|
|
|
|
CWeapon::IsTypeMelee(void)
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
return CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_eWeaponFire == WEAPON_FIRE_MELEE;
|
2019-07-05 22:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 15:06:24 +00:00
|
|
|
bool
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeapon::IsType2Handed(void)
|
|
|
|
{
|
2020-05-23 13:53:20 +00:00
|
|
|
return m_eWeaponType == WEAPONTYPE_FLAMETHROWER || m_eWeaponType == WEAPONTYPE_HELICANNON || m_eWeaponType == WEAPONTYPE_M60 ||
|
|
|
|
m_eWeaponType == WEAPONTYPE_M4 || IsShotgun(m_eWeaponType) ||
|
|
|
|
m_eWeaponType == WEAPONTYPE_RUGER || m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || m_eWeaponType == WEAPONTYPE_LASERSCOPE;
|
2020-04-15 05:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target)
|
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(shooter!=nil);
|
|
|
|
ASSERT(source!=nil);
|
|
|
|
ASSERT(target!=nil);
|
|
|
|
|
2020-04-19 16:34:08 +00:00
|
|
|
float minx = Min(source->x, target->x) - 2.0f;
|
|
|
|
float maxx = Max(source->x, target->x) + 2.0f;
|
|
|
|
float miny = Min(source->y, target->y) - 2.0f;
|
|
|
|
float maxy = Max(source->y, target->y) + 2.0f;
|
|
|
|
float minz = Min(source->z, target->z) - 2.0f;
|
|
|
|
float maxz = Max(source->z, target->z) + 2.0f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
for ( int32 i = CPools::GetPedPool()->GetSize() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
CPed *ped = CPools::GetPedPool()->GetSlot(i);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( ped )
|
|
|
|
{
|
|
|
|
if ( ped->GetPosition().x > minx && ped->GetPosition().x < maxx
|
|
|
|
&& ped->GetPosition().y > miny && ped->GetPosition().y < maxy
|
|
|
|
&& ped->GetPosition().z > minz && ped->GetPosition().z < maxz )
|
|
|
|
{
|
2020-04-16 02:07:32 +00:00
|
|
|
if ( ped != FindPlayerPed() && !((uint8)(ped->m_randomSeed ^ CGeneral::GetRandomNumber()) & 31) )
|
2020-04-15 05:03:53 +00:00
|
|
|
ped->SetEvasiveDive(shooter, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CWeapon::HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo)
|
2019-07-25 15:06:24 +00:00
|
|
|
{
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(holder!=nil);
|
|
|
|
ASSERT(aimingTo!=nil);
|
|
|
|
|
2019-07-25 15:06:24 +00:00
|
|
|
if (!holder->IsPed() || !((CPed*)holder)->m_pSeekTarget)
|
|
|
|
return false;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWeaponInfo *info = GetInfo();
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector adjustedOffset = info->m_vecFireOffset;
|
2019-07-25 15:06:24 +00:00
|
|
|
adjustedOffset.z += 0.6f;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CVector source, target;
|
2019-07-25 15:06:24 +00:00
|
|
|
CEntity *foundEnt = nil;
|
|
|
|
CColPoint foundCol;
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if (fireSource)
|
|
|
|
source = *fireSource;
|
2019-07-25 15:06:24 +00:00
|
|
|
else
|
2020-04-15 05:03:53 +00:00
|
|
|
source = holder->GetMatrix() * adjustedOffset;
|
2019-07-25 15:06:24 +00:00
|
|
|
|
|
|
|
CEntity *aimEntity = aimingTo ? aimingTo : ((CPed*)holder)->m_pSeekTarget;
|
2020-04-15 16:43:16 +00:00
|
|
|
ASSERT(aimEntity!=nil);
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
target = aimEntity->GetPosition();
|
|
|
|
target.z += 0.6f;
|
2019-07-25 15:06:24 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CWorld::ProcessLineOfSight(source, target, foundCol, foundEnt, true, false, false, false, false, false, false);
|
2019-07-25 15:06:24 +00:00
|
|
|
if (foundEnt && foundEnt->IsBuilding()) {
|
|
|
|
// That was supposed to be Magnitude, according to leftover code in assembly
|
2020-04-15 05:03:53 +00:00
|
|
|
float diff = (foundCol.point.z - source.z);
|
2019-07-25 15:06:24 +00:00
|
|
|
if (diff < 0.0f && diff > -3.0f)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
void
|
|
|
|
CWeapon::BlowUpExplosiveThings(CEntity *thing)
|
|
|
|
{
|
|
|
|
if ( thing )
|
|
|
|
{
|
|
|
|
CObject *object = (CObject*)thing;
|
|
|
|
int32 mi = object->GetModelIndex();
|
2020-06-17 18:24:59 +00:00
|
|
|
if ( IsExplosiveThingModel(mi) && !object->bHasBeenDamaged && object->IsObject() )
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
|
|
|
object->bHasBeenDamaged = true;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
CExplosion::AddExplosion(object, FindPlayerPed(), EXPLOSION_BARREL, object->GetPosition()+CVector(0.0f,0.0f,0.5f), 100);
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
if ( MI_EXPLODINGBARREL == mi )
|
2020-06-17 18:24:59 +00:00
|
|
|
object->m_vecMoveSpeed.z += 0.55f;
|
2020-04-15 05:03:53 +00:00
|
|
|
else
|
|
|
|
object->m_vecMoveSpeed.z += 0.45f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
|
|
|
|
object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-10-18 13:40:06 +00:00
|
|
|
if ( object->GetIsStatic())
|
2020-04-15 05:03:53 +00:00
|
|
|
{
|
2020-10-18 13:40:06 +00:00
|
|
|
object->SetIsStatic(false);
|
2020-04-15 05:03:53 +00:00
|
|
|
object->AddToMovingList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-07 14:23:09 +00:00
|
|
|
bool
|
|
|
|
CWeapon::HasWeaponAmmoToBeUsed(void)
|
|
|
|
{
|
2020-05-16 12:07:09 +00:00
|
|
|
// FIX: This is better (not bug tho)
|
2020-08-27 16:52:43 +00:00
|
|
|
//#if 0
|
2020-05-16 12:07:09 +00:00
|
|
|
if (m_eWeaponType <= WEAPONTYPE_CHAINSAW)
|
2020-08-27 16:52:43 +00:00
|
|
|
//#else
|
|
|
|
// if (CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_eWeaponFire == WEAPON_FIRE_MELEE)
|
|
|
|
//#endif
|
2020-05-16 12:07:09 +00:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return m_nAmmoTotal != 0;
|
2020-01-07 14:23:09 +00:00
|
|
|
}
|
2020-04-15 16:43:16 +00:00
|
|
|
|
2020-11-19 23:18:37 +00:00
|
|
|
bool
|
|
|
|
CPed::IsPedDoingDriveByShooting(void)
|
|
|
|
{
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
if (FindPlayerPed() == this && CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nWeaponSlot == 5) {
|
|
|
|
#else
|
|
|
|
if (FindPlayerPed() == this && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) {
|
|
|
|
#endif
|
|
|
|
if (TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || TheCamera.Cams[TheCamera.ActiveCam].LookingRight)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:03:53 +00:00
|
|
|
bool
|
|
|
|
CWeapon::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)
|
|
|
|
{
|
2021-01-13 19:09:53 +00:00
|
|
|
return CWorld::ProcessLineOfSight(point1, point2, point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, false, ignoreSomeObjects, true);
|
2020-05-02 15:02:17 +00:00
|
|
|
}
|
|
|
|
|
2020-06-03 13:16:31 +00:00
|
|
|
|
2020-06-20 13:23:32 +00:00
|
|
|
void
|
|
|
|
CWeapon::CheckForShootingVehicleOccupant(CEntity **victim, CColPoint *point, eWeaponType weapon, CVector const& source, CVector const& target)
|
|
|
|
{
|
|
|
|
if (!(*victim)->IsVehicle())
|
|
|
|
return;
|
|
|
|
|
|
|
|
CColSphere headSphere;
|
|
|
|
|
|
|
|
CVehicle *veh = (CVehicle*)*victim;
|
|
|
|
CColPoint origPoint(*point);
|
|
|
|
float radius = 1.0f;
|
|
|
|
bool found = false;
|
|
|
|
CColLine shootLine(source, target);
|
|
|
|
|
|
|
|
if (veh->pDriver && veh->pDriver->bCanBeShotInVehicle) {
|
|
|
|
CVector pos(0.f, 0.f, 0.f);
|
|
|
|
veh->pDriver->TransformToNode(pos, PED_HEAD);
|
|
|
|
headSphere.Set(0.2f, pos + CVector(0.f, 0.f, 0.1f), 0, PEDPIECE_HEAD);
|
|
|
|
if (CCollision::ProcessLineSphere(shootLine, headSphere, *point, radius)) {
|
|
|
|
*victim = veh->pDriver;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) {
|
|
|
|
CPed *passenger = veh->pPassengers[i];
|
|
|
|
if (passenger && passenger->bCanBeShotInVehicle) {
|
|
|
|
CVector pos(0.f, 0.f, 0.f);
|
|
|
|
passenger->TransformToNode(pos, PED_HEAD);
|
|
|
|
headSphere.Set(0.2f, pos + CVector(0.f, 0.f, 0.1f), 0, PEDPIECE_HEAD);
|
|
|
|
if (CCollision::ProcessLineSphere(shootLine, headSphere, *point, radius)) {
|
|
|
|
*victim = passenger;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (veh->IsCar()) {
|
|
|
|
CVector distVec = target - source;
|
|
|
|
if (DotProduct(distVec, veh->GetForward()) < 0.0f && DotProduct(distVec, veh->GetUp()) <= 0.0f) {
|
|
|
|
CColModel *colModel = veh->GetColModel();
|
|
|
|
if (colModel->numTriangles > 0) {
|
|
|
|
bool passesGlass = false;
|
|
|
|
CMatrix invVehMat;
|
|
|
|
Invert(veh->GetMatrix(), invVehMat);
|
|
|
|
shootLine.p0 = invVehMat * shootLine.p0;
|
|
|
|
shootLine.p1 = invVehMat * shootLine.p1;
|
|
|
|
CCollision::CalculateTrianglePlanes(colModel);
|
|
|
|
for (int i = 0; i < colModel->numTriangles; i++) {
|
|
|
|
if (colModel->triangles[i].surface == SURFACE_GLASS &&
|
|
|
|
CCollision::TestLineTriangle(shootLine, colModel->vertices, colModel->triangles[i], colModel->trianglePlanes[i])) {
|
|
|
|
passesGlass = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CAutomobile *car = (CAutomobile*)veh;
|
|
|
|
|
|
|
|
// No need to damage windscreen if there isn't one.
|
|
|
|
if (passesGlass && car->Damage.ProgressPanelDamage(VEHPANEL_WINDSCREEN)) {
|
|
|
|
if (car->Damage.GetPanelStatus(VEHPANEL_WINDSCREEN) == PANEL_STATUS_SMASHED2)
|
|
|
|
car->Damage.ProgressPanelDamage(VEHPANEL_WINDSCREEN);
|
|
|
|
|
|
|
|
car->SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN, true);
|
|
|
|
DMAudio.PlayOneShot(veh->m_audioEntityId, SOUND_CAR_WINDSHIELD_CRACK, 0.f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
*victim = veh;
|
|
|
|
*point = origPoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-02 15:02:17 +00:00
|
|
|
#ifdef COMPATIBLE_SAVES
|
2020-05-13 13:24:00 +00:00
|
|
|
#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data));
|
|
|
|
#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data));
|
2020-05-02 15:02:17 +00:00
|
|
|
void
|
|
|
|
CWeapon::Save(uint8*& buf)
|
|
|
|
{
|
2020-05-13 13:24:00 +00:00
|
|
|
CopyToBuf(buf, m_eWeaponType);
|
|
|
|
CopyToBuf(buf, m_eWeaponState);
|
|
|
|
CopyToBuf(buf, m_nAmmoInClip);
|
|
|
|
CopyToBuf(buf, m_nAmmoTotal);
|
|
|
|
CopyToBuf(buf, m_nTimer);
|
|
|
|
CopyToBuf(buf, m_bAddRotOffset);
|
2020-05-02 15:02:17 +00:00
|
|
|
SkipSaveBuf(buf, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeapon::Load(uint8*& buf)
|
|
|
|
{
|
2020-05-13 13:24:00 +00:00
|
|
|
CopyFromBuf(buf, m_eWeaponType);
|
|
|
|
CopyFromBuf(buf, m_eWeaponState);
|
|
|
|
CopyFromBuf(buf, m_nAmmoInClip);
|
|
|
|
CopyFromBuf(buf, m_nAmmoTotal);
|
|
|
|
CopyFromBuf(buf, m_nTimer);
|
|
|
|
CopyFromBuf(buf, m_bAddRotOffset);
|
2020-05-02 15:02:17 +00:00
|
|
|
SkipSaveBuf(buf, 3);
|
|
|
|
}
|
2020-05-13 13:24:00 +00:00
|
|
|
|
|
|
|
#undef CopyFromBuf
|
|
|
|
#undef CopyToBuf
|
2020-05-02 15:02:17 +00:00
|
|
|
#endif
|