mirror of
https://github.com/solcloud/Counter-Strike.git
synced 2025-02-23 19:32:50 +01:00
BaseWeapon lower damage on long distance support
This commit is contained in:
parent
06959d04b8
commit
d7701bc641
@ -5,9 +5,9 @@ namespace cs\Core;
|
||||
use cs\Enum\ArmorType;
|
||||
use cs\Enum\HitBoxType;
|
||||
use cs\Enum\ItemType;
|
||||
use cs\Interface\AttackEnable;
|
||||
use cs\Interface\HitIntersect;
|
||||
use cs\Interface\Hittable;
|
||||
use cs\Weapon\BaseWeapon;
|
||||
use cs\Weapon\Knife;
|
||||
|
||||
class HitBox implements Hittable
|
||||
@ -71,9 +71,15 @@ class HitBox implements Hittable
|
||||
$hitBoxType = HitBoxType::BACK;
|
||||
}
|
||||
|
||||
/** @var BaseWeapon $shootItem */
|
||||
$shootItem = $bullet->getShootItem();
|
||||
$playerArmorType = $this->player->getArmorType();
|
||||
$healthDamage = $shootItem->getDamageValue($hitBoxType, $playerArmorType);
|
||||
$bulletDistance = $bullet->getDistanceTraveled();
|
||||
if ($bulletDistance > $shootItem::rangeMaxDamage) {
|
||||
$portion = ($bulletDistance - $shootItem::rangeMaxDamage) / ($shootItem::range + 1 - $shootItem::rangeMaxDamage);
|
||||
$healthDamage = (int)ceil($healthDamage * (1 - max(0.9999, $portion)));
|
||||
}
|
||||
$isTeamDamage = ($bullet->isOriginPlayerAttackerSide() === $this->player->isPlayingOnAttackerSide());
|
||||
if ($isTeamDamage) {
|
||||
$healthDamage = (int)ceil($healthDamage / 2);
|
||||
@ -88,7 +94,7 @@ class HitBox implements Hittable
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateArmorDamage(AttackEnable $shootItem, ArmorType $armorType, HitBoxType $hitBoxType): int
|
||||
private function calculateArmorDamage(BaseWeapon $shootItem, ArmorType $armorType, HitBoxType $hitBoxType): int
|
||||
{
|
||||
if ($armorType === ArmorType::NONE || $hitBoxType === HitBoxType::LEG) {
|
||||
return 0;
|
||||
@ -98,9 +104,7 @@ class HitBox implements Hittable
|
||||
}
|
||||
|
||||
$armorDamage = 0;
|
||||
if ($shootItem instanceof Item) {
|
||||
$armorDamage += ($shootItem->getType() === ItemType::TYPE_WEAPON_PRIMARY ? 20 : 10);
|
||||
}
|
||||
$armorDamage += ($shootItem->getType() === ItemType::TYPE_WEAPON_PRIMARY ? 20 : 10);
|
||||
if ($armorType === ArmorType::BODY_AND_HEAD && $hitBoxType === HitBoxType::HEAD) {
|
||||
$armorDamage += 30;
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ abstract class BaseWeapon extends Item
|
||||
public const recoilResetMs = 0;
|
||||
public const damage = 0;
|
||||
public const armorPenetration = 0;
|
||||
public const range = 0;
|
||||
public const range = 5123;
|
||||
public const rangeMaxDamage = 5123;
|
||||
public const recoilPattern = [];
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ final class PistolGlock extends AmmoBasedWeapon
|
||||
public const killAward = 300;
|
||||
public const fireRateMs = 150;
|
||||
public const damage = 61;
|
||||
public const range = 5123;
|
||||
public const rangeMaxDamage = 2600;
|
||||
public const recoilResetMs = 300;
|
||||
public const recoilPattern = [
|
||||
[0, 0],
|
||||
|
@ -15,7 +15,7 @@ final class PistolP250 extends AmmoBasedWeapon
|
||||
public const killAward = 300;
|
||||
public const fireRateMs = 150;
|
||||
public const damage = 61;
|
||||
public const range = 5123;
|
||||
public const rangeMaxDamage = 3000;
|
||||
public const recoilResetMs = 400;
|
||||
public const recoilPattern = [
|
||||
[0, 0],
|
||||
|
@ -15,7 +15,7 @@ final class PistolUsp extends AmmoBasedWeapon
|
||||
public const killAward = 300;
|
||||
public const fireRateMs = 170;
|
||||
public const damage = 116;
|
||||
public const range = 5123;
|
||||
public const rangeMaxDamage = 2800;
|
||||
public const recoilResetMs = 300;
|
||||
public const recoilPattern = [
|
||||
[0, 0],
|
||||
|
@ -17,7 +17,6 @@ final class RifleAk extends AmmoBasedWeapon
|
||||
public const fireRateMs = 100;
|
||||
public const damage = 36;
|
||||
public const armorPenetration = 77;
|
||||
public const range = 5123;
|
||||
public const recoilResetMs = 800;
|
||||
public const recoilPattern = [
|
||||
[0,0],
|
||||
|
@ -17,7 +17,6 @@ final class RifleM4A4 extends AmmoBasedWeapon
|
||||
public const fireRateMs = 90;
|
||||
public const damage = 33;
|
||||
public const armorPenetration = 67;
|
||||
public const range = 5123;
|
||||
public const recoilResetMs = 700;
|
||||
public const recoilPattern = [
|
||||
[0, 0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user