@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,266 @@
|
|
|
1
|
+
import { hypot } from "./exactMath.js";
|
|
2
|
+
import { at } from "./defs.js";
|
|
3
|
+
import { defineComponent } from "./components.js";
|
|
4
|
+
import { engineMessage } from "./messages.js";
|
|
5
|
+
import { scaled } from "./abilities/scaled.js";
|
|
6
|
+
import { applyBuff, hasBuff, removeBuff } from "./abilities/buffs.js";
|
|
7
|
+
import { defineHook } from "./hooks.js";
|
|
8
|
+
import { valueOf } from "./abilities/amounts.js";
|
|
9
|
+
import { defineEffect, effectTargets } from "./abilities/effects.js";
|
|
10
|
+
//#region src/unitResources.ts
|
|
11
|
+
/**
|
|
12
|
+
* The resources pack's id
|
|
13
|
+
*
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
var RESOURCES = "core.resources";
|
|
17
|
+
/**
|
|
18
|
+
* What a unit holds of its pools (`UnitPools`): on every unit whose type has `pools`, from the moment it is made. Its
|
|
19
|
+
* players are told how much of each it holds (`values`, whole numbers), as they are of its mana
|
|
20
|
+
*
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
var pools = /* @__PURE__ */ defineComponent({
|
|
24
|
+
id: "core.pools",
|
|
25
|
+
index: true,
|
|
26
|
+
replicate: "everyone",
|
|
27
|
+
onSpawn: (entity) => {
|
|
28
|
+
const defs = entity.def.pools;
|
|
29
|
+
if (!defs) return;
|
|
30
|
+
const values = {};
|
|
31
|
+
for (const id in defs) values[id] = Math.min(Math.max(defs[id].start ?? defs[id].max, 0), defs[id].max);
|
|
32
|
+
entity.set(pools, { values });
|
|
33
|
+
},
|
|
34
|
+
snapshot: (value) => {
|
|
35
|
+
const sent = {};
|
|
36
|
+
for (const id in value.values) sent[id] = Math.floor(value.values[id]);
|
|
37
|
+
return sent;
|
|
38
|
+
},
|
|
39
|
+
same: (a, b) => {
|
|
40
|
+
for (const id in a) if (a[id] !== b[id]) return false;
|
|
41
|
+
for (const id in b) if (!(id in a)) return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* How much a unit holds of one of its pools (`UnitTypeDef.pools`): 0 where it has none
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
var poolOf = (entity, pool) => entity.get(pools)?.values[pool] ?? 0;
|
|
51
|
+
/** The threshold of a pool whose buff holds it still while it lasts, where it is on now */
|
|
52
|
+
function heldStill(entity, def) {
|
|
53
|
+
for (const threshold of def.thresholds ?? []) if (threshold.empties && !threshold.kept && hasBuff(entity, threshold.buff)) return true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
/** Sets a pool to a value, as its bounds and thresholds go */
|
|
57
|
+
function setPool(world, entity, state, pool, def, value) {
|
|
58
|
+
const before = state.values[pool] ?? 0;
|
|
59
|
+
const after = Math.min(Math.max(value, 0), def.max);
|
|
60
|
+
state.values[pool] = after;
|
|
61
|
+
for (const threshold of def.thresholds ?? []) {
|
|
62
|
+
if (!world.registry.buffs.has(threshold.buff)) continue;
|
|
63
|
+
if (threshold.kept) {
|
|
64
|
+
const on = hasBuff(entity, threshold.buff);
|
|
65
|
+
if (after >= threshold.at && !on) applyBuff(world, entity, threshold.buff, void 0, entity);
|
|
66
|
+
else if (after < threshold.at && on) removeBuff(world, entity, threshold.buff, entity);
|
|
67
|
+
} else if (before < threshold.at && after >= threshold.at) applyBuff(world, entity, threshold.buff, void 0, entity);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fills a pool of a unit by `amount` (empties it, under 0), as far as its bounds go, its thresholds' buffs put on and
|
|
72
|
+
* taken off, the time it decays after started over: what the `gain` effect does, and an ability's `cost` and `gain`.
|
|
73
|
+
* Nothing while a threshold's buff that `empties` it holds it still. How much it changed
|
|
74
|
+
*
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
function changePool(world, entity, pool, amount) {
|
|
78
|
+
const state = entity.get(pools);
|
|
79
|
+
const def = entity.def.pools?.[pool];
|
|
80
|
+
if (!state || !def || !entity.alive || heldStill(entity, def)) return 0;
|
|
81
|
+
const before = state.values[pool] ?? 0;
|
|
82
|
+
setPool(world, entity, state, pool, def, before + amount);
|
|
83
|
+
if (state.quiet) delete state.quiet[pool];
|
|
84
|
+
return state.values[pool] - before;
|
|
85
|
+
}
|
|
86
|
+
/** The factor an ability's costs are grown by, by the stacks of its `costGrowth` buff on the caster */
|
|
87
|
+
function growthOf(caster, ability) {
|
|
88
|
+
const growth = ability.costGrowth;
|
|
89
|
+
if (!growth) return 1;
|
|
90
|
+
const instance = caster.buffs.find((buff) => buff.id === growth.buff);
|
|
91
|
+
return instance ? 1 + growth.per * (instance.stacks ?? 1) : 1;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What an ability costs a caster of its pools now (`AbilityDef.cost`, grown by `costGrowth`), by pool: none for an ability
|
|
95
|
+
* that costs nothing of them
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
function poolCosts(caster, ability, level) {
|
|
100
|
+
if (!ability.cost) return void 0;
|
|
101
|
+
const grown = growthOf(caster, ability);
|
|
102
|
+
const costs = {};
|
|
103
|
+
for (const pool in ability.cost) costs[pool] = at(ability.cost[pool], level) * grown;
|
|
104
|
+
return costs;
|
|
105
|
+
}
|
|
106
|
+
/** The pool a caster has too little of for a cost, where there is one: its name */
|
|
107
|
+
function shortOf(caster, costs) {
|
|
108
|
+
for (const pool in costs) if (costs[pool] > 0 && poolOf(caster, pool) < costs[pool]) return caster.def.pools?.[pool]?.name ?? pool;
|
|
109
|
+
}
|
|
110
|
+
/** Fills or empties a pool of what it reaches */
|
|
111
|
+
var gainEffect = /* @__PURE__ */ defineEffect({
|
|
112
|
+
type: "gain",
|
|
113
|
+
run: (context, effect) => {
|
|
114
|
+
const { world, caster, level } = context;
|
|
115
|
+
for (const entity of effectTargets(context, effect, "allies")) {
|
|
116
|
+
const amount = scaled(world, caster, valueOf(context, effect.amount, entity), effect.scaling, level) * (context.share ?? 1);
|
|
117
|
+
changePool(world, entity, effect.pool, amount);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
fields: [
|
|
121
|
+
{
|
|
122
|
+
path: "pool",
|
|
123
|
+
kind: "text",
|
|
124
|
+
hint: "Which of the pools of what it reaches it fills (energy, fury, heat…): it empties it with an amount under 0"
|
|
125
|
+
},
|
|
126
|
+
"amount",
|
|
127
|
+
"scaling"
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
/** Pools filling and emptying by themselves: back each second, decaying, filled by walking, reloaded */
|
|
131
|
+
function tickPools(world, entity, state, dt) {
|
|
132
|
+
const defs = entity.def.pools;
|
|
133
|
+
const walked = state.at ? hypot(entity.pos.x - state.at.x, entity.pos.z - state.at.z) : 0;
|
|
134
|
+
state.at = {
|
|
135
|
+
x: entity.pos.x,
|
|
136
|
+
z: entity.pos.z
|
|
137
|
+
};
|
|
138
|
+
if (!entity.alive) return;
|
|
139
|
+
for (const pool in defs) {
|
|
140
|
+
const def = defs[pool];
|
|
141
|
+
const now = state.values[pool] ?? 0;
|
|
142
|
+
if (heldStill(entity, def)) continue;
|
|
143
|
+
if (def.thresholds?.find((threshold) => threshold.empties && !threshold.kept && now >= threshold.at && !hasBuff(entity, threshold.buff))) {
|
|
144
|
+
setPool(world, entity, state, pool, def, 0);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const quiet = state.quiet ??= {};
|
|
148
|
+
quiet[pool] = (quiet[pool] ?? 0) + dt;
|
|
149
|
+
let next = now + (def.regen ?? 0) * dt + (def.moving ?? 0) * walked;
|
|
150
|
+
if (def.decay && quiet[pool] >= (def.idle ?? 0)) next -= def.decay * dt;
|
|
151
|
+
if (def.reload !== void 0) {
|
|
152
|
+
const empty = state.empty ??= {};
|
|
153
|
+
if (now <= 0) {
|
|
154
|
+
empty[pool] = (empty[pool] ?? 0) + dt;
|
|
155
|
+
if (empty[pool] >= def.reload) {
|
|
156
|
+
next = def.max;
|
|
157
|
+
delete empty[pool];
|
|
158
|
+
}
|
|
159
|
+
} else delete empty[pool];
|
|
160
|
+
}
|
|
161
|
+
if (next !== now) setPool(world, entity, state, pool, def, next);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Whether a carrier has what a buff takes of it for a while (`BuffDef.drain`) */
|
|
165
|
+
function canPay(entity, drain, seconds) {
|
|
166
|
+
for (const pool in drain) if ((pool === "mana" ? entity.mana : poolOf(entity, pool)) < drain[pool] * seconds) return false;
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
/** What buffs take of their carriers each second, the buff taken off where there is not enough for the next second */
|
|
170
|
+
function drainBuffs(world, dt) {
|
|
171
|
+
for (const entity of world.units.values()) {
|
|
172
|
+
if (!entity.alive || !entity.buffs.length) continue;
|
|
173
|
+
for (const buff of [...entity.buffs]) {
|
|
174
|
+
const drain = world.registry.buffs.find(buff.id)?.drain;
|
|
175
|
+
if (!drain) continue;
|
|
176
|
+
if (!canPay(entity, drain, 1)) {
|
|
177
|
+
removeBuff(world, entity, buff.id);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
for (const pool in drain) if (pool === "mana") entity.mana = Math.max(entity.mana - drain[pool] * dt, 0);
|
|
181
|
+
else changePool(world, entity, pool, -drain[pool] * dt);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Pools by themselves, and what buffs drain: after the abilities have gone off this tick */
|
|
186
|
+
var poolsSystem = {
|
|
187
|
+
name: "pools",
|
|
188
|
+
phase: "decide",
|
|
189
|
+
after: ["abilities"],
|
|
190
|
+
update(world, dt) {
|
|
191
|
+
for (const entity of [...world.index.with(pools)]) {
|
|
192
|
+
const state = entity.get(pools);
|
|
193
|
+
if (state && entity.def.pools) tickPools(world, entity, state, dt);
|
|
194
|
+
}
|
|
195
|
+
drainBuffs(world, dt);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Unit resources: what a game with it (`Rules.packs`) gets for pools beside mana. A unit type's `pools` (`PoolDef`: energy
|
|
200
|
+
* back each second, fury that decays when unused, heat that overheats at a threshold, flow filled by walking, ammo that
|
|
201
|
+
* reloads), an ability's `cost` of them (not ready with less, paid as it goes off) and `gain` (given as it goes off), costs
|
|
202
|
+
* that grow by a buff's stacks (`costGrowth`, mana too), an attack's cost (`attackCost`: no attack with less), buffs
|
|
203
|
+
* that drain a pool or mana each second while they last (`BuffDef.drain`), and the `gain` effect. `changePool`, `poolOf`
|
|
204
|
+
* and `poolCosts` in code
|
|
205
|
+
*
|
|
206
|
+
* @beta
|
|
207
|
+
*/
|
|
208
|
+
function resourcesPack() {
|
|
209
|
+
const ready = defineHook({
|
|
210
|
+
hook: "canCast",
|
|
211
|
+
id: "resources",
|
|
212
|
+
run(world, event) {
|
|
213
|
+
const { caster, ability, level, item } = event;
|
|
214
|
+
if (event.cancelled || item || world.cheats.noManaCosts) return;
|
|
215
|
+
const short = shortOf(caster, poolCosts(caster, ability, level));
|
|
216
|
+
if (short !== void 0) return event.cancel(engineMessage("notEnough", { resource: short }));
|
|
217
|
+
if (ability.costGrowth && ability.manaCost !== void 0 && at(ability.manaCost, level) * growthOf(caster, ability) > caster.mana) event.cancel(engineMessage("notEnoughMana"));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const grown = defineHook({
|
|
221
|
+
hook: "beforeCast",
|
|
222
|
+
id: "resources",
|
|
223
|
+
run(_world, event) {
|
|
224
|
+
if (!event.item && event.ability.costGrowth) event.manaCost *= growthOf(event.caster, event.ability);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
const paid = defineHook({
|
|
228
|
+
hook: "afterCast",
|
|
229
|
+
id: "resources",
|
|
230
|
+
run(world, event) {
|
|
231
|
+
const { caster, ability, level, item } = event;
|
|
232
|
+
if (item) return;
|
|
233
|
+
if (!world.cheats.noManaCosts) {
|
|
234
|
+
const costs = poolCosts(caster, ability, level);
|
|
235
|
+
for (const pool in costs) changePool(world, caster, pool, -costs[pool]);
|
|
236
|
+
}
|
|
237
|
+
for (const pool in ability.gain) changePool(world, caster, pool, at(ability.gain[pool], level));
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const shot = defineHook({
|
|
241
|
+
hook: "beforeAttack",
|
|
242
|
+
id: "resources",
|
|
243
|
+
run(world, event) {
|
|
244
|
+
const cost = event.attacker.def.attackCost;
|
|
245
|
+
if (!cost || event.cancelled) return;
|
|
246
|
+
for (const pool in cost) if (poolOf(event.attacker, pool) < cost[pool]) return event.cancel();
|
|
247
|
+
for (const pool in cost) changePool(world, event.attacker, pool, -cost[pool]);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return {
|
|
251
|
+
id: RESOURCES,
|
|
252
|
+
components: [pools],
|
|
253
|
+
effects: [gainEffect],
|
|
254
|
+
systems: [poolsSystem],
|
|
255
|
+
hooks: [
|
|
256
|
+
ready,
|
|
257
|
+
grown,
|
|
258
|
+
paid,
|
|
259
|
+
shot
|
|
260
|
+
]
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
export { RESOURCES, changePool, poolCosts, poolOf, pools, resourcesPack };
|
|
265
|
+
|
|
266
|
+
//# sourceMappingURL=unitResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unitResources.js","names":[],"sources":["../src/unitResources.ts"],"sourcesContent":["import { valueOf } from './abilities/amounts'\nimport { applyBuff, hasBuff, removeBuff } from './abilities/buffs'\nimport { defineEffect, effectTargets } from './abilities/effects'\nimport { scaled } from './abilities/scaled'\nimport { defineComponent } from './components'\nimport { type AbilityDef, at, type PoolDef } from './defs'\nimport type { Entity } from './entity'\nimport { hypot } from './exactMath'\nimport { defineHook } from './hooks'\nimport type { Vec2 } from './math'\nimport { engineMessage } from './messages'\nimport type { GamePack } from './packs/pack'\nimport type { System } from './registry'\nimport type { World } from './world'\n\n/*\n * Unit resources, an opt-in pack (E2E-PLAN AB14): pools a unit has beside mana (energy, fury, heat, flow, ammo), what\n * abilities and attacks cost of them and give, how they fill and empty by themselves, and buffs at thresholds. A game\n * without it pays nothing for these\n */\n\n/**\n * The resources pack's id\n *\n * @beta\n */\nexport const RESOURCES = 'core.resources'\n\n/**\n * What a unit holds of its pools (`UnitTypeDef.pools`): how much of each (`values`), the seconds since each was last\n * spent or given (`quiet`, for its `decay`), the seconds each has been empty (`empty`, for its `reload`) and where the\n * unit stood a tick ago (`at`, for what fills by walking)\n *\n * @beta\n */\nexport interface UnitPools {\n\t/** How much it holds of each, by pool */\n\tvalues: Record<string, number>\n\t/** Seconds since each was last spent or given, by pool */\n\tquiet?: Record<string, number>\n\t/** Seconds each has been empty, for one that reloads */\n\tempty?: Record<string, number>\n\t/** Where it stood a tick ago, for a pool that fills by walking */\n\tat?: Vec2\n}\n\n/**\n * What a unit holds of its pools (`UnitPools`): on every unit whose type has `pools`, from the moment it is made. Its\n * players are told how much of each it holds (`values`, whole numbers), as they are of its mana\n *\n * @beta\n */\nexport const pools = /* @__PURE__ */ defineComponent<UnitPools, Record<string, number>>({\n\tid: 'core.pools',\n\tindex: true,\n\treplicate: 'everyone',\n\tonSpawn: (entity) => {\n\t\tconst defs = entity.def.pools\n\t\tif (!defs) return\n\t\tconst values: Record<string, number> = {}\n\t\tfor (const id in defs) values[id] = Math.min(Math.max(defs[id].start ?? defs[id].max, 0), defs[id].max)\n\t\tentity.set(pools, { values })\n\t},\n\tsnapshot: (value) => {\n\t\tconst sent: Record<string, number> = {}\n\t\tfor (const id in value.values) sent[id] = Math.floor(value.values[id])\n\t\treturn sent\n\t},\n\tsame: (a, b) => {\n\t\tfor (const id in a) if (a[id] !== b[id]) return false\n\t\tfor (const id in b) if (!(id in a)) return false\n\t\treturn true\n\t}\n})\n\n/**\n * How much a unit holds of one of its pools (`UnitTypeDef.pools`): 0 where it has none\n *\n * @beta\n */\nexport const poolOf = (entity: Entity, pool: string): number => entity.get(pools)?.values[pool] ?? 0\n\n/** The threshold of a pool whose buff holds it still while it lasts, where it is on now */\nfunction heldStill(entity: Entity, def: PoolDef): boolean {\n\tfor (const threshold of def.thresholds ?? []) if (threshold.empties && !threshold.kept && hasBuff(entity, threshold.buff)) return true\n\treturn false\n}\n\n/** Sets a pool to a value, as its bounds and thresholds go */\nfunction setPool(world: World, entity: Entity, state: UnitPools, pool: string, def: PoolDef, value: number): void {\n\tconst before = state.values[pool] ?? 0\n\tconst after = Math.min(Math.max(value, 0), def.max)\n\tstate.values[pool] = after\n\tfor (const threshold of def.thresholds ?? []) {\n\t\tif (!world.registry.buffs.has(threshold.buff)) continue\n\t\tif (threshold.kept) {\n\t\t\tconst on = hasBuff(entity, threshold.buff)\n\t\t\tif (after >= threshold.at && !on) applyBuff(world, entity, threshold.buff, undefined, entity)\n\t\t\telse if (after < threshold.at && on) removeBuff(world, entity, threshold.buff, entity)\n\t\t} else if (before < threshold.at && after >= threshold.at) applyBuff(world, entity, threshold.buff, undefined, entity)\n\t}\n}\n\n/**\n * Fills a pool of a unit by `amount` (empties it, under 0), as far as its bounds go, its thresholds' buffs put on and\n * taken off, the time it decays after started over: what the `gain` effect does, and an ability's `cost` and `gain`.\n * Nothing while a threshold's buff that `empties` it holds it still. How much it changed\n *\n * @beta\n */\nexport function changePool(world: World, entity: Entity, pool: string, amount: number): number {\n\tconst state = entity.get(pools)\n\tconst def = entity.def.pools?.[pool]\n\tif (!state || !def || !entity.alive || heldStill(entity, def)) return 0\n\tconst before = state.values[pool] ?? 0\n\tsetPool(world, entity, state, pool, def, before + amount)\n\tif (state.quiet) delete state.quiet[pool]\n\treturn state.values[pool] - before\n}\n\n/** The factor an ability's costs are grown by, by the stacks of its `costGrowth` buff on the caster */\nfunction growthOf(caster: Entity, ability: AbilityDef): number {\n\tconst growth = ability.costGrowth\n\tif (!growth) return 1\n\tconst instance = caster.buffs.find((buff) => buff.id === growth.buff)\n\treturn instance ? 1 + growth.per * (instance.stacks ?? 1) : 1\n}\n\n/**\n * What an ability costs a caster of its pools now (`AbilityDef.cost`, grown by `costGrowth`), by pool: none for an ability\n * that costs nothing of them\n *\n * @beta\n */\nexport function poolCosts(caster: Entity, ability: AbilityDef, level: number): Record<string, number> | undefined {\n\tif (!ability.cost) return undefined\n\tconst grown = growthOf(caster, ability)\n\tconst costs: Record<string, number> = {}\n\tfor (const pool in ability.cost) costs[pool] = at(ability.cost[pool], level) * grown\n\treturn costs\n}\n\n/** The pool a caster has too little of for a cost, where there is one: its name */\nfunction shortOf(caster: Entity, costs: Record<string, number> | undefined): string | undefined {\n\tfor (const pool in costs) if (costs[pool] > 0 && poolOf(caster, pool) < costs[pool]) return caster.def.pools?.[pool]?.name ?? pool\n\treturn undefined\n}\n\n/** Fills or empties a pool of what it reaches */\nconst gainEffect = /* @__PURE__ */ defineEffect({\n\ttype: 'gain',\n\trun: (context, effect) => {\n\t\tconst { world, caster, level } = context\n\t\tfor (const entity of effectTargets(context, effect, 'allies')) {\n\t\t\tconst amount = scaled(world, caster, valueOf(context, effect.amount, entity), effect.scaling, level) * (context.share ?? 1)\n\t\t\tchangePool(world, entity, effect.pool, amount)\n\t\t}\n\t},\n\tfields: [{ path: 'pool', kind: 'text', hint: 'Which of the pools of what it reaches it fills (energy, fury, heat…): it empties it with an amount under 0' }, 'amount', 'scaling']\n})\n\n/** Pools filling and emptying by themselves: back each second, decaying, filled by walking, reloaded */\nfunction tickPools(world: World, entity: Entity, state: UnitPools, dt: number): void {\n\tconst defs = entity.def.pools!\n\tconst walked = state.at ? hypot(entity.pos.x - state.at.x, entity.pos.z - state.at.z) : 0\n\tstate.at = { x: entity.pos.x, z: entity.pos.z }\n\tif (!entity.alive) return\n\tfor (const pool in defs) {\n\t\tconst def = defs[pool]\n\t\tconst now = state.values[pool] ?? 0\n\t\tif (heldStill(entity, def)) continue\n\t\t// what held it still has ended: empty, as an overheat leaves it\n\t\tconst over = def.thresholds?.find((threshold) => threshold.empties && !threshold.kept && now >= threshold.at && !hasBuff(entity, threshold.buff))\n\t\tif (over) {\n\t\t\tsetPool(world, entity, state, pool, def, 0)\n\t\t\tcontinue\n\t\t}\n\t\tconst quiet = (state.quiet ??= {})\n\t\tquiet[pool] = (quiet[pool] ?? 0) + dt\n\t\tlet next = now + (def.regen ?? 0) * dt + (def.moving ?? 0) * walked\n\t\tif (def.decay && quiet[pool] >= (def.idle ?? 0)) next -= def.decay * dt\n\t\tif (def.reload !== undefined) {\n\t\t\tconst empty = (state.empty ??= {})\n\t\t\tif (now <= 0) {\n\t\t\t\tempty[pool] = (empty[pool] ?? 0) + dt\n\t\t\t\tif (empty[pool] >= def.reload) {\n\t\t\t\t\tnext = def.max\n\t\t\t\t\tdelete empty[pool]\n\t\t\t\t}\n\t\t\t} else delete empty[pool]\n\t\t}\n\t\tif (next !== now) setPool(world, entity, state, pool, def, next)\n\t}\n}\n\n/** Whether a carrier has what a buff takes of it for a while (`BuffDef.drain`) */\nfunction canPay(entity: Entity, drain: Record<string, number>, seconds: number): boolean {\n\tfor (const pool in drain) if ((pool === 'mana' ? entity.mana : poolOf(entity, pool)) < drain[pool] * seconds) return false\n\treturn true\n}\n\n/** What buffs take of their carriers each second, the buff taken off where there is not enough for the next second */\nfunction drainBuffs(world: World, dt: number): void {\n\tfor (const entity of world.units.values()) {\n\t\tif (!entity.alive || !entity.buffs.length) continue\n\t\tfor (const buff of [...entity.buffs]) {\n\t\t\tconst drain = world.registry.buffs.find(buff.id)?.drain\n\t\t\tif (!drain) continue\n\t\t\tif (!canPay(entity, drain, 1)) {\n\t\t\t\tremoveBuff(world, entity, buff.id)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const pool in drain) {\n\t\t\t\tif (pool === 'mana') entity.mana = Math.max(entity.mana - drain[pool] * dt, 0)\n\t\t\t\telse changePool(world, entity, pool, -drain[pool] * dt)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Pools by themselves, and what buffs drain: after the abilities have gone off this tick */\nconst poolsSystem: System = {\n\tname: 'pools',\n\tphase: 'decide',\n\tafter: ['abilities'],\n\tupdate(world, dt) {\n\t\tfor (const entity of [...world.index.with(pools)]) {\n\t\t\tconst state = entity.get(pools)\n\t\t\tif (state && entity.def.pools) tickPools(world, entity, state, dt)\n\t\t}\n\t\tdrainBuffs(world, dt)\n\t}\n}\n\n/**\n * Unit resources: what a game with it (`Rules.packs`) gets for pools beside mana. A unit type's `pools` (`PoolDef`: energy\n * back each second, fury that decays when unused, heat that overheats at a threshold, flow filled by walking, ammo that\n * reloads), an ability's `cost` of them (not ready with less, paid as it goes off) and `gain` (given as it goes off), costs\n * that grow by a buff's stacks (`costGrowth`, mana too), an attack's cost (`attackCost`: no attack with less), buffs\n * that drain a pool or mana each second while they last (`BuffDef.drain`), and the `gain` effect. `changePool`, `poolOf`\n * and `poolCosts` in code\n *\n * @beta\n */\nexport function resourcesPack(): GamePack {\n\tconst ready = defineHook({\n\t\thook: 'canCast',\n\t\tid: 'resources',\n\t\trun(world, event) {\n\t\t\tconst { caster, ability, level, item } = event\n\t\t\tif (event.cancelled || item || world.cheats.noManaCosts) return\n\t\t\tconst short = shortOf(caster, poolCosts(caster, ability, level))\n\t\t\tif (short !== undefined) return event.cancel(engineMessage('notEnough', { resource: short }))\n\t\t\t// mana grown by stacks: the screen's own check had the cost as it is declared\n\t\t\tif (ability.costGrowth && ability.manaCost !== undefined && at(ability.manaCost, level) * growthOf(caster, ability) > caster.mana)\n\t\t\t\tevent.cancel(engineMessage('notEnoughMana'))\n\t\t}\n\t})\n\tconst grown = defineHook({\n\t\thook: 'beforeCast',\n\t\tid: 'resources',\n\t\trun(_world, event) {\n\t\t\tif (!event.item && event.ability.costGrowth) event.manaCost *= growthOf(event.caster, event.ability)\n\t\t}\n\t})\n\tconst paid = defineHook({\n\t\thook: 'afterCast',\n\t\tid: 'resources',\n\t\trun(world, event) {\n\t\t\tconst { caster, ability, level, item } = event\n\t\t\tif (item) return\n\t\t\tif (!world.cheats.noManaCosts) {\n\t\t\t\tconst costs = poolCosts(caster, ability, level)\n\t\t\t\tfor (const pool in costs) changePool(world, caster, pool, -costs[pool])\n\t\t\t}\n\t\t\tfor (const pool in ability.gain) changePool(world, caster, pool, at(ability.gain[pool], level))\n\t\t}\n\t})\n\tconst shot = defineHook({\n\t\thook: 'beforeAttack',\n\t\tid: 'resources',\n\t\trun(world, event) {\n\t\t\tconst cost = event.attacker.def.attackCost\n\t\t\tif (!cost || event.cancelled) return\n\t\t\tfor (const pool in cost) if (poolOf(event.attacker, pool) < cost[pool]) return event.cancel()\n\t\t\tfor (const pool in cost) changePool(world, event.attacker, pool, -cost[pool])\n\t\t}\n\t})\n\treturn {\n\t\tid: RESOURCES,\n\t\tcomponents: [pools],\n\t\teffects: [gainEffect],\n\t\tsystems: [poolsSystem],\n\t\thooks: [ready, grown, paid, shot]\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,YAAY;;;;;;;AA0BzB,IAAa,QAAwB,gCAAmD;CACvF,IAAI;CACJ,OAAO;CACP,WAAW;CACX,UAAU,WAAW;EACpB,MAAM,OAAO,OAAO,IAAI;EACxB,IAAI,CAAC,MAAM;EACX,MAAM,SAAiC,CAAC;EACxC,KAAK,MAAM,MAAM,MAAM,OAAO,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG;EACtG,OAAO,IAAI,OAAO,EAAE,OAAO,CAAC;CAC7B;CACA,WAAW,UAAU;EACpB,MAAM,OAA+B,CAAC;EACtC,K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AU,IAAI,IAAI,KAAK,OAAO,OAAO,MAAM,OAAO;GAC5F,KAAK,MAAM,QAAQ,MAAM,WAAW,OAAO,MAAM,UAAU,MAAM,CAAC,KAAK,KAAK;EAC7E;CACD,CAAC;CACD,OAAO;EACN,IAAI;EACJ,YAAY,CAAC,KAAK;EAClB,SAAS,CAAC,UAAU;EACpB,SAAS,CAAC,WAAW;EACrB,OAAO;GAAC;GAAO;GAAO;GAAM;EAAI;CACjC;AACD"}
|
package/dist/upkeep.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { PlayerId } from './entity';
|
|
2
2
|
import type { World } from './world';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The upkeep a player is at: its tier, its name and the share of income that reaches them
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
4
8
|
export interface Upkeep {
|
|
5
9
|
/** 0 without upkeep, then counting up with the tiers of the game */
|
|
6
10
|
tier: number;
|
|
11
|
+
/** The name of the upkeep tier, shown to the player */
|
|
7
12
|
name: string;
|
|
8
13
|
/** Part of the gold a worker brings in that reaches the player */
|
|
9
14
|
income: number;
|
package/dist/upkeep.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/upkeep.ts
|
|
2
|
+
/**
|
|
3
|
+
* What a player's army costs them, by how much supply they use
|
|
4
|
+
*
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
function upkeepOf(world, player) {
|
|
8
|
+
const { supplyUsed } = world.player(player);
|
|
9
|
+
let upkeep = {
|
|
10
|
+
tier: 0,
|
|
11
|
+
name: "No upkeep",
|
|
12
|
+
income: 1
|
|
13
|
+
};
|
|
14
|
+
world.registry.upkeep.forEach((tier, index) => {
|
|
15
|
+
if (supplyUsed > tier.above) upkeep = {
|
|
16
|
+
tier: index + 1,
|
|
17
|
+
name: tier.name,
|
|
18
|
+
income: tier.income
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return upkeep;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { upkeepOf };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=upkeep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upkeep.js","names":[],"sources":["../src/upkeep.ts"],"sourcesContent":["import type { PlayerId } from './entity'\nimport type { World } from './world'\n\n/**\n * The upkeep a player is at: its tier, its name and the share of income that reaches them\n *\n * @beta\n */\nexport interface Upkeep {\n\t/** 0 without upkeep, then counting up with the tiers of the game */\n\ttier: number\n\t/** The name of the upkeep tier, shown to the player */\n\tname: string\n\t/** Part of the gold a worker brings in that reaches the player */\n\tincome: number\n}\n\n/**\n * What a player's army costs them, by how much supply they use\n *\n * @beta\n */\nexport function upkeepOf(world: World, player: PlayerId): Upkeep {\n\tconst { supplyUsed } = world.player(player)\n\tlet upkeep: Upkeep = { tier: 0, name: 'No upkeep', income: 1 }\n\tworld.registry.upkeep.forEach((tier, index) => {\n\t\tif (supplyUsed > tier.above) upkeep = { tier: index + 1, name: tier.name, income: tier.income }\n\t})\n\treturn upkeep\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,SAAS,OAAc,QAA0B;CAChE,MAAM,EAAE,eAAe,MAAM,OAAO,MAAM;CAC1C,IAAI,SAAiB;EAAE,MAAM;EAAG,MAAM;EAAa,QAAQ;CAAE;CAC7D,MAAM,SAAS,OAAO,SAAS,MAAM,UAAU;EAC9C,IAAI,aAAa,KAAK,OAAO,SAAS;GAAE,MAAM,QAAQ;GAAG,MAAM,KAAK;GAAM,QAAQ,KAAK;EAAO;CAC/F,CAAC;CACD,OAAO;AACR"}
|
package/dist/veterancy.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ import type { World } from './world';
|
|
|
9
9
|
* @beta
|
|
10
10
|
*/
|
|
11
11
|
export interface VeterancyRank {
|
|
12
|
+
/** The rank's name */
|
|
12
13
|
name: string;
|
|
14
|
+
/** The experience a unit starts the rank at */
|
|
13
15
|
xp: number;
|
|
16
|
+
/** What the rank adds to the unit's stats, in place of the rank before's */
|
|
14
17
|
stats?: StatChange;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
@@ -19,7 +22,9 @@ export interface VeterancyRank {
|
|
|
19
22
|
* @beta
|
|
20
23
|
*/
|
|
21
24
|
export interface VeterancyState {
|
|
25
|
+
/** Experience the unit has gained */
|
|
22
26
|
xp: number;
|
|
27
|
+
/** Index of the rank reached, 0 for none yet */
|
|
23
28
|
rank: number;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
@@ -29,7 +34,7 @@ export interface VeterancyState {
|
|
|
29
34
|
*/
|
|
30
35
|
export declare const VETERANCY_RANKS: readonly VeterancyRank[];
|
|
31
36
|
/**
|
|
32
|
-
* What veterancy is made of (`
|
|
37
|
+
* What veterancy is made of (`veterancyPack`)
|
|
33
38
|
*
|
|
34
39
|
* @beta
|
|
35
40
|
*/
|
|
@@ -66,7 +71,7 @@ export declare function rankOf(entity: Entity, ranks?: readonly VeterancyRank[])
|
|
|
66
71
|
/**
|
|
67
72
|
* Gives a unit experience, as a kill does: its rank goes up where it reaches the next ones' thresholds, its stats
|
|
68
73
|
* with it, and `rankedUp` is told for each. Gives back the rank it is at. For a game's own rules (a unit that trains
|
|
69
|
-
* at a camp), and what `
|
|
74
|
+
* at a camp), and what `veterancyPack` does on a kill
|
|
70
75
|
*
|
|
71
76
|
* @beta
|
|
72
77
|
*/
|
|
@@ -77,4 +82,4 @@ export declare function grantVeterancy(world: World, entity: Entity, xp: number,
|
|
|
77
82
|
*
|
|
78
83
|
* @beta
|
|
79
84
|
*/
|
|
80
|
-
export declare function
|
|
85
|
+
export declare function veterancyPack(options?: VeterancyOptions): GamePack;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { defineComponent } from "./components.js";
|
|
2
|
+
import { invalidateStats } from "./stats.js";
|
|
3
|
+
import { defineEngineEvent } from "./events.js";
|
|
4
|
+
import { heroState, xpWorth } from "./hero.js";
|
|
5
|
+
import { defineHook } from "./hooks.js";
|
|
6
|
+
//#region src/veterancy.ts
|
|
7
|
+
/**
|
|
8
|
+
* Ranks as many games have them: three, at 50, 150 and 300 experience, 10%, 20% and 30% more damage and health
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
var VETERANCY_RANKS = [
|
|
13
|
+
{
|
|
14
|
+
name: "Veteran",
|
|
15
|
+
xp: 50,
|
|
16
|
+
stats: { percent: {
|
|
17
|
+
attackDamage: .1,
|
|
18
|
+
health: .1
|
|
19
|
+
} }
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "Elite",
|
|
23
|
+
xp: 150,
|
|
24
|
+
stats: { percent: {
|
|
25
|
+
attackDamage: .2,
|
|
26
|
+
health: .2
|
|
27
|
+
} }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "Heroic",
|
|
31
|
+
xp: 300,
|
|
32
|
+
stats: { percent: {
|
|
33
|
+
attackDamage: .3,
|
|
34
|
+
health: .3
|
|
35
|
+
} }
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* What a unit has of veterancy, told to everyone (a rank shows on its plate): none for one that has earned nothing
|
|
40
|
+
*
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
43
|
+
var veterancy = defineComponent({
|
|
44
|
+
id: "core.veterancy",
|
|
45
|
+
replicate: "everyone"
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* A unit reached a rank: told to everyone, for a sound or a word on the screen
|
|
49
|
+
*
|
|
50
|
+
* @beta
|
|
51
|
+
*/
|
|
52
|
+
var rankedUp = defineEngineEvent({
|
|
53
|
+
id: "core.rankedUp",
|
|
54
|
+
replicate: "everyone"
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* The rank a unit has reached, as a definition, or none: of the game's ranks (`VeterancyOptions.ranks`)
|
|
58
|
+
*
|
|
59
|
+
* @beta
|
|
60
|
+
*/
|
|
61
|
+
function rankOf(entity, ranks = VETERANCY_RANKS) {
|
|
62
|
+
const rank = entity.get(veterancy)?.rank ?? 0;
|
|
63
|
+
return rank > 0 ? ranks[rank - 1] : void 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gives a unit experience, as a kill does: its rank goes up where it reaches the next ones' thresholds, its stats
|
|
67
|
+
* with it, and `rankedUp` is told for each. Gives back the rank it is at. For a game's own rules (a unit that trains
|
|
68
|
+
* at a camp), and what `veterancyPack` does on a kill
|
|
69
|
+
*
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
function grantVeterancy(world, entity, xp, ranks = VETERANCY_RANKS) {
|
|
73
|
+
const now = entity.get(veterancy) ?? {
|
|
74
|
+
xp: 0,
|
|
75
|
+
rank: 0
|
|
76
|
+
};
|
|
77
|
+
const next = {
|
|
78
|
+
xp: now.xp + Math.max(0, xp),
|
|
79
|
+
rank: now.rank
|
|
80
|
+
};
|
|
81
|
+
while (next.rank < ranks.length && next.xp >= ranks[next.rank].xp) {
|
|
82
|
+
next.rank++;
|
|
83
|
+
world.events.emit(rankedUp, {
|
|
84
|
+
entity: entity.id,
|
|
85
|
+
rank: next.rank,
|
|
86
|
+
name: ranks[next.rank - 1].name
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
entity.set(veterancy, next);
|
|
90
|
+
if (next.rank !== now.rank) invalidateStats(world, entity);
|
|
91
|
+
return next.rank;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Veterancy for a game's units (`VeterancyOptions`): the killer of an enemy earns what it was worth, ranks come at
|
|
95
|
+
* their thresholds, each rank's stats are added (the `stats` hook). The game is the same otherwise
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
function veterancyPack(options = {}) {
|
|
100
|
+
const ranks = options.ranks ?? VETERANCY_RANKS;
|
|
101
|
+
const earns = options.earns ?? ((_world, entity) => !entity.has(heroState) && !entity.isStructure && entity.alive);
|
|
102
|
+
const deathHook = defineHook({
|
|
103
|
+
hook: "death",
|
|
104
|
+
id: "core.veterancy.death",
|
|
105
|
+
run(world, event) {
|
|
106
|
+
const { entity: dead, killer } = event;
|
|
107
|
+
if (!killer || !world.areEnemies(killer.owner, dead.owner) || !earns(world, killer)) return;
|
|
108
|
+
const worth = options.worth ? options.worth(world, dead, killer) : xpWorth(world, dead);
|
|
109
|
+
if (worth > 0) grantVeterancy(world, killer, worth, ranks);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const statsHook = defineHook({
|
|
113
|
+
hook: "stats",
|
|
114
|
+
id: "core.veterancy.stats",
|
|
115
|
+
run(_world, event) {
|
|
116
|
+
const rank = rankOf(event.entity, ranks);
|
|
117
|
+
if (rank?.stats) event.add(rank.stats);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
id: "veterancy",
|
|
122
|
+
options,
|
|
123
|
+
components: [veterancy],
|
|
124
|
+
events: [rankedUp],
|
|
125
|
+
hooks: [deathHook, statsHook]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { VETERANCY_RANKS, grantVeterancy, rankOf, rankedUp, veterancy, veterancyPack };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=veterancy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"veterancy.js","names":[],"sources":["../src/veterancy.ts"],"sourcesContent":["import { defineComponent } from './components'\nimport type { GamePack } from './packs/pack'\nimport type { StatChange } from './defs'\nimport type { Entity } from './entity'\nimport { defineEngineEvent } from './events'\nimport { heroState, xpWorth } from './hero'\nimport { defineHook } from './hooks'\nimport { invalidateStats } from './stats'\nimport type { World } from './world'\n\n/*\n * Veterancy, an opt-in pack (master plan OH1): units that are not heroes earn experience from what they kill, reach\n * ranks at thresholds, and each rank adds to their stats. A game turns it on with the pack `veterancyPack(options)` in its `packs`; what\n * a unit has is a component (`veterancy`), saved and told to everyone, and a rank reached is an event (`rankedUp`) for\n * the screen. What it looks like (a chevron on the plate) is the game's: the client reads the component\n */\n\n/**\n * A rank of veterancy: the experience it starts at, its name, and what it adds to a unit's stats (in place of the rank\n * before's: each says all a unit of that rank has)\n *\n * @beta\n */\nexport interface VeterancyRank {\n\t/** The rank's name */\n\tname: string\n\t/** The experience a unit starts the rank at */\n\txp: number\n\t/** What the rank adds to the unit's stats, in place of the rank before's */\n\tstats?: StatChange\n}\n\n/**\n * What a unit has of veterancy: its experience and the rank it reached (0 for none yet)\n *\n * @beta\n */\nexport interface VeterancyState {\n\t/** Experience the unit has gained */\n\txp: number\n\t/** Index of the rank reached, 0 for none yet */\n\trank: number\n}\n\n/**\n * Ranks as many games have them: three, at 50, 150 and 300 experience, 10%, 20% and 30% more damage and health\n *\n * @beta\n */\nexport const VETERANCY_RANKS: readonly VeterancyRank[] = [\n\t{ name: 'Veteran', xp: 50, stats: { percent: { attackDamage: 0.1, health: 0.1 } } },\n\t{ name: 'Elite', xp: 150, stats: { percent: { attackDamage: 0.2, health: 0.2 } } },\n\t{ name: 'Heroic', xp: 300, stats: { percent: { attackDamage: 0.3, health: 0.3 } } }\n]\n\n/**\n * What veterancy is made of (`veterancyPack`)\n *\n * @beta\n */\nexport interface VeterancyOptions {\n\t/** The ranks, from the lowest: `VETERANCY_RANKS` when left out */\n\tranks?: readonly VeterancyRank[]\n\t/** Who earns it: units of a player's that are not heroes and not structures, when left out */\n\tearns?: (world: World, entity: Entity) => boolean\n\t/** What a kill is worth to the killer: what it is worth to heroes (`xpWorth`), when left out. 0 for nothing */\n\tworth?: (world: World, dead: Entity, killer: Entity) => number\n}\n\n/**\n * What a unit has of veterancy, told to everyone (a rank shows on its plate): none for one that has earned nothing\n *\n * @beta\n */\nexport const veterancy = defineComponent<VeterancyState>({ id: 'core.veterancy', replicate: 'everyone' })\n\n/**\n * A unit reached a rank: told to everyone, for a sound or a word on the screen\n *\n * @beta\n */\nexport const rankedUp = defineEngineEvent<{ entity: number; rank: number; name: string }>({ id: 'core.rankedUp', replicate: 'everyone' })\n\n/**\n * The rank a unit has reached, as a definition, or none: of the game's ranks (`VeterancyOptions.ranks`)\n *\n * @beta\n */\nexport function rankOf(entity: Entity, ranks: readonly VeterancyRank[] = VETERANCY_RANKS): VeterancyRank | undefined {\n\tconst rank = entity.get(veterancy)?.rank ?? 0\n\treturn rank > 0 ? ranks[rank - 1] : undefined\n}\n\n/**\n * Gives a unit experience, as a kill does: its rank goes up where it reaches the next ones' thresholds, its stats\n * with it, and `rankedUp` is told for each. Gives back the rank it is at. For a game's own rules (a unit that trains\n * at a camp), and what `veterancyPack` does on a kill\n *\n * @beta\n */\nexport function grantVeterancy(world: World, entity: Entity, xp: number, ranks: readonly VeterancyRank[] = VETERANCY_RANKS): number {\n\tconst now = entity.get(veterancy) ?? { xp: 0, rank: 0 }\n\tconst next: VeterancyState = { xp: now.xp + Math.max(0, xp), rank: now.rank }\n\twhile (next.rank < ranks.length && next.xp >= ranks[next.rank].xp) {\n\t\tnext.rank++\n\t\tworld.events.emit(rankedUp, { entity: entity.id, rank: next.rank, name: ranks[next.rank - 1].name })\n\t}\n\tentity.set(veterancy, next)\n\tif (next.rank !== now.rank) invalidateStats(world, entity)\n\treturn next.rank\n}\n\n/**\n * Veterancy for a game's units (`VeterancyOptions`): the killer of an enemy earns what it was worth, ranks come at\n * their thresholds, each rank's stats are added (the `stats` hook). The game is the same otherwise\n *\n * @beta\n */\nexport function veterancyPack(options: VeterancyOptions = {}): GamePack {\n\tconst ranks = options.ranks ?? VETERANCY_RANKS\n\tconst earns = options.earns ?? ((_world: World, entity: Entity) => !entity.has(heroState) && !entity.isStructure && entity.alive)\n\tconst deathHook = defineHook({\n\t\thook: 'death',\n\t\tid: 'core.veterancy.death',\n\t\trun(world, event) {\n\t\t\tconst { entity: dead, killer } = event\n\t\t\tif (!killer || !world.areEnemies(killer.owner, dead.owner) || !earns(world, killer)) return\n\t\t\tconst worth = options.worth ? options.worth(world, dead, killer) : xpWorth(world, dead)\n\t\t\tif (worth > 0) grantVeterancy(world, killer, worth, ranks)\n\t\t}\n\t})\n\tconst statsHook = defineHook({\n\t\thook: 'stats',\n\t\tid: 'core.veterancy.stats',\n\t\trun(_world, event) {\n\t\t\tconst rank = rankOf(event.entity, ranks)\n\t\t\tif (rank?.stats) event.add(rank.stats)\n\t\t}\n\t})\n\treturn {\n\t\tid: 'veterancy',\n\t\toptions,\n\t\tcomponents: [veterancy],\n\t\tevents: [rankedUp],\n\t\thooks: [deathHook, statsHook]\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAiDA,IAAa,kBAA4C;CACxD;EAAE,MAAM;EAAW,IAAI;EAAI,OAAO,EAAE,SAAS;GAAE,cAAc;GAAK,QAAQ;EAAI,EAAE;CAAE;CAClF;EAAE,MAAM;EAAS,IAAI;EAAK,OAAO,EAAE,SAAS;GAAE,cAAc;GAAK,QAAQ;EAAI,EAAE;CAAE;CACjF;EAAE,MAAM;EAAU,IAAI;EAAK,OAAO,EAAE,SAAS;GAAE,cAAc;GAAK,QAAQ;EAAI,EAAE;CAAE;AACnF;;;;;;AAqBA,IAAa,YAAY,gBAAgC;CAAE,IAAI;CAAkB,WAAW;AAAW,CAAC;;;;;;AAOxG,IAAa,WAAW,kBAAkE;CAAE,IAAI;CAAiB,WAAW;AAAW,CAAC;;;;;;AAOxI,SAAgB,OAAO,QAAgB,QAAkC,iBAA4C;CACpH,MAAM,OAAO,OAAO,IAAI,SAAS,CAAC,EAAE,QAAQ;CAC5C,OAAO,OAAO,IAAI,MAAM,OAAO,KAAK,KAAA;AACrC;;;;;;;;AASA,SAAgB,eAAe,OAAc,QAAgB,IAAY,QAAkC,iBAAyB;CACnI,MAAM,MAAM,OAAO,IAAI,SAAS,KAAK;EAAE,IAAI;EAAG,MAAM;CAAE;CACtD,MAAM,OAAuB;EAAE,IAAI,IAAI,KAAK,KAAK,IAAI,GAAG,EAAE;EAAG,MAAM,IAAI;CAAK;CAC5E,OAA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
+
import { type Entity } from './entity';
|
|
2
|
+
import type { GamePack } from './packs/pack';
|
|
3
|
+
import type { World } from './world';
|
|
4
|
+
/**
|
|
5
|
+
* The vision pack's id
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export declare const VISION = "core.vision";
|
|
10
|
+
/**
|
|
11
|
+
* Lets a team see a unit wherever it is for so many seconds (the longer of these and what it had): in the fog (lit where
|
|
12
|
+
* it stands), in a bush, invisible or camouflaged. What the `revealUnit` effect does, for a game's own code. Works in any
|
|
13
|
+
* game: the engine's fog and sight read it
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export declare function revealUnit(world: World, entity: Entity, team: number, seconds: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* How near its enemies have to come to see a camouflaged unit (`BuffDef.camouflage`): the most of what its buffs say, or
|
|
20
|
+
* undefined where it is not camouflaged
|
|
21
|
+
*
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare function camouflageOf(world: World, entity: Entity): number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Vision: what a game with it (`Rules.packs`) gets for what is seen. A buff that reveals its carrier to the team of
|
|
27
|
+
* whoever put it on (`BuffDef.revealed`), the `revealUnit` effect (the caster's team sees each it reaches for its
|
|
28
|
+
* `duration`; `revealUnit` in code), camouflage (`BuffDef.camouflage`: enemies see the carrier only from that near) and
|
|
29
|
+
* true sight (`UnitTypeDef.trueSight`, `BuffDef.trueSight`: the invisible and camouflaged enemies that near are found).
|
|
30
|
+
* Everything that asks what a team sees goes by it (`world.isVisibleTo`: what units pick, the commands a player may give,
|
|
31
|
+
* the computer players, each player's snapshot), and the fog is lit where a revealed or found unit stands, as for what a
|
|
32
|
+
* `detect` found. Nothing of its own is saved: what is revealed is the `detection` component
|
|
33
|
+
*
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
export declare function visionPack(): GamePack;
|