Apply new formatting for NiceProjectileSpawner

This commit is contained in:
Shtoyan 2023-04-09 15:15:00 +04:00
parent 78ca66acdd
commit bf53b53b31

View File

@ -1,76 +1,160 @@
class NiceProjectileSpawner extends Actor class NiceProjectileSpawner extends Actor
dependson(NiceBullet); dependson(NiceBullet);
// NICETODO: use flags correctly // NICETODO: use flags correctly
static function MakeProjectile(Vector start, Rotator dir, NiceFire.ShotType shotParams, NiceFire.FireModeContext fireContext, optional bool bForceComplexTraj, static function MakeProjectile(
optional bool bDuplReal, optional bool bSkipGhosts){ Vector start,
Rotator dir,
NiceFire.ShotType shotParams,
NiceFire.FireModeContext fireContext,
optional bool bForceComplexTraj,
optional bool bDuplReal,
optional bool bSkipGhosts
) {
local int i; local int i;
local NicePack niceMut; local NicePack niceMut;
niceMut = class'NicePack'.static.Myself(fireContext.Instigator.Level); niceMut = class'NicePack'.static.Myself(fireContext.Instigator.Level);
if(niceMut == none) if (niceMut == none) {
return; return;
if(fireContext.Instigator.Role < ROLE_Authority || bDuplReal) }
if (fireContext.Instigator.Role < ROLE_Authority || bDuplReal) {
SpawnProjectile(Start, Dir, shotParams, fireContext, false, bForceComplexTraj); SpawnProjectile(Start, Dir, shotParams, fireContext, false, bForceComplexTraj);
if(fireContext.Instigator.Role == ROLE_Authority && niceMut != none && !bSkipGhosts){ }
for(i = 0;i < niceMut.playersList.Length;i ++){ if (fireContext.Instigator.Role == ROLE_Authority && niceMut != none && !bSkipGhosts) {
if(niceMut.playersList[i] != fireContext.Instigator.Controller) for (i = 0; i < niceMut.playersList.Length; i++) {
niceMut.playersList[i].ClientSpawnGhostProjectile(start, dir.pitch, dir.yaw, dir.roll, shotParams, fireContext, bForceComplexTraj); if (niceMut.playersList[i] != fireContext.Instigator.Controller) {
niceMut.playersList[i].ClientSpawnGhostProjectile(
start,
dir.pitch,
dir.yaw,
dir.roll,
shotParams,
fireContext,
bForceComplexTraj
);
}
} }
} }
} }
static function StickProjectile(KFHumanPawn instigator, Actor base, name bone, Vector shift, Rotator direction,
NiceBullet.ExplosionData expData, optional bool bDuplReal, optional bool bSkipGhosts){ static function StickProjectile(
KFHumanPawn instigator,
Actor base,
name bone,
Vector shift,
Rotator direction,
NiceBullet.ExplosionData expData,
optional bool bDuplReal,
optional bool bSkipGhosts
) {
local int i; local int i;
local NicePack niceMut; local NicePack niceMut;
niceMut = class'NicePack'.static.Myself(expData.Instigator.Level); niceMut = class'NicePack'.static.Myself(expData.Instigator.Level);
if(niceMut == none) if (niceMut == none) {
return; return;
}
niceMut.stuckCounter ++; niceMut.stuckCounter ++;
if(expData.Instigator.Role < ROLE_Authority) if (expData.Instigator.Role < ROLE_Authority) {
SpawnStuckProjectile(instigator, base, bone, shift, direction, expData, false, niceMut.stuckCounter); SpawnStuckProjectile(
if(expData.Instigator.Role == ROLE_Authority && niceMut != none){ instigator,
for(i = 0;i < niceMut.playersList.Length;i ++){ base,
if( (niceMut.playersList[i] != expData.Instigator.Controller && !bSkipGhosts) bone,
|| (niceMut.playersList[i] == expData.Instigator.Controller && bDuplReal) ) shift,
niceMut.playersList[i].ClientStickGhostProjectile(instigator, base, bone, shift, direction, expData, direction,
niceMut.stuckCounter); expData,
false,
niceMut.stuckCounter
);
}
if (expData.Instigator.Role == ROLE_Authority && niceMut != none) {
for (i = 0; i < niceMut.playersList.Length; i++) {
if (
(niceMut.playersList[i] != expData.Instigator.Controller && !bSkipGhosts) ||
(niceMut.playersList[i] == expData.Instigator.Controller && bDuplReal)
) {
niceMut.playersList[i].ClientStickGhostProjectile(
instigator,
base,
bone,
shift,
direction,
expData,
niceMut.stuckCounter
);
}
} }
} }
} }
static function NiceBullet SpawnProjectile(Vector Start, Rotator Dir, NiceFire.ShotType shotParams, NiceFire.FireModeContext fireContext, optional bool bIsGhost, optional bool bForceComplexTraj){
static function NiceBullet SpawnProjectile(
Vector Start,
Rotator Dir,
NiceFire.ShotType shotParams,
NiceFire.FireModeContext fireContext,
optional bool bIsGhost,
optional bool bForceComplexTraj
) {
local Actor other; local Actor other;
local NiceBullet niceProj; local NiceBullet niceProj;
local Vector HitLocation, HitNormal; local Vector HitLocation, HitNormal;
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
local class<NiceVeterancyTypes> niceVet; local class<NiceVeterancyTypes> niceVet;
// No class - no projectile // No class - no projectile
if(shotParams.bulletClass == none) if (shotParams.bulletClass == none) {
return none; return none;
}
// Try to spawn // Try to spawn
if(fireContext.Instigator != none) if (fireContext.Instigator != none) {
niceProj = fireContext.Instigator.Spawn(shotParams.bulletClass,,, Start, Dir); niceProj = fireContext.Instigator.Spawn(shotParams.bulletClass,,, Start, Dir);
}
// Try harder // Try harder
if(niceProj == none && fireContext.Instigator != none){ if (niceProj == none && fireContext.Instigator != none) {
other = fireContext.Instigator.Trace(HitLocation, HitNormal, Start, fireContext.Instigator.Location + fireContext.Instigator.EyePosition(), false, Vect(0,0,1)); other = fireContext.Instigator.Trace(
if(other != none) HitLocation,
HitNormal,
Start,
fireContext.Instigator.Location + fireContext.Instigator.EyePosition(),
false,
Vect(0, 0, 1)
);
if (other != none) {
Start = HitLocation; Start = HitLocation;
}
niceProj = fireContext.Instigator.Spawn(shotParams.bulletClass,,, Start, Dir); niceProj = fireContext.Instigator.Spawn(shotParams.bulletClass,,, Start, Dir);
} }
// Give up if failed after these two attempts // Give up if failed after these two attempts
if(niceProj == none) if (niceProj == none) {
return none; return none;
}
niceProj.Renew(); niceProj.Renew();
// Initialize projectile // Initialize projectile
if(fireContext.Instigator != none) if (fireContext.Instigator != none) {
nicePlayer = NicePlayerController(fireContext.Instigator.Controller); nicePlayer = NicePlayerController(fireContext.Instigator.Controller);
if(nicePlayer != none) }
if (nicePlayer != none) {
niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(nicePlayer.PlayerReplicationInfo); niceVet = class'NiceVeterancyTypes'.static.GetVeterancy(nicePlayer.PlayerReplicationInfo);
}
niceProj.bGhost = bIsGhost; niceProj.bGhost = bIsGhost;
// Fill-up data about what damage should projectile deal // Fill-up data about what damage should projectile deal
niceProj.charDamage = shotParams.damage; niceProj.charDamage = shotParams.damage;
if(niceVet != none && fireContext.bIsBursting && niceVet.static.hasSkill(nicePlayer, class'NiceSkillCommandoExplosivePower')) if (
niceVet != none &&
fireContext.bIsBursting &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillCommandoExplosivePower')
) {
niceProj.charDamage *= class'NiceSkillCommandoExplosivePower'.default.dmgMod; niceProj.charDamage *= class'NiceSkillCommandoExplosivePower'.default.dmgMod;
if(niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillSupportZEDBulletStorm') && nicePlayer.IsZedTimeActive()) }
if (
niceVet != none &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillSupportZEDBulletStorm') &&
nicePlayer.IsZedTimeActive()
) {
niceProj.charDamage = shotParams.damage * class'NiceSkillSupportZEDBulletStorm'.default.damageCut; niceProj.charDamage = shotParams.damage * class'NiceSkillSupportZEDBulletStorm'.default.damageCut;
}
niceProj.charOrigDamage = niceProj.charDamage; niceProj.charOrigDamage = niceProj.charDamage;
niceProj.charDamageType = shotParams.shotDamageType; niceProj.charDamageType = shotParams.shotDamageType;
niceProj.charExplosionDamageType = shotParams.explosionDamageType; niceProj.charExplosionDamageType = shotParams.explosionDamageType;
@ -92,40 +176,59 @@ static function NiceBullet SpawnProjectile(Vector Start, Rotator Dir, NiceFire.S
niceProj.charContiniousBonus = fireContext.continiousBonus; niceProj.charContiniousBonus = fireContext.continiousBonus;
// Fill-up data about at what speed should projectile travel // Fill-up data about at what speed should projectile travel
niceProj.movementSpeed = shotParams.projSpeed; niceProj.movementSpeed = shotParams.projSpeed;
if(niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoOnperk')) if (niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoOnperk')) {
niceProj.movementSpeed *= class'NiceSkillDemoOnperk'.default.speedBonus; niceProj.movementSpeed *= class'NiceSkillDemoOnperk'.default.speedBonus;
}
niceProj.movementDirection = Vector(niceProj.rotation); niceProj.movementDirection = Vector(niceProj.rotation);
niceProj.charAffectedByScream = shotParams.projAffectedByScream; niceProj.charAffectedByScream = shotParams.projAffectedByScream;
niceProj.charIsSticky = shotParams.bShouldStick; niceProj.charIsSticky = shotParams.bShouldStick;
niceProj.nicePlayer = nicePlayer; niceProj.nicePlayer = nicePlayer;
if(niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoVolatile')){ if (niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoVolatile')) {
niceProj.charExplosionRadius *= class'NiceSkillDemoVolatile'.default.explRangeMult; niceProj.charExplosionRadius *= class'NiceSkillDemoVolatile'.default.explRangeMult;
niceProj.charExplosionExponent *= class'NiceSkillDemoVolatile'.default.falloffMult; niceProj.charExplosionExponent *= class'NiceSkillDemoVolatile'.default.falloffMult;
niceProj.charMinExplosionDist *= class'NiceSkillDemoVolatile'.default.safeDistanceMult; niceProj.charMinExplosionDist *= class'NiceSkillDemoVolatile'.default.safeDistanceMult;
} }
if(niceVet != none && niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoZEDFullBlast') && nicePlayer.IsZedTimeActive()){ if (
niceVet != none &&
niceVet.static.hasSkill(nicePlayer, class'NiceSkillDemoZEDFullBlast') &&
nicePlayer.IsZedTimeActive()
) {
niceProj.charExplosionRadius *= class'NiceSkillDemoZEDFullBlast'.default.explRadiusMult; niceProj.charExplosionRadius *= class'NiceSkillDemoZEDFullBlast'.default.explRadiusMult;
niceProj.charExplosionExponent = 0.0; niceProj.charExplosionExponent = 0.0;
} }
if(bForceComplexTraj) if (bForceComplexTraj) {
niceProj.bDisableComplexMovement = false; niceProj.bDisableComplexMovement = false;
if(niceProj.Instigator != none && NicePlayerController(niceProj.Instigator.Controller) != none) }
if (niceProj.Instigator != none && NicePlayerController(niceProj.Instigator.Controller) != none) {
niceProj.niceRI = NicePlayerController(niceProj.Instigator.Controller).NiceRI; niceProj.niceRI = NicePlayerController(niceProj.Instigator.Controller).NiceRI;
}
// And some leftovers // And some leftovers
//niceProj.bShouldBounce = shotParams.bShouldBounce; //niceProj.bShouldBounce = shotParams.bShouldBounce;
niceProj.bInitFinished = true; niceProj.bInitFinished = true;
return niceProj; return niceProj;
} }
static function SpawnStuckProjectile(KFHumanPawn instigator, Actor base, name bone, Vector shift, Rotator direction,
NiceBullet.ExplosionData expData, bool bIsGhost, int stuckID){ static function SpawnStuckProjectile(
KFHumanPawn instigator,
Actor base,
name bone,
Vector shift,
Rotator direction,
NiceBullet.ExplosionData expData,
bool bIsGhost,
int stuckID
) {
local Pawn justPawn; local Pawn justPawn;
local NiceFire.ShotType shotParams; local NiceFire.ShotType shotParams;
local NiceFire.FireModeContext fireContext; local NiceFire.FireModeContext fireContext;
local NiceBullet spawnedBullet; local NiceBullet spawnedBullet;
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
nicePlayer = NicePlayerController(instigator.Controller); nicePlayer = NicePlayerController(instigator.Controller);
if(base == none || nicePlayer == none) if (base == none || nicePlayer == none) {
return; return;
}
justPawn = Pawn(base); justPawn = Pawn(base);
fireContext.instigator = NiceHumanPawn(instigator); fireContext.instigator = NiceHumanPawn(instigator);
fireContext.sourceWeapon = expData.sourceWeapon; fireContext.sourceWeapon = expData.sourceWeapon;
@ -139,12 +242,13 @@ static function SpawnStuckProjectile(KFHumanPawn instigator, Actor base, name bo
shotParams.explodeOnFuse = expData.explodeOnFuse; shotParams.explodeOnFuse = expData.explodeOnFuse;
shotParams.projAffectedByScream = expData.affectedByScream; shotParams.projAffectedByScream = expData.affectedByScream;
spawnedBullet = SpawnProjectile(base.location, direction, shotParams, fireContext, bIsGhost); spawnedBullet = SpawnProjectile(base.location, direction, shotParams, fireContext, bIsGhost);
if(spawnedBullet == none) if (spawnedBullet == none) {
return; return;
}
spawnedBullet.stuckID = stuckID; spawnedBullet.stuckID = stuckID;
spawnedBullet.bStuck = true; spawnedBullet.bStuck = true;
nicePlayer.RegisterStuckBullet(spawnedBullet); nicePlayer.RegisterStuckBullet(spawnedBullet);
if(justPawn != none){ if (justPawn != none) {
spawnedBullet.bStuckToHead = expData.stuckToHead; spawnedBullet.bStuckToHead = expData.stuckToHead;
spawnedBullet.SetBase(base); spawnedBullet.SetBase(base);
justPawn.AttachToBone(spawnedBullet, bone); justPawn.AttachToBone(spawnedBullet, bone);
@ -152,15 +256,13 @@ static function SpawnStuckProjectile(KFHumanPawn instigator, Actor base, name bo
spawnedBullet.SetRelativeRotation(Rotator(Vector(direction) << justPawn.GetBoneRotation(bone, 0))); spawnedBullet.SetRelativeRotation(Rotator(Vector(direction) << justPawn.GetBoneRotation(bone, 0)));
spawnedBullet.bUseBone = true; spawnedBullet.bUseBone = true;
spawnedBullet.stuckBone = bone; spawnedBullet.stuckBone = bone;
} } else {
else{
spawnedBullet.SetBase(base); spawnedBullet.SetBase(base);
spawnedBullet.SetRelativeLocation(shift); spawnedBullet.SetRelativeLocation(shift);
} }
} }
defaultproperties defaultproperties {
{
bHidden=True bHidden=True
RemoteRole=ROLE_SimulatedProxy RemoteRole=ROLE_SimulatedProxy
LifeSpan=1.000000 LifeSpan=1.000000