Add event AI target priority shifts
This commit is contained in:
@@ -93,7 +93,7 @@ $validConditionTypes = @(
|
||||
"any"
|
||||
)
|
||||
$validTriggers = @("battle_start", "battle_begin", "turn_start", "unit_reaches_tile", "unit_defeated")
|
||||
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments", "withdraw_unit", "withdraw_units")
|
||||
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments", "withdraw_unit", "withdraw_units", "set_ai_target_priority")
|
||||
$validEffects = @("heal_hp", "heal_mp", "cure_status")
|
||||
$validItemKinds = @("weapon", "armor", "accessory", "consumable")
|
||||
$validItemRarities = @("common", "named")
|
||||
@@ -647,6 +647,59 @@ function Check-Event-Withdraw-Units($UnitIds, $KnownUnitIds, [string]$Context) {
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Event-Unit-Ids($Action, $KnownUnitIds, [string]$Context) {
|
||||
$unitIds = @()
|
||||
if (Has-Prop $Action "unit_ids") {
|
||||
if (-not ($Action.unit_ids -is [System.Array])) {
|
||||
Fail "$Context unit_ids must be an array."
|
||||
}
|
||||
$unitIds = @($Action.unit_ids)
|
||||
} else {
|
||||
$unitId = [string](Get-Prop $Action "unit_id" (Get-Prop $Action "id" ""))
|
||||
if (-not [string]::IsNullOrWhiteSpace($unitId)) {
|
||||
$unitIds = @($unitId)
|
||||
}
|
||||
}
|
||||
|
||||
if ($unitIds.Count -le 0) {
|
||||
Fail "$Context needs unit_id or unit_ids."
|
||||
}
|
||||
$seenUnitIds = New-Object System.Collections.Generic.HashSet[string]
|
||||
foreach ($unitIdValue in $unitIds) {
|
||||
$unitId = [string]$unitIdValue
|
||||
if ([string]::IsNullOrWhiteSpace($unitId)) {
|
||||
Fail "$Context has empty unit id."
|
||||
}
|
||||
if (-not $KnownUnitIds.Contains($unitId)) {
|
||||
Fail "$Context references unknown unit: $unitId"
|
||||
}
|
||||
if (-not $seenUnitIds.Add($unitId)) {
|
||||
Fail "$Context has duplicate unit: $unitId"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Event-Ai-Target-Priority($Action, $KnownUnitIds, [string]$Context) {
|
||||
Check-Event-Unit-Ids $Action $KnownUnitIds $Context
|
||||
if (-not (Has-Prop $Action "priority")) {
|
||||
Fail "$Context must set priority."
|
||||
}
|
||||
$priorityValue = Get-Prop $Action "priority" 0
|
||||
if (-not ($priorityValue -is [int] -or $priorityValue -is [long])) {
|
||||
Fail "$Context priority must be an integer."
|
||||
}
|
||||
$priority = [int]$priorityValue
|
||||
if ($priority -lt 0 -or $priority -gt 20) {
|
||||
Fail "$Context priority must be between 0 and 20."
|
||||
}
|
||||
if ((Has-Prop $Action "text") -and [string]::IsNullOrWhiteSpace([string](Get-Prop $Action "text" ""))) {
|
||||
Fail "$Context text must not be empty."
|
||||
}
|
||||
if ((Has-Prop $Action "silent") -and -not ((Get-Prop $Action "silent" $false) -is [bool])) {
|
||||
Fail "$Context silent must be boolean."
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Class-Equipment-Slots() {
|
||||
$weaponTypes = @()
|
||||
$armorTypes = @()
|
||||
@@ -1880,6 +1933,9 @@ foreach ($scenario in $campaign.scenarios) {
|
||||
if ($actionType -eq "withdraw_units") {
|
||||
Check-Event-Withdraw-Units (Get-Prop $action "unit_ids" $null) $knownUnitIds "Scenario $scenarioId event $eventId withdraw_units"
|
||||
}
|
||||
if ($actionType -eq "set_ai_target_priority") {
|
||||
Check-Event-Ai-Target-Priority $action $knownUnitIds "Scenario $scenarioId event $eventId set_ai_target_priority"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user