Add guard behavior for opening defenders
This commit is contained in:
@@ -534,6 +534,31 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_target_priority must be between 0 and 20."
|
||||
}
|
||||
}
|
||||
$aiBehavior = [string](Get-Prop $Deployment "ai_behavior" "")
|
||||
if (-not [string]::IsNullOrWhiteSpace($aiBehavior)) {
|
||||
if ($aiBehavior -ne "guard") {
|
||||
Fail "Scenario $ScenarioId deployment $unitId has unknown ai_behavior: $aiBehavior"
|
||||
}
|
||||
if ($team -ne "enemy") {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_behavior guard is only valid for enemy deployments."
|
||||
}
|
||||
}
|
||||
if ((Has-Prop $Deployment "ai_guard_anchor") -and $aiBehavior -ne "guard") {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_anchor needs ai_behavior guard."
|
||||
}
|
||||
if ((Has-Prop $Deployment "ai_guard_radius") -and $aiBehavior -ne "guard") {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_radius needs ai_behavior guard."
|
||||
}
|
||||
if (Has-Prop $Deployment "ai_guard_radius") {
|
||||
$guardRadiusValue = Get-Prop $Deployment "ai_guard_radius" 0
|
||||
if (-not ($guardRadiusValue -is [int] -or $guardRadiusValue -is [long])) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_radius must be an integer."
|
||||
}
|
||||
$guardRadius = [int]$guardRadiusValue
|
||||
if ($guardRadius -lt 0 -or $guardRadius -gt 12) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_radius must be between 0 and 12."
|
||||
}
|
||||
}
|
||||
|
||||
$classId = Resolve-Class-Id $Deployment $ScenarioId
|
||||
if (-not $classIds.Contains($classId)) {
|
||||
@@ -562,6 +587,25 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
|
||||
if ([int]$moveCost -ge 99) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId starts on impassable terrain."
|
||||
}
|
||||
if (Has-Prop $Deployment "ai_guard_anchor") {
|
||||
$anchor = Get-Prop $Deployment "ai_guard_anchor" @()
|
||||
if ($anchor.Count -lt 2) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId has malformed ai_guard_anchor."
|
||||
}
|
||||
$anchorX = [int]$anchor[0]
|
||||
$anchorY = [int]$anchor[1]
|
||||
if ($anchorX -lt 0 -or $anchorY -lt 0 -or $anchorX -ge $Width -or $anchorY -ge $Height) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_anchor is outside map at [$anchorX,$anchorY]."
|
||||
}
|
||||
$anchorTerrainKey = Terrain-At $Rows $anchorX $anchorY
|
||||
$anchorMoveCost = $terrain.$anchorTerrainKey.move_cost.$moveType
|
||||
if ($null -eq $anchorMoveCost) {
|
||||
$anchorMoveCost = $terrain.$anchorTerrainKey.move_cost.foot
|
||||
}
|
||||
if ([int]$anchorMoveCost -ge 99) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId ai_guard_anchor is on impassable terrain."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Add-Deployment-Unit-Id($Deployment, $Result) {
|
||||
|
||||
Reference in New Issue
Block a user