Apply new formatting for NiceBulletAdapter

This commit is contained in:
Shtoyan 2023-04-09 14:52:39 +04:00
parent 3b5f46c2b5
commit 78ca66acdd

View File

@ -9,57 +9,132 @@
// E-mail: dkanus@gmail.com // E-mail: dkanus@gmail.com
//====================================================================================================================== //======================================================================================================================
class NiceBulletAdapter extends Object; class NiceBulletAdapter extends Object;
var const int BigZedMinHealth; // If zed's base Health >= this value, zed counts as Big var const int BigZedMinHealth; // If zed's base Health >= this value, zed counts as Big
var const int MediumZedMinHealth; // If zed's base Health >= this value, zed counts as Medium-size var const int MediumZedMinHealth; // If zed's base Health >= this value, zed counts as Medium-size
static function Explode(NiceBullet bullet, NiceReplicationInfo niceRI, Vector hitLocation, optional Actor explosionTarget){
static function Explode(
NiceBullet bullet,
NiceReplicationInfo niceRI,
Vector hitLocation,
optional Actor explosionTarget
) {
if (!bullet.bGhost) { if (!bullet.bGhost) {
niceRI.ServerExplode(bullet.charExplosionDamage, bullet.charExplosionRadius, bullet.charExplosionExponent, niceRI.ServerExplode(
bullet.charExplosionDamageType, bullet.charExplosionMomentum, hitLocation, bullet.instigator, true, bullet.charExplosionDamage,
explosionTarget, Vector(bullet.Rotation)); bullet.charExplosionRadius,
if(KFMonster(bullet.base) != none && bullet.bStuck && bullet.bStuckToHead) bullet.charExplosionExponent,
niceRI.ServerDealDamage(KFMonster(bullet.base), bullet.charExplosionDamage, bullet.instigator, hitLocation, bullet.charExplosionDamageType,
bullet.charExplosionMomentum * vect(0,0,-1), bullet.charExplosionDamageType, 1.0); bullet.charExplosionMomentum,
hitLocation,
bullet.instigator,
true,
explosionTarget,
Vector(bullet.Rotation)
);
if (KFMonster(bullet.base) != none && bullet.bStuck && bullet.bStuckToHead) {
niceRI.ServerDealDamage(
KFMonster(bullet.base),
bullet.charExplosionDamage,
bullet.instigator,
hitLocation,
bullet.charExplosionMomentum * vect(0, 0, -1),
bullet.charExplosionDamageType,
1.0
);
} }
} }
static function HandleCalibration }
(
static function HandleCalibration (
bool isHeadshot, bool isHeadshot,
NiceHumanPawn nicePawn, NiceHumanPawn nicePawn,
NiceMonster targetZed NiceMonster targetZed
) { ) {
if(nicePawn == none) return; if (nicePawn == none || nicePawn.currentCalibrationState != CALSTATE_ACTIVE) {
if(nicePawn.currentCalibrationState != CALSTATE_ACTIVE) return; return;
}
nicePawn.ServerUpdateCalibration(isHeadshot, targetZed); nicePawn.ServerUpdateCalibration(isHeadshot, targetZed);
} }
static function HitWall(NiceBullet bullet, NiceReplicationInfo niceRI, Actor targetWall,
Vector hitLocation, Vector hitNormal){ static function HitWall(
NiceBullet bullet,
NiceReplicationInfo niceRI,
Actor targetWall,
Vector hitLocation,
Vector hitNormal
) {
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
nicePlayer = NicePlayerController(bullet.Instigator.Controller); nicePlayer = NicePlayerController(bullet.Instigator.Controller);
if(nicePlayer == none) if (nicePlayer == none) {
return; return;
if(!bullet.bAlreadyHitZed) }
if (!bullet.bAlreadyHitZed) {
HandleCalibration(false, NiceHumanPawn(bullet.Instigator), none); HandleCalibration(false, NiceHumanPawn(bullet.Instigator), none);
if(!targetWall.bStatic && !targetWall.bWorldGeometry && nicePlayer != none && (nicePlayer.wallHitsLeft > 0 || Projectile(targetWall) != none)){ }
niceRI.ServerDealDamage(targetWall, bullet.charOrigDamage, bullet.Instigator, hitLocation, if (
bullet.charMomentumTransfer * hitNormal, bullet.charDamageType); !targetWall.bStatic &&
!targetWall.bWorldGeometry &&
nicePlayer != none &&
(nicePlayer.wallHitsLeft > 0 || Projectile(targetWall) != none)
) {
niceRI.ServerDealDamage(
targetWall,
bullet.charOrigDamage,
bullet.Instigator,
hitLocation,
bullet.charMomentumTransfer * hitNormal,
bullet.charDamageType
);
nicePlayer.wallHitsLeft --; nicePlayer.wallHitsLeft --;
} }
} }
static function HandleScream(NiceBullet bullet, NiceReplicationInfo niceRI, Vector location, Vector entryDirection){
static function HandleScream(
NiceBullet bullet,
NiceReplicationInfo niceRI,
Vector location,
Vector entryDirection
) {
bullet.charIsDud = true; bullet.charIsDud = true;
} }
static function HitPawn(NiceBullet bullet, NiceReplicationInfo niceRI, KFPawn targetPawn, Vector hitLocation,
Vector hitNormal, array<int> hitPoints){ static function HitPawn(
NiceBullet bullet,
NiceReplicationInfo niceRI,
KFPawn targetPawn,
Vector hitLocation,
Vector hitNormal,
array<int> hitPoints
) {
local NiceMedicProjectile niceDart; local NiceMedicProjectile niceDart;
niceDart = NiceMedicProjectile(bullet); niceDart = NiceMedicProjectile(bullet);
if(niceDart == none) if (niceDart == none) {
niceRI.ServerDealDamage(targetPawn, bullet.charDamage, bullet.instigator, HitLocation, niceRI.ServerDealDamage(
hitNormal * bullet.charMomentumTransfer, bullet.charDamageType); targetPawn,
else bullet.charDamage,
bullet.instigator,
HitLocation,
hitNormal * bullet.charMomentumTransfer,
bullet.charDamageType
);
} else {
niceRI.ServerHealTarget(NiceHumanPawn(targetPawn), bullet.charDamage, bullet.instigator); niceRI.ServerHealTarget(NiceHumanPawn(targetPawn), bullet.charDamage, bullet.instigator);
} }
static function HitZed(NiceBullet bullet, NiceReplicationInfo niceRI, KFMonster kfZed, Vector hitLocation, }
Vector hitNormal, float headshotLevel){
static function HitZed(
NiceBullet bullet,
NiceReplicationInfo niceRI,
KFMonster kfZed,
Vector hitLocation,
Vector hitNormal,
float headshotLevel
) {
local bool bIsHeadshot, bIsPreciseHeadshot; local bool bIsHeadshot, bIsPreciseHeadshot;
local float actualDamage; local float actualDamage;
local int lockonTicks; local int lockonTicks;
@ -68,37 +143,54 @@ static function HitZed(NiceBullet bullet, NiceReplicationInfo niceRI, KFMonster
local NiceHumanPawn nicePawn; local NiceHumanPawn nicePawn;
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
local class<NiceVeterancyTypes> niceVet; local class<NiceVeterancyTypes> niceVet;
nicePlayer = NicePlayerController(bullet.Instigator.Controller); nicePlayer = NicePlayerController(bullet.Instigator.Controller);
if ( nicePlayer != none && nicePlayer.abilityManager != none if (
&& nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillEnforcerBruteA'.default.abilityID)) { nicePlayer != none &&
nicePlayer.abilityManager != none &&
nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillEnforcerBruteA'.default.abilityID)
) {
headshotLevel = 0.0; headshotLevel = 0.0;
} }
bIsHeadshot = (headshotLevel > 0.0); bIsHeadshot = (headshotLevel > 0.0);
bIsPreciseHeadshot = (headshotLevel > bullet.charDamageType.default.prReqPrecise); bIsPreciseHeadshot = (headshotLevel > bullet.charDamageType.default.prReqPrecise);
if(!bullet.bAlreadyHitZed || bIsHeadshot) if (!bullet.bAlreadyHitZed || bIsHeadshot) {
HandleCalibration(bIsHeadshot, NiceHumanPawn(bullet.Instigator), NiceMonster(kfZed)); HandleCalibration(bIsHeadshot, NiceHumanPawn(bullet.Instigator), NiceMonster(kfZed));
if(bIsHeadshot && bullet.sourceWeapon != none) }
if (bIsHeadshot && bullet.sourceWeapon != none) {
bullet.sourceWeapon.lastHeadshotTime = bullet.Level.TimeSeconds; bullet.sourceWeapon.lastHeadshotTime = bullet.Level.TimeSeconds;
if(nicePlayer == none) }
if (nicePlayer == none) {
return; return;
}
nicePawn = NiceHumanPawn(bullet.instigator); nicePawn = NiceHumanPawn(bullet.instigator);
if( !bIsHeadshot if (
&& nicePawn != none !bIsHeadshot &&
&& nicePlayer.abilityManager != none nicePawn != none &&
&& nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillSharpshooterReaperA'.default.abilityID)) nicePlayer.abilityManager != none &&
nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillSharpshooterReaperA'.default.abilityID)
) {
nicePawn.ServerCooldownAbility(class'NiceSkillSharpshooterReaperA'.default.abilityID); nicePawn.ServerCooldownAbility(class'NiceSkillSharpshooterReaperA'.default.abilityID);
}
niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo)); niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo));
if(bullet.charCausePain) if (bullet.charCausePain) {
actualDamage = bullet.charOrigDamage; actualDamage = bullet.charOrigDamage;
else } else {
actualDamage = bullet.charDamage; actualDamage = bullet.charDamage;
if(headshotLevel > 0) }
if (headshotLevel > 0) {
actualDamage *= bullet.charContiniousBonus; actualDamage *= bullet.charContiniousBonus;
if(bullet.bGrazing) }
if (bullet.bGrazing) {
actualDamage *= class'NiceSkillSupportGraze'.default.grazeDamageMult; actualDamage *= class'NiceSkillSupportGraze'.default.grazeDamageMult;
}
bullet.bGrazing = false; bullet.bGrazing = false;
if(kfZed == bullet.lockonZed && bullet.lockonTime > bullet.sourceWeapon.stdFireRate if (
&& niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterKillConfirmed')){ kfZed == bullet.lockonZed &&
bullet.lockonTime > bullet.sourceWeapon.stdFireRate &&
niceVet != none &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterKillConfirmed')
) {
lockOnTickRate =class'NiceSkillSharpshooterKillConfirmed'.default.stackDelay; lockOnTickRate =class'NiceSkillSharpshooterKillConfirmed'.default.stackDelay;
lockonTicks = Ceil(bullet.lockonTime / lockOnTickRate) - 1; lockonTicks = Ceil(bullet.lockonTime / lockOnTickRate) - 1;
lockonTicks = Min(class'NiceSkillSharpshooterKillConfirmed'.default.maxStacks, lockonTicks); lockonTicks = Min(class'NiceSkillSharpshooterKillConfirmed'.default.maxStacks, lockonTicks);
@ -107,35 +199,57 @@ static function HitZed(NiceBullet bullet, NiceReplicationInfo niceRI, KFMonster
// damageMod *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus; // damageMod *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus;
actualDamage *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus; actualDamage *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus;
} }
if(!bullet.bGhost) if (!bullet.bGhost) {
niceRI.ServerDealDamage(kfZed, actualDamage, bullet.instigator, hitLocation, niceRI.ServerDealDamage(
bullet.charMomentumTransfer * hitNormal, bullet.charDamageType, headshotLevel, bullet.lockonTime); kfZed,
actualDamage,
bullet.instigator,
hitLocation,
bullet.charMomentumTransfer * hitNormal,
bullet.charDamageType,
headshotLevel,
bullet.lockonTime
);
}
//// Handle angled shots //// Handle angled shots
angle = asin(hitNormal.Z); angle = asin(hitNormal.Z);
// Apply angled shots // Apply angled shots
if ((angle > 0.8 || angle < -0.45) && bullet.bCanAngleDamage && kfZed != none) { if ((angle > 0.8 || angle < -0.45) && bullet.bCanAngleDamage && kfZed != none) {
bullet.bCanAngleDamage = false; bullet.bCanAngleDamage = false;
bullet.bAlreadyHitZed = true; bullet.bAlreadyHitZed = true;
if(ZedPenetration(bullet.charDamage, bullet, kfZed, bIsHeadshot, bIsPreciseHeadshot)) if (ZedPenetration(bullet.charDamage, bullet, kfZed, bIsHeadshot, bIsPreciseHeadshot)) {
HitZed(bullet, niceRI, kfZed, hitLocation, hitNormal, headshotLevel); HitZed(bullet, niceRI, kfZed, hitLocation, hitNormal, headshotLevel);
} }
}
//// 'Bore' support skill //// 'Bore' support skill
if( niceVet != none && nicePlayer.IsZedTimeActive() && bullet.insideBouncesLeft > 0 if (
&& niceVet.static.hasSkill(nicePlayer, class'NiceSkillSupportZEDBore')){ niceVet != none &&
nicePlayer.IsZedTimeActive() &&
bullet.insideBouncesLeft > 0 &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSupportZEDBore')
) {
// Count one bounce // Count one bounce
bullet.insideBouncesLeft --; bullet.insideBouncesLeft --;
// Swap head-shot level // Swap head-shot level
if(headshotLevel <= 0.0) if (headshotLevel <= 0.0) {
headshotLevel = class'NiceSkillSupportZEDBore'.default.minHeadshotPrecision; headshotLevel = class'NiceSkillSupportZEDBore'.default.minHeadshotPrecision;
else } else {
headshotLevel = -headshotLevel; headshotLevel = -headshotLevel;
}
// Deal next batch of damage // Deal next batch of damage
ZedPenetration(bullet.charDamage, bullet, kfZed, false, false); ZedPenetration(bullet.charDamage, bullet, kfZed, false, false);
HitZed(bullet, niceRI, kfZed, hitLocation, hitNormal, headshotLevel); HitZed(bullet, niceRI, kfZed, hitLocation, hitNormal, headshotLevel);
} }
bullet.insideBouncesLeft = 2; bullet.insideBouncesLeft = 2;
} }
static function bool ZedPenetration(out float Damage, NiceBullet bullet, KFMonster targetZed, bool bIsHeadshot, bool bIsPreciseHeadshot){
static function bool ZedPenetration(
out float Damage,
NiceBullet bullet,
KFMonster targetZed,
bool bIsHeadshot,
bool bIsPreciseHeadshot
) {
local float reductionMod; local float reductionMod;
local NiceMonster niceZed; local NiceMonster niceZed;
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
@ -144,31 +258,49 @@ static function bool ZedPenetration(out float Damage, NiceBullet bullet, KFMonst
local class<NiceWeaponDamageType> niceDmgType; local class<NiceWeaponDamageType> niceDmgType;
// True if we can penetrate even body, but now penetrating a head and shouldn't reduce damage too much // True if we can penetrate even body, but now penetrating a head and shouldn't reduce damage too much
local bool bEasyHeadPenetration; local bool bEasyHeadPenetration;
// Init variables // Init variables
niceZed = NiceMonster(targetZed); niceZed = NiceMonster(targetZed);
nicePlayer = NicePlayerController(bullet.Instigator.Controller); nicePlayer = NicePlayerController(bullet.Instigator.Controller);
niceVet = none; niceVet = none;
if(nicePlayer != none) if (nicePlayer != none) {
niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo)); niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo));
}
niceDmgType = bullet.charDamageType; niceDmgType = bullet.charDamageType;
bEasyHeadPenetration = bIsHeadshot && !niceDmgType.default.bPenetrationHSOnly; bEasyHeadPenetration = bIsHeadshot && !niceDmgType.default.bPenetrationHSOnly;
reductionMod = 1.0f; reductionMod = 1.0f;
// Apply zed reduction and perk reduction of reduction` // Apply zed reduction and perk reduction of reduction`
if (niceZed != none) { if (niceZed != none) {
// Railgun skill exception // Railgun skill exception
if(niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterZEDRailgun') && nicePlayer.IsZedTimeActive()) if (
niceVet != none &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterZEDRailgun') &&
nicePlayer.IsZedTimeActive()
) {
return true; return true;
if(niceZed.default.Health >= default.BigZedMinHealth && !bEasyHeadPenetration) }
if (niceZed.default.Health >= default.BigZedMinHealth && !bEasyHeadPenetration) {
reductionMod *= niceDmgType.default.BigZedPenDmgReduction; reductionMod *= niceDmgType.default.BigZedPenDmgReduction;
else if(niceZed.default.Health >= default.MediumZedMinHealth && !bEasyHeadPenetration) } else if (niceZed.default.Health >= default.MediumZedMinHealth && !bEasyHeadPenetration) {
reductionMod *= niceDmgType.default.MediumZedPenDmgReduction; reductionMod *= niceDmgType.default.MediumZedPenDmgReduction;
} }
else } else {
reductionMod *= niceDmgType.default.BigZedPenDmgReduction; reductionMod *= niceDmgType.default.BigZedPenDmgReduction;
if(niceVet != none) }
reductionMod = niceVet.static.GetPenetrationDamageMulti(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo), reductionMod, niceDmgType); if (niceVet != none) {
reductionMod = niceVet.static.GetPenetrationDamageMulti(
KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo),
reductionMod,
niceDmgType
);
}
actualMaxPenetrations = niceDmgType.default.maxPenetrations; actualMaxPenetrations = niceDmgType.default.maxPenetrations;
if(niceVet != none && !bullet.charWasHipFired && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterSurgical') && bIsHeadshot){ if (
niceVet != none &&
!bullet.charWasHipFired &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterSurgical') &&
bIsHeadshot
) {
actualMaxPenetrations += 1; actualMaxPenetrations += 1;
reductionMod = FMax(reductionMod, class'NiceSkillSharpshooterSurgical'.default.penDmgReduction); reductionMod = FMax(reductionMod, class'NiceSkillSharpshooterSurgical'.default.penDmgReduction);
} }
@ -176,20 +308,24 @@ static function bool ZedPenetration(out float Damage, NiceBullet bullet, KFMonst
Damage *= reductionMod * niceDmgType.default.PenDmgReduction; Damage *= reductionMod * niceDmgType.default.PenDmgReduction;
bullet.decapMod *= reductionMod * niceDmgType.default.PenDecapReduction; bullet.decapMod *= reductionMod * niceDmgType.default.PenDecapReduction;
bullet.incapMod *= reductionMod * niceDmgType.default.PenIncapReduction; bullet.incapMod *= reductionMod * niceDmgType.default.PenIncapReduction;
if(niceVet != none && actualMaxPenetrations >= 0) if (niceVet != none && actualMaxPenetrations >= 0) {
actualMaxPenetrations += actualMaxPenetrations +=
niceVet.static.GetAdditionalPenetrationAmount(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo)); niceVet.static.GetAdditionalPenetrationAmount(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo));
if(!bIsHeadshot && niceDmgType.default.bPenetrationHSOnly) }
if (!bIsHeadshot && niceDmgType.default.bPenetrationHSOnly) {
return false; return false;
if(actualMaxPenetrations < 0) }
if (actualMaxPenetrations < 0) {
return true; return true;
if(Damage / bullet.charOrigDamage < (niceDmgType.default.PenDmgReduction ** (actualMaxPenetrations + 1)) + 0.0001 || Damage < 1) }
if (Damage / bullet.charOrigDamage < (niceDmgType.default.PenDmgReduction ** (actualMaxPenetrations + 1)) + 0.0001 || Damage < 1) {
return false; return false;
}
return true; return true;
} }
defaultproperties defaultproperties {
{
BigZedMinHealth=1000 BigZedMinHealth=1000
MediumZedMinHealth=500 MediumZedMinHealth=500
} }