1
0
KF2-Dev-Scripts/KFGameContent/Classes/KFWeapAttach_HRG_BallisticBouncer.uc

129 lines
3.3 KiB
Ucode
Raw Normal View History

2022-11-27 21:49:25 +00:00
//=============================================================================
// KFWeapAttach_HRG_BallisticBouncer
//=============================================================================
//
//=============================================================================
// Killing Floor 2
// Copyright (C) 2022 Tripwire Interactive LLC
//=============================================================================
class KFWeapAttach_HRG_BallisticBouncer extends KFWeaponAttachment;
var() StaticMesh ChargeStaticMesh;
var transient StaticMeshComponent ChargeAttachment;
var transient MaterialInstanceConstant ChargeMIC;
var float MinProjPlaceholderScale;
var float MaxProjPlaceHolderScale;
var bool bIsCharging;
var bool bIsFullyCharged;
var repnotify float StartFireTime;
var int ChargeLevel;
var float ChargeRTPC;
simulated function StartFire()
{
StartFireTime = WorldInfo.TimeSeconds;
bIsCharging = true;
if (ChargeAttachment == none)
{
ChargeAttachment = new (self) class'StaticMeshComponent';
ChargeAttachment.SetStaticMesh(ChargeStaticMesh);
if (WeapMesh != none)
{
2023-02-24 17:06:51 +00:00
ChargeMIC = ChargeAttachment.CreateAndSetMaterialInstanceConstant(0);
2022-11-27 21:49:25 +00:00
WeapMesh.AttachComponentToSocket(ChargeAttachment, 'MuzzleFlash');
}
else
{
AttachComponent(ChargeAttachment);
}
}
if (ChargeAttachment != none)
{
ChargeAttachment.SetScale(MinProjPlaceholderScale);
ChargeAttachment.SetHidden(false);
}
}
simulated event Tick(float DeltaTime)
{
local float ChargeValue;
2023-02-24 17:06:51 +00:00
if (bIsCharging && !bIsFullyCharged)
2022-11-27 21:49:25 +00:00
{
ChargeValue = FMin(class'KFWeap_HRG_BallisticBouncer'.default.MaxChargeTime, WorldInfo.TimeSeconds - StartFireTime) / class'KFWeap_HRG_BallisticBouncer'.default.MaxChargeTime;
if (ChargeValue >= 1.0f)
{
bIsFullyCharged = true;
ChargeValue = 1.0f;
}
2023-02-24 17:06:51 +00:00
if (ChargeMIC != none)
{
// Change Color
ChargeMIC.SetScalarParameterValue('Charge', ChargeValue);
}
2022-11-27 21:49:25 +00:00
if( ChargeAttachment != none)
{
ChargeAttachment.SetScale(MinProjPlaceholderScale + (MaxProjPlaceHolderScale - MinProjPlaceholderScale) * ChargeValue);
}
}
Super.Tick(DeltaTime);
}
simulated function FirstPersonFireEffects(Weapon W, vector HitLocation)
{
super.FirstPersonFireEffects(W, HitLocation);
if (ChargeAttachment != none)
{
ChargeAttachment.SetHidden(true);
}
}
simulated function bool ThirdPersonFireEffects(vector HitLocation, KFPawn P, byte ThirdPersonAnimRateByte)
{
bIsCharging = false;
bIsFullyCharged = false;
ChargeRTPC=0;
if (ChargeAttachment != none)
{
ChargeAttachment.SetHidden(true);
}
return Super.ThirdPersonFireEffects(HitLocation, P, ThirdPersonAnimRateByte);
}
simulated function CauseMuzzleFlash(byte FiringMode)
{
if (MuzzleFlash == None && MuzzleFlashTemplate != None)
{
AttachMuzzleFlash();
}
Super.CauseMuzzleFlash(FiringMode);
}
defaultproperties
{
ChargeRTPC=0
MuzzleFlashTemplate=KFMuzzleFlash'WEP_Mine_Reconstructor_Arch.Wep_Mine_Reconstructor_MuzzleFlash_3P'
ChargeStaticMesh = StaticMesh'WEP_HRG_BallisticBouncer_EMIT.HRG_BallisticBouncer_ball_MESH'
MinProjPlaceholderScale = 2.0f;
MaxProjPlaceholderScale = 3.0f;
}