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 MediumZedMinHealth; // If zed's base Health >= this value, zed counts as Medium-size var const int BigZedMinHealth; // If zed's base Health >= this value, zed counts as Big
static function Explode(NiceBullet bullet, NiceReplicationInfo niceRI, Vector hitLocation, optional Actor explosionTarget){ var const int MediumZedMinHealth; // If zed's base Health >= this value, zed counts as Medium-size
if(!bullet.bGhost){
niceRI.ServerExplode(bullet.charExplosionDamage, bullet.charExplosionRadius, bullet.charExplosionExponent, static function Explode(
bullet.charExplosionDamageType, bullet.charExplosionMomentum, hitLocation, bullet.instigator, true, NiceBullet bullet,
explosionTarget, Vector(bullet.Rotation)); NiceReplicationInfo niceRI,
if(KFMonster(bullet.base) != none && bullet.bStuck && bullet.bStuckToHead) Vector hitLocation,
niceRI.ServerDealDamage(KFMonster(bullet.base), bullet.charExplosionDamage, bullet.instigator, hitLocation, optional Actor explosionTarget
bullet.charExplosionMomentum * vect(0,0,-1), bullet.charExplosionDamageType, 1.0); ) {
if (!bullet.bGhost) {
niceRI.ServerExplode(
bullet.charExplosionDamage,
bullet.charExplosionRadius,
bullet.charExplosionExponent,
bullet.charExplosionDamageType,
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) }
HandleCalibration(false, NiceHumanPawn(bullet.Instigator), none); if (!bullet.bAlreadyHitZed) {
if(!targetWall.bStatic && !targetWall.bWorldGeometry && nicePlayer != none && (nicePlayer.wallHitsLeft > 0 || Projectile(targetWall) != none)){ HandleCalibration(false, NiceHumanPawn(bullet.Instigator), none);
niceRI.ServerDealDamage(targetWall, bullet.charOrigDamage, bullet.Instigator, hitLocation, }
bullet.charMomentumTransfer * hitNormal, bullet.charDamageType); if (
nicePlayer.wallHitsLeft --; !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 --;
} }
} }
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,
niceRI.ServerHealTarget(NiceHumanPawn(targetPawn), bullet.charDamage, bullet.instigator); bullet.instigator,
HitLocation,
hitNormal * bullet.charMomentumTransfer,
bullet.charDamageType
);
} else {
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,74 +143,113 @@ 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) }
bullet.sourceWeapon.lastHeadshotTime = bullet.Level.TimeSeconds; if (bIsHeadshot && bullet.sourceWeapon != none) {
if(nicePlayer == none) bullet.sourceWeapon.lastHeadshotTime = bullet.Level.TimeSeconds;
return; }
nicePawn = NiceHumanPawn(bullet.instigator); if (nicePlayer == none) {
if( !bIsHeadshot return;
&& nicePawn != none }
&& nicePlayer.abilityManager != none nicePawn = NiceHumanPawn(bullet.instigator);
&& nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillSharpshooterReaperA'.default.abilityID)) if (
nicePawn.ServerCooldownAbility(class'NiceSkillSharpshooterReaperA'.default.abilityID); !bIsHeadshot &&
niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo)); nicePawn != none &&
if(bullet.charCausePain) nicePlayer.abilityManager != none &&
actualDamage = bullet.charOrigDamage; nicePlayer.abilityManager.IsAbilityActive(class'NiceSkillSharpshooterReaperA'.default.abilityID)
else ) {
actualDamage = bullet.charDamage; nicePawn.ServerCooldownAbility(class'NiceSkillSharpshooterReaperA'.default.abilityID);
if(headshotLevel > 0) }
actualDamage *= bullet.charContiniousBonus; niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo));
if(bullet.bGrazing) if (bullet.charCausePain) {
actualDamage *= class'NiceSkillSupportGraze'.default.grazeDamageMult; actualDamage = bullet.charOrigDamage;
bullet.bGrazing = false; } else {
if(kfZed == bullet.lockonZed && bullet.lockonTime > bullet.sourceWeapon.stdFireRate actualDamage = bullet.charDamage;
&& niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterKillConfirmed')){ }
lockOnTickRate =class'NiceSkillSharpshooterKillConfirmed'.default.stackDelay; if (headshotLevel > 0) {
lockonTicks = Ceil(bullet.lockonTime / lockOnTickRate) - 1; actualDamage *= bullet.charContiniousBonus;
lockonTicks = Min(class'NiceSkillSharpshooterKillConfirmed'.default.maxStacks, lockonTicks); }
//actualDamage *= 1.0 + if (bullet.bGrazing) {
// 0.5 * lockonTicks * (lockonTicks + 1) * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus; actualDamage *= class'NiceSkillSupportGraze'.default.grazeDamageMult;
//damageMod *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus; }
actualDamage *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus; bullet.bGrazing = false;
if (
kfZed == bullet.lockonZed &&
bullet.lockonTime > bullet.sourceWeapon.stdFireRate &&
niceVet != none &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterKillConfirmed')
) {
lockOnTickRate =class'NiceSkillSharpshooterKillConfirmed'.default.stackDelay;
lockonTicks = Ceil(bullet.lockonTime / lockOnTickRate) - 1;
lockonTicks = Min(class'NiceSkillSharpshooterKillConfirmed'.default.maxStacks, lockonTicks);
// actualDamage *= 1.0 +
// 0.5 * lockonTicks * (lockonTicks + 1) * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus;
// damageMod *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus;
actualDamage *= 1.0 + lockonTicks * class'NiceSkillSharpshooterKillConfirmed'.default.damageBonus;
}
if (!bullet.bGhost) {
niceRI.ServerDealDamage(
kfZed,
actualDamage,
bullet.instigator,
hitLocation,
bullet.charMomentumTransfer * hitNormal,
bullet.charDamageType,
headshotLevel,
bullet.lockonTime
);
} }
if(!bullet.bGhost)
niceRI.ServerDealDamage(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 &&
// Count one bounce nicePlayer.IsZedTimeActive() &&
bullet.insideBouncesLeft --; bullet.insideBouncesLeft > 0 &&
// Swap head-shot level niceVet.static.hasSkill(nicePlayer, class'NiceSkillSupportZEDBore')
if(headshotLevel <= 0.0) ) {
headshotLevel = class'NiceSkillSupportZEDBore'.default.minHeadshotPrecision; // Count one bounce
else bullet.insideBouncesLeft --;
headshotLevel = -headshotLevel; // Swap head-shot level
// Deal next batch of damage if (headshotLevel <= 0.0) {
ZedPenetration(bullet.charDamage, bullet, kfZed, false, false); headshotLevel = class'NiceSkillSupportZEDBore'.default.minHeadshotPrecision;
HitZed(bullet, niceRI, kfZed, hitLocation, hitNormal, headshotLevel); } else {
headshotLevel = -headshotLevel;
}
// Deal next batch of damage
ZedPenetration(bullet.charDamage, bullet, kfZed, false, false);
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,52 +258,74 @@ 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 (
return true; niceVet != none &&
if(niceZed.default.Health >= default.BigZedMinHealth && !bEasyHeadPenetration) niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterZEDRailgun') &&
reductionMod *= niceDmgType.default.BigZedPenDmgReduction; nicePlayer.IsZedTimeActive()
else if(niceZed.default.Health >= default.MediumZedMinHealth && !bEasyHeadPenetration) ) {
reductionMod *= niceDmgType.default.MediumZedPenDmgReduction; return true;
} }
else if (niceZed.default.Health >= default.BigZedMinHealth && !bEasyHeadPenetration) {
reductionMod *= niceDmgType.default.BigZedPenDmgReduction;
} else if (niceZed.default.Health >= default.MediumZedMinHealth && !bEasyHeadPenetration) {
reductionMod *= niceDmgType.default.MediumZedPenDmgReduction;
}
} else {
reductionMod *= niceDmgType.default.BigZedPenDmgReduction; reductionMod *= niceDmgType.default.BigZedPenDmgReduction;
if(niceVet != none) }
reductionMod = niceVet.static.GetPenetrationDamageMulti(KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo), reductionMod, niceDmgType); if (niceVet != none) {
actualMaxPenetrations = niceDmgType.default.maxPenetrations; reductionMod = niceVet.static.GetPenetrationDamageMulti(
if(niceVet != none && !bullet.charWasHipFired && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterSurgical') && bIsHeadshot){ KFPlayerReplicationInfo(nicePlayer.PlayerReplicationInfo),
actualMaxPenetrations += 1; reductionMod,
reductionMod = FMax(reductionMod, class'NiceSkillSharpshooterSurgical'.default.penDmgReduction); niceDmgType
} );
}
actualMaxPenetrations = niceDmgType.default.maxPenetrations;
if (
niceVet != none &&
!bullet.charWasHipFired &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSharpshooterSurgical') &&
bIsHeadshot
) {
actualMaxPenetrations += 1;
reductionMod = FMax(reductionMod, class'NiceSkillSharpshooterSurgical'.default.penDmgReduction);
}
// Assign new damage value and tell us if we should stop with penetration // Assign new damage value and tell us if we should stop with penetration
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) }
return false; if (!bIsHeadshot && niceDmgType.default.bPenetrationHSOnly) {
if(actualMaxPenetrations < 0) return false;
return true; }
if(Damage / bullet.charOrigDamage < (niceDmgType.default.PenDmgReduction ** (actualMaxPenetrations + 1)) + 0.0001 || Damage < 1) if (actualMaxPenetrations < 0) {
return false; return true;
}
if (Damage / bullet.charOrigDamage < (niceDmgType.default.PenDmgReduction ** (actualMaxPenetrations + 1)) + 0.0001 || Damage < 1) {
return false;
}
return true; return true;
} }
defaultproperties defaultproperties {
{ BigZedMinHealth=1000
BigZedMinHealth=1000 MediumZedMinHealth=500
MediumZedMinHealth=500
} }