Skip to content

Instantly share code, notes, and snippets.

@oscar-broman
Created February 15, 2015 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscar-broman/abc7dc524730520cbf3f to your computer and use it in GitHub Desktop.
Save oscar-broman/abc7dc524730520cbf3f to your computer and use it in GitHub Desktop.
switch (weaponid) {
// The spas shotguns shoot 8 bullets, each inflicting 4.95 damage
case WEAPON_SHOTGSPA: {
bullets = amount / 4.950000286102294921875;
if (8.0 - bullets < -0.05) {
return WC_INVALID_DAMAGE;
}
}
// Shotguns and sawed-off shotguns shoot 15 bullets, each inflicting 3.3 damage
case WEAPON_SHOTGUN, WEAPON_SAWEDOFF: {
bullets = amount / 3.30000019073486328125;
if (15.0 - bullets < -0.05) {
return WC_INVALID_DAMAGE;
}
}
}
if (_:bullets) {
new Float:f = floatfract(bullets);
// The damage for each bullet has been tampered with
if (f > 0.01 && f < 0.99) {
return WC_INVALID_DAMAGE;
}
// Divide the damage amount by the number of bullets
amount /= bullets;
}
// Check chainsaw damage
if (weaponid == WEAPON_CHAINSAW) {
switch (amount) {
case 6.6000003814697265625,
13.5300006866455078125,
16.1700000762939453125,
26.40000152587890625,
27.060001373291015625: {}
default: {
return WC_INVALID_DAMAGE;
}
}
}
// Check gun damage
new Float:def_amount = 0.0;
switch (weaponid) {
case WEAPON_COLT45,
WEAPON_MP5: def_amount = 8.25;
case WEAPON_SILENCED: def_amount = 13.200000762939453125;
case WEAPON_DEAGLE: def_amount = 46.200000762939453125;
case WEAPON_UZI,
WEAPON_TEC9: def_amount = 6.6000003814697265625;
case WEAPON_AK47,
WEAPON_M4,
WEAPON_VEHICLE_M4: def_amount = 9.90000057220458984375;
case WEAPON_RIFLE: def_amount = 24.7500019073486328125;
case WEAPON_SNIPER: def_amount = 41.25;
case WEAPON_MINIGUN,
WEAPON_VEHICLE_MINIGUN: def_amount = 46.200000762939453125;
case WEAPON_VEHICLE: def_amount = 9.90000057220458984375;
}
if (_:def_amount && _:def_amount != _:amount) {
return WC_INVALID_DAMAGE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment