Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function float AssessThreatTo(KFMonsterController Monster, optional bool CheckDistance)
- {
- local float DistancePart, RandomPart, TacticalPart;
- local float DistanceSquared; // squared distance is calculated faster
- if(Monster == none || KFMonster(Monster.Pawn) == none)
- {
- return -1.f;
- }
- if ( LastThreatMonster == Monster && LastThreatTime == Level.TimeSeconds )
- return LastThreat; // threat level for the given monster has been calculated already during the current tick
- DistanceSquared = VSizeSquared(Monster.Pawn.Location - Location);
- DistancePart = 65.0;
- RandomPart = 100.0 - DistancePart;
- // let zeds smell blood within 25m radius - wounded players attract zeds more
- if ( DistanceSquared < 1562500.0 )
- TacticalPart += RandomPart * 0.40 * (HealthMax - Health) / HealthMax;
- // more chance to attack the same enemy multiple times
- if ( Monster.Enemy == self || Monster.Target == self )
- TacticalPart += RandomPart * 0.25;
- // more chance to focus on the player, who are attacking the monster
- if ( KFMonster(Monster.Pawn).LastDamagedBy == self)
- TacticalPart += RandomPart * 0.25;
- RandomPart = 100.0 - DistancePart - TacticalPart;
- // If target is closer than 1 meter, max DistancePart value will be used,
- // otherwise DistancePart is lowering by 10% per meter
- // 1 meter = 50 ups (2500 squared)
- if ( DistanceSquared > 2500.0 )
- DistancePart /= 1.0 + DistanceSquared / 250000.0;
- RandomPart *= frand();
- // save threat level for this tick
- LastThreatMonster = Monster;
- LastThreatTime = Level.TimeSeconds;
- LastThreat = DistancePart + TacticalPart + RandomPart;
- if ( KFStoryGameInfo(Level.Game) != none )
- LastThreat *= InventoryThreatModifier();
- return LastThreat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement