# Creating Security Areas

## Usage

* Security areas serve two main purposes:
  * Makes the minimap say "Safe/Restricted/Hostile"
  * As an area in which specific player actions alert connected hostiles, as well as providing connectivity between devices and community NPCs (Such that pinging one enemy / device pings all devices and NPCs)

## Requirements

### Tools

* [World Builder](https://github.com/justarandomguyintheinternet/CP77_entSpawner/releases) (v.0.97 or newer)
* [ArchiveXL](https://github.com/psiberx/cp2077-archive-xl)
* [Codeware ](https://github.com/psiberx/cp2077-codeware/releases)(1.15.0 or newer)
* [WolvenKit](https://github.com/WolvenKit/WolvenKit) (With latest version of World Builder import script)

### Knowledge

* You need to have a basic understanding of:
  * Working with WolvenKit
  * Using World Builder (Spawning things and [importing](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/world-editing/object-spawner/exporting-from-object-spawner) into WolvenKit)

## Spawning the nodes

* In order to have a functional security area, you need two things:
  * A security system, linked to the security area
  * A security area, defining the area outline and type

{% hint style="warning" %}
Make sure to spawn both as `Device`(`Entity -> Device` in World Builder)
{% endhint %}

* Security system:
  * Spawn a `base\gameplay\devices\security_systems\security_system.ent`
  * Assign a unique NodeRef
* Security area:
  * Spawn a `base\gameplay\devices\security_systems\security_area\security_area_1.ent`
  * Assign a unique NodeRef
  * **Ensure that it has no rotation**, so set roll, pitch and yaw to 0

## Linking the devices

* Next we need to link the security system to the area
* To do this, we will go to the `Device -> Device Connections` header of the security system, add a new entry
* Fill the device class name field (On the left), with the device class name of the security area
  * In our case this would be `SecurityAreaControllerPS`, which can also be found under the device header of the security area
* Select the NodeRef of the security area on the right hand side of the entry

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-c3cc31b89deb0f1d7b945b05dac208fb98a68c5c%2FsecurityAreaConnections?alt=media" alt="" width="434"><figcaption><p>The security system is now linked to our security area (The device connection has the device class name and NodeRef of the security area)</p></figcaption></figure>

## Creating the outline

* Next we want to create the outline of the security area
* In order to do this, setup a `Dummy Area`, using the [guide for setting area outlines](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/world-editing/object-spawner/features-and-guides/setting-area-outlines) (Use a `Dummy Area` as area type)

{% hint style="warning" %}
Ensure that the `Dummy Area` is in the exact same position as our security area device
{% endhint %}

* Next, press the `Copy outline to clipboard` button, found in the Dummy Area

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-b434519086d8dc82e8293f72fd805617632a3d89%2FdummyAreaOutline?alt=media" alt="" width="386"><figcaption><p>Dummy area outline, linked to an outline group as described in the outlines guide</p></figcaption></figure>

## Setting the outline

* Now, we want our security area device to use our previously defined (And copied to clipboard) area outline
* Open the `Entity Instance Data` header of the security area
* Locate the `area` component, and expand it
* Right-click the `outline` header, and select `Paste outline [Number of outline markers]`

  <figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-7719dfdfdb3f09c3f27ee012e0806002cc48bedd%2FsecArea.gif?alt=media" alt="" width="259"><figcaption><p>How to copy and paste the outline</p></figcaption></figure>

## Setting area type

* By default, the area will be `Hostile`
* To change this, under the entity instance data header, locate:
  * `controller -> persistentState -> securityAreaType`
  * There you can select the type of area you want

## Recap

* You should now have:
  * A security system and security area, spawned as device
  * Both have unique NodeRefs
  * Security system has a device connection to the security area
  * Dummy outline, copy pasted the outline into the security area
* Now simply export your group from World Builder, and import into WKit using the World Builder [import feature](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/world-editing/object-spawner/exporting-from-object-spawner)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/world-editing/devices/creating-security-areas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
