Stealth & Awareness

**Tested for Shadowrun Returns and DFDC**

## The A.I. Stealth Test

The hard-coded **Stealth Test** can be found in the ShadowrunAI script in Assembly-CSharp.dll (you can view it with dnSpy). The most relevant lines are

```
int num = this.CurrentAwareness(enemy);
 int num2 = 0;
 if (tile.IsOpaque)
 			{
 				num2 += 99;
 				break;
 			}
 			num2 += StatsUtil.getCoverStealth(tile.CoverType);
 int num3 = 0;
 int num4 = enemy.GetSkill(Skill.Skill_Stealth, false) * 5 - num3 + num2 * 4;
 return num > num4;

```

And Covertype is

```
public static int getCoverStealth(StatsUtil.Cover curCover)
 	{
 		switch (curCover)
 		{
 		case StatsUtil.Cover.NONE:
 			return 0;
 		case StatsUtil.Cover.LIGHT:
 			return 1;
 			return 2;
 		default:
 			return 3;
 		}
 	}

```

This test is used in the CanAISeeTarget function also in the ShadowrunAI script. If Stealth test is true AND the target is in the line of sight cone and vision distance (default for low and high alert states is 18 tiles) then AI can see the target.
If the alert state is RED, the stealth test returns true automatically. If the target is in an opaque tile for the beholder, it is an automatic false.

It compares the result of the "enemy's" stealth test num4 against the beholder's current awareness num. Awareness (ranging from 0 to 99) was implemented in the game, and is greater if there is an alarm state. If num is greater than num4 then it returns true (the beholder suceeded in the stealth test, or, conversely, the target failed).

"enemy", in this case, is any target perceived as hostile in a character's line of sight (it could be a shadowrunner in a guard's line of sight. I point out here that there IS a stealth skill. It just never made it to the final version of the game as something you could spend karma on. Default value in isogame.Skills for stealth skill is 0. Guess everybody ended up with zero stealth. Too bad it has a weight of 5 in calculating num4

Cover type DOES give you extra stealth, however. The numbers in the StatsUtil script are:

No cover: 0
Light cover: 1
Medium cover: 2
Otherwise (heavy cover): 3

So you could have up to 12 (4 x 3) bonus from cover. I assume the in light/in darkness aspect also never made the cut to the final version.

In SRR by default if there are enemies in the map it will start in turn-based mode unless line-of-sight turn mode is enabled. That's OK if you don't want to mess with triggers that enter and exit manual turn mode. Mind you, this kind of trigger is still useful when you want to ambush enemies that you know to be behind a door.

## The Problem

SRR and Dragonfall never implemented the possibility of entering turn mode at will when turn mode is line-of-sight enabled, so you ALWAYS get ambushed by enemies unless you get a dialog option to attack them first. SRHK at last gave us the option to start combat first. Another problem is that in freemove you don't control the position of your three sidekicks, so even with Player0 having cover bonus your teammates will be spotted if they are not behind cover. Riggers must keep their drones behind cover too! Until now, I guess nobody knew that you COULD get stealth bonus from cover, since the default awareness of 75 always gets you spotted as the max cover bonus is just 12.

## The Solution

The default awareness for characters in the editor is 75, which is much bigger than the max heavy cover stealth bonus 12. Well, when building your campaign set the guard's awareness to:

11 if only heavy cover will hide you from him.
7 if medium and heavy cover will hide you from him.
3 if all three types of cover will hide you from him.
With zero awareness he won't see you at all.

### Line-of-Sight Combat OFF (game default)

And that's all you need if you are **not** going to use line-of-sight combat enter. The scene will start in turn-based mode if hostiles are present and stay in it unless you neutralise all of them. Remember that all shadowrunners and their drones must be BEHIND cover (butts sticking out from corners will be spotted when flanked by guards). Enemies will attack you if you either attack a visible enemy (just ready a weapon and click on him, the red target disk will be there) or if someone is spotted.

### Line-of-Sight Combat ON

If you are going to use line-of-sight only combat and don't want to be ambushed all the time, you need the Player Menu (on-actor-click dialog; you can see it work in "A Stitch in Time" for example) to enter and exit turn mode and be able to attack first, otherwise your three hirelings or drones will accidentally walk in front of an enemy's line of sight since you only control their movement in turn-based mode.

## Vision Cone (DFDC)

**Vision Cone** (main vision distance in tiles, default 18) and **Vision Angle** (how wide is the cone, default 90 degrees) in both Character Editor and Do > Actors > Set Actor Base Attribute. You can also build items that add bonus to them. The attribute name for vision distance is Attribute\_Vision\_Cone\_Distance. In the DFDC Editor you can also change the actors' and player's Attributes **Vision Peripheral**. The number in this attribute is the **distance** that the peripheral vision cone will cover, usually much shorter than the main vision cone. Set it to 0 to restrict detection to only the main vision cone, otherwise the actor will also detect another actor that moves into the peripheral cone. **The peripheral angle default is 270 degrees.** This angle can only be changed with the modify constant trigger using the argument AI\_PERIPHERAL\_VIS\_ANGLE

