Optimize code flow

This commit is contained in:
Shtoyan 2023-04-09 14:30:28 +04:00
parent 2f3385583c
commit 3b5f46c2b5

View File

@ -332,22 +332,15 @@ function Actor GetMainActor(Actor other) {
return none; return none;
} }
// Try owner if (!other.IsA('KFPawn') && !other.IsA('KFMonster')) {
if ( // Try owner
KFPawn(other) == none && if (other.owner.IsA('KFPawn') || other.owner.IsA('KFMonster')) {
KFMonster(other) == none && return other.owner;
(KFPawn(other.owner) != none || KFMonster(other.owner) != none) }
) { // Try base
other = other.owner; if (other.base.IsA('KFPawn') || other.base.IsA('KFMonster')) {
} return other.base;
}
// Try base
if (
KFPawn(other) == none &&
KFMonster(other) == none &&
(KFPawn(other.base) != none || KFMonster(other.base) != none)
) {
other = other.base;
} }
return other; return other;
@ -694,16 +687,19 @@ function DoProcessMovement(float delta) {
} }
function Stick(Actor target, Vector hitLocation) { function Stick(Actor target, Vector hitLocation) {
local NiceMonster targetZed;
local name boneStick;
local float distToBone;
local float t;
local Vector boneStrickOrig; local Vector boneStrickOrig;
local ExplosionData expData; local ExplosionData expData;
local Actor resultTarget;
local NiceMonster targetZed;
local name boneStick;
local float distToBone, t;
if (bGhost) { if (bGhost) {
return; return;
} }
expData.instigator = instigator;
expData.sourceWeapon = sourceWeapon;
expData.bulletClass = class;
expData.explosionDamageType = charExplosionDamageType; expData.explosionDamageType = charExplosionDamageType;
expData.explosionDamage = charExplosionDamage; expData.explosionDamage = charExplosionDamage;
expData.explosionRadius = charExplosionRadius; expData.explosionRadius = charExplosionRadius;
@ -712,31 +708,13 @@ function Stick(Actor target, Vector hitLocation) {
expData.fuseTime = charFuseTime; expData.fuseTime = charFuseTime;
expData.explodeOnFuse = charExplodeOnFuse; expData.explodeOnFuse = charExplodeOnFuse;
expData.affectedByScream = charAffectedByScream; expData.affectedByScream = charAffectedByScream;
expData.sourceWeapon = sourceWeapon;
targetZed = NiceMonster(target);
if (targetZed == none) { if (!target.IsA('NiceMonster')) {
expData.bulletClass = class; hitLocation -= target.location;
expData.instigator = instigator; boneStick = 'None';
niceRI.ServerStickProjectile( resultTarget = target;
KFHumanPawn(instigator),
target,
'None',
hitLocation - target.location,
Rotator(movementDirection),
expData
);
class'NiceProjectileSpawner'.static.StickProjectile(
KFHumanPawn(instigator),
target,
'None',
hitLocation - target.location,
Rotator(movementDirection),
expData
);
} else { } else {
expData.bulletClass = class; targetZed = NiceMonster(target);
expData.instigator = instigator;
boneStick = targetZed.GetClosestBone(hitLocation, movementDirection, distToBone); boneStick = targetZed.GetClosestBone(hitLocation, movementDirection, distToBone);
if (CheckHeadshot(targetZed, hitLocation, movementDirection) > 0.0) { if (CheckHeadshot(targetZed, hitLocation, movementDirection) > 0.0) {
boneStick = targetZed.HeadBone; boneStick = targetZed.HeadBone;
@ -751,23 +729,27 @@ function Stick(Actor target, Vector hitLocation) {
t /= VSizeSquared(movementDirection); t /= VSizeSquared(movementDirection);
t *= 0.5; t *= 0.5;
hitLocation = hitLocation + t * movementDirection; hitLocation = hitLocation + t * movementDirection;
niceRI.ServerStickProjectile( hitLocation -= boneStrickOrig;
KFHumanPawn(instigator), resultTarget = targetZed;
targetZed,
boneStick,
hitLocation - boneStrickOrig,
Rotator(movementDirection),
expData
);
class'NiceProjectileSpawner'.static.StickProjectile(
KFHumanPawn(instigator),
targetZed,
boneStick,
hitLocation - boneStrickOrig,
Rotator(movementDirection),
expData
);
} }
niceRI.ServerStickProjectile(
KFHumanPawn(instigator),
resultTarget,
boneStick,
hitLocation,
Rotator(movementDirection),
expData
);
class'NiceProjectileSpawner'.static.StickProjectile(
KFHumanPawn(instigator),
resultTarget,
boneStick,
hitLocation,
Rotator(movementDirection),
expData
);
KillBullet(); KillBullet();
} }