Teach enemy AI weapon-aware attacks
This commit is contained in:
@@ -455,7 +455,9 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
|
||||
if (-not $classIds.Contains($classId)) {
|
||||
Fail "Scenario $ScenarioId deployment $unitId references unknown class: $classId"
|
||||
}
|
||||
$classDef = $classes.$classId
|
||||
Check-Skill-Refs (Get-Prop $Deployment "skills" @()) "Scenario $ScenarioId deployment $unitId"
|
||||
Check-Equipment-Loadout (Get-Prop $Deployment "equipment" $null) $classDef "Scenario $ScenarioId deployment $unitId"
|
||||
|
||||
$pos = Get-Prop $Deployment "pos" @()
|
||||
if ($pos.Count -lt 2) {
|
||||
@@ -468,7 +470,6 @@ function Check-Deployment($Deployment, [string]$ScenarioId, [int]$Width, [int]$H
|
||||
}
|
||||
|
||||
$terrainKey = Terrain-At $Rows $x $y
|
||||
$classDef = $classes.$classId
|
||||
$moveType = [string](Get-Prop $Deployment "move_type" (Get-Prop $classDef "move_type" "foot"))
|
||||
$moveCost = $terrain.$terrainKey.move_cost.$moveType
|
||||
if ($null -eq $moveCost) {
|
||||
@@ -629,58 +630,66 @@ function Check-Class-Promotions() {
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Equipment-Loadout($Equipment, $ClassDef, [string]$Context) {
|
||||
$slots = Get-Prop $classDef "equipment_slots" $null
|
||||
if ($null -eq $Equipment) {
|
||||
return
|
||||
}
|
||||
if ($Equipment -is [string] -or $Equipment -is [System.Array]) {
|
||||
Fail "$Context equipment must be an object."
|
||||
}
|
||||
|
||||
foreach ($slot in $Equipment.PSObject.Properties) {
|
||||
$slotName = [string]$slot.Name
|
||||
$itemId = [string]$slot.Value
|
||||
if ([string]::IsNullOrWhiteSpace($itemId)) {
|
||||
continue
|
||||
}
|
||||
if (-not @("weapon", "armor", "accessory").Contains($slotName)) {
|
||||
Fail "$Context has unknown equipment slot: $slotName"
|
||||
}
|
||||
|
||||
$item = Find-Item-Def $itemId
|
||||
if ($null -eq $item) {
|
||||
Fail "$Context references unknown equipment item: $itemId"
|
||||
}
|
||||
|
||||
$kind = [string](Get-Prop $item "kind" "")
|
||||
if ($slotName -eq "weapon") {
|
||||
if ($kind -ne "weapon") {
|
||||
Fail "$Context has non-weapon item $itemId in weapon slot."
|
||||
}
|
||||
$weaponType = [string](Get-Prop $item "weapon_type" "")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "weapon" @())).Contains($weaponType))) {
|
||||
Fail "$Context cannot equip weapon type $weaponType."
|
||||
}
|
||||
} elseif ($slotName -eq "armor") {
|
||||
if ($kind -ne "armor") {
|
||||
Fail "$Context has non-armor item $itemId in armor slot."
|
||||
}
|
||||
$armorType = [string](Get-Prop $item "armor_type" "")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "armor" @())).Contains($armorType))) {
|
||||
Fail "$Context cannot equip armor type $armorType."
|
||||
}
|
||||
} elseif ($slotName -eq "accessory") {
|
||||
if ($kind -ne "accessory") {
|
||||
Fail "$Context has non-accessory item $itemId in accessory slot."
|
||||
}
|
||||
$accessoryType = [string](Get-Prop $item "accessory_type" "accessory")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "accessory" @())).Contains($accessoryType))) {
|
||||
Fail "$Context cannot equip accessory type $accessoryType."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Officer-Equipment([string]$OfficerId, $Officer) {
|
||||
$classId = [string](Get-Prop $Officer "class_id" "")
|
||||
if ([string]::IsNullOrWhiteSpace($classId) -or (-not $classIds.Contains($classId))) {
|
||||
Fail "Officer $OfficerId references unknown class: $classId"
|
||||
}
|
||||
|
||||
$classDef = $classes.$classId
|
||||
$slots = Get-Prop $classDef "equipment_slots" $null
|
||||
$equipment = Get-Prop $Officer "equipment" $null
|
||||
if ($null -eq $equipment) {
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($slot in $equipment.PSObject.Properties) {
|
||||
$slotName = [string]$slot.Name
|
||||
$itemId = [string]$slot.Value
|
||||
if ([string]::IsNullOrWhiteSpace($itemId)) {
|
||||
continue
|
||||
}
|
||||
|
||||
$item = Find-Item-Def $itemId
|
||||
if ($null -eq $item) {
|
||||
Fail "Officer $OfficerId references unknown equipment item: $itemId"
|
||||
}
|
||||
|
||||
$kind = [string](Get-Prop $item "kind" "")
|
||||
if ($slotName -eq "weapon") {
|
||||
if ($kind -ne "weapon") {
|
||||
Fail "Officer $OfficerId has non-weapon item $itemId in weapon slot."
|
||||
}
|
||||
$weaponType = [string](Get-Prop $item "weapon_type" "")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "weapon" @())).Contains($weaponType))) {
|
||||
Fail "Officer $OfficerId cannot equip weapon type $weaponType."
|
||||
}
|
||||
} elseif ($slotName -eq "armor") {
|
||||
if ($kind -ne "armor") {
|
||||
Fail "Officer $OfficerId has non-armor item $itemId in armor slot."
|
||||
}
|
||||
$armorType = [string](Get-Prop $item "armor_type" "")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "armor" @())).Contains($armorType))) {
|
||||
Fail "Officer $OfficerId cannot equip armor type $armorType."
|
||||
}
|
||||
} elseif ($slotName -eq "accessory") {
|
||||
if ($kind -ne "accessory") {
|
||||
Fail "Officer $OfficerId has non-accessory item $itemId in accessory slot."
|
||||
}
|
||||
$accessoryType = [string](Get-Prop $item "accessory_type" "accessory")
|
||||
if ($null -ne $slots -and (-not @((Get-Prop $slots "accessory" @())).Contains($accessoryType))) {
|
||||
Fail "Officer $OfficerId cannot equip accessory type $accessoryType."
|
||||
}
|
||||
}
|
||||
}
|
||||
Check-Equipment-Loadout (Get-Prop $Officer "equipment" $null) $classes.$classId "Officer $OfficerId"
|
||||
}
|
||||
|
||||
function Check-Item-Effects() {
|
||||
|
||||
Reference in New Issue
Block a user