Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

KFMod.KFPhysicsVolume


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
//=============================================================================
// KFPhysicsVolume
// AI Pawns within this volume will have their JumpZ values scaled based on
// the volume's gravity.
//=============================================================================
class KFPhysicsVolume extends PhysicsVolume;

var() float JumpZManualOverride;		// Set the AI Pawn JumpZ to this value and do not scale by gravity. 0 = No override
var() bool bScaleAIJumpZOnEntry;        // Scale the AI Pawn JumpZ by this volume's Z gravity when entered.
var() bool bRestoreAIJumpZOnExit;		// Restore the AI Pawn default JumpZ when the volume is exited.
var() float JumpZScaleFactor;			// Optionally tweak the JumpZ gravity scaled value (1.0 = no change)
var() bool bLogDebugInfo;			    // Logs entry and exit events and JumpZ values.
var() float MaxJumpZInVolumeScale;		// No AI will be allowed to have a JumpZ scaled higher than this value.
var() bool bScaleJumpZByMass;           // If true, will scale JumpZ by mass.
var() float AdditionalJumpZBloat;		// If this is a bloat, this value will be added to what was the final JumpZ adjustment

// Optionally scale the AI Pawn's JumpZ value based on this volume's gravity.
simulated event PawnEnteredVolume( Pawn Other )
{
	super.PawnEnteredVolume( Other );
	if( KFMonster( Other ) != none )
	{
		if( bScaleAIJumpZOnEntry )
		{
			if( bLogDebugInfo )
			{
				log( self$" --- "$Other$" entered volume, adjusting original JumpZ: "$Other.JumpZ$" original mass "$Other.Mass );
			}
			if( JumpZManualOverride > 0 )
			{
				// Optionally force the JumpZ to a specific value
				Other.JumpZ = JumpZManualOverride;			
			}
			else if( Other.JumpZ == Other.default.JumpZ )
			{
				if( bScaleJumpZByMass && ( Other.Mass > Other.default.JumpZ ) )
				{
					Other.JumpZ *= Max( MaxJumpZInVolumeScale, ( Other.Mass / Other.JumpZ ) );
				}
				else 
				{
					// Scale the JumpZ based on gravity and apply optional scale to refine it.
					Other.JumpZ *= ( sqrt( Gravity.Z / Default.Gravity.Z ) * JumpZScaleFactor );
				}
				if( AdditionalJumpZBloat > 0 )
				{
					if( Other.IsA( 'ZombieBloat' ) )
					{
						Other.JumpZ += AdditionalJumpZBloat;
					}
				}				
			}			
		}
	}
}

// Optionally restore the AI Pawn's JumpZ when it exits the volume (assumes the AI Pawn's default.JumpZ is the value to use)
simulated event PawnLeavingVolume( Pawn Other )
{
	super.PawnLeavingVolume( Other );
	if( KFMonster( Other ) != none )
	{
		if( bRestoreAIJumpZOnExit )
		{
			// Restore the Pawn's default JumpZ value.
			Other.JumpZ = Other.default.JumpZ;		
		}
	}
}

defaultproperties
{
     bScaleAIJumpZOnEntry=True
     JumpZScaleFactor=1.000000
     MaxJumpZInVolumeScale=1.500000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:26.000 - Creation time: Fri 13-10-2023 03:19:03.914 - Created with UnCodeX