diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index d312947f..f64aca2e 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -1131,6 +1131,91 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting ApplyMultiDamage(pev, pevAttacker); } +void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker) +{ + static int tracerCount; + int tracer; + + TraceResult tr; + Vector vecRight, vecUp; + + vecRight = gpGlobals->v_right; + vecUp = gpGlobals->v_up; + + if (!pevAttacker) + { + // the default attacker is ourselves + pevAttacker = pev; + } + + ClearMultiDamage(); + gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); + + for (ULONG iShot = 1; iShot <= cShots; iShot++) + { + // get circular gaussian spread + float x, y, z; + + do + { + x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + z = x * x + y * y; + } + while (z > 1); + + Vector vecDir, vecEnd; + + vecDir = vecDirShooting + x * vecSpread.x * vecRight + y * vecSpread.y * vecUp; + vecEnd = vecSrc + vecDir * flDistance; + + UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); + tracer = 0; + + if (iTracerFreq != 0 && !(tracerCount++ % iTracerFreq)) + { + Vector vecTracerSrc; + + if (IsPlayer()) + { + // adjust tracer position for player + vecTracerSrc = vecSrc + Vector(0, 0, -4) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; + } + else + { + vecTracerSrc = vecSrc; + } + + // guns that always trace also always decal + if (iTracerFreq != 1) + tracer = 1; + + MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecTracerSrc); + WRITE_BYTE(TE_TRACER); + WRITE_COORD(vecTracerSrc.x); + WRITE_COORD(vecTracerSrc.y); + WRITE_COORD(vecTracerSrc.z); + WRITE_COORD(tr.vecEndPos.x); + WRITE_COORD(tr.vecEndPos.y); + WRITE_COORD(tr.vecEndPos.z); + MESSAGE_END(); + } + + // do damage, paint decals + if (tr.flFraction != 1.0f) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + float flDamage = ((1 - tr.flFraction) * iDamage); + pEntity->TraceAttack(pevAttacker, int(flDamage), vecDir, &tr, DMG_BULLET); + } + + // make bullet trails + UTIL_BubbleTrail(vecSrc, tr.vecEndPos, int((flDistance * tr.flFraction) / 64)); + } + + ApplyMultiDamage(pev, pevAttacker); +} + bool EXT_FUNC IsPenetrableEntity_default(Vector &vecSrc, Vector &vecEnd, entvars_t *pevAttacker, edict_t *pHit) { return true; diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 2b818fea..51b5254f 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -146,6 +146,7 @@ public: void EXPORT SUB_CallUseToggle() { Use(this, this, USE_TOGGLE, 0); } int ShouldToggle(USE_TYPE useType, BOOL currentState); void FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = nullptr); + void FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker = nullptr); Vector FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand = 0); void SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value); bool Intersects(CBaseEntity *pOther); diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 32887c8f..c3b6d35d 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -552,15 +552,14 @@ public: void USPFire(float flSpread, float flCycleTime, BOOL fUseSemi); void MakeBeam(); void BeamUpdate(); - int m_iShell; +private: + unsigned short m_usFireUSP; + #ifdef REGAMEDLL_API float m_flBaseDamageSil; #endif - -private: - unsigned short m_usFireUSP; }; @@ -1228,6 +1227,7 @@ private: const float M3_MAX_SPEED = 230.0f; +const float M3_DAMAGE = 20.0f; const Vector M3_CONE_VECTOR = Vector(0.0675, 0.0675, 0.0); // special shotgun spreads enum m3_e @@ -1325,12 +1325,12 @@ public: int m_iShell; int iShellOn; +private: + unsigned short m_usFireM4A1; + #ifdef REGAMEDLL_API float m_flBaseDamageSil; #endif - -private: - unsigned short m_usFireM4A1; }; @@ -1633,6 +1633,7 @@ private: const float XM1014_MAX_SPEED = 240.0f; +const float XM1014_DAMAGE = 20.0f; const Vector XM1014_CONE_VECTOR = Vector(0.0725, 0.0725, 0.0); // special shotgun spreads enum xm1014_e diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp index 81ae9b5f..e90225bc 100644 --- a/regamedll/dlls/wpn_shared/wpn_m3.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp @@ -11,6 +11,10 @@ void CM3::Spawn() m_iDefaultAmmo = M3_DEFAULT_GIVE; +#ifdef REGAMEDLL_API + CSPlayerWeapon()->m_flBaseDamage = M3_DAMAGE; +#endif + // Get ready to fall down FallInit(); @@ -100,7 +104,17 @@ void CM3::PrimaryAttack() vecSrc = m_pPlayer->GetGunPosition(); vecAiming = gpGlobals->v_forward; +#ifdef REGAMEDLL_API + float flBaseDamage = CSPlayerWeapon()->m_flBaseDamage; +#else + float flBaseDamage = M3_DAMAGE; +#endif + +#ifdef REGAMEDLL_FIXES + m_pPlayer->FireBuckshots(9, vecSrc, vecAiming, M3_CONE_VECTOR, 3000, 0, flBaseDamage); +#else m_pPlayer->FireBullets(9, vecSrc, vecAiming, M3_CONE_VECTOR, 3000, BULLET_PLAYER_BUCKSHOT, 0); +#endif #ifdef CLIENT_WEAPONS flag = FEV_NOTHOST; diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp index 9ff27a0d..4816bb7b 100644 --- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp +++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp @@ -11,6 +11,10 @@ void CXM1014::Spawn() m_iDefaultAmmo = XM1014_DEFAULT_GIVE; +#ifdef REGAMEDLL_API + CSPlayerWeapon()->m_flBaseDamage = XM1014_DAMAGE; +#endif + // Get ready to fall down FallInit(); @@ -98,7 +102,17 @@ void CXM1014::PrimaryAttack() vecSrc = m_pPlayer->GetGunPosition(); vecAiming = gpGlobals->v_forward; +#ifdef REGAMEDLL_API + float flBaseDamage = CSPlayerWeapon()->m_flBaseDamage; +#else + float flBaseDamage = XM1014_DAMAGE; +#endif + +#ifdef REGAMEDLL_FIXES + m_pPlayer->FireBuckshots(6, vecSrc, vecAiming, XM1014_CONE_VECTOR, 3048, 0, flBaseDamage); +#else m_pPlayer->FireBullets(6, vecSrc, vecAiming, XM1014_CONE_VECTOR, 3048, BULLET_PLAYER_BUCKSHOT, 0); +#endif #ifdef CLIENT_WEAPONS flag = FEV_NOTHOST;