Advertisement
inkoalawetrust

NPC threat assessment

Apr 13th, 2023
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.41 KB | Gaming | 0 0
  1.     //WIP code for the also very WIP KAI library https://github.com/inkoalawetrust/KAI
  2.    
  3.     //TODO: Virtualize this. Also add a vehicle flag that allows a vehicles' threat level to be passed down to its' turrets.
  4.     //Try heuristically determining how dangerous the other actor is. This is pretty hard to do universally. Since stuff like attacks can't be checked.
  5.     Int AssessThreatLevel (Actor Other)
  6.     {
  7.         If (!Other || IsDead (Other)) Return THREAT_NONE;
  8.        
  9.         //KAI NPCs can have specific threat levels set, in which case, just return whatever the NPCs' threat level is.
  10.         If (Other Is "KAI_Actor" && KAI_Actor(Other).ThreatLevel != THREAT_ASSESS)
  11.             Return KAI_Actor(Other).ThreatLevel;
  12.        
  13.         //It's not even a player or NPC.
  14.         If (IsInanimateObject (Other))
  15.             Return THREAT_NONE;
  16.        
  17.         //If indestructible. Then the other actor is unstoppable (Obviously)
  18.         If (HasGodMode (Other) || HasBuddha (Other) || IsIndestructible (Other) ||
  19.         //Also unstoppable if, more esoterically, it has NONSHOOTABLE (Hitscans go through), NOBLOCKMAP (Projectiles go through), and NORADIUSDMG (No splash damage)
  20.         //NOTE: If you have any FORCERADIUSDMG attacks, you might want to remove these 3 flag checks. Since your actor can harm an enemy with these properties.
  21.         Other.bNonShootable && Other.bNoBlockmap && Other.bNoRadiusDmg)
  22.             Return THREAT_UNSTOPPABLE;
  23.        
  24.         //If the actor has 2500+ health.
  25.         If ((Other.SpawnHealth() >= 2500 || Other.Health >= 2500) ||
  26.         //Or it's enormous (3.4m tall and 4.5m wide or bigger, larger than the Challenger 2 tank, which is huge).
  27.         (Other.Height >= 110 && Other.Radius >= 72))
  28.             Return THREAT_VERYDANGEROUS;
  29.         //Alternatively, if the actor has as much health as a THREAT_DANGEROUS actor, but can reflect projectiles back at enemies, it's also very dangerous.
  30.         Else If ((Other.SpawnHealth() >= 1000 || Other.Health >= 1000) && Other.bReflective && Other.bAimReflect)
  31.             Return THREAT_VERYDANGEROUS;
  32.        
  33.         //If the actor has 1000+ health. Or 500+ health and deflects projectiles, then it's dangerous.
  34.         If ((Other.SpawnHealth() >= 1000 || Other.Health >= 1000) || (Other.SpawnHealth() >= 500 || Other.Health >= 500) && Other.bReflective)
  35.             Return THREAT_DANGEROUS;
  36.        
  37.         //If the actor has 500+ health.
  38.         If ((Other.SpawnHealth() >= 500 || Other.Health >= 500) ||
  39.         //Or has 100+ health and flies or is fast.
  40.         (Other.SpawnHealth() >= 100 || Other.Health >= 100) && (IsFlying (Other) || Other.Speed >= 15) ||
  41.         //Or is weak, but flies around fast.
  42.         (Other.SpawnHealth() >= 50 || Other.Health >= 50) && IsFlying (Other) && Other.Speed >= 15)
  43.             Return THREAT_ABOVENORMAL;
  44.        
  45.         //If the actor has 100+ health. Or is weak, but fast.
  46.         If ((Other.SpawnHealth() >= 100 || Other.Health >= 100) || (Other.SpawnHealth() >= 20 || Other.Health >= 20) && Other.Speed >= 15)
  47.             Return THREAT_NORMAL;
  48.        
  49.         //If the actor has 50+ health (About as much as an Imp or Chaingunner)
  50.         If ((Other.SpawnHealth() >= 50 || Other.Health >= 50))
  51.             Return THREAT_MILD;
  52.        
  53.         //If the actor has 20+ health. AKA is about as strong as a Shotgunner or Zombieman.
  54.         If ((Other.SpawnHealth() >= 20 || Other.Health >= 20))
  55.             Return THREAT_LOW;
  56.        
  57.         //If the actor has 10 health OR LESS. Or dies on contact with anything, then it's super weak.
  58.         If ((Other.SpawnHealth() <= 10 || Other.Health <= 10) || Other.bTouchy)
  59.             Return THREAT_VERYLOW;
  60.        
  61.         Return THREAT_NONE; //If it's none of the above, then it's probably not a problem, probably.
  62.     }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement