Skip to content

Shared humanoid and vehicle functions

inkoalawetrust edited this page Sep 25, 2024 · 2 revisions

This is a list of all the functions (And variables) that are shared between both humanoid and vehicle NPCs.

DetermineHitChance()

Parameters:

  • Other: The actor to check if the caller can hit.
  • Smart: If true, the check will be done by firing actual LOF traces at Other, instead of doing a simpler distance based calculation.
  • Distance: The distance to Other used by the Dumb algorithm for caching if desired, if this field is left unused, the function will calculate the distance itself.
  • DumbSpread: The spread of the attack when using the Dumb algorithm, can only be a perfect cone.
  • Shots: How many shots is the check firing ? Used by both Dumb and Smart algorithms, default is 1 shot.
  • Offset: Offsets the origin of the Smart algorithms' tracers relative to the shooter.
  • Spread: A Vector4 value that stores the horizontal and vertical spread of the Smart algorithms' tracers: X: Minimum horizontal spread Y: Maximum horizontal spread Z: Minimum vertical spread W: Maximum vertical spread
  • Range: The maximum range of the hypothetical attack.
  • TargZOfs: Offsets the vertical position that Smart algorithms' tracers are fired at relative to Other. Can be used to pass the value of a function like GetTurretAimOffset().
  • Flags:
    • DHC_HOSTILES: Counts any other actors hit by the Smart check that are hostile to the caller as successful hits too.
    • DHC_THRUHOSTILES: Implies DHC_HOSTILES, Smart check traces will go through any enemy actor already hit by another shot tracer.

Return type(s):

  • The number of hypothetical hits that landed on Other.

Function:

Returns a number of hits that will potentially land on Other from the caller. Allowing you to determine how many hits will land on an enemy. The number of hits can either be determined by actually firing traces from the caller to the shooter or by doing a purely distance based check using math.

Example

This full auto zombieman fires 10 hitscans at his enemies, but will not shoot if less than 5 of them land on his enemy.

	Override Bool ShouldAttack (Bool NoStateJump)
	{
		If (!Super.CanAttack() || !Super.ShouldAttack()) Return False;
		
		If (DetermineHitChance (Target, False, dumbspread:2, 10, range:MaxTargetRange) >= 5)
		{
			If (!NoStateJump)
				SetStateLabel (SeeState);
			
			Return True;
		}
		
		Return False;
	}
Clone this wiki locally