Add sentry pacing to opening battle

This commit is contained in:
2026-06-20 07:06:47 +09:00
parent 345ed20e4a
commit c26b052c90
7 changed files with 277 additions and 12 deletions

View File

@@ -536,11 +536,11 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
}
$aiBehavior = [string](Get-Prop $Deployment "ai_behavior" "")
if (-not [string]::IsNullOrWhiteSpace($aiBehavior)) {
if ($aiBehavior -ne "guard") {
if ($aiBehavior -notin @("guard", "sentry")) {
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."
Fail "Scenario $ScenarioId deployment $unitId ai_behavior $aiBehavior is only valid for enemy deployments."
}
}
if ((Has-Prop $Deployment "ai_guard_anchor") -and $aiBehavior -ne "guard") {
@@ -549,6 +549,15 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
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_sentry_anchor") -and $aiBehavior -ne "sentry") {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_anchor needs ai_behavior sentry."
}
if ((Has-Prop $Deployment "ai_sentry_radius") -and $aiBehavior -ne "sentry") {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_radius needs ai_behavior sentry."
}
if ((Has-Prop $Deployment "ai_sentry_activation_turn") -and $aiBehavior -ne "sentry") {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_activation_turn needs ai_behavior sentry."
}
if (Has-Prop $Deployment "ai_guard_radius") {
$guardRadiusValue = Get-Prop $Deployment "ai_guard_radius" 0
if (-not ($guardRadiusValue -is [int] -or $guardRadiusValue -is [long])) {
@@ -559,6 +568,26 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
Fail "Scenario $ScenarioId deployment $unitId ai_guard_radius must be between 0 and 12."
}
}
if (Has-Prop $Deployment "ai_sentry_radius") {
$sentryRadiusValue = Get-Prop $Deployment "ai_sentry_radius" 0
if (-not ($sentryRadiusValue -is [int] -or $sentryRadiusValue -is [long])) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_radius must be an integer."
}
$sentryRadius = [int]$sentryRadiusValue
if ($sentryRadius -lt 0 -or $sentryRadius -gt 12) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_radius must be between 0 and 12."
}
}
if (Has-Prop $Deployment "ai_sentry_activation_turn") {
$sentryActivationTurnValue = Get-Prop $Deployment "ai_sentry_activation_turn" 0
if (-not ($sentryActivationTurnValue -is [int] -or $sentryActivationTurnValue -is [long])) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_activation_turn must be an integer."
}
$sentryActivationTurn = [int]$sentryActivationTurnValue
if ($sentryActivationTurn -lt 0 -or $sentryActivationTurn -gt 99) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_activation_turn must be between 0 and 99."
}
}
$classId = Resolve-Class-Id $Deployment $ScenarioId
if (-not $classIds.Contains($classId)) {
@@ -606,6 +635,25 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
Fail "Scenario $ScenarioId deployment $unitId ai_guard_anchor is on impassable terrain."
}
}
if (Has-Prop $Deployment "ai_sentry_anchor") {
$sentryAnchor = Get-Prop $Deployment "ai_sentry_anchor" @()
if ($sentryAnchor.Count -lt 2) {
Fail "Scenario $ScenarioId deployment $unitId has malformed ai_sentry_anchor."
}
$sentryAnchorX = [int]$sentryAnchor[0]
$sentryAnchorY = [int]$sentryAnchor[1]
if ($sentryAnchorX -lt 0 -or $sentryAnchorY -lt 0 -or $sentryAnchorX -ge $Width -or $sentryAnchorY -ge $Height) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_anchor is outside map at [$sentryAnchorX,$sentryAnchorY]."
}
$sentryAnchorTerrainKey = Terrain-At $Rows $sentryAnchorX $sentryAnchorY
$sentryAnchorMoveCost = $terrain.$sentryAnchorTerrainKey.move_cost.$moveType
if ($null -eq $sentryAnchorMoveCost) {
$sentryAnchorMoveCost = $terrain.$sentryAnchorTerrainKey.move_cost.foot
}
if ([int]$sentryAnchorMoveCost -ge 99) {
Fail "Scenario $ScenarioId deployment $unitId ai_sentry_anchor is on impassable terrain."
}
}
}
function Add-Deployment-Unit-Id($Deployment, $Result) {