summaryrefslogtreecommitdiffstats
path: root/src/weapons
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2020-04-19 18:34:08 +0200
committerFilip Gawin <filip.gawin@zoho.com>2020-04-20 18:18:46 +0200
commit370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96 (patch)
tree5f5c66a542d7a121a7db88fed66e31f2a263b206 /src/weapons
parentMerge pull request #474 from Nick007J/master (diff)
downloadre3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar.gz
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar.bz2
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar.lz
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar.xz
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.tar.zst
re3-370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96.zip
Diffstat (limited to '')
-rw-r--r--src/weapons/BulletInfo.cpp24
-rw-r--r--src/weapons/BulletInfo.h3
-rw-r--r--src/weapons/ProjectileInfo.h3
-rw-r--r--src/weapons/ShotInfo.cpp2
-rw-r--r--src/weapons/ShotInfo.h3
-rw-r--r--src/weapons/Weapon.cpp33
-rw-r--r--src/weapons/Weapon.h50
-rw-r--r--src/weapons/WeaponInfo.h5
-rw-r--r--src/weapons/WeaponType.h49
9 files changed, 90 insertions, 82 deletions
diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp
index abf5c061..36c3cc78 100644
--- a/src/weapons/BulletInfo.cpp
+++ b/src/weapons/BulletInfo.cpp
@@ -232,35 +232,35 @@ bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, fl
#else
float minP = 0.0f;
float maxP = 1.0f;
- float minX = min(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
- float maxX = max(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
+ float minX = Min(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
+ float maxX = Max(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
if (minX < x2 || maxX > x1) {
if (minX < x1)
- minP = min(minP, (x1 - minX) / (maxX - minX));
+ minP = Min(minP, (x1 - minX) / (maxX - minX));
if (maxX > x2)
- maxP = max(maxP, (maxX - x2) / (maxX - minX));
+ maxP = Max(maxP, (maxX - x2) / (maxX - minX));
}
else
return false;
- float minY = min(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
- float maxY = max(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
+ float minY = Min(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
+ float maxY = Max(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
if (minY < y2 || maxY > y1) {
if (minY < y1)
- minP = min(minP, (y1 - minY) / (maxY - minY));
+ minP = Min(minP, (y1 - minY) / (maxY - minY));
if (maxY > y2)
- maxP = max(maxP, (maxY - y2) / (maxY - minY));
+ maxP = Max(maxP, (maxY - y2) / (maxY - minY));
}
#ifdef FIX_BUGS
else
return false;
#endif
- float minZ = min(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
- float maxZ = max(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
+ float minZ = Min(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
+ float maxZ = Max(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
if (minZ < z2 || maxZ > z1) {
if (minZ < z1)
- minP = min(minP, (z1 - minZ) / (maxZ - minZ));
+ minP = Min(minP, (z1 - minZ) / (maxZ - minZ));
if (maxZ > z2)
- maxP = max(maxP, (maxZ - z2) / (maxZ - minZ));
+ maxP = Max(maxP, (maxZ - z2) / (maxZ - minZ));
}
else
return false;
diff --git a/src/weapons/BulletInfo.h b/src/weapons/BulletInfo.h
index c7d740b2..cf1dd27f 100644
--- a/src/weapons/BulletInfo.h
+++ b/src/weapons/BulletInfo.h
@@ -1,7 +1,8 @@
#pragma once
+#include "WeaponType.h"
+
class CEntity;
-enum eWeaponType;
class CBulletInfo
{
diff --git a/src/weapons/ProjectileInfo.h b/src/weapons/ProjectileInfo.h
index b88322f9..3d8074c9 100644
--- a/src/weapons/ProjectileInfo.h
+++ b/src/weapons/ProjectileInfo.h
@@ -1,9 +1,10 @@
#pragma once
+#include "WeaponType.h"
+
class CEntity;
class CObject;
class CProjectile;
-enum eWeaponType;
class CProjectileInfo
{
diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp
index 83ce2a02..f09ae052 100644
--- a/src/weapons/ShotInfo.cpp
+++ b/src/weapons/ShotInfo.cpp
@@ -109,7 +109,7 @@ CShotInfo::Update()
if (shot.m_sourceEntity) {
assert(shot.m_sourceEntity->IsPed());
CPed *ped = (CPed*) shot.m_sourceEntity;
- float radius = max(1.0f, shot.m_radius);
+ float radius = Max(1.0f, shot.m_radius);
for (int i = 0; i < ped->m_numNearPeds; ++i) {
CPed *nearPed = ped->m_nearPeds[i];
diff --git a/src/weapons/ShotInfo.h b/src/weapons/ShotInfo.h
index a5e5fd35..db6158c2 100644
--- a/src/weapons/ShotInfo.h
+++ b/src/weapons/ShotInfo.h
@@ -1,7 +1,8 @@
#pragma once
+#include "WeaponType.h"
+
class CEntity;
-enum eWeaponType;
class CShotInfo
{
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 276693e8..b7ccb455 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -107,9 +107,11 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
CVector fireOffset(0.0f, 0.0f, 0.6f);
CVector *source = fireSource;
- if ( !fireSource )
- source = &(shooter->GetMatrix() * fireOffset);
-
+ if (!fireSource) {
+ static CVector tmp;
+ tmp = shooter->GetMatrix() * fireOffset;
+ source = &tmp;
+ }
if ( m_bAddRotOffset )
{
float heading = RADTODEG(shooter->GetForward().Heading());
@@ -997,7 +999,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
CVector dist = point->point - (*source);
- CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(ahead.x, ahead.y, 0.0f);
+ CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(ahead.x, ahead.y, 0.0f);
CVector smokePos = *source + offset;
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
@@ -1016,7 +1018,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
CVector dist = point->point - (*source);
- CVector offset = dist - max(0.2f*dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
+ CVector offset = dist - Max(0.2f*dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
CVector smokePos = *source + offset;
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
@@ -1265,7 +1267,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal*0.05f);
CVector dist = point.point - (*fireSource);
- CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
+ CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector smokePos = *fireSource + offset;
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
@@ -1280,7 +1282,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal*0.05f);
CVector dist = point.point - (*fireSource);
- CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
+ CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector smokePos = *fireSource + offset;
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
@@ -1347,7 +1349,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
else
{
CVector traceTarget = *fireSource;
- traceTarget += (target - (*fireSource)) * min(info->m_fRange, 30.0f) / info->m_fRange;
+ traceTarget += (target - (*fireSource)) * Min(info->m_fRange, 30.0f) / info->m_fRange;
CBulletTraces::AddTrace(fireSource, &traceTarget);
}
}
@@ -1877,8 +1879,9 @@ CWeapon::DoTankDoomAiming(CEntity *shooter, CEntity *driver, CVector *source, CV
if ( 3.0f*distToVictimZ < distToVictim )
{
+ CVector tmp = CVector(victim->GetPosition().x, victim->GetPosition().y, 0.0f);
if ( CCollision::DistToLine(source, target,
- &CVector(victim->GetPosition().x, victim->GetPosition().y, 0.0f)) < victim->GetBoundRadius()*3.0f )
+ &tmp) < victim->GetBoundRadius()*3.0f )
{
float vehicleDist = Sqrt(SQR(distToVictim) + SQR(distToVictimZ));
if ( vehicleDist < closestEntityDist )
@@ -2145,12 +2148,12 @@ CWeapon::MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target
ASSERT(source!=nil);
ASSERT(target!=nil);
- 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;
+ 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;
for ( int32 i = CPools::GetPedPool()->GetSize() - 1; i >= 0; i--)
{
diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h
index 265ffddb..2c3a9657 100644
--- a/src/weapons/Weapon.h
+++ b/src/weapons/Weapon.h
@@ -1,56 +1,10 @@
#pragma once
+#include "WeaponType.h"
+
#define DRIVEBYAUTOAIMING_MAXDIST (2.5f)
#define DOOMAUTOAIMING_MAXDIST (9000.0f)
-enum eWeaponType
-{
- WEAPONTYPE_UNARMED,
- WEAPONTYPE_BASEBALLBAT,
- WEAPONTYPE_COLT45,
- WEAPONTYPE_UZI,
- WEAPONTYPE_SHOTGUN,
- WEAPONTYPE_AK47,
- WEAPONTYPE_M16,
- WEAPONTYPE_SNIPERRIFLE,
- WEAPONTYPE_ROCKETLAUNCHER,
- WEAPONTYPE_FLAMETHROWER,
- WEAPONTYPE_MOLOTOV,
- WEAPONTYPE_GRENADE,
- WEAPONTYPE_DETONATOR,
- WEAPONTYPE_HELICANNON,
- WEAPONTYPE_LAST_WEAPONTYPE,
- WEAPONTYPE_ARMOUR,
- WEAPONTYPE_RAMMEDBYCAR,
- WEAPONTYPE_RUNOVERBYCAR,
- WEAPONTYPE_EXPLOSION,
- WEAPONTYPE_UZI_DRIVEBY,
- WEAPONTYPE_DROWNING,
- WEAPONTYPE_FALL,
- WEAPONTYPE_UNIDENTIFIED,
-
- WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
- WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
-};
-
-enum eWeaponFire {
- WEAPON_FIRE_MELEE,
- WEAPON_FIRE_INSTANT_HIT,
- WEAPON_FIRE_PROJECTILE,
- WEAPON_FIRE_AREA_EFFECT,
- WEAPON_FIRE_USE
-};
-
-// Taken from MTA SA, seems it's unchanged
-enum eWeaponState
-{
- WEAPONSTATE_READY,
- WEAPONSTATE_FIRING,
- WEAPONSTATE_RELOADING,
- WEAPONSTATE_OUT_OF_AMMO,
- WEAPONSTATE_MELEE_MADECONTACT
-};
-
class CEntity;
class CPhysical;
class CAutomobile;
diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h
index f82f18c5..3bafd324 100644
--- a/src/weapons/WeaponInfo.h
+++ b/src/weapons/WeaponInfo.h
@@ -1,8 +1,7 @@
#pragma once
-enum AnimationId;
-enum eWeaponFire;
-enum eWeaponType;
+#include "AnimationId.h"
+#include "WeaponType.h"
class CWeaponInfo {
// static CWeaponInfo(&ms_apWeaponInfos)[14];
diff --git a/src/weapons/WeaponType.h b/src/weapons/WeaponType.h
new file mode 100644
index 00000000..b45740b7
--- /dev/null
+++ b/src/weapons/WeaponType.h
@@ -0,0 +1,49 @@
+#pragma once
+
+enum eWeaponType
+{
+ WEAPONTYPE_UNARMED,
+ WEAPONTYPE_BASEBALLBAT,
+ WEAPONTYPE_COLT45,
+ WEAPONTYPE_UZI,
+ WEAPONTYPE_SHOTGUN,
+ WEAPONTYPE_AK47,
+ WEAPONTYPE_M16,
+ WEAPONTYPE_SNIPERRIFLE,
+ WEAPONTYPE_ROCKETLAUNCHER,
+ WEAPONTYPE_FLAMETHROWER,
+ WEAPONTYPE_MOLOTOV,
+ WEAPONTYPE_GRENADE,
+ WEAPONTYPE_DETONATOR,
+ WEAPONTYPE_HELICANNON,
+ WEAPONTYPE_LAST_WEAPONTYPE,
+ WEAPONTYPE_ARMOUR,
+ WEAPONTYPE_RAMMEDBYCAR,
+ WEAPONTYPE_RUNOVERBYCAR,
+ WEAPONTYPE_EXPLOSION,
+ WEAPONTYPE_UZI_DRIVEBY,
+ WEAPONTYPE_DROWNING,
+ WEAPONTYPE_FALL,
+ WEAPONTYPE_UNIDENTIFIED,
+
+ WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
+ WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
+};
+
+enum eWeaponFire {
+ WEAPON_FIRE_MELEE,
+ WEAPON_FIRE_INSTANT_HIT,
+ WEAPON_FIRE_PROJECTILE,
+ WEAPON_FIRE_AREA_EFFECT,
+ WEAPON_FIRE_USE
+};
+
+// Taken from MTA SA, seems it's unchanged
+enum eWeaponState
+{
+ WEAPONSTATE_READY,
+ WEAPONSTATE_FIRING,
+ WEAPONSTATE_RELOADING,
+ WEAPONSTATE_OUT_OF_AMMO,
+ WEAPONSTATE_MELEE_MADECONTACT
+}; \ No newline at end of file