1. Home
  2. Unity RTS Engine
  3. Units
  4. NPC Army Component

NPC Army Component

The NPC Army component handles the offense and defense behavior and strategies of a NPC faction.

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


Army Unit Management:

  1. Faction ID: The faction ID that this component belongs to.
  2. Check Army Reload: The duration of a timer that allows the faction each time to gather units needed to form an army, create needed units for the faction army or place buildings that allow to create these units.
  3. Army Units: A list that defines how should the army of the faction be built. Each slot includes a “Prefabs” list which you need to fill based on priority. The “Amount Per Hundred” defines the amount of units from this slot to create from the total army units.
  4. Default Attack Range: This is the “Attack Range” in the “Attack.cs” component for the army units when the faction is not attacking or defending.
  5. Non Attack Units Ratio: This defense how many units that don’t have the Attack component this faction will have in relation to the total amount of units (between 0 and 1). This allows to limit the amount of civilians that the faction creates.
  6. Max Non Attack Units: Maximum amount of civilian units that can not be surpassed even if the above value hasn’t been reached.

Offense: 

  1. Can Attack: If true, this faction can launch attacks on other factions. if false, it will only defend.
  2. Set Target Reload: The time needed before a faction picks a target.
  3. Randomly Pick Target: If true, then the faction will randomly pick a faction to be its target. If false, then the faction will pick the weakest faction to attack.
  4. Army Power Ratio: When a faction is attacking another faction, this determines how strong the army must be in comparison to the enemy’s army. The Army Power is defined by a sum of all the damage points that a unit can cause to another unit.
  5. Min Army Power: The minimum army power that the faction must have in any case (peace, defense or attack).
  6. Attack Time: The timer used to give orders or change orders for the units that are carrying the attack.
  7. Healers Rati: Between 0 and 1 and represents the ratio of the faction’s healers that will go with the army units while attacking.
  8. Converters Ratio: Between 0 and 1 and represents the ratio of the faction’s converters that will go with the army units while attacking.
  9. Attacking Support Range: This is the “Attack Range” in the “Attack.cs” component for the army units when the faction is attacking.

Defense:

  1. Surrender Army Power: If the army power goes below this value while the faction is attacking, then the faction will surrender and stop the attack.
  2. Defense Units Ratio: When a faction is defending against other factions, this determines how strong the defense army must be in comparison the enemy’s attacking army.
  3. Defense Ratio: The timer that checks the defense state of the faction: whether it should keep defending or not and sets the defense orders for army units.

How can we help?