2020-12-13 15:01:13 +00:00
//=============================================================================
// KFAfflication_Fire
//=============================================================================
//
//=============================================================================
// Killing Floor 2
// Copyright (C) 2015 Tripwire Interactive LLC
//=============================================================================
class KFAffliction _Fire extends KFAfflictionAdvanced ;
/** How burned is this zed currently? */
var protected float FireBurnedAmount ;
/** How long does a pawn have to be burning over the heat threshhold to get to fully charred skin */
var protected float FireFullyCharredDuration ;
/** When over this % on the FirePanicResist.StackedPower, apply charring to the skin shader. Think of it like how "hot" the character needs to get before its shader gets char applied */
var protected float FireCharPercentThreshhold ;
/** On Fire Effect Template */
var protected ParticleSystem BurningTemplate ;
/** On Fire Effect Particle System Component */
var protected ParticleSystemComponent BurningEffect ;
/** Material param value from the microwave class */
var float MicrowaveParamValue ;
/** Sound to play when this pawn is on fire */
var protected AkEvent OnFireSound ;
/** Sound to play when this pawn stops being on fire */
var protected AkEvent OnFireEndSound ;
2022-05-11 15:13:25 +00:00
var transient KFPlayerController Instigator ;
2020-12-13 15:01:13 +00:00
function Init ( KFPawn P , EAfflictionType Type , KFPerk InstigatorPerk )
{
Super . Init ( P , Type , InstigatorPerk ) ;
// copy over some settings from the affliction handler that we'll need
FireFullyCharredDuration = P . AfflictionHandler . FireFullyCharredDuration ;
FireCharPercentThreshhold = P . AfflictionHandler . FireCharPercentThreshhold ;
2022-05-11 15:13:25 +00:00
if ( InstigatorPerk != none )
{
Instigator = InstigatorPerk . OwnerPC ;
}
2020-12-13 15:01:13 +00:00
}
2022-11-27 21:49:25 +00:00
function Activate ( KFPerk InstigatorPerk , optional class < KFDamageType > DamageType = none )
2020-12-13 15:01:13 +00:00
{
// fire can accrue after death, but cannot trigger panic
if ( ! PawnOwner . bPlayedDeath )
{
2022-11-27 21:49:25 +00:00
Super . Activate ( InstigatorPerk , DamageType ) ;
2020-12-13 15:01:13 +00:00
SetFirePanicked ( true ) ;
}
}
function DeActivate ( )
{
Super . DeActivate ( ) ;
BurningEffect . DeactivateSystem ( ) ;
SetFirePanicked ( false ) ;
}
event Tick ( float DeltaTime )
{
UpdateBurnedMatParam ( DeltaTime ) ;
}
/** Set the fire panic functionality */
function SetFirePanicked ( bool bEnabled )
{
if ( PawnOwner . Role == ROLE _Authority )
{
if ( PawnOwner . bFirePanicked == bEnabled )
{
return ;
}
PawnOwner . bFirePanicked = bEnabled ;
PawnOwner . OnStackingAfflictionChanged ( AF _FirePanic ) ;
}
ToggleEffects ( bEnabled ) ;
}
/** Enable/Disable the Burned material effect */
function SetMaterialParameter ( float BurnedAmount )
{
local MaterialInstanceConstant MIC ;
if ( PawnOwner . WorldInfo . NetMode != NM _DedicatedServer )
{
foreach PawnOwner . CharacterMICs ( MIC )
{
MIC . SetScalarParameterValue ( 'Scalar_Burnt' , BurnedAmount ) ;
}
if ( PawnOwner . Role < ROLE _Authority )
{
FireBurnedAmount = BurnedAmount * PawnOwner . AfflictionHandler . FireFullyCharredDuration ;
}
}
}
/** Set whether or not this pawn is doing the burning effects */
function ToggleEffects ( bool bEnabled , optional bool bDummy )
{
` warn("FIRE");
// Don't do the effects on a dedicated server
if ( PawnOwner . WorldInfo . NetMode == NM _DedicatedServer )
{
return ;
}
if ( bEnabled )
{
if ( BurningEffect == none )
{
BurningEffect = new ( self ) class 'ParticleSystemComponent' ;
BurningEffect . SetTemplate ( BurningTemplate ) ;
PawnOwner . Mesh . AttachComponentToSocket ( BurningEffect , EffectSocketName ) ;
BurningEffect . ActivateSystem ( ) ;
}
else
{
BurningEffect . SetStopSpawning ( - 1 , false ) ;
}
PawnOwner . PlaySoundBase ( OnFireSound , true , true , true ) ;
if ( PawnOwner . Role < ROLE _Authority )
{
// So the client knows when to stop burning
LastActivationTime = PawnOwner . WorldInfo . TimeSeconds ;
}
}
else
{
if ( BurningEffect != none )
{
BurningEffect . SetStopSpawning ( - 1 , true ) ;
}
PawnOwner . PlaySoundBase ( OnFireEndSound , true , true ) ;
}
}
/** Net: Server */
function UpdateBurnedMatParam ( float DeltaTime )
{
local float BurnedParam ;
local float FinalCharParam ;
if ( ! PawnOwner . bPlayedDeath && PawnOwner . GetTeamNum ( ) == 0 )
{
return ;
}
// Add additional char to the skin if we're over the threshhold
if ( ( PawnOwner . bPlayedDeath || CurrentStrength > ( INCAP _THRESHOLD * FireCharPercentThreshhold ) ) && FireBurnedAmount < FireFullyCharredDuration )
{
FireBurnedAmount = FMin ( FireBurnedAmount + DeltaTime , FireFullyCharredDuration ) ;
BurnedParam = FireBurnedAmount / FireFullyCharredDuration ;
// Use whichever is more burned, fire or microwave burn
if ( MicrowaveParamValue > BurnedParam )
{
FinalCharParam = MicrowaveParamValue ;
}
else
{
FinalCharParam = BurnedParam ;
}
PawnOwner . RepFireBurnedAmount = FloatToByte ( FinalCharParam ) ;
if ( PawnOwner . WorldInfo . NetMode != NM _DedicatedServer )
{
SetMaterialParameter ( FinalCharParam ) ;
}
}
// Handle exclusive microwave burn
else if ( MicrowaveParamValue > 0 )
{
BurnedParam = FireBurnedAmount / FireFullyCharredDuration ;
// Use whichever is more burned, fire or microwave burn
if ( MicrowaveParamValue > BurnedParam )
{
FinalCharParam = MicrowaveParamValue ;
}
else
{
FinalCharParam = BurnedParam ;
}
PawnOwner . RepFireBurnedAmount = FloatToByte ( FinalCharParam ) ;
if ( PawnOwner . WorldInfo . NetMode != NM _DedicatedServer )
{
SetMaterialParameter ( FinalCharParam ) ;
}
}
PawnOwner . DeathFireStackedPower = FloatToByte ( CurrentStrength / INCAP _THRESHOLD ) ;
}
/** On death send FirePanic strength to all clients so they can continue to burn (aka TearOffFirePanic) */
function Shutdown ( )
{
Super . Shutdown ( ) ;
if ( PawnOwner . bTearOff )
{
CurrentStrength = ByteToFloat ( PawnOwner . DeathFireStackedPower ) * INCAP _THRESHOLD ;
}
}
defaultproperties
{
DissipationRate = 10
bNeedsTick = true
BurningTemplate = ParticleSystem 'FX_Gameplay_EMIT.Chr.FX_CHR_Fire'
OnFireSound = AkEvent 'WW_WEP_SA_Flamethrower.Play_WEP_SA_Flamethrower_Fleshburn_Loop'
OnFireEndSound = AkEvent 'WW_WEP_SA_Flamethrower.Stop_WEP_SA_Flamethrower_Fleshburn_Loop'
}