## Using the Stealth Skill

Skill\_Stealth exists in the game code, but it's default 0 for all characters. It did not make the cut to the final version of the game (along with some other skills), so you can't either spend karma on it or change it in the Character Editor or Trigger Editor. However, you can do so via **items** (outfits, cyberware etc) just as you would give a bonus to any other skill. Effectively, each point of stealth gives a **penalty of 5 to enemy awareness** during the **Stealth Test**. In this case, actors with awareness of 5 and below will never see an actor of stealth 1 unless it's red alert (not recommended due to weirdness). An actor with awareness 7 won't spot an actor of stealth 1 behind light cover (or greater) but will spot him in the open (effectively they will have awareness 7 − 5 = **2** during the Stealth Test). Remove the stealth bonus and the mechanics will return to bonus from cover only.

This is an outfit item that grants Stealth +1 and Vision Distance +5 bonuses:

```
id: "Player_NightOps"
 type: ItemType_Outfit
 uirep {
   icon: "icon_outfit_riggerflightsuit"
   name: "Milspec Camo Suit with Goggles"
   description: "Includes Vision Enhancement Goggles. Grants Vison Cone Range +5 and Stealth +1"
 }
 equippedStatusEffects {
   statMods {
     attribute: Attribute_Armor
     intModValue: 2
   }
   statMods {
     attribute: Attribute_Vision_Cone_Distance
     intModValue: 5
   }
   statMods {
     skill: Skill_Stealth
     intModValue: 1
   }
 }
 gear_bundle: "outfitriggerflightsuit"
 outfit_texture: "rigger_flightsuit"
 gear_prefab: "gear_rigger_flightsuit"
 gear_covers_arms: true
 gear_covers_hair: false
 store_cost: 750
 sorting_group: "Player Outfits"

```

## Perception

*(Tested for Shadowrun Returns)*

Quoting the developer Chris Kohnert:

*"Assuming the guard sees you, he must then make what we're calling a "perception" check (i.e. "What do I notice about him?").*
*This is where the non-combat elements of the game start to come into play. For example, if you've managed to procure a guard's uniform, he may take a look at you and decide you aren't a threat. Though, that uniform may not do you any good if you're carrying a couple of assault rifles when the standard issue weapon is a pistol. (Yes, we actually model that level of sophistication! Though whether it gets into the final game is based on how much fun it winds up being. . .)"*

AI perception can be set to **Normal (0), Smart (20) or Dim (-20)** in the Actor AI tab, next to Awareness. That will affect how an actor in an enemy team (typically lonestar and gangers) might decide the shadowrunners are Suspicious, Neutral or Friendly.

### The Scene Social Tab

AI's normal behavior is to attack anyone from an enemy team without a valid disguise. Once an AI actor engages, all nearby teammates also get into high alert and attack.

In the Scene Social tab valid **disguises** for the scene and whether unholstered weapons are allowed can be defined. Once the shadowrunners are wearing a valid disguise for the scene, they'll fool enemies of perception **Dim or Normal**. Unholstered weapons will raise suspicion unless social *allow drawn weapons* is true. Disguise items will automatically dress all 4 player characters, as long as they're selected from the Disguises item sorting group.

Alarm state on also raises suspicion. If the actor was attacked his threat perception will increase to **red alert**, and also if he saw a friendly being attacked or die. If the actor had heard gunfire or a scream he is more likely to be suspicious in **yellow alert**.

**Default bonuses and penalties (unless game constants below are changed):**

DISGUISE\_BONUS: 40

THREAT\_ENEMY\_TEAM = 37;

ALARM\_PERCEPTION\_PENALTY: -20

EXPOSED\_WEAPON\_PERCEPTION\_PENALTY: -20

AI\_PERCEPTION\_YELLOWALERT\_BONUS = 5

AI\_PERCEPTION\_REDALERT\_BONUS = 10

### Credentials

AI of perception **Smart** will see through disguises and engage unless **Player Character 0** has got a quest item with a **Credentials** value (20 or more work).

Credentials bonus: equal to credential number. So credentials 20 compensates for alarm, smart enemy or drawn weapon penalties (-20).

Credentials 40 is equivalent to a valid disguise.

40 or more + disguise allows even exposed weapons with social unchecked *allow unholstered weapons* against smart enemies*.* Credentials 60 will allow shadowrunners to bypass smart security without a disguise. The Seattle content pack has already got built-in 10-60 Credentials **quest items** that show in the game as "A stolen ID badge". Once PC0 has got the credentials item, all other PCs will get the same credentials as well.