@v12-engine/engine 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abilities/amounts.d.ts +28 -0
- package/dist/abilities/amounts.js +74 -0
- package/dist/abilities/amounts.js.map +1 -0
- package/dist/abilities/buffs.d.ts +106 -6
- package/dist/abilities/buffs.js +443 -0
- package/dist/abilities/buffs.js.map +1 -0
- package/dist/abilities/castTold.d.ts +2 -0
- package/dist/abilities/castTold.js +66 -0
- package/dist/abilities/castTold.js.map +1 -0
- package/dist/abilities/chance.d.ts +38 -0
- package/dist/abilities/chance.js +77 -0
- package/dist/abilities/chance.js.map +1 -0
- package/dist/abilities/charges.d.ts +18 -0
- package/dist/abilities/charges.js +101 -0
- package/dist/abilities/charges.js.map +1 -0
- package/dist/abilities/control.d.ts +28 -0
- package/dist/abilities/control.js +113 -0
- package/dist/abilities/control.js.map +1 -0
- package/dist/abilities/dispel.js +51 -0
- package/dist/abilities/dispel.js.map +1 -0
- package/dist/abilities/effectFields.d.ts +1 -1
- package/dist/abilities/effectFields.js +676 -0
- package/dist/abilities/effectFields.js.map +1 -0
- package/dist/abilities/effectIndex.d.ts +27 -0
- package/dist/abilities/effectIndex.js +64 -0
- package/dist/abilities/effectIndex.js.map +1 -0
- package/dist/abilities/effects/buff.d.ts +9 -3
- package/dist/abilities/effects/buff.js +84 -0
- package/dist/abilities/effects/buff.js.map +1 -0
- package/dist/abilities/effects/conditions.d.ts +2 -0
- package/dist/abilities/effects/conditions.js +41 -0
- package/dist/abilities/effects/conditions.js.map +1 -0
- package/dist/abilities/effects/core.js +54 -0
- package/dist/abilities/effects/core.js.map +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -1
- package/dist/abilities/effects/damage.js +43 -0
- package/dist/abilities/effects/damage.js.map +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -2
- package/dist/abilities/effects/heal.js +51 -0
- package/dist/abilities/effects/heal.js.map +1 -0
- package/dist/abilities/effects/missile.d.ts +13 -1
- package/dist/abilities/effects/missile.js +104 -0
- package/dist/abilities/effects/missile.js.map +1 -0
- package/dist/abilities/effects/morph.d.ts +5 -0
- package/dist/abilities/effects/morph.js +43 -0
- package/dist/abilities/effects/morph.js.map +1 -0
- package/dist/abilities/effects/moves.d.ts +16 -4
- package/dist/abilities/effects/moves.js +212 -0
- package/dist/abilities/effects/moves.js.map +1 -0
- package/dist/abilities/effects/passives.d.ts +19 -9
- package/dist/abilities/effects/passives.js +131 -0
- package/dist/abilities/effects/passives.js.map +1 -0
- package/dist/abilities/effects/proxy.d.ts +5 -0
- package/dist/abilities/effects/proxy.js +60 -0
- package/dist/abilities/effects/proxy.js.map +1 -0
- package/dist/abilities/effects/sight.d.ts +2 -2
- package/dist/abilities/effects/sight.js +39 -0
- package/dist/abilities/effects/sight.js.map +1 -0
- package/dist/abilities/effects/spawn.d.ts +5 -2
- package/dist/abilities/effects/spawn.js +40 -0
- package/dist/abilities/effects/spawn.js.map +1 -0
- package/dist/abilities/effects/timed.d.ts +2 -2
- package/dist/abilities/effects/timed.js +96 -0
- package/dist/abilities/effects/timed.js.map +1 -0
- package/dist/abilities/effects/trade.d.ts +1 -1
- package/dist/abilities/effects/trade.js +25 -0
- package/dist/abilities/effects/trade.js.map +1 -0
- package/dist/abilities/effects.d.ts +97 -23
- package/dist/abilities/effects.js +860 -0
- package/dist/abilities/effects.js.map +1 -0
- package/dist/abilities/land.d.ts +38 -4
- package/dist/abilities/land.js +189 -0
- package/dist/abilities/land.js.map +1 -0
- package/dist/abilities/recast.d.ts +45 -0
- package/dist/abilities/recast.js +118 -0
- package/dist/abilities/recast.js.map +1 -0
- package/dist/abilities/scaled.js +40 -0
- package/dist/abilities/scaled.js.map +1 -0
- package/dist/abilities/screen.d.ts +6 -0
- package/dist/abilities/screen.js +83 -0
- package/dist/abilities/screen.js.map +1 -0
- package/dist/abilities/shapes.d.ts +66 -0
- package/dist/abilities/shapes.js +122 -0
- package/dist/abilities/shapes.js.map +1 -0
- package/dist/abilities/text.d.ts +14 -2
- package/dist/abilities/text.js +204 -0
- package/dist/abilities/text.js.map +1 -0
- package/dist/abilities/triggers.d.ts +98 -0
- package/dist/abilities/triggers.js +351 -0
- package/dist/abilities/triggers.js.map +1 -0
- package/dist/abilityChanges.d.ts +131 -0
- package/dist/abilityChanges.js +345 -0
- package/dist/abilityChanges.js.map +1 -0
- package/dist/ai/area.d.ts +4 -1
- package/dist/ai/brain.d.ts +4 -1
- package/dist/ai/brain.js +844 -0
- package/dist/ai/brain.js.map +1 -0
- package/dist/ai/budget.js +74 -0
- package/dist/ai/budget.js.map +1 -0
- package/dist/ai/checks.d.ts +9 -1
- package/dist/ai/checks.js +242 -0
- package/dist/ai/checks.js.map +1 -0
- package/dist/ai/computer.d.ts +11 -4
- package/dist/ai/computer.js +251 -0
- package/dist/ai/computer.js.map +1 -0
- package/dist/ai/defence.d.ts +4 -0
- package/dist/ai/defence.js +430 -0
- package/dist/ai/defence.js.map +1 -0
- package/dist/ai/define.d.ts +3 -2
- package/dist/ai/define.js +31 -0
- package/dist/ai/define.js.map +1 -0
- package/dist/ai/economy.d.ts +10 -7
- package/dist/ai/economy.js +780 -0
- package/dist/ai/economy.js.map +1 -0
- package/dist/ai/geometry.js +38 -0
- package/dist/ai/geometry.js.map +1 -0
- package/dist/ai/goals.d.ts +1 -0
- package/dist/ai/goals.js +560 -0
- package/dist/ai/goals.js.map +1 -0
- package/dist/ai/knowledge.d.ts +72 -7
- package/dist/ai/knowledge.js +804 -0
- package/dist/ai/knowledge.js.map +1 -0
- package/dist/ai/lanes.d.ts +10 -2
- package/dist/ai/lanes.js +715 -0
- package/dist/ai/lanes.js.map +1 -0
- package/dist/ai/melee/build.js +264 -0
- package/dist/ai/melee/build.js.map +1 -0
- package/dist/ai/melee/goals.d.ts +7 -0
- package/dist/ai/melee/goals.js +720 -0
- package/dist/ai/melee/goals.js.map +1 -0
- package/dist/ai/melee/heroes.js +68 -0
- package/dist/ai/melee/heroes.js.map +1 -0
- package/dist/ai/melee/index.d.ts +1 -1
- package/dist/ai/melee/index.js +51 -0
- package/dist/ai/melee/index.js.map +1 -0
- package/dist/ai/melee/production.js +29 -0
- package/dist/ai/melee/production.js.map +1 -0
- package/dist/ai/melee/surrender.js +64 -0
- package/dist/ai/melee/surrender.js.map +1 -0
- package/dist/ai/micro.d.ts +9 -0
- package/dist/ai/micro.js +1316 -0
- package/dist/ai/micro.js.map +1 -0
- package/dist/ai/mission.d.ts +9 -2
- package/dist/ai/mission.js +538 -0
- package/dist/ai/mission.js.map +1 -0
- package/dist/ai/missionRules.d.ts +1 -1
- package/dist/ai/missionRules.js +26 -0
- package/dist/ai/missionRules.js.map +1 -0
- package/dist/ai/module.d.ts +6 -2
- package/dist/ai/module.js +37 -0
- package/dist/ai/module.js.map +1 -0
- package/dist/ai/options.d.ts +3 -3
- package/dist/ai/plans/build.d.ts +20 -1
- package/dist/ai/plans/build.js +608 -0
- package/dist/ai/plans/build.js.map +1 -0
- package/dist/ai/plans/placement.d.ts +4 -1
- package/dist/ai/plans/placement.js +295 -0
- package/dist/ai/plans/placement.js.map +1 -0
- package/dist/ai/plans/plans.d.ts +9 -0
- package/dist/ai/plans/plans.js +110 -0
- package/dist/ai/plans/plans.js.map +1 -0
- package/dist/ai/plans/production.d.ts +14 -2
- package/dist/ai/plans/production.js +434 -0
- package/dist/ai/plans/production.js.map +1 -0
- package/dist/ai/plans/purse.d.ts +6 -3
- package/dist/ai/plans/purse.js +139 -0
- package/dist/ai/plans/purse.js.map +1 -0
- package/dist/ai/plans/tech.d.ts +6 -0
- package/dist/ai/plans/tech.js +122 -0
- package/dist/ai/plans/tech.js.map +1 -0
- package/dist/ai/profiles.d.ts +4 -4
- package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
- package/dist/ai/profiles.js.map +1 -0
- package/dist/ai/reach.js +54 -0
- package/dist/ai/reach.js.map +1 -0
- package/dist/ai/report.d.ts +8 -0
- package/dist/ai/report.js +87 -0
- package/dist/ai/report.js.map +1 -0
- package/dist/ai/roles.d.ts +4 -0
- package/dist/ai/roles.js +207 -0
- package/dist/ai/roles.js.map +1 -0
- package/dist/ai/rules.d.ts +8 -2
- package/dist/ai/rules.js +416 -0
- package/dist/ai/rules.js.map +1 -0
- package/dist/ai/scouting.d.ts +6 -0
- package/dist/ai/scouting.js +324 -0
- package/dist/ai/scouting.js.map +1 -0
- package/dist/ai/settings.js +99 -0
- package/dist/ai/settings.js.map +1 -0
- package/dist/ai/squads.d.ts +21 -2
- package/dist/ai/squads.js +916 -0
- package/dist/ai/squads.js.map +1 -0
- package/dist/ai/strength.js +320 -0
- package/dist/ai/strength.js.map +1 -0
- package/dist/ai/task.d.ts +3 -1
- package/dist/ai/task.js +17 -0
- package/dist/ai/task.js.map +1 -0
- package/dist/ai/tasks/attack.js +24 -0
- package/dist/ai/tasks/attack.js.map +1 -0
- package/dist/ai/tasks/capture.d.ts +3 -3
- package/dist/ai/tasks/capture.js +37 -0
- package/dist/ai/tasks/capture.js.map +1 -0
- package/dist/ai/tasks/creep.js +29 -0
- package/dist/ai/tasks/creep.js.map +1 -0
- package/dist/ai/tasks/defend.js +61 -0
- package/dist/ai/tasks/defend.js.map +1 -0
- package/dist/ai/tasks/drop.js +81 -0
- package/dist/ai/tasks/drop.js.map +1 -0
- package/dist/ai/tasks/escort.js +59 -0
- package/dist/ai/tasks/escort.js.map +1 -0
- package/dist/ai/tasks/gather.js +48 -0
- package/dist/ai/tasks/gather.js.map +1 -0
- package/dist/ai/tasks/harass.js +39 -0
- package/dist/ai/tasks/harass.js.map +1 -0
- package/dist/ai/tasks/hold.js +32 -0
- package/dist/ai/tasks/hold.js.map +1 -0
- package/dist/ai/tasks/index.js +34 -0
- package/dist/ai/tasks/index.js.map +1 -0
- package/dist/ai/tasks/move.js +26 -0
- package/dist/ai/tasks/move.js.map +1 -0
- package/dist/ai/tasks/patrol.js +59 -0
- package/dist/ai/tasks/patrol.js.map +1 -0
- package/dist/ai/tasks/retreat.js +28 -0
- package/dist/ai/tasks/retreat.js.map +1 -0
- package/dist/ai/tasks/scout.js +73 -0
- package/dist/ai/tasks/scout.js.map +1 -0
- package/dist/ai/tasks/shared.d.ts +1 -1
- package/dist/ai/tasks/shared.js +137 -0
- package/dist/ai/tasks/shared.js.map +1 -0
- package/dist/ai/team.d.ts +18 -1
- package/dist/ai/team.js +492 -0
- package/dist/ai/team.js.map +1 -0
- package/dist/ai/threat.d.ts +6 -0
- package/dist/ai/threat.js +206 -0
- package/dist/ai/threat.js.map +1 -0
- package/dist/ai/view.d.ts +21 -7
- package/dist/ai/view.js +677 -0
- package/dist/ai/view.js.map +1 -0
- package/dist/ai/waves.d.ts +6 -0
- package/dist/ai/waves.js +410 -0
- package/dist/ai/waves.js.map +1 -0
- package/dist/ai.js +54 -6239
- package/dist/aiTesting.d.ts +6 -3
- package/dist/aiTesting.js +229 -0
- package/dist/aiTesting.js.map +1 -0
- package/dist/areas.d.ts +4 -1
- package/dist/areas.js +295 -0
- package/dist/areas.js.map +1 -0
- package/dist/attacks.d.ts +3 -3
- package/dist/attacks.js +127 -0
- package/dist/attacks.js.map +1 -0
- package/dist/burning.d.ts +267 -0
- package/dist/burning.js +795 -0
- package/dist/burning.js.map +1 -0
- package/dist/bytes.js +21 -0
- package/dist/bytes.js.map +1 -0
- package/dist/callings.d.ts +71 -0
- package/dist/callings.js +157 -0
- package/dist/callings.js.map +1 -0
- package/dist/cameraOrders.d.ts +78 -0
- package/dist/cameraOrders.js +114 -0
- package/dist/cameraOrders.js.map +1 -0
- package/dist/camps.d.ts +70 -4
- package/dist/camps.js +501 -0
- package/dist/camps.js.map +1 -0
- package/dist/capture.d.ts +15 -3
- package/dist/capture.js +304 -0
- package/dist/capture.js.map +1 -0
- package/dist/cellLayers.d.ts +78 -13
- package/dist/cellLayers.js +275 -0
- package/dist/cellLayers.js.map +1 -0
- package/dist/cellPatches.d.ts +24 -0
- package/dist/cellPatches.js +73 -0
- package/dist/cellPatches.js.map +1 -0
- package/dist/cinematics.d.ts +10 -5
- package/dist/cinematics.js +161 -0
- package/dist/cinematics.js.map +1 -0
- package/dist/clock.d.ts +2 -2
- package/dist/clock.js +78 -0
- package/dist/clock.js.map +1 -0
- package/dist/commands.d.ts +36 -4
- package/dist/commands.js +636 -0
- package/dist/commands.js.map +1 -0
- package/dist/components.d.ts +31 -10
- package/dist/components.js +74 -0
- package/dist/components.js.map +1 -0
- package/dist/computers.d.ts +4 -4
- package/dist/computers.js +194 -0
- package/dist/computers.js.map +1 -0
- package/dist/concealment.d.ts +25 -2
- package/dist/concealment.js +409 -0
- package/dist/concealment.js.map +1 -0
- package/dist/coreComponents.js +130 -0
- package/dist/coreComponents.js.map +1 -0
- package/dist/createGame.d.ts +306 -0
- package/dist/createGame.js +405 -0
- package/dist/createGame.js.map +1 -0
- package/dist/dashing.d.ts +18 -2
- package/dist/dashing.js +41 -0
- package/dist/dashing.js.map +1 -0
- package/dist/debug.d.ts +8 -0
- package/dist/debug.js +5 -3
- package/dist/debug2.js +76 -0
- package/dist/debug2.js.map +1 -0
- package/dist/debugCommands.d.ts +6 -6
- package/dist/debugCommands.js +537 -0
- package/dist/debugCommands.js.map +1 -0
- package/dist/debugging.d.ts +1 -0
- package/dist/defaultSets.d.ts +183 -0
- package/dist/defaultSets.js +216 -0
- package/dist/defaultSets.js.map +1 -0
- package/dist/definitions.d.ts +6 -0
- package/dist/definitions.js +78 -0
- package/dist/definitions.js.map +1 -0
- package/dist/defs.d.ts +1895 -165
- package/dist/defs.js +380 -0
- package/dist/defs.js.map +1 -0
- package/dist/denying.d.ts +4 -4
- package/dist/denying.js +106 -0
- package/dist/denying.js.map +1 -0
- package/dist/destructibles.d.ts +2 -2
- package/dist/destructibles.js +36 -0
- package/dist/destructibles.js.map +1 -0
- package/dist/determinism.d.ts +4 -4
- package/dist/determinism.js +247 -0
- package/dist/determinism.js.map +1 -0
- package/dist/dialog.d.ts +17 -2
- package/dist/dialog.js +108 -0
- package/dist/dialog.js.map +1 -0
- package/dist/effectRefs.js +28 -0
- package/dist/effectRefs.js.map +1 -0
- package/dist/effects.d.ts +27 -11
- package/dist/effects.js +110 -0
- package/dist/effects.js.map +1 -0
- package/dist/endings.d.ts +1 -1
- package/dist/endings.js +78 -0
- package/dist/endings.js.map +1 -0
- package/dist/engagement.d.ts +40 -6
- package/dist/engagement.js +530 -0
- package/dist/engagement.js.map +1 -0
- package/dist/engineEvents.d.ts +72 -9
- package/dist/engineEvents.js +520 -0
- package/dist/engineEvents.js.map +1 -0
- package/dist/entity.d.ts +275 -26
- package/dist/entity.js +441 -0
- package/dist/entity.js.map +1 -0
- package/dist/entityIndex.d.ts +10 -3
- package/dist/entityIndex.js +149 -0
- package/dist/entityIndex.js.map +1 -0
- package/dist/errors.d.ts +6 -2
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +11 -5
- package/dist/events.js +158 -0
- package/dist/events.js.map +1 -0
- package/dist/exactMath.js +273 -0
- package/dist/exactMath.js.map +1 -0
- package/dist/features.d.ts +1 -1
- package/dist/features.js +127 -0
- package/dist/features.js.map +1 -0
- package/dist/fields.d.ts +25 -5
- package/dist/fields.js +140 -0
- package/dist/fields.js.map +1 -0
- package/dist/fixture.d.ts +3 -3
- package/dist/fixture.js +512 -0
- package/dist/fixture.js.map +1 -0
- package/dist/fog.d.ts +26 -3
- package/dist/fog.js +333 -0
- package/dist/fog.js.map +1 -0
- package/dist/foliage.d.ts +476 -0
- package/dist/foliage.js +1478 -0
- package/dist/foliage.js.map +1 -0
- package/dist/foliageDebug.d.ts +57 -0
- package/dist/foliageDebug.js +172 -0
- package/dist/foliageDebug.js.map +1 -0
- package/dist/foliageRegrowth.d.ts +20 -0
- package/dist/foliageRegrowth.js +332 -0
- package/dist/foliageRegrowth.js.map +1 -0
- package/dist/formState.d.ts +67 -0
- package/dist/formState.js +65 -0
- package/dist/formState.js.map +1 -0
- package/dist/formation.d.ts +46 -8
- package/dist/formation.js +297 -0
- package/dist/formation.js.map +1 -0
- package/dist/forms.d.ts +58 -0
- package/dist/forms.js +146 -0
- package/dist/forms.js.map +1 -0
- package/dist/friendlyFire.d.ts +2 -2
- package/dist/friendlyFire.js +37 -0
- package/dist/friendlyFire.js.map +1 -0
- package/dist/game.d.ts +141 -48
- package/dist/game.js +834 -0
- package/dist/game.js.map +1 -0
- package/dist/gameData.d.ts +96 -22
- package/dist/gameData.js +1690 -0
- package/dist/gameData.js.map +1 -0
- package/dist/gameFiles.d.ts +3 -3
- package/dist/gameFiles.js +14 -0
- package/dist/gameFiles.js.map +1 -0
- package/dist/gates.js +92 -0
- package/dist/gates.js.map +1 -0
- package/dist/generate.d.ts +28 -1
- package/dist/generate.js +1062 -0
- package/dist/generate.js.map +1 -0
- package/dist/generateWorker.d.ts +7 -3
- package/dist/generateWorker.js +86 -0
- package/dist/generateWorker.js.map +1 -0
- package/dist/grid.d.ts +9 -0
- package/dist/grid.js +102 -0
- package/dist/grid.js.map +1 -0
- package/dist/ground.d.ts +17 -1
- package/dist/ground.js +375 -0
- package/dist/ground.js.map +1 -0
- package/dist/groundObjects.d.ts +70 -0
- package/dist/groundObjects.js +371 -0
- package/dist/groundObjects.js.map +1 -0
- package/dist/groundSpeed.d.ts +20 -3
- package/dist/groundSpeed.js +117 -0
- package/dist/groundSpeed.js.map +1 -0
- package/dist/hero.d.ts +126 -10
- package/dist/hero.js +432 -0
- package/dist/hero.js.map +1 -0
- package/dist/holds.d.ts +94 -0
- package/dist/holds.js +305 -0
- package/dist/holds.js.map +1 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.js +30 -0
- package/dist/home.js.map +1 -0
- package/dist/hooks.d.ts +339 -57
- package/dist/hooks.js +105 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hotReload.d.ts +6 -5
- package/dist/hotReload.js +145 -0
- package/dist/hotReload.js.map +1 -0
- package/dist/ids.d.ts +3 -3
- package/dist/ids.js +30 -0
- package/dist/ids.js.map +1 -0
- package/dist/idsFile.d.ts +36 -0
- package/dist/idsFile.js +134 -0
- package/dist/idsFile.js.map +1 -0
- package/dist/index.d.ts +105 -68
- package/dist/index.js +194 -4701
- package/dist/inspect.d.ts +29 -2
- package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
- package/dist/inspect.js.map +1 -0
- package/dist/inventory.d.ts +14 -1
- package/dist/inventory.js +84 -0
- package/dist/inventory.js.map +1 -0
- package/dist/items.d.ts +136 -8
- package/dist/items.js +585 -0
- package/dist/items.js.map +1 -0
- package/dist/lanes.d.ts +12 -3
- package/dist/lanes.js +496 -0
- package/dist/lanes.js.map +1 -0
- package/dist/life.d.ts +6 -2
- package/dist/life.js +287 -0
- package/dist/life.js.map +1 -0
- package/dist/log.d.ts +26 -3
- package/dist/log.js +192 -0
- package/dist/log.js.map +1 -0
- package/dist/manaBurn.d.ts +2 -2
- package/dist/manaBurn.js +75 -0
- package/dist/manaBurn.js.map +1 -0
- package/dist/map/file.d.ts +56 -3
- package/dist/map/file.js +264 -0
- package/dist/map/file.js.map +1 -0
- package/dist/map/images.js +61 -0
- package/dist/map/images.js.map +1 -0
- package/dist/map/look.d.ts +1 -1
- package/dist/map/look.js +30 -0
- package/dist/map/look.js.map +1 -0
- package/dist/map/pathProfile.js +183 -0
- package/dist/map/pathProfile.js.map +1 -0
- package/dist/map/resize.d.ts +4 -0
- package/dist/map/resize.js +136 -0
- package/dist/map/resize.js.map +1 -0
- package/dist/map/schema.js +257 -0
- package/dist/map/schema.js.map +1 -0
- package/dist/map/terrain.js +214 -0
- package/dist/map/terrain.js.map +1 -0
- package/dist/map/types.d.ts +92 -13
- package/dist/map/types.js +251 -0
- package/dist/map/types.js.map +1 -0
- package/dist/mapCheck/cells.js +94 -0
- package/dist/mapCheck/cells.js.map +1 -0
- package/dist/mapCheck/rules/foliage.d.ts +9 -0
- package/dist/mapCheck/rules/foliage.js +83 -0
- package/dist/mapCheck/rules/foliage.js.map +1 -0
- package/dist/mapCheck/rules/names.js +39 -0
- package/dist/mapCheck/rules/names.js.map +1 -0
- package/dist/mapCheck/rules/objects.d.ts +1 -1
- package/dist/mapCheck/rules/objects.js +56 -0
- package/dist/mapCheck/rules/objects.js.map +1 -0
- package/dist/mapCheck/rules/paths.js +32 -0
- package/dist/mapCheck/rules/paths.js.map +1 -0
- package/dist/mapCheck/rules/players.js +20 -0
- package/dist/mapCheck/rules/players.js.map +1 -0
- package/dist/mapCheck/rules/races.js +56 -0
- package/dist/mapCheck/rules/races.js.map +1 -0
- package/dist/mapCheck/rules/random.js +47 -0
- package/dist/mapCheck/rules/random.js.map +1 -0
- package/dist/mapCheck/rules/regions.js +30 -0
- package/dist/mapCheck/rules/regions.js.map +1 -0
- package/dist/mapCheck/rules/targets.js +31 -0
- package/dist/mapCheck/rules/targets.js.map +1 -0
- package/dist/mapCheck/rules/walking.js +45 -0
- package/dist/mapCheck/rules/walking.js.map +1 -0
- package/dist/mapCheck.d.ts +2 -2
- package/dist/mapCheck.js +63 -0
- package/dist/mapCheck.js.map +1 -0
- package/dist/mapFields.d.ts +25 -2
- package/dist/mapFields.js +134 -0
- package/dist/mapFields.js.map +1 -0
- package/dist/mapFile.js +176 -0
- package/dist/mapFile.js.map +1 -0
- package/dist/mapMeasure.d.ts +8 -0
- package/dist/mapMeasure.js +283 -0
- package/dist/mapMeasure.js.map +1 -0
- package/dist/mapMerge.d.ts +1 -0
- package/dist/mapMerge.js +172 -0
- package/dist/mapMerge.js.map +1 -0
- package/dist/mapObjectives.js +138 -0
- package/dist/mapObjectives.js.map +1 -0
- package/dist/mapObjects.js +80 -0
- package/dist/mapObjects.js.map +1 -0
- package/dist/math.d.ts +37 -7
- package/dist/math.js +155 -0
- package/dist/math.js.map +1 -0
- package/dist/messages.d.ts +71 -4
- package/dist/messages.js +29 -0
- package/dist/messages.js.map +1 -0
- package/dist/missionRules.d.ts +10 -2
- package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
- package/dist/missionRules.js.map +1 -0
- package/dist/mods.d.ts +39 -20
- package/dist/mods.js +271 -0
- package/dist/mods.js.map +1 -0
- package/dist/moves.d.ts +87 -0
- package/dist/moves.js +539 -0
- package/dist/moves.js.map +1 -0
- package/dist/names.d.ts +7 -0
- package/dist/names.js +122 -0
- package/dist/names.js.map +1 -0
- package/dist/navigation/agentParams.js +14 -0
- package/dist/navigation/agentParams.js.map +1 -0
- package/dist/navigation/air.d.ts +7 -3
- package/dist/navigation/air.js +401 -0
- package/dist/navigation/air.js.map +1 -0
- package/dist/navigation/builds.d.ts +34 -2
- package/dist/navigation/builds.js +287 -0
- package/dist/navigation/builds.js.map +1 -0
- package/dist/navigation/groundAreas.d.ts +59 -1
- package/dist/navigation/groundAreas.js +407 -0
- package/dist/navigation/groundAreas.js.map +1 -0
- package/dist/navigation/navigation.d.ts +98 -9
- package/dist/navigation/recast.d.ts +194 -18
- package/dist/navigation/recast.js +1379 -0
- package/dist/navigation/recast.js.map +1 -0
- package/dist/navigation/sidePaths.d.ts +8 -3
- package/dist/navigation/sidePaths.js +241 -0
- package/dist/navigation/sidePaths.js.map +1 -0
- package/dist/navigation/sized.js +243 -0
- package/dist/navigation/sized.js.map +1 -0
- package/dist/nearest.js +32 -0
- package/dist/nearest.js.map +1 -0
- package/dist/noise.js +59 -0
- package/dist/noise.js.map +1 -0
- package/dist/objectives.d.ts +12 -3
- package/dist/objectives.js +144 -0
- package/dist/objectives.js.map +1 -0
- package/dist/orders/basic.d.ts +5 -5
- package/dist/orders/basic.js +417 -0
- package/dist/orders/basic.js.map +1 -0
- package/dist/orders/build.js +278 -0
- package/dist/orders/build.js.map +1 -0
- package/dist/orders/cast.d.ts +13 -3
- package/dist/orders/cast.js +558 -0
- package/dist/orders/cast.js.map +1 -0
- package/dist/orders/facts.js +16 -0
- package/dist/orders/facts.js.map +1 -0
- package/dist/orders/harvest.d.ts +21 -5
- package/dist/orders/harvest.js +540 -0
- package/dist/orders/harvest.js.map +1 -0
- package/dist/orders/idle.d.ts +3 -1
- package/dist/orders/idle.js +234 -0
- package/dist/orders/idle.js.map +1 -0
- package/dist/orders/items.js +92 -0
- package/dist/orders/items.js.map +1 -0
- package/dist/orders/queue.js +108 -0
- package/dist/orders/queue.js.map +1 -0
- package/dist/orders/waiting.d.ts +39 -0
- package/dist/orders/waiting.js +149 -0
- package/dist/orders/waiting.js.map +1 -0
- package/dist/pack.schema.js +13 -0
- package/dist/pack.schema.js.map +1 -0
- package/dist/pack.schema.json +7622 -841
- package/dist/packs/director/index.d.ts +13 -5
- package/dist/packs/director/index.js +204 -0
- package/dist/packs/director/index.js.map +1 -0
- package/dist/packs/heroes/campaign.d.ts +3 -2
- package/dist/packs/heroes/campaign.js +241 -0
- package/dist/packs/heroes/campaign.js.map +1 -0
- package/dist/packs/heroes/carry.d.ts +6 -0
- package/dist/packs/heroes/carry.js +112 -0
- package/dist/packs/heroes/carry.js.map +1 -0
- package/dist/packs/heroes/commands.js +115 -0
- package/dist/packs/heroes/commands.js.map +1 -0
- package/dist/packs/heroes/fallen.d.ts +43 -0
- package/dist/packs/heroes/fallen.js +61 -0
- package/dist/packs/heroes/fallen.js.map +1 -0
- package/dist/packs/heroes/hire.js +60 -0
- package/dist/packs/heroes/hire.js.map +1 -0
- package/dist/packs/heroes/index.d.ts +7 -6
- package/dist/packs/heroes/index.js +130 -0
- package/dist/packs/heroes/index.js.map +1 -0
- package/dist/packs/heroes/loop.d.ts +95 -0
- package/dist/packs/heroes/loop.js +250 -0
- package/dist/packs/heroes/loop.js.map +1 -0
- package/dist/packs/heroes/making.d.ts +6 -3
- package/dist/packs/heroes/making.js +55 -0
- package/dist/packs/heroes/making.js.map +1 -0
- package/dist/packs/heroes/respawn.d.ts +3 -3
- package/dist/packs/heroes/respawn.js +87 -0
- package/dist/packs/heroes/respawn.js.map +1 -0
- package/dist/packs/heroes/sets.d.ts +32 -0
- package/dist/packs/heroes/sets.js +51 -0
- package/dist/packs/heroes/sets.js.map +1 -0
- package/dist/packs/heroes/spells.d.ts +16 -0
- package/dist/packs/heroes/spells.js +269 -0
- package/dist/packs/heroes/spells.js.map +1 -0
- package/dist/packs/items/defaults.d.ts +43 -0
- package/dist/packs/items/defaults.js +1504 -0
- package/dist/packs/items/defaults.js.map +1 -0
- package/dist/packs/items/index.d.ts +27 -0
- package/dist/packs/items/index.js +214 -0
- package/dist/packs/items/index.js.map +1 -0
- package/dist/packs/moba/index.d.ts +3 -3
- package/dist/packs/moba/index.js +174 -0
- package/dist/packs/moba/index.js.map +1 -0
- package/dist/packs/pack.d.ts +15 -15
- package/dist/packs/pack.js +14 -0
- package/dist/packs/pack.js.map +1 -0
- package/dist/packs.d.ts +15 -7
- package/dist/packs.js +222 -0
- package/dist/packs.js.map +1 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +109 -0
- package/dist/paths.js.map +1 -0
- package/dist/plain.js +57 -0
- package/dist/plain.js.map +1 -0
- package/dist/player.d.ts +33 -10
- package/dist/player.js +159 -0
- package/dist/player.js.map +1 -0
- package/dist/portals.d.ts +1 -1
- package/dist/portals.js +194 -0
- package/dist/portals.js.map +1 -0
- package/dist/prefabs.d.ts +25 -2
- package/dist/prefabs.js +239 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/presetBuildings.js +58 -0
- package/dist/presetBuildings.js.map +1 -0
- package/dist/presetFoliage.d.ts +27 -0
- package/dist/presetFoliage.js +98 -0
- package/dist/presetFoliage.js.map +1 -0
- package/dist/presetGround.js +65 -0
- package/dist/presetGround.js.map +1 -0
- package/dist/proxies.d.ts +12 -0
- package/dist/proxies.js +79 -0
- package/dist/proxies.js.map +1 -0
- package/dist/query.d.ts +56 -0
- package/dist/query.js +88 -0
- package/dist/query.js.map +1 -0
- package/dist/races.d.ts +15 -14
- package/dist/races.js +172 -0
- package/dist/races.js.map +1 -0
- package/dist/randomGroups.js +91 -0
- package/dist/randomGroups.js.map +1 -0
- package/dist/registry.d.ts +117 -53
- package/dist/registry.js +323 -0
- package/dist/registry.js.map +1 -0
- package/dist/remains.d.ts +11 -9
- package/dist/remains.js +188 -0
- package/dist/remains.js.map +1 -0
- package/dist/replication.d.ts +12 -7
- package/dist/replication.js +100 -0
- package/dist/replication.js.map +1 -0
- package/dist/rng.d.ts +2 -0
- package/dist/rng.js +40 -0
- package/dist/rng.js.map +1 -0
- package/dist/rules.d.ts +186 -99
- package/dist/rules.js +179 -0
- package/dist/rules.js.map +1 -0
- package/dist/rulesCheck.d.ts +5 -4
- package/dist/rulesCheck.js +693 -0
- package/dist/rulesCheck.js.map +1 -0
- package/dist/runes.d.ts +2 -2
- package/dist/runes.js +80 -0
- package/dist/runes.js.map +1 -0
- package/dist/save.d.ts +37 -12
- package/dist/save.js +532 -0
- package/dist/save.js.map +1 -0
- package/dist/scenario.d.ts +2 -2
- package/dist/scenario.js +99 -0
- package/dist/scenario.js.map +1 -0
- package/dist/scheduler.d.ts +3 -0
- package/dist/scheduler.js +156 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/score.d.ts +19 -19
- package/dist/score.js +709 -0
- package/dist/score.js.map +1 -0
- package/dist/sequences.d.ts +10 -6
- package/dist/sequences.js +206 -0
- package/dist/sequences.js.map +1 -0
- package/dist/server/doorman.js +154 -0
- package/dist/server/doorman.js.map +1 -0
- package/dist/server/gameServer.d.ts +16 -1
- package/dist/server/gameServer.js +643 -0
- package/dist/server/gameServer.js.map +1 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/lobby.js +199 -0
- package/dist/server/lobby.js.map +1 -0
- package/dist/server/log.js +18 -0
- package/dist/server/log.js.map +1 -0
- package/dist/server/match.js +267 -0
- package/dist/server/match.js.map +1 -0
- package/dist/server/mode.d.ts +18 -9
- package/dist/server/mode.js +220 -0
- package/dist/server/mode.js.map +1 -0
- package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
- package/dist/server/navigation-worker.js.map +1 -0
- package/dist/server/navigation.js +39 -0
- package/dist/server/navigation.js.map +1 -0
- package/dist/server/ops.d.ts +4 -0
- package/dist/server/ops.js +137 -0
- package/dist/server/ops.js.map +1 -0
- package/dist/server/packs.d.ts +3 -3
- package/dist/server/packs.js +32 -0
- package/dist/server/packs.js.map +1 -0
- package/dist/server/ratings.d.ts +5 -0
- package/dist/server/ratings.js +104 -0
- package/dist/server/ratings.js.map +1 -0
- package/dist/server/relay.d.ts +12 -2
- package/dist/server/relay.js +144 -0
- package/dist/server/relay.js.map +1 -0
- package/dist/server/rooms.d.ts +9 -2
- package/dist/server/rooms.js +442 -0
- package/dist/server/rooms.js.map +1 -0
- package/dist/server/seat.js +116 -0
- package/dist/server/seat.js.map +1 -0
- package/dist/server/seatSettings.d.ts +3 -3
- package/dist/server/seatSettings.js +63 -0
- package/dist/server/seatSettings.js.map +1 -0
- package/dist/server/secret.js +13 -0
- package/dist/server/secret.js.map +1 -0
- package/dist/server/start.d.ts +13 -6
- package/dist/server/start.js +76 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/websocket.d.ts +9 -1
- package/dist/server/websocket.js +306 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server.js +15 -2861
- package/dist/session/can.js +26 -0
- package/dist/session/can.js.map +1 -0
- package/dist/session/commandReplay.d.ts +8 -2
- package/dist/session/commandReplay.js +293 -0
- package/dist/session/commandReplay.js.map +1 -0
- package/dist/session/debug.js +151 -0
- package/dist/session/debug.js.map +1 -0
- package/dist/session/delay.js +62 -0
- package/dist/session/delay.js.map +1 -0
- package/dist/session/delta.d.ts +14 -1
- package/dist/session/delta.js +407 -0
- package/dist/session/delta.js.map +1 -0
- package/dist/session/entityState.js +415 -0
- package/dist/session/entityState.js.map +1 -0
- package/dist/session/local.d.ts +47 -5
- package/dist/session/local.js +670 -0
- package/dist/session/local.js.map +1 -0
- package/dist/session/memory.d.ts +20 -2
- package/dist/session/memory.js +131 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/protocol.d.ts +325 -31
- package/dist/session/protocol.js +55 -0
- package/dist/session/protocol.js.map +1 -0
- package/dist/session/remote.d.ts +74 -12
- package/dist/session/remote.js +1394 -0
- package/dist/session/remote.js.map +1 -0
- package/dist/session/replay.d.ts +11 -2
- package/dist/session/replay.js +160 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/seed.js +12 -0
- package/dist/session/seed.js.map +1 -0
- package/dist/session/share.d.ts +5 -1
- package/dist/session/share.js +94 -0
- package/dist/session/share.js.map +1 -0
- package/dist/session/socket.d.ts +1 -1
- package/dist/session/socket.js +29 -0
- package/dist/session/socket.js.map +1 -0
- package/dist/session/wire.d.ts +5 -0
- package/dist/session/wire.js +84 -0
- package/dist/session/wire.js.map +1 -0
- package/dist/session/worker.d.ts +77 -12
- package/dist/session/worker.js +499 -0
- package/dist/session/worker.js.map +1 -0
- package/dist/shared.d.ts +31 -5
- package/dist/shared.js +166 -0
- package/dist/shared.js.map +1 -0
- package/dist/sides.d.ts +9 -3
- package/dist/sides.js +149 -0
- package/dist/sides.js.map +1 -0
- package/dist/sight.js +85 -0
- package/dist/sight.js.map +1 -0
- package/dist/simulate-worker.js +1 -1
- package/dist/simulate.d.ts +12 -8
- package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
- package/dist/simulate.js.map +1 -0
- package/dist/smart.js +77 -0
- package/dist/smart.js.map +1 -0
- package/dist/spatial.d.ts +32 -16
- package/dist/spatial.js +234 -0
- package/dist/spatial.js.map +1 -0
- package/dist/spawning.d.ts +1 -0
- package/dist/spawning.js +224 -0
- package/dist/spawning.js.map +1 -0
- package/dist/stances.d.ts +6 -3
- package/dist/stances.js +169 -0
- package/dist/stances.js.map +1 -0
- package/dist/start.d.ts +10 -10
- package/dist/start.js +75 -0
- package/dist/start.js.map +1 -0
- package/dist/stats.d.ts +42 -16
- package/dist/stats.js +290 -0
- package/dist/stats.js.map +1 -0
- package/dist/summoned.d.ts +52 -0
- package/dist/summoned.js +38 -0
- package/dist/summoned.js.map +1 -0
- package/dist/summons.d.ts +10 -13
- package/dist/summons.js +271 -0
- package/dist/summons.js.map +1 -0
- package/dist/systems/abilities.js +224 -0
- package/dist/systems/abilities.js.map +1 -0
- package/dist/systems/combat.d.ts +35 -1
- package/dist/systems/combat.js +677 -0
- package/dist/systems/combat.js.map +1 -0
- package/dist/systems/combatTold.d.ts +3 -1
- package/dist/systems/combatTold.js +85 -0
- package/dist/systems/combatTold.js.map +1 -0
- package/dist/systems/construction.js +80 -0
- package/dist/systems/construction.js.map +1 -0
- package/dist/systems/economy.d.ts +0 -6
- package/dist/systems/economy.js +128 -0
- package/dist/systems/economy.js.map +1 -0
- package/dist/systems/fog.d.ts +1 -1
- package/dist/systems/fog.js +120 -0
- package/dist/systems/fog.js.map +1 -0
- package/dist/systems/life.js +32 -0
- package/dist/systems/life.js.map +1 -0
- package/dist/systems/movement.d.ts +24 -12
- package/dist/systems/movement.js +1247 -0
- package/dist/systems/movement.js.map +1 -0
- package/dist/systems/orders.js +64 -0
- package/dist/systems/orders.js.map +1 -0
- package/dist/systems/production.js +322 -0
- package/dist/systems/production.js.map +1 -0
- package/dist/systems/productionQueue.js +120 -0
- package/dist/systems/productionQueue.js.map +1 -0
- package/dist/systems/victory.d.ts +1 -1
- package/dist/systems/victory.js +56 -0
- package/dist/systems/victory.js.map +1 -0
- package/dist/talk.d.ts +6 -6
- package/dist/talk.js +153 -0
- package/dist/talk.js.map +1 -0
- package/dist/targeting.d.ts +142 -0
- package/dist/targeting.js +49 -0
- package/dist/targeting.js.map +1 -0
- package/dist/tech.d.ts +20 -3
- package/dist/tech.js +239 -0
- package/dist/tech.js.map +1 -0
- package/dist/techTree.d.ts +7 -0
- package/dist/techTree.js +90 -0
- package/dist/techTree.js.map +1 -0
- package/dist/terrain.d.ts +59 -7
- package/dist/terrain.js +389 -0
- package/dist/terrain.js.map +1 -0
- package/dist/terrainSave.d.ts +6 -0
- package/dist/terrainSave.js +74 -0
- package/dist/terrainSave.js.map +1 -0
- package/dist/testing.d.ts +8 -7
- package/dist/testing.js +13 -739
- package/dist/testing.js.map +1 -1
- package/dist/tiles.d.ts +1 -1
- package/dist/tiles.js +43 -0
- package/dist/tiles.js.map +1 -0
- package/dist/timers.d.ts +29 -4
- package/dist/timers.js +242 -0
- package/dist/timers.js.map +1 -0
- package/dist/tomes.d.ts +4 -4
- package/dist/tomes.js +94 -0
- package/dist/tomes.js.map +1 -0
- package/dist/trade.js +103 -0
- package/dist/trade.js.map +1 -0
- package/dist/transport.d.ts +6 -1
- package/dist/transport.js +281 -0
- package/dist/transport.js.map +1 -0
- package/dist/tunables.d.ts +10 -3
- package/dist/tunables.js +56 -0
- package/dist/tunables.js.map +1 -0
- package/dist/unitResources.d.ts +67 -0
- package/dist/unitResources.js +266 -0
- package/dist/unitResources.js.map +1 -0
- package/dist/upkeep.d.ts +6 -1
- package/dist/upkeep.js +26 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/veterancy.d.ts +8 -3
- package/dist/veterancy.js +131 -0
- package/dist/veterancy.js.map +1 -0
- package/dist/vision.d.ts +36 -0
- package/dist/vision.js +133 -0
- package/dist/vision.js.map +1 -0
- package/dist/walls.d.ts +1 -1
- package/dist/walls.js +278 -0
- package/dist/walls.js.map +1 -0
- package/dist/world.d.ts +606 -88
- package/dist/world.js +1263 -0
- package/dist/world.js.map +1 -0
- package/package.json +2 -2
- package/dist/ai.js.map +0 -1
- package/dist/attributes.d.ts +0 -66
- package/dist/brain-BvVdUhX8.js +0 -7659
- package/dist/brain-BvVdUhX8.js.map +0 -1
- package/dist/builds-C6LfgvEU.js +0 -460
- package/dist/builds-C6LfgvEU.js.map +0 -1
- package/dist/coreComponents-syuh2fPG.js +0 -5149
- package/dist/coreComponents-syuh2fPG.js.map +0 -1
- package/dist/debugCommands-CzjrSm66.js +0 -14739
- package/dist/debugCommands-CzjrSm66.js.map +0 -1
- package/dist/determinism-BCymQwiE.js +0 -518
- package/dist/determinism-BCymQwiE.js.map +0 -1
- package/dist/game-DiJEN-Ks.js +0 -5800
- package/dist/game-DiJEN-Ks.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspect-D9dWHmZ0.js.map +0 -1
- package/dist/local-Dkovq42k.js +0 -1379
- package/dist/local-Dkovq42k.js.map +0 -1
- package/dist/missionRules-C-bGxm0Q.js.map +0 -1
- package/dist/navigation-worker.js.map +0 -1
- package/dist/packs-g5thvmGn.js +0 -3199
- package/dist/packs-g5thvmGn.js.map +0 -1
- package/dist/profiles-B3NS9jwk.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/simulate-oXBiw1Ff.js.map +0 -1
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
import { distSq } from "../math.js";
|
|
2
|
+
import { heroOfState } from "../hero.js";
|
|
3
|
+
import { DEFAULT_STANCE, stance, stanceCommand } from "../stances.js";
|
|
4
|
+
import { defineModule } from "./module.js";
|
|
5
|
+
import "./reach.js";
|
|
6
|
+
import { UnitSet } from "./view.js";
|
|
7
|
+
import { pair, plural, point, where } from "./geometry.js";
|
|
8
|
+
import { capturePointsOf } from "./tasks/shared.js";
|
|
9
|
+
import { ATTACK } from "./tasks/attack.js";
|
|
10
|
+
import { HARASS } from "./tasks/harass.js";
|
|
11
|
+
import { CREEP } from "./tasks/creep.js";
|
|
12
|
+
import { DEFEND_TASK } from "./tasks/defend.js";
|
|
13
|
+
import { HOLD } from "./tasks/hold.js";
|
|
14
|
+
import { MOVE } from "./tasks/move.js";
|
|
15
|
+
import { CAPTURE } from "./tasks/capture.js";
|
|
16
|
+
import { RETREAT } from "./tasks/retreat.js";
|
|
17
|
+
import { ESCORT } from "./tasks/escort.js";
|
|
18
|
+
import { SCOUT_TASK } from "./tasks/scout.js";
|
|
19
|
+
import { PATROL } from "./tasks/patrol.js";
|
|
20
|
+
import { GATHER } from "./tasks/gather.js";
|
|
21
|
+
import { DROP } from "./tasks/drop.js";
|
|
22
|
+
import { TASKS } from "./tasks/index.js";
|
|
23
|
+
//#region src/ai/squads.ts
|
|
24
|
+
/** Seconds a squad waits for its stragglers at most, regrouping, before it goes on with what it has */
|
|
25
|
+
var REGROUP_FOR = 10;
|
|
26
|
+
/** Seconds between two calls for reinforcements */
|
|
27
|
+
var REINFORCE_EVERY = 5;
|
|
28
|
+
/** How far aside of the hottest place on its way a squad that avoids looks for a way round, then half as far again */
|
|
29
|
+
var DETOUR = 24;
|
|
30
|
+
/** Seconds a sighting of their army counts as where it is, for a squad that avoids it */
|
|
31
|
+
var AVOID_SEEN = 60;
|
|
32
|
+
/**
|
|
33
|
+
* A squad of the brain (`ai.squads.make`, `named`, `all`): a handle over its data, with the task methods. A squad's
|
|
34
|
+
* units are as of the think's picture: the dead and those its owner no longer holds are dropped as the squads module
|
|
35
|
+
* looks at it
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
var Squad = class {
|
|
40
|
+
squads;
|
|
41
|
+
data;
|
|
42
|
+
constructor(squads, data) {
|
|
43
|
+
this.squads = squads;
|
|
44
|
+
this.data = data;
|
|
45
|
+
}
|
|
46
|
+
/** Its name: unique among the brain's squads */
|
|
47
|
+
get name() {
|
|
48
|
+
return this.data.name;
|
|
49
|
+
}
|
|
50
|
+
/** Who it belongs to: the goal, rule or module that made it */
|
|
51
|
+
get owner() {
|
|
52
|
+
return this.data.owner;
|
|
53
|
+
}
|
|
54
|
+
/** What it is doing: none for a squad told nothing yet */
|
|
55
|
+
get current() {
|
|
56
|
+
return this.data.task;
|
|
57
|
+
}
|
|
58
|
+
/** How its task ended: none while it goes on, or while it has none */
|
|
59
|
+
get done() {
|
|
60
|
+
return this.data.task?.done;
|
|
61
|
+
}
|
|
62
|
+
/** Whether it has nothing to do: no task, or its task is over */
|
|
63
|
+
get idle() {
|
|
64
|
+
return !this.data.task || this.data.task.done !== void 0;
|
|
65
|
+
}
|
|
66
|
+
/** Whether it is still one of the brain's squads: not once disbanded */
|
|
67
|
+
get alive() {
|
|
68
|
+
return this.squads.named(this.data.name) === this;
|
|
69
|
+
}
|
|
70
|
+
/** How it behaves: its own options over the brain's */
|
|
71
|
+
get options() {
|
|
72
|
+
return this.data.options;
|
|
73
|
+
}
|
|
74
|
+
/** Its units, as of the think's picture: those alive and the player's */
|
|
75
|
+
units() {
|
|
76
|
+
const { view } = this.squads.ai;
|
|
77
|
+
return new UnitSet(view, this.data.units.map((id) => view.byId(id)).filter((unit) => !!unit && unit.health > 0));
|
|
78
|
+
}
|
|
79
|
+
/** How many units it has */
|
|
80
|
+
get length() {
|
|
81
|
+
return this.data.units.length;
|
|
82
|
+
}
|
|
83
|
+
/** How strong it is together (`UnitSet.strength`) */
|
|
84
|
+
strength() {
|
|
85
|
+
return this.units().strength();
|
|
86
|
+
}
|
|
87
|
+
/** Its middle: none with no unit left */
|
|
88
|
+
centre() {
|
|
89
|
+
return this.units().centre();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* How far from its middle a unit may be before it counts as strayed (`SquadOptions.spread`): grows with the squad
|
|
93
|
+
* when not given
|
|
94
|
+
*/
|
|
95
|
+
spread() {
|
|
96
|
+
return this.data.options.spread ?? Math.max(8, 3 * Math.sqrt(this.data.units.length));
|
|
97
|
+
}
|
|
98
|
+
/** Adds units: what its owner may have (see `Squads.make`), taken out of any other squad */
|
|
99
|
+
add(units, why = "given") {
|
|
100
|
+
const added = this.squads.enlist(this, ids(units));
|
|
101
|
+
if (added.length) {
|
|
102
|
+
this.data.size = Math.max(this.data.size, this.data.units.length);
|
|
103
|
+
this.changed(`${why}: ${plural(added.length)}`);
|
|
104
|
+
}
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
/** Takes units out: they go back to the pool (its owner lets go of them) */
|
|
108
|
+
remove(units, why = "taken out") {
|
|
109
|
+
const gone = new Set(ids(units));
|
|
110
|
+
const removed = this.data.units.filter((id) => gone.has(id));
|
|
111
|
+
if (!removed.length) return this;
|
|
112
|
+
this.data.units = this.data.units.filter((id) => !gone.has(id));
|
|
113
|
+
this.squads.ai.goals.drop(this.data.owner, removed);
|
|
114
|
+
this.changed(`${why}: ${plural(removed.length)}`);
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/** Disbands it: its units go back to its owner (a goal's), or to the pool (a squad of its own) */
|
|
118
|
+
disband(why = "disbanded") {
|
|
119
|
+
this.squads.disband(this, why);
|
|
120
|
+
}
|
|
121
|
+
/** Writes down the last change of its units or task, for the report */
|
|
122
|
+
changed(why) {
|
|
123
|
+
this.data.changed = {
|
|
124
|
+
tick: this.squads.ai.tick,
|
|
125
|
+
why
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
task(kind, data = {}) {
|
|
129
|
+
this.squads.give(this, kind, data);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
/** Ends its task, saying how: what a task's `think` calls once it is over */
|
|
133
|
+
finish(done) {
|
|
134
|
+
const state = this.data.task;
|
|
135
|
+
if (!state || state.done !== void 0) return;
|
|
136
|
+
state.done = done;
|
|
137
|
+
state.doneAt = this.squads.ai.tick;
|
|
138
|
+
state.phase = "done";
|
|
139
|
+
state.phaseSince = this.squads.ai.tick;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Goes to fight at a place or a target (an entity, or its id): attack-moves there, fighting what it meets, regroups
|
|
143
|
+
* on the way, retreats on the odds. Done `cleared` once there with nothing left to fight, `lost` when the target is
|
|
144
|
+
* gone. `avoid: 'army'` goes round where their strength is on the way (the threat map and their army as last seen),
|
|
145
|
+
* when there is a way round. `via`: a place to go by on the way (a way of its own: Random Paths). `then`: the task after it
|
|
146
|
+
*/
|
|
147
|
+
attack(target, options = {}) {
|
|
148
|
+
return this.task(ATTACK, {
|
|
149
|
+
...targetOf(this.squads.ai, target),
|
|
150
|
+
...options
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** Attack-moves to a place, as a group of units would on a click: the squad's attack without its regroup */
|
|
154
|
+
attackMove(at, options = {}) {
|
|
155
|
+
return this.task(ATTACK, {
|
|
156
|
+
at: point(at),
|
|
157
|
+
regroup: false,
|
|
158
|
+
...options
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Holds a place against what comes within `radius` of it (16 when left out): fights what comes, goes back once it is
|
|
163
|
+
* gone. Never over by itself: its owner says when
|
|
164
|
+
*/
|
|
165
|
+
defend(at, radius = 16) {
|
|
166
|
+
return this.task(DEFEND_TASK, {
|
|
167
|
+
at: point(at),
|
|
168
|
+
radius
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** Goes to a place (where it stands when left out) and holds it: stands, fighting only what comes within reach */
|
|
172
|
+
hold(at) {
|
|
173
|
+
const there = at ?? this.centre();
|
|
174
|
+
return this.task(HOLD, there ? { at: point(there) } : {});
|
|
175
|
+
}
|
|
176
|
+
/** Walks to a place, fighting nothing on the way. Done `arrived` */
|
|
177
|
+
move(at, options = {}) {
|
|
178
|
+
return this.task(MOVE, {
|
|
179
|
+
at: point(at),
|
|
180
|
+
...options
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Goes with a unit of the player's or an ally's, fighting what comes near it. Done `lost` when it is gone */
|
|
184
|
+
escort(target) {
|
|
185
|
+
return this.task(ESCORT, { target: typeof target === "number" ? target : target.id });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Goes for the workers at a place, round where their army is (`avoid: 'army'` unless told otherwise), the workers
|
|
189
|
+
* first once there. Done `cleared`
|
|
190
|
+
*/
|
|
191
|
+
harass(at, options = {}) {
|
|
192
|
+
return this.task(HARASS, {
|
|
193
|
+
at: point(at),
|
|
194
|
+
avoid: "army",
|
|
195
|
+
...options
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** Goes to look at places, one after the other: each is looked at once in sight, or reached as near as the ground lets. Done `arrived` */
|
|
199
|
+
scout(points) {
|
|
200
|
+
return this.task(SCOUT_TASK, { points: points.map(point) });
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Gathers at a rally point before going on (`then`): until `minForces` of it (a share, 1 when left out) is there,
|
|
204
|
+
* or `seconds` have gone by. Done `arrived`, and on to `then`
|
|
205
|
+
*/
|
|
206
|
+
gather(at, options = {}) {
|
|
207
|
+
return this.task(GATHER, {
|
|
208
|
+
at: point(at),
|
|
209
|
+
...options
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** Falls back to a place (home when left out), fighting nothing on the way. Done `retreated` */
|
|
213
|
+
retreat(to, why) {
|
|
214
|
+
const home = to ?? this.squads.ai.view.home();
|
|
215
|
+
return this.task(RETREAT, {
|
|
216
|
+
...home && { at: point(home) },
|
|
217
|
+
...why && { why }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Walks a round of places, one after the other and back to the first, fighting what it meets on the way (an
|
|
222
|
+
* attack-move to each): a mission's guards on the road, a watch round the walls. Never over by itself: its owner
|
|
223
|
+
* says when
|
|
224
|
+
*/
|
|
225
|
+
patrol(points) {
|
|
226
|
+
return this.task(PATROL, { points: points.map(point) });
|
|
227
|
+
}
|
|
228
|
+
/** Takes a camp of creeps: fights there until the camp is cleared. Done `cleared` */
|
|
229
|
+
creep(camp) {
|
|
230
|
+
return this.task(CREEP, { at: point(camp) });
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Carried by transports to a place it cannot walk to, let out on the land nearest it (the `drop` task): done
|
|
234
|
+
* `landed`, then what `then` says (an attack where it landed)
|
|
235
|
+
*/
|
|
236
|
+
drop(at, transports, options = {}) {
|
|
237
|
+
return this.task(DROP, {
|
|
238
|
+
at: point(at),
|
|
239
|
+
transports: [...transports],
|
|
240
|
+
...options.then && { then: options.then }
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/** Sends its units an order (`move`, `hold`, the game's), all or some of them: counted as the task's last */
|
|
244
|
+
order(order, units = this.data.units, queue = false) {
|
|
245
|
+
units = this.living(units);
|
|
246
|
+
if (!units.length) return;
|
|
247
|
+
this.squads.ai.send({
|
|
248
|
+
type: "order",
|
|
249
|
+
entities: [...units],
|
|
250
|
+
order,
|
|
251
|
+
...queue && { queue: true }
|
|
252
|
+
});
|
|
253
|
+
this.sent();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Puts its units, all or some, in a stance, where the game has stances (`stancesPack`): those not in it already. A
|
|
257
|
+
* squad that holds is defensive, one sent to fight aggressive
|
|
258
|
+
*/
|
|
259
|
+
setStance(id, units = this.data.units) {
|
|
260
|
+
if (!this.squads.ai.registry.command("stance")) return;
|
|
261
|
+
const change = [];
|
|
262
|
+
for (const unit of this.units()) {
|
|
263
|
+
if (!units.includes(unit.id)) continue;
|
|
264
|
+
if ((unit.components?.[stance.id] ?? "aggressive") !== id) change.push(unit.id);
|
|
265
|
+
}
|
|
266
|
+
if (change.length) this.squads.ai.send(stanceCommand.make({
|
|
267
|
+
entities: change,
|
|
268
|
+
stance: id
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Sends its units to take a capture point of the game's (`capturePack`), by its id: they fight their way in and
|
|
273
|
+
* stand in it until it is theirs (`captured`), or it is gone (`lost`)
|
|
274
|
+
*/
|
|
275
|
+
capture(id) {
|
|
276
|
+
const found = capturePointsOf(this.squads.ai).find((each) => each.id === id);
|
|
277
|
+
return this.task(CAPTURE, {
|
|
278
|
+
point: id,
|
|
279
|
+
...found && { at: point({
|
|
280
|
+
x: found.x,
|
|
281
|
+
z: found.z
|
|
282
|
+
}) }
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/** Sends its units, all or some, to fight at a place, or a target there: an attack-move, or an attack */
|
|
286
|
+
fight(at, units = this.data.units, target, queue = false) {
|
|
287
|
+
units = this.living(units);
|
|
288
|
+
if (!units.length) return;
|
|
289
|
+
this.setStance(DEFAULT_STANCE, units);
|
|
290
|
+
this.squads.ai.send({
|
|
291
|
+
type: "attack",
|
|
292
|
+
entities: [...units],
|
|
293
|
+
point: point(at),
|
|
294
|
+
...target !== void 0 && { target },
|
|
295
|
+
...queue && { queue: true }
|
|
296
|
+
});
|
|
297
|
+
this.sent();
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Of some of its units, those the picture has: a unit that died since the squads were last looked at (a task given by a
|
|
301
|
+
* goal before the `squads()` module ran) is no one to order
|
|
302
|
+
*/
|
|
303
|
+
living(units) {
|
|
304
|
+
const { mine } = this.squads.ai.view;
|
|
305
|
+
return units.every((id) => mine.has(id)) ? units : units.filter((id) => mine.has(id));
|
|
306
|
+
}
|
|
307
|
+
/** Its units that stand with nothing to do: what lost its order, or never had one */
|
|
308
|
+
idleUnits() {
|
|
309
|
+
return this.units().filter((unit) => !!unit.own && !unit.own.order && !unit.own.hidden);
|
|
310
|
+
}
|
|
311
|
+
/** Whether its last order was sent long enough ago to send one again (`RESEND` seconds): what keeps a stuck unit from being told every think */
|
|
312
|
+
mayResend() {
|
|
313
|
+
const state = this.data.task;
|
|
314
|
+
const { ai } = this.squads;
|
|
315
|
+
return !state || state.sent === void 0 || ai.tick - state.sent >= 3 * ai.session.tickRate;
|
|
316
|
+
}
|
|
317
|
+
sent() {
|
|
318
|
+
if (this.data.task) this.data.task.sent = this.squads.ai.tick;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Some squads together (`ai.squads.all()`, `idle()`): read as a list, told as one (`ai.squads.all().defend(home)`:
|
|
323
|
+
* each squad is given the task)
|
|
324
|
+
*
|
|
325
|
+
* @beta
|
|
326
|
+
*/
|
|
327
|
+
var SquadGroup = class {
|
|
328
|
+
ai;
|
|
329
|
+
squads;
|
|
330
|
+
constructor(ai, squads) {
|
|
331
|
+
this.ai = ai;
|
|
332
|
+
this.squads = squads;
|
|
333
|
+
}
|
|
334
|
+
/** Iterates the squads, so that the set reads as a list */
|
|
335
|
+
[Symbol.iterator]() {
|
|
336
|
+
return this.squads[Symbol.iterator]();
|
|
337
|
+
}
|
|
338
|
+
/** How many squads */
|
|
339
|
+
get length() {
|
|
340
|
+
return this.squads.length;
|
|
341
|
+
}
|
|
342
|
+
/** Their units together, as a set */
|
|
343
|
+
units() {
|
|
344
|
+
const { view } = this.ai;
|
|
345
|
+
const all = this.squads.flatMap((squad) => squad.units().items);
|
|
346
|
+
all.sort((a, b) => view.indexOf(a) - view.indexOf(b));
|
|
347
|
+
return new UnitSet(view, all);
|
|
348
|
+
}
|
|
349
|
+
/** How strong they are together */
|
|
350
|
+
strength() {
|
|
351
|
+
return this.units().strength();
|
|
352
|
+
}
|
|
353
|
+
task(kind, data = {}) {
|
|
354
|
+
for (const squad of this.squads) squad.squads.give(squad, kind, data);
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
/** Tells each squad to attack a point, an entity or an entity id, as `Squad.attack` does, and returns the set */
|
|
358
|
+
attack(target, options = {}) {
|
|
359
|
+
for (const squad of this.squads) squad.attack(target, options);
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
/** Tells each squad to defend a place within a radius as `Squad.defend` does; does nothing without a place; returns the set */
|
|
363
|
+
defend(at, radius) {
|
|
364
|
+
if (at) for (const squad of this.squads) squad.defend(at, radius);
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
/** Tells each squad to hold at a place, or where it is, as `Squad.hold` does, and returns the set */
|
|
368
|
+
hold(at) {
|
|
369
|
+
for (const squad of this.squads) squad.hold(at);
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
/** Tells each squad to move to a point as `Squad.move` does, and returns the set */
|
|
373
|
+
move(at) {
|
|
374
|
+
for (const squad of this.squads) squad.move(at);
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
377
|
+
/** Tells each squad to retreat to a point, or home when left out, as `Squad.retreat` does, and returns the set */
|
|
378
|
+
retreat(to) {
|
|
379
|
+
for (const squad of this.squads) squad.retreat(to);
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
/** Each disbanded */
|
|
383
|
+
disband(why) {
|
|
384
|
+
for (const squad of [...this.squads]) squad.disband(why);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
/** The ids of units given as entities or ids, each once */
|
|
388
|
+
function ids(units) {
|
|
389
|
+
const result = [];
|
|
390
|
+
for (const unit of units) {
|
|
391
|
+
const id = typeof unit === "number" ? unit : unit.id;
|
|
392
|
+
if (!result.includes(id)) result.push(id);
|
|
393
|
+
}
|
|
394
|
+
return result;
|
|
395
|
+
}
|
|
396
|
+
/** A target as an attack's data: a place, or an entity and where it is */
|
|
397
|
+
function targetOf(ai, target) {
|
|
398
|
+
if (typeof target === "number") {
|
|
399
|
+
const entity = ai.view.byId(target);
|
|
400
|
+
return {
|
|
401
|
+
target,
|
|
402
|
+
...entity && { at: point(entity) }
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if ("id" in target && typeof target.id === "number") return {
|
|
406
|
+
target: target.id,
|
|
407
|
+
at: point(target)
|
|
408
|
+
};
|
|
409
|
+
return { at: point(target) };
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* A brain's squads (`ai.squads`): made by its goals, rules and modules, watched by the `squads()` module each think
|
|
413
|
+
* (`think`): the dead dropped, what the owner let go of let go of, each task looked at, regroups, retreats and
|
|
414
|
+
* reinforcements seen to. Kept in the brain's memory (`BrainMemory.squads`)
|
|
415
|
+
*
|
|
416
|
+
* @beta
|
|
417
|
+
*/
|
|
418
|
+
var Squads = class {
|
|
419
|
+
ai;
|
|
420
|
+
/** Its id among the brain's areas: what its memory and its report are kept under */
|
|
421
|
+
id = "squads";
|
|
422
|
+
/** What the log says where a save's memory of it is of a shape it does not read */
|
|
423
|
+
afresh = "the save remembers the computer player’s squads in a shape this brain does not read: they are let go of";
|
|
424
|
+
list = [];
|
|
425
|
+
tasks = /* @__PURE__ */ new Map();
|
|
426
|
+
thoughtAt = -1;
|
|
427
|
+
/** How a squad behaves where it says nothing and the brain's settings say nothing either: the `squads()` module's */
|
|
428
|
+
moduleOptions = {};
|
|
429
|
+
constructor(ai, tasks = []) {
|
|
430
|
+
this.ai = ai;
|
|
431
|
+
for (const def of TASKS) this.tasks.set(def.id, def);
|
|
432
|
+
for (const def of tasks) this.define(def);
|
|
433
|
+
}
|
|
434
|
+
/** Puts the `squads()` module's options under the brain's settings */
|
|
435
|
+
configure(options) {
|
|
436
|
+
this.moduleOptions = options;
|
|
437
|
+
}
|
|
438
|
+
/** How a squad behaves where it says nothing: the module's options, the brain's settings over them (`ai.settings.squads`) */
|
|
439
|
+
get defaults() {
|
|
440
|
+
const { tasks: _tasks, ...settings } = this.ai.settings.squads ?? {};
|
|
441
|
+
return {
|
|
442
|
+
...this.moduleOptions,
|
|
443
|
+
...settings
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/** Registers a task of the game's own, so that a squad on it is carried on after a load. Given by `BrainDef.squads.tasks` */
|
|
447
|
+
define(def) {
|
|
448
|
+
const known = this.tasks.get(def.id);
|
|
449
|
+
if (known && known !== def && TASKS.includes(known)) throw new Error(`"${def.id}" is a task of the kit's: a task of the game's needs a name of its own`);
|
|
450
|
+
this.tasks.set(def.id, def);
|
|
451
|
+
}
|
|
452
|
+
/** A kind of task by its id: the kit's, or one registered */
|
|
453
|
+
taskDef(id) {
|
|
454
|
+
return this.tasks.get(id);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Makes a squad of units under a name (one of that name already is disbanded first), with how it behaves where it
|
|
458
|
+
* is not the brain's way. Whose it is (`owner`): what `options.owner` names (a goal makes its own with
|
|
459
|
+
* `claimed.squad`), else its own (`squad:<name>`). A goal's squad is made of what the goal holds, and what
|
|
460
|
+
* nothing holds is given to it; a squad of a rule or a module takes its units from whatever holds them (the goal
|
|
461
|
+
* told: `stop('told')`) and holds them until it is disbanded. A unit in another squad leaves it
|
|
462
|
+
*/
|
|
463
|
+
make(name, units, options = {}) {
|
|
464
|
+
if (!name) throw new Error("A squad needs a name");
|
|
465
|
+
const { ai } = this;
|
|
466
|
+
const { owner: named, ...own } = options;
|
|
467
|
+
const owner = named ?? `squad:${name}`;
|
|
468
|
+
const old = this.named(name);
|
|
469
|
+
if (old) this.disband(old, "made anew", old.owner !== owner);
|
|
470
|
+
const behaves = {
|
|
471
|
+
...this.defaults,
|
|
472
|
+
...own
|
|
473
|
+
};
|
|
474
|
+
const squad = new Squad(this, {
|
|
475
|
+
name,
|
|
476
|
+
owner,
|
|
477
|
+
units: [],
|
|
478
|
+
options: behaves,
|
|
479
|
+
size: 0,
|
|
480
|
+
made: ai.tick,
|
|
481
|
+
retreats: 0
|
|
482
|
+
});
|
|
483
|
+
this.list.push(squad);
|
|
484
|
+
this.enlist(squad, ids(units));
|
|
485
|
+
squad.data.size = squad.data.units.length;
|
|
486
|
+
squad.changed(`made by ${owner === `squad:${name}` ? "itself" : owner}: ${plural(squad.data.units.length)}`);
|
|
487
|
+
return squad;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Puts units in a squad: those its owner may have (held by it, or given from the pool for a goal; taken for a rule's
|
|
491
|
+
* or a module's), out of any other squad. Those put in, by id
|
|
492
|
+
*/
|
|
493
|
+
enlist(squad, wanted) {
|
|
494
|
+
const { goals, view, session, tick } = this.ai;
|
|
495
|
+
const owner = squad.data.owner;
|
|
496
|
+
const units = wanted.filter((id) => view.mine.has(id) && !squad.data.units.includes(id));
|
|
497
|
+
if (!units.length) return [];
|
|
498
|
+
let put;
|
|
499
|
+
if (goals.get(owner)) {
|
|
500
|
+
goals.give(owner, units);
|
|
501
|
+
put = units.filter((id) => goals.holder(id) === owner);
|
|
502
|
+
} else {
|
|
503
|
+
const hold = goals.held(owner);
|
|
504
|
+
const seconds = !hold || hold.kept ? Infinity : Math.max(1, (hold.until - tick) / session.tickRate);
|
|
505
|
+
goals.take(units, "told", {
|
|
506
|
+
id: owner,
|
|
507
|
+
seconds
|
|
508
|
+
});
|
|
509
|
+
put = units.filter((id) => goals.held(owner)?.units.includes(id));
|
|
510
|
+
}
|
|
511
|
+
if (!put.length) return put;
|
|
512
|
+
for (const other of [...this.list]) {
|
|
513
|
+
if (other === squad || !other.data.units.some((id) => put.includes(id))) continue;
|
|
514
|
+
other.data.units = other.data.units.filter((id) => !put.includes(id));
|
|
515
|
+
other.changed(`${plural(put.length)} went to ${squad.name}`);
|
|
516
|
+
if (!other.data.units.length) this.disband(other, `its units went to ${squad.name}`);
|
|
517
|
+
}
|
|
518
|
+
squad.data.units = squad.data.units.filter((id) => view.mine.has(id));
|
|
519
|
+
squad.data.units.push(...put);
|
|
520
|
+
squad.data.units.sort((a, b) => view.indexOf(view.byId(a)) - view.indexOf(view.byId(b)));
|
|
521
|
+
return put;
|
|
522
|
+
}
|
|
523
|
+
/** A squad by name: none for one there is not */
|
|
524
|
+
named(name) {
|
|
525
|
+
return this.list.find((squad) => squad.data.name === name);
|
|
526
|
+
}
|
|
527
|
+
/** Every squad, as made */
|
|
528
|
+
all() {
|
|
529
|
+
return new SquadGroup(this.ai, this.list);
|
|
530
|
+
}
|
|
531
|
+
/** The squads with nothing to do: told nothing, or their task over */
|
|
532
|
+
idle() {
|
|
533
|
+
return new SquadGroup(this.ai, this.list.filter((squad) => squad.idle));
|
|
534
|
+
}
|
|
535
|
+
/** The squads a goal, rule or module owns */
|
|
536
|
+
of(owner) {
|
|
537
|
+
return new SquadGroup(this.ai, this.list.filter((squad) => squad.data.owner === owner));
|
|
538
|
+
}
|
|
539
|
+
/** The squad a unit is in, by the unit or its id: none for a unit in none */
|
|
540
|
+
squadOf(unit) {
|
|
541
|
+
const id = typeof unit === "number" ? unit : unit.id;
|
|
542
|
+
return this.list.find((squad) => squad.data.units.includes(id));
|
|
543
|
+
}
|
|
544
|
+
/** The player's units nothing holds (`ai.goals.pool`, buildings left out): what a squad is made of, or reinforced from */
|
|
545
|
+
pool() {
|
|
546
|
+
return this.ai.goals.pool().units();
|
|
547
|
+
}
|
|
548
|
+
/** Disbands a squad: a squad that held its units itself lets them go back to the pool */
|
|
549
|
+
disband(squad, why = "disbanded", letGo = true) {
|
|
550
|
+
const index = this.list.indexOf(squad);
|
|
551
|
+
if (index < 0) return;
|
|
552
|
+
this.list.splice(index, 1);
|
|
553
|
+
const { goals } = this.ai;
|
|
554
|
+
if (letGo && !goals.get(squad.data.owner) && goals.held(squad.data.owner)) {
|
|
555
|
+
const others = new Set(this.list.filter((other) => other.data.owner === squad.data.owner).flatMap((other) => other.data.units));
|
|
556
|
+
goals.drop(squad.data.owner, squad.data.units.filter((id) => !others.has(id)));
|
|
557
|
+
}
|
|
558
|
+
if (squad.data.units.length || why !== "made anew") this.ai.decide(`squad ${squad.name} disbanded: ${why}`, { kind: "squad" });
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Gives a squad a task: what it was doing is over, and the new one's first orders go at once. What it has now is what
|
|
562
|
+
* reinforcements make up to from then on (`SquadData.size`), but for a task it goes on to by itself (`going on`: a
|
|
563
|
+
* task's `then`, a fall back on the odds), which keeps what the task before was given. The task it is on given
|
|
564
|
+
* again changes nothing, its `size` kept: what it lost since is what reinforcements make up
|
|
565
|
+
*/
|
|
566
|
+
give(squad, kind, data, goingOn = false) {
|
|
567
|
+
const { ai } = this;
|
|
568
|
+
const def = typeof kind === "string" ? this.tasks.get(kind) : kind;
|
|
569
|
+
if (!def) throw new Error(`The squad "${squad.name}" was given a task "${String(kind)}" the brain does not know: list it in its squads' tasks (defineTask)`);
|
|
570
|
+
if (typeof kind !== "string" && !this.tasks.has(def.id)) this.define(def);
|
|
571
|
+
const before = squad.data.task;
|
|
572
|
+
if (before && before.done === void 0 && before.kind === def.id && sameData(before.data, data)) return;
|
|
573
|
+
const state = {
|
|
574
|
+
kind: def.id,
|
|
575
|
+
data: { ...data },
|
|
576
|
+
since: ai.tick,
|
|
577
|
+
phase: "starting",
|
|
578
|
+
phaseSince: ai.tick,
|
|
579
|
+
memory: {}
|
|
580
|
+
};
|
|
581
|
+
squad.data.task = state;
|
|
582
|
+
if (!goingOn) squad.data.size = squad.data.units.length;
|
|
583
|
+
squad.changed(before && before.done === void 0 ? `${before.kind} → ${def.id}` : `on to ${def.id}`);
|
|
584
|
+
if (squad.data.units.length) def.start(ai, squad, state);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Looks at every squad, once a think: its units (the dead, and what its owner let go of, dropped; a squad of a goal
|
|
588
|
+
* that stopped disbanded), then its task (retreat on the odds, the task's own look, regroup, reinforcements). What the
|
|
589
|
+
* `squads()` module runs; a module may call it sooner
|
|
590
|
+
*/
|
|
591
|
+
think() {
|
|
592
|
+
const { ai } = this;
|
|
593
|
+
if (this.thoughtAt !== ai.tick) {
|
|
594
|
+
this.thoughtAt = ai.tick;
|
|
595
|
+
this.prune();
|
|
596
|
+
this.advancing = [...this.list];
|
|
597
|
+
this.cursor = 0;
|
|
598
|
+
} else if (!this.advancing) return;
|
|
599
|
+
const squads = this.advancing;
|
|
600
|
+
for (; this.cursor < squads.length; this.cursor++) {
|
|
601
|
+
const squad = squads[this.cursor];
|
|
602
|
+
this.advance(squad);
|
|
603
|
+
if (!ai.budget.spent(squad.data.units.length || 1) && this.cursor + 1 < squads.length) {
|
|
604
|
+
this.cursor++;
|
|
605
|
+
return ai.budget.later();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
this.advancing = void 0;
|
|
609
|
+
}
|
|
610
|
+
/** The squads still to be looked at this think, where a pass stopped for the tick's budget, and the next of them */
|
|
611
|
+
advancing;
|
|
612
|
+
cursor = 0;
|
|
613
|
+
/** Every squad's units looked at, as a think begins: the dead and what its owner let go of dropped, a squad with none left disbanded */
|
|
614
|
+
prune() {
|
|
615
|
+
const { ai } = this;
|
|
616
|
+
const { goals, view } = ai;
|
|
617
|
+
for (const squad of [...this.list]) {
|
|
618
|
+
const hold = goals.held(squad.data.owner);
|
|
619
|
+
if (!hold) {
|
|
620
|
+
this.disband(squad, `${squad.data.owner} let go`, false);
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (!goals.get(squad.data.owner) && hold.units.some((id) => !view.mine.has(id))) hold.units = hold.units.filter((id) => view.mine.has(id));
|
|
624
|
+
const kept = squad.data.units.filter((id) => hold.units.includes(id) && view.mine.has(id) && view.byId(id).health > 0);
|
|
625
|
+
if (kept.length !== squad.data.units.length) squad.data.units = kept;
|
|
626
|
+
if (!kept.length) {
|
|
627
|
+
squad.finish("wiped");
|
|
628
|
+
this.disband(squad, "none of its units left", false);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/** One squad's think: retreat on the odds, the task's own look, then on to the next task, regroup, reinforcements */
|
|
633
|
+
advance(squad) {
|
|
634
|
+
const { ai } = this;
|
|
635
|
+
const state = squad.data.task;
|
|
636
|
+
const def = state && this.tasks.get(state.kind);
|
|
637
|
+
const handles = def?.handles ?? [];
|
|
638
|
+
if (state && def && state.done === void 0) {
|
|
639
|
+
if (!handles.includes("retreat") && this.losing(squad)) return;
|
|
640
|
+
const over = def.done?.(ai, squad, state);
|
|
641
|
+
if (over) squad.finish(over);
|
|
642
|
+
else def.think(ai, squad, state);
|
|
643
|
+
if (state.done === void 0 && !handles.includes("regroup") && state.data.regroup !== false) this.regroup(squad, state, def);
|
|
644
|
+
const then = state.data.then;
|
|
645
|
+
if (state.done !== void 0 && state.done !== "lost" && state.done !== "wiped" && then?.kind && this.tasks.has(then.kind)) this.give(squad, then.kind, then.data ?? {}, true);
|
|
646
|
+
}
|
|
647
|
+
if (squad.data.options.reinforce && !handles.includes("reinforce")) this.reinforce(squad);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Whether a squad in a fight away from home is losing it (its odds under `retreatAt`), and so falls back: its task
|
|
651
|
+
* becomes `retreat`, home, and it is said why
|
|
652
|
+
*/
|
|
653
|
+
losing(squad) {
|
|
654
|
+
const { ai } = this;
|
|
655
|
+
const { view } = ai;
|
|
656
|
+
const at = squad.data.options.retreatAt ?? .3;
|
|
657
|
+
if (at === false || !(at > 0)) return false;
|
|
658
|
+
const units = squad.units();
|
|
659
|
+
const middle = units.centre();
|
|
660
|
+
const home = view.home();
|
|
661
|
+
if (!middle || !home) return false;
|
|
662
|
+
const safe = squad.data.options.home ?? 20;
|
|
663
|
+
if (distSq(middle, home) < safe * safe) return false;
|
|
664
|
+
const foes = view.hostile.units().alive().near(middle, 14);
|
|
665
|
+
if (!foes.length || !foes.some((foe) => units.some((unit) => distSq(unit, foe) <= 64))) return false;
|
|
666
|
+
const odds = view.strength.odds(units.near(middle, 14), foes);
|
|
667
|
+
if (odds >= at) return false;
|
|
668
|
+
const was = squad.data.task?.kind ?? "nothing";
|
|
669
|
+
squad.data.retreats++;
|
|
670
|
+
this.give(squad, "retreat", {
|
|
671
|
+
at: point(home),
|
|
672
|
+
why: "odds"
|
|
673
|
+
}, true);
|
|
674
|
+
ai.decide(`squad ${squad.name} falls back home with ${plural(units.length)}: ${was} lost (odds ${odds.toFixed(2)} under ${at})`, { kind: "squad" });
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Regroups a squad that is strung out on its way: too many of its units (`regroupWhen`) further than `spread` from its
|
|
679
|
+
* middle, and no fight near. It gathers on its middle and goes on once together, or once it has waited long enough
|
|
680
|
+
*/
|
|
681
|
+
regroup(squad, state, def) {
|
|
682
|
+
const { ai } = this;
|
|
683
|
+
const units = squad.units();
|
|
684
|
+
if (units.length < 3) return;
|
|
685
|
+
const middle = units.centre();
|
|
686
|
+
const spread = squad.spread();
|
|
687
|
+
if (state.phase === "regrouping") {
|
|
688
|
+
const together = units.every((unit) => distSq(unit, middle) <= spread * spread * .36);
|
|
689
|
+
if (together || ai.tick - state.phaseSince >= REGROUP_FOR * ai.session.tickRate) {
|
|
690
|
+
def.start(ai, squad, state);
|
|
691
|
+
ai.decide(`squad ${squad.name} regrouped${together ? "" : " as much as it waits for"}: on with ${state.kind}`, { kind: "squad" });
|
|
692
|
+
}
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (state.phase !== "going") return;
|
|
696
|
+
const when = squad.data.options.regroupWhen ?? .4;
|
|
697
|
+
if (when === false) return;
|
|
698
|
+
const strayed = units.filter((unit) => distSq(unit, middle) > spread * spread).length;
|
|
699
|
+
if (strayed <= units.length * when) return;
|
|
700
|
+
if (ai.view.hostile.alive().near(middle, 14).length) return;
|
|
701
|
+
state.phase = "regrouping";
|
|
702
|
+
state.phaseSince = ai.tick;
|
|
703
|
+
squad.order({
|
|
704
|
+
type: "move",
|
|
705
|
+
point: point(middle)
|
|
706
|
+
});
|
|
707
|
+
ai.decide(`squad ${squad.name} regroups at ${where(middle)}: ${strayed} of ${units.length} strung out`, { kind: "squad" });
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Makes up what a squad lost since its task began from the pool: the idle fighters nothing holds, the nearest
|
|
711
|
+
* first, given to its owner and sent to join it. Never a hero: one crossing the map alone to a fight dies on the
|
|
712
|
+
* way, and heroes are sent with a squad, not after it. Not while it falls back, nor more often than every few seconds
|
|
713
|
+
*/
|
|
714
|
+
reinforce(squad) {
|
|
715
|
+
const { ai } = this;
|
|
716
|
+
const { data } = squad;
|
|
717
|
+
const missing = data.size - data.units.length;
|
|
718
|
+
if (missing <= 0 || data.task?.kind === "retreat" && data.task.done === void 0) return;
|
|
719
|
+
if (data.nextReinforce !== void 0 && ai.tick < data.nextReinforce) return;
|
|
720
|
+
data.nextReinforce = ai.tick + REINFORCE_EVERY * ai.session.tickRate;
|
|
721
|
+
const join = squad.centre() ?? this.whereOf(squad) ?? ai.view.home();
|
|
722
|
+
if (!join) return;
|
|
723
|
+
const { strength } = ai.view;
|
|
724
|
+
const chosen = [...this.pool().fighters().idle()].filter((unit) => !heroOfState(unit) && unit.health >= WOUNDED * (unit.maxHealth ?? strength.statsOf(unit).health)).sort((a, b) => distSq(a, join) - distSq(b, join) || a.id - b.id).slice(0, missing).map((unit) => unit.id);
|
|
725
|
+
if (!chosen.length) return;
|
|
726
|
+
const size = data.size;
|
|
727
|
+
squad.add(chosen, "reinforced");
|
|
728
|
+
data.size = size;
|
|
729
|
+
const added = chosen.filter((id) => data.units.includes(id));
|
|
730
|
+
if (!added.length) return;
|
|
731
|
+
ai.send({
|
|
732
|
+
type: "attack",
|
|
733
|
+
entities: added,
|
|
734
|
+
point: point(join)
|
|
735
|
+
});
|
|
736
|
+
ai.decide(`squad ${squad.name} reinforced with ${plural(added.length)}`, { kind: "squad" });
|
|
737
|
+
}
|
|
738
|
+
/** The place a squad's task is about: none for a task about no place */
|
|
739
|
+
whereOf(squad) {
|
|
740
|
+
const state = squad.data.task;
|
|
741
|
+
const def = state && this.tasks.get(state.kind);
|
|
742
|
+
return state && def?.where?.(this.ai, squad, state);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* The way to a place round where the enemy is strong (`avoid: 'army'`): the waypoint to go by, where the straight way
|
|
746
|
+
* crosses their strength (the threat map, with what is remembered of their towers, and their army as last seen) and a
|
|
747
|
+
* way round is less hot, tried on either side and then further out, twice at most. A heuristic, not a safe route:
|
|
748
|
+
* none where the straight way is cool enough, or where there is no way round (`note` says so)
|
|
749
|
+
*/
|
|
750
|
+
route(from, to, squad) {
|
|
751
|
+
const { ai } = this;
|
|
752
|
+
const { view } = ai;
|
|
753
|
+
const units = squad.units();
|
|
754
|
+
const flying = units.length > 0 && units.every((unit) => !!view.def(unit).flying);
|
|
755
|
+
const layer = flying ? "air" : "ground";
|
|
756
|
+
const seen = ai.def.knowledge === false ? [] : ai.knowledge.enemy.armySeen(AVOID_SEEN);
|
|
757
|
+
const danger = (at) => {
|
|
758
|
+
let enemy = view.threat.at(at, {
|
|
759
|
+
layer,
|
|
760
|
+
remembered: true
|
|
761
|
+
}).enemy;
|
|
762
|
+
for (const army of seen) if (distSq(army.at, at) < 144) enemy += army.strength;
|
|
763
|
+
return enemy;
|
|
764
|
+
};
|
|
765
|
+
const hottest = (path) => {
|
|
766
|
+
let worst = {
|
|
767
|
+
at: path[0] ?? from,
|
|
768
|
+
enemy: 0
|
|
769
|
+
};
|
|
770
|
+
for (let i = 1; i < path.length; i++) {
|
|
771
|
+
const a = path[i - 1];
|
|
772
|
+
const b = path[i];
|
|
773
|
+
const steps = Math.max(1, Math.ceil(Math.sqrt(distSq(a, b)) / 6));
|
|
774
|
+
for (let s = 1; s <= steps; s++) {
|
|
775
|
+
const at = {
|
|
776
|
+
x: a.x + (b.x - a.x) * s / steps,
|
|
777
|
+
z: a.z + (b.z - a.z) * s / steps
|
|
778
|
+
};
|
|
779
|
+
const enemy = danger(at);
|
|
780
|
+
if (enemy > worst.enemy) worst = {
|
|
781
|
+
at,
|
|
782
|
+
enemy
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return worst;
|
|
787
|
+
};
|
|
788
|
+
const worst = hottest([from, ...view.findPath(from, to, flying) ?? [from, to]]);
|
|
789
|
+
const bearable = Math.max(1e-9, units.strength() * .5);
|
|
790
|
+
if (worst.enemy <= bearable) return { waypoints: [] };
|
|
791
|
+
const { width, depth } = view.session.terrain;
|
|
792
|
+
const dx = to.x - from.x;
|
|
793
|
+
const dz = to.z - from.z;
|
|
794
|
+
const length = Math.sqrt(dx * dx + dz * dz) || 1;
|
|
795
|
+
const aside = {
|
|
796
|
+
x: -dz / length,
|
|
797
|
+
z: dx / length
|
|
798
|
+
};
|
|
799
|
+
let best;
|
|
800
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
801
|
+
const far = DETOUR * (1 + attempt / 2);
|
|
802
|
+
for (const side of [1, -1]) {
|
|
803
|
+
const at = {
|
|
804
|
+
x: Math.min(width - 1, Math.max(1, worst.at.x + aside.x * far * side)),
|
|
805
|
+
z: Math.min(depth - 1, Math.max(1, worst.at.z + aside.z * far * side))
|
|
806
|
+
};
|
|
807
|
+
const there = view.findPath(from, at, flying);
|
|
808
|
+
const on = there && view.findPath(at, to, flying);
|
|
809
|
+
if (!there || !on) continue;
|
|
810
|
+
const enemy = Math.max(hottest([from, ...there]).enemy, hottest([at, ...on]).enemy);
|
|
811
|
+
if (!best || enemy < best.enemy) best = {
|
|
812
|
+
at,
|
|
813
|
+
enemy
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
if (best && best.enemy <= bearable) return {
|
|
817
|
+
waypoints: [point(best.at)],
|
|
818
|
+
note: `round ${where(worst.at)} by ${where(best.at)}`
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
if (best && best.enemy < worst.enemy) return {
|
|
822
|
+
waypoints: [point(best.at)],
|
|
823
|
+
note: `no way round ${where(worst.at)} that is safe: by ${where(best.at)}, the least hot`
|
|
824
|
+
};
|
|
825
|
+
return {
|
|
826
|
+
waypoints: [],
|
|
827
|
+
note: `no way round ${where(worst.at)}: straight`
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
/** Every squad as the report shows it */
|
|
831
|
+
report() {
|
|
832
|
+
return this.list.map((squad) => {
|
|
833
|
+
const { data } = squad;
|
|
834
|
+
const units = squad.units();
|
|
835
|
+
const middle = units.centre();
|
|
836
|
+
const state = data.task;
|
|
837
|
+
const at = this.whereOf(squad);
|
|
838
|
+
return {
|
|
839
|
+
name: data.name,
|
|
840
|
+
owner: data.owner,
|
|
841
|
+
units: [...data.units],
|
|
842
|
+
strength: units.strength(),
|
|
843
|
+
...middle && { at: pair(middle) },
|
|
844
|
+
size: data.size,
|
|
845
|
+
...state && { task: {
|
|
846
|
+
kind: state.kind,
|
|
847
|
+
phase: state.phase,
|
|
848
|
+
since: state.since,
|
|
849
|
+
...at && { at: pair(at) },
|
|
850
|
+
...state.done !== void 0 && { done: state.done }
|
|
851
|
+
} },
|
|
852
|
+
retreats: data.retreats,
|
|
853
|
+
...data.changed && { changed: { ...data.changed } }
|
|
854
|
+
};
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
/** What the squads are, for a save: copies */
|
|
858
|
+
/** Whether it has anything to remember now: one that does not is left out of a save */
|
|
859
|
+
remembers() {
|
|
860
|
+
return this.all().length > 0;
|
|
861
|
+
}
|
|
862
|
+
/** Gives the squads' data as plain data for a save of the brain */
|
|
863
|
+
save() {
|
|
864
|
+
return {
|
|
865
|
+
v: 1,
|
|
866
|
+
squads: this.list.map((squad) => structuredClone(squad.data))
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
/** Takes back what `save` gave: whether it was read. A squad on a task the brain does not know is kept, and does nothing */
|
|
870
|
+
restore(memory) {
|
|
871
|
+
const given = memory;
|
|
872
|
+
if (!given || typeof given !== "object" || given.v !== 1 || !Array.isArray(given.squads)) return false;
|
|
873
|
+
this.list = given.squads.filter((data) => data && typeof data.name === "string" && Array.isArray(data.units)).map((data) => new Squad(this, structuredClone(data)));
|
|
874
|
+
for (const squad of this.list) {
|
|
875
|
+
const kind = squad.data.task?.kind;
|
|
876
|
+
if (kind && !this.tasks.has(kind)) this.ai.log.info("ai", `the squad "${squad.name}" is on a task "${kind}" this brain does not know: it waits`, { squad: squad.name });
|
|
877
|
+
}
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
/** The share of its health under which a unit is not sent as a reinforcement */
|
|
882
|
+
var WOUNDED = .5;
|
|
883
|
+
/** Whether two tasks' data say the same: plain data, field by field */
|
|
884
|
+
function sameData(a, b) {
|
|
885
|
+
if (a === b) return true;
|
|
886
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
887
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
888
|
+
const keys = Object.keys(a).filter((key) => a[key] !== void 0);
|
|
889
|
+
const others = Object.keys(b).filter((key) => b[key] !== void 0);
|
|
890
|
+
return keys.length === others.length && keys.every((key) => sameData(a[key], b[key]));
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* The squads module: looks at every squad of the brain each think (`ai.squads.think`), after the goals, the rules and
|
|
894
|
+
* the words that make them: their units, their tasks, regroups, retreats, reinforcements. With how they behave where the
|
|
895
|
+
* brain's definition and the seat's options say nothing
|
|
896
|
+
*
|
|
897
|
+
* @beta
|
|
898
|
+
*/
|
|
899
|
+
var squads = (options = {}) => defineModule({
|
|
900
|
+
id: "squads",
|
|
901
|
+
make: (ai) => {
|
|
902
|
+
for (const def of options.tasks ?? []) ai.squads.define(def);
|
|
903
|
+
const { tasks: _tasks, ...defaults } = options;
|
|
904
|
+
ai.squads.configure(defaults);
|
|
905
|
+
return {
|
|
906
|
+
id: "squads",
|
|
907
|
+
phase: "act",
|
|
908
|
+
after: ["goals"],
|
|
909
|
+
think: () => ai.squads.think()
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
//#endregion
|
|
914
|
+
export { Squad, SquadGroup, Squads, squads };
|
|
915
|
+
|
|
916
|
+
//# sourceMappingURL=squads.js.map
|