Add PlaceDefenseTowardsEnemyChance trait to basebuilderbotmodule

Add PlaceDefenseTowardsEnemyChance trait to basebuilderbotmodule. This defeaults to 100 which is the current behavior. This change now allows you to set the chance that bots will place defenses evenly around the base like the AI in stock red alert and Tiberian sun did.
This commit is contained in:
blackhand1001
2019-10-15 20:17:44 -04:00
committed by teinarss
parent 2de51ae73c
commit 780982dbe2
2 changed files with 6 additions and 1 deletions

View File

@@ -134,7 +134,9 @@ namespace OpenRA.Mods.Common.Traits
// HACK: HACK HACK HACK
// TODO: Derive this from BuildingCommonNames instead
var type = BuildingType.Building;
if (world.Map.Rules.Actors[currentBuilding.Item].HasTraitInfo<AttackBaseInfo>())
// Check if Building is a defense and if we should place it towards the enemy or not.
if (world.Map.Rules.Actors[currentBuilding.Item].HasTraitInfo<AttackBaseInfo>() && world.LocalRandom.Next(100) < baseBuilder.Info.PlaceDefenseTowardsEnemyChance)
type = BuildingType.Defense;
else if (baseBuilder.Info.RefineryTypes.Contains(world.Map.Rules.Actors[currentBuilding.Item].Name))
type = BuildingType.Refinery;