1. Home
  2. Unity RTS Engine
  3. Resources
  4. NPC Resource Manager

NPC Resource Manager

The NPC Resource component handles resource collection and expanding borders for NPC factions.

When setting up a map, make sure that each faction slot has a NPC Resource component.


Resource Collection Settings:

  1. Faction ID: The faction ID that this component belongs to.
  2. Resource Need Ratio: Must always be > 1.0. This determines how safe the NPC team would like to use their resources. For example, if it is set to 2.0 and the faction needs 200 woods. Only when 400 (200 x 2) wood is available, the 200 can be used.
  3. Exploit Resources On Need: Determines how the faction decides to collect resources on need. For example, when the faction needs 200 wood to build something and they lack that amount. The higher this value is, the more chance the faction will immediately target a resource and start collecting or even expand for the sole purpose of getting this resource faster. The lower this value is, the more chance the faction will simply wait till the requested amount is met. So to disable exploiting resources on need, you can set this var to 0.0f. If you want to always exploit on need, you can set this var to 1.00f or above.
  4. Default Resource Exploit Range: Must be between 0 and 1. Defines the percentage of the resources (inside the faction’s border) that the faction will collect even if it does not need to.
  5. Resource Check Time: Each time the resource check timer is over, we check if the faction is correctly exploiting available resources.
  6. Move Collectors Range: Defines the chance that in case the NPC faction does not have resources to create resource collectors or population is saturated and all resource collectors are busy and it needs to collect another resource urgently then the NPC faction will look for the nearest resource where there are collectors and get collectors and send them to do collect the other resource (1 means all collectors will be moved to collect the new resource, 0 no one will be moved to collect the other resource).

Expanding Territory Settings:

  1. Expand Without Need: Can the faction build new centers without the need to actually expand to collect resources (expand for the sole purpose of increasing the faction’s territory)?
  2. Expand Target: Must be between 0 and 1. It refers to the percentage of the map that the team attempts to expand to. 1 being the whole map.
  3. Expand Resources: A list that holds the resources that need to be present to expand (create a new town center).
  4. Expand Time: How much time is needed for the faction to take a decision, whether to expand or not. Unless the faction reaches its territory control goals, it will keep looking to expand.

Task/Building Upgrade Settings:

  1. Task Upgrade Time: How much time is needed in order for the faction to see whether there are possible task upgrades available and whether it should upgrade or not.
  2. Task Upgrade Resource Ratio: Must be always > 1.0. This determines how safe the NPC team would like to use their resources when upgrading tasks. f it is set to 2.0 and the faction needs 200 woods for an upgrade. Only when 400 (200 x 2) wood is available, the 200 can be used to make the task upgrade.
  3. Building Upgrade Time: How much time is needed in order for the faction to see whether there are possible building upgrades available and whether it should upgrade them or not.
  4. Building Upgrade Resource Ratio: Must be always > 1.0. This determines how safe the NPC team would like to use their resources when upgrading buildings. f it is set to 2.0 and the faction needs 200 woods for an upgrade. Only when 400 (200 x 2) wood is available, the 200 can be used to make the building upgrade.

Drop Off Settings:

  1. Drop Off Control Time: This defines the time period (in seconds) at which the NPC faction checks whether all resources that are being collected have suitable drop off buildings or not.
  2. Must Have Drop Off: When enabled, then it will be a priority for the NPC faction to have a drop off building.

How can we help?