diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-10-07 23:21:44 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-10-07 23:26:24 +0200 |
commit | da39624f1c694dbeaefc6762fd6867715cdb77bc (patch) | |
tree | 58d34e45cba86fba08992f522e34fc182f215eb2 /src/weapons | |
parent | Fix build on clang (diff) | |
download | re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar.gz re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar.bz2 re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar.lz re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar.xz re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.tar.zst re3-da39624f1c694dbeaefc6762fd6867715cdb77bc.zip |
Diffstat (limited to 'src/weapons')
-rw-r--r-- | src/weapons/BulletInfo.cpp | 160 | ||||
-rw-r--r-- | src/weapons/ProjectileInfo.cpp | 235 |
2 files changed, 250 insertions, 145 deletions
diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 0efe6688..375a2ca9 100644 --- a/src/weapons/BulletInfo.cpp +++ b/src/weapons/BulletInfo.cpp @@ -23,6 +23,9 @@ #include "WeaponInfo.h" #include "World.h" #include "SurfaceTable.h" +#include "Heli.h" + +// --MIAMI: file done #ifdef SQUEEZE_PERFORMANCE uint32 bulletInfoInUse; @@ -32,9 +35,14 @@ uint32 bulletInfoInUse; #define NUM_PED_BLOOD_PARTICLES (8) #define BLOOD_PARTICLE_OFFSET (CVector(0.0f, 0.0f, 0.0f)) #define NUM_VEHICLE_SPARKS (16) +#define NUM_TYRE_POP_SMOKES (4) #define NUM_OTHER_SPARKS (8) #define BULLET_HIT_FORCE (7.5f) -#define MAP_BORDER (1960.0f) + +#define BULLET_BOUNDARY_MIN_X -2400.0f +#define BULLET_BOUNDARY_MAX_X 1600.0f +#define BULLET_BOUNDARY_MIN_Y -2000.0f +#define BULLET_BOUNDARY_MAX_Y 2000.0f CBulletInfo gaBulletInfo[CBulletInfo::NUM_BULLETS]; bool bPlayerSniperBullet; @@ -106,14 +114,18 @@ void CBulletInfo::Update(void) } CVector vecOldPos = pBullet->m_vecPosition; CVector vecNewPos = pBullet->m_vecPosition + pBullet->m_vecSpeed * CTimer::GetTimeStep() * 0.5f; - CWorld::bIncludeCarTyres = true; + + if ( vecNewPos.x <= BULLET_BOUNDARY_MIN_X || vecNewPos.x >= BULLET_BOUNDARY_MAX_X || vecNewPos.y <= BULLET_BOUNDARY_MIN_Y || vecNewPos.y >= BULLET_BOUNDARY_MAX_Y ) { + pBullet->m_bInUse = false; + continue; + } CWorld::bIncludeDeadPeds = true; + CWorld::bIncludeBikers = true; + CWorld::bIncludeCarTyres = true; CWorld::pIgnoreEntity = pBullet->m_pSource; CColPoint point; CEntity* pHitEntity; if (CWorld::ProcessLineOfSight(vecOldPos, vecNewPos, point, pHitEntity, true, true, true, true, true, false, false, true)) { - if (pBullet->m_pSource && (pHitEntity->IsPed() || pHitEntity->IsVehicle())) - CStats::BulletsThatHit++; CWeapon::CheckForShootingVehicleOccupant(&pHitEntity, &point, pBullet->m_eWeaponType, vecOldPos, vecNewPos); if (pHitEntity->IsPed()) { @@ -128,7 +140,7 @@ void CBulletInfo::Update(void) CEventList::RegisterEvent(pPed->m_nPedType == PEDTYPE_COP ? EVENT_SHOOT_COP : EVENT_SHOOT_PED, EVENT_ENTITY_PED, pPed, (CPed*)pBullet->m_pSource, 1000); pBullet->m_bInUse = false; #ifdef SQUEEZE_PERFORMANCE - bulletInfoInUse--; + bulletInfoInUse--; #endif vecNewPos = point.point; } @@ -159,13 +171,24 @@ void CBulletInfo::Update(void) } } else if (pHitEntity->IsVehicle()) { - CVehicle* pVehicle = (CVehicle*)pHitEntity; - pVehicle->InflictDamage(pBullet->m_pSource, pBullet->m_eWeaponType, pBullet->m_nDamage); - if (pBullet->m_eWeaponType == WEAPONTYPE_FLAMETHROWER) // huh? - gFireManager.StartFire(pVehicle, pBullet->m_pSource, 0.8f, true); - else { - for (int j = 0; j < NUM_VEHICLE_SPARKS; j++) - CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal / 20); + CEntity *source = pBullet->m_pSource; + if ( !source || !source->IsPed() || ((CPed*)source)->m_attachedTo != pHitEntity) { + if ( point.pieceB >= CAR_PIECE_WHEEL_LF && point.pieceB <= CAR_PIECE_WHEEL_RR ) { + ((CVehicle*)pHitEntity)->BurstTyre(point.pieceB, true); + for (int j=0; j<NUM_TYRE_POP_SMOKES; j++) { + CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, point.point, point.normal / 20); + } + } else { + // CVector sth(0.0f, 0.0f, 0.0f); // unused + ((CVehicle*)pHitEntity)->InflictDamage(source, pBullet->m_eWeaponType, pBullet->m_nDamage); + if ( pBullet->m_eWeaponType == WEAPONTYPE_FLAMETHROWER ) { + gFireManager.StartFire(pHitEntity, pBullet->m_pSource, 0.8f, 1); + } else { + for (int j=0; j<NUM_VEHICLE_SPARKS; j++) { + CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal / 20); + } + } + } } #ifdef FIX_BUGS pBullet->m_bInUse = false; @@ -174,19 +197,28 @@ void CBulletInfo::Update(void) #endif vecNewPos = point.point; #endif - } - else { + } else { for (int j = 0; j < NUM_OTHER_SPARKS; j++) CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal / 20); - if (pHitEntity->IsObject()) { - CObject* pObject = (CObject*)pHitEntity; - if (!pObject->bInfiniteMass) { - if (pObject->IsStatic() && pObject->m_fUprootLimit <= 0.0f) { - pObject->bIsStatic = false; - pObject->AddToMovingList(); + CEntity *source = pBullet->m_pSource; + if ( !source || !source->IsPed() || ((CPed*)source)->m_attachedTo != pHitEntity) { + if (pHitEntity->IsObject()) { + CObject *pHitObject = (CObject*)pHitEntity; + if ( !pHitObject->bInfiniteMass && pHitObject->m_fCollisionDamageMultiplier < 99.9f) { + bool notStatic = !pHitObject->IsStatic(); + if (notStatic && pHitObject->m_fUprootLimit <= 0.0f) { + pHitObject->bIsStatic = false; + pHitObject->AddToMovingList(); + } + + notStatic = !pHitObject->IsStatic(); + if (!notStatic) { + CVector moveForce = point.normal * -BULLET_HIT_FORCE; + pHitObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); + } + } else if (pHitObject->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY) { + pHitObject->ObjectDamage(50.f); } - if (!pObject->IsStatic()) - pObject->ApplyMoveForce(-BULLET_HIT_FORCE * point.normal); } } #ifdef FIX_BUGS @@ -200,35 +232,52 @@ void CBulletInfo::Update(void) if (pBullet->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || pBullet->m_eWeaponType == WEAPONTYPE_LASERSCOPE) { cAudioScriptObject* pAudio; switch (pHitEntity->GetType()) { - case ENTITY_TYPE_BUILDING: - pAudio = new cAudioScriptObject(); - pAudio->Posn = pHitEntity->GetPosition(); - pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_1; - pAudio->AudioEntity = AEHANDLE_NONE; - DMAudio.CreateOneShotScriptObject(pAudio); - break; - case ENTITY_TYPE_OBJECT: - pAudio = new cAudioScriptObject(); - pAudio->Posn = pHitEntity->GetPosition(); - pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_2; - pAudio->AudioEntity = AEHANDLE_NONE; - DMAudio.CreateOneShotScriptObject(pAudio); - break; - case ENTITY_TYPE_DUMMY: - pAudio = new cAudioScriptObject(); - pAudio->Posn = pHitEntity->GetPosition(); - pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_3; - pAudio->AudioEntity = AEHANDLE_NONE; - DMAudio.CreateOneShotScriptObject(pAudio); - break; - case ENTITY_TYPE_PED: - DMAudio.PlayOneShot(((CPed*)pHitEntity)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f); - ((CPed*)pHitEntity)->Say(SOUND_PED_BULLET_HIT); - break; - case ENTITY_TYPE_VEHICLE: - DMAudio.PlayOneShot(((CVehicle*)pHitEntity)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f); - break; - default: break; + case ENTITY_TYPE_BUILDING: + if (!DMAudio.IsAudioInitialised()) + break; + + pAudio = new cAudioScriptObject(); + if (pAudio) + pAudio->Reset(); + pAudio->Posn = pHitEntity->GetPosition(); + pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_1; + pAudio->AudioEntity = AEHANDLE_NONE; + DMAudio.CreateOneShotScriptObject(pAudio); + break; + case ENTITY_TYPE_OBJECT: + if (!DMAudio.IsAudioInitialised()) + break; + + pAudio = new cAudioScriptObject(); + if (pAudio) + pAudio->Reset(); + pAudio->Posn = pHitEntity->GetPosition(); + pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_2; + pAudio->AudioEntity = AEHANDLE_NONE; + DMAudio.CreateOneShotScriptObject(pAudio); + break; + case ENTITY_TYPE_DUMMY: + if (!DMAudio.IsAudioInitialised()) + break; + + pAudio = new cAudioScriptObject(); + if (pAudio) + pAudio->Reset(); + pAudio->Posn = pHitEntity->GetPosition(); + pAudio->AudioId = SCRIPT_SOUND_BULLET_HIT_GROUND_3; + pAudio->AudioEntity = AEHANDLE_NONE; + DMAudio.CreateOneShotScriptObject(pAudio); + break; + case ENTITY_TYPE_PED: + ++CStats::BulletsThatHit; + DMAudio.PlayOneShot(((CPed*)pHitEntity)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f); + ((CPed*)pHitEntity)->Say(SOUND_PED_BULLET_HIT); + break; + case ENTITY_TYPE_VEHICLE: + ++CStats::BulletsThatHit; + DMAudio.PlayOneShot(((CVehicle*)pHitEntity)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f); + break; + default: break; } } CGlass::WasGlassHitByBullet(pHitEntity, point.point); @@ -237,19 +286,14 @@ void CBulletInfo::Update(void) CWorld::pIgnoreEntity = nil; CWorld::bIncludeDeadPeds = false; CWorld::bIncludeCarTyres = false; + CWorld::bIncludeBikers = false; if (pBullet->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || pBullet->m_eWeaponType == WEAPONTYPE_LASERSCOPE) { bPlayerSniperBullet = true; PlayerSniperBulletStart = pBullet->m_vecPosition; PlayerSniperBulletEnd = vecNewPos; } pBullet->m_vecPosition = vecNewPos; - if (pBullet->m_vecPosition.x < -MAP_BORDER || pBullet->m_vecPosition.x > MAP_BORDER || - pBullet->m_vecPosition.y < -MAP_BORDER || pBullet->m_vecPosition.y > MAP_BORDER) { - pBullet->m_bInUse = false; -#ifdef SQUEEZE_PERFORMANCE - bulletInfoInUse--; -#endif - } + CHeli::TestSniperCollision(&PlayerSniperBulletStart, &PlayerSniperBulletEnd); } } diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp index 4150852a..71cd9cfb 100644 --- a/src/weapons/ProjectileInfo.cpp +++ b/src/weapons/ProjectileInfo.cpp @@ -17,9 +17,16 @@ uint32 projectileInUse; #endif +// --MIAMI: file done except TODOs + CProjectileInfo gaProjectileInfo[NUM_PROJECTILES]; CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES]; +#define PROJECTILE_BOUNDARY_MIN_X -2390.0f +#define PROJECTILE_BOUNDARY_MAX_X 1590.0f +#define PROJECTILE_BOUNDARY_MIN_Y -1990.0f +#define PROJECTILE_BOUNDARY_MAX_Y 1990.0f + void CProjectileInfo::Initialise() { @@ -53,7 +60,6 @@ CProjectileInfo::GetProjectileInfo(int32 id) return &gaProjectileInfo[id]; } -// --MIAMI: Mostly done bool CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, float speed) { @@ -67,70 +73,87 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, switch (weapon) { - case WEAPONTYPE_ROCKET: - { - float vy = 0.35f; - time = CTimer::GetTimeInMilliseconds() + 2000; - if (entity->GetModelIndex() == MI_SPARROW || entity->GetModelIndex() == MI_HUNTER || entity->GetModelIndex() == MI_SENTINEL) { - matrix = ped->GetMatrix(); - matrix.GetPosition() = pos; - CVector vecSpeed = ((CPhysical*)entity)->m_vecMoveSpeed; - vy += Max(0.0f, DotProduct(vecSpeed, entity->GetForward())) + Max(0.0f, DotProduct(vecSpeed, entity->GetUp())); - } else { - if (ped->IsPlayer()) { - matrix.GetForward() = TheCamera.Cams[TheCamera.ActiveCam].Front; - matrix.GetUp() = TheCamera.Cams[TheCamera.ActiveCam].Up; - matrix.GetRight() = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Up, TheCamera.Cams[TheCamera.ActiveCam].Front); + case WEAPONTYPE_ROCKET: + { + float vy = 0.35f; + time = CTimer::GetTimeInMilliseconds() + 2000; + if (entity->GetModelIndex() == MI_SPARROW || entity->GetModelIndex() == MI_HUNTER || entity->GetModelIndex() == MI_SENTINEL) { + matrix = ped->GetMatrix(); matrix.GetPosition() = pos; - } else if (ped->m_pSeekTarget != nil) { - float ry = CGeneral::GetRadianAngleBetweenPoints(1.0f, ped->m_pSeekTarget->GetPosition().z, 1.0f, pos.z); - float rz = Atan2(-ped->GetForward().x, ped->GetForward().y); - vy = 0.35f * speed + 0.15f; - matrix.SetTranslate(0.0f, 1.0f, 1.0f); - matrix.Rotate(0.0f, ry, rz); - matrix.GetPosition() += pos; + CVector vecSpeed = ((CPhysical*)entity)->m_vecMoveSpeed; + vy += Max(0.0f, DotProduct(vecSpeed, entity->GetForward())) + Max(0.0f, DotProduct(vecSpeed, entity->GetUp())); } else { - matrix = ped->GetMatrix(); + if (ped->IsPlayer()) { + matrix.GetForward() = TheCamera.Cams[TheCamera.ActiveCam].Front; + matrix.GetUp() = TheCamera.Cams[TheCamera.ActiveCam].Up; + matrix.GetRight() = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Up, TheCamera.Cams[TheCamera.ActiveCam].Front); + matrix.GetPosition() = pos; + } else if (ped->m_pSeekTarget != nil) { + float ry = CGeneral::GetRadianAngleBetweenPoints(1.0f, ped->m_pSeekTarget->GetPosition().z, 1.0f, pos.z); + float rz = Atan2(-ped->GetForward().x, ped->GetForward().y); + vy = 0.35f * speed + 0.15f; + matrix.SetTranslate(0.0f, 1.0f, 1.0f); + matrix.Rotate(0.0f, ry, rz); + matrix.GetPosition() += pos; + } else { + matrix = ped->GetMatrix(); + } } + velocity = Multiply3x3(matrix, CVector(0.0f, vy, 0.0f)); + gravity = false; + break; } - velocity = Multiply3x3(matrix, CVector(0.0f, vy, 0.0f)); - gravity = false; - break; - } - case WEAPONTYPE_MOLOTOV: - { - time = CTimer::GetTimeInMilliseconds() + 2000; - float scale = 0.22f * speed + 0.15f; - if (scale < 0.2f) - scale = 0.2f; - float angle = Atan2(-ped->GetForward().x, ped->GetForward().y); - matrix.SetTranslate(0.0f, 0.0f, 0.0f); - matrix.RotateZ(angle); - matrix.GetPosition() += pos; - velocity.x = -1.0f * scale * Sin(angle); - velocity.y = scale * Cos(angle); - velocity.z = (0.2f * speed + 0.4f) * scale; - break; - } - case WEAPONTYPE_GRENADE: - case WEAPONTYPE_DETONATOR_GRENADE: - { - time = CTimer::GetTimeInMilliseconds() + 2000; - float scale = 0.0f; - if (speed != 0.0f) - scale = 0.22f * speed + 0.15f; - float angle = Atan2(-ped->GetForward().x, ped->GetForward().y); - matrix.SetTranslate(0.0f, 0.0f, 0.0f); - matrix.RotateZ(angle); - matrix.GetPosition() += pos; - SpecialCollisionResponseCase = COLLRESPONSE_UNKNOWN5; - velocity.x = -1.0f * scale * Sin(angle); - velocity.y = scale * Cos(angle); - velocity.z = (0.4f * speed + 0.4f) * scale; - elasticity = 0.5f; - break; - } - default: + case WEAPONTYPE_MOLOTOV: + { + time = CTimer::GetTimeInMilliseconds() + 2000; + float scale = 0.22f * speed + 0.15f; + if (scale < 0.2f) + scale = 0.2f; + float angle = Atan2(-ped->GetForward().x, ped->GetForward().y); + matrix.SetTranslate(0.0f, 0.0f, 0.0f); + matrix.RotateZ(angle); + matrix.GetPosition() += pos; + velocity.x = -1.0f * scale * Sin(angle); + velocity.y = scale * Cos(angle); + velocity.z = (0.2f * speed + 0.4f) * scale; + break; + } + case WEAPONTYPE_TEARGAS: + { + time = CTimer::GetTimeInMilliseconds() + 20000; + float scale = 0.0f; + if (speed != 0.0f) + scale = 0.22f * speed + 0.15f; + float angle = Atan2(-ped->GetForward().x, ped->GetForward().y); + matrix.SetTranslate(0.0f, 0.0f, 0.0f); + matrix.RotateZ(angle); + matrix.GetPosition() += pos; + SpecialCollisionResponseCase = COLLRESPONSE_UNKNOWN5; + velocity.x = -1.0f * scale * Sin(angle); + velocity.y = scale * Cos(angle); + velocity.z = (0.4f * speed + 0.4f) * scale; + elasticity = 0.5f; + break; + } + case WEAPONTYPE_GRENADE: + case WEAPONTYPE_DETONATOR_GRENADE: + { + time = CTimer::GetTimeInMilliseconds() + 2000; + float scale = 0.0f; + if (speed != 0.0f) + scale = 0.22f * speed + 0.15f; + float angle = Atan2(-ped->GetForward().x, ped->GetForward().y); + matrix.SetTranslate(0.0f, 0.0f, 0.0f); + matrix.RotateZ(angle); + matrix.GetPosition() += pos; + SpecialCollisionResponseCase = COLLRESPONSE_UNKNOWN5; + velocity.x = -1.0f * scale * Sin(angle); + velocity.y = scale * Cos(angle); + velocity.z = (0.4f * speed + 0.4f) * scale; + elasticity = 0.5f; + break; + } + default: Error("Undefined projectile type, AddProjectile, ProjectileInfo.cpp"); break; } @@ -143,19 +166,20 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, switch (weapon) { - case WEAPONTYPE_ROCKET: + case WEAPONTYPE_ROCKET: ms_apProjectile[i] = new CProjectile(MI_MISSILE); break; - case WEAPONTYPE_FLAMETHROWER: + case WEAPONTYPE_TEARGAS: + ms_apProjectile[i] = new CProjectile(MI_TEARGAS); break; - case WEAPONTYPE_MOLOTOV: + case WEAPONTYPE_MOLOTOV: ms_apProjectile[i] = new CProjectile(MI_MOLOTOV); break; - case WEAPONTYPE_GRENADE: - case WEAPONTYPE_DETONATOR_GRENADE: + case WEAPONTYPE_GRENADE: + case WEAPONTYPE_DETONATOR_GRENADE: ms_apProjectile[i] = new CProjectile(MI_GRENADE); break; - default: break; + default: break; } if (ms_apProjectile[i] == nil) @@ -189,7 +213,18 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, void CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile) { - RemoveNotAdd(info->m_pSource, info->m_eWeaponType, projectile->GetPosition()); + // TODO(Miami): New parameter: 1 + switch (info->m_eWeaponType) { + case WEAPONTYPE_GRENADE: + CExplosion::AddExplosion(nil, info->m_pSource, EXPLOSION_GRENADE, projectile->GetPosition(), 0); + break; + case WEAPONTYPE_MOLOTOV: + CExplosion::AddExplosion(nil, info->m_pSource, EXPLOSION_MOLOTOV, projectile->GetPosition(), 0); + break; + case WEAPONTYPE_ROCKET: + CExplosion::AddExplosion(nil, info->m_pSource->IsVehicle() ? ((CVehicle*)info->m_pSource)->pDriver : info->m_pSource, EXPLOSION_ROCKET, projectile->GetPosition(), 0); + break; + } #ifdef SQUEEZE_PERFORMANCE projectileInUse--; #endif @@ -202,18 +237,17 @@ CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile void CProjectileInfo::RemoveNotAdd(CEntity *entity, eWeaponType weaponType, CVector pos) { - switch (weaponType) - { - case WEAPONTYPE_GRENADE: - CExplosion::AddExplosion(nil, entity, EXPLOSION_GRENADE, pos, 0); - break; - case WEAPONTYPE_MOLOTOV: - CExplosion::AddExplosion(nil, entity, EXPLOSION_MOLOTOV, pos, 0); - break; - case WEAPONTYPE_ROCKET: - CExplosion::AddExplosion(nil, entity, EXPLOSION_ROCKET, pos, 0); - break; - default: break; + // TODO(Miami): New parameter: 1 + switch (weaponType) { + case WEAPONTYPE_GRENADE: + CExplosion::AddExplosion(nil, entity, EXPLOSION_GRENADE, pos, 0); + break; + case WEAPONTYPE_MOLOTOV: + CExplosion::AddExplosion(nil, entity, EXPLOSION_MOLOTOV, pos, 0); + break; + case WEAPONTYPE_ROCKET: + CExplosion::AddExplosion(nil, entity, EXPLOSION_ROCKET, pos, 0); + break; } } @@ -225,6 +259,8 @@ CProjectileInfo::Update() return; #endif + int tearGasOffset = -0.0f; // unused + for (int i = 0; i < ARRAY_SIZE(gaProjectileInfo); i++) { if (!gaProjectileInfo[i].m_bInUse) continue; @@ -240,21 +276,48 @@ CProjectileInfo::Update() gaProjectileInfo[i].m_bInUse = false; continue; } + if ( (gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE || gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_TEARGAS) && ms_apProjectile[i]->m_fElasticity > 0.1f ) { + if ( Abs(ms_apProjectile[i]->m_vecMoveSpeed.x) < 0.05f && Abs(ms_apProjectile[i]->m_vecMoveSpeed.y) < 0.05f && Abs(ms_apProjectile[i]->m_vecMoveSpeed.z) < 0.05f ) { + ms_apProjectile[i]->m_fElasticity = 0.03f; + } + } + const CVector &projectilePos = ms_apProjectile[i]->GetPosition(); + CVector nextPos = CTimer::GetTimeStep() * ms_apProjectile[i]->m_vecMoveSpeed + projectilePos; + + if ( nextPos.x <= PROJECTILE_BOUNDARY_MIN_X || nextPos.x >= PROJECTILE_BOUNDARY_MAX_X || nextPos.y <= PROJECTILE_BOUNDARY_MIN_Y || nextPos.y >= PROJECTILE_BOUNDARY_MAX_Y ) { + // Not RemoveProjectile, because we don't want no explosion + gaProjectileInfo[i].m_bInUse = false; + CWorld::Remove(ms_apProjectile[i]); + delete ms_apProjectile[i]; + continue; + } + if ( gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_TEARGAS && CTimer::GetTimeInMilliseconds() > gaProjectileInfo[i].m_nExplosionTime - 19500 ) { + CParticle::AddParticle(PARTICLE_TEARGAS, projectilePos, CVector(0.2f, tearGasOffset, 0.0f), 0, 0.0f, 0, 0, 0, 0); + CParticle::AddParticle(PARTICLE_TEARGAS, projectilePos, CVector(-0.2f, tearGasOffset, 0.0f), 0, 0.0f, 0, 0, 0, 0); + CParticle::AddParticle(PARTICLE_TEARGAS, projectilePos, CVector(tearGasOffset, tearGasOffset, 0.0f), 0, 0.0f, 0, 0, 0, 0); + + // TODO(Miami): SetPedsChoking + /*if ( CTimer::GetTimeInMilliseconds() & 0x200 ) + CWorld::SetPedsChoking(projectilePos.x, projectilePos.y, projectilePos.z, 6.0f, gaProjectileInfo[i].m_pSource); + */ + } if (gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_ROCKET) { - CParticle::AddParticle(PARTICLE_SMOKE, ms_apProjectile[i]->GetPosition(), CVector(0.0f, 0.0f, 0.0f)); + CParticle::AddParticlesAlongLine(PARTICLE_ROCKET_SMOKE, gaProjectileInfo[i].m_vecPos, projectilePos, CVector(0.0f, 0.0f, 0.0f), 0.7f, 0, 0, 0, 3000); } - if (CTimer::GetTimeInMilliseconds() <= gaProjectileInfo[i].m_nExplosionTime) { + if (CTimer::GetTimeInMilliseconds() <= gaProjectileInfo[i].m_nExplosionTime || gaProjectileInfo[i].m_nExplosionTime == 0) { if (gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_ROCKET) { CVector pos = ms_apProjectile[i]->GetPosition(); CWorld::pIgnoreEntity = ms_apProjectile[i]; if (ms_apProjectile[i]->bHasCollided || !CWorld::GetIsLineOfSightClear(gaProjectileInfo[i].m_vecPos, pos, true, true, true, true, false, false) - || gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_ROCKET && (CHeli::TestRocketCollision(&pos) || CPlane::TestRocketCollision(&pos))) { + || CHeli::TestRocketCollision(&pos) || CPlane::TestRocketCollision(&pos)) { RemoveProjectile(&gaProjectileInfo[i], ms_apProjectile[i]); } CWorld::pIgnoreEntity = nil; + ms_apProjectile[i]->m_vecMoveSpeed *= 1.07f; + } else if (gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_MOLOTOV) { CVector pos = ms_apProjectile[i]->GetPosition(); CWorld::pIgnoreEntity = ms_apProjectile[i]; @@ -263,8 +326,7 @@ CProjectileInfo::Update() || ((gaProjectileInfo[i].m_vecPos - gaProjectileInfo[i].m_pSource->GetPosition()).MagnitudeSqr() >= 2.0f)) { if (ms_apProjectile[i]->bHasCollided - || !CWorld::GetIsLineOfSightClear(gaProjectileInfo[i].m_vecPos, pos, true, true, true, true, false, false) - || gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_ROCKET && (CHeli::TestRocketCollision(&pos) || CPlane::TestRocketCollision(&pos))) { + || !CWorld::GetIsLineOfSightClear(gaProjectileInfo[i].m_vecPos, pos, true, true, true, true, false, false)) { RemoveProjectile(&gaProjectileInfo[i], ms_apProjectile[i]); } } @@ -315,13 +377,12 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo return result; } -// --MIAMI: Done void CProjectileInfo::RemoveDetonatorProjectiles() { for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) { if (gaProjectileInfo[i].m_bInUse && gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE) { - CExplosion::AddExplosion(nil, gaProjectileInfo[i].m_pSource, EXPLOSION_GRENADE, gaProjectileInfo[i].m_vecPos, 0); // TODO(Miami): New parameter (1) + CExplosion::AddExplosion(nil, gaProjectileInfo[i].m_pSource, EXPLOSION_GRENADE, gaProjectileInfo[i].m_vecPos, 0); // TODO(Miami): New parameter: 1 gaProjectileInfo[i].m_bInUse = false; CWorld::Remove(ms_apProjectile[i]); delete ms_apProjectile[i]; |