Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function  float AssessThreatTo(KFMonsterController  Monster, optional bool CheckDistance)
  2. {
  3.     local float DistancePart, RandomPart, TacticalPart;
  4.     local float DistanceSquared; // squared distance is calculated faster
  5.    
  6.     if(Monster == none || KFMonster(Monster.Pawn) == none)
  7.     {
  8.         return -1.f;
  9.     }
  10.    
  11.     if ( LastThreatMonster == Monster && LastThreatTime == Level.TimeSeconds )
  12.         return LastThreat; // threat level for the given monster has been calculated already during the current tick
  13.  
  14.     DistanceSquared = VSizeSquared(Monster.Pawn.Location - Location);
  15.  
  16.     DistancePart = 65.0;
  17.     RandomPart = 100.0 - DistancePart;
  18.     // let zeds smell blood within 25m radius - wounded players attract zeds more
  19.     if ( DistanceSquared < 1562500.0 )
  20.         TacticalPart += RandomPart * 0.40 * (HealthMax - Health) / HealthMax;  
  21.     // more chance to attack the same enemy multiple times
  22.     if ( Monster.Enemy == self || Monster.Target == self )
  23.         TacticalPart += RandomPart * 0.25;
  24.     // more chance to focus on the player, who are attacking the monster
  25.     if ( KFMonster(Monster.Pawn).LastDamagedBy == self)
  26.         TacticalPart += RandomPart * 0.25;
  27.     RandomPart = 100.0 - DistancePart - TacticalPart;
  28.  
  29.     // If target is closer than 1 meter, max DistancePart value will be used,
  30.     // otherwise DistancePart is lowering by 10% per meter
  31.     // 1 meter = 50 ups (2500 squared)
  32.     if ( DistanceSquared > 2500.0 )
  33.         DistancePart /= 1.0 + DistanceSquared / 250000.0;
  34.     RandomPart *= frand();
  35.    
  36.     // save threat level for this tick
  37.     LastThreatMonster = Monster;
  38.     LastThreatTime = Level.TimeSeconds;
  39.     LastThreat = DistancePart + TacticalPart + RandomPart;
  40.     if ( KFStoryGameInfo(Level.Game) != none )
  41.         LastThreat *= InventoryThreatModifier();
  42.     return LastThreat;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement