FireBullets from cs16nd
This commit is contained in:
parent
3d34a0b8c3
commit
58823c5fde
@ -385,93 +385,275 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal )
|
||||
|
||||
Vector CBaseEntity::FireBullets3 ( Vector vecSrc, Vector vecDirShooting, float flSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand )
|
||||
{
|
||||
int iOriginalPenetration = iPenetration;
|
||||
int iPenetrationPower;
|
||||
float flPenetrationDistance;
|
||||
int iCurrentDamage = iDamage;
|
||||
float flCurrentDistance;
|
||||
TraceResult tr, tr2;
|
||||
Vector vecRight = gpGlobals->v_right;
|
||||
Vector vecUp = gpGlobals->v_up;
|
||||
CBaseEntity *pEntity;
|
||||
bool bHitMetal = false;
|
||||
int iSparksAmount;
|
||||
|
||||
switch (iBulletType)
|
||||
{
|
||||
case BULLET_PLAYER_9MM:
|
||||
{
|
||||
iPenetrationPower = 21;
|
||||
flPenetrationDistance = 800;
|
||||
iSparksAmount = 15;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
case BULLET_PLAYER_9MM:
|
||||
{
|
||||
iPenetrationPower = 21;
|
||||
flPenetrationDistance = 800;
|
||||
iSparksAmount = 15;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_45ACP:
|
||||
{
|
||||
iPenetrationPower = 15;
|
||||
flPenetrationDistance = 500;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-2 + RANDOM_LONG(0, 4));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_50AE:
|
||||
{
|
||||
iPenetrationPower = 30;
|
||||
flPenetrationDistance = 1000;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_762MM:
|
||||
{
|
||||
iPenetrationPower = 39;
|
||||
flPenetrationDistance = 5000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-2 + RANDOM_LONG(0, 4));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_556MM:
|
||||
{
|
||||
iPenetrationPower = 35;
|
||||
flPenetrationDistance = 4000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-3 + RANDOM_LONG(0, 6));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_338MAG:
|
||||
{
|
||||
iPenetrationPower = 45;
|
||||
flPenetrationDistance = 8000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 8));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_57MM:
|
||||
{
|
||||
iPenetrationPower = 30;
|
||||
flPenetrationDistance = 2000;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_357SIG:
|
||||
{
|
||||
iPenetrationPower = 25;
|
||||
flPenetrationDistance = 800;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
iPenetrationPower = 0;
|
||||
flPenetrationDistance = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_45ACP:
|
||||
if (!pevAttacker)
|
||||
pevAttacker = pev;
|
||||
|
||||
float x, y, z;
|
||||
|
||||
if (IsPlayer())
|
||||
{
|
||||
iPenetrationPower = 15;
|
||||
flPenetrationDistance = 500;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-2 + RANDOM_LONG(0, 4));
|
||||
break;
|
||||
x = UTIL_SharedRandomFloat(shared_rand, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 1, -0.5, 0.5);
|
||||
y = UTIL_SharedRandomFloat(shared_rand + 2, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 3, -0.5, 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_50AE:
|
||||
Vector vecDir = vecDirShooting + x * flSpread * vecRight + y * flSpread * vecUp;
|
||||
Vector vecEnd = vecSrc + vecDir * flDistance;
|
||||
Vector vecOldSrc;
|
||||
Vector vecNewSrc;
|
||||
float flDamageModifier = 0.5;
|
||||
|
||||
while (iPenetration != 0)
|
||||
{
|
||||
iPenetrationPower = 30;
|
||||
flPenetrationDistance = 1000;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
ClearMultiDamage();
|
||||
UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr);
|
||||
|
||||
char cTextureType = UTIL_TextureHit(&tr, vecSrc, vecEnd);
|
||||
bool bSparks = false;
|
||||
|
||||
switch (cTextureType)
|
||||
{
|
||||
case CHAR_TEX_METAL:
|
||||
{
|
||||
bSparks = true;
|
||||
bHitMetal = true;
|
||||
iPenetrationPower *= 0.15;
|
||||
flDamageModifier = 0.2;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_CONCRETE:
|
||||
{
|
||||
iPenetrationPower *= 0.25;
|
||||
flDamageModifier = 0.25;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_GRATE:
|
||||
{
|
||||
bSparks = true;
|
||||
bHitMetal = true;
|
||||
iPenetrationPower *= 0.5;
|
||||
flDamageModifier = 0.4;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_VENT:
|
||||
{
|
||||
bSparks = true;
|
||||
bHitMetal = true;
|
||||
iPenetrationPower *= 0.5;
|
||||
flDamageModifier = 0.45;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_TILE:
|
||||
{
|
||||
iPenetrationPower *= 0.65;
|
||||
flDamageModifier = 0.3;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_COMPUTER:
|
||||
{
|
||||
bSparks = true;
|
||||
bHitMetal = true;
|
||||
iPenetrationPower *= 0.4;
|
||||
flDamageModifier = 0.45;
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_TEX_WOOD:
|
||||
{
|
||||
iPenetrationPower *= 1;
|
||||
flDamageModifier = 0.6;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
bSparks = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
iPenetration--;
|
||||
flCurrentDistance = tr.flFraction * flDistance;
|
||||
iCurrentDamage *= pow(flRangeModifier, flCurrentDistance / 500);
|
||||
|
||||
if (flCurrentDistance > flPenetrationDistance)
|
||||
iPenetration = 0;
|
||||
|
||||
if (tr.iHitgroup == HITGROUP_SHIELD)
|
||||
{
|
||||
iPenetration = 0;
|
||||
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
if (RANDOM_LONG(0, 1))
|
||||
EMIT_SOUND(pEntity->edict(), CHAN_VOICE, "weapons/ric_metal-1.wav", 1, ATTN_NORM);
|
||||
else
|
||||
EMIT_SOUND(pEntity->edict(), CHAN_VOICE, "weapons/ric_metal-2.wav", 1, ATTN_NORM);
|
||||
|
||||
pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15);
|
||||
pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15);
|
||||
|
||||
if (pEntity->pev->punchangle.x < 4)
|
||||
pEntity->pev->punchangle.x = 4;
|
||||
|
||||
if (pEntity->pev->punchangle.z < -5)
|
||||
pEntity->pev->punchangle.z = -5;
|
||||
else if (pEntity->pev->punchangle.z > 5)
|
||||
pEntity->pev->punchangle.z = 5;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ((VARS(tr.pHit)->solid == SOLID_BSP) && (iPenetration != 0))
|
||||
{
|
||||
if (bPistol)
|
||||
DecalGunshot(&tr, iBulletType, false, pev, bHitMetal);
|
||||
else if (RANDOM_LONG(0, 3))
|
||||
DecalGunshot(&tr, iBulletType, true, pev, bHitMetal);
|
||||
|
||||
vecSrc = tr.vecEndPos + (vecDir * iPenetrationPower);
|
||||
flDistance = (flDistance - flCurrentDistance) * 0.5;
|
||||
vecEnd = vecSrc + (vecDir * flDistance);
|
||||
|
||||
pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB);
|
||||
|
||||
iCurrentDamage *= flDamageModifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bPistol)
|
||||
DecalGunshot(&tr, iBulletType, false, pev, bHitMetal);
|
||||
else if (RANDOM_LONG(0, 3))
|
||||
DecalGunshot(&tr, iBulletType, true, pev, bHitMetal);
|
||||
|
||||
vecSrc = tr.vecEndPos + (vecDir * 42);
|
||||
flDistance = (flDistance - flCurrentDistance) * 0.75;
|
||||
vecEnd = vecSrc + (vecDir * flDistance);
|
||||
|
||||
pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB);
|
||||
|
||||
iCurrentDamage *= 0.75;
|
||||
}
|
||||
}
|
||||
else
|
||||
iPenetration = 0;
|
||||
|
||||
ApplyMultiDamage(pev, pevAttacker);
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_762MM:
|
||||
{
|
||||
iPenetrationPower = 39;
|
||||
flPenetrationDistance = 5000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-2 + RANDOM_LONG(0, 4));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_556MM:
|
||||
{
|
||||
iPenetrationPower = 35;
|
||||
flPenetrationDistance = 4000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-3 + RANDOM_LONG(0, 6));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_338MAG:
|
||||
{
|
||||
iPenetrationPower = 45;
|
||||
flPenetrationDistance = 8000;
|
||||
iSparksAmount = 30;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 8));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_57MM:
|
||||
{
|
||||
iPenetrationPower = 30;
|
||||
flPenetrationDistance = 2000;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
case BULLET_PLAYER_357SIG:
|
||||
{
|
||||
iPenetrationPower = 25;
|
||||
flPenetrationDistance = 800;
|
||||
iSparksAmount = 20;
|
||||
iCurrentDamage += (-4 + RANDOM_LONG(0, 10));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
iPenetrationPower = 0;
|
||||
flPenetrationDistance = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Vector( flSpread, flSpread, 0);
|
||||
return Vector(x * flSpread, y * flSpread, 0);
|
||||
}
|
||||
/*
|
||||
=====================
|
||||
@ -1258,7 +1440,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
||||
|
||||
flags = from->client.iuser3;
|
||||
player.m_bCanShoot = flags & PLAYER_CAN_SHOOT;
|
||||
g_iFreezeTimeOver = flags & PLAYER_FREEZE_TIME_OVER;
|
||||
g_iFreezeTimeOver = !(flags & PLAYER_FREEZE_TIME_OVER);
|
||||
g_bInBombZone = flags & PLAYER_IN_BOMB_ZONE;
|
||||
g_bHoldingShield = flags & PLAYER_HOLDING_SHIELD;
|
||||
|
||||
@ -1474,7 +1656,7 @@ void _DLLEXPORT HUD_PostRunCmd( local_state_t *from, local_state_t *to, struct u
|
||||
to->client.fov = g_lastFOV;
|
||||
g_iWeaponFlags = from->weapondata[ from->client.m_iId - 1].m_iWeaponState;
|
||||
g_iPlayerFlags = from->client.flags;
|
||||
g_iFreezeTimeOver = from->client.iuser3 & PLAYER_FREEZE_TIME_OVER;
|
||||
g_iFreezeTimeOver = !(from->client.iuser3 & PLAYER_FREEZE_TIME_OVER);
|
||||
g_bInBombZone = from->client.iuser3 & PLAYER_IN_BOMB_ZONE;
|
||||
g_bHoldingShield = from->client.iuser3 & PLAYER_HOLDING_SHIELD;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user