Compare commits
54
Commits
bf85f62dca
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7452f8be6 | ||
|
|
8b1c3cf88a | ||
|
|
460d9808e5 | ||
|
|
518a1a5744 | ||
|
|
55c0ec775a | ||
|
|
9caed3f12d | ||
|
|
9418b6950a | ||
|
|
828bb0a1a7 | ||
|
|
4f02ad64b4 | ||
|
|
6ba3036de6 | ||
|
|
b8dfa9184e | ||
|
|
0e1e7790f9 | ||
|
|
2c2158702d | ||
|
|
d21adb90d5 | ||
|
|
6738eda748 | ||
|
|
2dcbe3107d | ||
|
|
3ec882dc4e | ||
|
|
08e5cbf5ea | ||
|
|
681d5e5eae | ||
|
|
213c31dfb2 | ||
|
|
5453159867 | ||
|
|
c6ee764c6c | ||
|
|
970dd338f5 | ||
|
|
95d21b06ff | ||
|
|
9233320fd1 | ||
|
|
6397fe89b6 | ||
|
|
3768ce7ed8 | ||
|
|
253dde90cd | ||
|
|
ac285b5c97 | ||
|
|
f41d8ba2f9 | ||
|
|
87d85ff02e | ||
|
|
ae2aedd131 | ||
|
|
cc322572b4 | ||
|
|
372fca7a68 | ||
|
|
82b52ae1fc | ||
|
|
d5464f7438 | ||
|
|
0e71ef1fa7 | ||
|
|
38fd8f7dd2 | ||
|
|
8f2e1f210d | ||
|
|
7a7ac59edf | ||
|
|
96f471ef4a | ||
|
|
f15c915e54 | ||
|
|
a66aca35bf | ||
|
|
ae9aaafaae | ||
|
|
009b2fb591 | ||
|
|
07c4d70de5 | ||
|
|
a2106cfa26 | ||
|
|
0a7102cd51 | ||
|
|
3b920e0715 | ||
|
|
7b13231f29 | ||
|
|
fda19a5200 | ||
|
|
01994ed344 | ||
|
|
e4ca37dfc1 | ||
|
|
0048527fe2 |
+31
@@ -0,0 +1,31 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: discord-changelog
|
||||||
|
|
||||||
|
clone:
|
||||||
|
depth: 0
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: test-changelog
|
||||||
|
image: python:3.13-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git
|
||||||
|
- python tools/build_admin_menu.py --check
|
||||||
|
- python -m unittest discover -s tests -p test_admin_menu_sources.py
|
||||||
|
- python -m unittest discover -s tests -p test_discord_changelog_ci.py
|
||||||
|
- python -m unittest discover -s tests -p test_workshop_changelog.py
|
||||||
|
|
||||||
|
- name: notify-discord
|
||||||
|
image: python:3.13-alpine
|
||||||
|
environment:
|
||||||
|
DISCORD_WEBHOOK_URL:
|
||||||
|
from_secret: discord_webhook_url
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git
|
||||||
|
- python tools/discord_changelog_ci.py
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
@@ -6,6 +6,11 @@ __pycache__/
|
|||||||
.local/
|
.local/
|
||||||
profiles/
|
profiles/
|
||||||
|
|
||||||
|
# Retired RHS 1.9 overrides: keep archived/generated upstream source out of Git.
|
||||||
|
# These files must be absent from the active addon and future Workshop packages.
|
||||||
|
/addons/core/Scripts/Game/Editor/Components/EditableEntity/RHS_CAS_EditableEntityComponent.c
|
||||||
|
/addons/core/Scripts/Game/Vehicle/RHS_DestructionTireComponent.c
|
||||||
|
|
||||||
# Preserve exact raw dedicated diagnostic evidence, outside release addons.
|
# Preserve exact raw dedicated diagnostic evidence, outside release addons.
|
||||||
!docs/evidence/**/*.log
|
!docs/evidence/**/*.log
|
||||||
!docs/evidence/**/resourceDatabase.rdb
|
!docs/evidence/**/resourceDatabase.rdb
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Push changelogs
|
||||||
|
|
||||||
|
Drone is the sole Discord changelog sender. Its first delivery was verified in
|
||||||
|
build #1 on 2026-10-17, and the user confirmed receipt and disabled local sending.
|
||||||
|
Do not run a local/manual Discord sender after pushes or as an automatic fallback.
|
||||||
|
`tools/discord_changelog.py` is disabled and cannot send messages.
|
||||||
|
|
||||||
|
For player-facing changes, maintain the newest entry in `CHANGELOG.md` before
|
||||||
|
pushing to `origin/main`. Keep it concise and describe only fixes/features, without
|
||||||
|
server, deployment, Git push status, operational disclaimers or footers. Do not
|
||||||
|
backfill old changes unless requested. Internal workflow-only changes need no
|
||||||
|
announcement.
|
||||||
|
|
||||||
|
After a confirmed successful Workbench Workshop upload, run
|
||||||
|
`python3 tools/workshop_changelog.py --published` before committing the changelog.
|
||||||
|
This reads the local publishing manifest and records the version in the changelog
|
||||||
|
preamble. Compilation/bundling alone is not confirmation of publication; check
|
||||||
|
the successful upload result first. With no flag the helper only displays the
|
||||||
|
bundled version. Drone includes the recorded version with new changelog entries;
|
||||||
|
a version-only edit does not announce an old entry again.
|
||||||
|
|
||||||
|
The `.drone.yml` pipeline posts the latest changed entry using Drone's
|
||||||
|
`discord_webhook_url` repository secret. See `docs/discord-changelog-ci.md`.
|
||||||
|
Check the Drone result and notification log when available; a successful Git push
|
||||||
|
alone does not prove delivery. Report delivery failures honestly. Inspect Discord
|
||||||
|
before rerunning an uncertain delivery or rebuilding the same push, since builds
|
||||||
|
do not share delivery state and retries can produce duplicates.
|
||||||
|
|
||||||
|
The saved local webhook in `.local/discord-webhook.url` is no longer used for
|
||||||
|
post-push notifications. Never print it, commit it, or put it into changelogs or
|
||||||
|
command-line arguments. Do not configure an additional Discord push webhook
|
||||||
|
alongside Drone.
|
||||||
+201
@@ -0,0 +1,201 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
Latest published Workshop version: **0.0.146**
|
||||||
|
|
||||||
|
## 2026-11-06 — Crash-site salvage
|
||||||
|
|
||||||
|
- Added configurable smoking helicopter and armored wreck sites with finite loot crates.
|
||||||
|
- Crash-site loot defaults to random quality, from poor pistol supplies to rich scoped-rifle and AA/RPG finds; Custom mode keeps manual loot controls.
|
||||||
|
- Added crash-site count, wreck mix and loot settings under Forces → Crash sites.
|
||||||
|
|
||||||
|
## 2026-11-06 — More room in admin lists
|
||||||
|
|
||||||
|
- Expanded scrolling lists into unused menu space and compacted item weight controls to show more settings at once.
|
||||||
|
|
||||||
|
## 2026-11-06 — Clearer content controls
|
||||||
|
|
||||||
|
- Unified mod, item and vehicle controls under Content, with searchable lists and clear enabled/disabled states.
|
||||||
|
- Added mod switches that remember individual choices.
|
||||||
|
- Removed the obsolete RHS 1.9 script overrides so updated RHS scripts are used directly.
|
||||||
|
- Discover vehicles from installed mods and assign them to garages, yards, traffic, enemy patrols and convoy escort or supply roles.
|
||||||
|
|
||||||
|
## 2026-11-06 — Rural traffic and menu scaling
|
||||||
|
|
||||||
|
- Added V2101 variants to civilian traffic and occasional DLC tractors beside farm buildings.
|
||||||
|
- Kept the mission administration panel within the screen at larger UI scales.
|
||||||
|
|
||||||
|
## 2026-11-06 — More parked cars
|
||||||
|
|
||||||
|
- Added T601 and V2101 cars and optional Rally variants to garage vehicle spawns.
|
||||||
|
- Added vehicle parking in suitable residential yards, sharing the garage vehicle limit.
|
||||||
|
|
||||||
|
## 2026-11-05 — RHS compatibility
|
||||||
|
|
||||||
|
- Included the RHS 1.9 script compatibility fixes in Escape, without an extra compatibility addon.
|
||||||
|
- Fixed recovering squads losing their queued reserve orders.
|
||||||
|
- Clarified radio-intel requirements and the airborne extraction objective.
|
||||||
|
- Prevented combat epinephrine use when it would provide no treatment benefit.
|
||||||
|
|
||||||
|
## 2026-11-05 — Garage vehicle access
|
||||||
|
|
||||||
|
- Fixed garage vehicles refusing player entry because of civilian faction hostility.
|
||||||
|
|
||||||
|
## 2026-11-03 — Spectator body camera and player names
|
||||||
|
|
||||||
|
- Spectator cycling now includes your own unconscious body, with ground-level framing and orbit controls.
|
||||||
|
- The statistics dashboard now shows player names alongside their account IDs.
|
||||||
|
|
||||||
|
## 2026-11-01 — Dedicated-server names
|
||||||
|
|
||||||
|
- Server-name telemetry now reads the running dedicated-server configuration before checking lobby metadata.
|
||||||
|
|
||||||
|
## 2026-11-01 — Statistics dashboard
|
||||||
|
|
||||||
|
- Added a private statistics webpage with server win/loss records, last received reports, mission details, player totals and event history, with manual refresh.
|
||||||
|
- Mission telemetry automatically reports server names and keeps dashboard labels updated when servers are renamed.
|
||||||
|
|
||||||
|
## 2026-11-01 — Checkpoints and reconnects
|
||||||
|
|
||||||
|
- Added larger checkpoints with eight guards, extra sandbags and longer barrier approaches on wide roads.
|
||||||
|
- Added separate small/large checkpoint counts and a road-width cutoff under Forces → Checkpoints.
|
||||||
|
- Fixed saving mission settings on fresh profiles.
|
||||||
|
- Returning players receive a fresh soldier when their reserved body is gone, until extraction begins.
|
||||||
|
|
||||||
|
## 2026-10-31 — Terrain mission text
|
||||||
|
|
||||||
|
- Terrain takeover now shows Escape’s mission description on the loading screen instead of the original terrain scenario’s text.
|
||||||
|
|
||||||
|
## 2026-10-31 — Extraction finish
|
||||||
|
|
||||||
|
- Escape statistics open after 30 seconds of airborne evacuation instead of a long flight across the escape boundary.
|
||||||
|
- Rescue helicopters remain safely in place while the results screen is open.
|
||||||
|
|
||||||
|
## 2026-10-31 — Recovery forecast
|
||||||
|
|
||||||
|
- All-down rounds now check whether anyone can wake within five minutes before starting the defeat countdown, while preserving usable self-epinephrine opportunities.
|
||||||
|
|
||||||
|
## 2026-10-30 — Passenger handbrake
|
||||||
|
|
||||||
|
- The front passenger can hold Space to apply the handbrake and release it to let go.
|
||||||
|
|
||||||
|
## 2026-10-30 — Roadblocks, fuel pumps and garage vehicles
|
||||||
|
|
||||||
|
- Added civilian cars and optional motorbikes to garages near exploring players, with gradual spawning, retention of used vehicles, and menu controls for count, chance, radius and spawn delay.
|
||||||
|
- Reduced roadside checkpoint width and length to fit more locations while retaining four guards and a clear vehicle passage.
|
||||||
|
- Fixed existing petrol-station pumps losing their refuelling service when Escape starts on a terrain scenario.
|
||||||
|
|
||||||
|
## 2026-10-30 — Community statistics delivery
|
||||||
|
|
||||||
|
- Fixed rejected mission reports so wins, defeats and queued results can update community statistics.
|
||||||
|
- Game servers now report the loaded island name in statistics instead of the Game Master scenario path.
|
||||||
|
|
||||||
|
## 2026-10-30 — Quieter AI traffic
|
||||||
|
|
||||||
|
- Limited AI drivers to short horn beeps with a 30-second cooldown to reduce repeated honking.
|
||||||
|
|
||||||
|
## 2026-10-30 — Results reading time and spectator hints
|
||||||
|
|
||||||
|
- Kept mission results open for two minutes before automatic restart.
|
||||||
|
- Prevented objective hints from interrupting unconscious spectators and stabilized recovery messages to reduce repeated switching.
|
||||||
|
|
||||||
|
## 2026-10-30 — Results panel visibility
|
||||||
|
|
||||||
|
- Fixed the blank end-of-mission panel so victory, failure and mission statistics are visible before restart.
|
||||||
|
|
||||||
|
## 2026-10-30 — Community mission statistics
|
||||||
|
|
||||||
|
- Mission statistics now connect automatically on community servers without manual registration.
|
||||||
|
- Server administrators can disable reporting under Mission → Statistics.
|
||||||
|
- Victory and failure screens show the current map's wins, failures and win rate on this server and across all reporting servers.
|
||||||
|
|
||||||
|
## 2026-10-30 — Mission results
|
||||||
|
|
||||||
|
- Added an after-mission summary with duration, kills, friendly kills, deaths, times downed and recoveries for each participant.
|
||||||
|
- Results show who escaped and retain the records of players who disconnected.
|
||||||
|
|
||||||
|
## 2026-10-28 — Extraction landing zones
|
||||||
|
|
||||||
|
- Extraction can use suitable clear ground anywhere on the terrain, including original Everon, without prioritizing airports.
|
||||||
|
- Landing zones retain terrain, obstacle, aircraft-space and escape-boundary checks.
|
||||||
|
|
||||||
|
## 2026-10-28 — Starting supplies and mission statistics
|
||||||
|
|
||||||
|
- Oversized starting weapons and other items remain available beside the backpack instead of delaying preparation and being removed.
|
||||||
|
- Choose whether each starting item spawns inside the backpack or on the ground beside it, with separate quantities for each destination.
|
||||||
|
|
||||||
|
- Added optional mission statistics reporting for starts, restarts, terrain, mods, player participation and mission results.
|
||||||
|
- Statistics are enabled by default and can be disabled under Mission → Statistics; player escape records distinguish actual escapees from spectators.
|
||||||
|
|
||||||
|
## 2026-10-25 — Startup error screen
|
||||||
|
|
||||||
|
- Failed mission starts now show an interactive error screen with a Return to main menu button.
|
||||||
|
- Esc opens the normal pause menu from the error screen, so leaving no longer requires closing Arma.
|
||||||
|
|
||||||
|
## 2026-10-25 — Small-terrain startup
|
||||||
|
|
||||||
|
- Fixed low-lying dry terrain being rejected during site placement, player spawning and mortar setup; water checks now use the actual ground surface.
|
||||||
|
- Helicopter landing sites can use clear ground near roads and use the landing-pad flatness limit instead of the stricter camp limit.
|
||||||
|
- Fixed aircraft clearance checks using the wrong ground height during extraction placement.
|
||||||
|
|
||||||
|
## 2026-10-24 — Placement on smaller terrains
|
||||||
|
|
||||||
|
- Improved mission placement on small maps with shorter airport separation for prisons and support for terrain bounds down to 1 km.
|
||||||
|
- Extraction searches can find a clear landing zone elsewhere when an airport has no suitable space.
|
||||||
|
- Difficult terrain searches try more positions for longer before giving up.
|
||||||
|
- Startup failures show their cause directly on the loading screen, including placement rejection reasons.
|
||||||
|
|
||||||
|
## 2026-10-21 — Radio intel progression
|
||||||
|
|
||||||
|
- Radio intel unlocks after five distinct non-radio sites are fully identified; finding and using radios in person remains unrestricted.
|
||||||
|
- Configure the requirement under Intel → Radio intel, with live progress and a zero option to disable it for the next round.
|
||||||
|
- Early ordinary folders reveal other sites; fixed radio documents stay available and are read automatically after unlocking.
|
||||||
|
|
||||||
|
## 2026-10-21 — Recon drones, body burial and spectator camera
|
||||||
|
|
||||||
|
- Players holding a shovel can bury dead bodies and their remaining equipment.
|
||||||
|
- Added optional enemy reconnaissance drones using Realistic Combat Drones, responding to recent HQ sightings.
|
||||||
|
- Configure the active drone limit and launch cooldown under HQ → Recon drones; disabled by default.
|
||||||
|
- Buffered the full first-person spectator camera position to reduce shaking from remote character movement corrections.
|
||||||
|
|
||||||
|
## 2026-10-20 — Optional site map hints
|
||||||
|
|
||||||
|
- Added an Intel menu option to show sites as question marks until intel identifies their types.
|
||||||
|
|
||||||
|
## 2026-10-20 — Safe intel cleanup
|
||||||
|
|
||||||
|
- Removing used intel folders preserves enemies' ability to discover stolen documents.
|
||||||
|
- Used ordinary folders are cleaned up even when no new locations remain to reveal.
|
||||||
|
- Failed inventory cleanup retries safely without granting extra intel or deleting objective documents.
|
||||||
|
|
||||||
|
## 2026-10-20 — Hunter recovery and intel cleanup
|
||||||
|
|
||||||
|
- Hunters with a blocked driver seat or failed reboarding can abandon the vehicle and continue on foot.
|
||||||
|
- Hunters remember failed approach positions and pause before attempting another coordinated manoeuvre.
|
||||||
|
- Ordinary intel folders are removed after revealing a location; objective documents are retained.
|
||||||
|
|
||||||
|
## 2026-10-17 — Fewer Šárka hunters
|
||||||
|
|
||||||
|
- Set how many anger points are needed per Šárka in the mission menu. Higher values mean fewer cars.
|
||||||
|
- Default: one car per three anger points, rounded down. Zero disables new waves.
|
||||||
|
|
||||||
|
## 2026-10-17 — Mission status readability
|
||||||
|
|
||||||
|
- Fixed clipped status and journal text so long reports can be scrolled.
|
||||||
|
- Fixed duplicated Šárka wave details and restored the hunting-patrol summary.
|
||||||
|
|
||||||
|
## 2026-10-17 — Mission menu navigation
|
||||||
|
|
||||||
|
- Reorganized the mission menu with main tabs across the top and related submenus on the left.
|
||||||
|
|
||||||
|
## 2026-10-17 — Configurable Šárka hunters
|
||||||
|
|
||||||
|
- Added a mission-menu setting for the number of Šárka special-forces cars per anger point.
|
||||||
|
- Set cars per anger point to zero to disable new waves. Deployed teams remain.
|
||||||
|
|
||||||
|
## 2026-10-17 — Discord changelog test
|
||||||
|
|
||||||
|
- Test notification for automatic mission changelogs.
|
||||||
|
|
||||||
|
## 2026-10-17 — Changelog notifications
|
||||||
|
|
||||||
|
- Added automatic Discord changelogs for new mission updates.
|
||||||
@@ -6,7 +6,7 @@ An independently authored replacement for the abandoned Escapists base mission,
|
|||||||
|
|
||||||
The current base supplies prison spawning, two independent scavenging/clue routes, finite medical and outpost stock, an optional ground vehicle, physical radio documents, named discovery markers, native objectives, a separate radio-defence service, capacity-checked helicopter extraction, identity-based partial results, early helicopter-loss defeat, saved mission time/speed, defeat/restart, identity-based lives and local spectator following. Authored site definitions and an injected vanilla faction/asset catalog own the initial physical population. Core provides administration and startup diagnostics; the AI, Intel, Chat and Map modules extend its interfaces inside one addon. HQ coordinates enemy responses through physical radios and available forces.
|
The current base supplies prison spawning, two independent scavenging/clue routes, finite medical and outpost stock, an optional ground vehicle, physical radio documents, named discovery markers, native objectives, a separate radio-defence service, capacity-checked helicopter extraction, identity-based partial results, early helicopter-loss defeat, saved mission time/speed, defeat/restart, identity-based lives and local spectator following. Authored site definitions and an injected vanilla faction/asset catalog own the initial physical population. Core provides administration and startup diagnostics; the AI, Intel, Chat and Map modules extend its interfaces inside one addon. HQ coordinates enemy responses through physical radios and available forces.
|
||||||
|
|
||||||
The current working tree passes **326 registered regression programs** after the [5 October validation repairs](docs/evidence/review-audit-2026-10-05/review.json). These offline checks do not establish native gameplay or multiplayer correctness.
|
The complete repository validator passes at the [5 November integration checkpoint](docs/evidence/integration-check-2026-11-05/report.json), bound to 1,229 unchanged input files. These offline checks do not establish native gameplay or multiplayer correctness.
|
||||||
|
|
||||||
The [4 October development playtest handoff](.build/playtest-2026-10-04-ui-bmp/README.md) includes the inventory callback and BMP ammunition-accounting corrections. Its 439 authored files match 378 PAK payloads and three runtime files. At that archived checkpoint, code/tests/tools bound to 309 passing regression programs; exact-source normal escape and ordinary packaged startup complete with retained engine errors. It remains an **unqualified development candidate**. Existing missions and prior packages are preserved. See [current status](docs/current-status.md) for exact scope and limits.
|
The [4 October development playtest handoff](.build/playtest-2026-10-04-ui-bmp/README.md) includes the inventory callback and BMP ammunition-accounting corrections. Its 439 authored files match 378 PAK payloads and three runtime files. At that archived checkpoint, code/tests/tools bound to 309 passing regression programs; exact-source normal escape and ordinary packaged startup complete with retained engine errors. It remains an **unqualified development candidate**. Existing missions and prior packages are preserved. See [current status](docs/current-status.md) for exact scope and limits.
|
||||||
|
|
||||||
@@ -39,11 +39,27 @@ Scripts are organized under `addons/core/Scripts/Game/ERR/`:
|
|||||||
The prefixes preserve Enforce script extension order. All modules load together.
|
The prefixes preserve Enforce script extension order. All modules load together.
|
||||||
Resources retain their existing paths and GUIDs within the combined project.
|
Resources retain their existing paths and GUIDs within the combined project.
|
||||||
|
|
||||||
|
Menu appearance and navigation are maintained in [ui/admin_menu](ui/admin_menu/README.md):
|
||||||
|
one theme, a navigation manifest, and separate page layouts. Run
|
||||||
|
`python3 tools/build_admin_menu.py` after changing those sources; the generated
|
||||||
|
native layouts remain in the addon for Workbench and publishing.
|
||||||
|
|
||||||
Register only this project and its external dependencies in Workbench. Remove stale
|
Register only this project and its external dependencies in Workbench. Remove stale
|
||||||
AI/Intel/Map/Chat project entries if you previously added them. RHS: Status Quo,
|
AI/Intel/Map/Chat project entries if you previously added them. RHS: Status Quo,
|
||||||
WCS Armaments and WCS BMP-1 (including their dependencies) remain separate,
|
WCS Armaments and WCS BMP-1 (including their dependencies) remain separate,
|
||||||
author-supplied mods; see [external dependencies](docs/external-addons.md).
|
author-supplied mods; see [external dependencies](docs/external-addons.md).
|
||||||
Their assets are referenced, never redistributed.
|
Their assets are referenced. Use updated RHS Status Quo directly. The old RHS 1.9
|
||||||
|
script overrides and standalone compatibility addon are retired; do not generate
|
||||||
|
or load them. See [RHS compatibility retirement](compatibility/rhs-1.9/README.md).
|
||||||
|
|
||||||
|
With a shovel equipped, look at a dead body and hold **Bury body** for eight
|
||||||
|
seconds. This removes the corpse and its remaining equipment; loot it first.
|
||||||
|
Living and unconscious characters cannot be buried. Existing HQ casualty reports
|
||||||
|
remain valid after burial.
|
||||||
|
|
||||||
|
Optional [enemy reconnaissance drones](docs/drone-reconnaissance.md) use Realistic
|
||||||
|
Combat Drones. Configure their limit and cooldown in **HQ → Recon drones**;
|
||||||
|
they are disabled by default.
|
||||||
|
|
||||||
See the [single-mod migration and current commands](docs/single-mod.md).
|
See the [single-mod migration and current commands](docs/single-mod.md).
|
||||||
Earlier five-addon build reports below are historical evidence, not validation of
|
Earlier five-addon build reports below are historical evidence, not validation of
|
||||||
@@ -76,4 +92,6 @@ The [development source bundle tool](docs/development-source-bundle.md) previews
|
|||||||
|
|
||||||
Random field hospitals and camps, their permanent/mobile guard split, finite supplies and authoring options are documented in [Field sites](docs/field-sites.md).
|
Random field hospitals and camps, their permanent/mobile guard split, finite supplies and authoring options are documented in [Field sites](docs/field-sites.md).
|
||||||
|
|
||||||
|
Configurable smoking wrecks and finite weapon crates are documented in [Crash-site salvage](docs/crash-sites.md).
|
||||||
|
|
||||||
Town population, configurable factory guards and safe tower/roof posts: [town and object garrisons](docs/town-garrisons.md).
|
Town population, configurable factory guards and safe tower/roof posts: [town and object garrisons](docs/town-garrisons.md).
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
MenuManager {
|
MenuManager {
|
||||||
MenuPresets {
|
MenuPresets {
|
||||||
|
MenuPreset ERR_PreparationFailure {
|
||||||
|
Layout "{28DD8E27B1CF40C5}UI/layouts/ERR/PreparationFailure.layout"
|
||||||
|
ActionContext "MenuContext"
|
||||||
|
Class "ERR_PreparationFailureMenu"
|
||||||
|
}
|
||||||
MenuPreset ERR_AdminPanel {
|
MenuPreset ERR_AdminPanel {
|
||||||
Layout "{AE761C0439D25FB8}UI/layouts/ERR/AdminMenu.layout"
|
Layout "{AE761C0439D25FB8}UI/layouts/ERR/AdminMenu.layout"
|
||||||
ActionContext "MenuContext"
|
ActionContext "MenuContext"
|
||||||
|
|||||||
@@ -70,12 +70,13 @@ ERR_ScenarioDefinition {
|
|||||||
}
|
}
|
||||||
ERR_SiteDefinition {
|
ERR_SiteDefinition {
|
||||||
Id "everon-extraction-1"
|
Id "everon-extraction-1"
|
||||||
Label "Initial helicopter pickup site"
|
Label "Extraction landing zone"
|
||||||
Kind 2
|
Kind 2
|
||||||
Prefab "{033503110AC34EAC}Prefabs/ERR/Extraction.et"
|
Prefab "{033503110AC34EAC}Prefabs/ERR/Extraction.et"
|
||||||
Position 4800.953 0 11487.412
|
Position 4800.953 0 11487.412
|
||||||
AircraftOffset 0 0 0
|
AircraftOffset 0 0 0
|
||||||
RequireAirfield 1
|
RequireAirfield 0
|
||||||
|
RandomClear 1
|
||||||
Guarded 1
|
Guarded 1
|
||||||
GuardOffset 30 0 0
|
GuardOffset 30 0 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ SCR_GameOverScreenConfig : "{651583FFFB7FC765}Configs/GameOverScreen/BaseGameOve
|
|||||||
m_aGameOverScreens {
|
m_aGameOverScreens {
|
||||||
ERR_EscapeGameOverScreenInfo "{6B193DC8DDC63507}" {
|
ERR_EscapeGameOverScreenInfo "{6B193DC8DDC63507}" {
|
||||||
m_GameOverScreenId VICTORY
|
m_GameOverScreenId VICTORY
|
||||||
m_GameOverContentLayout "{C4507D07F3C54831}UI/layouts/HUD/GameOver/EndScreen/EndScreenContent_NoImage.layout"
|
m_GameOverContentLayout "{C63B4D1E09A572F8}UI/layouts/ERR/RoundResults.layout"
|
||||||
m_OptionalParams SCR_BaseGameOverScreenInfoOptional "{4984A5C1BFEFC04E}" {
|
m_OptionalParams SCR_BaseGameOverScreenInfoOptional "{4984A5C1BFEFC04E}" {
|
||||||
m_sTitle "Escape complete"
|
m_sTitle "Escape complete"
|
||||||
m_sAudioOneShot "SOUND_ONVICTORY"
|
m_sAudioOneShot "SOUND_ONVICTORY"
|
||||||
@@ -10,7 +10,7 @@ SCR_GameOverScreenConfig : "{651583FFFB7FC765}Configs/GameOverScreen/BaseGameOve
|
|||||||
}
|
}
|
||||||
ERR_FailureGameOverScreenInfo "{E66F29A7A8AD7438}" {
|
ERR_FailureGameOverScreenInfo "{E66F29A7A8AD7438}" {
|
||||||
m_GameOverScreenId LOOSE
|
m_GameOverScreenId LOOSE
|
||||||
m_GameOverContentLayout "{C4507D07F3C54831}UI/layouts/HUD/GameOver/EndScreen/EndScreenContent_NoImage.layout"
|
m_GameOverContentLayout "{C63B4D1E09A572F8}UI/layouts/ERR/RoundResults.layout"
|
||||||
m_OptionalParams SCR_BaseGameOverScreenInfoOptional "{3DBF0BDE715945FA}" {
|
m_OptionalParams SCR_BaseGameOverScreenInfoOptional "{3DBF0BDE715945FA}" {
|
||||||
m_sTitle "Escape failed"
|
m_sTitle "Escape failed"
|
||||||
m_sDebriefing "No surviving prisoners can complete the escape, or the extraction helicopter has been lost."
|
m_sDebriefing "No surviving prisoners can complete the escape, or the extraction helicopter has been lost."
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
ActionManager : "{795184CF9AD764DB}Configs/System/chimeraInputCommon.conf" {
|
ActionManager : "{795184CF9AD764DB}Configs/System/chimeraInputCommon.conf" {
|
||||||
Contexts {
|
Contexts {
|
||||||
|
ActionContext ERR_PassengerBrakeContext {
|
||||||
|
Priority 60
|
||||||
|
Flags 0xa 0
|
||||||
|
Actions {
|
||||||
|
Action ERR_PassengerBrake {
|
||||||
|
InputSource InputSourceValue "{A7B19F416E541030}" {
|
||||||
|
Input "keyboard:KC_SPACE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ActionContext ERR_FieldMapContext {
|
ActionContext ERR_FieldMapContext {
|
||||||
Priority 60
|
Priority 60
|
||||||
Flags 0xa 0
|
Flags 0xa 0
|
||||||
@@ -90,6 +101,11 @@ ActionManager : "{795184CF9AD764DB}Configs/System/chimeraInputCommon.conf" {
|
|||||||
}
|
}
|
||||||
ActionContext ERR_ObserverContext : "{C538807EEE48BED8}Configs/System/ActionContext/ManualCameraContext.conf" {
|
ActionContext ERR_ObserverContext : "{C538807EEE48BED8}Configs/System/ActionContext/ManualCameraContext.conf" {
|
||||||
Actions {
|
Actions {
|
||||||
|
Action ERR_SelfEpinephrine {
|
||||||
|
InputSource InputSourceValue "{A7B19F416E541020}" {
|
||||||
|
Input "keyboard:KC_SPACE"
|
||||||
|
}
|
||||||
|
}
|
||||||
Action ERR_ObserverPrevious {
|
Action ERR_ObserverPrevious {
|
||||||
InputSource InputSourceValue "{A7B19F416E541001}" {
|
InputSource InputSourceValue "{A7B19F416E541001}" {
|
||||||
Input "keyboard:KC_LEFT"
|
Input "keyboard:KC_LEFT"
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ERR_TelemetryConfig {
|
||||||
|
Endpoint "https://co10escape-telemetry.zacekjakub.workers.dev/api/mission-events"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{E72B130684FA492C}Configs/ERR/Telemetry.conf"
|
||||||
|
Configurations {
|
||||||
|
CONFResourceClass PC { }
|
||||||
|
CONFResourceClass HEADLESS : PC { }
|
||||||
|
CONFResourceClass XBOX_ONE : PC { }
|
||||||
|
CONFResourceClass XBOX_SERIES : PC { }
|
||||||
|
CONFResourceClass PS4 : PC { }
|
||||||
|
CONFResourceClass PS5 : PC { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
SCR_ChimeraCharacter {
|
||||||
|
ID "520EC961A090B1EE"
|
||||||
|
components {
|
||||||
|
ActionsManagerComponent "{520EA1D2F659CE02}" {
|
||||||
|
additionalActions {
|
||||||
|
ERR_BuryBodyAction "{A62CB789905D4011}" {
|
||||||
|
ParentContextList { "Chest" "LowerTorso" }
|
||||||
|
UIInfo SCR_ActionUIInfo "{A62CB789905D4012}" {
|
||||||
|
Name "Bury body"
|
||||||
|
Description "Bury the body and its remaining equipment. Loot anything you want to keep first."
|
||||||
|
}
|
||||||
|
Duration 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{37578B1666981FCE}Prefabs/Characters/Core/Character_Base.et"
|
||||||
|
Configurations {
|
||||||
|
EntityTemplateResourceClass PC {}
|
||||||
|
EntityTemplateResourceClass HEADLESS : PC {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
GenericEntity : "{B90E5414AB7C325B}Prefabs/Props/Wrecks/BTR70_Wreck/BTR70_wreck_static.et" {
|
||||||
|
ID "9EA3A65E039FDAC0"
|
||||||
|
components {
|
||||||
|
Hierarchy "{BD920DE465D04435}" {}
|
||||||
|
RplComponent "{7E4852E4567E49D6}" { Streamable Disabled }
|
||||||
|
}
|
||||||
|
coords 0 0 0
|
||||||
|
angles 0 0 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{56C7BD958478A96D}Prefabs/ERR/CrashArmorWreck.et"
|
||||||
|
Configurations {
|
||||||
|
ResourceClass PC {}
|
||||||
|
ResourceClass HEADLESS : PC {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
GenericEntity : "{EBBC859CCD94D96D}Prefabs/Props/EmptyStorages/USSR_AmmoBox_empty.et" {
|
||||||
|
ID "A2DD3ADFFC0219D9"
|
||||||
|
components {
|
||||||
|
RplComponent "{6530845A09302A0A}" { Streamable Disabled }
|
||||||
|
MeshObject "{6530845A09309E37}" {
|
||||||
|
Object "{819ED3266EE5113B}Assets/Props/Military/AmmoBox/EquipmentBoxWooden_01/EquipmentBoxWooden_Weapon_01.xob"
|
||||||
|
Materials {
|
||||||
|
MaterialAssignClass "{6530845A093091BB}" {
|
||||||
|
SourceMaterial "EquipmentBoxWooden_Weapon_01"
|
||||||
|
AssignedMaterial "{7D2E831AFA5CF50D}Assets/Props/Military/AmmoBox/EquipmentBoxWooden_01/Data/EquipmentBoxWooden_Weapon_01_USSR.emat"
|
||||||
|
}
|
||||||
|
MaterialAssignClass "{6530845A093091B2}" {
|
||||||
|
SourceMaterial "EquipmentBoxWooden_Weapon_01_Decal"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SCR_UniversalInventoryStorageComponent "{6530845A09302DE0}" {
|
||||||
|
MaxCumulativeVolume 1000000
|
||||||
|
MaxItemSize 200 100 100
|
||||||
|
m_fMaxWeight 400
|
||||||
|
Attributes SCR_ItemAttributeCollection "{6530845A09302DFF}" {
|
||||||
|
ItemDisplayName SCR_InventoryUIInfo "{6530845A09302D03}" {
|
||||||
|
Name "Crash-site weapons"
|
||||||
|
Description "Salvaged weapons and ammunition. This crate does not refill."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InventoryStorageManagerComponent "{18A1D42A468F584F}" {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{CD7E33406E1ACA1D}Prefabs/ERR/CrashLootCrate.et"
|
||||||
|
Configurations {
|
||||||
|
ResourceClass PC {}
|
||||||
|
ResourceClass HEADLESS : PC {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
ReplicatedParticleEffectEntity {
|
||||||
|
ID "3B6ACA9A82472A27"
|
||||||
|
components {
|
||||||
|
Hierarchy "{666ECA1B7BACEF74}" {}
|
||||||
|
RplComponent "{7E4852E4567E49D6}" { Streamable Disabled }
|
||||||
|
}
|
||||||
|
UseFrameEvent 1
|
||||||
|
EffectPath "{6EE3295AC363E562}Particles/Enviroment/Smoke_Smokestack_Big.ptc"
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{2608501780FEE1EA}Prefabs/ERR/CrashLootSmoke.et"
|
||||||
|
Configurations {
|
||||||
|
ResourceClass PC {}
|
||||||
|
ResourceClass HEADLESS : PC {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,6 @@ ERR_GameMode : "{0F307326459A1395}Prefabs/MP/Modes/GameMode_Base.et" {
|
|||||||
m_SpawnLogic ERR_SpawnLogic "{79AD722B2EFD595F}" {}
|
m_SpawnLogic ERR_SpawnLogic "{79AD722B2EFD595F}" {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_fAutoReloadTime 10
|
m_fAutoReloadTime 120
|
||||||
m_bUseSpawnPreload 1
|
m_bUseSpawnPreload 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,5 @@ ERR_TerrainTakeoverMode : "{978E045E53EF36C8}Prefabs/ERR/GameMode.et" {
|
|||||||
SCR_LoadoutManager Loadouts : "{97EF4C1A41F63DDB}Prefabs/MP/Managers/Loadouts/LoadoutManager_USxUSSR.et" {
|
SCR_LoadoutManager Loadouts : "{97EF4C1A41F63DDB}Prefabs/MP/Managers/Loadouts/LoadoutManager_USxUSSR.et" {
|
||||||
ID "588AD55F7655278B"
|
ID "588AD55F7655278B"
|
||||||
}
|
}
|
||||||
ScriptedChatEntity Chat : "{F69BC912AC8236F9}Prefabs/MP/ScriptedChatEntity.et" {
|
|
||||||
ID "85ED17B0836DB4A2"
|
|
||||||
components { RplComponent "{CA456708D69D73BA}" { Streamable Disabled } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
ERR_TerrainTakeoverMode : "{9D182739ABEF405C}Prefabs/ERR/TerrainTakeover.et" {
|
||||||
|
ID "CE902374A658BDF1"
|
||||||
|
{
|
||||||
|
ScriptedChatEntity Chat : "{F69BC912AC8236F9}Prefabs/MP/ScriptedChatEntity.et" {
|
||||||
|
ID "85ED17B0836DB4A2"
|
||||||
|
components { RplComponent "{CA456708D69D73BA}" { Streamable Disabled } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
MetaFileClass {
|
||||||
|
Name "{DA8E364BC095712F}Prefabs/ERR/TerrainTakeoverWithChat.et"
|
||||||
|
Configurations { ResourceClass PC {} ResourceClass HEADLESS : PC {} }
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
GenericEntity {
|
GenericEntity {
|
||||||
|
ID "E83CA269A0D647B1"
|
||||||
components {
|
components {
|
||||||
MeshObject { Object "{76D738EEB0CA431F}Assets/Items/ERR_Atlas/ERR_AtlasLeaf.xob" InheritVisibility 1 }
|
MeshObject { Object "{76D738EEB0CA431F}Assets/Items/ERR_Atlas/ERR_AtlasLeaf.xob" InheritVisibility 1 }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ class ERR_Actors
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map altitude is not water depth. Query the terrain surface itself, without
|
||||||
|
// Ground's 10cm spawn lift, so even shallow water remains unsuitable.
|
||||||
|
static bool DryGround(vector position)
|
||||||
|
{
|
||||||
|
position[1] = GetGame().GetWorld().GetSurfaceY(position[0], position[2]);
|
||||||
|
if (!ERR_ForceRules.Finite(position[1])) return false;
|
||||||
|
return !ChimeraWorldUtils.TryGetWaterSurfaceSimple(GetGame().GetWorld(), position);
|
||||||
|
}
|
||||||
|
|
||||||
static void Players(out array<IEntity> players, bool conscious = false)
|
static void Players(out array<IEntity> players, bool conscious = false)
|
||||||
{
|
{
|
||||||
players.Clear();
|
players.Clear();
|
||||||
|
|||||||
@@ -3,90 +3,6 @@ modded enum ChimeraMenuPreset
|
|||||||
ERR_AdminPanel
|
ERR_AdminPanel
|
||||||
}
|
}
|
||||||
|
|
||||||
// Presentation rules only: all mutations still use the authenticated command service.
|
|
||||||
class ERR_AdminMenuFields
|
|
||||||
{
|
|
||||||
static array<string> Keys()
|
|
||||||
{
|
|
||||||
return {"aiDoctrine", "aiShadow", "automaticEquipmentChancePercent", "motorbikeCount", "planeAltitudeMetres", "planeReplacementSeconds", "planeSectorSeconds", "fieldCampCount", "fieldHospitalCount", "startWeaponCount", "startMagazineCount", "objectGuardCount", "objectGuardEvery", "objectGuardHQMode", "hunterSpawnDistanceMetres", "roadblockCount", "civilianTrafficCount", "startMode", "radioDefenceSeconds", "aiIntelChancePercent", "intelRevealChancePercent", "startTimeMinutes", "timeMultiplier", "startDateCode", "weatherProfile", "viewDistanceMetres", "reportIntervalSeconds", "supportSquadLimit", "responseRadiusMetres", "convoyCount", "antiAirChancePercent", "antiPersonnelMineChancePercent", "heliTimerMinutes"};
|
|
||||||
}
|
|
||||||
static bool Available(string key, bool hq, bool intel)
|
|
||||||
{
|
|
||||||
if (key == "aiDoctrine" || key == "aiShadow") return hq;
|
|
||||||
if (key == "aiIntelChancePercent") return intel;
|
|
||||||
if (key == "automaticEquipmentChancePercent" || key == "motorbikeCount" || key == "planeAltitudeMetres" || key == "planeReplacementSeconds" || key == "planeSectorSeconds" || key == "planeReconEnabled" || key == "objectGuardCount" || key == "objectGuardEvery" || key == "objectGuardHQMode" || key == "hunterSpawnDistanceMetres" || key == "heliTimerMinutes" || key == "antiAirChancePercent" || key == "antiPersonnelMineChancePercent" || key == "convoyCount" || key == "reportIntervalSeconds" || key == "supportSquadLimit" || key == "responseRadiusMetres") return hq;
|
|
||||||
return Keys().Contains(key);
|
|
||||||
}
|
|
||||||
// A short journal has no older off-screen lines, even if its slider is zero.
|
|
||||||
static bool FollowJournal(bool empty, float slider, float height, float viewHeight, bool latest)
|
|
||||||
{
|
|
||||||
return latest || empty || slider >= 0.98 || height <= viewHeight;
|
|
||||||
}
|
|
||||||
// TextWidget interprets hash-prefixed tokens as localization IDs. Keep the
|
|
||||||
// server audit and retained entries intact; render their numeric IDs literally.
|
|
||||||
static string JournalText(string line, bool details = false)
|
|
||||||
{
|
|
||||||
return ERR_JournalText.Menu(line, details);
|
|
||||||
}
|
|
||||||
static string Display(string key, string value)
|
|
||||||
{
|
|
||||||
if (key == "aiDoctrine") { if (value == "1") return "Coordinated"; return "Current"; }
|
|
||||||
if (key == "aiShadow") { if (value == "1") return "On"; return "Off"; }
|
|
||||||
if (value == "-1" || value == "-2") return ERR_Settings.SelectionText(value.ToInt());
|
|
||||||
if (key == "startMode") { if (value == "1") return "Crash"; return "Prison"; }
|
|
||||||
if (key == "startTimeMinutes") return ERR_TimeService.Clock(value.ToInt());
|
|
||||||
if (key == "startDateCode") return ERR_EnvironmentService.Date(value.ToInt());
|
|
||||||
if (key == "weatherProfile") return ERR_EnvironmentService.ProfileName(value.ToInt());
|
|
||||||
if (key == "viewDistanceMetres" && value == "0") return "default";
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
static string StartSummary(int saved, int current)
|
|
||||||
{
|
|
||||||
return "Next start: " + Display("startMode", saved.ToString()) + " | Current round: " + Display("startMode", current.ToString());
|
|
||||||
}
|
|
||||||
static string Command(string key, string value)
|
|
||||||
{
|
|
||||||
string prefix;
|
|
||||||
if (key == "aiDoctrine") prefix = "mission doctrine";
|
|
||||||
else if (key == "aiShadow") prefix = "mission aishadow";
|
|
||||||
else if (key == "automaticEquipmentChancePercent") prefix = "hq equipment";
|
|
||||||
else if (key == "motorbikeCount") prefix = "mission motorbikes";
|
|
||||||
else if (key == "planeReconEnabled") prefix = "mission plane";
|
|
||||||
else if (key == "planeAltitudeMetres") prefix = "mission planealtitude";
|
|
||||||
else if (key == "planeReplacementSeconds") prefix = "mission planereplacement";
|
|
||||||
else if (key == "planeSectorSeconds") prefix = "mission planesector";
|
|
||||||
else if (key == "startWeaponCount") prefix = "mission startweapons";
|
|
||||||
else if (key == "startMagazineCount") prefix = "mission startammo";
|
|
||||||
else if (key == "objectGuardEvery") prefix = "mission objectevery";
|
|
||||||
else if (key == "objectGuardHQMode") prefix = "mission objecthq";
|
|
||||||
else if (key == "objectGuardCount") prefix = "mission objectguards";
|
|
||||||
else if (key == "hunterSpawnDistanceMetres") prefix = "mission hunterdistance";
|
|
||||||
else if (key == "fieldCampCount") prefix = "mission camps";
|
|
||||||
else if (key == "fieldHospitalCount") prefix = "mission hospitals";
|
|
||||||
else if (key == "roadblockCount") prefix = "mission roadblocks";
|
|
||||||
else if (key == "civilianTrafficCount") prefix = "mission traffic";
|
|
||||||
else if (key == "startMode") prefix = "mission start";
|
|
||||||
else if (key == "radioDefenceSeconds") prefix = "mission radio";
|
|
||||||
else if (key == "aiIntelChancePercent") prefix = "intel carrying";
|
|
||||||
else if (key == "intelRevealChancePercent") prefix = "intel reveal";
|
|
||||||
else if (key == "startTimeMinutes") prefix = "mission time";
|
|
||||||
else if (key == "timeMultiplier") prefix = "mission speed";
|
|
||||||
else if (key == "startDateCode") prefix = "mission date";
|
|
||||||
else if (key == "weatherProfile") prefix = "mission weather";
|
|
||||||
else if (key == "viewDistanceMetres") prefix = "mission viewdistance";
|
|
||||||
else if (key == "reportIntervalSeconds") prefix = "hq interval";
|
|
||||||
else if (key == "supportSquadLimit") prefix = "hq squads";
|
|
||||||
else if (key == "responseRadiusMetres") prefix = "hq radius";
|
|
||||||
else if (key == "antiAirChancePercent") prefix = "hq aa";
|
|
||||||
else if (key == "antiPersonnelMineChancePercent") prefix = "hq mines";
|
|
||||||
else if (key == "heliTimerMinutes") prefix = "hq heli timer";
|
|
||||||
else if (key == "convoyCount") prefix = "hq convoy count";
|
|
||||||
value = value.Trim();
|
|
||||||
if (prefix.IsEmpty() || value.IsEmpty() || value.Length() > 32) return "";
|
|
||||||
return prefix + " set " + value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Own mission dialog. ChimeraMenuBase owns focus, cursor and input-context lifetime.
|
// Own mission dialog. ChimeraMenuBase owns focus, cursor and input-context lifetime.
|
||||||
class ERR_AdminMenu : ChimeraMenuBase
|
class ERR_AdminMenu : ChimeraMenuBase
|
||||||
{
|
{
|
||||||
@@ -113,6 +29,7 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
protected bool m_ScrollToEnd;
|
protected bool m_ScrollToEnd;
|
||||||
protected int m_LogCursor = -1;
|
protected int m_LogCursor = -1;
|
||||||
|
|
||||||
|
protected void OpenVehicleAddon(string addon) {}
|
||||||
static ERR_AdminMenu GetOpenMenu()
|
static ERR_AdminMenu GetOpenMenu()
|
||||||
{
|
{
|
||||||
if (!GetGame() || !GetGame().GetMenuManager()) return null;
|
if (!GetGame() || !GetGame().GetMenuManager()) return null;
|
||||||
@@ -130,15 +47,9 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
m_Controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
m_Controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
||||||
m_Mode = ERR_GameMode.Cast(GetGame().GetGameMode());
|
m_Mode = ERR_GameMode.Cast(GetGame().GetGameMode());
|
||||||
if (!m_Controller) { Close(); return; }
|
if (!m_Controller) { Close(); return; }
|
||||||
array<string> names = {"PlaneOn", "PlaneOff", "Close", "OpenSettings", "OpenWorld", "OpenFactions", "OpenHQ", "OpenJournal", "PauseJournal", "JournalDetails", "LatestJournal", "KeepWeaponOn", "KeepWeaponOff", "IntelSummary", "RerollIntel", "OpenMods", "OpenIntel", "OpenStatus", "OpenTerrains", "OpenItems", "OpenTTS"};
|
array<string> names = {"TelemetryOn", "TelemetryOff","SitesOn", "SitesOff", "PlaneOn", "PlaneOff", "Close", "PauseJournal", "JournalDetails", "LatestJournal", "KeepWeaponOn", "KeepWeaponOff", "SelfEpiOn", "SelfEpiOff", "IntelSummary", "RerollIntel", "RandomDay_startTimeMinutes", "Default_viewDistanceMetres", "RestartEmptyOn", "RestartEmptyOff", "RecommendedPlane", "RecommendedWeapons", "RecommendedDrones"};
|
||||||
names.Insert("RandomDay_startTimeMinutes");
|
foreach (string mainButton : ERR_AdminMenuPages.MainButtons()) names.Insert(mainButton);
|
||||||
names.Insert("Default_viewDistanceMetres");
|
foreach (string pageButton : Navigation()) names.Insert(pageButton);
|
||||||
names.Insert("OpenForces");
|
|
||||||
names.Insert("OpenGuards"); names.Insert("GuardsBack");
|
|
||||||
names.Insert("OpenSites"); names.Insert("SitesBack");
|
|
||||||
names.Insert("OpenPlane"); names.Insert("PlaneBack");
|
|
||||||
names.Insert("OpenAI"); names.Insert("AIBack");
|
|
||||||
names.Insert("EquipmentOverview"); names.Insert("OpenAllowedItems"); names.Insert("OpenItemPresets"); names.Insert("OpenWeights"); names.Insert("OpenRecommendations"); names.Insert("RecommendationsBack"); names.Insert("RecommendedPlane"); names.Insert("RecommendedWeapons");
|
|
||||||
for (int density = 1; density <= 4; density++) names.Insert("GuardEvery_" + density.ToString());
|
for (int density = 1; density <= 4; density++) names.Insert("GuardEvery_" + density.ToString());
|
||||||
for (int policy = 0; policy <= 2; policy++) names.Insert("GuardHQ_" + policy.ToString());
|
for (int policy = 0; policy <= 2; policy++) names.Insert("GuardHQ_" + policy.ToString());
|
||||||
foreach (string key : ERR_AdminMenuFields.Keys())
|
foreach (string key : ERR_AdminMenuFields.Keys())
|
||||||
@@ -159,10 +70,11 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
button.m_OnClicked.Insert(OnButton);
|
button.m_OnClicked.Insert(OnButton);
|
||||||
m_Buttons.Insert(button);
|
m_Buttons.Insert(button);
|
||||||
}
|
}
|
||||||
|
ERR_AdminMenuView.FitPanel(GetRootWidget());
|
||||||
m_Ready = false; m_Age = 0; m_Poll = 0;
|
m_Ready = false; m_Age = 0; m_Poll = 0;
|
||||||
GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.PRESSED, OnBack);
|
GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.PRESSED, OnBack);
|
||||||
m_Bound = true;
|
m_Bound = true;
|
||||||
ShowPage(0);
|
ShowPage(ERR_AdminPage.MISSION);
|
||||||
UpdateActions();
|
UpdateActions();
|
||||||
RequestSnapshot();
|
RequestSnapshot();
|
||||||
}
|
}
|
||||||
@@ -179,6 +91,7 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
override void OnMenuUpdate(float tDelta)
|
override void OnMenuUpdate(float tDelta)
|
||||||
{
|
{
|
||||||
super.OnMenuUpdate(tDelta);
|
super.OnMenuUpdate(tDelta);
|
||||||
|
ERR_AdminMenuView.FitPanel(GetRootWidget());
|
||||||
if (!m_Controller || m_Controller != GetGame().GetPlayerController() || !m_Mode || m_Mode != GetGame().GetGameMode() || ERR_MissionRules.Terminal(m_Mode.Phase())) { Close(); return; }
|
if (!m_Controller || m_Controller != GetGame().GetPlayerController() || !m_Mode || m_Mode != GetGame().GetGameMode() || ERR_MissionRules.Terminal(m_Mode.Phase())) { Close(); return; }
|
||||||
m_Age += tDelta; m_Poll += tDelta;
|
m_Age += tDelta; m_Poll += tDelta;
|
||||||
m_ClickDelay = Math.Max(0, m_ClickDelay - tDelta);
|
m_ClickDelay = Math.Max(0, m_ClickDelay - tDelta);
|
||||||
@@ -189,7 +102,7 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
UpdateActions();
|
UpdateActions();
|
||||||
}
|
}
|
||||||
if (IsFocused() && m_Poll >= 2) RequestSnapshot();
|
if (IsFocused() && m_Poll >= 2) RequestSnapshot();
|
||||||
if (m_Page != 2) return;
|
if (m_Page != ERR_AdminPage.JOURNAL) return;
|
||||||
m_LogPoll += tDelta;
|
m_LogPoll += tDelta;
|
||||||
if (m_LogPending && m_LogPoll > 5) m_LogPending = false;
|
if (m_LogPending && m_LogPoll > 5) m_LogPending = false;
|
||||||
if (IsFocused() && m_Ready && m_HQ && !m_LogPaused && !m_LogPending && m_LogPoll >= 1)
|
if (IsFocused() && m_Ready && m_HQ && !m_LogPaused && !m_LogPending && m_LogPoll >= 1)
|
||||||
@@ -220,12 +133,14 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
protected void OnBack()
|
protected void OnBack()
|
||||||
{
|
{
|
||||||
if (!IsFocused()) return;
|
if (!IsFocused()) return;
|
||||||
foreach (string key : ERR_AdminMenuFields.Keys())
|
array<string> editFields = ERR_AdminMenuFields.Keys();
|
||||||
|
editFields.InsertAll({"ModsSearch", "ItemsSearch", "VehiclesSearch", "ItemsPresetName"});
|
||||||
|
foreach (string key : editFields)
|
||||||
{
|
{
|
||||||
SCR_EditBoxComponent edit = SCR_EditBoxComponent.GetEditBoxComponent(key, GetRootWidget());
|
SCR_EditBoxComponent edit = SCR_EditBoxComponent.GetEditBoxComponent(key, GetRootWidget());
|
||||||
if (edit && edit.IsInWriteMode()) return;
|
if (edit && edit.IsInWriteMode()) return;
|
||||||
}
|
}
|
||||||
if (m_Page != 0) ShowPage(0);
|
if (m_Page != ERR_AdminPage.MISSION) ShowPage(ERR_AdminPage.MISSION);
|
||||||
else Close();
|
else Close();
|
||||||
}
|
}
|
||||||
protected void SetText(string name, string value)
|
protected void SetText(string name, string value)
|
||||||
@@ -233,31 +148,27 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
TextWidget widget = TextWidget.Cast(GetRootWidget().FindAnyWidget(name));
|
TextWidget widget = TextWidget.Cast(GetRootWidget().FindAnyWidget(name));
|
||||||
if (widget) widget.SetText(value);
|
if (widget) widget.SetText(value);
|
||||||
}
|
}
|
||||||
// Stable page order is also used by the shared navigation bar and native probe.
|
// Stable IDs are generated from the navigation manifest; extensions use named pages.
|
||||||
static array<string> Pages() { return {"SettingsPage", "HQPage", "JournalPage", "ModsPage", "FactionsPage", "WorldPage", "IntelPage", "StatusPage", "TerrainsPage", "ItemsPage", "TTSPage", "ForcesPage", "GuardsPage", "SitesPage", "PlanePage", "RecommendationsPage", "WeightsPage", "AllowedItemsPage", "ItemPresetsPage", "AIPage"}; }
|
static array<string> Pages() { return ERR_AdminMenuPages.Pages(); }
|
||||||
static array<string> Navigation() { return {"OpenSettings", "OpenHQ", "OpenJournal", "OpenMods", "OpenFactions", "OpenWorld", "OpenIntel", "OpenStatus", "OpenTerrains", "OpenItems", "OpenTTS", "OpenForces", "OpenGuards", "OpenSites", "OpenPlane", "OpenRecommendations", "OpenWeights", "OpenAllowedItems", "OpenItemPresets", "OpenAI"}; }
|
static array<string> Navigation() { return ERR_AdminMenuPages.Navigation(); }
|
||||||
protected void ShowPage(int page)
|
protected void ShowPage(int page)
|
||||||
{
|
{
|
||||||
array<string> pages = Pages();
|
if (!ERR_AdminMenuView.ShowPage(GetRootWidget(), page)) return;
|
||||||
array<string> navigation = Navigation();
|
|
||||||
if (page < 0 || page >= pages.Count()) return;
|
|
||||||
m_Page = page;
|
m_Page = page;
|
||||||
for (int i = 0; i < pages.Count(); i++)
|
if (page == ERR_AdminPage.JOURNAL) m_LogPoll = 1;
|
||||||
{
|
|
||||||
GetRootWidget().FindAnyWidget(pages[i]).SetVisible(i == page);
|
|
||||||
bool selected = i == page || ((page == 12 || page == 13) && i == 11) || ((page == 16 || page == 17 || page == 18) && i == 9) || ((page == 14 || page == 19) && i == 1);
|
|
||||||
GetRootWidget().FindAnyWidget("Selected_" + navigation[i]).SetVisible(selected);
|
|
||||||
ERR_SelectionStyle.Choice(SCR_ButtonTextComponent.GetButtonText(navigation[i], GetRootWidget()), selected);
|
|
||||||
}
|
|
||||||
GetRootWidget().FindAnyWidget("EquipmentNavigation").SetVisible(page == 9 || page == 16 || page == 17 || page == 18);
|
|
||||||
GetRootWidget().FindAnyWidget("Selected_EquipmentOverview").SetVisible(page == 9);
|
|
||||||
ERR_SelectionStyle.Choice(SCR_ButtonTextComponent.GetButtonText("EquipmentOverview", GetRootWidget()), page == 9);
|
|
||||||
if (page == 2) m_LogPoll = 1;
|
|
||||||
}
|
}
|
||||||
protected int m_KeepWeaponState = -1;
|
protected int m_KeepWeaponState = -1;
|
||||||
|
protected int m_SelfEpiState = -1;
|
||||||
|
protected int m_SitesState = -1;
|
||||||
|
protected int m_RestartEmptyState = -1;
|
||||||
|
protected int m_TelemetryState = -1;
|
||||||
protected void UpdateActions()
|
protected void UpdateActions()
|
||||||
{
|
{
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "TelemetryOn", "TelemetryOff", m_TelemetryState);
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "SitesOn", "SitesOff", m_SitesState);
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "SelfEpiOn", "SelfEpiOff", m_SelfEpiState);
|
||||||
ERR_SelectionStyle.Pair(GetRootWidget(), "KeepWeaponOn", "KeepWeaponOff", m_KeepWeaponState);
|
ERR_SelectionStyle.Pair(GetRootWidget(), "KeepWeaponOn", "KeepWeaponOff", m_KeepWeaponState);
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "RestartEmptyOn", "RestartEmptyOff", m_RestartEmptyState);
|
||||||
foreach (SCR_ButtonBaseComponent button : m_Buttons)
|
foreach (SCR_ButtonBaseComponent button : m_Buttons)
|
||||||
{
|
{
|
||||||
string name = button.GetRootWidget().GetName();
|
string name = button.GetRootWidget().GetName();
|
||||||
@@ -272,6 +183,14 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
else if (name.IndexOf("GuardHQ_") == 0) button.SetEnabled(m_Ready && m_HQ && m_AvailableFields.Contains("objectGuardHQMode"));
|
else if (name.IndexOf("GuardHQ_") == 0) button.SetEnabled(m_Ready && m_HQ && m_AvailableFields.Contains("objectGuardHQMode"));
|
||||||
else if (name == "RerollIntel" || name == "IntelSummary") button.SetEnabled(m_Ready && m_Intel);
|
else if (name == "RerollIntel" || name == "IntelSummary") button.SetEnabled(m_Ready && m_Intel);
|
||||||
else if (name == "LatestJournal") button.SetEnabled(m_Ready && m_HQ);
|
else if (name == "LatestJournal") button.SetEnabled(m_Ready && m_HQ);
|
||||||
|
else if (name == "TelemetryOn") button.SetEnabled(m_Ready && m_TelemetryState == 0);
|
||||||
|
else if (name == "TelemetryOff") button.SetEnabled(m_Ready && m_TelemetryState == 1);
|
||||||
|
else if (name == "RestartEmptyOn") button.SetEnabled(m_Ready && m_RestartEmptyState == 0);
|
||||||
|
else if (name == "RestartEmptyOff") button.SetEnabled(m_Ready && m_RestartEmptyState == 1);
|
||||||
|
else if (name == "SitesOn") button.SetEnabled(m_Ready && m_SitesState == 0);
|
||||||
|
else if (name == "SitesOff") button.SetEnabled(m_Ready && m_SitesState == 1);
|
||||||
|
else if (name == "SelfEpiOn") button.SetEnabled(m_Ready && m_SelfEpiState == 0);
|
||||||
|
else if (name == "SelfEpiOff") button.SetEnabled(m_Ready && m_SelfEpiState == 1);
|
||||||
else if (name == "KeepWeaponOn") button.SetEnabled(m_Ready && m_KeepWeaponState == 0);
|
else if (name == "KeepWeaponOn") button.SetEnabled(m_Ready && m_KeepWeaponState == 0);
|
||||||
else if (name == "KeepWeaponOff") button.SetEnabled(m_Ready && m_KeepWeaponState == 1);
|
else if (name == "KeepWeaponOff") button.SetEnabled(m_Ready && m_KeepWeaponState == 1);
|
||||||
}
|
}
|
||||||
@@ -280,7 +199,7 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
{
|
{
|
||||||
if (!authorized) { Close(); return; }
|
if (!authorized) { Close(); return; }
|
||||||
if (!values) return;
|
if (!values) return;
|
||||||
m_HQ = false; m_Intel = false; m_AvailableFields.Clear(); m_KeepWeaponState = -1;
|
m_HQ = false; m_Intel = false; m_AvailableFields.Clear(); m_KeepWeaponState = -1; m_SelfEpiState = -1; m_RestartEmptyState = -1; m_TelemetryState = -1;
|
||||||
foreach (string entry : values)
|
foreach (string entry : values)
|
||||||
{
|
{
|
||||||
if (entry == "supports=hq") { m_HQ = true; continue; }
|
if (entry == "supports=hq") { m_HQ = true; continue; }
|
||||||
@@ -288,6 +207,8 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
int divider = entry.IndexOf("=");
|
int divider = entry.IndexOf("=");
|
||||||
if (divider <= 0) continue;
|
if (divider <= 0) continue;
|
||||||
string key = entry.Substring(0, divider);
|
string key = entry.Substring(0, divider);
|
||||||
|
if (key == "radioIntelProgress") { SetText("RadioIntelProgress", entry.Substring(divider + 1, entry.Length() - divider - 1)); continue; }
|
||||||
|
if (key == "droneRuntime") { SetText("DroneRuntime", entry.Substring(divider + 1, entry.Length() - divider - 1)); continue; }
|
||||||
if (key == "recommendedBikeRuntime") { SetText("RecommendedBikeRuntime", entry.Substring(divider + 1, entry.Length() - divider - 1)); continue; }
|
if (key == "recommendedBikeRuntime") { SetText("RecommendedBikeRuntime", entry.Substring(divider + 1, entry.Length() - divider - 1)); continue; }
|
||||||
if (key.IndexOf("recommended_") == 0)
|
if (key.IndexOf("recommended_") == 0)
|
||||||
{
|
{
|
||||||
@@ -299,8 +220,8 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
Widget state = GetRootWidget().FindAnyWidget("recommended_" + addonKey);
|
Widget state = GetRootWidget().FindAnyWidget("recommended_" + addonKey);
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
if (entry.Substring(divider + 1, entry.Length() - divider - 1) == "1") state.SetColor(Color.FromRGBA(105, 190, 140, 255));
|
if (entry.Substring(divider + 1, entry.Length() - divider - 1) == "1") state.SetColor(Color.FromInt(ERR_MenuTheme.READY_TEXT));
|
||||||
else state.SetColor(Color.FromRGBA(220, 115, 115, 255));
|
else state.SetColor(Color.FromInt(ERR_MenuTheme.UNAVAILABLE_TEXT));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -316,6 +237,33 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
ERR_SelectionStyle.Pair(GetRootWidget(), "PlaneOn", "PlaneOff", planeState);
|
ERR_SelectionStyle.Pair(GetRootWidget(), "PlaneOn", "PlaneOff", planeState);
|
||||||
m_AvailableFields.Insert(key); continue;
|
m_AvailableFields.Insert(key); continue;
|
||||||
}
|
}
|
||||||
|
if (key == "telemetryStatus") { SetText("TelemetryStatus", entry.Substring(divider + 1, entry.Length() - divider - 1)); continue; }
|
||||||
|
if (key == "telemetryEnabled")
|
||||||
|
{
|
||||||
|
m_TelemetryState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
||||||
|
string telemetryState = "Disabled";
|
||||||
|
if (m_TelemetryState == 1) telemetryState = "Enabled";
|
||||||
|
SetText("Saved_telemetryEnabled", "Saved: " + telemetryState);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key == "restartOnEmpty")
|
||||||
|
{
|
||||||
|
m_RestartEmptyState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
||||||
|
string restartState = "Disabled";
|
||||||
|
if (m_RestartEmptyState == 1) restartState = "Enabled";
|
||||||
|
SetText("Saved_restartOnEmpty", "Saved: " + restartState);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key == "showAllSites")
|
||||||
|
{
|
||||||
|
m_SitesState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key == "selfEpinephrine")
|
||||||
|
{
|
||||||
|
m_SelfEpiState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (key == "keepWeaponOnUnconscious")
|
if (key == "keepWeaponOnUnconscious")
|
||||||
{
|
{
|
||||||
m_KeepWeaponState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
m_KeepWeaponState = entry.Substring(divider + 1, entry.Length() - divider - 1).ToInt();
|
||||||
@@ -409,13 +357,11 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
if (!button || !IsFocused()) return;
|
if (!button || !IsFocused()) return;
|
||||||
string name = button.GetRootWidget().GetName();
|
string name = button.GetRootWidget().GetName();
|
||||||
if (name == "Close") { Close(); return; }
|
if (name == "Close") { Close(); return; }
|
||||||
if (name == "RecommendationsBack") { ShowPage(3); return; }
|
int section = ERR_AdminMenuPages.MainButtons().Find(name);
|
||||||
if (name == "RecommendedPlane") { ShowPage(14); return; }
|
if (section >= 0) { ShowPage(ERR_AdminMenuPages.MainPage(section)); return; }
|
||||||
if (name == "EquipmentOverview") { ShowPage(9); return; }
|
if (name == "RecommendedDrones") { ShowPage(ERR_AdminPage.DRONES); return; }
|
||||||
if (name == "RecommendedWeapons") { ShowPage(9); return; }
|
if (name == "RecommendedPlane") { ShowPage(ERR_AdminPage.PLANE); return; }
|
||||||
if (name == "PlaneBack") { ShowPage(1); return; }
|
if (name == "RecommendedWeapons") { ShowPage(ERR_AdminPage.ITEMS); return; }
|
||||||
if (name == "AIBack") { ShowPage(1); return; }
|
|
||||||
if (name == "GuardsBack" || name == "SitesBack") { ShowPage(11); return; }
|
|
||||||
int page = Navigation().Find(name);
|
int page = Navigation().Find(name);
|
||||||
if (page >= 0) { ShowPage(page); return; }
|
if (page >= 0) { ShowPage(page); return; }
|
||||||
if (name == "JournalDetails")
|
if (name == "JournalDetails")
|
||||||
@@ -464,6 +410,33 @@ class ERR_AdminMenu : ChimeraMenuBase
|
|||||||
m_ClickDelay = 0.3; SetText("Feedback", "Saving reconnaissance plane selection for next round...");
|
m_ClickDelay = 0.3; SetText("Feedback", "Saving reconnaissance plane selection for next round...");
|
||||||
m_Controller.ERR_AdminSubmit("mission plane set " + enabled, true); return;
|
m_Controller.ERR_AdminSubmit("mission plane set " + enabled, true); return;
|
||||||
}
|
}
|
||||||
|
if (name == "TelemetryOn" || name == "TelemetryOff")
|
||||||
|
{
|
||||||
|
if (m_TelemetryState < 0) return;
|
||||||
|
string enabled = "0"; if (name == "TelemetryOn") enabled = "1";
|
||||||
|
m_Controller.ERR_AdminSubmit("mission telemetry set " + enabled, true); return;
|
||||||
|
}
|
||||||
|
if (name == "RestartEmptyOn" || name == "RestartEmptyOff")
|
||||||
|
{
|
||||||
|
if (m_RestartEmptyState < 0) return;
|
||||||
|
string restartEnabled = "0"; if (name == "RestartEmptyOn") restartEnabled = "1";
|
||||||
|
m_ClickDelay = 0.3; SetText("Feedback", "Saving restart after last disconnect...");
|
||||||
|
m_Controller.ERR_AdminSubmit("mission restartempty set " + restartEnabled, true); return;
|
||||||
|
}
|
||||||
|
if (name == "SitesOn" || name == "SitesOff")
|
||||||
|
{
|
||||||
|
if (m_SitesState < 0) return;
|
||||||
|
string sitesEnabled = "0"; if (name == "SitesOn") sitesEnabled = "1";
|
||||||
|
m_ClickDelay = 0.3; SetText("Feedback", "Saving site map visibility...");
|
||||||
|
m_Controller.ERR_AdminSubmit("intel sites set " + sitesEnabled, true); return;
|
||||||
|
}
|
||||||
|
if (name == "SelfEpiOn" || name == "SelfEpiOff")
|
||||||
|
{
|
||||||
|
if (m_SelfEpiState < 0) return;
|
||||||
|
m_ClickDelay = 0.3; SetText("Feedback", "Saving self epinephrine permission...");
|
||||||
|
string selfEpi = "0"; if (name == "SelfEpiOn") selfEpi = "1";
|
||||||
|
m_Controller.ERR_AdminSubmit("mission selfepi set " + selfEpi, true); return;
|
||||||
|
}
|
||||||
if (name == "KeepWeaponOn" || name == "KeepWeaponOff")
|
if (name == "KeepWeaponOn" || name == "KeepWeaponOff")
|
||||||
{
|
{
|
||||||
string retain = "0"; if (name == "KeepWeaponOn") retain = "1";
|
string retain = "0"; if (name == "KeepWeaponOn") retain = "1";
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
// Presentation rules only: all mutations still use the authenticated command service.
|
||||||
|
class ERR_AdminMenuFields
|
||||||
|
{
|
||||||
|
static array<string> Keys()
|
||||||
|
{
|
||||||
|
return {"crashLootMode", "crashSiteCount", "crashHelicopterChancePercent", "crashRifleCount", "crashMagazineCount", "crashAntiAirChancePercent", "crashRocketChancePercent", "aiDoctrine", "aiShadow", "automaticEquipmentChancePercent", "sarkaAngerPerCar", "motorbikeCount", "droneReconCount", "droneCooldownSeconds", "planeAltitudeMetres", "planeReplacementSeconds", "planeSectorSeconds", "fieldCampCount", "fieldHospitalCount", "startWeaponCount", "startMagazineCount", "objectGuardCount", "objectGuardEvery", "objectGuardHQMode", "hunterSpawnDistanceMetres", "roadblockCount", "largeRoadblockCount", "mainRoadWidthMetres", "civilianTrafficCount", "garageVehicleCount", "garageChancePercent", "garageRadiusMetres", "garageSpawnIntervalSeconds", "emptyRestartHours", "startMode", "radioDefenceSeconds", "aiIntelChancePercent", "intelRevealChancePercent", "radioIntelSiteCount", "startTimeMinutes", "timeMultiplier", "startDateCode", "weatherProfile", "viewDistanceMetres", "reportIntervalSeconds", "supportSquadLimit", "responseRadiusMetres", "convoyCount", "antiAirChancePercent", "antiPersonnelMineChancePercent", "heliTimerMinutes"};
|
||||||
|
}
|
||||||
|
static bool Available(string key, bool hq, bool intel)
|
||||||
|
{
|
||||||
|
if (key == "aiDoctrine" || key == "aiShadow") return hq;
|
||||||
|
if (key == "sarkaAngerPerCar" || key == "droneReconCount" || key == "droneCooldownSeconds") return hq;
|
||||||
|
if (key == "aiIntelChancePercent") return intel;
|
||||||
|
if (key == "automaticEquipmentChancePercent" || key == "motorbikeCount" || key == "planeAltitudeMetres" || key == "planeReplacementSeconds" || key == "planeSectorSeconds" || key == "planeReconEnabled" || key == "objectGuardCount" || key == "objectGuardEvery" || key == "objectGuardHQMode" || key == "hunterSpawnDistanceMetres" || key == "heliTimerMinutes" || key == "antiAirChancePercent" || key == "antiPersonnelMineChancePercent" || key == "convoyCount" || key == "reportIntervalSeconds" || key == "supportSquadLimit" || key == "responseRadiusMetres") return hq;
|
||||||
|
return Keys().Contains(key);
|
||||||
|
}
|
||||||
|
// A short journal has no older off-screen lines, even if its slider is zero.
|
||||||
|
static bool FollowJournal(bool empty, float slider, float height, float viewHeight, bool latest)
|
||||||
|
{
|
||||||
|
return latest || empty || slider >= 0.98 || height <= viewHeight;
|
||||||
|
}
|
||||||
|
// TextWidget interprets hash-prefixed tokens as localization IDs. Keep the
|
||||||
|
// server audit and retained entries intact; render their numeric IDs literally.
|
||||||
|
static string JournalText(string line, bool details = false)
|
||||||
|
{
|
||||||
|
return ERR_JournalText.Menu(line, details);
|
||||||
|
}
|
||||||
|
static string Display(string key, string value)
|
||||||
|
{
|
||||||
|
if (key == "crashLootMode") { if (value == "1") return "Random"; return "Custom"; }
|
||||||
|
if (key == "aiDoctrine") { if (value == "1") return "Coordinated"; return "Current"; }
|
||||||
|
if (key == "aiShadow") { if (value == "1") return "On"; return "Off"; }
|
||||||
|
if (value == "-1" || value == "-2") return ERR_Settings.SelectionText(value.ToInt());
|
||||||
|
if (key == "startMode") { if (value == "1") return "Crash"; return "Prison"; }
|
||||||
|
if (key == "startTimeMinutes") return ERR_TimeService.Clock(value.ToInt());
|
||||||
|
if (key == "startDateCode") return ERR_EnvironmentService.Date(value.ToInt());
|
||||||
|
if (key == "weatherProfile") return ERR_EnvironmentService.ProfileName(value.ToInt());
|
||||||
|
if (key == "viewDistanceMetres" && value == "0") return "default";
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
static string StartSummary(int saved, int current)
|
||||||
|
{
|
||||||
|
return "Next start: " + Display("startMode", saved.ToString()) + " | Current round: " + Display("startMode", current.ToString());
|
||||||
|
}
|
||||||
|
static string Command(string key, string value)
|
||||||
|
{
|
||||||
|
string prefix;
|
||||||
|
if (key == "aiDoctrine") prefix = "mission doctrine";
|
||||||
|
else if (key == "aiShadow") prefix = "mission aishadow";
|
||||||
|
else if (key == "automaticEquipmentChancePercent") prefix = "hq equipment";
|
||||||
|
else if (key == "sarkaAngerPerCar") prefix = "mission sarkapoints";
|
||||||
|
else if (key == "motorbikeCount") prefix = "mission motorbikes";
|
||||||
|
else if (key == "droneReconCount") prefix = "mission drones";
|
||||||
|
else if (key == "droneCooldownSeconds") prefix = "mission dronecooldown";
|
||||||
|
else if (key == "planeReconEnabled") prefix = "mission plane";
|
||||||
|
else if (key == "planeAltitudeMetres") prefix = "mission planealtitude";
|
||||||
|
else if (key == "planeReplacementSeconds") prefix = "mission planereplacement";
|
||||||
|
else if (key == "planeSectorSeconds") prefix = "mission planesector";
|
||||||
|
else if (key == "startWeaponCount") prefix = "mission startweapons";
|
||||||
|
else if (key == "startMagazineCount") prefix = "mission startammo";
|
||||||
|
else if (key == "objectGuardEvery") prefix = "mission objectevery";
|
||||||
|
else if (key == "objectGuardHQMode") prefix = "mission objecthq";
|
||||||
|
else if (key == "objectGuardCount") prefix = "mission objectguards";
|
||||||
|
else if (key == "hunterSpawnDistanceMetres") prefix = "mission hunterdistance";
|
||||||
|
else if (key == "crashLootMode") prefix = "mission crashloot";
|
||||||
|
else if (key == "crashSiteCount") prefix = "mission crashsites";
|
||||||
|
else if (key == "crashHelicopterChancePercent") prefix = "mission crashhelis";
|
||||||
|
else if (key == "crashRifleCount") prefix = "mission crashrifles";
|
||||||
|
else if (key == "crashMagazineCount") prefix = "mission crashammo";
|
||||||
|
else if (key == "crashAntiAirChancePercent") prefix = "mission crashaa";
|
||||||
|
else if (key == "crashRocketChancePercent") prefix = "mission crashrockets";
|
||||||
|
else if (key == "fieldCampCount") prefix = "mission camps";
|
||||||
|
else if (key == "fieldHospitalCount") prefix = "mission hospitals";
|
||||||
|
else if (key == "roadblockCount") prefix = "mission roadblocks";
|
||||||
|
else if (key == "largeRoadblockCount") prefix = "mission largeroadblocks";
|
||||||
|
else if (key == "mainRoadWidthMetres") prefix = "mission mainroadwidth";
|
||||||
|
else if (key == "emptyRestartHours") prefix = "mission emptyhours";
|
||||||
|
else if (key == "garageChancePercent") prefix = "mission garagechance";
|
||||||
|
else if (key == "garageRadiusMetres") prefix = "mission garageradius";
|
||||||
|
else if (key == "garageSpawnIntervalSeconds") prefix = "mission garageinterval";
|
||||||
|
else if (key == "garageVehicleCount") prefix = "mission garagevehicles";
|
||||||
|
else if (key == "civilianTrafficCount") prefix = "mission traffic";
|
||||||
|
else if (key == "startMode") prefix = "mission start";
|
||||||
|
else if (key == "radioDefenceSeconds") prefix = "mission radio";
|
||||||
|
else if (key == "aiIntelChancePercent") prefix = "intel carrying";
|
||||||
|
else if (key == "intelRevealChancePercent") prefix = "intel reveal";
|
||||||
|
else if (key == "radioIntelSiteCount") prefix = "intel radiosites";
|
||||||
|
else if (key == "startTimeMinutes") prefix = "mission time";
|
||||||
|
else if (key == "timeMultiplier") prefix = "mission speed";
|
||||||
|
else if (key == "startDateCode") prefix = "mission date";
|
||||||
|
else if (key == "weatherProfile") prefix = "mission weather";
|
||||||
|
else if (key == "viewDistanceMetres") prefix = "mission viewdistance";
|
||||||
|
else if (key == "reportIntervalSeconds") prefix = "hq interval";
|
||||||
|
else if (key == "supportSquadLimit") prefix = "hq squads";
|
||||||
|
else if (key == "responseRadiusMetres") prefix = "hq radius";
|
||||||
|
else if (key == "antiAirChancePercent") prefix = "hq aa";
|
||||||
|
else if (key == "antiPersonnelMineChancePercent") prefix = "hq mines";
|
||||||
|
else if (key == "heliTimerMinutes") prefix = "hq heli timer";
|
||||||
|
else if (key == "convoyCount") prefix = "hq convoy count";
|
||||||
|
value = value.Trim();
|
||||||
|
if (prefix.IsEmpty() || value.IsEmpty() || value.Length() > 32) return "";
|
||||||
|
return prefix + " set " + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// Generated by tools/build_admin_menu.py; edit ui/admin_menu/navigation.json.
|
||||||
|
enum ERR_AdminPage
|
||||||
|
{
|
||||||
|
MISSION = 0,
|
||||||
|
HQ = 1,
|
||||||
|
JOURNAL = 2,
|
||||||
|
MODS = 3,
|
||||||
|
FACTIONS = 4,
|
||||||
|
WORLD = 5,
|
||||||
|
INTEL = 6,
|
||||||
|
STATUS = 7,
|
||||||
|
TERRAINS = 8,
|
||||||
|
ITEMS = 9,
|
||||||
|
SPEECH = 10,
|
||||||
|
FORCES = 11,
|
||||||
|
GUARDS = 12,
|
||||||
|
SITES = 13,
|
||||||
|
PLANE = 14,
|
||||||
|
RECOMMENDATIONS = 15,
|
||||||
|
WEIGHTS = 16,
|
||||||
|
ALLOWED_ITEMS = 17,
|
||||||
|
ITEM_PRESETS = 18,
|
||||||
|
AI = 19,
|
||||||
|
STARTER = 20,
|
||||||
|
SARKA = 21,
|
||||||
|
DRONES = 22,
|
||||||
|
RADIO_INTEL = 23,
|
||||||
|
TELEMETRY = 24,
|
||||||
|
VEHICLES = 25,
|
||||||
|
CHECKPOINTS = 26,
|
||||||
|
VEHICLE_POOL = 27,
|
||||||
|
PACKS = 28,
|
||||||
|
CRASH_SITES = 29,
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_AdminMenuPages
|
||||||
|
{
|
||||||
|
static array<string> Pages() { return {"SettingsPage", "HQPage", "JournalPage", "ModsPage", "FactionsPage", "WorldPage", "IntelPage", "StatusPage", "TerrainsPage", "ItemsPage", "TTSPage", "ForcesPage", "GuardsPage", "SitesPage", "PlanePage", "RecommendationsPage", "WeightsPage", "AllowedItemsPage", "ItemPresetsPage", "AIPage", "StarterPage", "SarkaPage", "DronesPage", "RadioIntelPage", "TelemetryPage", "VehiclesPage", "CheckpointsPage", "VehiclePoolPage", "PacksPage", "CrashSitesPage"}; }
|
||||||
|
static array<string> Navigation() { return {"OpenSettings", "OpenHQ", "OpenJournal", "OpenMods", "OpenFactions", "OpenWorld", "OpenIntel", "OpenStatus", "OpenTerrains", "OpenItems", "OpenTTS", "OpenForces", "OpenGuards", "OpenSites", "OpenPlane", "OpenRecommendations", "OpenWeights", "OpenAllowedItems", "OpenItemPresets", "OpenAI", "OpenStarter", "OpenSarka", "OpenDrones", "OpenRadioIntel", "OpenTelemetry", "OpenVehicles", "OpenCheckpoints", "OpenVehiclePool", "OpenPacks", "OpenCrashSites"}; }
|
||||||
|
static array<string> MainButtons() { return {"Main_Mission", "Main_Forces", "Main_HQ", "Main_Intel", "Main_Content", "Main_Audio", "Main_Status"}; }
|
||||||
|
static array<string> Sidebars() { return {"Sidebar_Mission", "Sidebar_Forces", "Sidebar_HQ", "Sidebar_Intel", "Sidebar_Content", "Sidebar_Audio", "Sidebar_Status"}; }
|
||||||
|
static int Group(int page)
|
||||||
|
{
|
||||||
|
array<int> groups = {0, 2, 6, 4, 1, 0, 3, 6, 0, 4, 5, 1, 1, 1, 2, 0, 4, 4, 4, 2, 4, 1, 2, 3, 0, 4, 1, 4, 1, 1};
|
||||||
|
if (page < 0 || page >= groups.Count()) return -1;
|
||||||
|
return groups[page];
|
||||||
|
}
|
||||||
|
static int MainPage(int group)
|
||||||
|
{
|
||||||
|
array<int> pages = {ERR_AdminPage.MISSION, ERR_AdminPage.FORCES, ERR_AdminPage.HQ, ERR_AdminPage.INTEL, ERR_AdminPage.MODS, ERR_AdminPage.SPEECH, ERR_AdminPage.STATUS};
|
||||||
|
if (group < 0 || group >= pages.Count()) return -1;
|
||||||
|
return pages[group];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// Widget presentation only. No settings writes, authorization or transport here.
|
||||||
|
class ERR_AdminMenuView
|
||||||
|
{
|
||||||
|
// Preserve the requested UI scale until the fixed panel would leave the viewport.
|
||||||
|
static void FitPanel(Widget root)
|
||||||
|
{
|
||||||
|
if (!root || !GetGame() || !GetGame().GetWorkspace()) return;
|
||||||
|
ScaleWidget scale = ScaleWidget.Cast(root.FindAnyWidget("PanelScale"));
|
||||||
|
if (!scale) return;
|
||||||
|
float width, height; root.GetScreenSize(width, height);
|
||||||
|
float panelWidth = GetGame().GetWorkspace().DPIScale(1220);
|
||||||
|
float panelHeight = GetGame().GetWorkspace().DPIScale(760);
|
||||||
|
if (width <= 0 || height <= 0 || panelWidth <= 0 || panelHeight <= 0) return;
|
||||||
|
float fit = Math.Min(1, Math.Min(width * 0.96 / panelWidth, height * 0.96 / panelHeight));
|
||||||
|
if (Math.AbsFloat(scale.GetScale() - fit) > 0.001) scale.SetScale(fit);
|
||||||
|
}
|
||||||
|
static bool ShowPage(Widget root, int page)
|
||||||
|
{
|
||||||
|
int group = ERR_AdminMenuPages.Group(page);
|
||||||
|
if (!root || group < 0) return false;
|
||||||
|
array<string> pages = ERR_AdminMenuPages.Pages();
|
||||||
|
array<string> navigation = ERR_AdminMenuPages.Navigation();
|
||||||
|
for (int i = 0; i < pages.Count(); i++)
|
||||||
|
{
|
||||||
|
root.FindAnyWidget(pages[i]).SetVisible(i == page);
|
||||||
|
root.FindAnyWidget("Selected_" + navigation[i]).SetVisible(i == page);
|
||||||
|
ERR_SelectionStyle.Choice(SCR_ButtonTextComponent.GetButtonText(navigation[i], root), i == page);
|
||||||
|
}
|
||||||
|
array<string> buttons = ERR_AdminMenuPages.MainButtons();
|
||||||
|
array<string> sidebars = ERR_AdminMenuPages.Sidebars();
|
||||||
|
for (int section = 0; section < buttons.Count(); section++)
|
||||||
|
{
|
||||||
|
root.FindAnyWidget(sidebars[section]).SetVisible(section == group);
|
||||||
|
root.FindAnyWidget("Selected_" + buttons[section]).SetVisible(section == group);
|
||||||
|
ERR_SelectionStyle.Choice(SCR_ButtonTextComponent.GetButtonText(buttons[section], root), section == group);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,14 +4,25 @@ class ERR_CommandArguments
|
|||||||
{
|
{
|
||||||
static string CoreSetting(string section, string option)
|
static string CoreSetting(string section, string option)
|
||||||
{
|
{
|
||||||
|
if (section == "mission" && option == "telemetry") return "telemetryEnabled";
|
||||||
if (section == "mission" && option == "doctrine") return "aiDoctrine";
|
if (section == "mission" && option == "doctrine") return "aiDoctrine";
|
||||||
if (section == "mission" && option == "aishadow") return "aiShadow";
|
if (section == "mission" && option == "aishadow") return "aiShadow";
|
||||||
|
if (section == "mission" && option == "sarkapoints") return "sarkaAngerPerCar";
|
||||||
if (section == "mission" && option == "motorbikes") return "motorbikeCount";
|
if (section == "mission" && option == "motorbikes") return "motorbikeCount";
|
||||||
if (section == "mission" && option == "planealtitude") return "planeAltitudeMetres";
|
if (section == "mission" && option == "planealtitude") return "planeAltitudeMetres";
|
||||||
if (section == "mission" && option == "planereplacement") return "planeReplacementSeconds";
|
if (section == "mission" && option == "planereplacement") return "planeReplacementSeconds";
|
||||||
if (section == "mission" && option == "planesector") return "planeSectorSeconds";
|
if (section == "mission" && option == "planesector") return "planeSectorSeconds";
|
||||||
|
if (section == "mission" && option == "drones") return "droneReconCount";
|
||||||
|
if (section == "mission" && option == "dronecooldown") return "droneCooldownSeconds";
|
||||||
if (section == "mission" && option == "plane") return "planeReconEnabled";
|
if (section == "mission" && option == "plane") return "planeReconEnabled";
|
||||||
if (section == "mission" && option == "camps") return "fieldCampCount";
|
if (section == "mission" && option == "camps") return "fieldCampCount";
|
||||||
|
if (section == "mission" && option == "crashloot") return "crashLootMode";
|
||||||
|
if (section == "mission" && option == "crashsites") return "crashSiteCount";
|
||||||
|
if (section == "mission" && option == "crashhelis") return "crashHelicopterChancePercent";
|
||||||
|
if (section == "mission" && option == "crashrifles") return "crashRifleCount";
|
||||||
|
if (section == "mission" && option == "crashammo") return "crashMagazineCount";
|
||||||
|
if (section == "mission" && option == "crashaa") return "crashAntiAirChancePercent";
|
||||||
|
if (section == "mission" && option == "crashrockets") return "crashRocketChancePercent";
|
||||||
if (section == "mission" && option == "hospitals") return "fieldHospitalCount";
|
if (section == "mission" && option == "hospitals") return "fieldHospitalCount";
|
||||||
if (section == "mission" && option == "startweapons") return "startWeaponCount";
|
if (section == "mission" && option == "startweapons") return "startWeaponCount";
|
||||||
if (section == "mission" && option == "startammo") return "startMagazineCount";
|
if (section == "mission" && option == "startammo") return "startMagazineCount";
|
||||||
@@ -20,19 +31,32 @@ class ERR_CommandArguments
|
|||||||
if (section == "mission" && option == "objectguards") return "objectGuardCount";
|
if (section == "mission" && option == "objectguards") return "objectGuardCount";
|
||||||
if (section == "mission" && option == "hunterdistance") return "hunterSpawnDistanceMetres";
|
if (section == "mission" && option == "hunterdistance") return "hunterSpawnDistanceMetres";
|
||||||
if (section == "mission" && option == "roadblocks") return "roadblockCount";
|
if (section == "mission" && option == "roadblocks") return "roadblockCount";
|
||||||
|
if (section == "mission" && option == "largeroadblocks") return "largeRoadblockCount";
|
||||||
|
if (section == "mission" && option == "mainroadwidth") return "mainRoadWidthMetres";
|
||||||
|
if (section == "mission" && option == "garagechance") return "garageChancePercent";
|
||||||
|
if (section == "mission" && option == "garageradius") return "garageRadiusMetres";
|
||||||
|
if (section == "mission" && option == "garageinterval") return "garageSpawnIntervalSeconds";
|
||||||
|
if (section == "mission" && option == "garagevehicles") return "garageVehicleCount";
|
||||||
if (section == "mission" && option == "traffic") return "civilianTrafficCount";
|
if (section == "mission" && option == "traffic") return "civilianTrafficCount";
|
||||||
if (section == "mission" && option == "start") return "startMode";
|
if (section == "mission" && option == "start") return "startMode";
|
||||||
|
if (section == "mission" && option == "selfepi") return "selfEpinephrine";
|
||||||
if (section == "mission" && option == "keepweapon") return "keepWeaponOnUnconscious";
|
if (section == "mission" && option == "keepweapon") return "keepWeaponOnUnconscious";
|
||||||
|
if (section == "mission" && option == "restartempty") return "restartOnEmpty";
|
||||||
|
if (section == "mission" && option == "emptyhours") return "emptyRestartHours";
|
||||||
if (section == "mission" && option == "radio") return "radioDefenceSeconds";
|
if (section == "mission" && option == "radio") return "radioDefenceSeconds";
|
||||||
|
if (section == "intel" && option == "sites") return "showAllSites";
|
||||||
|
if (section == "intel" && option == "radiosites") return "radioIntelSiteCount";
|
||||||
if (section == "intel" && option == "reveal") return "intelRevealChancePercent";
|
if (section == "intel" && option == "reveal") return "intelRevealChancePercent";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
static bool Selection(string key, string text, out int value)
|
static bool Selection(string key, string text, out int value)
|
||||||
{
|
{
|
||||||
|
if (key == "crashLootMode" && text == "random") { value = 1; return true; }
|
||||||
|
if (key == "crashLootMode" && text == "custom") { value = 0; return true; }
|
||||||
if (key == "aiDoctrine" && text == "current") { value = 0; return true; }
|
if (key == "aiDoctrine" && text == "current") { value = 0; return true; }
|
||||||
if (key == "aiDoctrine" && text == "coordinated") { value = 1; return true; }
|
if (key == "aiDoctrine" && text == "coordinated") { value = 1; return true; }
|
||||||
if (key == "aiShadow" && text == "off") { value = 0; return true; }
|
if ((key == "aiShadow" || key == "restartOnEmpty" || key == "showAllSites") && text == "off") { value = 0; return true; }
|
||||||
if (key == "aiShadow" && text == "on") { value = 1; return true; }
|
if ((key == "aiShadow" || key == "restartOnEmpty" || key == "showAllSites") && text == "on") { value = 1; return true; }
|
||||||
if (key == "startMode" && text == "prison") { value = 0; return true; }
|
if (key == "startMode" && text == "prison") { value = 0; return true; }
|
||||||
if (key == "startMode" && text == "crash") { value = 1; return true; }
|
if (key == "startMode" && text == "crash") { value = 1; return true; }
|
||||||
if (text == "random" && ERR_Settings.Randomizable(key)) { value = -1; return true; }
|
if (text == "random" && ERR_Settings.Randomizable(key)) { value = -1; return true; }
|
||||||
@@ -167,30 +191,53 @@ class ERR_AdminService
|
|||||||
if (key == "aiShadow") return "On (1) records coordinated proposals without issuing their orders; Off (0) uses the selected doctrine. Saved for next round.";
|
if (key == "aiShadow") return "On (1) records coordinated proposals without issuing their orders; Off (0) uses the selected doctrine. Saved for next round.";
|
||||||
if (key == "startWeaponCount") return "0..12 pistols in the shared prison/crash supply backpack; default 5. Applies next round.";
|
if (key == "startWeaponCount") return "0..12 pistols in the shared prison/crash supply backpack; default 5. Applies next round.";
|
||||||
if (key == "startMagazineCount") return "0..48 spare pistol magazines in the shared prison/crash supply backpack; default 8. Applies next round.";
|
if (key == "startMagazineCount") return "0..48 spare pistol magazines in the shared prison/crash supply backpack; default 8. Applies next round.";
|
||||||
|
if (key == "sarkaAngerPerCar") return "1-30 anger points per car; 0 disables new waves. Default 3. Whole thresholds only: 5 means one car at 5 anger, two at 10. Four special-forces crew per car. Applies to new waves; existing teams remain.";
|
||||||
if (key == "motorbikeCount") return "0-6; default 2; 0 disabled. Optional WCS Motorbikes, two response specialists per bike. Applies next round; losses are not replaced.";
|
if (key == "motorbikeCount") return "0-6; default 2; 0 disabled. Optional WCS Motorbikes, two response specialists per bike. Applies next round; losses are not replaced.";
|
||||||
|
if (key == "droneReconCount") return "0-3; default 0. Applies next round.";
|
||||||
|
if (key == "droneCooldownSeconds") return "60-1800; default 300. Applies next round.";
|
||||||
if (key == "planeAltitudeMetres") return "150-500; default 250. Applies next round.";
|
if (key == "planeAltitudeMetres") return "150-500; default 250. Applies next round.";
|
||||||
if (key == "planeReplacementSeconds") return "30-1800; default 60. Applies next round.";
|
if (key == "planeReplacementSeconds") return "30-1800; default 60. Applies next round.";
|
||||||
if (key == "planeSectorSeconds") return "30-600; default 120. Applies next round.";
|
if (key == "planeSectorSeconds") return "30-600; default 120. Applies next round.";
|
||||||
if (key == "planeReconEnabled") return "0 disabled, 1 enabled if Cessna 172 and Propeller Flight Core are loaded. Applies next round. A clear airport departure area is required.";
|
if (key == "planeReconEnabled") return "0 disabled, 1 enabled if Cessna 172 and Propeller Flight Core are loaded. Applies next round. A clear airport departure area is required.";
|
||||||
if (key == "fieldCampCount") return "1..16 field camps; default 12. Applies next round. Counts are requested: unsafe optional sites may be omitted.";
|
if (key == "fieldCampCount") return "1..16 field camps; default 12. Applies next round. Counts are requested: unsafe optional sites may be omitted.";
|
||||||
|
if (key == "crashLootMode") return "Random (1, default): each crate rolls independently from poor pistol supplies to rich scoped-rifle/launcher loot. Custom (0): use configured rifle, ammo and launcher values. Next round.";
|
||||||
|
if (key == "crashSiteCount") return "0..12; default 3. 0 disables sites. Finite wrecks and loot; no refills. Applies next round.";
|
||||||
|
if (key == "crashHelicopterChancePercent") return "0..100; default 50. 0 = armored wrecks; 100 = helicopters. Applies next round.";
|
||||||
|
if (key == "crashRifleCount") return "1..6; default 3. Random M21 / SVD rifles with fitted scopes. Custom loot mode only; next round.";
|
||||||
|
if (key == "crashMagazineCount") return "1..8; default 4. Matching ammunition for each selected rifle. Custom loot mode only; next round.";
|
||||||
|
if (key == "crashAntiAirChancePercent") return "0..100; default 25. One loaded Stinger, if installed and enabled. Custom loot mode only; next round.";
|
||||||
|
if (key == "crashRocketChancePercent") return "0..100; default 50. One scoped RPG-7 with two matching rockets. Custom loot mode only; next round.";
|
||||||
if (key == "fieldHospitalCount") return "1..8 field hospitals; default 6. Applies next round. The required radio-clue hospital is retained.";
|
if (key == "fieldHospitalCount") return "1..8 field hospitals; default 6. Applies next round. The required radio-clue hospital is retained.";
|
||||||
if (key == "objectGuardEvery") return "Guard every 1st, 2nd, 3rd or 4th eligible site; default every third. Nearby buildings share one site. Next round.";
|
if (key == "objectGuardEvery") return "Guard every 1st, 2nd, 3rd or 4th eligible site; default every third. Nearby buildings share one site. Next round.";
|
||||||
if (key == "objectGuardHQMode") return "0: all hold their posts; 1: half hold, half respond to HQ; 2: all may respond to HQ. All report contacts. Next round.";
|
if (key == "objectGuardHQMode") return "0: all hold their posts; 1: half hold, half respond to HQ; 2: all may respond to HQ. All report contacts. Next round.";
|
||||||
if (key == "objectGuardCount") return "0..16 soldiers per factory/industrial, military or infrastructure site; default 8, zero off. Next round. HQ participation is configured separately; all report. Towers and chimneys use suitable platforms. Lost guards are not replaced.";
|
if (key == "objectGuardCount") return "0..16 soldiers per factory/industrial, military or infrastructure site; default 8, zero off. Next round. HQ participation is configured separately; all report. Towers and chimneys use suitable platforms. Lost guards are not replaced.";
|
||||||
if (key == "hunterSpawnDistanceMetres") return "Opening UAZ and troop-truck patrol placement. Applies next round.";
|
if (key == "hunterSpawnDistanceMetres") return "Opening UAZ and troop-truck patrol placement. Applies next round.";
|
||||||
if (key == "roadblockCount") return "Set 0..30 roadblocks (default 4; 0 disables). Applies next round. Each has four guards; unsuitable sites are skipped.";
|
if (key == "largeRoadblockCount") return "Set 0..30 main-road checkpoints (default 4; 0 disables large posts). Eight guards per post. Applies next round; unsuitable sites are skipped.";
|
||||||
|
if (key == "mainRoadWidthMetres") return "Set main-road minimum width to 5..12 metres (default 6). Wider roads use large checkpoints; narrower roads use small ones. Applies next round.";
|
||||||
|
if (key == "roadblockCount") return "Set 0..30 small-road checkpoints (default 4; 0 disables small posts). Four guards per post. Applies next round; unsuitable sites are skipped.";
|
||||||
|
if (key == "telemetryEnabled") return "Default on. Sends mission results and player identities to the configured statistics service. Disabling clears unsent events immediately.";
|
||||||
|
if (key == "restartOnEmpty") return "On (1) restarts after the last disconnect; Off (0) preserves the round for reconnects. Default On. Applies immediately; normal round endings still apply.";
|
||||||
|
if (key == "emptyRestartHours") return "0 disables idle restarts; 1..168 real hours continuously empty. Default 5. Applies immediately, measured from mission start or the last disconnect. Connected players, including spectators, prevent idle restarts.";
|
||||||
|
if (key == "garageChancePercent") return "Parking-site selection chance (0-100%). Default 70%; applies to suitable garages and residential yards. Next round.";
|
||||||
|
if (key == "garageRadiusMetres") return "Spawn radius (250-1500 metres). Distance around players; default 1000 m. Next round.";
|
||||||
|
if (key == "garageSpawnIntervalSeconds") return "Time between spawns (5-60 seconds). Default 5 s. Increase to spread out spawning. Next round.";
|
||||||
|
if (key == "garageVehicleCount") return "0..24 unclaimed cars in garages and residential yards; default 16. Used vehicles stay. Optional Rally cars, farm tractors and bikes. Next round.";
|
||||||
if (key == "civilianTrafficCount") return "Set 0..6 civilian cars (default 3). Zero disables new traffic. Unclaimed cars retire only far from all players and out of sight; player-entered cars are preserved.";
|
if (key == "civilianTrafficCount") return "Set 0..6 civilian cars (default 3). Zero disables new traffic. Unclaimed cars retire only far from all players and out of sight; player-entered cars are preserved.";
|
||||||
|
if (key == "showAllSites") return "0 disabled (default), 1 enabled. Show prepared sites at their positions as question marks; recovered intel identifies their types. Applies immediately to everyone.";
|
||||||
|
if (key == "selfEpinephrine") return "0 disabled (default), 1 enabled. Unconscious players can press Space to use a carried epinephrine injector. Applies immediately; consumes the item and keeps its normal medical effect.";
|
||||||
if (key == "keepWeaponOnUnconscious") return "Set 1 to retain the held firearm during unconsciousness and equip it after recovery; 0 keeps normal dropping. Applies to the next knockout.";
|
if (key == "keepWeaponOnUnconscious") return "Set 1 to retain the held firearm during unconsciousness and equip it after recovery; 0 keeps normal dropping. Applies to the next knockout.";
|
||||||
if (key == "antiAirChancePercent" || key == "antiPersonnelMineChancePercent")
|
if (key == "antiAirChancePercent" || key == "antiPersonnelMineChancePercent")
|
||||||
return "Set 0..100 percent or Random. Applies to newly equipped enemy soldiers; existing loadouts are not rerolled or replenished.";
|
return "Set 0..100 percent or Random. Applies to newly equipped enemy soldiers; existing loadouts are not rerolled or replenished.";
|
||||||
|
if (key == "radioIntelSiteCount") return "Sites required before radio intel: 0..20, default 5; 0 disables. Fully identify distinct non-radio sites; starting reveals do not count. Applies next round. Finding and using radios in person remains unrestricted.";
|
||||||
if (key == "intelRevealChancePercent")
|
if (key == "intelRevealChancePercent")
|
||||||
return "Use /esc intel reveal set N (0-100) or random. This is the chance that a first document identifies its location exactly; otherwise it gives a rough location. A second document for that location always identifies it. Changes affect newly recovered documents immediately; known locations and spent documents remain unchanged.";
|
return "Use /esc intel reveal set N (0-100) or random. This is the chance that a first document identifies its location exactly; otherwise it gives a rough location. A second document for that location always identifies it. With all sites shown, the first document always identifies the type. Changes affect newly recovered documents immediately; known locations and spent documents remain unchanged.";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
protected string RoadblockTiming(string key)
|
protected string RoadblockTiming(string key)
|
||||||
{
|
{
|
||||||
if (key == "aiDoctrine" || key == "aiShadow") return " for next round";
|
if (key == "crashLootMode" || key == "crashSiteCount" || key == "crashHelicopterChancePercent" || key == "crashRifleCount" || key == "crashMagazineCount" || key == "crashAntiAirChancePercent" || key == "crashRocketChancePercent" || key == "radioIntelSiteCount" || key == "garageVehicleCount" || key == "garageChancePercent" || key == "garageRadiusMetres" || key == "garageSpawnIntervalSeconds") return " for next round";
|
||||||
if (key == "motorbikeCount" || key == "planeAltitudeMetres" || key == "planeReplacementSeconds" || key == "planeSectorSeconds" || key == "planeReconEnabled" || key == "fieldCampCount" || key == "fieldHospitalCount" || key == "startWeaponCount" || key == "startMagazineCount" || key == "objectGuardCount" || key == "objectGuardEvery" || key == "objectGuardHQMode" || key == "hunterSpawnDistanceMetres" || key == "roadblockCount") return " for next round";
|
if (key == "aiDoctrine" || key == "aiShadow" || key == "droneReconCount" || key == "droneCooldownSeconds") return " for next round";
|
||||||
|
if (key == "motorbikeCount" || key == "planeAltitudeMetres" || key == "planeReplacementSeconds" || key == "planeSectorSeconds" || key == "planeReconEnabled" || key == "fieldCampCount" || key == "fieldHospitalCount" || key == "startWeaponCount" || key == "startMagazineCount" || key == "objectGuardCount" || key == "objectGuardEvery" || key == "objectGuardHQMode" || key == "hunterSpawnDistanceMetres" || key == "roadblockCount" || key == "largeRoadblockCount" || key == "mainRoadWidthMetres") return " for next round";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
protected void SettingCommand(ERR_Settings settings, string key, array<string> parts, array<string> replies)
|
protected void SettingCommand(ERR_Settings settings, string key, array<string> parts, array<string> replies)
|
||||||
@@ -220,6 +267,8 @@ class ERR_AdminService
|
|||||||
if (topic == "time" || topic == "mission")
|
if (topic == "time" || topic == "mission")
|
||||||
{
|
{
|
||||||
replies.Insert("/esc mission radio show|set N|random | mission abandon");
|
replies.Insert("/esc mission radio show|set N|random | mission abandon");
|
||||||
|
replies.Insert("/esc mission selfepi show|set 0|1; allow unconscious self-injection with Space. Disabled by default.");
|
||||||
|
replies.Insert("/esc mission restartempty show|set on|off | mission emptyhours show|set 0..168; applies now, zero hours disables idle restarts.");
|
||||||
replies.Insert("/esc mission doctrine show|set current|coordinated | mission aishadow show|set off|on; next round only.");
|
replies.Insert("/esc mission doctrine show|set current|coordinated | mission aishadow show|set off|on; next round only.");
|
||||||
replies.Insert("/esc mission start show|set prison|crash: save the next round start; current round unchanged.");
|
replies.Insert("/esc mission start show|set prison|crash: save the next round start; current round unchanged.");
|
||||||
replies.Insert("/esc mission startweapons show|set 0..12 | mission startammo show|set 0..48; shared backpack, next round.");
|
replies.Insert("/esc mission startweapons show|set 0..12 | mission startammo show|set 0..48; shared backpack, next round.");
|
||||||
@@ -230,6 +279,7 @@ class ERR_AdminService
|
|||||||
}
|
}
|
||||||
if (topic == "intel")
|
if (topic == "intel")
|
||||||
{
|
{
|
||||||
|
replies.Insert("/esc intel sites show|set on|off; show anonymous site positions and let intel identify their types.");
|
||||||
replies.Insert("/esc intel reveal show|set N|help (0-100); affects newly recovered documents immediately.");
|
replies.Insert("/esc intel reveal show|set N|help (0-100); affects newly recovered documents immediately.");
|
||||||
replies.Insert("AI carrying and reroll commands require the Intel addon.");
|
replies.Insert("AI carrying and reroll commands require the Intel addon.");
|
||||||
return;
|
return;
|
||||||
@@ -319,6 +369,7 @@ class ERR_AdminService
|
|||||||
if (!key.IsEmpty())
|
if (!key.IsEmpty())
|
||||||
{
|
{
|
||||||
SettingCommand(mode.Settings(), key, parts, replies);
|
SettingCommand(mode.Settings(), key, parts, replies);
|
||||||
|
if (key == "showAllSites") mode.PublishSiteVisibility();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class ERR_AdminSession
|
|||||||
protected int m_Cursor;
|
protected int m_Cursor;
|
||||||
protected string m_ItemAddon;
|
protected string m_ItemAddon;
|
||||||
protected int m_ItemPage;
|
protected int m_ItemPage;
|
||||||
|
protected int m_ItemFilter;
|
||||||
|
protected string m_ItemQuery;
|
||||||
protected float m_LastRequest = -1000;
|
protected float m_LastRequest = -1000;
|
||||||
protected float m_LastSnapshot = -1000;
|
protected float m_LastSnapshot = -1000;
|
||||||
protected float m_LastLog = -1000;
|
protected float m_LastLog = -1000;
|
||||||
@@ -68,11 +70,38 @@ class ERR_AdminSession
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
array<string> replies = {};
|
array<string> replies = {};
|
||||||
if (!ItemCatalogCommand(arguments, replies) && !JournalCommand(arguments, replies) && !m_Tools.Execute(m_Mode, m_Controller, arguments, replies))
|
if (!StartBackpackCommand(arguments, replies) && !ItemCatalogCommand(arguments, replies) && !VehicleCatalogCommand(arguments, replies) && !JournalCommand(arguments, replies) && !m_Tools.Execute(m_Mode, m_Controller, arguments, replies))
|
||||||
m_Mode.Admin().Execute(m_Mode, true, arguments, replies);
|
m_Mode.Admin().Execute(m_Mode, true, arguments, replies);
|
||||||
foreach (string reply : replies) m_Controller.ERR_AdminDeliverReply(m_Token, reply, menu);
|
foreach (string reply : replies) m_Controller.ERR_AdminDeliverReply(m_Token, reply, menu);
|
||||||
if (menu) Snapshot(true);
|
if (menu) Snapshot(true);
|
||||||
}
|
}
|
||||||
|
protected bool StartBackpackCommand(string arguments, array<string> replies)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; arguments.Split(" ", parts, true);
|
||||||
|
if (parts.IsEmpty() || parts[0] != "starter") return false;
|
||||||
|
ERR_StartBackpack supplies = GetGame().ERR_StartingSupplies();
|
||||||
|
bool saved;
|
||||||
|
if (parts.Count() == 3 && parts[1] == "mode" && (parts[2] == "default" || parts[2] == "custom")) saved = supplies.SetMode(parts[2] == "custom");
|
||||||
|
else if ((parts.Count() == 3 || parts.Count() == 4) && parts[1] == "remove")
|
||||||
|
{
|
||||||
|
string removeDestination = "backpack"; if (parts.Count() == 4) removeDestination = parts[3];
|
||||||
|
saved = supplies.Remove(parts[2], removeDestination);
|
||||||
|
}
|
||||||
|
else if ((parts.Count() == 5 || parts.Count() == 6) && parts[1] == "set")
|
||||||
|
{
|
||||||
|
ERR_ServerItemCatalog catalog = GetGame().ERR_ServerItems(); catalog.Start(m_Mode);
|
||||||
|
int count;
|
||||||
|
if (catalog.Contains(parts[2], parts[3]) && ERR_CommandArguments.Integer(parts[4], count))
|
||||||
|
{
|
||||||
|
ERR_ServerItem item = catalog.Item(parts[3]);
|
||||||
|
string destination = "backpack"; if (parts.Count() == 6) destination = parts[5];
|
||||||
|
if (item) saved = supplies.Set(item.Prefab, count, destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (saved) replies.Insert("Starting supplies saved for next round. Custom contents are used only when Custom is selected.");
|
||||||
|
else replies.Insert("Not saved. Choose a catalog item and quantity 0-48; maximum 32 entries and 64 items across both destinations. Check configuration if read-only.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// Per-session paging: another administrator cannot change this menu's selection.
|
// Per-session paging: another administrator cannot change this menu's selection.
|
||||||
protected bool ItemCatalogCommand(string arguments, array<string> replies)
|
protected bool ItemCatalogCommand(string arguments, array<string> replies)
|
||||||
{
|
{
|
||||||
@@ -80,6 +109,22 @@ class ERR_AdminSession
|
|||||||
if (parts.IsEmpty() || parts[0] != "items") return false;
|
if (parts.IsEmpty() || parts[0] != "items") return false;
|
||||||
int page;
|
int page;
|
||||||
ERR_ServerItemCatalog catalog = GetGame().ERR_ServerItems(); catalog.Start(m_Mode);
|
ERR_ServerItemCatalog catalog = GetGame().ERR_ServerItems(); catalog.Start(m_Mode);
|
||||||
|
if (parts.Count() == 4 && parts[1] == "mod" && catalog.Find(parts[2]) && (parts[3] == "0" || parts[3] == "1"))
|
||||||
|
{
|
||||||
|
if (GetGame().ERR_ItemSelections().SetSwitch(parts[2], "mod", parts[3] == "1")) replies.Insert("Mod selection saved for future random equipment and civilian vehicles. Individual choices are remembered.");
|
||||||
|
else replies.Insert("Could not save mod selection. Previous choices retained.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (parts.Count() >= 5 && parts[1] == "browse" && catalog.Find(parts[2]))
|
||||||
|
{
|
||||||
|
int filter;
|
||||||
|
if (!ERR_CommandArguments.Integer(parts[3], page) || page < 0 || page > 2730 || !ERR_CommandArguments.Integer(parts[4], filter) || filter < 0 || filter > 2) return true;
|
||||||
|
string query;
|
||||||
|
for (int q = 5; q < parts.Count(); q++) { if (!query.IsEmpty()) query += " "; query += parts[q]; }
|
||||||
|
if (query.Length() > 64) return true;
|
||||||
|
m_ItemAddon = parts[2]; m_ItemPage = page; m_ItemFilter = filter; m_ItemQuery = query;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (parts.Count() == 4 && parts[1] == "preset")
|
if (parts.Count() == 4 && parts[1] == "preset")
|
||||||
{
|
{
|
||||||
if (GetGame().ERR_ItemSelections().Preset(parts[2], parts[3])) replies.Insert("Preset " + parts[2] + " completed: " + parts[3] + ". Future random equipment uses the saved selection.");
|
if (GetGame().ERR_ItemSelections().Preset(parts[2], parts[3])) replies.Insert("Preset " + parts[2] + " completed: " + parts[3] + ". Future random equipment uses the saved selection.");
|
||||||
@@ -102,7 +147,7 @@ class ERR_AdminSession
|
|||||||
}
|
}
|
||||||
if (parts.Count() != 4 || parts[1] != "list" || !catalog.Find(parts[2]) || !ERR_CommandArguments.Integer(parts[3], page) || page < 0 || page > 2730)
|
if (parts.Count() != 4 || parts[1] != "list" || !catalog.Find(parts[2]) || !ERR_CommandArguments.Integer(parts[3], page) || page < 0 || page > 2730)
|
||||||
{ replies.Insert("Choose a loaded server mod in Items, then press Show items."); return true; }
|
{ replies.Insert("Choose a loaded server mod in Items, then press Show items."); return true; }
|
||||||
m_ItemAddon = parts[2]; m_ItemPage = page;
|
m_ItemAddon = parts[2]; m_ItemPage = page; m_ItemFilter = 0; m_ItemQuery = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
protected bool JournalCommand(string arguments, array<string> replies)
|
protected bool JournalCommand(string arguments, array<string> replies)
|
||||||
@@ -132,10 +177,14 @@ class ERR_AdminSession
|
|||||||
if (key == "convoyCount" || key == "startTimeMinutes" || key == "timeMultiplier" || key == "startDateCode" || key == "weatherProfile") continue;
|
if (key == "convoyCount" || key == "startTimeMinutes" || key == "timeMultiplier" || key == "startDateCode" || key == "weatherProfile") continue;
|
||||||
if (m_Mode.Settings().Get(key) == -1) values.Insert("resolved_" + key + "=" + m_Mode.Settings().Runtime(key).ToString());
|
if (m_Mode.Settings().Get(key) == -1) values.Insert("resolved_" + key + "=" + m_Mode.Settings().Runtime(key).ToString());
|
||||||
}
|
}
|
||||||
|
if (m_Mode.Discovery()) values.Insert("radioIntelProgress=" + m_Mode.Discovery().RadioIntelStatus());
|
||||||
m_Mode.Admin().Capabilities(values);
|
m_Mode.Admin().Capabilities(values);
|
||||||
ERR_RecommendedAddons.Snapshot(m_Mode, values);
|
ERR_RecommendedAddons.Snapshot(m_Mode, values);
|
||||||
GetGame().ERR_ServerItems().Snapshot(m_Mode, values, m_ItemAddon, m_ItemPage);
|
GetGame().ERR_ServerItems().Snapshot(m_Mode, values, m_ItemAddon, m_ItemPage, m_ItemFilter, m_ItemQuery);
|
||||||
|
GetGame().ERR_ServerVehicles().Snapshot(values, m_VehicleAddon, m_VehiclePage, m_VehicleFilter, m_VehicleQuery, m_VehicleRole);
|
||||||
|
GetGame().ERR_StartingSupplies().Snapshot(values);
|
||||||
m_Mode.Admin().Execute(m_Mode, true, "status", status);
|
m_Mode.Admin().Execute(m_Mode, true, "status", status);
|
||||||
|
if (m_Mode.CrashSites()) status.Insert(m_Mode.CrashSites().Status());
|
||||||
m_Controller.ERR_AdminDeliverSnapshot(m_Token, true, values, status);
|
m_Controller.ERR_AdminDeliverSnapshot(m_Token, true, values, status);
|
||||||
}
|
}
|
||||||
void Log(int cursor, bool latest)
|
void Log(int cursor, bool latest)
|
||||||
@@ -180,4 +229,38 @@ class ERR_AdminSession
|
|||||||
m_Tools.Stop();
|
m_Tools.Stop();
|
||||||
if (m_Mode) m_Mode.OnStop().Remove(Stop);
|
if (m_Mode) m_Mode.OnStop().Remove(Stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected string m_VehicleAddon;
|
||||||
|
protected int m_VehiclePage;
|
||||||
|
protected int m_VehicleFilter;
|
||||||
|
protected int m_VehicleRole;
|
||||||
|
protected string m_VehicleQuery;
|
||||||
|
protected bool VehicleCatalogCommand(string arguments, array<string> replies)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; arguments.Split(" ", parts, true);
|
||||||
|
if (parts.IsEmpty() || parts[0] != "vehicles") return false;
|
||||||
|
ERR_ServerVehicleCatalog catalog = GetGame().ERR_ServerVehicles(); catalog.Start();
|
||||||
|
if (parts.Count() == 6 && parts[1] == "role" && catalog.Find(parts[2]))
|
||||||
|
{
|
||||||
|
int role;
|
||||||
|
if (!ERR_CommandArguments.Integer(parts[3], role) || role < 0 || role > 4 || (parts[5] != "0" && parts[5] != "1")) return true;
|
||||||
|
if (parts[4] != "*" && (!catalog.Contains(parts[2], parts[4]) || (parts[5] == "1" && !catalog.Capable(parts[4], role)))) return true;
|
||||||
|
if (GetGame().ERR_ItemSelections().SetVehicleRole(parts[2], parts[4], role, parts[5] == "1")) replies.Insert("Vehicle assignment saved for future spawns. Existing vehicles stay.");
|
||||||
|
else replies.Insert("Could not save assignment. Previous choices retained.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (parts.Count() >= 6 && parts[1] == "browse" && catalog.Find(parts[2]))
|
||||||
|
{
|
||||||
|
int page, filter, role;
|
||||||
|
if (!ERR_CommandArguments.Integer(parts[3], page) || page < 0 || page > 2730 || !ERR_CommandArguments.Integer(parts[4], filter) || filter < 0 || filter > 2 || !ERR_CommandArguments.Integer(parts[5], role) || role < 0 || role > 4) return true;
|
||||||
|
string query;
|
||||||
|
for (int q = 6; q < parts.Count(); q++) { if (!query.IsEmpty()) query += " "; query += parts[q]; }
|
||||||
|
if (query.Length() > 64) return true;
|
||||||
|
m_VehicleAddon = parts[2]; m_VehiclePage = page; m_VehicleFilter = filter; m_VehicleQuery = query; m_VehicleRole = role;
|
||||||
|
replies.Insert("Vehicle list updated. Assignments apply to future spawns.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
replies.Insert("Choose a mod in Content / Vehicles, then choose a use, then assign vehicles.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ERR_AirfieldPlacement
|
|||||||
}
|
}
|
||||||
static bool Clear(vector position)
|
static bool Clear(vector position)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || position[1] < 2 || ChimeraWorldUtils.TryGetWaterSurfaceSimple(GetGame().GetWorld(), position)) return false;
|
if (!Replication.IsServer() || !ERR_Actors.DryGround(position)) return false;
|
||||||
ERR_AirfieldPlacement survey = new ERR_AirfieldPlacement();
|
ERR_AirfieldPlacement survey = new ERR_AirfieldPlacement();
|
||||||
array<vector> authored = {};
|
array<vector> authored = {};
|
||||||
AuthoredAirports(authored);
|
AuthoredAirports(authored);
|
||||||
@@ -49,12 +49,12 @@ class ERR_AirfieldPlacement
|
|||||||
// Same aircraft footprint/vertical sweep, without requiring airport scenery.
|
// Same aircraft footprint/vertical sweep, without requiring airport scenery.
|
||||||
static bool ClearGround(vector position)
|
static bool ClearGround(vector position)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || ChimeraWorldUtils.TryGetWaterSurfaceSimple(GetGame().GetWorld(), position)) return false;
|
if (!Replication.IsServer() || !ERR_Actors.DryGround(position)) return false;
|
||||||
for (int edge = 0; edge < 4; edge++)
|
for (int edge = 0; edge < 4; edge++)
|
||||||
{
|
{
|
||||||
float side = edge * Math.PI / 2;
|
float side = edge * Math.PI / 2;
|
||||||
vector sample = position + Vector(Math.Cos(side) * 14, 0, Math.Sin(side) * 14);
|
vector sample = position + Vector(Math.Cos(side) * 14, 0, Math.Sin(side) * 14);
|
||||||
if (Math.AbsFloat(SCR_TerrainHelper.GetTerrainY(sample) - position[1]) > 0.8) return false;
|
if (!ERR_Actors.DryGround(sample) || Math.AbsFloat(SCR_TerrainHelper.GetTerrainY(sample) - position[1]) > 0.8) return false;
|
||||||
}
|
}
|
||||||
if (!SCR_WorldTools.TraceCilinderUtil(position + "0 2.5 0", 40, 4, TraceFlags.ENTS)) return false;
|
if (!SCR_WorldTools.TraceCilinderUtil(position + "0 2.5 0", 40, 4, TraceFlags.ENTS)) return false;
|
||||||
TraceBox clearance = new TraceBox();
|
TraceBox clearance = new TraceBox();
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
// Generated by tools/build_bundled_speech.py from docs/bundled-speech.json.
|
||||||
|
// Only these packaged graphs are accepted as local speech sources.
|
||||||
|
class ERR_BakedSpeech
|
||||||
|
{
|
||||||
|
static array<string> Sources() { return {"baked:welcome", "baked:soldier_1001", "baked:soldier_1002", "baked:soldier_1003", "baked:soldier_1004", "baked:soldier_1005", "baked:soldier_1100", "baked:soldier_1101", "baked:soldier_1102", "baked:soldier_1103", "baked:soldier_1104", "baked:soldier_1105", "baked:soldier_1200", "baked:soldier_1201", "baked:soldier_1202", "baked:soldier_1203", "baked:soldier_1204", "baked:soldier_1205", "baked:soldier_clear", "baked:soldier_moving", "baked:soldier_covering", "baked:soldier_reloading", "baked:soldier_under_fire", "baked:soldier_no_ammo", "baked:soldier_engaging", "baked:soldier_target_down", "baked:soldier_target_lost", "baked:radio_01", "baked:radio_02", "baked:radio_03", "baked:radio_04", "baked:radio_05", "baked:radio_06", "baked:radio_07", "baked:radio_08", "baked:radio_09", "baked:radio_10"}; }
|
||||||
|
static string Welcome() { return "baked:welcome"; }
|
||||||
|
static string WelcomeText() { return "Welcome to Escape Reintroduced. Work together, stay alert, and find your way off the island. Good luck."; }
|
||||||
|
static ResourceName Graph(string source)
|
||||||
|
{
|
||||||
|
switch (source)
|
||||||
|
{
|
||||||
|
case "baked:welcome": return "{3B55F836F9B6D20C}Sounds/ERR/Speech/welcome.acp";
|
||||||
|
case "baked:soldier_1001": return "{3DF753B659A184FB}Sounds/ERR/Speech/soldier_1001.acp";
|
||||||
|
case "baked:soldier_1002": return "{B1B78A9E50D41FD5}Sounds/ERR/Speech/soldier_1002.acp";
|
||||||
|
case "baked:soldier_1003": return "{FEE47650B627484E}Sounds/ERR/Speech/soldier_1003.acp";
|
||||||
|
case "baked:soldier_1004": return "{2FA4DC16F80F04FE}Sounds/ERR/Speech/soldier_1004.acp";
|
||||||
|
case "baked:soldier_1005": return "{5F3C22AA392DAE36}Sounds/ERR/Speech/soldier_1005.acp";
|
||||||
|
case "baked:soldier_1100": return "{AD2DC2C52E226AA7}Sounds/ERR/Speech/soldier_1100.acp";
|
||||||
|
case "baked:soldier_1101": return "{AE2E3AA19209018D}Sounds/ERR/Speech/soldier_1101.acp";
|
||||||
|
case "baked:soldier_1102": return "{74617A1D01426F95}Sounds/ERR/Speech/soldier_1102.acp";
|
||||||
|
case "baked:soldier_1103": return "{6B5037B1DEEB3FCB}Sounds/ERR/Speech/soldier_1103.acp";
|
||||||
|
case "baked:soldier_1104": return "{0C8AE411366B20EB}Sounds/ERR/Speech/soldier_1104.acp";
|
||||||
|
case "baked:soldier_1105": return "{3E1B0B6406E16734}Sounds/ERR/Speech/soldier_1105.acp";
|
||||||
|
case "baked:soldier_1200": return "{86FD331E3D1EB134}Sounds/ERR/Speech/soldier_1200.acp";
|
||||||
|
case "baked:soldier_1201": return "{A840837CC23E4A32}Sounds/ERR/Speech/soldier_1201.acp";
|
||||||
|
case "baked:soldier_1202": return "{3AF9ED4087FE442C}Sounds/ERR/Speech/soldier_1202.acp";
|
||||||
|
case "baked:soldier_1203": return "{97397F4FD27C4371}Sounds/ERR/Speech/soldier_1203.acp";
|
||||||
|
case "baked:soldier_1204": return "{EB394FAC323A0CA0}Sounds/ERR/Speech/soldier_1204.acp";
|
||||||
|
case "baked:soldier_1205": return "{69750949590AECF1}Sounds/ERR/Speech/soldier_1205.acp";
|
||||||
|
case "baked:soldier_clear": return "{ECF3257A4BFF2F53}Sounds/ERR/Speech/soldier_clear.acp";
|
||||||
|
case "baked:soldier_moving": return "{BAB1942B5DE85A52}Sounds/ERR/Speech/soldier_moving.acp";
|
||||||
|
case "baked:soldier_covering": return "{78DCA194DA126513}Sounds/ERR/Speech/soldier_covering.acp";
|
||||||
|
case "baked:soldier_reloading": return "{C51337F1692C21A7}Sounds/ERR/Speech/soldier_reloading.acp";
|
||||||
|
case "baked:soldier_under_fire": return "{8A05B1A08D5F23CC}Sounds/ERR/Speech/soldier_under_fire.acp";
|
||||||
|
case "baked:soldier_no_ammo": return "{D363E6B37331E416}Sounds/ERR/Speech/soldier_no_ammo.acp";
|
||||||
|
case "baked:soldier_engaging": return "{A700E14970CCA3E2}Sounds/ERR/Speech/soldier_engaging.acp";
|
||||||
|
case "baked:soldier_target_down": return "{388F2800E5683289}Sounds/ERR/Speech/soldier_target_down.acp";
|
||||||
|
case "baked:soldier_target_lost": return "{DA42EA7B286B20BD}Sounds/ERR/Speech/soldier_target_lost.acp";
|
||||||
|
case "baked:radio_01": return "{29F6A1A8A691488D}Sounds/ERR/Speech/radio_01.acp";
|
||||||
|
case "baked:radio_02": return "{0B1147F331AC4EDA}Sounds/ERR/Speech/radio_02.acp";
|
||||||
|
case "baked:radio_03": return "{BC0C902F48008D93}Sounds/ERR/Speech/radio_03.acp";
|
||||||
|
case "baked:radio_04": return "{E9EB0183C1ED1906}Sounds/ERR/Speech/radio_04.acp";
|
||||||
|
case "baked:radio_05": return "{4995CB641455140B}Sounds/ERR/Speech/radio_05.acp";
|
||||||
|
case "baked:radio_06": return "{E4473DD1140515F9}Sounds/ERR/Speech/radio_06.acp";
|
||||||
|
case "baked:radio_07": return "{3D3AA49576443D5D}Sounds/ERR/Speech/radio_07.acp";
|
||||||
|
case "baked:radio_08": return "{207C5D973D7EBE55}Sounds/ERR/Speech/radio_08.acp";
|
||||||
|
case "baked:radio_09": return "{DCAF67D5B901D45F}Sounds/ERR/Speech/radio_09.acp";
|
||||||
|
case "baked:radio_10": return "{8CC6CCBA6BDF1568}Sounds/ERR/Speech/radio_10.acp";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
static string Soldier(int kind)
|
||||||
|
{
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case 1001: return "baked:soldier_1001";
|
||||||
|
case 1002: return "baked:soldier_1002";
|
||||||
|
case 1003: return "baked:soldier_1003";
|
||||||
|
case 1004: return "baked:soldier_1004";
|
||||||
|
case 1005: return "baked:soldier_1005";
|
||||||
|
case 1100: return "baked:soldier_1100";
|
||||||
|
case 1101: return "baked:soldier_1101";
|
||||||
|
case 1102: return "baked:soldier_1102";
|
||||||
|
case 1103: return "baked:soldier_1103";
|
||||||
|
case 1104: return "baked:soldier_1104";
|
||||||
|
case 1105: return "baked:soldier_1105";
|
||||||
|
case 1200: return "baked:soldier_1200";
|
||||||
|
case 1201: return "baked:soldier_1201";
|
||||||
|
case 1202: return "baked:soldier_1202";
|
||||||
|
case 1203: return "baked:soldier_1203";
|
||||||
|
case 1204: return "baked:soldier_1204";
|
||||||
|
case 1205: return "baked:soldier_1205";
|
||||||
|
case ECommunicationType.REPORT_CLEAR: return "baked:soldier_clear";
|
||||||
|
case ECommunicationType.REPORT_MOVING: return "baked:soldier_moving";
|
||||||
|
case ECommunicationType.REPORT_COVERING: return "baked:soldier_covering";
|
||||||
|
case ECommunicationType.REPORT_RELOADING: return "baked:soldier_reloading";
|
||||||
|
case ECommunicationType.REPORT_UNDER_FIRE: return "baked:soldier_under_fire";
|
||||||
|
case ECommunicationType.REPORT_NO_AMMO: return "baked:soldier_no_ammo";
|
||||||
|
case ECommunicationType.REPORT_ENGAGING: return "baked:soldier_engaging";
|
||||||
|
case ECommunicationType.REPORT_TARGET_DOWN: return "baked:soldier_target_down";
|
||||||
|
case ECommunicationType.REPORT_TARGET_LOST: return "baked:soldier_target_lost";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
static string Radio(string text)
|
||||||
|
{
|
||||||
|
switch (text)
|
||||||
|
{
|
||||||
|
case "Escapists, this is rescue command. We are preparing your escape route and assembling transports with armed escort helicopters. Hold the radio position until preparations are complete. Keep your smoke grenades ready and stand by for pickup coordinates.": return "baked:radio_01";
|
||||||
|
case "Your escape route is ready. The exact pickup point is marked on your map. Gather your team there and throw a smoke grenade within 25 metres of the mark. We will send the transport and armed escorts when we see your smoke.": return "baked:radio_02";
|
||||||
|
case "Rescue command cannot establish a safe approach. Extraction has failed.": return "baked:radio_03";
|
||||||
|
case "Rescue command could not assemble the required transport capacity. Extraction has failed.": return "baked:radio_04";
|
||||||
|
case "Signal received. Launching the rescue flight. Keep the landing point clear.": return "baked:radio_05";
|
||||||
|
case "A rescue transport is down or unable to continue. Extraction has failed.": return "baked:radio_06";
|
||||||
|
case "Rescue transports are on the ground. Everyone aboard, including your wounded. Use either rescue transport if there are two. Escorts are covering the pickup. We leave when all surviving prisoners are inside.": return "baked:radio_07";
|
||||||
|
case "All survivors aboard. Lifting now. Stay inside the transport; escorts are taking you to safety.": return "baked:radio_08";
|
||||||
|
case "Smoke confirmed. Rescue transport and armed cover are inbound. Clear the marked landing point. Bring your wounded; we wait for all surviving prisoners to board.": return "baked:radio_09";
|
||||||
|
case "Smoke confirmed. Two rescue transports and armed cover are inbound. The helicopters will land separately near the marker. Use either transport and bring your wounded; both wait until everyone is aboard.": return "baked:radio_10";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
// The native action supplies held progress/cancellation. Authority rechecks the
|
||||||
|
// current player, shovel and corpse immediately before replicated deletion.
|
||||||
|
class ERR_Burial
|
||||||
|
{
|
||||||
|
static bool Dead(IEntity entity)
|
||||||
|
{
|
||||||
|
ChimeraCharacter character = ChimeraCharacter.Cast(entity);
|
||||||
|
return character && character.GetCharacterController()
|
||||||
|
&& character.GetCharacterController().GetLifeState() == ECharacterLifeState.DEAD;
|
||||||
|
}
|
||||||
|
static bool ShovelHeld(IEntity user)
|
||||||
|
{
|
||||||
|
ChimeraCharacter character = ChimeraCharacter.Cast(user);
|
||||||
|
if (!character || !character.GetCharacterController()) return false;
|
||||||
|
CharacterControllerComponent controller = character.GetCharacterController();
|
||||||
|
// Gadgets occupy the left-hand slot; GetCurrentItemInHands alone only finds
|
||||||
|
// weapons. Inventory ownership and a selected quickslot are not sufficient.
|
||||||
|
IEntity item = controller.GetAttachedGadgetAtLeftHandSlot();
|
||||||
|
if (!item) item = controller.GetCurrentItemInHands();
|
||||||
|
return item && item.FindComponent(SCR_CampaignBuildingGadgetToolComponent) != null;
|
||||||
|
}
|
||||||
|
static bool Reach(float distance)
|
||||||
|
{
|
||||||
|
return distance >= 0 && distance <= 2.5;
|
||||||
|
}
|
||||||
|
static bool Clear(IEntity user, IEntity body)
|
||||||
|
{
|
||||||
|
TraceParam trace = new TraceParam();
|
||||||
|
trace.Start = user.GetOrigin() + Vector(0, 1.2, 0);
|
||||||
|
trace.End = body.GetOrigin() + Vector(0, 0.25, 0);
|
||||||
|
trace.Exclude = user; trace.Flags = TraceFlags.ENTS | TraceFlags.WORLD;
|
||||||
|
if (GetGame().GetWorld().TraceMove(trace, null) >= 1) return true;
|
||||||
|
IEntity hit = trace.TraceEnt;
|
||||||
|
for (int depth = 0; hit && depth < 16; depth++)
|
||||||
|
{
|
||||||
|
if (hit == body) return true;
|
||||||
|
hit = hit.GetParent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
static string Rejection(IEntity user, IEntity body)
|
||||||
|
{
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
if (!mode || !mode.Active()) return "Mission is not active";
|
||||||
|
if (!ERR_Actors.Player(user) || !ERR_Actors.CanFight(user)) return "You must be alive and conscious";
|
||||||
|
if (user == body || !Dead(body)) return "Only dead bodies can be buried";
|
||||||
|
if (!ShovelHeld(user)) return "Take a shovel into your hands";
|
||||||
|
if (CompartmentAccessComponent.GetVehicleIn(user) || CompartmentAccessComponent.GetVehicleIn(body)) return "Move yourself and the body out of the vehicle";
|
||||||
|
if (!Reach(vector.Distance(user.GetOrigin(), body.GetOrigin()))) return "Move closer to the body";
|
||||||
|
if (!Clear(user, body)) return "The body is obstructed";
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
static bool Permitted(IEntity user, IEntity body)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return false;
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
return mode && mode.Players() && mode.Players().CurrentActor(user) && Rejection(user, body).IsEmpty();
|
||||||
|
}
|
||||||
|
static void Complete(IEntity user, IEntity body)
|
||||||
|
{
|
||||||
|
if (!Permitted(user, body)) return;
|
||||||
|
// Corpses and their remaining inventory disappear on every peer. Already
|
||||||
|
// queued HQ casualty reports retain their immutable attribution and position.
|
||||||
|
SCR_EntityHelper.DeleteEntityAndChildren(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_BuryBodyAction : ScriptedUserAction
|
||||||
|
{
|
||||||
|
override bool HasLocalEffectOnlyScript() { return false; }
|
||||||
|
override bool CheckOnServerFirstScript() { return true; }
|
||||||
|
override bool CanBroadcastScript() { return false; }
|
||||||
|
override bool CanBeShownScript(IEntity user)
|
||||||
|
{
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
return mode && mode.Active() && user != GetOwner() && ERR_Burial.Dead(GetOwner()) && ERR_Burial.ShovelHeld(user);
|
||||||
|
}
|
||||||
|
override bool CanBePerformedScript(IEntity user)
|
||||||
|
{
|
||||||
|
string reason = ERR_Burial.Rejection(user, GetOwner());
|
||||||
|
SetCannotPerformReason(reason);
|
||||||
|
return reason.IsEmpty();
|
||||||
|
}
|
||||||
|
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
|
||||||
|
{
|
||||||
|
if (pOwnerEntity != GetOwner() || !ERR_Burial.Permitted(pUserEntity, pOwnerEntity)) return;
|
||||||
|
// Let the native action finish before destroying its owning manager. The
|
||||||
|
// deferred callback revalidates, so duplicate completions are harmless.
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_Burial.Complete, 1, false, pUserEntity, pOwnerEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
class ERR_CommunityMapRecord
|
||||||
|
{
|
||||||
|
int wins = -1;
|
||||||
|
int losses = -1;
|
||||||
|
int completed = -1;
|
||||||
|
int partialMissions = -1;
|
||||||
|
bool Valid()
|
||||||
|
{
|
||||||
|
return wins >= 0 && wins <= 1000000000 && losses >= 0 && losses <= 1000000000 && completed == wins + losses && completed > 0 && partialMissions >= 0 && partialMissions <= completed;
|
||||||
|
}
|
||||||
|
string Line(string label)
|
||||||
|
{
|
||||||
|
int rate = Math.Round(100.0 * wins / completed);
|
||||||
|
return string.Format("%1: %2 wins | %3 failures | ", label, wins, losses) + rate.ToString() + "% win rate";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class ERR_CommunityStatistics
|
||||||
|
{
|
||||||
|
int schemaVersion;
|
||||||
|
string terrain;
|
||||||
|
string serverId;
|
||||||
|
string missionId;
|
||||||
|
string eventId;
|
||||||
|
string outcome;
|
||||||
|
ref ERR_CommunityMapRecord server;
|
||||||
|
ref ERR_CommunityMapRecord allServers;
|
||||||
|
bool Matches(string expectedServer, string expectedMission, string expectedEvent, string expectedTerrain, string expectedOutcome)
|
||||||
|
{
|
||||||
|
if (schemaVersion != 1 || serverId != expectedServer || missionId != expectedMission || eventId != expectedEvent || terrain != expectedTerrain || outcome != expectedOutcome) return false;
|
||||||
|
if (outcome != "victory" && outcome != "defeat") return false;
|
||||||
|
if (!server || !allServers || !server.Valid() || !allServers.Valid()) return false;
|
||||||
|
if (server.wins > allServers.wins || server.losses > allServers.losses) return false;
|
||||||
|
if (outcome == "victory" && server.wins == 0) return false;
|
||||||
|
if (outcome == "defeat" && server.losses == 0) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
string Summary()
|
||||||
|
{
|
||||||
|
string text = "This map's record (including this round)\n";
|
||||||
|
text += server.Line("This server") + "\n" + allServers.Line("All reporting servers");
|
||||||
|
if (allServers.partialMissions > 0) text += "\nIncludes rounds with partial statistics.";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,17 +7,18 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
Open();
|
Open();
|
||||||
ERR_AdminMenu menu = GetOpenMenu();
|
ERR_AdminMenu menu = GetOpenMenu();
|
||||||
if (menu) menu.ShowPage(3);
|
if (menu) menu.ShowPage(ERR_AdminPage.MODS);
|
||||||
}
|
}
|
||||||
override void OnMenuOpen()
|
override void OnMenuOpen()
|
||||||
{
|
{
|
||||||
super.OnMenuOpen();
|
super.OnMenuOpen();
|
||||||
Widget list = GetRootWidget().FindAnyWidget("ModList");
|
Widget list = GetRootWidget().FindAnyWidget("PackList");
|
||||||
foreach (string pack : ERR_ContentRegistry.Ids())
|
foreach (string pack : ERR_ContentRegistry.Ids())
|
||||||
{
|
{
|
||||||
Widget row = GetGame().GetWorkspace().CreateWidgets("{F092D45656A8E02B}UI/layouts/ERR/ContentRow.layout", list);
|
Widget row = GetGame().GetWorkspace().CreateWidgets("{F092D45656A8E02B}UI/layouts/ERR/ContentRow.layout", list);
|
||||||
if (!row) { Close(); return; }
|
if (!row) { Close(); return; }
|
||||||
m_ModRows.Set(pack, row);
|
m_ModRows.Set(pack, row);
|
||||||
|
row.FindAnyWidget("EditItems").SetVisible(false); row.FindAnyWidget("EditVehicles").SetVisible(false);
|
||||||
TextWidget label = TextWidget.Cast(row.FindAnyWidget("PackLabel"));
|
TextWidget label = TextWidget.Cast(row.FindAnyWidget("PackLabel"));
|
||||||
if (label) label.SetText(ERR_ContentRegistry.Label(pack));
|
if (label) label.SetText(ERR_ContentRegistry.Label(pack));
|
||||||
SCR_ButtonTextComponent enable = SCR_ButtonTextComponent.GetButtonText("Enable", row);
|
SCR_ButtonTextComponent enable = SCR_ButtonTextComponent.GetButtonText("Enable", row);
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// Curated compatible weapon/ammunition pairs. No dependency is added for AA.
|
||||||
|
class ERR_CrashLoot
|
||||||
|
{
|
||||||
|
static ResourceName Rifle(bool west)
|
||||||
|
{
|
||||||
|
if (west) return "{81EB948E6414BD6F}Prefabs/Weapons/Rifles/M14/Rifle_M21_ARTII.et";
|
||||||
|
return "{6415B7923DE28C1B}Prefabs/Weapons/Rifles/SVD/Rifle_SVD_PSO.et";
|
||||||
|
}
|
||||||
|
static ResourceName Magazine(bool west)
|
||||||
|
{
|
||||||
|
if (west) return "{627255315038152A}Prefabs/Weapons/Magazines/Magazine_762x51_M14_20rnd_SpecialBall.et";
|
||||||
|
return "{9CCB46C6EE632C1A}Prefabs/Weapons/Magazines/Magazine_762x54_SVD_10rnd_Sniper.et";
|
||||||
|
}
|
||||||
|
static ResourceName Scope(bool west)
|
||||||
|
{
|
||||||
|
if (west) return "{D2018EDB1BBF4C88}Prefabs/Weapons/Attachments/Optics/Optic_ARTII/Optic_ARTII.et";
|
||||||
|
return "{C850A33226B8F9C1}Prefabs/Weapons/Attachments/Optics/Optic_PSO1/Optic_PSO1.et";
|
||||||
|
}
|
||||||
|
static ResourceName RPG() { return "{E8A55396050E1762}Prefabs/Weapons/Launchers/RPG7/Launcher_RPG7_PGO7.et"; }
|
||||||
|
static ResourceName Rocket() { return "{609E216CBF8D0B68}Prefabs/Weapons/Ammo/Ammo_Rocket_PG7VL.et"; }
|
||||||
|
static bool Allowed(ResourceName prefab)
|
||||||
|
{
|
||||||
|
if (!GetGame().ERR_ItemSelections().Allows(prefab)) return false;
|
||||||
|
Resource resource = Resource.Load(prefab);
|
||||||
|
return resource && resource.IsValid();
|
||||||
|
}
|
||||||
|
static bool RifleAllowed(bool west) { return Allowed(Rifle(west)) && Allowed(Magazine(west)) && Allowed(Scope(west)); }
|
||||||
|
// Roll quality once per site, then quantities within that quality. Never reroll on opening.
|
||||||
|
static void RandomPlan(array<ResourceName> items)
|
||||||
|
{
|
||||||
|
QualityPlan(Math.RandomInt(0, 100), items);
|
||||||
|
}
|
||||||
|
static void QualityPlan(int quality, array<ResourceName> items)
|
||||||
|
{
|
||||||
|
items.Clear();
|
||||||
|
if (quality < 30)
|
||||||
|
{
|
||||||
|
// Poor salvage can be only a few pistol magazines, without a weapon.
|
||||||
|
if (!Allowed(ERR_Supplies.Magazine())) return;
|
||||||
|
if (Math.RandomInt(0, 2) == 1 && Allowed(ERR_Supplies.Pistol())) items.Insert(ERR_Supplies.Pistol());
|
||||||
|
int magazines = Math.RandomInt(1, 4);
|
||||||
|
for (int i = 0; i < magazines; i++) items.Insert(ERR_Supplies.Magazine());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (quality < 65) { Plan(1, Math.RandomInt(1, 4), 0, 0, items); return; }
|
||||||
|
if (quality < 90) { Plan(Math.RandomInt(2, 4), Math.RandomInt(2, 6), 15, 35, items); return; }
|
||||||
|
Plan(Math.RandomInt(4, 7), Math.RandomInt(4, 9), 50, 75, items);
|
||||||
|
}
|
||||||
|
static void Plan(int rifles, int magazines, int aaChance, int rocketChance, array<ResourceName> items)
|
||||||
|
{
|
||||||
|
items.Clear();
|
||||||
|
bool west = RifleAllowed(true), east = RifleAllowed(false);
|
||||||
|
for (int i = 0; i < rifles && (west || east); i++)
|
||||||
|
{
|
||||||
|
bool useWest = west && (!east || Math.RandomInt(0, 2) == 0);
|
||||||
|
items.Insert(Rifle(useWest));
|
||||||
|
for (int j = 0; j < magazines; j++) items.Insert(Magazine(useWest));
|
||||||
|
}
|
||||||
|
if (Math.RandomInt(0, 100) < rocketChance && Allowed(RPG()) && Allowed(Rocket())
|
||||||
|
&& Allowed("{E5E9DBBF3BFB88C6}Prefabs/Weapons/Attachments/Optics/Optic_PGO7/Optic_PGO7V3.et"))
|
||||||
|
{
|
||||||
|
items.Insert(RPG()); items.Insert(Rocket()); items.Insert(Rocket());
|
||||||
|
}
|
||||||
|
// The inspected WCS Stinger is disposable and already contains one missile.
|
||||||
|
if (Math.RandomInt(0, 100) < aaChance && Allowed(ERR_EnemyLoadoutCatalog.FIM)
|
||||||
|
&& Allowed("{517333DE6AADE624}Prefabs/Weapons/Ammo/WCS/Ammo_Missile_FIM92.et")) items.Insert(ERR_EnemyLoadoutCatalog.FIM);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
class ERR_CrashSite
|
||||||
|
{
|
||||||
|
vector Position;
|
||||||
|
IEntity Wreck;
|
||||||
|
IEntity Smoke;
|
||||||
|
IEntity Crate;
|
||||||
|
ref array<IEntity> Stock = {};
|
||||||
|
bool Ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finite server-owned scenery. Small bounded steps never block mission preparation.
|
||||||
|
class ERR_CrashSites
|
||||||
|
{
|
||||||
|
protected ERR_GameMode m_Mode;
|
||||||
|
protected ref array<ref ERR_CrashSite> m_Sites = {};
|
||||||
|
protected ref ERR_CampTerrain m_Terrain = new ERR_CampTerrain();
|
||||||
|
protected ref array<ResourceName> m_Loot = {};
|
||||||
|
protected ERR_CrashSite m_Pending;
|
||||||
|
protected InventoryStorageManagerComponent m_Inventory;
|
||||||
|
protected IEntity m_Item;
|
||||||
|
protected bool m_Accepted, m_ItemIssued, m_Started, m_Stopped;
|
||||||
|
protected int m_Target, m_Consumed, m_Attempts, m_HeliChance, m_LootMode, m_Rifles, m_Magazines, m_AA, m_Rockets;
|
||||||
|
protected int m_ItemIndex, m_ItemTicks, m_Skipped;
|
||||||
|
void ERR_CrashSites(ERR_GameMode mode) { m_Mode = mode; }
|
||||||
|
int Count() { return m_Sites.Count(); }
|
||||||
|
ERR_CrashSite At(int index) { return m_Sites[index]; }
|
||||||
|
string Status()
|
||||||
|
{
|
||||||
|
return string.Format("Crash sites: %1/%2 created; %3 unsuitable slots skipped. Finite loot; no refills.", Count(), m_Target, m_Skipped);
|
||||||
|
}
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
if (m_Started || m_Stopped || !Replication.IsServer() || !m_Mode) return;
|
||||||
|
m_Started = true;
|
||||||
|
ERR_Settings settings = m_Mode.Settings();
|
||||||
|
m_LootMode = settings.Get("crashLootMode");
|
||||||
|
m_Target = settings.Get("crashSiteCount"); m_HeliChance = settings.Get("crashHelicopterChancePercent");
|
||||||
|
m_Rifles = settings.Get("crashRifleCount"); m_Magazines = settings.Get("crashMagazineCount");
|
||||||
|
m_AA = settings.Get("crashAntiAirChancePercent"); m_Rockets = settings.Get("crashRocketChancePercent");
|
||||||
|
if (m_Target > 0) GetGame().GetCallqueue().CallLater(Step, 250, true);
|
||||||
|
}
|
||||||
|
protected bool Ready()
|
||||||
|
{
|
||||||
|
if (!m_Mode.Sites() || !GetGame().GetWorldEntity()) return false;
|
||||||
|
ERR_ScenarioComponent scenario = ERR_ScenarioComponent.Cast(m_Mode.FindComponent(ERR_ScenarioComponent));
|
||||||
|
return scenario && !scenario.BackgroundPending();
|
||||||
|
}
|
||||||
|
protected bool Separated(vector point)
|
||||||
|
{
|
||||||
|
foreach (ERR_CrashSite site : m_Sites) if (vector.DistanceXZ(site.Position, point) < 600) return false;
|
||||||
|
if (m_Mode.Sites())
|
||||||
|
for (int i = 0; i < m_Mode.Sites().Count(); i++)
|
||||||
|
{
|
||||||
|
ERR_SiteRuntime other = m_Mode.Sites().At(i);
|
||||||
|
if (other && other.Definition && vector.DistanceXZ(other.Definition.Position, point) < 250) return false;
|
||||||
|
}
|
||||||
|
array<int> players = {}; GetGame().GetPlayerManager().GetPlayers(players);
|
||||||
|
foreach (int id : players)
|
||||||
|
{
|
||||||
|
IEntity actor = GetGame().GetPlayerManager().GetPlayerControlledEntity(id);
|
||||||
|
if (actor && vector.DistanceXZ(actor.GetOrigin(), point) < 400) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected bool Survey(out vector point, out float heading)
|
||||||
|
{
|
||||||
|
vector low, high; GetGame().GetWorldEntity().GetWorldBounds(low, high);
|
||||||
|
point = Vector(Math.RandomFloat(low[0], high[0]), 0, Math.RandomFloat(low[2], high[2]));
|
||||||
|
heading = Math.RandomFloat(0, 360);
|
||||||
|
if (!Separated(point)) return false;
|
||||||
|
SCR_AIWorld ai = SCR_AIWorld.Cast(GetGame().GetAIWorld());
|
||||||
|
if (!ai || !ai.GetRoadNetworkManager()) return false;
|
||||||
|
BaseRoad road; float distance;
|
||||||
|
ai.GetRoadNetworkManager().GetClosestRoad(point, road, distance, skipNavlinks: true);
|
||||||
|
if (road && distance < 20) return false;
|
||||||
|
float floor;
|
||||||
|
// Includes UH-1 tail (-8.8m), armor, smoke and the crate at x=6m plus access.
|
||||||
|
if (!m_Terrain.Clear(point, heading, 11, 0.6, floor, 5)) return false;
|
||||||
|
point = ERR_Actors.Ground(point);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected IEntity Spawn(ResourceName resource, vector position, vector angles)
|
||||||
|
{
|
||||||
|
IEntity entity = ERR_Actors.Spawn(resource, position, angles);
|
||||||
|
if (entity) m_Mode.Own(entity);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
protected bool Create(vector point, float heading)
|
||||||
|
{
|
||||||
|
if (m_LootMode == 1) ERR_CrashLoot.RandomPlan(m_Loot);
|
||||||
|
else ERR_CrashLoot.Plan(m_Rifles, m_Magazines, m_AA, m_Rockets, m_Loot);
|
||||||
|
if (m_Loot.IsEmpty() && m_LootMode == 0) return false;
|
||||||
|
ERR_CrashSite site = new ERR_CrashSite(); site.Position = point;
|
||||||
|
ResourceName wreck = "{56C7BD958478A96D}Prefabs/ERR/CrashArmorWreck.et";
|
||||||
|
if (Math.RandomInt(0, 100) < m_HeliChance) wreck = ERR_CrashSiteResources.WreckPrefab();
|
||||||
|
vector wreckPoint = point;
|
||||||
|
if (wreck == ERR_CrashSiteResources.WreckPrefab())
|
||||||
|
{
|
||||||
|
vector minimum, maximum;
|
||||||
|
if (ERR_CrashSiteResources.Bounds(minimum, maximum)) wreckPoint[1] = wreckPoint[1] - minimum[1];
|
||||||
|
}
|
||||||
|
site.Wreck = Spawn(wreck, wreckPoint, Vector(heading, 0, 0));
|
||||||
|
vector cratePoint = ERR_Actors.Ground(point + ERR_CampTerrain.Rotate("6 0 0", heading));
|
||||||
|
site.Crate = Spawn("{CD7E33406E1ACA1D}Prefabs/ERR/CrashLootCrate.et", cratePoint + "0 0.1 0", Vector(heading, 0, 0));
|
||||||
|
site.Smoke = Spawn("{2608501780FEE1EA}Prefabs/ERR/CrashLootSmoke.et", point + "0 1 0", "0 0 0");
|
||||||
|
if (site.Crate) m_Inventory = InventoryStorageManagerComponent.Cast(site.Crate.FindComponent(InventoryStorageManagerComponent));
|
||||||
|
BaseInventoryStorageComponent storage;
|
||||||
|
if (site.Crate) storage = BaseInventoryStorageComponent.Cast(site.Crate.FindComponent(BaseInventoryStorageComponent));
|
||||||
|
if (!site.Wreck || !site.Crate || !site.Smoke || !m_Inventory || !storage)
|
||||||
|
{
|
||||||
|
ERR_Actors.DeleteSpawned(site.Smoke); ERR_Actors.DeleteSpawned(site.Crate); ERR_Actors.DeleteSpawned(site.Wreck);
|
||||||
|
m_Inventory = null; return false;
|
||||||
|
}
|
||||||
|
ParticleEffectEntity smoke = ParticleEffectEntity.Cast(site.Smoke);
|
||||||
|
if (smoke) { smoke.SetDeleteWhenStopped(false); smoke.Play(); }
|
||||||
|
m_Inventory.AddStorage(storage);
|
||||||
|
m_Sites.Insert(site); m_Pending = site; m_ItemIndex = 0;
|
||||||
|
SCR_AIWorld ai = SCR_AIWorld.Cast(GetGame().GetAIWorld());
|
||||||
|
if (ai) ai.RequestNavmeshRebuildEntity(site.Wreck);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected void Fill()
|
||||||
|
{
|
||||||
|
if (!m_Pending.Crate || !m_Inventory) { Finish(); return; }
|
||||||
|
if (m_Item)
|
||||||
|
{
|
||||||
|
array<IEntity> items = {}; m_Inventory.GetItems(items);
|
||||||
|
InventoryItemComponent itemComponent = InventoryItemComponent.Cast(m_Item.FindComponent(InventoryItemComponent));
|
||||||
|
// A player may take the item between insertion and this confirmation tick.
|
||||||
|
// Any attached inventory slot consumes the grant; never steal it back.
|
||||||
|
if (items.Contains(m_Item) || (itemComponent && itemComponent.GetParentSlot()))
|
||||||
|
{
|
||||||
|
m_Pending.Stock.Insert(m_Item); m_Item = null; m_ItemIssued = false; m_ItemIndex++; m_ItemTicks = 0; m_Accepted = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_ItemTicks++;
|
||||||
|
if (m_ItemTicks > 12)
|
||||||
|
{
|
||||||
|
Print("Reintroduced [crash sites]: inventory rejected " + m_Loot[m_ItemIndex], LogLevel.WARNING);
|
||||||
|
ERR_Actors.DeleteSpawned(m_Item); m_Item = null; m_ItemIssued = false; m_ItemIndex++; m_ItemTicks = 0; m_Accepted = false; return;
|
||||||
|
}
|
||||||
|
if (!m_Accepted) m_Accepted = m_Inventory.TryInsertItem(m_Item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// A destroyed/consumed entity is still a spent grant, not a spawn retry.
|
||||||
|
if (m_ItemIssued) { m_ItemIssued = false; m_ItemIndex++; m_ItemTicks = 0; m_Accepted = false; return; }
|
||||||
|
if (m_ItemIndex >= m_Loot.Count()) { Finish(); return; }
|
||||||
|
ResourceName resource = m_Loot[m_ItemIndex];
|
||||||
|
if (!ERR_CrashLoot.Allowed(resource)) { m_ItemIndex++; return; }
|
||||||
|
m_ItemIssued = true;
|
||||||
|
m_Item = Spawn(resource, m_Pending.Crate.GetOrigin() + "0 0.4 0", "0 0 0");
|
||||||
|
if (!m_Item) { m_ItemIssued = false; m_ItemIndex++; }
|
||||||
|
}
|
||||||
|
protected void Finish()
|
||||||
|
{
|
||||||
|
if (m_Item)
|
||||||
|
{
|
||||||
|
InventoryItemComponent itemComponent = InventoryItemComponent.Cast(m_Item.FindComponent(InventoryItemComponent));
|
||||||
|
if (!itemComponent || !itemComponent.GetParentSlot()) ERR_Actors.DeleteSpawned(m_Item);
|
||||||
|
}
|
||||||
|
m_Item = null; m_ItemIssued = false;
|
||||||
|
if (m_Pending) m_Pending.Ready = true;
|
||||||
|
m_Pending = null; m_Inventory = null; m_Loot.Clear();
|
||||||
|
}
|
||||||
|
protected void Step()
|
||||||
|
{
|
||||||
|
if (m_Stopped || !Replication.IsServer() || !m_Mode || m_Mode != ERR_GameMode.Get() || ERR_MissionRules.Terminal(m_Mode.Phase())) { Stop(); return; }
|
||||||
|
if (!m_Mode.Active()) return;
|
||||||
|
if (m_Pending) { Fill(); return; }
|
||||||
|
if (m_Consumed >= m_Target) { Stop(); return; }
|
||||||
|
if (!Ready()) return;
|
||||||
|
int began = System.GetTickCount();
|
||||||
|
for (int sample = 0; sample < 8; sample++)
|
||||||
|
{
|
||||||
|
vector point; float heading;
|
||||||
|
m_Attempts++;
|
||||||
|
if (Survey(point, heading))
|
||||||
|
{
|
||||||
|
m_Consumed++; m_Attempts = 0;
|
||||||
|
if (!Create(point, heading)) m_Skipped++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_Attempts >= 2000)
|
||||||
|
{
|
||||||
|
m_Consumed++; m_Skipped++; m_Attempts = 0;
|
||||||
|
Print("Reintroduced [crash sites]: skipped slot after bounded terrain search", LogLevel.WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (System.GetTickCount() - began >= 4) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Stop()
|
||||||
|
{
|
||||||
|
if (m_Stopped) return;
|
||||||
|
m_Stopped = true;
|
||||||
|
if (GetGame()) GetGame().GetCallqueue().Remove(Step);
|
||||||
|
Finish();
|
||||||
|
// All scenery and issued stock remain in the round's owned-entity cleanup.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
// A first clue identifies a stable search square, not the exact objective.
|
// Normal clues use stable search squares to prevent triangulating the site.
|
||||||
// Stable grid centers prevent repeated updates from triangulating the site.
|
// The optional anonymous-site mode intentionally exposes positions, never types.
|
||||||
class ERR_DiscoveryMapRules
|
class ERR_DiscoveryMapRules
|
||||||
{
|
{
|
||||||
|
// -1 hidden, 0 anonymous exact position, 1 approximate clue, 2 identified.
|
||||||
|
static int DisplayKnowledge(int knowledge, bool prepared, bool prison, bool showAll)
|
||||||
|
{
|
||||||
|
if (prison || !prepared) return -1;
|
||||||
|
if (knowledge >= 2) return 2;
|
||||||
|
if (showAll) return 0;
|
||||||
|
if (knowledge == 1) return 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
static int Coordinate(float coordinate, int knowledge)
|
static int Coordinate(float coordinate, int knowledge)
|
||||||
{
|
{
|
||||||
if (knowledge >= 2) return Math.Round(coordinate);
|
if (knowledge == 0 || knowledge >= 2) return Math.Round(coordinate);
|
||||||
return Math.Floor(coordinate / 500.0) * 500 + 250;
|
return Math.Floor(coordinate / 500.0) * 500 + 250;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,12 +118,12 @@ modded class SCR_MapMarkerManagerComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read replicated discovery locally. A server-wide marker list never leaks
|
// Read replicated discovery and the administrator-selected visibility locally.
|
||||||
// locations which have not been recovered through gameplay.
|
// Anonymous markers never expose a site label or type before discovery.
|
||||||
modded class ERR_LocationComponent
|
modded class ERR_LocationComponent
|
||||||
{
|
{
|
||||||
protected ref ERR_DiscoveryMarker m_ERRMarker;
|
protected ref ERR_DiscoveryMarker m_ERRMarker;
|
||||||
protected int m_ERRShown;
|
protected int m_ERRShown = -1;
|
||||||
protected string m_ERRShownLabel;
|
protected string m_ERRShownLabel;
|
||||||
|
|
||||||
protected override void EOnInit(IEntity owner)
|
protected override void EOnInit(IEntity owner)
|
||||||
@@ -126,20 +135,24 @@ modded class ERR_LocationComponent
|
|||||||
protected void ERR_UpdateMarker()
|
protected void ERR_UpdateMarker()
|
||||||
{
|
{
|
||||||
if (!GetGame().GetPlayerController()) return;
|
if (!GetGame().GetPlayerController()) return;
|
||||||
if (Kind() == ERR_LocationKind.PRISON || Knowledge() < 1)
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
bool showAll = mode && mode.ShowAllSites();
|
||||||
|
int shown = ERR_DiscoveryMapRules.DisplayKnowledge(Knowledge(), Prepared(), Kind() == ERR_LocationKind.PRISON, showAll);
|
||||||
|
if (shown < 0)
|
||||||
{
|
{
|
||||||
SCR_MapMarkerManagerComponent oldManager = SCR_MapMarkerManagerComponent.GetInstance();
|
SCR_MapMarkerManagerComponent oldManager = SCR_MapMarkerManagerComponent.GetInstance();
|
||||||
if (m_ERRMarker && oldManager) oldManager.ERR_RemoveDiscoveryMarker(m_ERRMarker);
|
if (m_ERRMarker && oldManager) oldManager.ERR_RemoveDiscoveryMarker(m_ERRMarker);
|
||||||
else if (m_ERRMarker) m_ERRMarker.OnDelete();
|
else if (m_ERRMarker) m_ERRMarker.OnDelete();
|
||||||
m_ERRMarker = null; m_ERRShown = 0; m_ERRShownLabel = "";
|
m_ERRMarker = null; m_ERRShown = -1; m_ERRShownLabel = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_ERRMarker) m_ERRMarker.RefreshPresentation();
|
if (m_ERRMarker) m_ERRMarker.RefreshPresentation();
|
||||||
if (Knowledge() == m_ERRShown && Label() == m_ERRShownLabel) return;
|
if (m_ERRMarker && shown == m_ERRShown && Label() == m_ERRShownLabel) return;
|
||||||
SCR_MapMarkerManagerComponent manager = SCR_MapMarkerManagerComponent.GetInstance();
|
SCR_MapMarkerManagerComponent manager = SCR_MapMarkerManagerComponent.GetInstance();
|
||||||
if (!manager || !manager.GetMarkerConfig()) return;
|
if (!manager || !manager.GetMarkerConfig()) return;
|
||||||
string label = "Unknown location (500 m area)";
|
string label = "Unknown location (500 m area)";
|
||||||
if (Knowledge() == 2)
|
if (shown == 0) label = "Unknown site";
|
||||||
|
if (shown == 2)
|
||||||
{
|
{
|
||||||
if (!Label().IsEmpty()) label = Label();
|
if (!Label().IsEmpty()) label = Label();
|
||||||
else if (Kind() == ERR_LocationKind.RADIO) label = "Radio station";
|
else if (Kind() == ERR_LocationKind.RADIO) label = "Radio station";
|
||||||
@@ -152,18 +165,18 @@ modded class ERR_LocationComponent
|
|||||||
{
|
{
|
||||||
m_ERRMarker = new ERR_DiscoveryMarker();
|
m_ERRMarker = new ERR_DiscoveryMarker();
|
||||||
m_ERRMarker.SetType(SCR_EMapMarkerType.PLACED_CUSTOM);
|
m_ERRMarker.SetType(SCR_EMapMarkerType.PLACED_CUSTOM);
|
||||||
m_ERRMarker.SetDiscoveryPosition(Position(), Knowledge());
|
m_ERRMarker.SetDiscoveryPosition(Position(), shown);
|
||||||
m_ERRMarker.SetMarkerConfigID(0);
|
m_ERRMarker.SetMarkerConfigID(0);
|
||||||
m_ERRMarker.SetLocationIcon(Kind(), Id(), Knowledge());
|
m_ERRMarker.SetLocationIcon(Kind(), Id(), shown);
|
||||||
m_ERRMarker.SetCustomText(label);
|
m_ERRMarker.SetCustomText(label);
|
||||||
manager.ERR_InsertDiscoveryMarker(m_ERRMarker);
|
manager.ERR_InsertDiscoveryMarker(m_ERRMarker);
|
||||||
}
|
}
|
||||||
m_ERRMarker.SetDiscoveryPosition(Position(), Knowledge());
|
m_ERRMarker.SetDiscoveryPosition(Position(), shown);
|
||||||
m_ERRMarker.SetLocationIcon(Kind(), Id(), Knowledge());
|
m_ERRMarker.SetLocationIcon(Kind(), Id(), shown);
|
||||||
m_ERRMarker.SetCustomText(label);
|
m_ERRMarker.SetCustomText(label);
|
||||||
// The objective presentation performs its own normal viewport culling.
|
// The objective presentation performs its own normal viewport culling.
|
||||||
m_ERRMarker.RefreshPresentation();
|
m_ERRMarker.RefreshPresentation();
|
||||||
m_ERRShown = Knowledge();
|
m_ERRShown = shown;
|
||||||
m_ERRShownLabel = Label();
|
m_ERRShownLabel = Label();
|
||||||
}
|
}
|
||||||
protected override void OnDelete(IEntity owner)
|
protected override void OnDelete(IEntity owner)
|
||||||
|
|||||||
@@ -1,10 +1,86 @@
|
|||||||
// Base mission discovery: recovering physical documents works without companions.
|
// Base mission discovery: recovering physical documents works without companions.
|
||||||
// The Intel addon optionally assigns extra documents to enemy inventories.
|
// The Intel addon optionally assigns extra documents to enemy inventories.
|
||||||
|
class ERR_IntelDeleteCallback : ScriptedInventoryOperationCallback
|
||||||
|
{
|
||||||
|
bool Finished;
|
||||||
|
bool Succeeded;
|
||||||
|
protected void Finish(bool success) { if (!Finished) { Finished = true; Succeeded = success; } }
|
||||||
|
protected override void OnComplete() { Finish(true); }
|
||||||
|
protected override void OnFailed() { Finish(false); }
|
||||||
|
protected override void OnAllComplete() { Finish(true); }
|
||||||
|
protected override void OnAllFailed() { Finish(false); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_SpentIntelCleanup
|
||||||
|
{
|
||||||
|
IEntity Folder;
|
||||||
|
ref ERR_IntelDeleteCallback Operation;
|
||||||
|
int Attempts;
|
||||||
|
float NextAttempt;
|
||||||
|
float Deadline;
|
||||||
|
bool TimeoutReported;
|
||||||
|
}
|
||||||
|
|
||||||
class ERR_DiscoveryService
|
class ERR_DiscoveryService
|
||||||
{
|
{
|
||||||
protected ERR_GameMode m_Mode;
|
protected ERR_GameMode m_Mode;
|
||||||
protected ref set<IEntity> m_Spent = new set<IEntity>();
|
protected ref set<IEntity> m_Spent = new set<IEntity>();
|
||||||
void ERR_DiscoveryService(ERR_GameMode mode) { m_Mode = mode; }
|
protected ref array<ref ERR_SpentIntelCleanup> m_Cleanup = {};
|
||||||
|
protected int m_CleanupCursor;
|
||||||
|
protected float m_CleanupNow;
|
||||||
|
protected bool m_Stopped;
|
||||||
|
protected int m_RadioIntelRequired;
|
||||||
|
protected int m_RadioIntelIdentified;
|
||||||
|
protected bool m_RadioIntelFinalized;
|
||||||
|
protected bool m_RadioIntelUnlocked;
|
||||||
|
void ERR_DiscoveryService(ERR_GameMode mode)
|
||||||
|
{
|
||||||
|
m_Mode = mode;
|
||||||
|
// Freeze the saved setting for this round; menu edits affect the next one.
|
||||||
|
m_RadioIntelRequired = mode.Settings().Get("radioIntelSiteCount");
|
||||||
|
m_RadioIntelUnlocked = m_RadioIntelRequired == 0;
|
||||||
|
}
|
||||||
|
protected bool CountsForRadioIntel(ERR_LocationComponent location)
|
||||||
|
{
|
||||||
|
if (!location || !location.Prepared() || location.Kind() == ERR_LocationKind.RADIO || location.Kind() == ERR_LocationKind.PRISON || location.Kind() == ERR_LocationKind.EXTRACTION) return false;
|
||||||
|
ERR_SiteService sites = m_Mode.Sites();
|
||||||
|
ERR_SiteRuntime site;
|
||||||
|
if (sites) site = sites.Find(location.Id());
|
||||||
|
return !site || !site.Definition || !site.Definition.RevealOnEscape;
|
||||||
|
}
|
||||||
|
protected void RefreshRadioIntel()
|
||||||
|
{
|
||||||
|
if (m_Stopped || !m_Mode || !Replication.IsServer()) return;
|
||||||
|
array<ERR_LocationComponent> locations = {};
|
||||||
|
m_Mode.Locations(locations);
|
||||||
|
set<string> available = new set<string>();
|
||||||
|
set<string> identified = new set<string>();
|
||||||
|
foreach (ERR_LocationComponent location : locations)
|
||||||
|
{
|
||||||
|
if (!CountsForRadioIntel(location)) continue;
|
||||||
|
available.Insert(location.Id());
|
||||||
|
if (location.Knowledge() == 2) identified.Insert(location.Id());
|
||||||
|
}
|
||||||
|
m_RadioIntelIdentified = identified.Count();
|
||||||
|
// Background generation can still add eligible sites. Finalize only once
|
||||||
|
// the active world's preparation has finished, including sparse terrains.
|
||||||
|
if (!m_RadioIntelFinalized && m_Mode.Active() && !m_Mode.WorldPreparing())
|
||||||
|
{
|
||||||
|
m_RadioIntelRequired = Math.Min(m_RadioIntelRequired, available.Count());
|
||||||
|
m_RadioIntelFinalized = true;
|
||||||
|
}
|
||||||
|
if (m_RadioIntelIdentified >= m_RadioIntelRequired) m_RadioIntelUnlocked = true;
|
||||||
|
}
|
||||||
|
bool RadioIntelAllowed() { RefreshRadioIntel(); return m_RadioIntelUnlocked; }
|
||||||
|
string RadioIntelStatus()
|
||||||
|
{
|
||||||
|
RefreshRadioIntel();
|
||||||
|
string state = "locked";
|
||||||
|
if (m_RadioIntelUnlocked) state = "unlocked";
|
||||||
|
string progress = string.Format("Radio intel %1: %2 / %3 non-radio sites identified this round.", state, m_RadioIntelIdentified, m_RadioIntelRequired);
|
||||||
|
if (!m_RadioIntelFinalized) progress += " Site preparation is still in progress.";
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
// Shared ledger for recovered and administratively retired documents.
|
// Shared ledger for recovered and administratively retired documents.
|
||||||
bool IsSpent(IEntity folder) { return folder && m_Spent.Contains(folder); }
|
bool IsSpent(IEntity folder) { return folder && m_Spent.Contains(folder); }
|
||||||
bool CanMarkSpent(IEntity folder)
|
bool CanMarkSpent(IEntity folder)
|
||||||
@@ -37,14 +113,74 @@ class ERR_DiscoveryService
|
|||||||
|
|
||||||
void Tick(float now)
|
void Tick(float now)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer()) return;
|
if (!Replication.IsServer() || m_Stopped || !m_Mode || m_Mode != ERR_GameMode.Get() || !m_Mode.Active()) return;
|
||||||
array<IEntity> players = {};
|
array<IEntity> players = {};
|
||||||
ERR_Actors.Players(players);
|
ERR_Actors.Players(players);
|
||||||
|
m_CleanupNow = now;
|
||||||
foreach (IEntity player : players) Recover(player);
|
foreach (IEntity player : players) Recover(player);
|
||||||
|
// Pending callbacks are observed only; even a missing callback never
|
||||||
|
// permits a second operation against the same physical item.
|
||||||
|
int budget = Math.Min(8, m_Cleanup.Count());
|
||||||
|
while (budget-- > 0)
|
||||||
|
{
|
||||||
|
if (m_CleanupCursor >= m_Cleanup.Count()) m_CleanupCursor = 0;
|
||||||
|
if (ProcessCleanup(m_Cleanup[m_CleanupCursor], players, now)) m_Cleanup.Remove(m_CleanupCursor);
|
||||||
|
else m_CleanupCursor++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void QueueCleanup(IEntity folder, float now)
|
||||||
|
{
|
||||||
|
if (!folder || folder.FindComponent(ERR_DocumentComponent)) return;
|
||||||
|
// One request per newly spent folder; admission shares the spent-ledger
|
||||||
|
// bound. Administrative retirement does not enter this queue.
|
||||||
|
ERR_SpentIntelCleanup request = new ERR_SpentIntelCleanup();
|
||||||
|
request.Folder = folder;
|
||||||
|
request.Deadline = now + 60000;
|
||||||
|
m_Cleanup.Insert(request);
|
||||||
|
}
|
||||||
|
protected bool ProcessCleanup(ERR_SpentIntelCleanup request, array<IEntity> players, float now)
|
||||||
|
{
|
||||||
|
if (!request.Folder) return true;
|
||||||
|
if (request.Operation)
|
||||||
|
{
|
||||||
|
if (!request.Operation.Finished)
|
||||||
|
{
|
||||||
|
if (now >= request.Deadline && !request.TimeoutReported)
|
||||||
|
{
|
||||||
|
request.TimeoutReported = true;
|
||||||
|
Print("Reintroduced [intel]: spent-folder deletion still pending; no duplicate request", LogLevel.WARNING);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (request.Operation.Succeeded) return true;
|
||||||
|
request.Operation = null;
|
||||||
|
request.NextAttempt = now + 5000;
|
||||||
|
}
|
||||||
|
if (now >= request.Deadline || request.Attempts >= 3)
|
||||||
|
{
|
||||||
|
Print("Reintroduced [intel]: spent-folder cleanup expired; item retained without granting more intel", LogLevel.WARNING);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (request.Folder.FindComponent(ERR_DocumentComponent)) return true;
|
||||||
|
if (now < request.NextAttempt) return false;
|
||||||
|
foreach (IEntity player : players)
|
||||||
|
{
|
||||||
|
if (!m_Mode.Players() || !m_Mode.Players().CurrentActor(player) || !ERR_Actors.Alive(player)) continue;
|
||||||
|
if (!m_Mode.PlayerFaction() || SCR_FactionManager.SGetFaction(player) != m_Mode.PlayerFaction()) continue;
|
||||||
|
if (!ERR_InfantryAmmoTransfer.StoredUnder(request.Folder, player)) continue;
|
||||||
|
InventoryStorageManagerComponent inventory = InventoryStorageManagerComponent.Cast(player.FindComponent(InventoryStorageManagerComponent));
|
||||||
|
if (!inventory || !inventory.Contains(request.Folder)) continue;
|
||||||
|
request.Attempts++;
|
||||||
|
request.NextAttempt = now + 5000;
|
||||||
|
request.Operation = new ERR_IntelDeleteCallback();
|
||||||
|
if (!inventory.TryDeleteItem(request.Folder, request.Operation)) request.Operation = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
protected void Recover(IEntity player)
|
protected void Recover(IEntity player)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || !m_Mode || !m_Mode.Players() || !m_Mode.Players().CurrentActor(player) || !ERR_Actors.Alive(player)) return;
|
if (!Replication.IsServer() || m_Stopped || !m_Mode || !m_Mode.Players() || !m_Mode.Players().CurrentActor(player) || !ERR_Actors.Alive(player)) return;
|
||||||
if (!m_Mode.PlayerFaction() || SCR_FactionManager.SGetFaction(player) != m_Mode.PlayerFaction()) return;
|
if (!m_Mode.PlayerFaction() || SCR_FactionManager.SGetFaction(player) != m_Mode.PlayerFaction()) return;
|
||||||
InventoryStorageManagerComponent inventory = InventoryStorageManagerComponent.Cast(player.FindComponent(InventoryStorageManagerComponent));
|
InventoryStorageManagerComponent inventory = InventoryStorageManagerComponent.Cast(player.FindComponent(InventoryStorageManagerComponent));
|
||||||
if (!inventory) return;
|
if (!inventory) return;
|
||||||
@@ -60,10 +196,22 @@ class ERR_DiscoveryService
|
|||||||
array<ERR_LocationComponent> eligible = {};
|
array<ERR_LocationComponent> eligible = {};
|
||||||
ERR_DocumentComponent document = ERR_DocumentComponent.Cast(folder.FindComponent(ERR_DocumentComponent));
|
ERR_DocumentComponent document = ERR_DocumentComponent.Cast(folder.FindComponent(ERR_DocumentComponent));
|
||||||
string sealedTarget = m_Mode.Evidence().Target(folder);
|
string sealedTarget = m_Mode.Evidence().Target(folder);
|
||||||
|
bool radioAllowed = RadioIntelAllowed();
|
||||||
|
bool redirectRadio;
|
||||||
|
if (!radioAllowed && !document && !sealedTarget.IsEmpty())
|
||||||
|
{
|
||||||
|
foreach (ERR_LocationComponent target : locations)
|
||||||
|
if (target && target.Id() == sealedTarget && target.Kind() == ERR_LocationKind.RADIO) redirectRadio = true;
|
||||||
|
}
|
||||||
foreach (ERR_LocationComponent location : locations)
|
foreach (ERR_LocationComponent location : locations)
|
||||||
{
|
{
|
||||||
if (!location || location.Knowledge() >= 2) continue;
|
if (!location || location.Knowledge() >= 2) continue;
|
||||||
if (!sealedTarget.IsEmpty() && location.Id() != sealedTarget) continue;
|
if (!radioAllowed && location.Kind() == ERR_LocationKind.RADIO)
|
||||||
|
{
|
||||||
|
if (document && location.Id() == document.TargetId()) m_Mode.ERR_RadioIntelWaiting();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!redirectRadio && !sealedTarget.IsEmpty() && location.Id() != sealedTarget) continue;
|
||||||
if (document)
|
if (document)
|
||||||
{
|
{
|
||||||
if (location.Id() == document.TargetId()) eligible.Insert(location);
|
if (location.Id() == document.TargetId()) eligible.Insert(location);
|
||||||
@@ -72,15 +220,24 @@ class ERR_DiscoveryService
|
|||||||
}
|
}
|
||||||
if (eligible.IsEmpty())
|
if (eligible.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!document && !m_Mode.WorldPreparing() && MarkSpent(folder) && !mineRecovered) m_Mode.ERR_IntelExhausted(!sealedTarget.IsEmpty());
|
if (!document && radioAllowed && !m_Mode.WorldPreparing() && MarkSpent(folder))
|
||||||
|
{
|
||||||
|
QueueCleanup(folder, m_CleanupNow);
|
||||||
|
if (!mineRecovered) m_Mode.ERR_IntelExhausted(!sealedTarget.IsEmpty());
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ERR_LocationComponent chosen = eligible.GetRandomElement();
|
ERR_LocationComponent chosen = eligible.GetRandomElement();
|
||||||
if (!chosen.Discover(Math.RandomInt(0, 100), m_Mode.Settings().Runtime("intelRevealChancePercent"))) continue;
|
if (!chosen.Discover(Math.RandomInt(0, 100), m_Mode.Settings().Runtime("intelRevealChancePercent"))) continue;
|
||||||
|
if (redirectRadio) m_Mode.Evidence().Retarget(folder, chosen.Id());
|
||||||
m_Spent.Insert(folder);
|
m_Spent.Insert(folder);
|
||||||
PrintFormat("Reintroduced [intel]: player %1 recovered folder; location=%2 knowledge=%3", GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(player), chosen.Id(), chosen.Knowledge());
|
PrintFormat("Reintroduced [intel]: player %1 recovered folder; location=%2 knowledge=%3", GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(player), chosen.Id(), chosen.Knowledge());
|
||||||
|
|
||||||
|
// Preserve issued evidence: a later corpse inspection must still
|
||||||
|
// report this site's missing document after the physical item is gone.
|
||||||
|
if (!document) QueueCleanup(folder, m_CleanupNow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop() { m_Spent.Clear(); }
|
void Stop() { m_Stopped = true; m_Cleanup.Clear(); m_Spent.Clear(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ class ERR_ConsumableCombatEpinephrine : SCR_ConsumableMorphine
|
|||||||
{
|
{
|
||||||
SCR_CharacterDamageManagerComponent damage = SCR_CharacterDamageManagerComponent.Cast(target.FindComponent(SCR_CharacterDamageManagerComponent));
|
SCR_CharacterDamageManagerComponent damage = SCR_CharacterDamageManagerComponent.Cast(target.FindComponent(SCR_CharacterDamageManagerComponent));
|
||||||
if (!damage || damage.GetState() == EDamageState.DESTROYED) { failReason = SCR_EConsumableFailReason.UNDAMAGED; return false; }
|
if (!damage || damage.GetState() == EDamageState.DESTROYED) { failReason = SCR_EConsumableFailReason.UNDAMAGED; return false; }
|
||||||
|
CharacterControllerComponent controller = CharacterControllerComponent.Cast(target.FindComponent(CharacterControllerComponent));
|
||||||
|
if (controller && controller.IsUnconscious()) return true;
|
||||||
if (damage.IsBleeding()) return true;
|
if (damage.IsBleeding()) return true;
|
||||||
HitZone blood = damage.GetBloodHitZone(), resilience = damage.GetResilienceHitZone();
|
HitZone blood = damage.GetBloodHitZone(), resilience = damage.GetResilienceHitZone();
|
||||||
if ((blood && blood.GetHealthScaled() < 1) || (resilience && resilience.GetHealthScaled() < 1)) return true;
|
if ((blood && blood.GetHealthScaled() <= blood.GetDamageStateThreshold(ECharacterBloodState.FAINTING)) || (resilience && resilience.GetHealthScaled() < 1)) return true;
|
||||||
array<HitZone> zones = {}; damage.GetPhysicalHitZones(zones);
|
array<HitZone> zones = {}; damage.GetPhysicalHitZones(zones);
|
||||||
foreach (HitZone zone : zones) if (zone && zone.GetHealthScaled() < 1) return true;
|
foreach (HitZone zone : zones) if (zone && zone.GetHealthScaled() < 1) return true;
|
||||||
failReason = SCR_EConsumableFailReason.UNDAMAGED; return false;
|
failReason = SCR_EConsumableFailReason.UNDAMAGED; return false;
|
||||||
|
|||||||
@@ -33,13 +33,22 @@ class ERR_EscapeGameOverScreenInfo : SCR_BaseGameOverScreenInfo
|
|||||||
modded class SCR_GameOverScreenContentUIComponent
|
modded class SCR_GameOverScreenContentUIComponent
|
||||||
{
|
{
|
||||||
protected bool m_ERREscapeContent;
|
protected bool m_ERREscapeContent;
|
||||||
|
protected ERR_GameMode m_ERRStatisticsMode;
|
||||||
protected ERR_GameMode m_ERRFailureMode;
|
protected ERR_GameMode m_ERRFailureMode;
|
||||||
override void InitContent(SCR_GameOverScreenUIContentData endScreenUIContent)
|
override void InitContent(SCR_GameOverScreenUIContentData endScreenUIContent)
|
||||||
{
|
{
|
||||||
SCR_PlayerController.ERR_OnEscapeResultChanged().Remove(ERR_RefreshEscapeContent);
|
SCR_PlayerController.ERR_OnEscapeResultChanged().Remove(ERR_RefreshEscapeContent);
|
||||||
if (m_ERRFailureMode) m_ERRFailureMode.OnEndReasonChanged().Remove(ERR_RefreshFailureContent);
|
if (m_ERRFailureMode) m_ERRFailureMode.OnEndReasonChanged().Remove(ERR_RefreshFailureContent);
|
||||||
m_ERRFailureMode = null;
|
m_ERRFailureMode = null;
|
||||||
|
if (m_ERRStatisticsMode) m_ERRStatisticsMode.ERR_OnStatisticsChanged().Remove(ERR_RefreshStatistics);
|
||||||
|
m_ERRStatisticsMode = null;
|
||||||
super.InitContent(endScreenUIContent);
|
super.InitContent(endScreenUIContent);
|
||||||
|
if (ERR_EscapeGameOverScreenInfo.Cast(endScreenUIContent.m_GameOverInfo) || ERR_FailureGameOverScreenInfo.Cast(endScreenUIContent.m_GameOverInfo))
|
||||||
|
{
|
||||||
|
m_ERRStatisticsMode = ERR_GameMode.Get();
|
||||||
|
if (m_ERRStatisticsMode) m_ERRStatisticsMode.ERR_OnStatisticsChanged().Insert(ERR_RefreshStatistics);
|
||||||
|
ERR_RefreshStatistics();
|
||||||
|
}
|
||||||
if (ERR_FailureGameOverScreenInfo.Cast(endScreenUIContent.m_GameOverInfo))
|
if (ERR_FailureGameOverScreenInfo.Cast(endScreenUIContent.m_GameOverInfo))
|
||||||
{
|
{
|
||||||
m_ERRFailureMode = ERR_GameMode.Get();
|
m_ERRFailureMode = ERR_GameMode.Get();
|
||||||
@@ -71,10 +80,21 @@ modded class SCR_GameOverScreenContentUIComponent
|
|||||||
TextWidget debrief = TextWidget.Cast(m_wRoot.FindAnyWidget(m_sDebriefingName));
|
TextWidget debrief = TextWidget.Cast(m_wRoot.FindAnyWidget(m_sDebriefingName));
|
||||||
if (debrief) debrief.SetText(info.GetDebriefing(-1, null));
|
if (debrief) debrief.SetText(info.GetDebriefing(-1, null));
|
||||||
}
|
}
|
||||||
|
protected void ERR_RefreshStatistics()
|
||||||
|
{
|
||||||
|
if (!m_wRoot || !m_ERRStatisticsMode || m_ERRStatisticsMode != ERR_GameMode.Get()) return;
|
||||||
|
TextWidget text = TextWidget.Cast(m_wRoot.FindAnyWidget("RoundStatistics"));
|
||||||
|
if (!text) return;
|
||||||
|
string summary = m_ERRStatisticsMode.ERR_RoundSummary();
|
||||||
|
if (summary.IsEmpty()) summary = "Waiting for mission statistics...";
|
||||||
|
text.SetText(summary);
|
||||||
|
}
|
||||||
override void HandlerDeattached(Widget w)
|
override void HandlerDeattached(Widget w)
|
||||||
{
|
{
|
||||||
SCR_PlayerController.ERR_OnEscapeResultChanged().Remove(ERR_RefreshEscapeContent);
|
SCR_PlayerController.ERR_OnEscapeResultChanged().Remove(ERR_RefreshEscapeContent);
|
||||||
m_ERREscapeContent = false;
|
m_ERREscapeContent = false;
|
||||||
|
if (m_ERRStatisticsMode) m_ERRStatisticsMode.ERR_OnStatisticsChanged().Remove(ERR_RefreshStatistics);
|
||||||
|
m_ERRStatisticsMode = null;
|
||||||
if (m_ERRFailureMode) m_ERRFailureMode.OnEndReasonChanged().Remove(ERR_RefreshFailureContent);
|
if (m_ERRFailureMode) m_ERRFailureMode.OnEndReasonChanged().Remove(ERR_RefreshFailureContent);
|
||||||
m_ERRFailureMode = null;
|
m_ERRFailureMode = null;
|
||||||
super.HandlerDeattached(w);
|
super.HandlerDeattached(w);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ modded class SCR_PlayerController
|
|||||||
protected void ERR_ReceiveExtractionRadio(string text, string url)
|
protected void ERR_ReceiveExtractionRadio(string text, string url)
|
||||||
{
|
{
|
||||||
if (this != GetGame().GetPlayerController() || !ERR_GameMode.Get()) return;
|
if (this != GetGame().GetPlayerController() || !ERR_GameMode.Get()) return;
|
||||||
|
if (!ERR_GameMode.Get().ERR_RecordingsEnabled() && !ERR_BakedSpeech.Graph(url).IsEmpty()) url = "";
|
||||||
if (!url.IsEmpty()) { GetGame().ERR_PlaySpeechPreview(url, text, "Extraction radio"); return; }
|
if (!url.IsEmpty()) { GetGame().ERR_PlaySpeechPreview(url, text, "Extraction radio"); return; }
|
||||||
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
||||||
if (hints) hints.ShowCustom(text, "Extraction radio", 20);
|
if (hints) hints.ShowCustom(text, "Extraction radio", 20);
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ class ERR_RescueRules
|
|||||||
if (since < 0 || now < since) return now;
|
if (since < 0 || now < since) return now;
|
||||||
return since;
|
return since;
|
||||||
}
|
}
|
||||||
|
static float AirborneSince(bool airborne, float since, float now)
|
||||||
|
{
|
||||||
|
if (!airborne || now < 0) return -1;
|
||||||
|
if (since < 0 || now < since) return now;
|
||||||
|
return since;
|
||||||
|
}
|
||||||
|
static bool FlightComplete(float since, float now)
|
||||||
|
{
|
||||||
|
return since >= 0 && now >= since && now - since >= 30000;
|
||||||
|
}
|
||||||
static bool CanDepart(float since, float now)
|
static bool CanDepart(float since, float now)
|
||||||
{
|
{
|
||||||
return since >= 0 && now >= since && now - since >= 8000;
|
return since >= 0 && now >= since && now - since >= 8000;
|
||||||
@@ -64,7 +74,11 @@ class ERR_ExtractionService
|
|||||||
{
|
{
|
||||||
m_Stage = value; m_Mode.PublishPickupStage(value);
|
m_Stage = value; m_Mode.PublishPickupStage(value);
|
||||||
PrintFormat("Reintroduced [extraction]: stage=%1 %2", value, message);
|
PrintFormat("Reintroduced [extraction]: stage=%1 %2", value, message);
|
||||||
m_Mode.DeliverExtractionRadio(message);
|
string bundled = ERR_BakedSpeech.Radio(message);
|
||||||
|
string audio = bundled;
|
||||||
|
if (!m_Mode.ERR_RecordingsEnabled()) audio = "";
|
||||||
|
m_Mode.DeliverExtractionRadio(message, audio);
|
||||||
|
if (!bundled.IsEmpty()) { m_RadioPending = ""; return; }
|
||||||
m_RadioPending = message; m_RadioUntil = GetGame().GetWorld().GetWorldTime() + 30000;
|
m_RadioPending = message; m_RadioUntil = GetGame().GetWorld().GetWorldTime() + 30000;
|
||||||
}
|
}
|
||||||
void PreparingRoute()
|
void PreparingRoute()
|
||||||
@@ -230,6 +244,7 @@ class ERR_ExtractionService
|
|||||||
protected bool m_Stopped;
|
protected bool m_Stopped;
|
||||||
protected vector m_Center;
|
protected vector m_Center;
|
||||||
protected float m_Radius;
|
protected float m_Radius;
|
||||||
|
protected float m_AirborneSince = -1;
|
||||||
protected ERR_ExtractionState m_State;
|
protected ERR_ExtractionState m_State;
|
||||||
protected ref set<UUID> m_Escapees = new set<UUID>();
|
protected ref set<UUID> m_Escapees = new set<UUID>();
|
||||||
protected int m_ParticipantCount;
|
protected int m_ParticipantCount;
|
||||||
@@ -324,8 +339,12 @@ class ERR_ExtractionService
|
|||||||
if (m_State != ERR_ExtractionState.WAITING || !m_Assigned) return;
|
if (m_State != ERR_ExtractionState.WAITING || !m_Assigned) return;
|
||||||
if (!FleetAlive()) { Resolve(ERR_ExtractionState.LOST); return; }
|
if (!FleetAlive()) { Resolve(ERR_ExtractionState.LOST); return; }
|
||||||
if (m_Stage != 5 || phase != ERR_Phase.EXTRACTION) return;
|
if (m_Stage != 5 || phase != ERR_Phase.EXTRACTION) return;
|
||||||
|
bool airborne = !m_Transports.IsEmpty();
|
||||||
foreach (ERR_RescueFlightComponent departing : m_Transports)
|
foreach (ERR_RescueFlightComponent departing : m_Transports)
|
||||||
if (vector.DistanceXZ(departing.Aircraft().GetOrigin(), m_Pickup) < 1000 || vector.DistanceXZ(departing.Aircraft().GetOrigin(), m_Center) <= m_Radius) return;
|
if (!departing || !departing.AirborneAfterPickup()) airborne = false;
|
||||||
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
|
m_AirborneSince = ERR_RescueRules.AirborneSince(airborne, m_AirborneSince, now);
|
||||||
|
if (!ERR_RescueRules.FlightComplete(m_AirborneSince, now)) return;
|
||||||
array<ref ERR_PlayerLife> lives = {};
|
array<ref ERR_PlayerLife> lives = {};
|
||||||
m_Roster.Participants(lives);
|
m_Roster.Participants(lives);
|
||||||
foreach (ERR_PlayerLife life : lives)
|
foreach (ERR_PlayerLife life : lives)
|
||||||
@@ -355,6 +374,13 @@ class ERR_ExtractionService
|
|||||||
}
|
}
|
||||||
void Stop()
|
void Stop()
|
||||||
{
|
{
|
||||||
|
// Capture the final aircraft state before terminal cleanup releases autopilots
|
||||||
|
// and removes the AI groups. Keep the same occupied airframes until reload.
|
||||||
|
if (m_State == ERR_ExtractionState.ESCAPED)
|
||||||
|
{
|
||||||
|
foreach (ERR_RescueFlightComponent safeTransport : m_Transports) if (safeTransport) safeTransport.HoldForResults();
|
||||||
|
foreach (ERR_RescueFlightComponent safeEscort : m_Escorts) if (safeEscort && !safeEscort.Lost()) safeEscort.HoldForResults();
|
||||||
|
}
|
||||||
m_Stopped = true; m_RadioPending = ""; m_PreviousSignals.Clear();
|
m_Stopped = true; m_RadioPending = ""; m_PreviousSignals.Clear();
|
||||||
foreach (ERR_RescueFlightComponent transport : m_Transports) if (transport) transport.Release(false);
|
foreach (ERR_RescueFlightComponent transport : m_Transports) if (transport) transport.Release(false);
|
||||||
foreach (ERR_RescueFlightComponent escort : m_Escorts) if (escort) escort.Release(false);
|
foreach (ERR_RescueFlightComponent escort : m_Escorts) if (escort) escort.Release(false);
|
||||||
|
|||||||
@@ -26,6 +26,16 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
m_SelectedPlayerFaction = player; m_SelectedEnemyFaction = enemy; Replication.BumpMe();
|
m_SelectedPlayerFaction = player; m_SelectedEnemyFaction = enemy; Replication.BumpMe();
|
||||||
}
|
}
|
||||||
protected ref ERR_Settings m_Settings;
|
protected ref ERR_Settings m_Settings;
|
||||||
|
[RplProp()] protected bool m_ShowAllSites;
|
||||||
|
bool ShowAllSites() { return m_ShowAllSites; }
|
||||||
|
void PublishSiteVisibility()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || !m_Settings || m_Stopped || m_NativeEndHandled) return;
|
||||||
|
bool enabled = m_Settings.Get("showAllSites") == 1;
|
||||||
|
if (m_ShowAllSites == enabled) return;
|
||||||
|
m_ShowAllSites = enabled;
|
||||||
|
Replication.BumpMe();
|
||||||
|
}
|
||||||
[RplProp()] protected int m_StartMode;
|
[RplProp()] protected int m_StartMode;
|
||||||
protected bool m_StartModeFrozen;
|
protected bool m_StartModeFrozen;
|
||||||
protected bool m_StartPrepared;
|
protected bool m_StartPrepared;
|
||||||
@@ -55,6 +65,8 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
protected ref ERR_Performance m_Performance;
|
protected ref ERR_Performance m_Performance;
|
||||||
ERR_Performance Performance() { return m_Performance; }
|
ERR_Performance Performance() { return m_Performance; }
|
||||||
protected ref ERR_CivilianTraffic m_CivilianTraffic;
|
protected ref ERR_CivilianTraffic m_CivilianTraffic;
|
||||||
|
protected ref ERR_GarageVehicles m_GarageVehicles;
|
||||||
|
protected ref ERR_CrashSites m_CrashSites;
|
||||||
protected ref ERR_ForceLedger m_Forces = new ERR_ForceLedger();
|
protected ref ERR_ForceLedger m_Forces = new ERR_ForceLedger();
|
||||||
protected ref ERR_ForceSimulation m_ForceSimulation;
|
protected ref ERR_ForceSimulation m_ForceSimulation;
|
||||||
protected ref array<AIAgent> m_ForceAgents = {};
|
protected ref array<AIAgent> m_ForceAgents = {};
|
||||||
@@ -73,6 +85,9 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
[RplProp()]
|
[RplProp()]
|
||||||
protected string m_RecoveryStatus;
|
protected string m_RecoveryStatus;
|
||||||
protected bool m_StartedPlayers;
|
protected bool m_StartedPlayers;
|
||||||
|
protected bool m_HadConnectedPlayers;
|
||||||
|
protected bool m_EmptyRestartRequested;
|
||||||
|
protected int m_EmptySince;
|
||||||
protected ref map<int, PlayerController> m_ExhaustedInitialAdmissions = new map<int, PlayerController>();
|
protected ref map<int, PlayerController> m_ExhaustedInitialAdmissions = new map<int, PlayerController>();
|
||||||
protected bool m_Stopped;
|
protected bool m_Stopped;
|
||||||
protected bool m_NativeEndHandled;
|
protected bool m_NativeEndHandled;
|
||||||
@@ -130,6 +145,8 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
ERR_ForceLedger Forces() { return m_Forces; }
|
ERR_ForceLedger Forces() { return m_Forces; }
|
||||||
ERR_CommandService Command() { return m_Command; }
|
ERR_CommandService Command() { return m_Command; }
|
||||||
ERR_CivilianTraffic CivilianTraffic() { return m_CivilianTraffic; }
|
ERR_CivilianTraffic CivilianTraffic() { return m_CivilianTraffic; }
|
||||||
|
ERR_GarageVehicles GarageVehicles() { return m_GarageVehicles; }
|
||||||
|
ERR_CrashSites CrashSites() { return m_CrashSites; }
|
||||||
ERR_Objectives Objectives() { return m_Objectives; }
|
ERR_Objectives Objectives() { return m_Objectives; }
|
||||||
ERR_ExtractionService Extraction() { return m_Extraction; }
|
ERR_ExtractionService Extraction() { return m_Extraction; }
|
||||||
string EndReason() { return m_EndReason; }
|
string EndReason() { return m_EndReason; }
|
||||||
@@ -449,6 +466,42 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
|
|
||||||
protected string SettingsPath() { return ERR_Settings.PATH; }
|
protected string SettingsPath() { return ERR_Settings.PATH; }
|
||||||
|
|
||||||
|
// A connection can arrive and leave between server ticks, even before audit
|
||||||
|
// or spawning. Defer the population check until native disconnect cleanup ends.
|
||||||
|
void ObservePlayerDisconnect()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Stopped || m_NativeEndHandled) return;
|
||||||
|
m_HadConnectedPlayers = true;
|
||||||
|
m_EmptySince = System.GetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool CheckEmptyServerRestart()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Stopped || m_NativeEndHandled || !m_Settings) return false;
|
||||||
|
if (m_EmptyRestartRequested) return true;
|
||||||
|
PlayerManager manager = GetGame().GetPlayerManager();
|
||||||
|
if (!manager) return false;
|
||||||
|
// Count all connections, including admission and spectators, not living bodies.
|
||||||
|
if (manager.GetPlayerCount() > 0)
|
||||||
|
{
|
||||||
|
m_HadConnectedPlayers = true;
|
||||||
|
m_EmptySince = System.GetTickCount();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Real elapsed milliseconds: mission clock settings cannot accelerate this.
|
||||||
|
bool afterDisconnect = m_HadConnectedPlayers && m_Settings.Get("restartOnEmpty") == 1;
|
||||||
|
int hours = m_Settings.Get("emptyRestartHours");
|
||||||
|
if (!afterDisconnect && (hours == 0 || System.GetTickCount() - m_EmptySince < hours * 3600000)) return false;
|
||||||
|
m_EmptyRestartRequested = true;
|
||||||
|
m_EndReason = string.Format("The server has been empty for %1 hours. Restarting the mission.", hours);
|
||||||
|
if (afterDisconnect) m_EndReason = "All players disconnected. Restarting the mission.";
|
||||||
|
PrintFormat("Reintroduced [round lifecycle]: %1", m_EndReason);
|
||||||
|
// Native termination also handles PREPARING, before Transition is available.
|
||||||
|
// OnGameModeEnd stops our services; vanilla owns the scenario reload.
|
||||||
|
EndGameMode(SCR_GameModeEndData.Create(EGameOverTypes.LOOSE));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void EOnInit(IEntity owner)
|
protected override void EOnInit(IEntity owner)
|
||||||
{
|
{
|
||||||
super.EOnInit(owner);
|
super.EOnInit(owner);
|
||||||
@@ -457,7 +510,9 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
if (!System.IsConsoleApp()) GetGame().GetCallqueue().CallLater(BindLocalObserver, 250, true);
|
if (!System.IsConsoleApp()) GetGame().GetCallqueue().CallLater(BindLocalObserver, 250, true);
|
||||||
if (!System.IsConsoleApp()) GetGame().GetCallqueue().CallLater(ApplyLocalViewDistance, 1000, true);
|
if (!System.IsConsoleApp()) GetGame().GetCallqueue().CallLater(ApplyLocalViewDistance, 1000, true);
|
||||||
if (!Replication.IsServer()) return;
|
if (!Replication.IsServer()) return;
|
||||||
|
m_EmptySince = System.GetTickCount();
|
||||||
m_Settings = new ERR_Settings(SettingsPath());
|
m_Settings = new ERR_Settings(SettingsPath());
|
||||||
|
PublishSiteVisibility();
|
||||||
if (!System.IsCLIParam("errNoPerf")) m_Performance = new ERR_Performance();
|
if (!System.IsCLIParam("errNoPerf")) m_Performance = new ERR_Performance();
|
||||||
PublishViewDistance();
|
PublishViewDistance();
|
||||||
m_ContentSettings = new ERR_ContentSettings();
|
m_ContentSettings = new ERR_ContentSettings();
|
||||||
@@ -495,6 +550,12 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
m_Command = CreateCommandService();
|
m_Command = CreateCommandService();
|
||||||
m_CivilianTraffic = new ERR_CivilianTraffic(this);
|
m_CivilianTraffic = new ERR_CivilianTraffic(this);
|
||||||
OnStop().Insert(m_CivilianTraffic.Stop);
|
OnStop().Insert(m_CivilianTraffic.Stop);
|
||||||
|
m_GarageVehicles = new ERR_GarageVehicles(this);
|
||||||
|
OnStop().Insert(m_GarageVehicles.Stop);
|
||||||
|
m_GarageVehicles.Start();
|
||||||
|
m_CrashSites = new ERR_CrashSites(this);
|
||||||
|
OnStop().Insert(m_CrashSites.Stop);
|
||||||
|
m_CrashSites.Start();
|
||||||
GetGame().GetCallqueue().CallLater(ServerTick, 1000, true);
|
GetGame().GetCallqueue().CallLater(ServerTick, 1000, true);
|
||||||
GetGame().GetCallqueue().CallLater(StartScenario, 1500, false);
|
GetGame().GetCallqueue().CallLater(StartScenario, 1500, false);
|
||||||
}
|
}
|
||||||
@@ -564,6 +625,7 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
|
|
||||||
protected void ServerTick()
|
protected void ServerTick()
|
||||||
{
|
{
|
||||||
|
if (CheckEmptyServerRestart()) return;
|
||||||
if (!Replication.IsServer() || !Active()) return;
|
if (!Replication.IsServer() || !Active()) return;
|
||||||
int started;
|
int started;
|
||||||
if (m_Performance) started = m_Performance.BeginTick();
|
if (m_Performance) started = m_Performance.BeginTick();
|
||||||
@@ -618,9 +680,8 @@ class ERR_GameMode : SCR_BaseGameMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else m_NoSurvivorsSince = -1;
|
else m_NoSurvivorsSince = -1;
|
||||||
// A played round must finish after its last reserved body expires, even
|
// Empty-server restart is checked by ServerTick before tactical work.
|
||||||
// with nobody connected. Keep tactical/observer work idle until players
|
// Keep tactical/observer work idle when nobody is connected.
|
||||||
// return; a fresh unplayed round still waits without a restart loop.
|
|
||||||
if (GetGame().GetPlayerManager().GetPlayerCount() == 0) return;
|
if (GetGame().GetPlayerManager().GetPlayerCount() == 0) return;
|
||||||
if (m_Performance) perfStamp = System.GetTickCount();
|
if (m_Performance) perfStamp = System.GetTickCount();
|
||||||
array<int> connected = {};
|
array<int> connected = {};
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
class ERR_CampTerrain
|
class ERR_CampTerrain
|
||||||
{
|
{
|
||||||
protected ref array<vector> m_Airfields = {};
|
protected ref array<vector> m_Airfields = {};
|
||||||
|
protected string m_Rejection;
|
||||||
|
string Rejection() { return m_Rejection; }
|
||||||
|
protected bool Reject(string reason) { m_Rejection = reason; return false; }
|
||||||
protected bool Airport(IEntity entity)
|
protected bool Airport(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!entity || !entity.GetPrefabData()) return false;
|
if (!entity || !entity.GetPrefabData()) return false;
|
||||||
@@ -27,21 +30,19 @@ class ERR_CampTerrain
|
|||||||
}
|
}
|
||||||
bool Clear(vector center, float heading, float halfSize, float maximumRange, out float lowest, float clearanceHeight = 4)
|
bool Clear(vector center, float heading, float halfSize, float maximumRange, out float lowest, float clearanceHeight = 4)
|
||||||
{
|
{
|
||||||
|
m_Rejection = "";
|
||||||
lowest = float.MAX; float highest = -float.MAX;
|
lowest = float.MAX; float highest = -float.MAX;
|
||||||
for (int x = -1; x <= 1; x++)
|
|
||||||
for (int z = -1; z <= 1; z++)
|
|
||||||
{
|
|
||||||
vector corner = center + Rotate(Vector(x * halfSize, 0, z * halfSize), heading);
|
|
||||||
if (ChimeraWorldUtils.TryGetWaterSurfaceSimple(GetGame().GetWorld(), corner)) return false;
|
|
||||||
}
|
|
||||||
// A 2m grid covers the walls, door approach, furniture and all interior slots.
|
// A 2m grid covers the walls, door approach, furniture and all interior slots.
|
||||||
for (float dx = -halfSize; dx <= halfSize; dx += 2)
|
for (float dx = -halfSize; dx <= halfSize; dx += 2)
|
||||||
for (float dz = -halfSize; dz <= halfSize; dz += 2)
|
for (float dz = -halfSize; dz <= halfSize; dz += 2)
|
||||||
{
|
{
|
||||||
vector sample = center + Rotate(Vector(dx, 0, dz), heading);
|
vector sample = center + Rotate(Vector(dx, 0, dz), heading);
|
||||||
float height = GetGame().GetWorld().GetSurfaceY(sample[0], sample[2]);
|
float height = GetGame().GetWorld().GetSurfaceY(sample[0], sample[2]);
|
||||||
|
if (!ERR_ForceRules.Finite(height)) return Reject("invalid terrain height");
|
||||||
|
sample[1] = height;
|
||||||
|
if (ChimeraWorldUtils.TryGetWaterSurfaceSimple(GetGame().GetWorld(), sample)) return Reject("water");
|
||||||
lowest = Math.Min(lowest, height); highest = Math.Max(highest, height);
|
lowest = Math.Min(lowest, height); highest = Math.Max(highest, height);
|
||||||
if (lowest < 1 || highest - lowest > maximumRange) return false;
|
if (highest - lowest > maximumRange) return Reject("uneven ground");
|
||||||
}
|
}
|
||||||
for (float cx = -halfSize + 1; cx < halfSize; cx += 2)
|
for (float cx = -halfSize + 1; cx < halfSize; cx += 2)
|
||||||
for (float cz = -halfSize + 1; cz < halfSize; cz += 2)
|
for (float cz = -halfSize + 1; cz < halfSize; cz += 2)
|
||||||
@@ -53,33 +54,42 @@ class ERR_CampTerrain
|
|||||||
// Bounding the rotated cell conservatively also protects the exit corridor.
|
// Bounding the rotated cell conservatively also protects the exit corridor.
|
||||||
trace.Mins = "-1.42 0 -1.42"; trace.Maxs = "1.42 0.1 1.42";
|
trace.Mins = "-1.42 0 -1.42"; trace.Maxs = "1.42 0.1 1.42";
|
||||||
trace.Flags = TraceFlags.ENTS | TraceFlags.WORLD;
|
trace.Flags = TraceFlags.ENTS | TraceFlags.WORLD;
|
||||||
if (GetGame().GetWorld().TraceMove(trace, null) < 1) return false;
|
if (GetGame().GetWorld().TraceMove(trace, null) < 1) return Reject("obstructed footprint");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Site(ERR_SiteDefinition site, vector position, float heading, out float baseHeight)
|
bool Site(ERR_SiteDefinition site, vector position, float heading, out float baseHeight, float airportBuffer = 1500)
|
||||||
{
|
{
|
||||||
|
m_Rejection = "";
|
||||||
bool prison = site.Kind == ERR_LocationKind.PRISON;
|
bool prison = site.Kind == ERR_LocationKind.PRISON;
|
||||||
if (prison)
|
if (prison)
|
||||||
{
|
{
|
||||||
foreach (vector airport : m_Airfields) if (vector.DistanceXZ(position, airport) < 1500) return false;
|
foreach (vector airport : m_Airfields) if (vector.DistanceXZ(position, airport) < airportBuffer) return Reject("airport separation");
|
||||||
}
|
}
|
||||||
|
bool extraction = site.Kind == ERR_LocationKind.EXTRACTION;
|
||||||
|
// Camps must stay off roads; a helicopter pad may use clear paved ground.
|
||||||
|
// Its physical terrain, obstacle and fleet checks still decide acceptance.
|
||||||
|
if (!extraction)
|
||||||
|
{
|
||||||
SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
|
SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
|
||||||
if (!aiWorld || !aiWorld.GetRoadNetworkManager()) return false;
|
if (!aiWorld || !aiWorld.GetRoadNetworkManager()) return Reject("road network unavailable");
|
||||||
BaseRoad road; float distance;
|
BaseRoad road; float distance;
|
||||||
aiWorld.GetRoadNetworkManager().GetClosestRoad(position, road, distance, skipNavlinks: true);
|
aiWorld.GetRoadNetworkManager().GetClosestRoad(position, road, distance, skipNavlinks: true);
|
||||||
if (road && distance < 12) return false;
|
if (road && distance < 12) return Reject("road proximity");
|
||||||
if (!Clear(position, heading, 10, 0.6, baseHeight)) return false;
|
}
|
||||||
|
float maximumRange = 0.6;
|
||||||
|
if (extraction) maximumRange = 0.8;
|
||||||
|
if (!Clear(position, heading, 10, maximumRange, baseHeight)) return false;
|
||||||
if (ERR_StartSetup.IsCrash(site))
|
if (ERR_StartSetup.IsCrash(site))
|
||||||
{
|
{
|
||||||
vector offset, center; float halfSize, height;
|
vector offset, center; float halfSize, height;
|
||||||
if (!ERR_StartSetup.Geometry(offset, center, halfSize, height)) return false;
|
if (!ERR_StartSetup.Geometry(offset, center, halfSize, height)) return Reject("crash footprint unavailable");
|
||||||
float wreckFloor;
|
float wreckFloor;
|
||||||
if (!Clear(position + Rotate(center, heading), heading, halfSize, 0.6, wreckFloor, height)) return false;
|
if (!Clear(position + Rotate(center, heading), heading, halfSize, 0.6, wreckFloor, height)) return Reject("wreck area: " + m_Rejection);
|
||||||
}
|
}
|
||||||
float guardHeight;
|
float guardHeight;
|
||||||
if (site.Guarded && !Clear(position + Rotate(site.GuardOffset, heading), heading, 6, 0.6, guardHeight)) return false;
|
if (site.Guarded && !Clear(position + Rotate(site.GuardOffset, heading), heading, 6, 0.6, guardHeight)) return Reject("guard area: " + m_Rejection);
|
||||||
if (site.ResponseCount > 0 && !Clear(position + Rotate(site.ResponseOffset, heading), heading, 6, 0.6, guardHeight)) return false;
|
if (site.ResponseCount > 0 && !Clear(position + Rotate(site.ResponseOffset, heading), heading, 6, 0.6, guardHeight)) return Reject("patrol area: " + m_Rejection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,6 +100,38 @@ class ERR_GeneratedSites
|
|||||||
protected ref array<ERR_SiteDefinition> m_Pending = {};
|
protected ref array<ERR_SiteDefinition> m_Pending = {};
|
||||||
protected vector m_Low, m_High;
|
protected vector m_Low, m_High;
|
||||||
protected int m_Index, m_Attempts, m_Began;
|
protected int m_Index, m_Attempts, m_Began;
|
||||||
|
protected int m_NextDiagnostic;
|
||||||
|
protected ref map<string, int> m_Rejections = new map<string, int>();
|
||||||
|
protected void RecordRejection(string reason)
|
||||||
|
{
|
||||||
|
if (reason.IsEmpty()) reason = "unspecified terrain clearance";
|
||||||
|
int count;
|
||||||
|
m_Rejections.Find(reason, count);
|
||||||
|
m_Rejections.Set(reason, count + 1);
|
||||||
|
}
|
||||||
|
protected string RejectionSummary()
|
||||||
|
{
|
||||||
|
string summary;
|
||||||
|
foreach (string reason, int count : m_Rejections)
|
||||||
|
{
|
||||||
|
if (!summary.IsEmpty()) summary += "; ";
|
||||||
|
summary += reason + "=" + count.ToString();
|
||||||
|
}
|
||||||
|
if (summary.IsEmpty()) return "none recorded";
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
protected void ReportSearch(ERR_SiteDefinition site, string stage)
|
||||||
|
{
|
||||||
|
PrintFormat("Reintroduced [placement search]: stage=%1 site=%2 (%3) attempts=%4 elapsedMs=%5 failed/deferred checks: %6", stage, site.Id, site.Label, m_Attempts, System.GetTickCount() - m_Began, RejectionSummary());
|
||||||
|
}
|
||||||
|
protected void ReportProgress(ERR_SiteDefinition site)
|
||||||
|
{
|
||||||
|
int now = System.GetTickCount();
|
||||||
|
if (now - m_Began < 30000 || now < m_NextDiagnostic) return;
|
||||||
|
ReportSearch(site, "still searching");
|
||||||
|
m_NextDiagnostic = now + 30000;
|
||||||
|
}
|
||||||
|
protected void ClearDiagnostics() { m_Rejections.Clear(); m_NextDiagnostic = 0; }
|
||||||
protected bool m_Started;
|
protected bool m_Started;
|
||||||
protected ERR_PrepareResult m_Result = ERR_PrepareResult.PENDING;
|
protected ERR_PrepareResult m_Result = ERR_PrepareResult.PENDING;
|
||||||
protected string m_Error;
|
protected string m_Error;
|
||||||
@@ -144,6 +186,7 @@ class ERR_GeneratedSites
|
|||||||
if (candidate.Kind == ERR_LocationKind.RADIO && other.Kind == ERR_LocationKind.PRISON) minimum = 1000;
|
if (candidate.Kind == ERR_LocationKind.RADIO && other.Kind == ERR_LocationKind.PRISON) minimum = 1000;
|
||||||
if (vector.DistanceXZ(position, other.Position) < minimum) return false;
|
if (vector.DistanceXZ(position, other.Position) < minimum) return false;
|
||||||
if (candidate.Kind == ERR_LocationKind.PRISON && other.Kind == ERR_LocationKind.EXTRACTION && vector.DistanceXZ(position, other.Position) + 100 >= ERR_GameMode.Get().EscapeRadius()) return false;
|
if (candidate.Kind == ERR_LocationKind.PRISON && other.Kind == ERR_LocationKind.EXTRACTION && vector.DistanceXZ(position, other.Position) + 100 >= ERR_GameMode.Get().EscapeRadius()) return false;
|
||||||
|
if (candidate.Kind == ERR_LocationKind.EXTRACTION && other.Kind == ERR_LocationKind.PRISON && vector.DistanceXZ(position, other.Position) + 100 >= ERR_GameMode.Get().EscapeRadius()) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -169,6 +212,10 @@ class ERR_GeneratedSites
|
|||||||
{
|
{
|
||||||
if (site.Kind != ERR_LocationKind.EXTRACTION) return true;
|
if (site.Kind != ERR_LocationKind.EXTRACTION) return true;
|
||||||
vector primary = ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.AircraftOffset, heading));
|
vector primary = ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.AircraftOffset, heading));
|
||||||
|
// Validate the primary pad before committing a random candidate, so an
|
||||||
|
// obstructed clearing is retried instead of failing later during site creation.
|
||||||
|
if (site.RequireAirfield) { if (!ERR_AirfieldPlacement.Clear(primary)) return false; }
|
||||||
|
else if (!ERR_AirfieldPlacement.ClearGround(primary)) return false;
|
||||||
return ERR_RescueLanding.Fits(primary);
|
return ERR_RescueLanding.Fits(primary);
|
||||||
}
|
}
|
||||||
ERR_PrepareResult Tick()
|
ERR_PrepareResult Tick()
|
||||||
@@ -180,6 +227,7 @@ class ERR_GeneratedSites
|
|||||||
{
|
{
|
||||||
if (m_StartupOnly && StartupReady()) return ERR_PrepareResult.PENDING;
|
if (m_StartupOnly && StartupReady()) return ERR_PrepareResult.PENDING;
|
||||||
ERR_SiteDefinition site = m_Pending[m_Index];
|
ERR_SiteDefinition site = m_Pending[m_Index];
|
||||||
|
ReportProgress(site);
|
||||||
bool fallback = m_Attempts >= 12000 || System.GetTickCount() - m_Began >= 30000;
|
bool fallback = m_Attempts >= 12000 || System.GetTickCount() - m_Began >= 30000;
|
||||||
vector position = site.Position; float heading = site.Heading;
|
vector position = site.Position; float heading = site.Heading;
|
||||||
if (!fallback)
|
if (!fallback)
|
||||||
@@ -188,22 +236,30 @@ class ERR_GeneratedSites
|
|||||||
heading = Math.RandomFloat(0, 360); m_Attempts++;
|
heading = Math.RandomFloat(0, 360); m_Attempts++;
|
||||||
}
|
}
|
||||||
float floor;
|
float floor;
|
||||||
if (Separated(site, position, fallback) && m_Terrain.Site(site, position, heading, floor) && RescueFits(site, position, heading))
|
bool fits;
|
||||||
|
if (!Separated(site, position, fallback)) RecordRejection("site spacing / escape boundary");
|
||||||
|
else if (!m_Terrain.Site(site, position, heading, floor)) RecordRejection(m_Terrain.Rejection());
|
||||||
|
else if (!RescueFits(site, position, heading)) RecordRejection("aircraft landing clearance / fleet space");
|
||||||
|
else fits = true;
|
||||||
|
if (fits)
|
||||||
{
|
{
|
||||||
position[1] = floor + 0.02;
|
position[1] = floor + 0.02;
|
||||||
site.Position = position; site.Heading = heading; site.PlacementResolved = true;
|
site.Position = position; site.Heading = heading; site.PlacementResolved = true;
|
||||||
PrintFormat("Co10 Escape Reintroduced [generated site]: id=%1 position=%2 heading=%3 attempts=%4 fallback=%5", site.Id, position, heading, m_Attempts, fallback);
|
PrintFormat("Co10 Escape Reintroduced [generated site]: id=%1 position=%2 heading=%3 attempts=%4 fallback=%5", site.Id, position, heading, m_Attempts, fallback);
|
||||||
|
ReportSearch(site, "placed"); ClearDiagnostics();
|
||||||
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
||||||
}
|
}
|
||||||
else if (fallback)
|
else if (fallback)
|
||||||
{
|
{
|
||||||
|
ReportSearch(site, "exhausted; authored fallback rejected");
|
||||||
if (SkipOptional(site))
|
if (SkipOptional(site))
|
||||||
{
|
{
|
||||||
|
ClearDiagnostics();
|
||||||
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Error = "No safe terrain or valid authored fallback for required site " + site.Id;
|
m_Error = "No safe terrain or valid authored fallback for required site " + site.Id + ". Checks: " + RejectionSummary();
|
||||||
m_Result = ERR_PrepareResult.FAILED; return m_Result;
|
m_Result = ERR_PrepareResult.FAILED; return m_Result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ class ERR_ItemPreferences
|
|||||||
for (int i = 0; i < 16; i++) if ("0123456789abcdef".IndexOf(value.Substring(i, 1)) < 0) return false;
|
for (int i = 0; i < 16; i++) if ("0123456789abcdef".IndexOf(value.Substring(i, 1)) < 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
static bool RoleKey(string key)
|
||||||
|
{
|
||||||
|
if (key.Length() != 3 && key.Length() != 18) return false;
|
||||||
|
if (key.Substring(0, 1) != "r" || "01234".IndexOf(key.Substring(1, 1)) < 0) return false;
|
||||||
|
return key.Substring(2, key.Length() - 2) == "*" || Guid(key.Substring(2, key.Length() - 2));
|
||||||
|
}
|
||||||
static bool WeightKey(string key)
|
static bool WeightKey(string key)
|
||||||
{
|
{
|
||||||
return key == "w*" || (key.Length() == 17 && key.Substring(0, 1) == "w" && Guid(key.Substring(1, 16)));
|
return key == "w*" || (key.Length() == 17 && key.Substring(0, 1) == "w" && Guid(key.Substring(1, 16)));
|
||||||
@@ -67,7 +73,7 @@ class ERR_ItemPreferences
|
|||||||
{
|
{
|
||||||
if (parts.Count() != 4 || !Name(parts[0]) || !Guid(parts[1])) return false;
|
if (parts.Count() != 4 || !Name(parts[0]) || !Guid(parts[1])) return false;
|
||||||
if (WeightKey(parts[2])) { if (!WeightValue(parts[3])) return false; }
|
if (WeightKey(parts[2])) { if (!WeightValue(parts[3])) return false; }
|
||||||
else if ((parts[2] != "*" && !Guid(parts[2])) || (parts[3] != "0" && parts[3] != "1")) return false;
|
else if ((parts[2] != "*" && parts[2] != "mod" && parts[2] != "v*" && !RoleKey(parts[2]) && !Guid(parts[2]) && !(parts[2].Length() == 17 && parts[2].StartsWith("v") && Guid(parts[2].Substring(1, 16)))) || (parts[3] != "0" && parts[3] != "1")) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (names.Count() > 17) return false;
|
if (names.Count() > 17) return false;
|
||||||
@@ -137,13 +143,91 @@ class ERR_ItemPreferences
|
|||||||
key = addon + "|*";
|
key = addon + "|*";
|
||||||
return !m_Rules.Contains(key) || m_Rules.Get(key) == 1;
|
return !m_Rules.Contains(key) || m_Rules.Get(key) == 1;
|
||||||
}
|
}
|
||||||
|
bool ModEnabled(string addon)
|
||||||
|
{
|
||||||
|
string key = addon + "|mod";
|
||||||
|
return !m_Rules.Contains(key) || m_Rules.Get(key) == 1;
|
||||||
|
}
|
||||||
|
bool VehicleEnabled(string addon, string item)
|
||||||
|
{
|
||||||
|
string key = addon + "|v" + item;
|
||||||
|
if (m_Rules.Contains(key)) return m_Rules.Get(key) == 1;
|
||||||
|
key = addon + "|v*";
|
||||||
|
return !m_Rules.Contains(key) || m_Rules.Get(key) == 1;
|
||||||
|
}
|
||||||
|
bool SetSwitch(string addon, string key, bool enabled)
|
||||||
|
{
|
||||||
|
if (!Guid(addon) || (key != "mod" && key != "v*" && !(key.Length() == 17 && key.StartsWith("v") && Guid(key.Substring(1, 16))))) return false;
|
||||||
|
array<string> next = {};
|
||||||
|
foreach (string row : m_Records)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; row.Split("|", parts, false);
|
||||||
|
if (parts.Count() == 4 && parts[0] == "active" && parts[1] == addon && (parts[2] == key || (key == "v*" && parts[2].StartsWith("v")))) continue;
|
||||||
|
next.Insert(row);
|
||||||
|
}
|
||||||
|
string value = "0"; if (enabled) value = "1";
|
||||||
|
next.Insert("active|" + addon + "|" + key + "|" + value);
|
||||||
|
return Save(next);
|
||||||
|
}
|
||||||
|
bool SetVehicleRole(string addon, string item, int role, bool enabled)
|
||||||
|
{
|
||||||
|
if (!Guid(addon) || (item != "*" && !Guid(item)) || role < 0 || role > 4) return false;
|
||||||
|
string prefix = "r" + role.ToString(), key = prefix + item;
|
||||||
|
array<string> next = {};
|
||||||
|
foreach (string row : m_Records)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; row.Split("|", parts, false);
|
||||||
|
if (parts.Count() == 4 && parts[0] == "active" && parts[1] == addon)
|
||||||
|
{
|
||||||
|
if (parts[2] == key || (item == "*" && parts[2].StartsWith(prefix))) continue;
|
||||||
|
if (enabled && (parts[2] == "v" + item || (item == "*" && parts[2].StartsWith("v")))) continue;
|
||||||
|
}
|
||||||
|
next.Insert(row);
|
||||||
|
}
|
||||||
|
string value = "0"; if (enabled) value = "1";
|
||||||
|
next.Insert("active|" + addon + "|" + key + "|" + value);
|
||||||
|
if (enabled) next.Insert("active|" + addon + "|v" + item + "|1");
|
||||||
|
return Save(next);
|
||||||
|
}
|
||||||
|
// -1 means inherit the mission's defaults. Shared-source explicit exclusions win.
|
||||||
|
int VehicleRole(string addon, string item, int role)
|
||||||
|
{
|
||||||
|
string prefix = addon + "|r" + role.ToString();
|
||||||
|
if (m_Rules.Contains(prefix + item)) return m_Rules.Get(prefix + item);
|
||||||
|
if (m_Rules.Contains(prefix + "*")) return m_Rules.Get(prefix + "*");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
bool AllowsVehicleRole(ResourceName prefab, int role, bool defaultEnabled)
|
||||||
|
{
|
||||||
|
if (role < 0 || role > 4 || !AllowsVehicle(prefab)) return false;
|
||||||
|
string item = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
bool enabled = defaultEnabled;
|
||||||
|
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
||||||
|
foreach (string project : sources)
|
||||||
|
{
|
||||||
|
if (!m_Loaded.Contains(project)) continue;
|
||||||
|
int rule = VehicleRole(m_Loaded.Get(project), item, role);
|
||||||
|
if (rule == 0) return false;
|
||||||
|
if (rule == 1) enabled = true;
|
||||||
|
}
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
bool AllowsVehicle(ResourceName prefab)
|
||||||
|
{
|
||||||
|
string item = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
if (item.IsEmpty()) return false;
|
||||||
|
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
||||||
|
foreach (string project : sources)
|
||||||
|
if (m_Loaded.Contains(project) && (!ModEnabled(m_Loaded.Get(project)) || !VehicleEnabled(m_Loaded.Get(project), item))) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
bool Allows(ResourceName prefab)
|
bool Allows(ResourceName prefab)
|
||||||
{
|
{
|
||||||
string item = ERR_TerrainCatalog.Key(prefab);
|
string item = ERR_TerrainCatalog.Key(prefab);
|
||||||
if (item.IsEmpty()) return true;
|
if (item.IsEmpty()) return true;
|
||||||
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
||||||
foreach (string project : sources)
|
foreach (string project : sources)
|
||||||
if (m_Loaded.Contains(project) && !Enabled(m_Loaded.Get(project), item)) return false;
|
if (m_Loaded.Contains(project) && (!ModEnabled(m_Loaded.Get(project)) || !Enabled(m_Loaded.Get(project), item))) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Set(string addon, string item, bool enabled)
|
bool Set(string addon, string item, bool enabled)
|
||||||
@@ -153,7 +237,7 @@ class ERR_ItemPreferences
|
|||||||
foreach (string row : m_Records)
|
foreach (string row : m_Records)
|
||||||
{
|
{
|
||||||
array<string> parts = {}; row.Split("|", parts, false);
|
array<string> parts = {}; row.Split("|", parts, false);
|
||||||
if (parts.Count() == 4 && parts[0] == "active" && parts[1] == addon && (item == "*" || parts[2] == item) && !WeightKey(parts[2])) continue;
|
if (parts.Count() == 4 && parts[0] == "active" && parts[1] == addon && (parts[2] == item || (item == "*" && (parts[2] == "*" || Guid(parts[2]))))) continue;
|
||||||
next.Insert(row);
|
next.Insert(row);
|
||||||
}
|
}
|
||||||
string value = "0"; if (enabled) value = "1";
|
string value = "0"; if (enabled) value = "1";
|
||||||
@@ -225,6 +309,6 @@ class ERR_ItemPreferences
|
|||||||
{
|
{
|
||||||
foreach (string row : m_Records) if (row != "active" && row.IndexOf("|") < 0) values.Insert("itemPreset=" + row);
|
foreach (string row : m_Records) if (row != "active" && row.IndexOf("|") < 0) values.Insert("itemPreset=" + row);
|
||||||
if (m_ReadOnly) values.Insert("itemsStorage=Read-only: preference file needs repair");
|
if (m_ReadOnly) values.Insert("itemsStorage=Read-only: preference file needs repair");
|
||||||
else values.Insert("itemsStorage=Auto-saved; applies to future random equipment. Presets include selections and probability weights for all mods.");
|
else values.Insert("itemsStorage=Auto-saved for future spawns. Presets include mod switches, item and vehicle-role choices, and equipment weights.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,11 @@ class ERR_LocationComponent : ScriptComponent
|
|||||||
bool Discover(int roll, int chance)
|
bool Discover(int roll, int chance)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || !m_Prepared || m_Knowledge >= 2) return false;
|
if (!Replication.IsServer() || !m_Prepared || m_Knowledge >= 2) return false;
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
if (mode && mode.ShowAllSites()) chance = 100;
|
||||||
int previous = m_Knowledge;
|
int previous = m_Knowledge;
|
||||||
m_Knowledge = ERR_MissionRules.Discovery(m_Knowledge, roll, chance);
|
m_Knowledge = ERR_MissionRules.Discovery(m_Knowledge, roll, chance);
|
||||||
Replication.BumpMe();
|
Replication.BumpMe();
|
||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
|
||||||
if (mode) mode.LocationDiscovered(this, previous, m_Knowledge);
|
if (mode) mode.LocationDiscovered(this, previous, m_Knowledge);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Generated by tools/build_admin_menu.py; edit ui/admin_menu/theme.json.
|
||||||
|
class ERR_MenuTheme
|
||||||
|
{
|
||||||
|
static const int NEUTRAL = 0xFF454B52;
|
||||||
|
static const int NEUTRAL_HOVER = 0xFF606870;
|
||||||
|
static const int POSITIVE = 0xFF246B3C;
|
||||||
|
static const int POSITIVE_HOVER = 0xFF31894F;
|
||||||
|
static const int NEGATIVE = 0xFF8F2929;
|
||||||
|
static const int NEGATIVE_HOVER = 0xFFB43B3B;
|
||||||
|
static const int MIXED = 0xFF805B17;
|
||||||
|
static const int READY_TEXT = 0xFF69BE8C;
|
||||||
|
static const int UNAVAILABLE_TEXT = 0xFFDC7373;
|
||||||
|
}
|
||||||
@@ -19,16 +19,33 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
GetRootWidget().Update();
|
GetRootWidget().Update();
|
||||||
if (m_Page != expected) return false;
|
if (m_Page != expected) return false;
|
||||||
|
int activeGroup = ERR_AdminMenuPages.Group(expected);
|
||||||
|
Widget content = GetRootWidget().FindAnyWidget(Pages()[expected]);
|
||||||
|
if (!content) return false;
|
||||||
|
float contentX, contentY, contentWidth, contentHeight;
|
||||||
|
content.GetScreenPos(contentX, contentY); content.GetScreenSize(contentWidth, contentHeight);
|
||||||
|
array<string> mainButtons = ERR_AdminMenuPages.MainButtons();
|
||||||
|
array<string> sidebars = ERR_AdminMenuPages.Sidebars();
|
||||||
|
for (int group = 0; group < mainButtons.Count(); group++)
|
||||||
|
{
|
||||||
|
Widget mainTab = GetRootWidget().FindAnyWidget(mainButtons[group]);
|
||||||
|
Widget marker = GetRootWidget().FindAnyWidget("Selected_" + mainButtons[group]);
|
||||||
|
Widget sidebar = GetRootWidget().FindAnyWidget(sidebars[group]);
|
||||||
|
if (!mainTab || !marker || !sidebar || !mainTab.IsVisible() || marker.IsVisible() != (group == activeGroup) || sidebar.IsVisible() != (group == activeGroup)) return false;
|
||||||
|
float x, y, width, height;
|
||||||
|
mainTab.GetScreenPos(x, y); mainTab.GetScreenSize(width, height);
|
||||||
|
if (width <= 1 || height <= 1 || y + height > contentY) return false;
|
||||||
|
}
|
||||||
for (int i = 0; i < Pages().Count(); i++)
|
for (int i = 0; i < Pages().Count(); i++)
|
||||||
{
|
{
|
||||||
Widget panel = GetRootWidget().FindAnyWidget(Pages()[i]);
|
Widget panel = GetRootWidget().FindAnyWidget(Pages()[i]);
|
||||||
Widget tab = GetRootWidget().FindAnyWidget(Navigation()[i]);
|
Widget tab = GetRootWidget().FindAnyWidget(Navigation()[i]);
|
||||||
Widget selected = GetRootWidget().FindAnyWidget("Selected_" + Navigation()[i]);
|
Widget selected = GetRootWidget().FindAnyWidget("Selected_" + Navigation()[i]);
|
||||||
if (!panel || !tab || !selected || panel.IsVisible() != (i == expected) || !tab.IsVisible() || selected.IsVisible() != (i == expected)) return false;
|
if (!panel || !tab || !selected || panel.IsVisible() != (i == expected) || selected.IsVisible() != (i == expected)) return false;
|
||||||
float x, y, width, height, px, py;
|
if (ERR_AdminMenuPages.Group(i) != activeGroup) continue;
|
||||||
tab.GetScreenPos(x, y); tab.GetScreenSize(width, height); panel.GetScreenPos(px, py);
|
float x, y, width, height;
|
||||||
if (width <= 1 || height <= 1 || (i == expected && y + height > py))
|
tab.GetScreenPos(x, y); tab.GetScreenSize(width, height);
|
||||||
{ PrintFormat("ERR ADMIN NAV BOUNDS: page=%1 tab=%2 bounds=%3,%4,%5,%6 panelY=%7", expected, i, x, y, width, height, py); return false; }
|
if (!tab.IsVisible() || width <= 1 || height <= 1 || x + width > contentX || y < contentY || y + height > contentY + contentHeight) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -114,7 +131,7 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
GetRootWidget().Update();
|
GetRootWidget().Update();
|
||||||
PrintFormat("ERR MOD MENU: page=%1 rows=%2 saved=%3 active=%4", m_Page, m_ModRows.Count(), m_ModSaved.Count(), m_ModActive.Count());
|
PrintFormat("ERR MOD MENU: page=%1 rows=%2 saved=%3 active=%4", m_Page, m_ModRows.Count(), m_ModSaved.Count(), m_ModActive.Count());
|
||||||
if (m_Page != 3 || m_ModRows.Count() != ERR_ContentRegistry.Ids().Count()) return false;
|
if (m_Page != ERR_AdminPage.PACKS || m_ModRows.Count() != ERR_ContentRegistry.Ids().Count()) return false;
|
||||||
foreach (string pack, Widget row : m_ModRows)
|
foreach (string pack, Widget row : m_ModRows)
|
||||||
{
|
{
|
||||||
TextWidget text = TextWidget.Cast(row.FindAnyWidget("PackState"));
|
TextWidget text = TextWidget.Cast(row.FindAnyWidget("PackState"));
|
||||||
@@ -163,6 +180,36 @@ modded class ERR_AdminMenu
|
|||||||
}
|
}
|
||||||
ERR_ProbePage(0); return true;
|
ERR_ProbePage(0); return true;
|
||||||
}
|
}
|
||||||
|
bool ERR_ProbeReportOverflow(string textName, string scrollName)
|
||||||
|
{
|
||||||
|
TextWidget text = TextWidget.Cast(GetRootWidget().FindAnyWidget(textName));
|
||||||
|
ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(GetRootWidget().FindAnyWidget(scrollName));
|
||||||
|
if (!text || !scroll) return false;
|
||||||
|
string saved = text.GetText();
|
||||||
|
string report;
|
||||||
|
for (int i = 0; i < 80; i++) report += "Report line " + i.ToString() + ": a long mission report must remain readable.\n";
|
||||||
|
report += "FINAL REPORT LINE";
|
||||||
|
text.SetText(report); GetRootWidget().Update();
|
||||||
|
float width, height, textWidth, textHeight, viewWidth, viewHeight;
|
||||||
|
text.GetScreenSize(width, height); text.GetTextSize(textWidth, textHeight);
|
||||||
|
scroll.GetScreenSize(viewWidth, viewHeight);
|
||||||
|
bool fits = GetGame().GetWorkspace().DPIUnscale(height) >= textHeight - 2 && height > viewHeight;
|
||||||
|
scroll.SetSliderPos(0, 1); GetRootWidget().Update();
|
||||||
|
float x, y, viewX, viewY, sliderX, sliderY;
|
||||||
|
text.GetScreenPos(x, y); scroll.GetScreenPos(viewX, viewY); scroll.GetSliderPos(sliderX, sliderY);
|
||||||
|
bool reachable = sliderY >= 0.98 && y + height <= viewY + viewHeight + 2 && y + height > viewY;
|
||||||
|
PrintFormat("ERR REPORT OVERFLOW: widget=%1 height=%2 textHeight=%3 viewport=%4 slider=%5 fits=%6 reachable=%7", textName, height, textHeight, viewHeight, sliderY, fits, reachable);
|
||||||
|
text.SetText(saved); scroll.SetSliderPos(0, 0); GetRootWidget().Update();
|
||||||
|
return fits && reachable;
|
||||||
|
}
|
||||||
|
bool ERR_ProbeHunterSummary()
|
||||||
|
{
|
||||||
|
TextWidget text = TextWidget.Cast(GetRootWidget().FindAnyWidget("Status"));
|
||||||
|
if (!text) return false;
|
||||||
|
string report = text.GetText();
|
||||||
|
array<string> parts = {}; report.Split("Sarka waves:", parts, false);
|
||||||
|
return report.Contains("HQ hunting patrols:") && parts.Count() == 2 && report.Contains("One car per");
|
||||||
|
}
|
||||||
bool ERR_ProbeJournalVisible()
|
bool ERR_ProbeJournalVisible()
|
||||||
{
|
{
|
||||||
TextWidget text = TextWidget.Cast(GetRootWidget().FindAnyWidget("JournalText"));
|
TextWidget text = TextWidget.Cast(GetRootWidget().FindAnyWidget("JournalText"));
|
||||||
@@ -239,7 +286,7 @@ class ERR_NativeAdminMenuProbe
|
|||||||
Pass("all thirteen setting descriptions fit their native text widgets");
|
Pass("all thirteen setting descriptions fit their native text widgets");
|
||||||
System.MakeScreenshot("$logs:err-admin-open");
|
System.MakeScreenshot("$logs:err-admin-open");
|
||||||
if (!menu.ERR_ProbeNavigation(0)) return Fail("Esc entry did not open Mission page with shared navigation");
|
if (!menu.ERR_ProbeNavigation(0)) return Fail("Esc entry did not open Mission page with shared navigation");
|
||||||
menu.ERR_ProbePage(3);
|
menu.ERR_ProbePage(ERR_AdminPage.PACKS);
|
||||||
if (!menu.ERR_ProbeMods()) return Fail("mod rows missing state or collapsed");
|
if (!menu.ERR_ProbeMods()) return Fail("mod rows missing state or collapsed");
|
||||||
Print("ERR MOD CAPTURE READY");
|
Print("ERR MOD CAPTURE READY");
|
||||||
menu.ERR_ProbePage(0);
|
menu.ERR_ProbePage(0);
|
||||||
@@ -288,7 +335,7 @@ class ERR_NativeAdminMenuProbe
|
|||||||
if (m_Mode.Settings().Get("radioDefenceSeconds") != m_RadioSeconds) return Fail("test setting restoration failed");
|
if (m_Mode.Settings().Get("radioDefenceSeconds") != m_RadioSeconds) return Fail("test setting restoration failed");
|
||||||
Pass("test setting restored without resetting menu drafts");
|
Pass("test setting restored without resetting menu drafts");
|
||||||
System.MakeScreenshot("$logs:err-admin-hq");
|
System.MakeScreenshot("$logs:err-admin-hq");
|
||||||
menu.ERR_ProbePage(3);
|
menu.ERR_ProbePage(ERR_AdminPage.PACKS);
|
||||||
menu.ERR_ProbeMod(!m_RhsSaved);
|
menu.ERR_ProbeMod(!m_RhsSaved);
|
||||||
m_Wait = now + 2000; m_Stage = 11; return 0;
|
m_Wait = now + 2000; m_Stage = 11; return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ modded class ERR_GameMode
|
|||||||
if (!ERR_MortarIntelReady()) return;
|
if (!ERR_MortarIntelReady()) return;
|
||||||
if (!ERR_AirfieldCheck(!Sites().Find("everon-supply-2"), "guarded car-and-crate site absent")) return;
|
if (!ERR_AirfieldCheck(!Sites().Find("everon-supply-2"), "guarded car-and-crate site absent")) return;
|
||||||
ERR_SiteRuntime extraction = Sites().Find("everon-extraction-1");
|
ERR_SiteRuntime extraction = Sites().Find("everon-extraction-1");
|
||||||
if (!ERR_AirfieldCheck(extraction.Definition.RequireAirfield && vector.DistanceXZ(ExtractionVehicle().GetOrigin(), "4800.953 0 11487.412") < 3 && ERR_CasualtyLoadingRules.AircraftReady(ExtractionVehicle()), "production aircraft settled intact on validated Everon airfield pad")) return;
|
if (!ERR_AirfieldCheck(!extraction.Definition.RequireAirfield && extraction.Definition.PlacementResolved && vector.DistanceXZ(ExtractionVehicle().GetOrigin(), extraction.Definition.Position) < 3 && ERR_CasualtyLoadingRules.AircraftReady(ExtractionVehicle()), "production aircraft settled intact on validated generated landing zone")) return;
|
||||||
if (!ERR_AirfieldCheck(!ERR_AirfieldPlacement.Clear(ERR_Actors.Ground("7012 0 7500")), "old off-airfield helicopter position rejected")) return;
|
if (!ERR_AirfieldCheck(!ERR_AirfieldPlacement.Clear(ERR_Actors.Ground("7012 0 7500")), "old off-airfield helicopter position rejected")) return;
|
||||||
if (!ERR_AirfieldCheck(!ERR_AirfieldPlacement.Clear(ExtractionVehicle().GetOrigin()), "occupied airfield pad rejected")) return;
|
if (!ERR_AirfieldCheck(!ERR_AirfieldPlacement.Clear(ExtractionVehicle().GetOrigin()), "occupied airfield pad rejected")) return;
|
||||||
if (!ERR_AirfieldCheck(Sites().Find("everon-medical-1").Definition.RevealOnEscape && Sites().Find("everon-supply-1").Definition.RevealOnEscape, "two reachable intel sites retained")) return;
|
if (!ERR_AirfieldCheck(Sites().Find("everon-medical-1").Definition.RevealOnEscape && Sites().Find("everon-supply-1").Definition.RevealOnEscape, "two reachable intel sites retained")) return;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ modded class ERR_GameMode
|
|||||||
string enabled;
|
string enabled;
|
||||||
if (SCR_Global.IsEditMode() || !Replication.IsServer() || !System.GetCLIParam("errBaseSmoke", enabled) || enabled != "1") return;
|
if (SCR_Global.IsEditMode() || !Replication.IsServer() || !System.GetCLIParam("errBaseSmoke", enabled) || enabled != "1") return;
|
||||||
string nativeEndCase;
|
string nativeEndCase;
|
||||||
array<string> independentFixtures = {"coordinated-ai", "optional-site-skip", "infantry-combat", "medical-combat", "hunter-faction", "unconscious-camera", "objective-map", "town-garrisons", "site-garrisons", "radio-interaction", "enemy-loadout", "aggression", "native-end-active", "native-end-preparing", "generated-sites", "mortar-station", "opening-tools", "airfield-markers", "air-logistics", "air-assault", "air-recon"};
|
array<string> independentFixtures = {"coordinated-ai", "optional-site-skip", "infantry-combat", "medical-combat", "hunter-faction", "unconscious-camera", "self-epinephrine", "starter-backpack", "speech-download", "bundled-speech", "objective-map", "town-garrisons", "site-garrisons", "radio-interaction", "enemy-loadout", "aggression", "sarka-hunters", "native-end-active", "native-end-preparing", "generated-sites", "roadblocks", "mortar-station", "opening-tools", "airfield-markers", "air-logistics", "air-assault", "air-recon"};
|
||||||
if (System.GetCLIParam("errSmokeOutcome", nativeEndCase) && independentFixtures.Contains(nativeEndCase)) return;
|
if (System.GetCLIParam("errSmokeOutcome", nativeEndCase) && independentFixtures.Contains(nativeEndCase)) return;
|
||||||
ERR_NativeObjectiveProbe.BeginRound();
|
ERR_NativeObjectiveProbe.BeginRound();
|
||||||
ERR_NativeProgressionIdentityProbe.BeginRound();
|
ERR_NativeProgressionIdentityProbe.BeginRound();
|
||||||
@@ -775,6 +775,10 @@ modded class ERR_GameMode
|
|||||||
ERR_SiteRuntime medical = Sites().Find("everon-medical-1");
|
ERR_SiteRuntime medical = Sites().Find("everon-medical-1");
|
||||||
if (!ERR_BaseCheck(medical.Location.Knowledge() == 2 && medical.Location.Label() == "Medical stash" && m_ERRMedicalDiscoveries == 1, "conscious nearby player visually discovers named medical stash once")) return;
|
if (!ERR_BaseCheck(medical.Location.Knowledge() == 2 && medical.Location.Label() == "Medical stash" && m_ERRMedicalDiscoveries == 1, "conscious nearby player visually discovers named medical stash once")) return;
|
||||||
if (!ERR_BaseCheck(!Sites().CanObserve(m_ERRBasePlayer, Sites().Find("everon-radio-1")), "distant medical-site discovery does not reveal the radio")) return;
|
if (!ERR_BaseCheck(!Sites().CanObserve(m_ERRBasePlayer, Sites().Find("everon-radio-1")), "distant medical-site discovery does not reveal the radio")) return;
|
||||||
|
// This sparse historical fixture has two eligible sites. Arrange the
|
||||||
|
// remaining identification before testing document ownership and recovery.
|
||||||
|
Sites().Find("everon-outpost-1").Location.Discover(0, 100);
|
||||||
|
if (!ERR_BaseCheck(Discovery().RadioIntelAllowed(), "identified optional sites unlock the historical radio documents")) return;
|
||||||
m_ERRBaseStep = 1;
|
m_ERRBaseStep = 1;
|
||||||
}
|
}
|
||||||
else if (m_ERRBaseStep == 1 || m_ERRBaseStep == 2)
|
else if (m_ERRBaseStep == 1 || m_ERRBaseStep == 2)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
protected ref ERR_ObjectiveMapPresentation m_Presentation;
|
protected ref ERR_ObjectiveMapPresentation m_Presentation;
|
||||||
protected SCR_MapMenuUI m_Menu;
|
protected SCR_MapMenuUI m_Menu;
|
||||||
protected Widget m_SharedRoot, m_ReusedRoot, m_ExpectedRoot, m_PreviousWidget;
|
protected Widget m_SharedRoot, m_ReusedRoot, m_ExpectedRoot, m_PreviousWidget;
|
||||||
|
protected ref ERRM_AtlasPresentation m_Atlas;
|
||||||
protected ref MapConfiguration m_Config;
|
protected ref MapConfiguration m_Config;
|
||||||
protected MapConfiguration m_Ready;
|
protected MapConfiguration m_Ready;
|
||||||
protected vector m_Point;
|
protected vector m_Point;
|
||||||
@@ -94,7 +95,7 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
m_CloseObserved = false;
|
m_CloseObserved = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
protected Widget CreateSharedRoot()
|
protected Widget CreateSharedRoot(int page = ERRM_PaperPages.OVERVIEW)
|
||||||
{
|
{
|
||||||
Widget root = GetGame().GetWorkspace().CreateWidgets("{255E1265F702B4AE}UI/layouts/ERRMap/SharedMapRenderTarget.layout");
|
Widget root = GetGame().GetWorkspace().CreateWidgets("{255E1265F702B4AE}UI/layouts/ERRMap/SharedMapRenderTarget.layout");
|
||||||
if (!root) return null;
|
if (!root) return null;
|
||||||
@@ -104,6 +105,12 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
// is bound, so these observations cannot qualify the physical held texture.
|
// is bound, so these observations cannot qualify the physical held texture.
|
||||||
target.SetEnabled(false);
|
target.SetEnabled(false);
|
||||||
root.SetVisible(true);
|
root.SetVisible(true);
|
||||||
|
// Exercise the production atlas gutter, index grid and objective visibility.
|
||||||
|
m_Atlas = new ERRM_AtlasPresentation(root);
|
||||||
|
float zoom; int columns, rows;
|
||||||
|
if (!ERRM_PaperPages.Layout(m_Map.Size(), 0.5, zoom, columns, rows)) return null;
|
||||||
|
m_Atlas.Prepare(page, m_Map.Size(), zoom, columns, rows);
|
||||||
|
m_Atlas.Draw(page, zoom, columns, rows, m_Map.Size());
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
protected bool OpenShared(Widget root)
|
protected bool OpenShared(Widget root)
|
||||||
@@ -122,7 +129,9 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
protected void Center(float zoom)
|
protected void Center(float zoom)
|
||||||
{
|
{
|
||||||
int position[2]; m_Marker.GetWorldPos(position);
|
int position[2]; m_Marker.GetWorldPos(position);
|
||||||
m_Map.ZoomPanSmooth(zoom, position[0] + 100.0 / zoom, position[1], 0.1);
|
float width, height; m_Map.GetMapWidget().GetScreenSize(width, height);
|
||||||
|
float offset = Math.Min(100, width * 0.25);
|
||||||
|
m_Map.ZoomPanSmooth(zoom, position[0] + offset / zoom, position[1], 0.1);
|
||||||
}
|
}
|
||||||
protected bool Inspect(string label, bool rough)
|
protected bool Inspect(string label, bool rough)
|
||||||
{
|
{
|
||||||
@@ -133,6 +142,13 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
Widget nativeIcons = m_ExpectedRoot.FindAnyWidget("UIIconsContainer");
|
Widget nativeIcons = m_ExpectedRoot.FindAnyWidget("UIIconsContainer");
|
||||||
if (!container && nativeIcons) container = nativeIcons.GetParent();
|
if (!container && nativeIcons) container = nativeIcons.GetParent();
|
||||||
if (!Check(root && element && container && container != m_Map.GetMapWidget() && root.GetParent() == container && m_Presentation.ERR_ProbeContainer() == container && m_Presentation.ERR_ProbeCanvas() == m_Map.GetMapWidget(), "actual authored layout handler belongs to the exact supported objective container and native canvas")) return false;
|
if (!Check(root && element && container && container != m_Map.GetMapWidget() && root.GetParent() == container && m_Presentation.ERR_ProbeContainer() == container && m_Presentation.ERR_ProbeCanvas() == m_Map.GetMapWidget(), "actual authored layout handler belongs to the exact supported objective container and native canvas")) return false;
|
||||||
|
if (m_ExpectedRoot.FindAnyWidget("ERR_ObjectiveOverlay"))
|
||||||
|
{
|
||||||
|
vector mapPos = FrameSlot.GetPos(m_Map.GetMapWidget()), overlayPos = FrameSlot.GetPos(container);
|
||||||
|
float mapW, mapH, overlayW, overlayH;
|
||||||
|
m_Map.GetMapWidget().GetScreenSize(mapW, mapH); container.GetScreenSize(overlayW, overlayH);
|
||||||
|
if (!Check(container.IsVisible() && container.GetZOrder() > 10 && Math.AbsFloat(mapPos[0] - overlayPos[0]) < 0.1 && Math.AbsFloat(mapPos[1] - overlayPos[1]) < 0.1 && Math.AbsFloat(mapW - overlayW) < 1 && Math.AbsFloat(mapH - overlayH) < 1, "atlas index/regional overlay is visible above print and matches the map rectangle")) return false;
|
||||||
|
}
|
||||||
TextWidget text = TextWidget.Cast(root.FindAnyWidget("ObjectiveText"));
|
TextWidget text = TextWidget.Cast(root.FindAnyWidget("ObjectiveText"));
|
||||||
ImageWidget image = ImageWidget.Cast(root.FindAnyWidget("Image"));
|
ImageWidget image = ImageWidget.Cast(root.FindAnyWidget("Image"));
|
||||||
if (!Check(text && image && text.GetText() == label && root.IsVisible(), "actual visible widget contains the current objective label and icon widget")) return false;
|
if (!Check(text && image && text.GetText() == label && root.IsVisible(), "actual visible widget contains the current objective label and icon widget")) return false;
|
||||||
@@ -285,7 +301,7 @@ class ERR_NativeObjectiveMapProbe
|
|||||||
MapConfiguration previousConfig = m_Config;
|
MapConfiguration previousConfig = m_Config;
|
||||||
m_Map.CloseMap();
|
m_Map.CloseMap();
|
||||||
if (!Check(!m_Presentation.ERR_ProbeRoot(), "closing shared root clears only owned objective widget")) return -1;
|
if (!Check(!m_Presentation.ERR_ProbeRoot(), "closing shared root clears only owned objective widget")) return -1;
|
||||||
m_ReusedRoot = CreateSharedRoot();
|
m_ReusedRoot = CreateSharedRoot(ERRM_PaperPages.REGION);
|
||||||
if (!OpenShared(m_ReusedRoot)) return -1;
|
if (!OpenShared(m_ReusedRoot)) return -1;
|
||||||
if (!Check(m_Config == previousConfig && m_ReusedRoot != m_SharedRoot, "native plain config is reused with a distinct root")) return -1;
|
if (!Check(m_Config == previousConfig && m_ReusedRoot != m_SharedRoot, "native plain config is reused with a distinct root")) return -1;
|
||||||
m_Stage = 11; m_Wait = now + 1000; return 0;
|
m_Stage = 11; m_Wait = now + 1000; return 0;
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
modded class ERR_CampTerrain
|
modded class ERR_CampTerrain
|
||||||
{
|
{
|
||||||
static bool s_ERROptionalSiteRefused;
|
static bool s_ERROptionalSiteRefused;
|
||||||
override bool Site(ERR_SiteDefinition site, vector position, float heading, out float baseHeight)
|
override bool Site(ERR_SiteDefinition site, vector position, float heading, out float baseHeight, float airportBuffer = 1500)
|
||||||
{
|
{
|
||||||
string outcome;
|
string outcome;
|
||||||
if ((site.Id == "everon-camp-5" || site.Id == "everon-outpost-1") && System.GetCLIParam("errSmokeOutcome", outcome) && outcome == "optional-site-skip")
|
if ((site.Id == "everon-camp-5" || site.Id == "everon-outpost-1") && System.GetCLIParam("errSmokeOutcome", outcome) && outcome == "optional-site-skip")
|
||||||
{
|
{
|
||||||
s_ERROptionalSiteRefused = true; return false;
|
s_ERROptionalSiteRefused = true; return false;
|
||||||
}
|
}
|
||||||
return super.Site(site, position, heading, baseHeight);
|
return super.Site(site, position, heading, baseHeight, airportBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modded class ERR_GameMode
|
modded class ERR_GameMode
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ modded class ERR_GameMode
|
|||||||
float now = GetWorld().GetWorldTime();
|
float now = GetWorld().GetWorldTime();
|
||||||
if (Phase() == ERR_Phase.VICTORY)
|
if (Phase() == ERR_Phase.VICTORY)
|
||||||
{
|
{
|
||||||
ERR_RescueCheck(Extraction().EscapedCount() == 1, "native flight carried the original prisoner across the escape boundary");
|
ERR_RescueCheck(Extraction().EscapedCount() == 1, "native flight carried the original prisoner through thirty seconds of airborne evacuation");
|
||||||
Print("ERR RESCUE COMPLETE"); GetGame().GetCallqueue().Remove(ERR_RescueProbeTick); return;
|
Print("ERR RESCUE COMPLETE"); GetGame().GetCallqueue().Remove(ERR_RescueProbeTick); return;
|
||||||
}
|
}
|
||||||
if (!PreparationError().IsEmpty() || Phase() == ERR_Phase.DEFEAT) { ERR_RescueCheck(false, "mission failed: " + PreparationError()); return; }
|
if (!PreparationError().IsEmpty() || Phase() == ERR_Phase.DEFEAT) { ERR_RescueCheck(false, "mission failed: " + PreparationError()); return; }
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
#ifdef WORKBENCH
|
#ifdef WORKBENCH
|
||||||
|
class ERR_RoadblockProbeRules
|
||||||
|
{
|
||||||
|
static int SmallTarget()
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (System.GetCLIParam("errRoadblockProbeCount", value)) return Math.Clamp(value.ToInt(), 0, 30);
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
static int LargeTarget()
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (System.GetCLIParam("errLargeRoadblockProbeCount", value)) return Math.Clamp(value.ToInt(), 0, 30);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int Target() { return SmallTarget() + LargeTarget(); }
|
||||||
|
static int Guards() { return SmallTarget() * 4 + LargeTarget() * 8; }
|
||||||
|
static int Props() { return SmallTarget() * 8 + LargeTarget() * 14; }
|
||||||
|
|
||||||
|
}
|
||||||
modded class ERR_HQ
|
modded class ERR_HQ
|
||||||
{
|
{
|
||||||
bool ERR_ProbeRoadblockGroup(SCR_AIGroup group)
|
bool ERR_ProbeRoadblockGroup(SCR_AIGroup group)
|
||||||
@@ -10,21 +29,158 @@ modded class ERR_HQ
|
|||||||
}
|
}
|
||||||
modded class ERR_Roadblocks
|
modded class ERR_Roadblocks
|
||||||
{
|
{
|
||||||
|
override ERR_PrepareResult Prepare(ERR_ScenarioDefinition definition)
|
||||||
|
{
|
||||||
|
string outcome;
|
||||||
|
if (!m_Begun && System.GetCLIParam("errSmokeOutcome", outcome) && outcome == "roadblocks")
|
||||||
|
{
|
||||||
|
m_Mode.Settings().Set("roadblockCount", ERR_RoadblockProbeRules.SmallTarget());
|
||||||
|
m_Mode.Settings().Set("largeRoadblockCount", ERR_RoadblockProbeRules.LargeTarget());
|
||||||
|
m_Mode.Settings().Set("mainRoadWidthMetres", 6);
|
||||||
|
}
|
||||||
|
return super.Prepare(definition);
|
||||||
|
}
|
||||||
|
protected int m_ERRLayoutPosts;
|
||||||
|
protected bool m_ERRLayoutFailed, m_ERRLayoutCaptured;
|
||||||
|
protected SCR_ManualCamera m_ERRLayoutCamera;
|
||||||
|
override protected void BuildPost()
|
||||||
|
{
|
||||||
|
string outcome;
|
||||||
|
if (!System.GetCLIParam("errSmokeOutcome", outcome) || outcome != "roadblocks") { super.BuildPost(); return; }
|
||||||
|
// Inspect the actual spawned models before the transaction clears its refs.
|
||||||
|
if (m_BuildHold)
|
||||||
|
{
|
||||||
|
bool valid = ShareProps();
|
||||||
|
for (int i = 0; i < m_BuildCovers.Count() && valid; i++)
|
||||||
|
{
|
||||||
|
ERR_RoadblockProp prop = m_BuildCovers[i];
|
||||||
|
IEntity entity = m_BuildSpawned[i + m_BuildPositions.Count()];
|
||||||
|
vector low, high; entity.GetBounds(low, high);
|
||||||
|
if (m_ERRLayoutPosts == 0) PrintFormat("ERR ROADBLOCK PROP NATIVE: prefab=%1 low=%2 high=%3", prop.Prefab, low, high);
|
||||||
|
if (Math.Max(Math.AbsFloat(low[0]), Math.AbsFloat(high[0])) > prop.HalfWidth
|
||||||
|
|| Math.Max(Math.AbsFloat(low[2]), Math.AbsFloat(high[2])) > prop.HalfDepth || high[1] > prop.Height) valid = false;
|
||||||
|
// Every actual prop corner must stay outside the four-metre centre lane.
|
||||||
|
for (int x = 0; x < 2; x++)
|
||||||
|
for (int z = 0; z < 2; z++)
|
||||||
|
{
|
||||||
|
vector corner = low;
|
||||||
|
if (x) corner[0] = high[0];
|
||||||
|
if (z) corner[2] = high[2];
|
||||||
|
vector delta = entity.CoordToParent(corner) - m_Centre;
|
||||||
|
if (Math.AbsFloat(vector.Dot(delta, m_Right)) < 2) valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid) { m_ERRLayoutFailed = true; Print("ERR SMOKE FAIL: roadblock prop geometry or centre lane", LogLevel.ERROR); }
|
||||||
|
if (!m_ERRLayoutCaptured && m_Mode.Active())
|
||||||
|
{
|
||||||
|
m_ERRLayoutCaptured = true;
|
||||||
|
EntitySpawnParams params = new EntitySpawnParams();
|
||||||
|
m_ERRLayoutCamera = SCR_ManualCamera.Cast(GetGame().SpawnEntity(SCR_ManualCamera, GetGame().GetWorld(), params));
|
||||||
|
if (m_ERRLayoutCamera)
|
||||||
|
{
|
||||||
|
vector camera[4];
|
||||||
|
vector eye = m_Centre - m_Forward * 18 + m_Right * 12 + "0 13 0";
|
||||||
|
Math3D.DirectionAndUpMatrix(vector.Direction(eye, m_Centre), "0 1 0", camera);
|
||||||
|
camera[3] = eye; m_ERRLayoutCamera.SetWorldTransform(camera); m_ERRLayoutCamera.SetVerticalFOV(65);
|
||||||
|
GetGame().GetCameraManager().SetCamera(m_ERRLayoutCamera);
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_ProbeCaptureLayout, 3000, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_ERRLayoutPosts++;
|
||||||
|
}
|
||||||
|
super.BuildPost();
|
||||||
|
}
|
||||||
|
protected void ERR_ProbeCaptureLayout()
|
||||||
|
{
|
||||||
|
System.MakeScreenshot("$logs:err-roadblock-layout");
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_ProbeCloseLayoutCamera, 1000, false);
|
||||||
|
}
|
||||||
|
protected void ERR_ProbeCloseLayoutCamera()
|
||||||
|
{
|
||||||
|
if (!m_ERRLayoutCamera) return;
|
||||||
|
GetGame().GetCameraManager().SetCamera(GetGame().GetPlayerController().GetPlayerCamera());
|
||||||
|
m_ERRLayoutCamera.Terminate(); delete m_ERRLayoutCamera; m_ERRLayoutCamera = null;
|
||||||
|
}
|
||||||
|
override void Stop()
|
||||||
|
{
|
||||||
|
GetGame().GetCallqueue().Remove(ERR_ProbeCaptureLayout);
|
||||||
|
GetGame().GetCallqueue().Remove(ERR_ProbeCloseLayoutCamera);
|
||||||
|
ERR_ProbeCloseLayoutCamera();
|
||||||
|
super.Stop();
|
||||||
|
}
|
||||||
|
int ERR_ProbePostCount() { return m_Positions.Count(); }
|
||||||
|
bool ERR_ProbeBackgroundPending() { return m_Background; }
|
||||||
|
bool ERR_ProbeCompleteRoadblocks()
|
||||||
|
{
|
||||||
|
if (m_ERRLayoutFailed || m_ERRLayoutPosts < ERR_RoadblockProbeRules.Target() || m_Target != ERR_RoadblockProbeRules.Target() || m_Positions.Count() != m_Target || m_Background || !m_Ready) return false;
|
||||||
|
foreach (SCR_AIGroup group : m_Groups)
|
||||||
|
{
|
||||||
|
ERR_ForceRecord record = m_Mode.Forces().FindGroup(group);
|
||||||
|
if (!group || !record || record.Kind != ERR_ForceKind.CHECKPOINT || (record.InitialStrength != 4 && record.InitialStrength != 8) || m_Mode.ForceLiving(group) != record.InitialStrength) return false;
|
||||||
|
if (group.GetFaction() != m_Mode.EnemyFaction() || !ERR_HQ.Get().ERR_ProbeRoadblockGroup(group)) return false;
|
||||||
|
}
|
||||||
|
if (m_SmallPlaced != ERR_RoadblockProbeRules.SmallTarget() || m_LargePlaced != ERR_RoadblockProbeRules.LargeTarget()) return false;
|
||||||
|
int count = m_Positions.Count();
|
||||||
|
BackgroundStep();
|
||||||
|
PrintFormat("ERR ROADBLOCK BACKGROUND NATIVE: posts=%1 guards=%2 steps=%3 workMs=%4 maxStepMs=%5 attempts=%6", count, ERR_RoadblockProbeRules.Guards(), m_BackgroundSteps, m_BackgroundWork, m_MaxBackgroundStep, m_Attempts);
|
||||||
|
return m_Positions.Count() == count && (m_BackgroundSteps > 0 || ERR_RoadblockProbeRules.Target() <= 4);
|
||||||
|
}
|
||||||
bool ERR_ProbePreparedRoadblocks()
|
bool ERR_ProbePreparedRoadblocks()
|
||||||
{
|
{
|
||||||
if (!m_Ready || m_Target != 4 || m_Groups.IsEmpty() || m_Groups.Count() > m_Target || m_Groups.Count() != m_Positions.Count()) return false;
|
if (!m_Ready || m_Target != m_SmallTarget + m_LargeTarget || m_Groups.IsEmpty() || m_Groups.Count() > m_Target || m_Groups.Count() != m_Positions.Count()) return false;
|
||||||
int count = m_Groups.Count();
|
int count = m_Groups.Count();
|
||||||
foreach (SCR_AIGroup group : m_Groups)
|
foreach (SCR_AIGroup group : m_Groups)
|
||||||
{
|
{
|
||||||
ERR_ForceRecord record = m_Mode.Forces().FindGroup(group);
|
ERR_ForceRecord record = m_Mode.Forces().FindGroup(group);
|
||||||
if (!record || record.Kind != ERR_ForceKind.CHECKPOINT || record.InitialStrength != 4 || m_Mode.ForceLiving(group) != 4
|
if (!record || record.Kind != ERR_ForceKind.CHECKPOINT || (record.InitialStrength != 4 && record.InitialStrength != 8) || m_Mode.ForceLiving(group) != record.InitialStrength
|
||||||
|| group.GetFaction() != m_Mode.EnemyFaction() || !ERR_HQ.Get().ERR_ProbeRoadblockGroup(group)) return false;
|
|| group.GetFaction() != m_Mode.EnemyFaction() || !ERR_HQ.Get().ERR_ProbeRoadblockGroup(group)) return false;
|
||||||
}
|
}
|
||||||
ERR_ScenarioDefinition definition = ERR_ScenarioDefinition.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab("{ACA98B44E2173605}Configs/ERR/Tests/LegacySites.conf"));
|
ERR_ScenarioDefinition definition = ERR_ScenarioDefinition.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab("{ACA98B44E2173605}Configs/ERR/Tests/LegacySites.conf"));
|
||||||
// Repeated preparation cannot replenish or create another squad.
|
// Repeated preparation cannot replenish or create another squad.
|
||||||
if (Prepare(definition) != ERR_PrepareResult.READY || m_Groups.Count() != count) return false;
|
if (Prepare(definition) != ERR_PrepareResult.READY || m_Groups.Count() != count) return false;
|
||||||
PrintFormat("ERR ROADBLOCK NATIVE: posts=%1 soldiers=%2 ledger=checkpoint HQ=available repeatedPrepare=unchanged", count, count * 4);
|
PrintFormat("ERR ROADBLOCK NATIVE: posts=%1 soldiers=%2 ledger=checkpoint HQ=available repeatedPrepare=unchanged", count, m_SmallPlaced * 4 + m_LargePlaced * 8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
modded class ERR_GameMode
|
||||||
|
{
|
||||||
|
protected int m_ERRRoadblockDeadline, m_ERRRoadblockInitial = -1;
|
||||||
|
protected override void EOnInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.EOnInit(owner);
|
||||||
|
string outcome;
|
||||||
|
if (!Replication.IsServer() || SCR_Global.IsEditMode() || !System.GetCLIParam("errSmokeOutcome", outcome) || outcome != "roadblocks") return;
|
||||||
|
m_ERRRoadblockDeadline = System.GetTickCount() + 900000;
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_RoadblockProbeTick, 500, true);
|
||||||
|
OnStop().Insert(ERR_StopRoadblockProbe);
|
||||||
|
}
|
||||||
|
protected void ERR_StopRoadblockProbe() { GetGame().GetCallqueue().Remove(ERR_RoadblockProbeTick); }
|
||||||
|
protected void ERR_RoadblockProbeFail(string reason)
|
||||||
|
{
|
||||||
|
Print("ERR SMOKE FAIL: roadblocks " + reason, LogLevel.ERROR);
|
||||||
|
ERR_StopRoadblockProbe();
|
||||||
|
}
|
||||||
|
protected void ERR_RoadblockProbeTick()
|
||||||
|
{
|
||||||
|
if (System.GetTickCount() > m_ERRRoadblockDeadline || !PreparationError().IsEmpty()) { ERR_RoadblockProbeFail("deadline or preparation error"); return; }
|
||||||
|
if (!Active()) return;
|
||||||
|
ERR_Roadblocks posts = ERR_HQ.Get().Roadblocks();
|
||||||
|
if (m_ERRRoadblockInitial < 0)
|
||||||
|
{
|
||||||
|
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
||||||
|
IEntity player; if (controller) player = controller.GetControlledEntity();
|
||||||
|
if (!player || !Players().CurrentActor(player)) return;
|
||||||
|
DamageManagerComponent.Cast(player.FindComponent(DamageManagerComponent)).EnableDamageHandling(false);
|
||||||
|
if ((ERR_RoadblockProbeRules.Target() > 4 && (!posts.ERR_ProbeBackgroundPending() || posts.ERR_ProbePostCount() >= ERR_RoadblockProbeRules.Target())) || !UnlockPrison(player)) { ERR_RoadblockProbeFail("did not enter background search with prison unlocked"); return; }
|
||||||
|
m_ERRRoadblockInitial = posts.ERR_ProbePostCount();
|
||||||
|
PrintFormat("ERR SMOKE PASS: roadblocks prison unlocked with %1/%2 posts; placement observation started", m_ERRRoadblockInitial, ERR_RoadblockProbeRules.Target());
|
||||||
|
}
|
||||||
|
if (posts.ERR_ProbeBackgroundPending()) return;
|
||||||
|
if (!posts.ERR_ProbeCompleteRoadblocks() || (ERR_RoadblockProbeRules.Target() > 4 && posts.ERR_ProbePostCount() <= m_ERRRoadblockInitial)) { ERR_RoadblockProbeFail("physical small/large posts, independent quotas, replicated props, ledger and HQ admission"); return; }
|
||||||
|
PrintFormat("ERR SMOKE PASS: roadblocks %1 physical posts / %2 guards / %3 replicated checkpoint props with distance streaming disabled; verified model footprints and centre lane; placement complete after prison unlock, no extra posts on repeat tick", posts.ERR_ProbePostCount(), ERR_RoadblockProbeRules.Guards(), ERR_RoadblockProbeRules.Props());
|
||||||
|
ERR_StopRoadblockProbe();
|
||||||
|
Transition(ERR_Phase.DEFEAT);
|
||||||
|
Print("ERR SMOKE COMPLETE: roadblocks background completion on Everon; scripted local fixture");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
#ifdef WORKBENCH
|
||||||
|
modded class ERR_AdminMenu
|
||||||
|
{
|
||||||
|
bool ERR_SarkaProbeReady() { return m_Ready && m_AvailableFields.Contains("sarkaAngerPerCar"); }
|
||||||
|
bool ERR_SarkaProbeSet(int points)
|
||||||
|
{
|
||||||
|
ShowPage(Navigation().Find("OpenSarka"));
|
||||||
|
SCR_EditBoxComponent edit = SCR_EditBoxComponent.GetEditBoxComponent("sarkaAngerPerCar", GetRootWidget());
|
||||||
|
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText("Apply_sarkaAngerPerCar", GetRootWidget());
|
||||||
|
if (!edit || !button || !button.IsEnabled()) return false;
|
||||||
|
edit.SetValue(points.ToString()); OnButton(button); return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class ERR_HunterService
|
||||||
|
{
|
||||||
|
void ERR_ProbeSarkaDue(float now) { m_SarkaWaves.NextWave = now; }
|
||||||
|
bool ERR_ProbeSarkaDisabled() { return m_SarkaWaves.AngerPerCar == 0 && m_SarkaWaves.Pending == 0; }
|
||||||
|
void ERR_ProbeSarkas(out array<ERR_HunterVehicle> cars)
|
||||||
|
{
|
||||||
|
cars.Clear();
|
||||||
|
foreach (ERR_HunterVehicle unit : m_Hunters) if (unit.Sarka) cars.Insert(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class ERR_HQ
|
||||||
|
{
|
||||||
|
void ERR_ProbeSarkaBodies(float now)
|
||||||
|
{
|
||||||
|
for (int slot = 0; slot < 24; slot++)
|
||||||
|
{
|
||||||
|
ERR_HQReport report = new ERR_HQReport();
|
||||||
|
report.TravelMode = "body"; report.MessageId = 200000 + slot;
|
||||||
|
report.CasualtySourceId = "fixture-sarka-bodies"; report.CasualtyStrength = 24; report.CasualtySlot = slot;
|
||||||
|
report.ObservedAt = now; report.Position = "5000 50 5000";
|
||||||
|
Accept(report, now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class ERR_GameMode
|
||||||
|
{
|
||||||
|
protected int m_ERRSarkaStage;
|
||||||
|
protected int m_ERRSarkaMenuPage;
|
||||||
|
protected int m_ERRSarkaDeadline;
|
||||||
|
protected bool m_ERRSarkaOrder;
|
||||||
|
protected override void EOnInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.EOnInit(owner);
|
||||||
|
string outcome;
|
||||||
|
if (!Replication.IsServer() || SCR_Global.IsEditMode() || !System.GetCLIParam("errSmokeOutcome", outcome) || outcome != "sarka-hunters") return;
|
||||||
|
m_ERRSarkaDeadline = System.GetTickCount() + 420000;
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_SarkaProbeTick, 1000, true);
|
||||||
|
}
|
||||||
|
protected bool ERR_SarkaProbeCheck(bool ok, string detail)
|
||||||
|
{
|
||||||
|
if (ok) { Print("ERR SMOKE PASS: sarka " + detail); return true; }
|
||||||
|
Print("ERR SMOKE FAIL: sarka " + detail, LogLevel.ERROR);
|
||||||
|
GetGame().GetCallqueue().Remove(ERR_SarkaProbeTick); return false;
|
||||||
|
}
|
||||||
|
protected void ERR_SarkaProbeTick()
|
||||||
|
{
|
||||||
|
if (System.GetTickCount() >= m_ERRSarkaDeadline || Phase() == ERR_Phase.DEFEAT) { ERR_SarkaProbeCheck(false, "native spawn/admission/driving deadline"); return; }
|
||||||
|
if (Phase() < ERR_Phase.PRISON || !GetGame().GetPlayerController()) return;
|
||||||
|
IEntity player = GetGame().GetPlayerController().GetControlledEntity(); if (!player) return;
|
||||||
|
DamageManagerComponent damage = DamageManagerComponent.Cast(player.FindComponent(DamageManagerComponent));
|
||||||
|
if (damage) damage.EnableDamageHandling(false);
|
||||||
|
ERR_HQ hq = ERR_HQ.Get(); if (!hq) return;
|
||||||
|
float now = GetWorld().GetWorldTime();
|
||||||
|
if (m_ERRSarkaStage == 0)
|
||||||
|
{
|
||||||
|
if (!ERR_SarkaProbeCheck(Settings().Get("sarkaAngerPerCar") == 3, "default three anger points per car")) return;
|
||||||
|
ERR_AdminMenu.Open(); m_ERRSarkaStage = 9; return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 9)
|
||||||
|
{
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu();
|
||||||
|
if (!menu || !menu.ERR_SarkaProbeReady()) return;
|
||||||
|
menu.ERR_ProbePage(m_ERRSarkaMenuPage); m_ERRSarkaStage = 90; return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 90)
|
||||||
|
{
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu();
|
||||||
|
if (!ERR_SarkaProbeCheck(menu && menu.ERR_ProbeNavigation(m_ERRSarkaMenuPage), "top main tabs and left sidebar reach page " + m_ERRSarkaMenuPage.ToString())) return;
|
||||||
|
if (m_ERRSarkaMenuPage == ERR_AdminPage.STATUS)
|
||||||
|
{
|
||||||
|
if (!ERR_SarkaProbeCheck(menu.ERR_ProbeHunterSummary(), "patrol summary and exactly one Sarka wave summary")) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(menu.ERR_ProbeReportOverflow("Status", "StatusScroll"), "long status grows and last line scrolls into view")) return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaMenuPage == ERR_AdminPage.JOURNAL)
|
||||||
|
if (!ERR_SarkaProbeCheck(menu.ERR_ProbeReportOverflow("JournalText", "JournalScroll"), "long journal grows and last line scrolls into view")) return;
|
||||||
|
System.MakeScreenshot("$logs:err-menu-sidebar-" + m_ERRSarkaMenuPage.ToString());
|
||||||
|
m_ERRSarkaStage = 91; return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 91)
|
||||||
|
{
|
||||||
|
m_ERRSarkaMenuPage++;
|
||||||
|
if (m_ERRSarkaMenuPage < ERR_AdminMenu.Pages().Count()) m_ERRSarkaStage = 9;
|
||||||
|
else m_ERRSarkaStage = 10;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 10)
|
||||||
|
{
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu();
|
||||||
|
if (!menu || !menu.ERR_SarkaProbeReady()) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(menu.ERR_SarkaProbeSet(2), "real menu submits two anger points per car")) return;
|
||||||
|
m_ERRSarkaStage = 11; return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 11)
|
||||||
|
{
|
||||||
|
if (Settings().Get("sarkaAngerPerCar") != 2) return;
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu(); if (!menu || !menu.ERR_SarkaProbeReady()) return;
|
||||||
|
System.MakeScreenshot("$logs:err-sarka-settings"); menu.Close();
|
||||||
|
ERR_Settings reloaded = new ERR_Settings();
|
||||||
|
if (!ERR_SarkaProbeCheck(reloaded.Get("sarkaAngerPerCar") == 2, "menu owner RPC persists anger threshold")) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(UnlockPrison(player) || Phase() >= ERR_Phase.RADIO_SEARCH, "prison released")) return;
|
||||||
|
hq.ERR_ProbeSarkaBodies(now);
|
||||||
|
if (!ERR_SarkaProbeCheck(hq.Watch().Aggression() == 8, "24 delivered bodies produce eight anger points")) return;
|
||||||
|
// Accelerate only the opt-in wave deadline; production placement/admission run unchanged.
|
||||||
|
hq.Hunters().ERR_ProbeSarkaDue(now); m_ERRSarkaStage = 1;
|
||||||
|
}
|
||||||
|
array<ERR_HunterVehicle> cars = {}; hq.Hunters().ERR_ProbeSarkas(cars);
|
||||||
|
if (cars.Count() < 4) return;
|
||||||
|
if (m_ERRSarkaStage == 20)
|
||||||
|
{
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu();
|
||||||
|
if (!menu || !menu.ERR_SarkaProbeReady()) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(menu.ERR_SarkaProbeSet(0), "real menu submits disable")) return;
|
||||||
|
m_ERRSarkaStage = 21; return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 21)
|
||||||
|
{
|
||||||
|
if (Settings().Get("sarkaAngerPerCar") != 0 || !hq.Hunters().ERR_ProbeSarkaDisabled()) return;
|
||||||
|
foreach (ERR_HunterVehicle retained : cars)
|
||||||
|
if (!ERR_SarkaProbeCheck(retained.Entity && retained.Members.Count() == 4, "disabling retains deployed cars and teams")) return;
|
||||||
|
ERR_AdminMenu menu = ERR_AdminMenu.GetOpenMenu(); if (menu) menu.Close();
|
||||||
|
GetGame().GetCallqueue().Remove(ERR_SarkaProbeTick);
|
||||||
|
Print("ERR SMOKE COMPLETE: sarka menu save, anger threshold, four SF cars, radio, driving and disable"); return;
|
||||||
|
}
|
||||||
|
if (m_ERRSarkaStage == 1)
|
||||||
|
{
|
||||||
|
if (!ERR_SarkaProbeCheck(cars.Count() == 4, "eight anger at two points per car produces four physical cars")) return;
|
||||||
|
array<vector> positions = {player.GetOrigin()};
|
||||||
|
foreach (ERR_HunterVehicle car : cars)
|
||||||
|
{
|
||||||
|
if (!car.Registered) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(car.Entity.GetPrefabData().GetPrefabName() == ERR_SarkaRules.Prefab() && car.CrewValid(this) && car.Members.Count() == 4 && car.Seats.Count() == 4, "native S105 with four original seated crew")) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(ERR_SarkaRules.InBand(car.PatrolHome, positions), "actual road spawn 1-1.25 km from player")) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(hq.Hunters().VehicleRadioCapability(car.Driver) == 2 && car.Group.GetFaction() == EnemyFaction(), "physical vehicle manpack and selected hostile faction")) return;
|
||||||
|
int medics;
|
||||||
|
foreach (IEntity member : car.Members)
|
||||||
|
{
|
||||||
|
ResourceName profile = member.GetPrefabData().GetPrefabName();
|
||||||
|
if (profile == ERR_EnemyMedicalCatalog.Crew(this, true)) medics++;
|
||||||
|
else if (!ERR_SarkaProbeCheck(profile == ERR_EnemyMedicalCatalog.Crew(this, false), "selected special-forces profile")) return;
|
||||||
|
SCR_AICombatComponent combat = SCR_AICombatComponent.Cast(member.FindComponent(SCR_AICombatComponent));
|
||||||
|
if (!combat || combat.GetAISkill() != EAISkill.CYLON || !combat.ERR_EnhancedEnemy()) return;
|
||||||
|
}
|
||||||
|
if (!ERR_SarkaProbeCheck(medics == 1, "one medic within the four-person team")) return;
|
||||||
|
}
|
||||||
|
m_ERRSarkaStage = 2;
|
||||||
|
}
|
||||||
|
if (cars[0].Waypoint) m_ERRSarkaOrder = true;
|
||||||
|
if (!m_ERRSarkaOrder || vector.DistanceXZ(cars[0].PatrolHome, cars[0].Entity.GetOrigin()) < 30) return;
|
||||||
|
if (!ERR_SarkaProbeCheck(hq.Hunters().Deployed() <= hq.Watch().HunterTarget(), "cars do not spend ordinary hunter allowance")) return;
|
||||||
|
ERR_SarkaProbeCheck(true, "native patrol order and over 30 metres driven; all crew enhanced");
|
||||||
|
ERR_AdminMenu.Open(); m_ERRSarkaStage = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#ifdef WORKBENCH
|
||||||
|
// Explicit local HTTP fixture. It exercises the production REST downloader,
|
||||||
|
// incremental preparation and native audio handle without Google or game RPCs.
|
||||||
|
class ERR_SpeechDownloadProbeClient : ERR_WelcomeVoiceClient
|
||||||
|
{
|
||||||
|
bool Played;
|
||||||
|
bool PlaybackValid;
|
||||||
|
void ERR_SpeechDownloadProbeClient(ERR_GameMode mode, int serial, ERR_WelcomeConnection connection, bool requirePermit = false, string title = "Speech transport test") {}
|
||||||
|
override protected void Play()
|
||||||
|
{
|
||||||
|
PlaybackValid = FileIO.CopyFile(m_Path, "$profile:speech-downloaded.wav");
|
||||||
|
m_Handle = AudioSystem.PlaySound(m_Path);
|
||||||
|
PlaybackValid = PlaybackValid && m_Handle != AudioHandle.Invalid;
|
||||||
|
Played = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class ERR_GameMode
|
||||||
|
{
|
||||||
|
protected ref ERR_SpeechDownloadProbeClient m_ERRSpeechDownloadProbe;
|
||||||
|
protected int m_ERRSpeechDownloadDeadline;
|
||||||
|
protected string m_ERRSpeechProbeURL;
|
||||||
|
protected override void EOnInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.EOnInit(owner);
|
||||||
|
string outcome;
|
||||||
|
if (SCR_Global.IsEditMode() || !System.GetCLIParam("errSmokeOutcome", outcome) || outcome != "speech-download") return;
|
||||||
|
// Only explicit loopback fixtures: no paid synthesis or production endpoint.
|
||||||
|
if (!System.GetCLIParam("errSpeechProbeURL", m_ERRSpeechProbeURL) || m_ERRSpeechProbeURL.IndexOf("http://127.0.0.1:") != 0)
|
||||||
|
{ Print("ERR SMOKE FAIL: speech download needs an explicit loopback URL", LogLevel.ERROR); return; }
|
||||||
|
m_ERRSpeechDownloadDeadline = System.GetTickCount() + 180000;
|
||||||
|
OnStop().Insert(ERR_StopSpeechDownloadProbe);
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_TickSpeechDownloadProbe, 100, true);
|
||||||
|
}
|
||||||
|
protected void ERR_TickSpeechDownloadProbe()
|
||||||
|
{
|
||||||
|
if (System.GetTickCount() >= m_ERRSpeechDownloadDeadline || !PreparationError().IsEmpty())
|
||||||
|
{
|
||||||
|
Print("ERR SMOKE FAIL: speech download preparation/deadline", LogLevel.ERROR);
|
||||||
|
ERR_StopSpeechDownloadProbe(); return;
|
||||||
|
}
|
||||||
|
if (!Active()) return;
|
||||||
|
if (!m_ERRSpeechDownloadProbe) m_ERRSpeechDownloadProbe = new ERR_SpeechDownloadProbeClient(this, 910, new ERR_WelcomeConnection(), false);
|
||||||
|
m_ERRSpeechDownloadProbe.Tick(0.1, true, m_ERRSpeechProbeURL, "Local transport test");
|
||||||
|
if (!m_ERRSpeechDownloadProbe.Played) return;
|
||||||
|
if (m_ERRSpeechDownloadProbe.PlaybackValid)
|
||||||
|
Print("ERR SMOKE COMPLETE: native REST multipart speech download, incremental preparation and valid playback handle; compare speech-downloaded.wav to source for byte integrity; not an audible multiplayer test");
|
||||||
|
else Print("ERR SMOKE FAIL: speech download native output/playback", LogLevel.ERROR);
|
||||||
|
ERR_StopSpeechDownloadProbe();
|
||||||
|
}
|
||||||
|
protected void ERR_StopSpeechDownloadProbe()
|
||||||
|
{
|
||||||
|
if (GetGame()) GetGame().GetCallqueue().Remove(ERR_TickSpeechDownloadProbe);
|
||||||
|
if (m_ERRSpeechDownloadProbe) m_ERRSpeechDownloadProbe.Stop();
|
||||||
|
OnStop().Remove(ERR_StopSpeechDownloadProbe);
|
||||||
|
}
|
||||||
|
void ~ERR_GameMode() { ERR_StopSpeechDownloadProbe(); }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -35,7 +35,7 @@ class ERR_ObjectiveText
|
|||||||
ERR_Phase phase = mode.Phase();
|
ERR_Phase phase = mode.Phase();
|
||||||
if (phase == ERR_Phase.PREPARING)
|
if (phase == ERR_Phase.PREPARING)
|
||||||
{
|
{
|
||||||
if (!mode.PreparationError().IsEmpty()) return "The mission could not start. An administrator can use /esc status for the cause. Spawning is disabled until the configuration is corrected and the scenario restarted.";
|
if (!mode.PreparationError().IsEmpty()) return "Reason: " + mode.PreparationError() + "\n\nAn administrator must correct the problem and restart the scenario before players can spawn.";
|
||||||
return "Preparing mission sites and equipment. You will spawn when the mission is ready.";
|
return "Preparing mission sites and equipment. You will spawn when the mission is ready.";
|
||||||
}
|
}
|
||||||
if (phase == ERR_Phase.PRISON)
|
if (phase == ERR_Phase.PRISON)
|
||||||
@@ -52,12 +52,15 @@ class ERR_ObjectiveText
|
|||||||
return "The radio station is identified on your map. Reach its radio and complete the 'Contact extraction HQ' action to start the transmission.";
|
return "The radio station is identified on your map. Reach its radio and complete the 'Contact extraction HQ' action to start the transmission.";
|
||||||
if (location.Knowledge() == 1) roughRadio = true;
|
if (location.Knowledge() == 1) roughRadio = true;
|
||||||
}
|
}
|
||||||
|
// The frozen radio-intel gate is server-owned; conditional guidance remains
|
||||||
|
// correct on clients, with the gate disabled and on sparse terrains.
|
||||||
|
string intelRequirement = "Keep any radio document that cannot yet be deciphered. If radio intel is locked, fully identify more distinct non-radio sites; the starting clue markers do not count. Kept radio documents are read automatically when the requirement is met. ";
|
||||||
// Scan all sites before acknowledging rough intel: an identified radio wins.
|
// Scan all sites before acknowledging rough intel: an identified radio wins.
|
||||||
if (roughRadio)
|
if (roughRadio)
|
||||||
return "Intel recovered: a question mark shows an approximate location, but its type is still unknown. Take a different intelligence folder into your inventory to pinpoint the radio; a folder already recovered cannot provide another clue. Try the other marked clue site if needed. A close approach with a clear view can also identify the station.";
|
return "Intel recovered: a question mark shows an approximate location, but its type is still unknown. Take a different intelligence folder into your inventory to pinpoint the radio; a folder already recovered cannot provide another clue. Try the other marked clue site if needed. A close approach with a clear view can also identify the station. " + intelRequirement;
|
||||||
string startHint;
|
string startHint;
|
||||||
if (mode.StartMode() == 1) startHint = "Search the salvage backpack at the crash site for weapons and a field map. ";
|
if (mode.StartMode() == 1) startHint = "Search the salvage backpack at the crash site for weapons and a field map. ";
|
||||||
return startHint + "Choose either marked clue site. Take its intelligence folders into your own inventory to reveal the station on your map. If the location is not yet identified, take another folder. Each marked site has enough folders; use the other if one is lost. If every folder is lost, a close approach with a clear view can identify the station itself. Nearby medical and guard sites can also be discovered by approaching with a clear view.";
|
return startHint + "Choose either marked clue site and take its intelligence folders into your own inventory. " + intelRequirement + "After radio intel unlocks, a different folder can refine a rough location. Use the other clue site if folders are lost. Even if every folder is lost, a close approach with a clear view can identify the station itself. Nearby medical and guard sites can also be discovered by approaching with a clear view.";
|
||||||
}
|
}
|
||||||
if (phase == ERR_Phase.RADIO_DEFENCE)
|
if (phase == ERR_Phase.RADIO_DEFENCE)
|
||||||
{
|
{
|
||||||
@@ -76,7 +79,7 @@ class ERR_ObjectiveText
|
|||||||
{
|
{
|
||||||
if (mode.PickupStage() == 2 || mode.PickupStage() == 3) return "Smoke accepted. Armed rescue helicopters are approaching. Keep the marked landing point clear and gather everyone nearby.";
|
if (mode.PickupStage() == 2 || mode.PickupStage() == 3) return "Smoke accepted. Armed rescue helicopters are approaching. Keep the marked landing point clear and gather everyone nearby.";
|
||||||
if (mode.PickupStage() == 4) return "Board the rescue transport. It waits for all living prisoners, including unconscious or disconnected survivors. Escorts cover the landing zone. After everyone is aboard for eight seconds, the pilot takes off.";
|
if (mode.PickupStage() == 4) return "Board the rescue transport. It waits for all living prisoners, including unconscious or disconnected survivors. Escorts cover the landing zone. After everyone is aboard for eight seconds, the pilot takes off.";
|
||||||
if (mode.PickupStage() == 5) return "Stay aboard. The rescue pilot and escorts are taking you beyond the escape boundary to safety.";
|
if (mode.PickupStage() == 5) return "Stay aboard. Escape completes after all rescue transports have remained airborne for 30 continuous seconds.";
|
||||||
return Extraction(mode.EscapeRadius());
|
return Extraction(mode.EscapeRadius());
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ERR_ObserverGuidance
|
|||||||
}
|
}
|
||||||
if (!survivorAvailable)
|
if (!survivorAvailable)
|
||||||
return message + " No teammate or body is currently available to follow. Use camera look controls to orbit the last known position and zoom controls to change distance.";
|
return message + " No teammate or body is currently available to follow. Use camera look controls to orbit the last known position and zoom controls to change distance.";
|
||||||
return message + " Press Left / Right arrow to change teammate or body (or /esc spectate next / /esc spectate previous). Press Enter to switch between third-person and the living teammate's camera. Player view waits in third-person if no live camera stream is available. Use camera look controls to orbit and zoom controls to change distance in third-person.";
|
return message + " Press Left / Right arrow to change teammate or body, including your own (or /esc spectate next / /esc spectate previous). Press Enter to switch between third-person and the living teammate's camera. Player view waits in third-person if no live camera stream is available. Use camera look controls to orbit and zoom controls to change distance in third-person.";
|
||||||
}
|
}
|
||||||
static bool Refresh(bool shown, int previousReason, int reason, bool previousAvailable, bool survivorAvailable)
|
static bool Refresh(bool shown, int previousReason, int reason, bool previousAvailable, bool survivorAvailable)
|
||||||
{
|
{
|
||||||
@@ -127,11 +127,12 @@ class ERR_FollowSurvivorCameraComponent : SCR_BaseManualCameraComponent
|
|||||||
protected ref ERR_ObserverScopeDisplay m_ScopeDisplay = new ERR_ObserverScopeDisplay();
|
protected ref ERR_ObserverScopeDisplay m_ScopeDisplay = new ERR_ObserverScopeDisplay();
|
||||||
protected ref ERR_ObserverPIPDisplay m_PIPDisplay = new ERR_ObserverPIPDisplay();
|
protected ref ERR_ObserverPIPDisplay m_PIPDisplay = new ERR_ObserverPIPDisplay();
|
||||||
protected bool m_InputContextActive;
|
protected bool m_InputContextActive;
|
||||||
|
protected bool m_SpaceDown;
|
||||||
bool InputContextActive() { return m_InputContextActive; }
|
bool InputContextActive() { return m_InputContextActive; }
|
||||||
bool IsPlayerView() { return m_PlayerView; }
|
bool IsPlayerView() { return m_PlayerView; }
|
||||||
// Process one edge per press; menus still consume the state so holding a key
|
// Process one edge per press; menus still consume the state so holding a key
|
||||||
// while closing a menu cannot unexpectedly change the followed teammate.
|
// while closing a menu cannot unexpectedly change the followed teammate.
|
||||||
void Input(bool enabled, bool left, bool right, bool enter)
|
void Input(bool enabled, bool left, bool right, bool enter, bool space = false)
|
||||||
{
|
{
|
||||||
// An inactive context reports zero even while a physical key is held. Let
|
// An inactive context reports zero even while a physical key is held. Let
|
||||||
// the reactivated context settle, then require release before accepting keys.
|
// the reactivated context settle, then require release before accepting keys.
|
||||||
@@ -139,16 +140,20 @@ class ERR_FollowSurvivorCameraComponent : SCR_BaseManualCameraComponent
|
|||||||
else if (m_InputResumeFrames > 0)
|
else if (m_InputResumeFrames > 0)
|
||||||
{
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
if (m_InputResumeFrames > 1 || (!left && !right && !enter)) m_InputResumeFrames--;
|
if (m_InputResumeFrames > 1 || (!left && !right && !enter && !space)) m_InputResumeFrames--;
|
||||||
}
|
}
|
||||||
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
||||||
int cycle = ERR_ObserverRules.Cycle(enabled, left, right, m_LeftDown, m_RightDown);
|
int cycle = ERR_ObserverRules.Cycle(enabled, left, right, m_LeftDown, m_RightDown);
|
||||||
if (controller && cycle != 0) controller.ERR_CycleObserver(cycle);
|
if (controller && cycle != 0) controller.ERR_CycleObserver(cycle);
|
||||||
if (ERR_ObserverRules.Toggle(enabled, enter, m_EnterDown)) m_PlayerView = !m_PlayerView;
|
if (ERR_ObserverRules.Toggle(enabled, enter, m_EnterDown)) m_PlayerView = !m_PlayerView;
|
||||||
|
if (controller && ERR_ObserverRules.Toggle(enabled, space, m_SpaceDown)) controller.ERR_UseSelfEpinephrine();
|
||||||
|
m_SpaceDown = space;
|
||||||
m_LeftDown = left; m_RightDown = right; m_EnterDown = enter;
|
m_LeftDown = left; m_RightDown = right; m_EnterDown = enter;
|
||||||
}
|
}
|
||||||
override bool EOnCameraInit()
|
override bool EOnCameraInit()
|
||||||
{
|
{
|
||||||
|
// Release a held jump key after knockout before accepting self-injection.
|
||||||
|
m_InputResumeFrames = 2;
|
||||||
m_OrbitFov = GetCameraEntity().GetVerticalFOV();
|
m_OrbitFov = GetCameraEntity().GetVerticalFOV();
|
||||||
m_OrbitNear = GetCameraEntity().GetNearPlane();
|
m_OrbitNear = GetCameraEntity().GetNearPlane();
|
||||||
return true;
|
return true;
|
||||||
@@ -159,7 +164,7 @@ class ERR_FollowSurvivorCameraComponent : SCR_BaseManualCameraComponent
|
|||||||
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
||||||
if (!controller || GetGame().GetCameraManager().CurrentCamera() != GetCameraEntity()) { m_PIPDisplay.Close(); m_ScopeDisplay.Close(); m_ViewHead.Restore(); return; }
|
if (!controller || GetGame().GetCameraManager().CurrentCamera() != GetCameraEntity()) { m_PIPDisplay.Close(); m_ScopeDisplay.Close(); m_ViewHead.Restore(); return; }
|
||||||
m_InputContextActive = GetInputManager().IsContextActive("ERR_ObserverContext");
|
m_InputContextActive = GetInputManager().IsContextActive("ERR_ObserverContext");
|
||||||
Input(param.isManualInputEnabled, GetInputManager().GetActionValue("ERR_ObserverPrevious") > 0.5, GetInputManager().GetActionValue("ERR_ObserverNext") > 0.5, GetInputManager().GetActionValue("ERR_ObserverView") > 0.5);
|
Input(param.isManualInputEnabled, GetInputManager().GetActionValue("ERR_ObserverPrevious") > 0.5, GetInputManager().GetActionValue("ERR_ObserverNext") > 0.5, GetInputManager().GetActionValue("ERR_ObserverView") > 0.5, GetInputManager().GetActionValue("ERR_SelfEpinephrine") > 0.5);
|
||||||
IEntity target = controller.ERR_ObservedEntity();
|
IEntity target = controller.ERR_ObservedEntity();
|
||||||
float fov, nearPlane;
|
float fov, nearPlane;
|
||||||
if (m_PlayerView && controller.ERR_ReadPlayerView(target, param.timeSlice, param.transform, fov, nearPlane))
|
if (m_PlayerView && controller.ERR_ReadPlayerView(target, param.timeSlice, param.transform, fov, nearPlane))
|
||||||
@@ -220,7 +225,7 @@ class ERR_FollowSurvivorCameraComponent : SCR_BaseManualCameraComponent
|
|||||||
{
|
{
|
||||||
target.GetWorldTransform(transform);
|
target.GetWorldTransform(transform);
|
||||||
aim = transform[3] + "0 1.5 0";
|
aim = transform[3] + "0 1.5 0";
|
||||||
if (!ERR_Actors.Alive(target)) aim = transform[3] + "0 0.4 0";
|
if (!ERR_Actors.CanFight(target)) aim = transform[3] + "0 0.4 0";
|
||||||
}
|
}
|
||||||
if (target != m_Target || vehicle != m_Vehicle)
|
if (target != m_Target || vehicle != m_Vehicle)
|
||||||
{
|
{
|
||||||
@@ -237,7 +242,7 @@ class ERR_FollowSurvivorCameraComponent : SCR_BaseManualCameraComponent
|
|||||||
m_Target = null; m_Vehicle = null;
|
m_Target = null; m_Vehicle = null;
|
||||||
m_Distance = Math.Clamp(m_Distance, 2, 12);
|
m_Distance = Math.Clamp(m_Distance, 2, 12);
|
||||||
}
|
}
|
||||||
if ((!m_PlayerView || !target || !ERR_Actors.Alive(target)) && param.isManualInputEnabled)
|
if ((!m_PlayerView || !target || !ERR_Actors.CanFight(target)) && param.isManualInputEnabled)
|
||||||
{
|
{
|
||||||
m_Yaw += GetInputManager().GetActionValue("ManualCameraRotateYaw") * 90 * param.timeSlice;
|
m_Yaw += GetInputManager().GetActionValue("ManualCameraRotateYaw") * 90 * param.timeSlice;
|
||||||
m_Pitch = Math.Clamp(m_Pitch - GetInputManager().GetActionValue("ManualCameraRotatePitch") * 90 * param.timeSlice, 5, 75);
|
m_Pitch = Math.Clamp(m_Pitch - GetInputManager().GetActionValue("ManualCameraRotatePitch") * 90 * param.timeSlice, 5, 75);
|
||||||
@@ -279,10 +284,15 @@ modded class SCR_PlayerController
|
|||||||
protected ERR_ObserverReason m_ERRShownObserverReason;
|
protected ERR_ObserverReason m_ERRShownObserverReason;
|
||||||
protected bool m_ERRShownObserverAvailable;
|
protected bool m_ERRShownObserverAvailable;
|
||||||
protected string m_ERRShownRecoveryStatus;
|
protected string m_ERRShownRecoveryStatus;
|
||||||
|
protected string m_ERRPendingRecoveryStatus;
|
||||||
|
protected int m_ERRRecoveryStatusSince;
|
||||||
protected float m_ERRLastCycle = -1000;
|
protected float m_ERRLastCycle = -1000;
|
||||||
protected IEntity m_ERRRecoveryBody;
|
protected IEntity m_ERRRecoveryBody;
|
||||||
protected float m_ERRRecoveryDeadline = -1;
|
protected float m_ERRRecoveryDeadline = -1;
|
||||||
|
|
||||||
|
// Optional casualty action is implemented by the self-epinephrine extension.
|
||||||
|
string ERR_SelfEpinephrineHint() { return ""; }
|
||||||
|
void ERR_UseSelfEpinephrine() {}
|
||||||
ERR_ObserverReason ERR_ObserverState() { return m_ERRObserverReason; }
|
ERR_ObserverReason ERR_ObserverState() { return m_ERRObserverReason; }
|
||||||
vector ERR_ObserverAnchor() { return m_ERRObserverAnchor; }
|
vector ERR_ObserverAnchor() { return m_ERRObserverAnchor; }
|
||||||
IEntity ERR_ObservedEntity()
|
IEntity ERR_ObservedEntity()
|
||||||
@@ -356,10 +366,13 @@ modded class SCR_PlayerController
|
|||||||
if (survivors[i] == body || (casualty && !ERR_Actors.CanFight(survivors[i])) || !friendly || !mode.Players() || !mode.Players().CurrentActor(survivors[i]) || SCR_FactionManager.SGetFaction(survivors[i]) != friendly) survivors.RemoveOrdered(i);
|
if (survivors[i] == body || (casualty && !ERR_Actors.CanFight(survivors[i])) || !friendly || !mode.Players() || !mode.Players().CurrentActor(survivors[i]) || SCR_FactionManager.SGetFaction(survivors[i]) != friendly) survivors.RemoveOrdered(i);
|
||||||
// Dead teammates remain selectable alongside survivors, including our own body.
|
// Dead teammates remain selectable alongside survivors, including our own body.
|
||||||
ERR_ObserverTargets.Bodies(mode, survivors);
|
ERR_ObserverTargets.Bodies(mode, survivors);
|
||||||
|
// Lethal damage normally leaves a treatable casualty, not a native corpse.
|
||||||
|
// Keep that player's own canonical body in the cycle without possessing it.
|
||||||
|
if (casualty && !survivors.Contains(body)) survivors.Insert(body);
|
||||||
int index = survivors.Find(m_ERRServerObserved);
|
int index = survivors.Find(m_ERRServerObserved);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
if (life && life.Actor) index = survivors.Find(life.Actor);
|
if (!casualty && life && life.Actor) index = survivors.Find(life.Actor);
|
||||||
if (index < 0) index = 0;
|
if (index < 0) index = 0;
|
||||||
}
|
}
|
||||||
else index += direction;
|
else index += direction;
|
||||||
@@ -458,13 +471,26 @@ modded class SCR_PlayerController
|
|||||||
// whose local entity is still streaming. Never imply no survivors from delay.
|
// whose local entity is still streaming. Never imply no survivors from delay.
|
||||||
bool survivorAvailable = m_ERRObservedId != RplId.Invalid();
|
bool survivorAvailable = m_ERRObservedId != RplId.Invalid();
|
||||||
string recovery = mode.RecoveryStatus();
|
string recovery = mode.RecoveryStatus();
|
||||||
if (ERR_ObserverGuidance.Refresh(m_ERRObserverReady, m_ERRShownObserverReason, m_ERRObserverReason, m_ERRShownObserverAvailable, survivorAvailable) || m_ERRShownRecoveryStatus != recovery)
|
string selfEpiHint = ERR_SelfEpinephrineHint();
|
||||||
|
if (!selfEpiHint.IsEmpty()) recovery += "\n" + selfEpiHint;
|
||||||
|
bool contextChanged = ERR_ObserverGuidance.Refresh(m_ERRObserverReady, m_ERRShownObserverReason, m_ERRObserverReason, m_ERRShownObserverAvailable, survivorAvailable);
|
||||||
|
int now = System.GetTickCount();
|
||||||
|
// Medical samples can alternate between improving and stalled. Keep the
|
||||||
|
// accepted hint readable until the new status has remained stable for 3s.
|
||||||
|
// This affects presentation only, never the authoritative defeat timer.
|
||||||
|
if (m_ERRPendingRecoveryStatus != recovery || now < m_ERRRecoveryStatusSince)
|
||||||
|
{
|
||||||
|
m_ERRPendingRecoveryStatus = recovery;
|
||||||
|
m_ERRRecoveryStatusSince = now;
|
||||||
|
}
|
||||||
|
if (!contextChanged && m_ERRShownRecoveryStatus != recovery && now - m_ERRRecoveryStatusSince < 3000) return;
|
||||||
|
if (contextChanged || m_ERRShownRecoveryStatus != recovery)
|
||||||
{
|
{
|
||||||
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
||||||
if (!hints) return; // retry on the existing monitor; do not lose the first hint
|
if (!hints) return; // retry on the existing monitor; do not lose the first hint
|
||||||
string message = ERR_ObserverGuidance.Message(m_ERRObserverReason, survivorAvailable);
|
string message = ERR_ObserverGuidance.Message(m_ERRObserverReason, survivorAvailable);
|
||||||
if (!recovery.IsEmpty()) message += "\n" + recovery;
|
if (!recovery.IsEmpty()) message += "\n" + recovery;
|
||||||
if (!hints.ShowCustom(message, "Spectating", 12)) return;
|
if (!hints.ShowCustom(message, "Spectating", 12, m_ERRObserverReady)) return;
|
||||||
m_ERRObserverReady = true;
|
m_ERRObserverReady = true;
|
||||||
m_ERRShownObserverReason = m_ERRObserverReason;
|
m_ERRShownObserverReason = m_ERRObserverReason;
|
||||||
m_ERRShownObserverAvailable = survivorAvailable;
|
m_ERRShownObserverAvailable = survivorAvailable;
|
||||||
@@ -500,6 +526,8 @@ modded class SCR_PlayerController
|
|||||||
{
|
{
|
||||||
m_ERRObserverReady = false;
|
m_ERRObserverReady = false;
|
||||||
m_ERRShownRecoveryStatus = "";
|
m_ERRShownRecoveryStatus = "";
|
||||||
|
m_ERRPendingRecoveryStatus = "";
|
||||||
|
m_ERRRecoveryStatusSince = 0;
|
||||||
if (!m_ERRObserverCamera) return;
|
if (!m_ERRObserverCamera) return;
|
||||||
if (GetGame().GetPlayerController() == this) m_ERRObserverCamera.TrySwitchToControlledEntityCamera();
|
if (GetGame().GetPlayerController() == this) m_ERRObserverCamera.TrySwitchToControlledEntityCamera();
|
||||||
m_ERRObserverCamera.Terminate();
|
m_ERRObserverCamera.Terminate();
|
||||||
|
|||||||
@@ -3,30 +3,44 @@
|
|||||||
class ERR_ObserverViewRules
|
class ERR_ObserverViewRules
|
||||||
{
|
{
|
||||||
// One unreliable packet contains both cameras, so loss/reordering cannot
|
// One unreliable packet contains both cameras, so loss/reordering cannot
|
||||||
// pair a new eye pose with an old aiming pose. Four vectors for ordinary/2D,
|
// pair a new eye pose with an old aiming pose. Five vectors for ordinary/2D,
|
||||||
// nine for PiP: scope pose/lens, eye pose/lens, native lens geometry.
|
// ten for PiP: the existing pose/lens data followed by the sampled body origin.
|
||||||
|
// Older offset-only packets are rejected rather than decoded as world poses.
|
||||||
static bool Packet(array<vector> packet)
|
static bool Packet(array<vector> packet)
|
||||||
{
|
{
|
||||||
if (!packet || (packet.Count() != 4 && packet.Count() != 9)) return false;
|
if (!packet || (packet.Count() != 5 && packet.Count() != 10)) return false;
|
||||||
|
vector origin = packet[packet.Count() - 1];
|
||||||
|
if (!Origin(origin) || !Origin(WorldPosition(origin, packet[0]))) return false;
|
||||||
if (!Sample(packet[0], packet[1], packet[2], packet[3][0], packet[3][1])) return false;
|
if (!Sample(packet[0], packet[1], packet[2], packet[3][0], packet[3][1])) return false;
|
||||||
if (packet.Count() == 4) return packet[3][2] == 0;
|
if (packet.Count() == 5) return packet[3][2] == 0;
|
||||||
if (!(packet[3][2] >= 0.01 && packet[3][2] <= 150)) return false;
|
if (!(packet[3][2] >= 0.01 && packet[3][2] <= 150)) return false;
|
||||||
|
if (!Origin(WorldPosition(origin, packet[4]))) return false;
|
||||||
if (!Sample(packet[4], packet[5], packet[6], packet[7][0], packet[7][1])) return false;
|
if (!Sample(packet[4], packet[5], packet[6], packet[7][0], packet[7][1])) return false;
|
||||||
return packet[7][2] >= 0 && packet[7][2] <= 100 && Math.AbsFloat(packet[8][0]) <= 90 && Math.AbsFloat(packet[8][1]) <= 90 && packet[8][2] >= 0.001 && packet[8][2] <= 100;
|
return packet[7][2] >= 0 && packet[7][2] <= 100 && Math.AbsFloat(packet[8][0]) <= 90 && Math.AbsFloat(packet[8][1]) <= 90 && packet[8][2] >= 0.001 && packet[8][2] <= 100;
|
||||||
}
|
}
|
||||||
// The body and camera arrive through independently timed replication streams.
|
// Sample axes, world-axis eye offset and body origin on the owner together.
|
||||||
// Keep the sampled world axes and world-axis eye offset together. Applying
|
// Neither the proxy body rotation nor its position is used during playback.
|
||||||
// the proxy body's rotation to delayed body-local aim adds its yaw error to
|
|
||||||
// both aim and eye position, even when the owner's camera is steady.
|
|
||||||
static void Encode(vector body[4], vector view[4], out vector pose[4])
|
static void Encode(vector body[4], vector view[4], out vector pose[4])
|
||||||
{
|
{
|
||||||
for (int axis = 0; axis < 3; axis++) pose[axis] = view[axis];
|
for (int axis = 0; axis < 3; axis++) pose[axis] = view[axis];
|
||||||
pose[3] = view[3] - body[3];
|
pose[3] = view[3] - body[3];
|
||||||
}
|
}
|
||||||
static void Decode(vector body[4], vector pose[4], out vector view[4])
|
// Reconstruct before interpolation, once per received sample. Both eye and
|
||||||
|
// scope use the exact same captured origin, never the current proxy position.
|
||||||
|
static vector WorldPosition(vector origin, vector offset) { return origin + offset; }
|
||||||
|
static bool Origin(vector position)
|
||||||
{
|
{
|
||||||
for (int axis = 0; axis < 3; axis++) view[axis] = pose[axis];
|
// Finite coordinate bounds cover large terrains while rejecting NaN/infinity.
|
||||||
view[3] = body[3] + pose[3];
|
return Math.AbsFloat(position[0]) <= 10000000 && Math.AbsFloat(position[1]) <= 10000000 && Math.AbsFloat(position[2]) <= 10000000;
|
||||||
|
}
|
||||||
|
static bool NearBody(vector origin, vector authoritative)
|
||||||
|
{
|
||||||
|
if (!Origin(origin) || !Origin(authoritative)) return false;
|
||||||
|
return (origin - authoritative).LengthSq() <= 10000;
|
||||||
|
}
|
||||||
|
static bool WorldSample(vector position, vector forward, vector up, float fov, float nearPlane)
|
||||||
|
{
|
||||||
|
return Origin(position) && Sample(vector.Zero, forward, up, fov, nearPlane);
|
||||||
}
|
}
|
||||||
static bool Sample(vector position, vector forward, vector up, float fov, float nearPlane)
|
static bool Sample(vector position, vector forward, vector up, float fov, float nearPlane)
|
||||||
{
|
{
|
||||||
@@ -42,6 +56,7 @@ class ERR_ObserverViewRules
|
|||||||
class ERR_ObserverViewSample
|
class ERR_ObserverViewSample
|
||||||
{
|
{
|
||||||
int Stamp;
|
int Stamp;
|
||||||
|
// Complete sampled world pose, not an offset from the replicated proxy.
|
||||||
vector Position, Forward, Up;
|
vector Position, Forward, Up;
|
||||||
float Fov, Near;
|
float Fov, Near;
|
||||||
float PipFov, Vignette;
|
float PipFov, Vignette;
|
||||||
@@ -74,7 +89,7 @@ class ERR_ObserverViewBuffer
|
|||||||
void Push(RplId target, int stamp, float now, vector position, vector forward, vector up, float fov, float nearPlane, RplId scopeWeapon, vector scopeData, float pipFov = 0, vector geometry = "0 0 0", float vignette = 0)
|
void Push(RplId target, int stamp, float now, vector position, vector forward, vector up, float fov, float nearPlane, RplId scopeWeapon, vector scopeData, float pipFov = 0, vector geometry = "0 0 0", float vignette = 0)
|
||||||
{
|
{
|
||||||
if (!ERR_ObserverScope.Valid(scopeWeapon, scopeData)) return;
|
if (!ERR_ObserverScope.Valid(scopeWeapon, scopeData)) return;
|
||||||
if (!ERR_ObserverViewRules.Sample(position, forward, up, fov, nearPlane)) return;
|
if (!ERR_ObserverViewRules.WorldSample(position, forward, up, fov, nearPlane)) return;
|
||||||
if (target == m_Target && stamp <= m_Stamp) return;
|
if (target == m_Target && stamp <= m_Stamp) return;
|
||||||
if (target != m_Target || scopeWeapon != m_ScopeWeapon || scopeData[0] != m_ScopeData[0] || !ERR_ObserverViewRules.Fresh(now, m_Received))
|
if (target != m_Target || scopeWeapon != m_ScopeWeapon || scopeData[0] != m_ScopeData[0] || !ERR_ObserverViewRules.Fresh(now, m_Received))
|
||||||
{
|
{
|
||||||
@@ -144,13 +159,11 @@ modded class SCR_PlayerController
|
|||||||
bool ERR_ReadPlayerEye(IEntity target, float seconds, out vector transform[4], out float fov, out float nearPlane, out float pipFov, out vector geometry, out float vignette)
|
bool ERR_ReadPlayerEye(IEntity target, float seconds, out vector transform[4], out float fov, out float nearPlane, out float pipFov, out vector geometry, out float vignette)
|
||||||
{
|
{
|
||||||
if (!m_ERRHasPIP || this != GetGame().GetPlayerController() || !target || !ERR_Actors.CanFight(target)) return false;
|
if (!m_ERRHasPIP || this != GetGame().GetPlayerController() || !target || !ERR_Actors.CanFight(target)) return false;
|
||||||
vector pose[4], world[4];
|
|
||||||
float now = GetGame().GetWorld().GetWorldTime();
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
// Use the exact aiming playhead even after a streamed optic temporarily
|
// Use the exact aiming playhead even after a streamed optic temporarily
|
||||||
// fails resolution and this eye buffer is not read for several frames.
|
// fails resolution and this eye buffer is not read for several frames.
|
||||||
m_ERREyeBuffer.Align(m_ERRViewBuffer.Playback(), now);
|
m_ERREyeBuffer.Align(m_ERRViewBuffer.Playback(), now);
|
||||||
if (!m_ERREyeBuffer.Read(m_ERRObservedId, now, seconds, pose, fov, nearPlane)) return false;
|
if (!m_ERREyeBuffer.Read(m_ERRObservedId, now, seconds, transform, fov, nearPlane)) return false;
|
||||||
target.GetWorldTransform(world); ERR_ObserverViewRules.Decode(world, pose, transform);
|
|
||||||
m_ERRViewBuffer.PIP(pipFov, geometry, vignette);
|
m_ERRViewBuffer.PIP(pipFov, geometry, vignette);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -160,13 +173,10 @@ modded class SCR_PlayerController
|
|||||||
float now = GetGame().GetWorld().GetWorldTime();
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
if (now - m_ERRViewRequestAt >= 500)
|
if (now - m_ERRViewRequestAt >= 500)
|
||||||
{ m_ERRViewRequestAt = now; Rpc(ERR_RequestPlayerView); }
|
{ m_ERRViewRequestAt = now; Rpc(ERR_RequestPlayerView); }
|
||||||
vector pose[4], world[4];
|
if (!m_ERRViewBuffer.Read(m_ERRObservedId, now, seconds, transform, fov, nearPlane)) return false;
|
||||||
if (!m_ERRViewBuffer.Read(m_ERRObservedId, now, seconds, pose, fov, nearPlane)) return false;
|
|
||||||
RplId scopeWeapon; vector scopeData;
|
RplId scopeWeapon; vector scopeData;
|
||||||
m_ERRViewBuffer.Scope(scopeWeapon, scopeData);
|
m_ERRViewBuffer.Scope(scopeWeapon, scopeData);
|
||||||
if (scopeWeapon != RplId.Invalid() && !ERR_ObserverScope.Resolve(target, scopeWeapon, scopeData)) return false;
|
if (scopeWeapon != RplId.Invalid() && !ERR_ObserverScope.Resolve(target, scopeWeapon, scopeData)) return false;
|
||||||
target.GetWorldTransform(world);
|
|
||||||
ERR_ObserverViewRules.Decode(world, pose, transform);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
|
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
|
||||||
@@ -229,12 +239,14 @@ modded class SCR_PlayerController
|
|||||||
packet[3] = Vector(fov, nearPlane, pip.GetPIPCamera().GetVerticalFOV());
|
packet[3] = Vector(fov, nearPlane, pip.GetPIPCamera().GetVerticalFOV());
|
||||||
packet.Insert(eye[3]); packet.Insert(eye[2]); packet.Insert(eye[1]);
|
packet.Insert(eye[3]); packet.Insert(eye[2]); packet.Insert(eye[1]);
|
||||||
packet.Insert(Vector(eyeFov, nearPlane, pip.ERR_ObserverPIPVignette(actor, camera))); packet.Insert(pip.ERR_ObserverPIPGeometry());
|
packet.Insert(Vector(eyeFov, nearPlane, pip.ERR_ObserverPIPVignette(actor, camera))); packet.Insert(pip.ERR_ObserverPIPGeometry());
|
||||||
|
packet.Insert(world[3]);
|
||||||
if (!ERR_ObserverViewRules.Packet(packet))
|
if (!ERR_ObserverViewRules.Packet(packet))
|
||||||
{
|
{
|
||||||
// An unusual addon lens must not suppress an otherwise valid 2D view.
|
// An unusual addon lens must not suppress an otherwise valid 2D view.
|
||||||
packet.Resize(4); packet[3] = Vector(fov, nearPlane, 0);
|
packet.Resize(4); packet[3] = Vector(fov, nearPlane, 0); packet.Insert(world[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (packet.Count() == 4) packet.Insert(world[3]);
|
||||||
if (!ERR_ObserverViewRules.Packet(packet)) return;
|
if (!ERR_ObserverViewRules.Packet(packet)) return;
|
||||||
Rpc(ERR_SubmitPlayerView, ++m_ERRViewSequence, packet, scopeWeapon, scopeData);
|
Rpc(ERR_SubmitPlayerView, ++m_ERRViewSequence, packet, scopeWeapon, scopeData);
|
||||||
}
|
}
|
||||||
@@ -242,12 +254,13 @@ modded class SCR_PlayerController
|
|||||||
protected void ERR_SubmitPlayerView(int sequence, array<vector> packet, RplId scopeWeapon, vector scopeData)
|
protected void ERR_SubmitPlayerView(int sequence, array<vector> packet, RplId scopeWeapon, vector scopeData)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || !ERR_ObserverScope.Valid(scopeWeapon, scopeData) || !ERR_ObserverViewRules.Packet(packet)) return;
|
if (!Replication.IsServer() || !ERR_ObserverScope.Valid(scopeWeapon, scopeData) || !ERR_ObserverViewRules.Packet(packet)) return;
|
||||||
if (packet.Count() == 9 && scopeWeapon == RplId.Invalid()) return;
|
if (packet.Count() == 10 && scopeWeapon == RplId.Invalid()) return;
|
||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
IEntity actor = GetControlledEntity();
|
IEntity actor = GetControlledEntity();
|
||||||
if (!mode || !mode.Active() || !ERR_Actors.CanFight(actor)) return;
|
if (!mode || !mode.Active() || !ERR_Actors.CanFight(actor)) return;
|
||||||
ERR_PlayerLife life = mode.Players().CurrentActor(actor);
|
ERR_PlayerLife life = mode.Players().CurrentActor(actor);
|
||||||
if (!life || GetGame().GetPlayerManager().GetPlayerController(life.ConnectionId) != this) return;
|
if (!life || GetGame().GetPlayerManager().GetPlayerController(life.ConnectionId) != this) return;
|
||||||
|
if (!ERR_ObserverViewRules.NearBody(packet[packet.Count() - 1], actor.GetOrigin())) return;
|
||||||
float now = GetGame().GetWorld().GetWorldTime();
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
if (actor != m_ERRViewSourceBody) { m_ERRViewSourceBody = actor; m_ERRViewInputSequence = 0; }
|
if (actor != m_ERRViewSourceBody) { m_ERRViewSourceBody = actor; m_ERRViewInputSequence = 0; }
|
||||||
if (sequence <= m_ERRViewInputSequence || now - m_ERRViewLastPacket < 35) return;
|
if (sequence <= m_ERRViewInputSequence || now - m_ERRViewLastPacket < 35) return;
|
||||||
@@ -275,19 +288,20 @@ modded class SCR_PlayerController
|
|||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
if (this != GetGame().GetPlayerController() || target == RplId.Invalid() || target != m_ERRObservedId || !mode || !ERR_ObserverRules.View(m_ERRObserverReason, mode.Active(), ERR_Actors.Alive(GetControlledEntity()), ERR_Actors.CanFight(GetControlledEntity()))) return;
|
if (this != GetGame().GetPlayerController() || target == RplId.Invalid() || target != m_ERRObservedId || !mode || !ERR_ObserverRules.View(m_ERRObserverReason, mode.Active(), ERR_Actors.Alive(GetControlledEntity()), ERR_Actors.CanFight(GetControlledEntity()))) return;
|
||||||
if (!ERR_ObserverViewRules.Packet(packet) || !ERR_ObserverScope.Valid(scopeWeapon, scopeData)) return;
|
if (!ERR_ObserverViewRules.Packet(packet) || !ERR_ObserverScope.Valid(scopeWeapon, scopeData)) return;
|
||||||
if (packet.Count() == 9 && scopeWeapon == RplId.Invalid()) return;
|
if (packet.Count() == 10 && scopeWeapon == RplId.Invalid()) return;
|
||||||
// Reject before updating either stream or PiP metadata.
|
// Reject before updating either stream or PiP metadata.
|
||||||
if (!m_ERRViewBuffer.Accepts(target, stamp)) return;
|
if (!m_ERRViewBuffer.Accepts(target, stamp)) return;
|
||||||
float now = GetGame().GetWorld().GetWorldTime();
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
bool pip = packet.Count() == 9;
|
bool pip = packet.Count() == 10;
|
||||||
if (pip != m_ERRHasPIP) { m_ERRViewBuffer.Clear(); m_ERREyeBuffer.Clear(); }
|
if (pip != m_ERRHasPIP) { m_ERRViewBuffer.Clear(); m_ERREyeBuffer.Clear(); }
|
||||||
vector geometry; float vignette;
|
vector geometry; float vignette;
|
||||||
if (pip) { geometry = packet[8]; vignette = packet[7][2]; }
|
if (pip) { geometry = packet[8]; vignette = packet[7][2]; }
|
||||||
m_ERRViewBuffer.Push(target, stamp, now, packet[0], packet[1], packet[2], packet[3][0], packet[3][1], scopeWeapon, scopeData, packet[3][2], geometry, vignette);
|
vector origin = packet[packet.Count() - 1];
|
||||||
|
m_ERRViewBuffer.Push(target, stamp, now, ERR_ObserverViewRules.WorldPosition(origin, packet[0]), packet[1], packet[2], packet[3][0], packet[3][1], scopeWeapon, scopeData, packet[3][2], geometry, vignette);
|
||||||
m_ERRHasPIP = pip;
|
m_ERRHasPIP = pip;
|
||||||
if (pip)
|
if (pip)
|
||||||
{
|
{
|
||||||
m_ERREyeBuffer.Push(target, stamp, now, packet[4], packet[5], packet[6], packet[7][0], packet[7][1], scopeWeapon, scopeData);
|
m_ERREyeBuffer.Push(target, stamp, now, ERR_ObserverViewRules.WorldPosition(origin, packet[4]), packet[5], packet[6], packet[7][0], packet[7][1], scopeWeapon, scopeData);
|
||||||
}
|
}
|
||||||
else m_ERREyeBuffer.Clear();
|
else m_ERREyeBuffer.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
// Front-seat passenger assistance is an extra held input, not a parking-brake
|
||||||
|
// toggle. The driver's persistent brake, gears and service brake stay native.
|
||||||
|
class ERR_PassengerHandbrake
|
||||||
|
{
|
||||||
|
static bool Beside(vector delta)
|
||||||
|
{
|
||||||
|
float lateral = Math.AbsFloat(delta[0]);
|
||||||
|
return lateral >= 0.35 && lateral <= 1.7 && Math.AbsFloat(delta[1]) <= 0.5 && Math.AbsFloat(delta[2]) <= 0.65;
|
||||||
|
}
|
||||||
|
static bool FrontSeat(IEntity vehicle, BaseCompartmentSlot slot)
|
||||||
|
{
|
||||||
|
if (!vehicle || !slot || slot.GetType() != ECompartmentType.CARGO) return false;
|
||||||
|
CarControllerComponent car = CarControllerComponent.Cast(vehicle.FindComponent(CarControllerComponent));
|
||||||
|
if (!car) return false;
|
||||||
|
BaseCompartmentSlot pilot = car.GetPilotCompartmentSlot();
|
||||||
|
if (!pilot || pilot == slot || !slot.GetOwner() || slot.GetOwner().GetRootParent() != vehicle.GetRootParent()) return false;
|
||||||
|
PointInfo passengerPoint = slot.GetPassengerPointInfo(), pilotPoint = pilot.GetPassengerPointInfo();
|
||||||
|
if (!passengerPoint || !pilotPoint) return false;
|
||||||
|
vector passenger = vehicle.CoordToLocal(passengerPoint.GetWorldTransformAxis(3));
|
||||||
|
vector driver = vehicle.CoordToLocal(pilotPoint.GetWorldTransformAxis(3));
|
||||||
|
return Beside(passenger - driver);
|
||||||
|
}
|
||||||
|
static IEntity VehicleFor(IEntity actor)
|
||||||
|
{
|
||||||
|
if (!ERR_Actors.CanFight(actor)) return null;
|
||||||
|
CompartmentAccessComponent access = CompartmentAccessComponent.Cast(actor.FindComponent(CompartmentAccessComponent));
|
||||||
|
if (!access) return null;
|
||||||
|
BaseCompartmentSlot slot = access.GetCompartment();
|
||||||
|
IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(actor);
|
||||||
|
if (!slot || slot.GetOccupant() != actor || !FrontSeat(vehicle, slot)) return null;
|
||||||
|
return vehicle;
|
||||||
|
}
|
||||||
|
static bool Requested(IEntity driver)
|
||||||
|
{
|
||||||
|
IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(driver);
|
||||||
|
if (!vehicle) return false;
|
||||||
|
CarControllerComponent car = CarControllerComponent.Cast(vehicle.FindComponent(CarControllerComponent));
|
||||||
|
if (!car || !car.GetPilotCompartmentSlot() || car.GetPilotCompartmentSlot().GetOccupant() != driver) return false;
|
||||||
|
// Native held-handbrake input releases the parking latch. A parked car
|
||||||
|
// already satisfies the passenger's demand, so leave that latch untouched.
|
||||||
|
if (car.GetPersistentHandBrake()) return false;
|
||||||
|
BaseCompartmentManagerComponent manager = BaseCompartmentManagerComponent.Cast(vehicle.FindComponent(BaseCompartmentManagerComponent));
|
||||||
|
if (!manager) return false;
|
||||||
|
array<BaseCompartmentSlot> slots = {};
|
||||||
|
manager.GetCompartments(slots);
|
||||||
|
foreach (BaseCompartmentSlot slot : slots)
|
||||||
|
{
|
||||||
|
IEntity actor = slot.GetOccupant();
|
||||||
|
if (!actor || actor == driver) continue;
|
||||||
|
SCR_CharacterControllerComponent character = SCR_CharacterControllerComponent.Cast(actor.FindComponent(SCR_CharacterControllerComponent));
|
||||||
|
if (character && character.ERR_PassengerBrakeHeld() && VehicleFor(actor) == vehicle) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modded class SCR_PlayerController
|
||||||
|
{
|
||||||
|
protected SCR_CharacterControllerComponent m_ERRBrakingPassenger;
|
||||||
|
// No caller-supplied body, seat or vehicle: authority derives all three.
|
||||||
|
void ERR_SendPassengerBrake(bool held)
|
||||||
|
{
|
||||||
|
if (this != GetGame().GetPlayerController()) return;
|
||||||
|
if (Replication.IsServer()) ERR_RequestPassengerBrake(held);
|
||||||
|
else Rpc(ERR_RequestPassengerBrake, held);
|
||||||
|
}
|
||||||
|
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
|
||||||
|
protected void ERR_RequestPassengerBrake(bool held)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return;
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
IEntity actor = GetControlledEntity();
|
||||||
|
SCR_CharacterControllerComponent character;
|
||||||
|
if (actor) character = SCR_CharacterControllerComponent.Cast(actor.FindComponent(SCR_CharacterControllerComponent));
|
||||||
|
if (m_ERRBrakingPassenger && (m_ERRBrakingPassenger != character || !held)) m_ERRBrakingPassenger.ERR_SetPassengerBrake(false);
|
||||||
|
m_ERRBrakingPassenger = null;
|
||||||
|
if (!character) return;
|
||||||
|
bool allowed = held && mode && mode.Active() && mode.Players() && mode.Players().CurrentActor(actor) && ERR_PassengerHandbrake.VehicleFor(actor);
|
||||||
|
character.ERR_SetPassengerBrake(allowed);
|
||||||
|
if (allowed) m_ERRBrakingPassenger = character;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modded class SCR_CharacterControllerComponent
|
||||||
|
{
|
||||||
|
[RplProp()] protected bool m_ERRPassengerBrake;
|
||||||
|
protected int m_ERRPassengerBrakeHeartbeat;
|
||||||
|
protected bool m_ERRPassengerBrakeSent;
|
||||||
|
protected int m_ERRPassengerBrakeNextSend;
|
||||||
|
protected IEntity m_ERRPassengerBrakeHintVehicle;
|
||||||
|
|
||||||
|
bool ERR_PassengerBrakeHeld() { return m_ERRPassengerBrake; }
|
||||||
|
void ERR_SetPassengerBrake(bool held)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return;
|
||||||
|
m_ERRPassengerBrakeHeartbeat = System.GetTickCount();
|
||||||
|
if (held == m_ERRPassengerBrake) return;
|
||||||
|
m_ERRPassengerBrake = held;
|
||||||
|
Replication.BumpMe();
|
||||||
|
GetGame().GetCallqueue().Remove(ERR_ExpirePassengerBrake);
|
||||||
|
if (held) GetGame().GetCallqueue().CallLater(ERR_ExpirePassengerBrake, 250, true);
|
||||||
|
}
|
||||||
|
protected void ERR_ExpirePassengerBrake()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || !m_ERRPassengerBrake) return;
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
int age = System.GetTickCount() - m_ERRPassengerBrakeHeartbeat;
|
||||||
|
if (!mode || !mode.Active() || age < 0 || age > 1000 || !ERR_PassengerHandbrake.VehicleFor(GetOwner())) ERR_SetPassengerBrake(false);
|
||||||
|
}
|
||||||
|
void ~SCR_CharacterControllerComponent()
|
||||||
|
{
|
||||||
|
if (GetGame() && GetGame().GetCallqueue()) GetGame().GetCallqueue().Remove(ERR_ExpirePassengerBrake);
|
||||||
|
}
|
||||||
|
override void OnPrepareControls(IEntity owner, ActionManager am, float dt, bool player)
|
||||||
|
{
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
// Feed the actor's native action before it prepares driving controls. The
|
||||||
|
// device/AI refreshes this value each tick; only add a held demand, never
|
||||||
|
// write a release over the driver's own handbrake or parking-brake input.
|
||||||
|
if (am && mode && mode.Active() && !am.GetActionTriggered("CarHandBrakePersistent") && ERR_PassengerHandbrake.Requested(owner)) am.SetActionValue("CarHandBrake", 1);
|
||||||
|
super.OnPrepareControls(owner, am, dt, player);
|
||||||
|
SCR_PlayerController controller = SCR_PlayerController.Cast(GetGame().GetPlayerController());
|
||||||
|
if (!controller || controller.GetControlledEntity() != owner) return;
|
||||||
|
IEntity vehicle;
|
||||||
|
if (mode && mode.Active()) vehicle = ERR_PassengerHandbrake.VehicleFor(owner);
|
||||||
|
bool held;
|
||||||
|
InputManager input = GetGame().GetInputManager();
|
||||||
|
if (vehicle && input && GetGame().GetMenuManager() && !GetGame().GetMenuManager().GetTopMenu() && !ERR_ObserverChatInput.Capture())
|
||||||
|
{
|
||||||
|
input.ActivateContext("ERR_PassengerBrakeContext", 1);
|
||||||
|
held = input.GetActionValue("ERR_PassengerBrake") > 0.5;
|
||||||
|
if (m_ERRPassengerBrakeHintVehicle != vehicle)
|
||||||
|
{
|
||||||
|
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
||||||
|
if (hints) hints.ShowCustom("Hold Space to apply the handbrake. Release Space to let go.", "Passenger handbrake", 5);
|
||||||
|
m_ERRPassengerBrakeHintVehicle = vehicle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!vehicle) m_ERRPassengerBrakeHintVehicle = null;
|
||||||
|
int now = System.GetTickCount();
|
||||||
|
if (held != m_ERRPassengerBrakeSent || (held && now >= m_ERRPassengerBrakeNextSend))
|
||||||
|
{
|
||||||
|
controller.ERR_SendPassengerBrake(held);
|
||||||
|
m_ERRPassengerBrakeSent = held;
|
||||||
|
m_ERRPassengerBrakeNextSend = now + 250;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,7 +40,9 @@ modded class SCR_PlayerController
|
|||||||
}
|
}
|
||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
if (!mode) return;
|
if (!mode) return;
|
||||||
if (mode.Phase() != ERR_Phase.PREPARING && (ERR_ObserverState() != ERR_ObserverReason.NONE || !ERR_Actors.Alive(GetControlledEntity()))) return;
|
// Local unconsciousness can arrive before the replicated observer reason.
|
||||||
|
// Do not let objective hints compete with casualty/spectator guidance then.
|
||||||
|
if (mode.Phase() != ERR_Phase.PREPARING && (ERR_ObserverState() != ERR_ObserverReason.NONE || !ERR_Actors.CanFight(GetControlledEntity()))) return;
|
||||||
string message = ERR_ObjectiveText.Description(mode, false);
|
string message = ERR_ObjectiveText.Description(mode, false);
|
||||||
if (message.IsEmpty()) return;
|
if (message.IsEmpty()) return;
|
||||||
if (m_ERRGuidePhase == mode.Phase() && m_ERRGuideMessage == message) return;
|
if (m_ERRGuidePhase == mode.Phase() && m_ERRGuideMessage == message) return;
|
||||||
|
|||||||
@@ -43,6 +43,22 @@ modded class SCR_ReconnectComponent
|
|||||||
PrintFormat("Reintroduced [reconnect]: player %1 original body reserved; timeoutSeconds=%2", playerId, seconds);
|
PrintFormat("Reintroduced [reconnect]: player %1 original body reserved; timeoutSeconds=%2", playerId, seconds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Only an actual disconnected account may receive a replacement. Retire an
|
||||||
|
// orphaned living body through native cleanup before admitting a fresh one.
|
||||||
|
protected void PrepareReplacement(int playerId, ERR_GameMode mode, ERR_PlayerLife life)
|
||||||
|
{
|
||||||
|
if (!life.ReconnectPending || !ERR_PlayerLifeRules.CanEnter(false, mode.Phase())) return;
|
||||||
|
if (GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId)) return;
|
||||||
|
if (life.Actor && GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(life.Actor) > 0) return;
|
||||||
|
if (ERR_Actors.Alive(life.Actor))
|
||||||
|
{
|
||||||
|
SCR_ReconnectData orphan = new SCR_ReconnectData();
|
||||||
|
orphan.m_ReservedEntity = life.Actor;
|
||||||
|
HandleDataExpiery(orphan);
|
||||||
|
}
|
||||||
|
if (mode.Players().AllowReconnectReplacement(playerId, mode.Phase()))
|
||||||
|
PrintFormat("Reintroduced [reconnect]: player %1 has no recoverable reservation; fresh admission allowed", playerId);
|
||||||
|
}
|
||||||
override bool HandlePlayerReconnect(int playerId)
|
override bool HandlePlayerReconnect(int playerId)
|
||||||
{
|
{
|
||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
@@ -54,11 +70,21 @@ modded class SCR_ReconnectComponent
|
|||||||
UUID identity = SCR_PlayerIdentityUtils.GetPlayerIdentityId(playerId);
|
UUID identity = SCR_PlayerIdentityUtils.GetPlayerIdentityId(playerId);
|
||||||
if (!life || !life.Connected || !life.UsedLife || identity.IsNull() || life.AccountId != identity) return false;
|
if (!life || !life.Connected || !life.UsedLife || identity.IsNull() || life.AccountId != identity) return false;
|
||||||
SCR_ReconnectData data;
|
SCR_ReconnectData data;
|
||||||
if (!m_mReconnectData.Find(identity, data)) return false;
|
if (!m_mReconnectData.Find(identity, data))
|
||||||
|
{
|
||||||
|
PrepareReplacement(playerId, mode, life);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
IEntity actor = data.m_ReservedEntity;
|
IEntity actor = data.m_ReservedEntity;
|
||||||
int owner;
|
int owner;
|
||||||
if (actor) owner = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actor);
|
if (actor) owner = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actor);
|
||||||
if (!actor || actor != life.Actor || (owner > 0 && owner != playerId))
|
if (!actor)
|
||||||
|
{
|
||||||
|
m_mReconnectData.Remove(identity); UpdateExpieryCheck();
|
||||||
|
PrepareReplacement(playerId, mode, life);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (actor != life.Actor || (owner > 0 && owner != playerId))
|
||||||
{
|
{
|
||||||
m_mReconnectData.Remove(identity); UpdateExpieryCheck();
|
m_mReconnectData.Remove(identity); UpdateExpieryCheck();
|
||||||
PrintFormat("Reintroduced [reconnect]: player %1 rejected mismatched body reservation", playerId);
|
PrintFormat("Reintroduced [reconnect]: player %1 rejected mismatched body reservation", playerId);
|
||||||
@@ -69,7 +95,7 @@ modded class SCR_ReconnectComponent
|
|||||||
if (IsDataExpired(data, GetGame().GetWorld().GetTimestamp()) || !IsDataRelevant(data))
|
if (IsDataExpired(data, GetGame().GetWorld().GetTimestamp()) || !IsDataRelevant(data))
|
||||||
{
|
{
|
||||||
m_mReconnectData.Remove(identity); HandleDataExpiery(data); UpdateExpieryCheck();
|
m_mReconnectData.Remove(identity); HandleDataExpiery(data); UpdateExpieryCheck();
|
||||||
PrintFormat("Reintroduced [reconnect]: player %1 reservation expired or body lost; no replacement life", playerId);
|
PrepareReplacement(playerId, mode, life);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool restored = super.HandlePlayerReconnect(playerId);
|
bool restored = super.HandlePlayerReconnect(playerId);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class ERR_PlayerLife
|
|||||||
int ConnectionId;
|
int ConnectionId;
|
||||||
bool Connected;
|
bool Connected;
|
||||||
bool UsedLife;
|
bool UsedLife;
|
||||||
|
bool ReconnectPending;
|
||||||
IEntity Actor;
|
IEntity Actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,18 @@ class ERR_PlayerRoster
|
|||||||
ERR_PlayerLife life = Get(playerId);
|
ERR_PlayerLife life = Get(playerId);
|
||||||
return life && life.Connected && ERR_PlayerLifeRules.CanEnter(life.UsedLife, phase);
|
return life && life.Connected && ERR_PlayerLifeRules.CanEnter(life.UsedLife, phase);
|
||||||
}
|
}
|
||||||
|
bool AllowReconnectReplacement(int playerId, int phase)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return false;
|
||||||
|
ERR_PlayerLife life = Get(playerId);
|
||||||
|
if (!life || !life.Connected || !life.UsedLife || !life.ReconnectPending || !ERR_PlayerLifeRules.CanEnter(false, phase)) return false;
|
||||||
|
if (ERR_Actors.Alive(life.Actor)) return false;
|
||||||
|
life.Actor = null;
|
||||||
|
life.UsedLife = false;
|
||||||
|
life.ReconnectPending = false;
|
||||||
|
m_OnChanged.Invoke(playerId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void Spawned(int playerId, IEntity actor)
|
void Spawned(int playerId, IEntity actor)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || !actor) return;
|
if (!Replication.IsServer() || !actor) return;
|
||||||
@@ -73,13 +86,18 @@ class ERR_PlayerRoster
|
|||||||
if (!life) return;
|
if (!life) return;
|
||||||
life.Actor = actor;
|
life.Actor = actor;
|
||||||
life.UsedLife = true;
|
life.UsedLife = true;
|
||||||
|
life.ReconnectPending = false;
|
||||||
m_OnChanged.Invoke(playerId);
|
m_OnChanged.Invoke(playerId);
|
||||||
}
|
}
|
||||||
void Disconnect(int playerId)
|
void Disconnect(int playerId)
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer()) return;
|
if (!Replication.IsServer()) return;
|
||||||
ERR_PlayerLife life = Get(playerId);
|
ERR_PlayerLife life = Get(playerId);
|
||||||
if (life) life.Connected = false;
|
if (life)
|
||||||
|
{
|
||||||
|
life.Connected = false;
|
||||||
|
life.ReconnectPending = life.UsedLife;
|
||||||
|
}
|
||||||
m_Connections.Remove(playerId);
|
m_Connections.Remove(playerId);
|
||||||
m_OnChanged.Invoke(playerId);
|
m_OnChanged.Invoke(playerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
modded enum ChimeraMenuPreset
|
||||||
|
{
|
||||||
|
ERR_PreparationFailure
|
||||||
|
}
|
||||||
|
|
||||||
|
// The native loading placeholder is not a menu and has no focus/input lifetime.
|
||||||
|
// Use a real local menu on failure; never grant admission or change server state.
|
||||||
|
class ERR_PreparationFailureMenu : ChimeraMenuBase
|
||||||
|
{
|
||||||
|
protected ERR_GameMode m_Mode;
|
||||||
|
protected SCR_ButtonTextComponent m_ReturnButton, m_PauseButton;
|
||||||
|
protected TextWidget m_Description;
|
||||||
|
protected string m_LastError;
|
||||||
|
protected bool m_Bound, m_Leaving;
|
||||||
|
|
||||||
|
static bool Failed(ERR_GameMode mode)
|
||||||
|
{
|
||||||
|
return mode && mode == ERR_GameMode.Get() && mode.Phase() == ERR_Phase.PREPARING && !mode.PreparationError().IsEmpty();
|
||||||
|
}
|
||||||
|
static bool Show(ERR_GameMode mode)
|
||||||
|
{
|
||||||
|
if (System.IsConsoleApp() || !Failed(mode) || !GetGame() || !GetGame().GetMenuManager()) return false;
|
||||||
|
MenuManager manager = GetGame().GetMenuManager();
|
||||||
|
// Leave existing menus and exit confirmation dialogs in control of focus.
|
||||||
|
if (manager.IsAnyMenuOpen() || manager.IsAnyDialogOpen()) return true;
|
||||||
|
if (manager.OpenMenu(ChimeraMenuPreset.ERR_PreparationFailure)) return true;
|
||||||
|
// A missing custom layout must not trap the player on the loading overlay.
|
||||||
|
GetGame().OpenPauseMenu(false, true);
|
||||||
|
return manager.FindMenuByPreset(ChimeraMenuPreset.PauseMenu) != null;
|
||||||
|
}
|
||||||
|
override void OnMenuOpen()
|
||||||
|
{
|
||||||
|
super.OnMenuOpen();
|
||||||
|
m_Mode = ERR_GameMode.Get();
|
||||||
|
if (!Failed(m_Mode)) { Close(); return; }
|
||||||
|
m_Description = TextWidget.Cast(GetRootWidget().FindAnyWidget("FailureDescription"));
|
||||||
|
m_ReturnButton = SCR_ButtonTextComponent.GetButtonText("ReturnToMainMenu", GetRootWidget());
|
||||||
|
m_PauseButton = SCR_ButtonTextComponent.GetButtonText("OpenPauseMenu", GetRootWidget());
|
||||||
|
if (m_ReturnButton) m_ReturnButton.m_OnClicked.Insert(OnReturn);
|
||||||
|
if (m_PauseButton) m_PauseButton.m_OnClicked.Insert(OnPause);
|
||||||
|
GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.PRESSED, OnBack);
|
||||||
|
m_Bound = true;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
protected void Refresh()
|
||||||
|
{
|
||||||
|
string detail = ERR_ObjectiveText.Description(m_Mode, false);
|
||||||
|
if (m_Description && detail != m_LastError) { m_Description.SetText(detail); m_LastError = detail; }
|
||||||
|
}
|
||||||
|
override void OnMenuUpdate(float tDelta)
|
||||||
|
{
|
||||||
|
super.OnMenuUpdate(tDelta);
|
||||||
|
if (!Failed(m_Mode)) { Close(); return; }
|
||||||
|
if (!m_Leaving) Refresh();
|
||||||
|
}
|
||||||
|
protected void OpenPause()
|
||||||
|
{
|
||||||
|
if (!IsFocused() || m_Leaving || !Failed(m_Mode)) return;
|
||||||
|
GetGame().OpenPauseMenu(false, true);
|
||||||
|
}
|
||||||
|
protected void OnBack() { OpenPause(); }
|
||||||
|
protected void OnPause(SCR_ButtonBaseComponent button) { OpenPause(); }
|
||||||
|
protected void OnReturn(SCR_ButtonBaseComponent button)
|
||||||
|
{
|
||||||
|
if (!IsFocused() || m_Leaving || !Failed(m_Mode)) return;
|
||||||
|
m_Leaving = true;
|
||||||
|
if (m_ReturnButton) m_ReturnButton.SetEnabled(false);
|
||||||
|
if (m_PauseButton) m_PauseButton.SetEnabled(false);
|
||||||
|
ChimeraWorld world = GetGame().GetWorld();
|
||||||
|
if (world) world.PauseGameTime(false);
|
||||||
|
// Same local exit transition as vanilla's pause-menu exit. No mission RPC.
|
||||||
|
GameStateTransitions.RequestGameplayEndTransition();
|
||||||
|
}
|
||||||
|
override void OnMenuClose()
|
||||||
|
{
|
||||||
|
if (m_Bound && GetGame() && GetGame().GetInputManager())
|
||||||
|
GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.PRESSED, OnBack);
|
||||||
|
m_Bound = false;
|
||||||
|
if (m_ReturnButton) m_ReturnButton.m_OnClicked.Remove(OnReturn);
|
||||||
|
if (m_PauseButton) m_PauseButton.m_OnClicked.Remove(OnPause);
|
||||||
|
m_ReturnButton = null; m_PauseButton = null; m_Description = null; m_Mode = null;
|
||||||
|
super.OnMenuClose();
|
||||||
|
}
|
||||||
|
#ifdef WORKBENCH
|
||||||
|
static bool Visible(ERR_GameMode mode)
|
||||||
|
{
|
||||||
|
if (!Failed(mode)) return false;
|
||||||
|
ERR_PreparationFailureMenu menu = ERR_PreparationFailureMenu.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.ERR_PreparationFailure));
|
||||||
|
return menu && menu.m_Mode == mode && menu.GetRootWidget().IsVisible() && menu.m_Description && menu.m_ReturnButton && menu.m_PauseButton && menu.m_Description.GetText() == ERR_ObjectiveText.Description(mode, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -109,6 +109,10 @@ modded class SCR_RespawnSystemComponent
|
|||||||
if (m_ERRPreparationSpinner) m_ERRPreparationSpinner.SetVisible(m_ERRPreparationSpinnerWasVisible);
|
if (m_ERRPreparationSpinner) m_ERRPreparationSpinner.SetVisible(m_ERRPreparationSpinnerWasVisible);
|
||||||
m_ERRPreparationSpinnerHidden = false;
|
m_ERRPreparationSpinnerHidden = false;
|
||||||
}
|
}
|
||||||
|
// The placeholder's high-Z black layer would obscure even the pause menu.
|
||||||
|
// Hide it only after an interactive menu is available; native updates restore
|
||||||
|
// it if preparation recovers. The failed round still admits no players.
|
||||||
|
if (failed && ERR_PreparationFailureMenu.Show(mode)) m_wLoadingPlaceholder.SetVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void DestroyLoadingPlaceholder()
|
override void DestroyLoadingPlaceholder()
|
||||||
@@ -130,6 +134,7 @@ modded class SCR_RespawnSystemComponent
|
|||||||
// Inspect the actual production-created widgets, without creating or changing them.
|
// Inspect the actual production-created widgets, without creating or changing them.
|
||||||
bool ERR_ProbePreparationVisible(ERR_GameMode mode, bool failed)
|
bool ERR_ProbePreparationVisible(ERR_GameMode mode, bool failed)
|
||||||
{
|
{
|
||||||
|
if (failed && ERR_PreparationFailureMenu.Visible(mode)) return true;
|
||||||
if (!mode || mode != ERR_GameMode.Get() || m_pGameMode != mode || !m_wLoadingPlaceholder || !m_wLoadingPlaceholder.IsVisible()) return false;
|
if (!mode || mode != ERR_GameMode.Get() || m_pGameMode != mode || !m_wLoadingPlaceholder || !m_wLoadingPlaceholder.IsVisible()) return false;
|
||||||
if (!m_ERRPreparationRoot || m_ERRPreparationParent != m_wLoadingPlaceholder || m_ERRPreparationRoot.GetParent() != m_wLoadingPlaceholder || !m_ERRPreparationRoot.IsVisible()) return false;
|
if (!m_ERRPreparationRoot || m_ERRPreparationParent != m_wLoadingPlaceholder || m_ERRPreparationRoot.GetParent() != m_wLoadingPlaceholder || !m_ERRPreparationRoot.IsVisible()) return false;
|
||||||
if (!ERR_PreparationWidgetVisible(m_ERRPreparationTitle) || !ERR_PreparationWidgetVisible(m_ERRPreparationDescription) || !ERR_PreparationWidgetVisible(m_ERRPreparationRoot)) return false;
|
if (!ERR_PreparationWidgetVisible(m_ERRPreparationTitle) || !ERR_PreparationWidgetVisible(m_ERRPreparationDescription) || !ERR_PreparationWidgetVisible(m_ERRPreparationRoot)) return false;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class ERR_ProfileConfig
|
|||||||
static const string VOICE = "$profile:EscapistsWelcomeVoice.json";
|
static const string VOICE = "$profile:EscapistsWelcomeVoice.json";
|
||||||
static array<string> LegacyPaths()
|
static array<string> LegacyPaths()
|
||||||
{
|
{
|
||||||
return {ERR_Settings.PATH, ERR_ContentSettings.PATH, ERR_FactionSelection.PATH, ERR_TerrainPreference.PATH, ERR_ItemPreferences.PATH, VOICE};
|
return {ERR_Settings.PATH, ERR_ContentSettings.PATH, ERR_FactionSelection.PATH, ERR_TerrainPreference.PATH, ERR_ItemPreferences.PATH, ERR_StartBackpack.PATH, VOICE};
|
||||||
}
|
}
|
||||||
static string Section(string path)
|
static string Section(string path)
|
||||||
{
|
{
|
||||||
@@ -15,6 +15,7 @@ class ERR_ProfileConfig
|
|||||||
if (path == ERR_FactionSelection.PATH) return "factions";
|
if (path == ERR_FactionSelection.PATH) return "factions";
|
||||||
if (path == ERR_TerrainPreference.PATH) return "terrain";
|
if (path == ERR_TerrainPreference.PATH) return "terrain";
|
||||||
if (path == ERR_ItemPreferences.PATH) return "items";
|
if (path == ERR_ItemPreferences.PATH) return "items";
|
||||||
|
if (path == ERR_StartBackpack.PATH) return "startBackpack";
|
||||||
if (path == VOICE) return "voice";
|
if (path == VOICE) return "voice";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -86,6 +87,7 @@ class ERR_ProfileConfig
|
|||||||
if (section == "factions") return ERR_FactionSelection.Parse(json, roles);
|
if (section == "factions") return ERR_FactionSelection.Parse(json, roles);
|
||||||
if (section == "terrain") return ERR_TerrainPreference.Parse(json, scenario);
|
if (section == "terrain") return ERR_TerrainPreference.Parse(json, scenario);
|
||||||
if (section == "items") return ERR_ItemPreferences.Parse(json, records);
|
if (section == "items") return ERR_ItemPreferences.Parse(json, records);
|
||||||
|
if (section == "startBackpack") return ERR_StartBackpack.Parse(json, records);
|
||||||
string url;
|
string url;
|
||||||
return section == "voice" && json.ReadValue("welcomeUrl", url) && (url.IsEmpty() || ERR_WelcomeVoiceRules.URL(url));
|
return section == "voice" && json.ReadValue("welcomeUrl", url) && (url.IsEmpty() || ERR_WelcomeVoiceRules.URL(url));
|
||||||
}
|
}
|
||||||
@@ -95,6 +97,7 @@ class ERR_ProfileConfig
|
|||||||
if (section == "factions") return "{\"escapists\":\"us\",\"enemy\":\"ussr\",\"independent\":\"fia\"}";
|
if (section == "factions") return "{\"escapists\":\"us\",\"enemy\":\"ussr\",\"independent\":\"fia\"}";
|
||||||
if (section == "terrain") return "{\"scenario\":\"\"}";
|
if (section == "terrain") return "{\"scenario\":\"\"}";
|
||||||
if (section == "items") return "{\"version\":1,\"records\":[\"active\"]}";
|
if (section == "items") return "{\"version\":1,\"records\":[\"active\"]}";
|
||||||
|
if (section == "startBackpack") return "{\"version\":1,\"records\":[\"default\"]}";
|
||||||
if (section == "voice") return "{\"welcomeUrl\":\"\"}";
|
if (section == "voice") return "{\"welcomeUrl\":\"\"}";
|
||||||
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
||||||
foreach (string key : ERR_Settings.Keys())
|
foreach (string key : ERR_Settings.Keys())
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
// Immutable snapshots only: never tick native effects or alter a patient's zones.
|
||||||
|
// Seconds: >=0 = predicted wake, -1 = beyond horizon, -2 = unsupported/uncertain.
|
||||||
|
class ERR_RecoveryFlow
|
||||||
|
{
|
||||||
|
bool Passive;
|
||||||
|
float BloodRate;
|
||||||
|
float ResilienceRate;
|
||||||
|
float Delay;
|
||||||
|
float End = 301;
|
||||||
|
}
|
||||||
|
class ERR_RecoveryForecast
|
||||||
|
{
|
||||||
|
static bool KeepsRound(float forecast, bool selfRescue, bool existingRecovery)
|
||||||
|
{
|
||||||
|
return selfRescue || forecast >= 0 || (forecast == -2 && existingRecovery);
|
||||||
|
}
|
||||||
|
static float Horizon() { return 300; }
|
||||||
|
static bool Awake(float blood, float resilience, float bloodThreshold, float resilienceThreshold)
|
||||||
|
{
|
||||||
|
return blood > bloodThreshold && resilience > resilienceThreshold;
|
||||||
|
}
|
||||||
|
static float Overlap(float start, float end, float delay, float expires)
|
||||||
|
{
|
||||||
|
return Math.Max(0, Math.Min(end, expires) - Math.Max(start, delay));
|
||||||
|
}
|
||||||
|
static float Predict(float blood, float resilience, float bloodThreshold, float resilienceThreshold, array<ref ERR_RecoveryFlow> flows)
|
||||||
|
{
|
||||||
|
if (Awake(blood, resilience, bloodThreshold, resilienceThreshold)) return 0;
|
||||||
|
for (int second = 0; second < 300; second++)
|
||||||
|
{
|
||||||
|
// All flow starts/ends partition this second, including finite medicines.
|
||||||
|
float time = second;
|
||||||
|
while (time < second + 1)
|
||||||
|
{
|
||||||
|
float next = second + 1;
|
||||||
|
foreach (ERR_RecoveryFlow flow : flows)
|
||||||
|
{
|
||||||
|
if (flow.Delay > time && flow.Delay < next) next = flow.Delay;
|
||||||
|
if (flow.End > time && flow.End < next) next = flow.End;
|
||||||
|
}
|
||||||
|
float db, dr;
|
||||||
|
foreach (ERR_RecoveryFlow rate : flows)
|
||||||
|
{
|
||||||
|
float duration = Overlap(time, next, rate.Delay, rate.End);
|
||||||
|
db += rate.BloodRate * duration; dr += rate.ResilienceRate * duration;
|
||||||
|
}
|
||||||
|
blood = Math.Clamp(blood + db, 0, 1);
|
||||||
|
resilience = Math.Clamp(resilience + dr, 0, 1);
|
||||||
|
if (Awake(blood, resilience, bloodThreshold, resilienceThreshold)) return next;
|
||||||
|
time = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
static float Estimate(SCR_CharacterDamageManagerComponent damage)
|
||||||
|
{
|
||||||
|
if (!damage || !damage.ERR_IsRevivablePlayer()) return -2;
|
||||||
|
return damage.ERR_ForecastRecovery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class SCR_PassiveHitZoneRegenDamageEffect
|
||||||
|
{
|
||||||
|
float ERR_RemainingRegenDelay() { return Math.Max(0, m_fLocalRegenDelayTime - m_fDelayTimer); }
|
||||||
|
}
|
||||||
|
modded class SCR_CharacterDamageManagerComponent
|
||||||
|
{
|
||||||
|
float ERR_ForecastRecovery()
|
||||||
|
{
|
||||||
|
SCR_CharacterBloodHitZone blood = GetBloodHitZone();
|
||||||
|
SCR_CharacterResilienceHitZone resilience = GetResilienceHitZone();
|
||||||
|
if (!blood || !resilience || blood.GetMaxHealth() <= 0 || resilience.GetMaxHealth() <= 0) return -2;
|
||||||
|
if (m_aBeingHealedGroup && !m_aBeingHealedGroup.IsEmpty()) return -2;
|
||||||
|
array<ref ERR_RecoveryFlow> flows = {};
|
||||||
|
array<ref SCR_PersistentDamageEffect> effects = GetAllPersistentEffectsOfType(SCR_PersistentDamageEffect, true);
|
||||||
|
bool bloodChanges, passiveResilience, unknown, pausedNatural;
|
||||||
|
foreach (SCR_PersistentDamageEffect effect : effects)
|
||||||
|
{
|
||||||
|
DotDamageEffect dot = DotDamageEffect.Cast(effect);
|
||||||
|
if (!dot) { unknown = true; continue; }
|
||||||
|
HitZone zone = dot.GetAffectedHitZone();
|
||||||
|
typename kind = effect.Type();
|
||||||
|
bool bleeding = kind == SCR_BleedingDamageEffect;
|
||||||
|
bool passive = kind == SCR_PassiveHitZoneRegenDamageEffect;
|
||||||
|
bool saline = kind == SCR_SalineDamageEffect;
|
||||||
|
bool epi = kind == ERR_EpinephrineEffect;
|
||||||
|
// Physical wound regen and native morphine do not restore consciousness.
|
||||||
|
if (kind == SCR_PhysicalHitZonesRegenDamageEffect || kind == SCR_MorphineDamageEffect) continue;
|
||||||
|
if (passive && !effect.IsActive()) { pausedNatural = true; continue; }
|
||||||
|
if (!effect.IsActive()) { unknown = true; continue; }
|
||||||
|
if (!bleeding && !passive && !saline && !epi) { unknown = true; continue; }
|
||||||
|
if (!bleeding && zone != blood && zone != resilience) continue;
|
||||||
|
ERR_RecoveryFlow flow = new ERR_RecoveryFlow();
|
||||||
|
flow.Passive = passive;
|
||||||
|
float maximum = dot.GetMaxDuration();
|
||||||
|
if (maximum > 0) flow.End = Math.Max(0, maximum - dot.GetCurrentDuration());
|
||||||
|
HitZone target = zone;
|
||||||
|
if (bleeding) target = blood;
|
||||||
|
float rate = -dot.GetDPS() * target.GetBaseDamageMultiplier() * target.GetDamageMultiplier(dot.GetDamageType());
|
||||||
|
if (passive)
|
||||||
|
{
|
||||||
|
flow.Delay = SCR_PassiveHitZoneRegenDamageEffect.Cast(effect).ERR_RemainingRegenDelay();
|
||||||
|
// A terminated blood regen can still be visible until native cleanup.
|
||||||
|
if (IsBleeding()) rate = 0;
|
||||||
|
if (zone == resilience) passiveResilience = true;
|
||||||
|
}
|
||||||
|
if (bleeding)
|
||||||
|
{
|
||||||
|
SCR_CharacterHitZone wound = SCR_CharacterHitZone.Cast(zone);
|
||||||
|
if (!wound) { unknown = true; continue; }
|
||||||
|
if (GetGroupTourniquetted(wound.GetHitZoneGroup())) rate *= GetTourniquetStrengthMultiplier();
|
||||||
|
flow.BloodRate = rate / blood.GetMaxHealth();
|
||||||
|
// Expiring bleeding can create new delayed native regen: do not declare
|
||||||
|
// hopelessness based on a snapshot that cannot yet contain that effect.
|
||||||
|
if (flow.End <= 300) unknown = true;
|
||||||
|
}
|
||||||
|
else if (zone == blood) flow.BloodRate = rate / blood.GetMaxHealth();
|
||||||
|
else flow.ResilienceRate = rate / resilience.GetMaxHealth();
|
||||||
|
if (flow.BloodRate != 0) bloodChanges = true;
|
||||||
|
flows.Insert(flow);
|
||||||
|
}
|
||||||
|
// Native treatment suppresses passive resilience regeneration while the
|
||||||
|
// medicine acts. Do not add both DPS values as simultaneous recovery.
|
||||||
|
bool treatmentOverlap;
|
||||||
|
foreach (ERR_RecoveryFlow regen : flows)
|
||||||
|
{
|
||||||
|
if (!regen.Passive || regen.ResilienceRate <= 0) continue;
|
||||||
|
foreach (ERR_RecoveryFlow medicine : flows)
|
||||||
|
{
|
||||||
|
if (medicine.Passive || medicine.ResilienceRate <= 0) continue;
|
||||||
|
regen.Delay = Math.Max(regen.Delay, medicine.End);
|
||||||
|
treatmentOverlap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float bt = blood.GetDamageStateThreshold(ECharacterBloodState.UNCONSCIOUS);
|
||||||
|
float rt = resilience.GetDamageStateThreshold(ECharacterResilienceState.WEAKENED);
|
||||||
|
float predicted = ERR_RecoveryForecast.Predict(blood.GetHealthScaled(), resilience.GetHealthScaled(), bt, rt, flows);
|
||||||
|
if (unknown || (pausedNatural && predicted < 0)) return -2;
|
||||||
|
// If the estimate needs post-treatment passive recovery, the native delay
|
||||||
|
// reset may move that start later. Retain safeguards instead of inventing it.
|
||||||
|
if (treatmentOverlap)
|
||||||
|
foreach (ERR_RecoveryFlow treatment : flows)
|
||||||
|
if (!treatment.Passive && treatment.ResilienceRate > 0 && (predicted < 0 || predicted > treatment.End)) return -2;
|
||||||
|
// Native resilience rates depend on changing blood-state bands. A snapshot's
|
||||||
|
// DPS cannot establish that future rate. Use an optimistic blood-only bound
|
||||||
|
// to prove impossibility; otherwise defer rather than kill a viable casualty.
|
||||||
|
if (bloodChanges && passiveResilience)
|
||||||
|
{
|
||||||
|
float optimistic = ERR_RecoveryForecast.Predict(blood.GetHealthScaled(), 1, bt, rt, flows);
|
||||||
|
if (optimistic < 0) return -1;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
return predicted;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ class ERR_RecoveryService
|
|||||||
protected float m_NextMedicalLog;
|
protected float m_NextMedicalLog;
|
||||||
protected string m_MedicalDetails;
|
protected string m_MedicalDetails;
|
||||||
protected bool m_DefeatLogged;
|
protected bool m_DefeatLogged;
|
||||||
|
protected float m_NextForecast;
|
||||||
protected ref ScriptInvoker m_OnChanged = new ScriptInvoker();
|
protected ref ScriptInvoker m_OnChanged = new ScriptInvoker();
|
||||||
void ERR_RecoveryService(ERR_GameMode mode) { m_Mode = mode; }
|
void ERR_RecoveryService(ERR_GameMode mode) { m_Mode = mode; }
|
||||||
ScriptInvoker OnChanged() { return m_OnChanged; }
|
ScriptInvoker OnChanged() { return m_OnChanged; }
|
||||||
@@ -55,7 +56,7 @@ class ERR_RecoveryService
|
|||||||
if (due && !m_DefeatLogged)
|
if (due && !m_DefeatLogged)
|
||||||
{
|
{
|
||||||
m_DefeatLogged = true;
|
m_DefeatLogged = true;
|
||||||
ERR_HQ.Event("MEDICAL DEFEAT", "30 seconds without a viable rescuer or recovery; " + m_MedicalDetails);
|
ERR_HQ.Event("MEDICAL DEFEAT", "30 seconds without a viable rescuer, self-injection or recovery within five minutes; " + m_MedicalDetails);
|
||||||
}
|
}
|
||||||
return due;
|
return due;
|
||||||
}
|
}
|
||||||
@@ -70,9 +71,11 @@ class ERR_RecoveryService
|
|||||||
{
|
{
|
||||||
if (!Replication.IsServer() || m_Stopped || !m_Mode || !m_Mode.Active()) return;
|
if (!Replication.IsServer() || m_Stopped || !m_Mode || !m_Mode.Active()) return;
|
||||||
float now = GetGame().GetWorld().GetWorldTime();
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
|
if (now >= m_NextForecast - 1000 && now < m_NextForecast) return;
|
||||||
|
m_NextForecast = now + 1000;
|
||||||
bool logMedical = now >= m_NextMedicalLog;
|
bool logMedical = now >= m_NextMedicalLog;
|
||||||
string medicalDetails;
|
string medicalDetails;
|
||||||
int conscious, incapacitated, reserved, reservedRescuers, recovering;
|
int conscious, incapacitated, reserved, reservedRescuers, recovering, selfRescuers, uncertain;
|
||||||
map<IEntity, ref ERR_RecoverySample> nextSamples = new map<IEntity, ref ERR_RecoverySample>();
|
map<IEntity, ref ERR_RecoverySample> nextSamples = new map<IEntity, ref ERR_RecoverySample>();
|
||||||
array<ref ERR_PlayerLife> lives = {};
|
array<ref ERR_PlayerLife> lives = {};
|
||||||
m_Mode.Players().Participants(lives);
|
m_Mode.Players().Participants(lives);
|
||||||
@@ -99,7 +102,12 @@ class ERR_RecoveryService
|
|||||||
bool improving = previous && (sample.Blood > previous.Blood + 0.001 || sample.Resilience > previous.Resilience + 0.001);
|
bool improving = previous && (sample.Blood > previous.Blood + 0.001 || sample.Resilience > previous.Resilience + 0.001);
|
||||||
bool treatment = medical.ERR_TreatmentInProgress();
|
bool treatment = medical.ERR_TreatmentInProgress();
|
||||||
bool natural = medical.ERR_CanRecoverNaturally();
|
bool natural = medical.ERR_CanRecoverNaturally();
|
||||||
if (improving || treatment || natural) recovering++;
|
float forecast = ERR_RecoveryForecast.Estimate(medical);
|
||||||
|
bool selfRescue = life.Connected && controlled == life.Actor && m_Mode.Settings().Get("selfEpinephrine") == 1 && ERR_SelfEpinephrineInventory.FindUsable(life.Actor);
|
||||||
|
if (selfRescue) selfRescuers++;
|
||||||
|
if (forecast == -2) uncertain++;
|
||||||
|
if (ERR_RecoveryForecast.KeepsRound(forecast, selfRescue, improving || treatment || natural)) recovering++;
|
||||||
|
medicalDetails += string.Format("forecastSeconds=%1 selfInjection=%2; ", forecast, selfRescue);
|
||||||
medicalDetails += string.Format("player=%1 connected=%2 blood=%3 resilience=%4 bleeding=%5 improving=%6 treatment=%7 naturalRecovery=%8; ", life.ConnectionId, life.Connected, sample.Blood, sample.Resilience, medical.IsBleeding(), improving, treatment, natural);
|
medicalDetails += string.Format("player=%1 connected=%2 blood=%3 resilience=%4 bleeding=%5 improving=%6 treatment=%7 naturalRecovery=%8; ", life.ConnectionId, life.Connected, sample.Blood, sample.Resilience, medical.IsBleeding(), improving, treatment, natural);
|
||||||
nextSamples.Insert(life.Actor, sample);
|
nextSamples.Insert(life.Actor, sample);
|
||||||
}
|
}
|
||||||
@@ -122,9 +130,11 @@ class ERR_RecoveryService
|
|||||||
{
|
{
|
||||||
message = "No conscious prisoner is currently available to help.";
|
message = "No conscious prisoner is currently available to help.";
|
||||||
if (evacuating) message += " The rescue crew is carrying all living prisoners to safety; evacuation continues.";
|
if (evacuating) message += " The rescue crew is carrying all living prisoners to safety; evacuation continues.";
|
||||||
else if (recovering > 0) message += " Treatment or natural recovery is possible; the round continues.";
|
else if (selfRescuers > 0) message += " Self epinephrine is available. Press Space to use your carried injector; the round continues.";
|
||||||
|
else if (recovering > 0 && uncertain > 0) message += " Recovery timing is uncertain; existing treatment and recovery safeguards remain active.";
|
||||||
|
else if (recovering > 0) message += " A prisoner is expected to wake within five minutes under current medical conditions.";
|
||||||
else if (reservedRescuers > 0) message += " A conscious prisoner's reconnection may provide help.";
|
else if (reservedRescuers > 0) message += " A conscious prisoner's reconnection may provide help.";
|
||||||
else message += " Everyone is unconscious with no treatment or recovery progressing. The mission fails after 30 uninterrupted seconds in this state.";
|
else message += " Nobody is expected to wake within five minutes and no self-injection is available. The mission fails after 30 uninterrupted seconds in this state.";
|
||||||
}
|
}
|
||||||
Publish(message);
|
Publish(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
// Round-local statistics are always available, independently of telemetry.
|
||||||
|
// Only authoritative participant bodies own records; transient connection IDs
|
||||||
|
// and native winner-ID lists never decide kill credit or escape results.
|
||||||
|
class ERR_RoundPlayerStats
|
||||||
|
{
|
||||||
|
UUID Account;
|
||||||
|
string Name;
|
||||||
|
IEntity Actor;
|
||||||
|
bool Connected;
|
||||||
|
bool Down;
|
||||||
|
int Kills;
|
||||||
|
int FriendlyKills;
|
||||||
|
int Deaths;
|
||||||
|
int Downed;
|
||||||
|
int Recoveries;
|
||||||
|
}
|
||||||
|
class ERR_RoundStatistics
|
||||||
|
{
|
||||||
|
protected ERR_GameMode m_Mode;
|
||||||
|
protected ref array<ref ERR_RoundPlayerStats> m_Players = {};
|
||||||
|
protected bool m_Finished;
|
||||||
|
protected bool m_Truncated;
|
||||||
|
protected int m_StartedAt = -1;
|
||||||
|
void ERR_RoundStatistics(ERR_GameMode mode) { m_Mode = mode; }
|
||||||
|
ERR_RoundPlayerStats Find(UUID account)
|
||||||
|
{
|
||||||
|
foreach (ERR_RoundPlayerStats row : m_Players) if (row.Account == account) return row;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
protected ERR_RoundPlayerStats Body(IEntity actor)
|
||||||
|
{
|
||||||
|
if (!actor) return null;
|
||||||
|
foreach (ERR_RoundPlayerStats row : m_Players) if (row.Actor == actor) return row;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
static string DisplayName(string name)
|
||||||
|
{
|
||||||
|
name.Replace("\n", " "); name.Replace("\r", " "); name.Replace("\t", " ");
|
||||||
|
if (name.Length() > 48) name = name.Substring(0, 48);
|
||||||
|
if (name.IsEmpty()) return "Player";
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
void RosterChanged(int playerId) { Sync(); }
|
||||||
|
void Sync()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Finished || !m_Mode || !m_Mode.Players()) return;
|
||||||
|
array<ref ERR_PlayerLife> lives = {}; m_Mode.Players().Participants(lives);
|
||||||
|
foreach (ERR_PlayerLife life : lives)
|
||||||
|
{
|
||||||
|
ERR_RoundPlayerStats row = Find(life.AccountId);
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
if (m_Players.Count() >= 128) { m_Truncated = true; continue; }
|
||||||
|
row = new ERR_RoundPlayerStats(); row.Account = life.AccountId; m_Players.Insert(row);
|
||||||
|
}
|
||||||
|
row.Connected = life.Connected;
|
||||||
|
if (life.Connected) row.Name = DisplayName(GetGame().GetPlayerManager().GetPlayerName(life.ConnectionId));
|
||||||
|
if (row.Actor != life.Actor) { row.Actor = life.Actor; row.Down = false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A consciousness edge is a down/recovery, not a death. Repeated callbacks
|
||||||
|
// cannot count the same incapacitation twice; corpse deletion is not a kill.
|
||||||
|
static void Consciousness(ERR_RoundPlayerStats row, bool conscious)
|
||||||
|
{
|
||||||
|
if (!row) return;
|
||||||
|
if (!conscious && !row.Down) row.Downed++;
|
||||||
|
if (conscious && row.Down) row.Recoveries++;
|
||||||
|
row.Down = !conscious;
|
||||||
|
}
|
||||||
|
void ConsciousnessChanged(IEntity actor, bool conscious)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Finished || !m_Mode || !m_Mode.Active() || !ERR_Actors.Alive(actor)) return;
|
||||||
|
Sync(); Consciousness(Body(actor), conscious);
|
||||||
|
}
|
||||||
|
static void CountDeath(ERR_RoundPlayerStats victim, ERR_RoundPlayerStats killer, bool friendly, bool credit)
|
||||||
|
{
|
||||||
|
if (victim) { victim.Deaths++; victim.Down = false; }
|
||||||
|
if (!credit || !killer || victim == killer) return;
|
||||||
|
if (friendly) killer.FriendlyKills++;
|
||||||
|
else killer.Kills++;
|
||||||
|
}
|
||||||
|
void Killed(IEntity victim, IEntity killerEntity, Instigator instigator)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Finished || !m_Mode || !m_Mode.Active() || !ChimeraCharacter.Cast(victim)) return;
|
||||||
|
SCR_CharacterDamageManagerComponent damage = SCR_CharacterDamageManagerComponent.Cast(victim.FindComponent(SCR_CharacterDamageManagerComponent));
|
||||||
|
if (!damage || !damage.IsDestroyed()) return;
|
||||||
|
Sync();
|
||||||
|
ERR_RoundPlayerStats killed = Body(victim);
|
||||||
|
// Native damage normally provides the original instigator body, including
|
||||||
|
// delayed explosives. Never recover credit from a possibly recycled player ID.
|
||||||
|
IEntity source = killerEntity;
|
||||||
|
if (!ChimeraCharacter.Cast(source) && instigator) source = instigator.GetInstigatorEntity();
|
||||||
|
ERR_RoundPlayerStats killer = Body(source);
|
||||||
|
if (!killed && !killer) return;
|
||||||
|
if (!damage.ERR_ClaimRoundDeath()) return;
|
||||||
|
bool credit = instigator && instigator.GetInstigatorType() != InstigatorType.INSTIGATOR_GM;
|
||||||
|
bool friendly = killed != null;
|
||||||
|
Faction faction = SCR_FactionManager.SGetFaction(victim);
|
||||||
|
if (faction && faction == m_Mode.PlayerFaction()) friendly = true;
|
||||||
|
CountDeath(killed, killer, friendly, credit);
|
||||||
|
}
|
||||||
|
void PhaseChanged(ERR_Phase previous, ERR_Phase current)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Finished) return;
|
||||||
|
if (m_StartedAt < 0 && current >= ERR_Phase.PRISON && current <= ERR_Phase.EXTRACTION) m_StartedAt = System.GetTickCount();
|
||||||
|
if (ERR_MissionRules.Terminal(current)) Finish();
|
||||||
|
}
|
||||||
|
protected string Outcome(ERR_RoundPlayerStats row)
|
||||||
|
{
|
||||||
|
if (m_Mode.Extraction() && m_Mode.Extraction().DidEscape(row.Account)) return "Escaped";
|
||||||
|
if (row.Deaths > 0 && !ERR_Actors.Alive(row.Actor)) return "Dead";
|
||||||
|
if (!row.Connected) return "Disconnected - did not escape";
|
||||||
|
if (row.Down) return "Down - did not escape";
|
||||||
|
return "Did not escape";
|
||||||
|
}
|
||||||
|
void Finish()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_Finished || !m_Mode) return;
|
||||||
|
Sync(); m_Finished = true;
|
||||||
|
int seconds;
|
||||||
|
if (m_StartedAt >= 0) seconds = Math.Max(0, (System.GetTickCount() - m_StartedAt) / 1000);
|
||||||
|
int kills, friendly, deaths, downed, recovered, escaped;
|
||||||
|
string rows;
|
||||||
|
foreach (ERR_RoundPlayerStats row : m_Players)
|
||||||
|
{
|
||||||
|
kills += row.Kills; friendly += row.FriendlyKills; deaths += row.Deaths; downed += row.Downed; recovered += row.Recoveries;
|
||||||
|
if (m_Mode.Extraction() && m_Mode.Extraction().DidEscape(row.Account)) escaped++;
|
||||||
|
if (!rows.IsEmpty()) rows += "\n\n";
|
||||||
|
rows += DisplayName(row.Name) + " - " + Outcome(row) + "\n";
|
||||||
|
rows += string.Format("Kills: %1 Friendly kills: %2 Deaths: %3 Downed: %4 Recoveries: %5", row.Kills, row.FriendlyKills, row.Deaths, row.Downed, row.Recoveries);
|
||||||
|
}
|
||||||
|
string summary = string.Format("Duration: %1m %2s Participants: %3 Escaped: %4\n", seconds / 60, Math.Mod(seconds, 60), m_Players.Count(), escaped);
|
||||||
|
summary += string.Format("Total kills: %1 Friendly kills: %2 Deaths: %3 Downed: %4 Recoveries: %5\n\n", kills, friendly, deaths, downed, recovered);
|
||||||
|
summary += "Downed counts unconscious episodes; recoveries include self-recovery. Deaths count fatal losses.\n\n";
|
||||||
|
if (rows.IsEmpty()) rows = "No players participated in this round.";
|
||||||
|
summary += rows;
|
||||||
|
if (m_Truncated) summary += "\n\nOnly the first 128 participants are shown; totals cover those players.";
|
||||||
|
m_Mode.ERR_PublishRoundStatistics(summary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class SCR_CharacterDamageManagerComponent
|
||||||
|
{
|
||||||
|
protected bool m_ERRRoundDeathCounted;
|
||||||
|
bool ERR_ClaimRoundDeath()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_ERRRoundDeathCounted) return false;
|
||||||
|
m_ERRRoundDeathCounted = true; return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class SCR_CharacterControllerComponent
|
||||||
|
{
|
||||||
|
override void OnConsciousnessChanged(bool conscious)
|
||||||
|
{
|
||||||
|
super.OnConsciousnessChanged(conscious);
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
if (mode && mode.ERR_Statistics()) mode.ERR_Statistics().ConsciousnessChanged(GetOwner(), conscious);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
modded class ERR_GameMode
|
||||||
|
{
|
||||||
|
protected ref ERR_RoundStatistics m_ERRStatistics;
|
||||||
|
[RplProp(onRplName: "ERR_OnRoundStatisticsReplicated")]
|
||||||
|
protected string m_ERRRoundSummary;
|
||||||
|
[RplProp(onRplName: "ERR_OnRoundStatisticsReplicated")]
|
||||||
|
protected string m_ERRCommunitySummary = "Community map records unavailable.";
|
||||||
|
protected ref ScriptInvoker m_ERRStatisticsChanged = new ScriptInvoker();
|
||||||
|
ERR_RoundStatistics ERR_Statistics() { return m_ERRStatistics; }
|
||||||
|
string ERR_RoundSummary()
|
||||||
|
{
|
||||||
|
if (m_ERRRoundSummary.IsEmpty()) return "";
|
||||||
|
return m_ERRCommunitySummary + "\n\n" + m_ERRRoundSummary;
|
||||||
|
}
|
||||||
|
void ERR_PublishCommunityStatistics(string summary)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || summary.Length() > 2048 || m_ERRCommunitySummary == summary) return;
|
||||||
|
m_ERRCommunitySummary = summary;
|
||||||
|
Replication.BumpMe(); ERR_OnRoundStatisticsReplicated();
|
||||||
|
}
|
||||||
|
ScriptInvoker ERR_OnStatisticsChanged() { return m_ERRStatisticsChanged; }
|
||||||
|
protected void ERR_OnRoundStatisticsReplicated() { m_ERRStatisticsChanged.Invoke(); }
|
||||||
|
void ERR_PublishRoundStatistics(string summary)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || !m_ERRRoundSummary.IsEmpty()) return;
|
||||||
|
m_ERRRoundSummary = summary;
|
||||||
|
Replication.BumpMe(); ERR_OnRoundStatisticsReplicated();
|
||||||
|
}
|
||||||
|
protected override void EOnInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.EOnInit(owner);
|
||||||
|
if (!Replication.IsServer() || SCR_Global.IsEditMode() || !Players()) return;
|
||||||
|
m_ERRStatistics = new ERR_RoundStatistics(this);
|
||||||
|
OnPhaseChanged().Insert(m_ERRStatistics.PhaseChanged);
|
||||||
|
Players().OnChanged().Insert(m_ERRStatistics.RosterChanged);
|
||||||
|
}
|
||||||
|
protected override void OnControllableDestroyed(IEntity entity, IEntity killerEntity, notnull Instigator instigator)
|
||||||
|
{
|
||||||
|
if (m_ERRStatistics) m_ERRStatistics.Killed(entity, killerEntity, instigator);
|
||||||
|
super.OnControllableDestroyed(entity, killerEntity, instigator);
|
||||||
|
}
|
||||||
|
protected override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
|
||||||
|
{
|
||||||
|
if (m_ERRStatistics) m_ERRStatistics.Killed(playerEntity, killerEntity, killer);
|
||||||
|
super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
|
||||||
|
}
|
||||||
|
protected override void OnGameModeEnd(SCR_GameModeEndData endData)
|
||||||
|
{
|
||||||
|
// Freeze before native shutdown can detach bodies or remove roster ownership.
|
||||||
|
if (m_ERRStatistics) m_ERRStatistics.Finish();
|
||||||
|
super.OnGameModeEnd(endData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,16 +63,16 @@ class ERR_ScenarioComponent : ScriptComponent
|
|||||||
#endif
|
#endif
|
||||||
#ifdef WORKBENCH
|
#ifdef WORKBENCH
|
||||||
string historicalFixture;
|
string historicalFixture;
|
||||||
if (!m_TerrainIndependent && System.GetCLIParam("errSmokeOutcome", historicalFixture) && historicalFixture != "normal-escape-route" && historicalFixture != "crash-start" && historicalFixture != "mounted-ammo" && historicalFixture != "alarm-hearing" && historicalFixture != "optional-site-skip" && historicalFixture != "infantry-combat" && historicalFixture != "site-garrisons" && historicalFixture != "generated-sites" && historicalFixture != "opening-tools" && historicalFixture != "airfield-markers" && historicalFixture != "air-recon" && historicalFixture != "air-logistics" && historicalFixture != "air-assault")
|
if (!m_TerrainIndependent && System.GetCLIParam("errSmokeOutcome", historicalFixture) && historicalFixture != "normal-escape-route" && historicalFixture != "crash-start" && historicalFixture != "mounted-ammo" && historicalFixture != "alarm-hearing" && historicalFixture != "optional-site-skip" && historicalFixture != "infantry-combat" && historicalFixture != "site-garrisons" && historicalFixture != "generated-sites" && historicalFixture != "roadblocks" && historicalFixture != "opening-tools" && historicalFixture != "airfield-markers" && historicalFixture != "air-recon" && historicalFixture != "air-logistics" && historicalFixture != "air-assault")
|
||||||
m_Definition = "{ACA98B44E2173605}Configs/ERR/Tests/LegacySites.conf";
|
if (historicalFixture != "sarka-hunters" && historicalFixture != "self-epinephrine" && historicalFixture != "unconscious-camera" && historicalFixture != "starter-backpack" && historicalFixture != "objective-map" && historicalFixture != "speech-download" && historicalFixture != "bundled-speech") m_Definition = "{ACA98B44E2173605}Configs/ERR/Tests/LegacySites.conf";
|
||||||
#endif
|
#endif
|
||||||
m_RuntimeDefinition = ERR_ScenarioDefinition.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab(m_Definition));
|
m_RuntimeDefinition = ERR_ScenarioDefinition.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab(m_Definition));
|
||||||
if (!m_RuntimeDefinition || !m_RuntimeDefinition.Valid()) { m_Failed = true; return ERR_PrepareResult.FAILED; }
|
if (!m_RuntimeDefinition || !m_RuntimeDefinition.Valid()) { m_Failed = true; return ERR_PrepareResult.FAILED; }
|
||||||
#ifdef WORKBENCH
|
#ifdef WORKBENCH
|
||||||
// Existing deterministic probes intentionally use authored coordinates.
|
// Existing deterministic probes intentionally use authored coordinates.
|
||||||
string fixture;
|
string fixture;
|
||||||
if (!m_TerrainIndependent && System.GetCLIParam("errSmokeOutcome", fixture) && fixture != "normal-escape-route" && fixture != "crash-start" && fixture != "mounted-ammo" && fixture != "alarm-hearing" && fixture != "optional-site-skip" && fixture != "infantry-combat" && fixture != "site-garrisons" && fixture != "generated-sites" && fixture != "airfield-markers" && fixture != "air-recon" && fixture != "air-logistics" && fixture != "air-assault")
|
if (!m_TerrainIndependent && System.GetCLIParam("errSmokeOutcome", fixture) && fixture != "normal-escape-route" && fixture != "crash-start" && fixture != "mounted-ammo" && fixture != "alarm-hearing" && fixture != "optional-site-skip" && fixture != "infantry-combat" && fixture != "site-garrisons" && fixture != "generated-sites" && fixture != "roadblocks" && fixture != "airfield-markers" && fixture != "air-recon" && fixture != "air-logistics" && fixture != "air-assault")
|
||||||
foreach (ERR_SiteDefinition fixedSite : m_RuntimeDefinition.Sites) fixedSite.RandomClear = false;
|
if (fixture != "sarka-hunters" && fixture != "self-epinephrine" && fixture != "unconscious-camera" && fixture != "starter-backpack" && fixture != "objective-map" && fixture != "speech-download" && fixture != "bundled-speech") foreach (ERR_SiteDefinition fixedSite : m_RuntimeDefinition.Sites) fixedSite.RandomClear = false;
|
||||||
if (!ERR_ConfigurePatrolHQFixture(fixture)) { m_Failed = true; return ERR_PrepareResult.FAILED; }
|
if (!ERR_ConfigurePatrolHQFixture(fixture)) { m_Failed = true; return ERR_PrepareResult.FAILED; }
|
||||||
#endif
|
#endif
|
||||||
if (m_Progressive && !m_RuntimeDefinition.ConfigurePopulation(m_Definition, mode.Settings().Get("fieldCampCount"), mode.Settings().Get("fieldHospitalCount")))
|
if (m_Progressive && !m_RuntimeDefinition.ConfigurePopulation(m_Definition, mode.Settings().Get("fieldCampCount"), mode.Settings().Get("fieldHospitalCount")))
|
||||||
@@ -114,7 +114,6 @@ class ERR_ScenarioComponent : ScriptComponent
|
|||||||
m_Finished = true;
|
m_Finished = true;
|
||||||
if (m_Progressive)
|
if (m_Progressive)
|
||||||
{
|
{
|
||||||
m_Generated.StartupOnly(false);
|
|
||||||
GetGame().GetCallqueue().CallLater(BackgroundStep, 250, true);
|
GetGame().GetCallqueue().CallLater(BackgroundStep, 250, true);
|
||||||
PrintFormat("Reintroduced [generation]: spawn-ready in %1 ms; remaining sites continue in background", System.GetTickCount() - m_PreparationStarted);
|
PrintFormat("Reintroduced [generation]: spawn-ready in %1 ms; remaining sites continue in background", System.GetTickCount() - m_PreparationStarted);
|
||||||
}
|
}
|
||||||
@@ -132,6 +131,9 @@ class ERR_ScenarioComponent : ScriptComponent
|
|||||||
if (!m_BackgroundActivated)
|
if (!m_BackgroundActivated)
|
||||||
{
|
{
|
||||||
if (GetGame().GetPlayerManager().GetPlayerCount() == 0) return;
|
if (GetGame().GetPlayerManager().GetPlayerCount() == 0) return;
|
||||||
|
// Resume the placement clock only when work can actually start. An empty
|
||||||
|
// server may have waited hours since the prison became spawn-ready.
|
||||||
|
m_Generated.StartupOnly(false);
|
||||||
m_BackgroundActivated = true;
|
m_BackgroundActivated = true;
|
||||||
}
|
}
|
||||||
if (!m_PlacementDone)
|
if (!m_PlacementDone)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ class ERR_SelectionStyle
|
|||||||
static void Action(SCR_ButtonTextComponent button, bool enable)
|
static void Action(SCR_ButtonTextComponent button, bool enable)
|
||||||
{
|
{
|
||||||
if (!button) return;
|
if (!button) return;
|
||||||
Color normal = Color.FromInt(0xFF8F2929), hover = Color.FromInt(0xFFB43B3B);
|
Color normal = Color.FromInt(ERR_MenuTheme.NEGATIVE), hover = Color.FromInt(ERR_MenuTheme.NEGATIVE_HOVER);
|
||||||
if (enable) { normal = Color.FromInt(0xFF246B3C); hover = Color.FromInt(0xFF31894F); }
|
if (enable) { normal = Color.FromInt(ERR_MenuTheme.POSITIVE); hover = Color.FromInt(ERR_MenuTheme.POSITIVE_HOVER); }
|
||||||
button.SetBackgroundColors(normal, hover, normal, hover, hover);
|
button.SetBackgroundColors(normal, hover, normal, hover, hover);
|
||||||
button.ColorizeBackground(false);
|
button.ColorizeBackground(false);
|
||||||
}
|
}
|
||||||
@@ -14,11 +14,11 @@ class ERR_SelectionStyle
|
|||||||
static void Choice(SCR_ButtonTextComponent button, bool selected, bool positive = true)
|
static void Choice(SCR_ButtonTextComponent button, bool selected, bool positive = true)
|
||||||
{
|
{
|
||||||
if (!button) return;
|
if (!button) return;
|
||||||
Color normal = Color.FromInt(0xFF454B52), hover = Color.FromInt(0xFF606870);
|
Color normal = Color.FromInt(ERR_MenuTheme.NEUTRAL), hover = Color.FromInt(ERR_MenuTheme.NEUTRAL_HOVER);
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
normal = Color.FromInt(0xFF246B3C); hover = Color.FromInt(0xFF31894F);
|
normal = Color.FromInt(ERR_MenuTheme.POSITIVE); hover = Color.FromInt(ERR_MenuTheme.POSITIVE_HOVER);
|
||||||
if (!positive) { normal = Color.FromInt(0xFF8F2929); hover = Color.FromInt(0xFFB43B3B); }
|
if (!positive) { normal = Color.FromInt(ERR_MenuTheme.NEGATIVE); hover = Color.FromInt(ERR_MenuTheme.NEGATIVE_HOVER); }
|
||||||
}
|
}
|
||||||
button.SetDisabledOpacity(1);
|
button.SetDisabledOpacity(1);
|
||||||
button.SetBackgroundColors(normal, hover, normal, hover, hover);
|
button.SetBackgroundColors(normal, hover, normal, hover, hover);
|
||||||
@@ -34,10 +34,10 @@ class ERR_SelectionStyle
|
|||||||
{
|
{
|
||||||
SCR_ButtonTextComponent badge = SCR_ButtonTextComponent.GetButtonText(name, parent);
|
SCR_ButtonTextComponent badge = SCR_ButtonTextComponent.GetButtonText(name, parent);
|
||||||
if (!badge) return;
|
if (!badge) return;
|
||||||
string label = "Waiting..."; Color color = Color.FromInt(0xFF454B52);
|
string label = "Waiting..."; Color color = Color.FromInt(ERR_MenuTheme.NEUTRAL);
|
||||||
if (state == 0) { label = "Disabled"; color = Color.FromInt(0xFF8F2929); }
|
if (state == 0) { label = "Disabled"; color = Color.FromInt(ERR_MenuTheme.NEGATIVE); }
|
||||||
if (state == 1) { label = "Enabled"; color = Color.FromInt(0xFF246B3C); }
|
if (state == 1) { label = "Enabled"; color = Color.FromInt(ERR_MenuTheme.POSITIVE); }
|
||||||
if (state == 2) { label = "Mixed"; color = Color.FromInt(0xFF805B17); }
|
if (state == 2) { label = "Mixed"; color = Color.FromInt(ERR_MenuTheme.MIXED); }
|
||||||
badge.SetText(label); badge.SetDisabledOpacity(1); badge.SetEnabled(false, false);
|
badge.SetText(label); badge.SetDisabledOpacity(1); badge.SetEnabled(false, false);
|
||||||
badge.SetBackgroundColors(color, color, color, color, color); badge.ColorizeBackground(false);
|
badge.SetBackgroundColors(color, color, color, color, color); badge.ColorizeBackground(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
// Optional casualty assistance. The authoritative controller supplies the body;
|
||||||
|
// clients cannot nominate another patient, an item, or an enabled setting.
|
||||||
|
class ERR_SelfEpinephrineRules
|
||||||
|
{
|
||||||
|
static bool Allowed(bool active, bool enabled, bool currentBody, bool alive, bool unconscious)
|
||||||
|
{
|
||||||
|
return active && enabled && currentBody && alive && unconscious;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class SCR_PlayerController
|
||||||
|
{
|
||||||
|
[RplProp()] protected bool m_ERRSelfEpinephrineEnabled;
|
||||||
|
protected float m_ERRLastSelfEpinephrine = -10000;
|
||||||
|
override void ERR_UpdateObserverServer(int direction = 0)
|
||||||
|
{
|
||||||
|
super.ERR_UpdateObserverServer(direction);
|
||||||
|
if (!Replication.IsServer()) return;
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
bool enabled = mode && mode.Active() && mode.Settings().Get("selfEpinephrine") == 1;
|
||||||
|
if (enabled == m_ERRSelfEpinephrineEnabled) return;
|
||||||
|
m_ERRSelfEpinephrineEnabled = enabled; Replication.BumpMe();
|
||||||
|
}
|
||||||
|
override string ERR_SelfEpinephrineHint()
|
||||||
|
{
|
||||||
|
if (!m_ERRSelfEpinephrineEnabled || ERR_ObserverState() != ERR_ObserverReason.UNCONSCIOUS) return "";
|
||||||
|
return "Press Space to use an epinephrine injector from your inventory.";
|
||||||
|
}
|
||||||
|
override void ERR_UseSelfEpinephrine()
|
||||||
|
{
|
||||||
|
if (this != GetGame().GetPlayerController() || !m_ERRSelfEpinephrineEnabled || ERR_ObserverState() != ERR_ObserverReason.UNCONSCIOUS) return;
|
||||||
|
Rpc(ERR_RequestSelfEpinephrine);
|
||||||
|
}
|
||||||
|
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
|
||||||
|
protected void ERR_RequestSelfEpinephrine()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return;
|
||||||
|
float now = GetGame().GetWorld().GetWorldTime();
|
||||||
|
if (now >= m_ERRLastSelfEpinephrine && now - m_ERRLastSelfEpinephrine < 1000) return;
|
||||||
|
m_ERRLastSelfEpinephrine = now;
|
||||||
|
string result = ERR_TrySelfEpinephrine();
|
||||||
|
if (!result.IsEmpty()) Rpc(ERR_SelfEpinephrineResponse, result);
|
||||||
|
}
|
||||||
|
protected string ERR_TrySelfEpinephrine()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) return "";
|
||||||
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
|
IEntity actor = GetControlledEntity();
|
||||||
|
CharacterControllerComponent controller;
|
||||||
|
if (actor) controller = CharacterControllerComponent.Cast(actor.FindComponent(CharacterControllerComponent));
|
||||||
|
ERR_PlayerLife life;
|
||||||
|
if (mode && mode.Players()) life = mode.Players().Get(GetPlayerId());
|
||||||
|
if (!mode || !ERR_SelfEpinephrineRules.Allowed(mode.Active(), mode.Settings().Get("selfEpinephrine") == 1,
|
||||||
|
life && life.Actor == actor && mode.Players().CurrentActor(actor) == life, ERR_Actors.Alive(actor), controller && controller.IsUnconscious())) return "";
|
||||||
|
IEntity injector = ERR_SelfEpinephrineInventory.FindUsable(actor);
|
||||||
|
if (!injector) return "No usable epinephrine injector in your inventory, or treatment is already active.";
|
||||||
|
SCR_ConsumableItemComponent item = SCR_ConsumableItemComponent.Cast(injector.FindComponent(SCR_ConsumableItemComponent));
|
||||||
|
SCR_ConsumableMorphine effect = SCR_ConsumableMorphine.Cast(item.GetConsumableEffect());
|
||||||
|
item.ApplyItemEffect(actor, actor, effect.GetAnimationParameters(injector, actor), injector, effect.GetDeleteOnUse());
|
||||||
|
return "Epinephrine administered. Its normal medical effect is active.";
|
||||||
|
}
|
||||||
|
|
||||||
|
[RplRpc(RplChannel.Reliable, RplRcver.Owner)]
|
||||||
|
protected void ERR_SelfEpinephrineResponse(string message)
|
||||||
|
{
|
||||||
|
if (this != GetGame().GetPlayerController()) return;
|
||||||
|
SCR_HintManagerComponent hints = SCR_HintManagerComponent.GetInstance();
|
||||||
|
if (hints) hints.ShowCustom(message, "Self epinephrine", 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shared read-only eligibility: defeat prediction and the actual Space action
|
||||||
|
// must agree, including native duplicate-dose rejection and item preference.
|
||||||
|
class ERR_SelfEpinephrineInventory
|
||||||
|
{
|
||||||
|
static IEntity FindUsable(IEntity actor)
|
||||||
|
{
|
||||||
|
if (!ERR_Actors.Alive(actor) || ERR_Actors.CanFight(actor)) return null;
|
||||||
|
InventoryStorageManagerComponent inventory = InventoryStorageManagerComponent.Cast(actor.FindComponent(InventoryStorageManagerComponent));
|
||||||
|
array<IEntity> items = {};
|
||||||
|
if (inventory) inventory.GetItems(items);
|
||||||
|
if (items.Count() > 512) return null;
|
||||||
|
// Prefer the standard injector; preserve each item's ordinary medical effect.
|
||||||
|
for (int kind = 0; kind < 2; kind++)
|
||||||
|
foreach (IEntity injector : items)
|
||||||
|
{
|
||||||
|
if (!injector || !inventory.Contains(injector)) continue;
|
||||||
|
SCR_ConsumableItemComponent item = SCR_ConsumableItemComponent.Cast(injector.FindComponent(SCR_ConsumableItemComponent));
|
||||||
|
if (!item) continue;
|
||||||
|
SCR_ConsumableMorphine effect = SCR_ConsumableMorphine.Cast(item.GetConsumableEffect());
|
||||||
|
if (!effect) continue;
|
||||||
|
if (kind == 0 && !ERR_ConsumableEpinephrine.Cast(effect)) continue;
|
||||||
|
if (kind == 1 && !ERR_ConsumableCombatEpinephrine.Cast(effect)) continue;
|
||||||
|
SCR_EConsumableFailReason reason;
|
||||||
|
if (!effect.CanApplyEffect(actor, actor, reason)) continue;
|
||||||
|
return injector;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ class ERR_ServerItem
|
|||||||
{
|
{
|
||||||
ResourceName Prefab;
|
ResourceName Prefab;
|
||||||
string Label;
|
string Label;
|
||||||
|
string SearchLabel;
|
||||||
bool Eligible;
|
bool Eligible;
|
||||||
}
|
}
|
||||||
class ERR_ServerAddonItems
|
class ERR_ServerAddonItems
|
||||||
@@ -40,6 +41,7 @@ class ERR_ServerItemCatalog
|
|||||||
foreach (ERR_ServerAddonItems addon : m_Addons) if (addon.Id == id) return addon;
|
foreach (ERR_ServerAddonItems addon : m_Addons) if (addon.Id == id) return addon;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
ERR_ServerItem Item(string key) { return m_Seen.Get(key); }
|
||||||
bool Contains(string addonId, string itemId)
|
bool Contains(string addonId, string itemId)
|
||||||
{
|
{
|
||||||
ERR_ServerAddonItems addon = Find(addonId);
|
ERR_ServerAddonItems addon = Find(addonId);
|
||||||
@@ -73,6 +75,7 @@ class ERR_ServerItemCatalog
|
|||||||
if (addon.Label.IsEmpty()) addon.Label = Clean(addon.Project);
|
if (addon.Label.IsEmpty()) addon.Label = Clean(addon.Project);
|
||||||
m_Addons.Insert(addon);
|
m_Addons.Insert(addon);
|
||||||
}
|
}
|
||||||
|
SortAddons(m_Addons);
|
||||||
Queue(manager.GetEntityCatalogOfType(EEntityCatalogType.ITEM, false));
|
Queue(manager.GetEntityCatalogOfType(EEntityCatalogType.ITEM, false));
|
||||||
array<Faction> all = {}; factions.GetFactionsList(all);
|
array<Faction> all = {}; factions.GetFactionsList(all);
|
||||||
foreach (Faction faction : all)
|
foreach (Faction faction : all)
|
||||||
@@ -108,6 +111,7 @@ class ERR_ServerItemCatalog
|
|||||||
item = new ERR_ServerItem(); item.Prefab = prefab; item.Eligible = eligible;
|
item = new ERR_ServerItem(); item.Prefab = prefab; item.Eligible = eligible;
|
||||||
item.Label = Clean(entry.GetEntityName());
|
item.Label = Clean(entry.GetEntityName());
|
||||||
if (item.Label.IsEmpty()) item.Label = Clean(FilePath.StripPath(prefab.GetPath()));
|
if (item.Label.IsEmpty()) item.Label = Clean(FilePath.StripPath(prefab.GetPath()));
|
||||||
|
item.SearchLabel = WidgetManager.Translate(item.Label);
|
||||||
m_Seen.Set(key, item);
|
m_Seen.Set(key, item);
|
||||||
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
||||||
bool attributed;
|
bool attributed;
|
||||||
@@ -118,16 +122,51 @@ class ERR_ServerItemCatalog
|
|||||||
if (m_Cursor >= m_Pending.Count())
|
if (m_Cursor >= m_Pending.Count())
|
||||||
{
|
{
|
||||||
GetGame().GetCallqueue().Remove(Scan);
|
GetGame().GetCallqueue().Remove(Scan);
|
||||||
|
foreach (ERR_ServerAddonItems sortedAddon : m_Addons) SortItems(sortedAddon.Items);
|
||||||
PrintFormat("Reintroduced [server items]: addons=%1 uniqueItems=%2 unattributed=%3 truncated=%4", m_Addons.Count(), m_Seen.Count(), m_Unattributed, m_Truncated);
|
PrintFormat("Reintroduced [server items]: addons=%1 uniqueItems=%2 unattributed=%3 truncated=%4", m_Addons.Count(), m_Seen.Count(), m_Unattributed, m_Truncated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void SortAddons(array<ref ERR_ServerAddonItems> addons)
|
||||||
|
{
|
||||||
|
array<string> order = {}; map<string, ref ERR_ServerAddonItems> entries = new map<string, ref ERR_ServerAddonItems>();
|
||||||
|
foreach (ERR_ServerAddonItems addon : addons)
|
||||||
|
{
|
||||||
|
string key = addon.Label + "|" + addon.Id; key.ToLower(); order.Insert(key); entries.Set(key, addon);
|
||||||
|
}
|
||||||
|
order.Sort(); addons.Clear();
|
||||||
|
foreach (string key : order) addons.Insert(entries.Get(key));
|
||||||
|
}
|
||||||
|
static void SortItems(array<ref ERR_ServerItem> items)
|
||||||
|
{
|
||||||
|
array<string> order = {}; map<string, ref ERR_ServerItem> entries = new map<string, ref ERR_ServerItem>();
|
||||||
|
foreach (ERR_ServerItem item : items)
|
||||||
|
{
|
||||||
|
string key = item.SearchLabel + "|" + ERR_TerrainCatalog.Key(item.Prefab); key.ToLower(); order.Insert(key); entries.Set(key, item);
|
||||||
|
}
|
||||||
|
order.Sort(); items.Clear();
|
||||||
|
foreach (string key : order) items.Insert(entries.Get(key));
|
||||||
|
}
|
||||||
|
static string Flag(bool value)
|
||||||
|
{
|
||||||
|
if (value) return "1";
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
static bool Matches(string label, string path, bool enabled, int filter, string query)
|
||||||
|
{
|
||||||
|
if ((filter == 1 && !enabled) || (filter == 2 && enabled)) return false;
|
||||||
|
if (query.IsEmpty()) return true;
|
||||||
|
string haystack = label + " " + path; haystack.ToLower(); query.ToLower();
|
||||||
|
array<string> words = {}; query.Split(" ", words, true);
|
||||||
|
foreach (string word : words) if (!haystack.Contains(word)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
static string Share(int tickets, int total)
|
static string Share(int tickets, int total)
|
||||||
{
|
{
|
||||||
if (total <= 0 || tickets <= 0) return "0%";
|
if (total <= 0 || tickets <= 0) return "0%";
|
||||||
float percent = Math.Round(tickets * 10000.0 / total) / 100.0;
|
float percent = Math.Round(tickets * 10000.0 / total) / 100.0;
|
||||||
return percent.ToString() + "%";
|
return percent.ToString() + "%";
|
||||||
}
|
}
|
||||||
void Snapshot(ERR_GameMode mode, array<string> values, string selected, int page)
|
void Snapshot(ERR_GameMode mode, array<string> values, string selected, int page, int filter = 0, string query = "")
|
||||||
{
|
{
|
||||||
Start(mode);
|
Start(mode);
|
||||||
ERR_ItemPreferences preferences = GetGame().ERR_ItemSelections();
|
ERR_ItemPreferences preferences = GetGame().ERR_ItemSelections();
|
||||||
@@ -150,7 +189,7 @@ class ERR_ServerItemCatalog
|
|||||||
foreach (ERR_ServerAddonItems addon : m_Addons)
|
foreach (ERR_ServerAddonItems addon : m_Addons)
|
||||||
{
|
{
|
||||||
string defaultEnabled = "0"; if (preferences.Enabled(addon.Id, "*")) defaultEnabled = "1";
|
string defaultEnabled = "0"; if (preferences.Enabled(addon.Id, "*")) defaultEnabled = "1";
|
||||||
values.Insert("serverMod=" + addon.Id + "|" + addon.Label + "|" + addon.Items.Count().ToString() + "|" + addon.EnabledCount.ToString() + "|" + defaultEnabled);
|
values.Insert("serverMod=" + addon.Id + "|" + addon.Label + "|" + addon.Items.Count().ToString() + "|" + addon.EnabledCount.ToString() + "|" + defaultEnabled + "|" + Flag(preferences.ModEnabled(addon.Id)));
|
||||||
}
|
}
|
||||||
string state = "Catalog complete";
|
string state = "Catalog complete";
|
||||||
if (!m_Started || m_Cursor < m_Pending.Count()) state = "Scanning inventory catalogs";
|
if (!m_Started || m_Cursor < m_Pending.Count()) state = "Scanning inventory catalogs";
|
||||||
@@ -158,24 +197,28 @@ class ERR_ServerItemCatalog
|
|||||||
if (m_Unattributed > 0) state += "; " + m_Unattributed.ToString() + " items could not be attributed";
|
if (m_Unattributed > 0) state += "; " + m_Unattributed.ToString() + " items could not be attributed";
|
||||||
values.Insert("itemsScan=" + state);
|
values.Insert("itemsScan=" + state);
|
||||||
int extraChance = mode.Settings().Runtime("automaticEquipmentChancePercent");
|
int extraChance = mode.Settings().Runtime("automaticEquipmentChancePercent");
|
||||||
values.Insert("weightChance=" + extraChance.ToString() + "% current chance per eligible soldier. The Spawn chances page controls which extra item is chosen; inventory fit can still prevent a grant.");
|
values.Insert("weightChance=" + extraChance.ToString() + "% current chance per eligible soldier. Advanced weights controls which extra item is chosen; inventory fit can still prevent a grant.");
|
||||||
ERR_ServerAddonItems chosen = Find(selected);
|
ERR_ServerAddonItems chosen = Find(selected);
|
||||||
if (!chosen) return;
|
if (!chosen) return;
|
||||||
values.Insert("modWeight=" + chosen.Id + "|" + preferences.WeightSetting(chosen.Id, "*").ToString() + "|" + Share(chosen.TicketWeight, totalWeight));
|
values.Insert("modWeight=" + chosen.Id + "|" + preferences.WeightSetting(chosen.Id, "*").ToString() + "|" + Share(chosen.TicketWeight, totalWeight));
|
||||||
int lastPage = Math.Max(0, (chosen.Items.Count() - 1) / PAGE_SIZE);
|
array<ref ERR_ServerItem> matches = {};
|
||||||
|
foreach (ERR_ServerItem candidate : chosen.Items)
|
||||||
|
if (Matches(candidate.SearchLabel, candidate.Prefab.GetPath(), preferences.Allows(candidate.Prefab) && (!mode.Content() || mode.Content().Allows(candidate.Prefab)), filter, query)) matches.Insert(candidate);
|
||||||
|
int lastPage = Math.Max(0, (matches.Count() - 1) / PAGE_SIZE);
|
||||||
page = Math.Clamp(page, 0, lastPage);
|
page = Math.Clamp(page, 0, lastPage);
|
||||||
values.Insert("itemsPage=" + selected + "|" + page.ToString() + "|" + lastPage.ToString() + "|" + chosen.Items.Count().ToString());
|
values.Insert("itemsPage=" + selected + "|" + page.ToString() + "|" + lastPage.ToString() + "|" + matches.Count().ToString());
|
||||||
int end = Math.Min(chosen.Items.Count(), (page + 1) * PAGE_SIZE);
|
int end = Math.Min(matches.Count(), (page + 1) * PAGE_SIZE);
|
||||||
for (int i = page * PAGE_SIZE; i < end; i++)
|
for (int i = page * PAGE_SIZE; i < end; i++)
|
||||||
{
|
{
|
||||||
ERR_ServerItem item = chosen.Items[i];
|
ERR_ServerItem item = matches[i];
|
||||||
string stateText = "Catalog item; not in automatic equipment pool";
|
string stateText = "Catalog item; not in automatic equipment pool";
|
||||||
if (item.Eligible) stateText = "Eligible for automatic equipment";
|
if (item.Eligible) stateText = "Eligible for automatic equipment";
|
||||||
if (mode.Content() && !mode.Content().Allows(item.Prefab)) stateText = "Blocked by current content-pack selection";
|
if (mode.Content() && !mode.Content().Allows(item.Prefab)) stateText = "Blocked by current content-pack selection";
|
||||||
string key = ERR_TerrainCatalog.Key(item.Prefab);
|
string key = ERR_TerrainCatalog.Key(item.Prefab);
|
||||||
string enabled = "0";
|
string enabled = "0";
|
||||||
if (preferences.Enabled(selected, key)) enabled = "1";
|
if (preferences.Enabled(selected, key)) enabled = "1";
|
||||||
if (!preferences.Allows(item.Prefab)) stateText = "Disabled by item/mod selection";
|
if (!preferences.Allows(item.Prefab)) stateText = "Disabled by a source mod or item selection";
|
||||||
|
if (!preferences.ModEnabled(selected)) stateText = "Mod disabled - item choice is remembered";
|
||||||
string effective = "0";
|
string effective = "0";
|
||||||
if (preferences.Allows(item.Prefab) && (!mode.Content() || mode.Content().Allows(item.Prefab))) effective = "1";
|
if (preferences.Allows(item.Prefab) && (!mode.Content() || mode.Content().Allows(item.Prefab))) effective = "1";
|
||||||
values.Insert("itemWeight=" + key + "|" + preferences.WeightSetting(selected, key).ToString() + "|" + Share(ERR_AutomaticEquipmentCatalog.TicketWeight(item.Prefab), totalWeight));
|
values.Insert("itemWeight=" + key + "|" + preferences.WeightSetting(selected, key).ToString() + "|" + Share(ERR_AutomaticEquipmentCatalog.TicketWeight(item.Prefab), totalWeight));
|
||||||
@@ -188,6 +231,12 @@ modded class ArmaReforgerScripted
|
|||||||
{
|
{
|
||||||
protected ref ERR_ServerItemCatalog m_ERRServerItems;
|
protected ref ERR_ServerItemCatalog m_ERRServerItems;
|
||||||
protected ref ERR_ItemPreferences m_ERRItemSelections;
|
protected ref ERR_ItemPreferences m_ERRItemSelections;
|
||||||
|
protected ref ERR_ServerVehicleCatalog m_ERRServerVehicles;
|
||||||
|
ERR_ServerVehicleCatalog ERR_ServerVehicles()
|
||||||
|
{
|
||||||
|
if (!m_ERRServerVehicles) m_ERRServerVehicles = new ERR_ServerVehicleCatalog();
|
||||||
|
return m_ERRServerVehicles;
|
||||||
|
}
|
||||||
ERR_ItemPreferences ERR_ItemSelections()
|
ERR_ItemPreferences ERR_ItemSelections()
|
||||||
{
|
{
|
||||||
if (!m_ERRItemSelections) m_ERRItemSelections = new ERR_ItemPreferences();
|
if (!m_ERRItemSelections) m_ERRItemSelections = new ERR_ItemPreferences();
|
||||||
@@ -201,7 +250,8 @@ modded class ArmaReforgerScripted
|
|||||||
override protected void OnBeforeWorldCleanup()
|
override protected void OnBeforeWorldCleanup()
|
||||||
{
|
{
|
||||||
if (m_ERRServerItems) m_ERRServerItems.Stop();
|
if (m_ERRServerItems) m_ERRServerItems.Stop();
|
||||||
m_ERRServerItems = null; m_ERRItemSelections = null;
|
if (m_ERRServerVehicles) m_ERRServerVehicles.Stop();
|
||||||
|
m_ERRServerItems = null; m_ERRItemSelections = null; m_ERRServerVehicles = null;
|
||||||
super.OnBeforeWorldCleanup();
|
super.OnBeforeWorldCleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,21 @@ modded class ERR_AdminMenu
|
|||||||
protected ref array<string> m_ItemPresets = {};
|
protected ref array<string> m_ItemPresets = {};
|
||||||
protected ref map<string, int> m_ItemSaved = new map<string, int>();
|
protected ref map<string, int> m_ItemSaved = new map<string, int>();
|
||||||
protected ref map<string, int> m_AddonSelectionStates = new map<string, int>();
|
protected ref map<string, int> m_AddonSelectionStates = new map<string, int>();
|
||||||
|
protected ref map<string, int> m_ServerModEnabled = new map<string, int>();
|
||||||
|
protected ref map<string, string> m_ServerModLabels = new map<string, string>();
|
||||||
|
protected ref map<string, int> m_ServerModItemCounts = new map<string, int>();
|
||||||
|
protected ref map<string, int> m_ServerModVehicleCounts = new map<string, int>();
|
||||||
|
protected string m_ServerScanState;
|
||||||
|
protected string m_ItemRowSignature;
|
||||||
|
protected string m_LastItemChoice;
|
||||||
|
protected int m_LastItemFilter = -1;
|
||||||
protected string m_ShownItemAddon;
|
protected string m_ShownItemAddon;
|
||||||
protected int m_ShownItemPage;
|
protected int m_ShownItemPage;
|
||||||
protected int m_LastItemPage;
|
protected int m_LastItemPage;
|
||||||
override void OnMenuOpen()
|
override void OnMenuOpen()
|
||||||
{
|
{
|
||||||
super.OnMenuOpen();
|
super.OnMenuOpen();
|
||||||
foreach (string name : {"ItemsShow", "ItemsPrevious", "ItemsNext", "ItemsEnableAll", "ItemsDisableAll", "ItemsPresetSave", "ItemsPresetLoad", "ItemsPresetDelete"})
|
foreach (string name : {"ItemsShow", "ItemsClear", "ItemsPrevious", "ItemsNext", "ItemsEnableAll", "ItemsDisableAll", "ItemsPresetSave", "ItemsPresetLoad", "ItemsPresetDelete"})
|
||||||
{
|
{
|
||||||
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
||||||
if (!button) { Close(); return; }
|
if (!button) { Close(); return; }
|
||||||
@@ -24,6 +32,12 @@ modded class ERR_AdminMenu
|
|||||||
if (name == "ItemsEnableAll") ERR_SelectionStyle.Action(button, true);
|
if (name == "ItemsEnableAll") ERR_SelectionStyle.Action(button, true);
|
||||||
button.m_OnClicked.Insert(OnItemsButton); m_ItemButtons.Insert(button);
|
button.m_OnClicked.Insert(OnItemsButton); m_ItemButtons.Insert(button);
|
||||||
}
|
}
|
||||||
|
foreach (string filterName : {"ItemsFilter", "ModsFilter"})
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent filter = SCR_ComboBoxComponent.GetComboBoxComponent(filterName, GetRootWidget());
|
||||||
|
if (filterName == "ModsFilter") filter.AddItem("With items / vehicles");
|
||||||
|
filter.AddItem("All"); filter.AddItem("Enabled"); filter.AddItem("Disabled"); filter.SetCurrentItem(0, false, false, false);
|
||||||
|
}
|
||||||
ERR_SelectionStyle.Status(GetRootWidget(), "ItemsSelectionState", -1);
|
ERR_SelectionStyle.Status(GetRootWidget(), "ItemsSelectionState", -1);
|
||||||
UpdateActions();
|
UpdateActions();
|
||||||
}
|
}
|
||||||
@@ -31,8 +45,10 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
foreach (SCR_ButtonTextComponent button : m_ItemButtons) if (button) button.m_OnClicked.Remove(OnItemsButton);
|
foreach (SCR_ButtonTextComponent button : m_ItemButtons) if (button) button.m_OnClicked.Remove(OnItemsButton);
|
||||||
ClearItemRows(); m_ItemPresets.Clear();
|
ClearItemRows(); m_ItemPresets.Clear();
|
||||||
foreach (string addon, Widget row : m_ServerAddonRows) SCR_ButtonTextComponent.GetButtonText("Enable", row).m_OnClicked.Remove(OnLoadedModEdit);
|
foreach (string addon, Widget row : m_ServerAddonRows)
|
||||||
m_AddonSelectionStates.Clear();
|
foreach (string action : {"Enable", "Disable", "EditItems", "EditVehicles"}) SCR_ButtonTextComponent.GetButtonText(action, row).m_OnClicked.Remove(OnLoadedModEdit);
|
||||||
|
m_AddonSelectionStates.Clear(); m_ServerModEnabled.Clear(); m_ServerModLabels.Clear(); m_ServerModItemCounts.Clear(); m_ServerModVehicleCounts.Clear();
|
||||||
|
m_LastItemChoice = ""; m_LastItemFilter = -1; m_ItemRowSignature = "";
|
||||||
m_ItemButtons.Clear(); m_ServerAddonRows.Clear(); m_ServerAddonKeys.Clear(); m_ServerAddonLabels.Clear();
|
m_ItemButtons.Clear(); m_ServerAddonRows.Clear(); m_ServerAddonKeys.Clear(); m_ServerAddonLabels.Clear();
|
||||||
m_ShownItemAddon = ""; m_ShownItemPage = 0; m_LastItemPage = 0;
|
m_ShownItemAddon = ""; m_ShownItemPage = 0; m_LastItemPage = 0;
|
||||||
super.OnMenuClose();
|
super.OnMenuClose();
|
||||||
@@ -49,11 +65,22 @@ modded class ERR_AdminMenu
|
|||||||
bool ready = m_Ready && !m_ServerAddonKeys.IsEmpty();
|
bool ready = m_Ready && !m_ServerAddonKeys.IsEmpty();
|
||||||
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
||||||
if (combo) combo.SetEnabled(ready);
|
if (combo) combo.SetEnabled(ready);
|
||||||
foreach (string addon, Widget loadedRow : m_ServerAddonRows) SCR_ButtonTextComponent.GetButtonText("Enable", loadedRow).SetEnabled(ready);
|
foreach (string addon, Widget loadedRow : m_ServerAddonRows)
|
||||||
|
{
|
||||||
|
bool hasItems = m_ServerModItemCounts.Get(addon) > 0;
|
||||||
|
bool hasVehicles = m_ServerModVehicleCounts.Get(addon) > 0;
|
||||||
|
bool selectedMod = m_ServerModEnabled.Get(addon) == 1;
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Enable", loadedRow).SetEnabled(ready && (hasItems || hasVehicles) && !selectedMod);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Disable", loadedRow).SetEnabled(ready && (hasItems || hasVehicles) && selectedMod);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("EditItems", loadedRow).SetEnabled(ready && hasItems);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("EditVehicles", loadedRow).SetEnabled(ready && hasVehicles);
|
||||||
|
ERR_SelectionStyle.Pair(loadedRow, "Enable", "Disable", m_ServerModEnabled.Get(addon));
|
||||||
|
}
|
||||||
|
bool rowReady = ItemSelectionReady();
|
||||||
foreach (string key, Widget row : m_ItemRows)
|
foreach (string key, Widget row : m_ItemRows)
|
||||||
{
|
{
|
||||||
SCR_ButtonTextComponent.GetButtonText("Enable", row).SetEnabled(ready && m_ItemSaved.Contains(key) && m_ItemSaved.Get(key) == 0);
|
SCR_ButtonTextComponent.GetButtonText("Enable", row).SetEnabled(rowReady && m_ItemSaved.Contains(key) && m_ItemSaved.Get(key) == 0);
|
||||||
SCR_ButtonTextComponent.GetButtonText("Disable", row).SetEnabled(ready && m_ItemSaved.Contains(key) && m_ItemSaved.Get(key) == 1);
|
SCR_ButtonTextComponent.GetButtonText("Disable", row).SetEnabled(rowReady && m_ItemSaved.Contains(key) && m_ItemSaved.Get(key) == 1);
|
||||||
int selected = -1; if (m_ItemSaved.Contains(key)) selected = m_ItemSaved.Get(key);
|
int selected = -1; if (m_ItemSaved.Contains(key)) selected = m_ItemSaved.Get(key);
|
||||||
ERR_SelectionStyle.Pair(row, "Enable", "Disable", selected);
|
ERR_SelectionStyle.Pair(row, "Enable", "Disable", selected);
|
||||||
}
|
}
|
||||||
@@ -65,7 +92,7 @@ modded class ERR_AdminMenu
|
|||||||
if (button.GetRootWidget().GetName() == "ItemsPrevious") enabled = ready && m_ShownItemPage > 0;
|
if (button.GetRootWidget().GetName() == "ItemsPrevious") enabled = ready && m_ShownItemPage > 0;
|
||||||
if (button.GetRootWidget().GetName() == "ItemsNext") enabled = ready && m_ShownItemPage < m_LastItemPage;
|
if (button.GetRootWidget().GetName() == "ItemsNext") enabled = ready && m_ShownItemPage < m_LastItemPage;
|
||||||
string name = button.GetRootWidget().GetName();
|
string name = button.GetRootWidget().GetName();
|
||||||
if (name == "ItemsEnableAll" || name == "ItemsDisableAll") enabled = ready && !m_ShownItemAddon.IsEmpty();
|
if (name == "ItemsEnableAll" || name == "ItemsDisableAll") enabled = rowReady;
|
||||||
if (name == "ItemsPresetLoad" || name == "ItemsPresetDelete") enabled = ready && !m_ItemPresets.IsEmpty();
|
if (name == "ItemsPresetLoad" || name == "ItemsPresetDelete") enabled = ready && !m_ItemPresets.IsEmpty();
|
||||||
button.SetEnabled(enabled);
|
button.SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
@@ -74,7 +101,7 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
array<string> keys = {}, labels = {};
|
array<string> keys = {}, labels = {};
|
||||||
array<string> itemRows = {}, presets = {};
|
array<string> itemRows = {}, presets = {};
|
||||||
string scan, shown;
|
string scan, shown, signature;
|
||||||
int page, last, total;
|
int page, last, total;
|
||||||
if (authorized && values)
|
if (authorized && values)
|
||||||
foreach (string entry : values)
|
foreach (string entry : values)
|
||||||
@@ -87,9 +114,11 @@ modded class ERR_AdminMenu
|
|||||||
if (field == "itemPreset") presets.Insert(value);
|
if (field == "itemPreset") presets.Insert(value);
|
||||||
if (field == "itemsPage" && parts.Count() == 4)
|
if (field == "itemsPage" && parts.Count() == 4)
|
||||||
{ shown = parts[0]; page = parts[1].ToInt(); last = parts[2].ToInt(); total = parts[3].ToInt(); }
|
{ shown = parts[0]; page = parts[1].ToInt(); last = parts[2].ToInt(); total = parts[3].ToInt(); }
|
||||||
if (field == "serverItem" && parts.Count() == 6) itemRows.Insert(value);
|
if (field == "serverItem" && parts.Count() == 6) { itemRows.Insert(value); signature += parts[0]; }
|
||||||
if (field != "serverMod" || parts.Count() != 5 || keys.Contains(parts[0])) continue;
|
if (field == "vehicleMod" && parts.Count() == 5) m_ServerModVehicleCounts.Set(parts[0], parts[2].ToInt());
|
||||||
|
if (field != "serverMod" || parts.Count() != 6 || keys.Contains(parts[0])) continue;
|
||||||
keys.Insert(parts[0]); labels.Insert(parts[1]);
|
keys.Insert(parts[0]); labels.Insert(parts[1]);
|
||||||
|
m_ServerModEnabled.Set(parts[0], parts[5].ToInt()); m_ServerModLabels.Set(parts[0], parts[1]); m_ServerModItemCounts.Set(parts[0], parts[2].ToInt());
|
||||||
int aggregate = ERR_SelectionStyle.Aggregate(parts[2].ToInt(), parts[3].ToInt(), parts[4] == "1");
|
int aggregate = ERR_SelectionStyle.Aggregate(parts[2].ToInt(), parts[3].ToInt(), parts[4] == "1");
|
||||||
m_AddonSelectionStates.Set(parts[0], aggregate);
|
m_AddonSelectionStates.Set(parts[0], aggregate);
|
||||||
Widget row = m_ServerAddonRows.Get(parts[0]);
|
Widget row = m_ServerAddonRows.Get(parts[0]);
|
||||||
@@ -98,13 +127,11 @@ modded class ERR_AdminMenu
|
|||||||
row = GetGame().GetWorkspace().CreateWidgets("{F092D45656A8E02B}UI/layouts/ERR/ContentRow.layout", GetRootWidget().FindAnyWidget("ModList"));
|
row = GetGame().GetWorkspace().CreateWidgets("{F092D45656A8E02B}UI/layouts/ERR/ContentRow.layout", GetRootWidget().FindAnyWidget("ModList"));
|
||||||
if (!row) continue;
|
if (!row) continue;
|
||||||
m_ServerAddonRows.Set(parts[0], row);
|
m_ServerAddonRows.Set(parts[0], row);
|
||||||
row.FindAnyWidget("Disable").SetVisible(false);
|
foreach (string action : {"Enable", "Disable", "EditItems", "EditVehicles"}) SCR_ButtonTextComponent.GetButtonText(action, row).m_OnClicked.Insert(OnLoadedModEdit);
|
||||||
SCR_ButtonTextComponent edit = SCR_ButtonTextComponent.GetButtonText("Enable", row);
|
|
||||||
edit.SetText("Edit items"); edit.m_OnClicked.Insert(OnLoadedModEdit);
|
|
||||||
}
|
}
|
||||||
ERR_SelectionStyle.Status(row, "SelectionState", aggregate);
|
ERR_SelectionStyle.Status(row, "SelectionState", parts[5].ToInt());
|
||||||
TextWidget.Cast(row.FindAnyWidget("PackLabel")).SetText(parts[1]);
|
TextWidget.Cast(row.FindAnyWidget("PackLabel")).SetText(parts[1]);
|
||||||
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText("Loaded on server | " + parts[2] + " catalogued items | Edit future random equipment");
|
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText(parts[3] + " / " + parts[2] + " items enabled");
|
||||||
}
|
}
|
||||||
bool changed = keys.Count() != m_ServerAddonKeys.Count();
|
bool changed = keys.Count() != m_ServerAddonKeys.Count();
|
||||||
if (!changed) for (int i = 0; i < keys.Count(); i++) if (keys[i] != m_ServerAddonKeys[i] || labels[i] != m_ServerAddonLabels[i]) changed = true;
|
if (!changed) for (int i = 0; i < keys.Count(); i++) if (keys[i] != m_ServerAddonKeys[i] || labels[i] != m_ServerAddonLabels[i]) changed = true;
|
||||||
@@ -118,14 +145,16 @@ modded class ERR_AdminMenu
|
|||||||
combo.SetCurrentItem(Math.Max(0, keys.Find(draft)), false, false, false);
|
combo.SetCurrentItem(Math.Max(0, keys.Find(draft)), false, false, false);
|
||||||
m_ServerAddonKeys.Copy(keys); m_ServerAddonLabels.Copy(labels);
|
m_ServerAddonKeys.Copy(keys); m_ServerAddonLabels.Copy(labels);
|
||||||
}
|
}
|
||||||
SetText("ItemsScan", scan);
|
m_ServerScanState = scan;
|
||||||
|
SetText("ItemsHelp", "Extra equipment | " + scan);
|
||||||
if (!shown.IsEmpty())
|
if (!shown.IsEmpty())
|
||||||
{
|
{
|
||||||
bool moved = shown != m_ShownItemAddon || page != m_ShownItemPage;
|
bool moved = shown != m_ShownItemAddon || page != m_ShownItemPage || signature != m_ItemRowSignature;
|
||||||
|
m_ItemRowSignature = signature;
|
||||||
m_ShownItemAddon = shown; m_ShownItemPage = page; m_LastItemPage = last;
|
m_ShownItemAddon = shown; m_ShownItemPage = page; m_LastItemPage = last;
|
||||||
int selected = keys.Find(shown); string title = shown;
|
int selected = keys.Find(shown); string title = shown;
|
||||||
if (selected >= 0) title = labels[selected];
|
if (selected >= 0) title = labels[selected];
|
||||||
SetText("ItemsPageState", title + " | " + total.ToString() + " items | Page " + (page + 1).ToString() + "/" + (last + 1).ToString());
|
SetText("ItemsPageState", total.ToString() + " matching items | Page " + (page + 1).ToString() + " of " + (last + 1).ToString());
|
||||||
if (moved)
|
if (moved)
|
||||||
{
|
{
|
||||||
ClearItemRows();
|
ClearItemRows();
|
||||||
@@ -150,11 +179,11 @@ modded class ERR_AdminMenu
|
|||||||
TextWidget.Cast(row.FindAnyWidget("PackLabel")).SetText(WidgetManager.Translate(parts[1]));
|
TextWidget.Cast(row.FindAnyWidget("PackLabel")).SetText(WidgetManager.Translate(parts[1]));
|
||||||
m_ItemSaved.Set(parts[0], parts[4].ToInt());
|
m_ItemSaved.Set(parts[0], parts[4].ToInt());
|
||||||
ERR_SelectionStyle.Status(row, "SelectionState", parts[5].ToInt());
|
ERR_SelectionStyle.Status(row, "SelectionState", parts[5].ToInt());
|
||||||
string selection = "Disabled"; if (parts[4] == "1") selection = "Enabled";
|
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText(parts[3] + " | " + FilePath.StripPath(parts[2]));
|
||||||
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText(selection + " here | " + parts[3] + "\n" + parts[2]);
|
|
||||||
}
|
}
|
||||||
string empty; if (itemRows.IsEmpty()) empty = "No registered inventory items found for this mod.";
|
string empty; if (itemRows.IsEmpty()) empty = "No items match. Clear search or choose All to see more.";
|
||||||
SetText("ItemsText", empty);
|
SetText("ItemsText", empty);
|
||||||
|
GetRootWidget().FindAnyWidget("ItemsText").SetVisible(!empty.IsEmpty());
|
||||||
ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(GetRootWidget().FindAnyWidget("ItemsScroll"));
|
ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(GetRootWidget().FindAnyWidget("ItemsScroll"));
|
||||||
if (moved && scroll) scroll.SetSliderPos(0, 0);
|
if (moved && scroll) scroll.SetSliderPos(0, 0);
|
||||||
}
|
}
|
||||||
@@ -175,9 +204,15 @@ modded class ERR_AdminMenu
|
|||||||
{
|
{
|
||||||
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
||||||
string name = button.GetRootWidget().GetName();
|
string name = button.GetRootWidget().GetName();
|
||||||
|
if (name == "ItemsClear")
|
||||||
|
{
|
||||||
|
SCR_EditBoxComponent.GetEditBoxComponent("ItemsSearch", GetRootWidget()).SetValue("");
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("ItemsFilter", GetRootWidget()).SetCurrentItem(0, false, false, false);
|
||||||
|
BrowseItems(0); return;
|
||||||
|
}
|
||||||
if (name == "ItemsEnableAll" || name == "ItemsDisableAll")
|
if (name == "ItemsEnableAll" || name == "ItemsDisableAll")
|
||||||
{
|
{
|
||||||
if (m_ShownItemAddon.IsEmpty()) return;
|
if (!ItemSelectionReady()) return;
|
||||||
string value = "0"; if (name == "ItemsEnableAll") value = "1";
|
string value = "0"; if (name == "ItemsEnableAll") value = "1";
|
||||||
SubmitItems("items set " + m_ShownItemAddon + " * " + value); return;
|
SubmitItems("items set " + m_ShownItemAddon + " * " + value); return;
|
||||||
}
|
}
|
||||||
@@ -206,23 +241,73 @@ modded class ERR_AdminMenu
|
|||||||
if (button.GetRootWidget().GetName() == "ItemsPrevious") page = Math.Max(0, page - 1);
|
if (button.GetRootWidget().GetName() == "ItemsPrevious") page = Math.Max(0, page - 1);
|
||||||
if (button.GetRootWidget().GetName() == "ItemsNext") page = Math.Min(m_LastItemPage, page + 1);
|
if (button.GetRootWidget().GetName() == "ItemsNext") page = Math.Min(m_LastItemPage, page + 1);
|
||||||
}
|
}
|
||||||
SubmitItems("items list " + addon + " " + page.ToString());
|
if (name == "ItemsShow") page = 0;
|
||||||
|
BrowseItems(page);
|
||||||
|
}
|
||||||
|
protected bool ItemSelectionReady()
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
||||||
|
if (!m_Ready || !combo) return false;
|
||||||
|
int index = combo.GetCurrentIndex();
|
||||||
|
return index >= 0 && index < m_ServerAddonKeys.Count() && m_ServerAddonKeys[index] == m_ShownItemAddon;
|
||||||
|
}
|
||||||
|
protected void BrowseItems(int page)
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
||||||
|
int index = combo.GetCurrentIndex(); if (index < 0 || index >= m_ServerAddonKeys.Count()) return;
|
||||||
|
int filter = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsFilter", GetRootWidget()).GetCurrentIndex();
|
||||||
|
string query = SCR_EditBoxComponent.GetEditBoxComponent("ItemsSearch", GetRootWidget()).GetValue().Trim();
|
||||||
|
if (query.Length() > 64) { ReceiveReply("Search can contain up to 64 characters."); return; }
|
||||||
|
m_LastItemChoice = m_ServerAddonKeys[index]; m_LastItemFilter = filter;
|
||||||
|
SubmitItems("items browse " + m_LastItemChoice + " " + page.ToString() + " " + filter.ToString() + " " + query);
|
||||||
|
UpdateActions();
|
||||||
|
}
|
||||||
|
override void OnMenuUpdate(float tDelta)
|
||||||
|
{
|
||||||
|
super.OnMenuUpdate(tDelta);
|
||||||
|
if (!m_Ready || !IsFocused() || m_ClickDelay > 0 || m_Age > 6) return;
|
||||||
|
if (m_Page == ERR_AdminPage.ALLOWED_ITEMS)
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
||||||
|
int index = combo.GetCurrentIndex();
|
||||||
|
int filter = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsFilter", GetRootWidget()).GetCurrentIndex();
|
||||||
|
if (index >= 0 && index < m_ServerAddonKeys.Count() && (m_ServerAddonKeys[index] != m_LastItemChoice || filter != m_LastItemFilter)) BrowseItems(0);
|
||||||
|
}
|
||||||
|
if (m_Page != ERR_AdminPage.ALLOWED_ITEMS) m_LastItemChoice = "";
|
||||||
|
if (m_Page != ERR_AdminPage.MODS) return;
|
||||||
|
string query = SCR_EditBoxComponent.GetEditBoxComponent("ModsSearch", GetRootWidget()).GetValue();
|
||||||
|
int filter = SCR_ComboBoxComponent.GetComboBoxComponent("ModsFilter", GetRootWidget()).GetCurrentIndex();
|
||||||
|
int shown;
|
||||||
|
foreach (string addon, Widget row : m_ServerAddonRows)
|
||||||
|
{
|
||||||
|
bool visible = ERR_ServerItemCatalog.Matches(m_ServerModLabels.Get(addon), addon, m_ServerModEnabled.Get(addon) == 1, Math.Max(0, filter - 1), query);
|
||||||
|
if (filter == 0 && m_ServerModItemCounts.Get(addon) == 0 && m_ServerModVehicleCounts.Get(addon) == 0) visible = false;
|
||||||
|
row.SetVisible(visible); if (visible) shown++;
|
||||||
|
string details = m_ServerModItemCounts.Get(addon).ToString() + " items / " + m_ServerModVehicleCounts.Get(addon).ToString() + " vehicles";
|
||||||
|
if (m_ServerModItemCounts.Get(addon) == 0 && m_ServerModVehicleCounts.Get(addon) == 0) details = "No selectable items or vehicles";
|
||||||
|
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText(details);
|
||||||
|
}
|
||||||
|
SetText("ModsCount", shown.ToString() + " of " + m_ServerAddonRows.Count().ToString() + " loaded mods | " + m_ServerScanState);
|
||||||
}
|
}
|
||||||
protected void OnLoadedModEdit(SCR_ButtonBaseComponent button)
|
protected void OnLoadedModEdit(SCR_ButtonBaseComponent button)
|
||||||
{
|
{
|
||||||
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
||||||
foreach (string addon, Widget row : m_ServerAddonRows)
|
foreach (string addon, Widget row : m_ServerAddonRows)
|
||||||
{
|
{
|
||||||
if (button.GetRootWidget() != row.FindAnyWidget("Enable")) continue;
|
if (button.GetRootWidget() == row.FindAnyWidget("Enable")) { SubmitItems("items mod " + addon + " 1"); return; }
|
||||||
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget());
|
if (button.GetRootWidget() == row.FindAnyWidget("Disable")) { SubmitItems("items mod " + addon + " 0"); return; }
|
||||||
if (combo) combo.SetCurrentItem(m_ServerAddonKeys.Find(addon), false, false, false);
|
if (button.GetRootWidget() == row.FindAnyWidget("EditVehicles")) { OpenVehicleAddon(addon); return; }
|
||||||
ShowPage(17); SubmitItems("items list " + addon + " 0"); return;
|
if (button.GetRootWidget() != row.FindAnyWidget("EditItems")) continue;
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("ItemsMod", GetRootWidget()).SetCurrentItem(m_ServerAddonKeys.Find(addon), false, false, false);
|
||||||
|
SCR_EditBoxComponent.GetEditBoxComponent("ItemsSearch", GetRootWidget()).SetValue("");
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("ItemsFilter", GetRootWidget()).SetCurrentItem(0, false, false, false);
|
||||||
|
ShowPage(ERR_AdminPage.ALLOWED_ITEMS); BrowseItems(0); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void SubmitItems(string command)
|
protected void SubmitItems(string command)
|
||||||
{
|
{
|
||||||
m_ClickDelay = 0.3;
|
m_ClickDelay = 0.3;
|
||||||
SetText("Feedback", "Saving selection on the server...");
|
SetText("Feedback", "Waiting for server confirmation...");
|
||||||
m_Controller.ERR_AdminSubmit(command, true);
|
m_Controller.ERR_AdminSubmit(command, true);
|
||||||
}
|
}
|
||||||
protected void ClearItemRows()
|
protected void ClearItemRows()
|
||||||
@@ -237,7 +322,7 @@ modded class ERR_AdminMenu
|
|||||||
}
|
}
|
||||||
protected void OnItemRowButton(SCR_ButtonBaseComponent button)
|
protected void OnItemRowButton(SCR_ButtonBaseComponent button)
|
||||||
{
|
{
|
||||||
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0 || m_ShownItemAddon.IsEmpty()) return;
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0 || !ItemSelectionReady()) return;
|
||||||
foreach (string key, Widget row : m_ItemRows)
|
foreach (string key, Widget row : m_ItemRows)
|
||||||
{
|
{
|
||||||
string value;
|
string value;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ modded class ERR_AdminMenu
|
|||||||
protected ref map<string, Widget> m_WeightRows = new map<string, Widget>();
|
protected ref map<string, Widget> m_WeightRows = new map<string, Widget>();
|
||||||
protected ref map<string, int> m_WeightSaved = new map<string, int>();
|
protected ref map<string, int> m_WeightSaved = new map<string, int>();
|
||||||
protected ref array<string> m_WeightMods = {};
|
protected ref array<string> m_WeightMods = {};
|
||||||
|
protected string m_WeightRowSignature;
|
||||||
protected string m_WeightAddon;
|
protected string m_WeightAddon;
|
||||||
protected int m_WeightPage = -1;
|
protected int m_WeightPage = -1;
|
||||||
override void OnMenuOpen()
|
override void OnMenuOpen()
|
||||||
@@ -68,7 +69,8 @@ modded class ERR_AdminMenu
|
|||||||
m_WeightMods.Copy(m_ServerAddonKeys);
|
m_WeightMods.Copy(m_ServerAddonKeys);
|
||||||
combo.SetCurrentItem(Math.Max(0, m_ServerAddonKeys.Find(m_ShownItemAddon)), false, false, false);
|
combo.SetCurrentItem(Math.Max(0, m_ServerAddonKeys.Find(m_ShownItemAddon)), false, false, false);
|
||||||
}
|
}
|
||||||
bool moved = m_WeightAddon != m_ShownItemAddon || m_WeightPage != m_ShownItemPage;
|
bool moved = m_WeightAddon != m_ShownItemAddon || m_WeightPage != m_ShownItemPage || m_WeightRowSignature != m_ItemRowSignature;
|
||||||
|
m_WeightRowSignature = m_ItemRowSignature;
|
||||||
if (moved)
|
if (moved)
|
||||||
{
|
{
|
||||||
ClearWeightRows(); m_WeightAddon = m_ShownItemAddon; m_WeightPage = m_ShownItemPage;
|
ClearWeightRows(); m_WeightAddon = m_ShownItemAddon; m_WeightPage = m_ShownItemPage;
|
||||||
|
|||||||
@@ -0,0 +1,260 @@
|
|||||||
|
// Server discovery never instantiates a vehicle. New entries are opt-in per use.
|
||||||
|
class ERR_VehicleEntry
|
||||||
|
{
|
||||||
|
ResourceName Prefab;
|
||||||
|
int Defaults;
|
||||||
|
int Capabilities;
|
||||||
|
}
|
||||||
|
class ERR_ServerVehicleCatalog
|
||||||
|
{
|
||||||
|
protected ref array<ref ERR_ServerAddonItems> m_Addons = {};
|
||||||
|
protected ref map<string, ref ERR_VehicleEntry> m_Entries = new map<string, ref ERR_VehicleEntry>();
|
||||||
|
protected ref map<string, ref ERR_ServerItem> m_Items = new map<string, ref ERR_ServerItem>();
|
||||||
|
protected ref array<ResourceName> m_Pending = {};
|
||||||
|
protected ref set<string> m_Queued = new set<string>();
|
||||||
|
protected ERR_GameMode m_Mode;
|
||||||
|
protected int m_Cursor;
|
||||||
|
protected bool m_Started;
|
||||||
|
protected bool m_Truncated;
|
||||||
|
static string RoleName(int role)
|
||||||
|
{
|
||||||
|
if (role == 0) return "Garages / yards";
|
||||||
|
if (role == 1) return "Civilian traffic";
|
||||||
|
if (role == 2) return "Enemy patrols";
|
||||||
|
if (role == 3) return "Convoy armed escorts";
|
||||||
|
return "Convoy supply trucks";
|
||||||
|
}
|
||||||
|
static string RoleHint(int role)
|
||||||
|
{
|
||||||
|
if (role == 0) return "Garages / yards: unarmed vehicles that fit the parking space.";
|
||||||
|
if (role == 1) return "Traffic: vehicles with AI driving support; road size limits apply.";
|
||||||
|
if (role == 2) return "Enemy patrols: driver and crew, up to 15 seats; your enemy faction supplies the soldiers.";
|
||||||
|
if (role == 3) return "Convoy escorts: driver and gunner required. The specialized BMP slot stays unchanged.";
|
||||||
|
return "Convoy supply slot: AI vehicle with cargo storage; normal supply capacity checks apply.";
|
||||||
|
}
|
||||||
|
static bool Candidate(string path)
|
||||||
|
{
|
||||||
|
path.ToLower();
|
||||||
|
return path.EndsWith(".et") && path.Contains("vehicle") && !path.Contains("wreck")
|
||||||
|
&& !path.Contains("_base") && !path.Contains("/parts/") && !path.Contains("/turrets/");
|
||||||
|
}
|
||||||
|
protected void Queue(ResourceName prefab, string path = "")
|
||||||
|
{
|
||||||
|
string key = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
if (key.IsEmpty() || m_Queued.Contains(key)) return;
|
||||||
|
if (m_Pending.Count() >= 8192) { m_Truncated = true; return; }
|
||||||
|
m_Queued.Insert(key); m_Pending.Insert(prefab);
|
||||||
|
}
|
||||||
|
protected void Search(ResourceName prefab, string path = "") { if (Candidate(prefab)) Queue(prefab); }
|
||||||
|
protected void Catalog(SCR_EntityCatalog catalog)
|
||||||
|
{
|
||||||
|
if (!catalog) return;
|
||||||
|
array<SCR_EntityCatalogEntry> entries = {}; catalog.GetEntityList(entries);
|
||||||
|
foreach (SCR_EntityCatalogEntry entry : entries) if (entry && entry.IsEnabled()) Queue(entry.GetPrefab());
|
||||||
|
}
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
if (m_Started || !Replication.IsServer()) return;
|
||||||
|
m_Mode = ERR_GameMode.Get();
|
||||||
|
SCR_EntityCatalogManagerComponent manager = SCR_EntityCatalogManagerComponent.GetInstance();
|
||||||
|
if (!m_Mode || !manager || !GetGame().GetFactionManager()) return;
|
||||||
|
m_Started = true;
|
||||||
|
array<string> loaded = {}; GameProject.GetLoadedAddons(loaded);
|
||||||
|
foreach (string guid : loaded)
|
||||||
|
{
|
||||||
|
ERR_ServerAddonItems addon = new ERR_ServerAddonItems(); addon.Id = guid; addon.Id.ToLower();
|
||||||
|
addon.Project = GameProject.GetAddonID(guid); addon.Label = ERR_ServerItemCatalog.Clean(GameProject.GetAddonTitle(guid));
|
||||||
|
if (addon.Label.IsEmpty()) addon.Label = addon.Project;
|
||||||
|
m_Addons.Insert(addon);
|
||||||
|
}
|
||||||
|
ERR_ServerItemCatalog.SortAddons(m_Addons);
|
||||||
|
ERR_ParkedCarCatalog cars = new ERR_ParkedCarCatalog(); cars.Find();
|
||||||
|
foreach (ResourceName parked : cars.Prefabs) Seed(parked, 0);
|
||||||
|
foreach (ResourceName road : cars.RoadPrefabs) Seed(road, 1);
|
||||||
|
Seed(ERR_CivilianTraffic.CarPrefab(2), 1);
|
||||||
|
foreach (ResourceName tractor : cars.Tractors) Seed(tractor, 0);
|
||||||
|
ERR_MotorbikeCatalog bikes = new ERR_MotorbikeCatalog(); bikes.Find();
|
||||||
|
foreach (ResourceName bike : bikes.Prefabs) Seed(bike, 0);
|
||||||
|
Seed(ERR_HunterFleetRules.VehiclePrefab(0), 2); Seed(ERR_HunterFleetRules.VehiclePrefab(2), 2);
|
||||||
|
Seed(ERR_ConvoyResources.VehiclePrefab(0), 3); Seed(ERR_ConvoyResources.VehiclePrefab(1), 4);
|
||||||
|
Catalog(manager.GetEntityCatalogOfType(EEntityCatalogType.VEHICLE, false));
|
||||||
|
array<Faction> factions = {}; GetGame().GetFactionManager().GetFactionsList(factions);
|
||||||
|
foreach (Faction faction : factions)
|
||||||
|
{
|
||||||
|
SCR_Faction nativeFaction = SCR_Faction.Cast(faction);
|
||||||
|
if (nativeFaction) Catalog(nativeFaction.GetFactionEntityCatalogOfType(EEntityCatalogType.VEHICLE, false));
|
||||||
|
}
|
||||||
|
// Also find complete vehicle prefabs from mods without faction catalogs.
|
||||||
|
foreach (ERR_ServerAddonItems project : m_Addons)
|
||||||
|
{
|
||||||
|
SearchResourcesFilter filter = new SearchResourcesFilter(); filter.fileExtensions = {"et"}; filter.recursive = true;
|
||||||
|
filter.rootPath = "$" + project.Project + ":Prefabs";
|
||||||
|
ResourceDatabase.SearchResources(filter, Search);
|
||||||
|
}
|
||||||
|
GetGame().GetCallqueue().CallLater(Scan, 50, true); m_Mode.OnStop().Insert(Stop);
|
||||||
|
}
|
||||||
|
void Stop()
|
||||||
|
{
|
||||||
|
if (GetGame()) GetGame().GetCallqueue().Remove(Scan);
|
||||||
|
if (m_Mode) m_Mode.OnStop().Remove(Stop);
|
||||||
|
m_Mode = null; m_Started = false; m_Cursor = 0;
|
||||||
|
m_Addons.Clear(); m_Entries.Clear(); m_Items.Clear(); m_Pending.Clear(); m_Queued.Clear();
|
||||||
|
}
|
||||||
|
protected void Seed(ResourceName prefab, int role)
|
||||||
|
{
|
||||||
|
string key = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
ERR_VehicleEntry entry = m_Entries.Get(key);
|
||||||
|
if (!entry) { entry = new ERR_VehicleEntry(); entry.Prefab = prefab; m_Entries.Set(key, entry); }
|
||||||
|
entry.Defaults = entry.Defaults | (1 << role);
|
||||||
|
// Authored defaults remain available while asynchronous discovery completes.
|
||||||
|
entry.Capabilities = entry.Capabilities | (1 << role);
|
||||||
|
Queue(prefab);
|
||||||
|
}
|
||||||
|
protected bool Has(Resource resource, typename component)
|
||||||
|
{
|
||||||
|
IEntitySource source = SCR_BaseContainerTools.FindEntitySource(resource);
|
||||||
|
if (!source) return false;
|
||||||
|
array<IEntityComponentSource> matches = {};
|
||||||
|
SCR_BaseContainerTools.FindComponentSourcesOfClass(source, component, true, matches);
|
||||||
|
return !matches.IsEmpty();
|
||||||
|
}
|
||||||
|
protected void Scan()
|
||||||
|
{
|
||||||
|
if (!m_Mode || m_Mode != ERR_GameMode.Get() || !Replication.IsServer()) { Stop(); return; }
|
||||||
|
int end = Math.Min(m_Cursor + 4, m_Pending.Count());
|
||||||
|
while (m_Cursor < end)
|
||||||
|
{
|
||||||
|
ResourceName prefab = m_Pending[m_Cursor++]; string key = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
Resource resource = Resource.Load(prefab);
|
||||||
|
if (!resource || !resource.IsValid()) continue;
|
||||||
|
bool wheeled = Has(resource, VehicleWheeledSimulation);
|
||||||
|
bool tracked = Has(resource, VehicleTrackedSimulation);
|
||||||
|
if (!wheeled && !tracked) continue;
|
||||||
|
bool ai = (Has(resource, ChimeraAIVehicleControlComponent) || Has(resource, AICarMovementComponent)) && Has(resource, SCR_AIVehicleUsageComponent);
|
||||||
|
ERR_VehicleEntry entry = m_Entries.Get(key);
|
||||||
|
if (!entry) { entry = new ERR_VehicleEntry(); entry.Prefab = prefab; m_Entries.Set(key, entry); }
|
||||||
|
int capabilities;
|
||||||
|
if (wheeled) capabilities = 1;
|
||||||
|
if (ai)
|
||||||
|
{
|
||||||
|
capabilities = capabilities | 12;
|
||||||
|
if (wheeled) capabilities = capabilities | 2;
|
||||||
|
if (Has(resource, InventoryStorageManagerComponent)) capabilities = capabilities | 16;
|
||||||
|
}
|
||||||
|
entry.Capabilities = capabilities;
|
||||||
|
ERR_ServerItem item = new ERR_ServerItem(); item.Prefab = prefab; item.Eligible = true;
|
||||||
|
item.Label = FilePath.StripPath(prefab.GetPath()); item.Label.Replace(".et", ""); item.Label.Replace("_", " "); item.SearchLabel = item.Label;
|
||||||
|
m_Items.Set(key, item);
|
||||||
|
array<string> sources = SCR_AddonTool.GetResourceAddons(prefab);
|
||||||
|
foreach (ERR_ServerAddonItems addon : m_Addons) if (sources.Contains(addon.Project)) addon.Items.Insert(item);
|
||||||
|
}
|
||||||
|
if (m_Cursor >= m_Pending.Count())
|
||||||
|
{
|
||||||
|
GetGame().GetCallqueue().Remove(Scan);
|
||||||
|
foreach (ERR_ServerAddonItems sorted : m_Addons) ERR_ServerItemCatalog.SortItems(sorted.Items);
|
||||||
|
PrintFormat("Reintroduced [server vehicles]: inspected=%1 groundVehicles=%2 truncated=%3", m_Cursor, m_Items.Count(), m_Truncated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ERR_ServerAddonItems Find(string id)
|
||||||
|
{
|
||||||
|
foreach (ERR_ServerAddonItems addon : m_Addons) if (addon.Id == id) return addon;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bool Contains(string addonId, string itemId)
|
||||||
|
{
|
||||||
|
ERR_ServerAddonItems addon = Find(addonId); if (!addon) return false;
|
||||||
|
foreach (ERR_ServerItem item : addon.Items) if (ERR_TerrainCatalog.Key(item.Prefab) == itemId) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void Reject(ResourceName prefab, int role)
|
||||||
|
{
|
||||||
|
ERR_VehicleEntry entry = m_Entries.Get(ERR_TerrainCatalog.Key(prefab));
|
||||||
|
if (!entry || role < 0 || role > 4) return;
|
||||||
|
entry.Capabilities = entry.Capabilities & ~(1 << role);
|
||||||
|
PrintFormat("Reintroduced [vehicle assignment]: rejected %1 for %2: physical fit, driver, crew seats or storage unavailable; excluded until next round", prefab, RoleName(role));
|
||||||
|
}
|
||||||
|
bool Capable(string key, int role)
|
||||||
|
{
|
||||||
|
ERR_VehicleEntry entry = m_Entries.Get(key);
|
||||||
|
return role >= 0 && role < 5 && entry && (entry.Capabilities & (1 << role)) != 0;
|
||||||
|
}
|
||||||
|
bool Allowed(ResourceName prefab, int role)
|
||||||
|
{
|
||||||
|
Start(); string key = ERR_TerrainCatalog.Key(prefab); ERR_VehicleEntry entry = m_Entries.Get(key);
|
||||||
|
return Capable(key, role) && GetGame().ERR_ItemSelections().AllowsVehicleRole(prefab, role, (entry.Defaults & (1 << role)) != 0);
|
||||||
|
}
|
||||||
|
ResourceName Choose(int role, ResourceName preferred, bool otherDefaults = true)
|
||||||
|
{
|
||||||
|
Start(); array<ResourceName> choices = {};
|
||||||
|
if (!preferred.IsEmpty() && Allowed(preferred, role)) choices.Insert(preferred);
|
||||||
|
foreach (string key, ERR_VehicleEntry entry : m_Entries)
|
||||||
|
if ((entry.Defaults & (1 << role)) == 0 && Allowed(entry.Prefab, role) && !choices.Contains(entry.Prefab)) choices.Insert(entry.Prefab);
|
||||||
|
// If the preferred default was disabled, another enabled default may serve.
|
||||||
|
if (choices.IsEmpty() && otherDefaults)
|
||||||
|
foreach (string key, ERR_VehicleEntry entry : m_Entries)
|
||||||
|
if (Allowed(entry.Prefab, role)) choices.Insert(entry.Prefab);
|
||||||
|
if (choices.IsEmpty()) return "";
|
||||||
|
return choices[Math.RandomInt(0, choices.Count())];
|
||||||
|
}
|
||||||
|
void Snapshot(array<string> values, string selected, int page, int filter, string query, int role = 0)
|
||||||
|
{
|
||||||
|
Start(); ERR_ItemPreferences preferences = GetGame().ERR_ItemSelections();
|
||||||
|
foreach (ERR_ServerAddonItems addon : m_Addons)
|
||||||
|
{
|
||||||
|
if (addon.Items.IsEmpty()) continue;
|
||||||
|
int enabled;
|
||||||
|
foreach (ERR_ServerItem item : addon.Items) if (Allowed(item.Prefab, role)) enabled++;
|
||||||
|
values.Insert("vehicleMod=" + addon.Id + "|" + addon.Label + "|" + addon.Items.Count().ToString() + "|" + enabled.ToString() + "|" + ERR_ServerItemCatalog.Flag(preferences.ModEnabled(addon.Id)));
|
||||||
|
}
|
||||||
|
string scan = "Vehicle discovery complete";
|
||||||
|
if (!m_Started || m_Cursor < m_Pending.Count()) scan = "Discovering vehicles from loaded mods";
|
||||||
|
if (m_Truncated) scan += "; scan limit reached";
|
||||||
|
values.Insert("vehiclesScan=" + scan);
|
||||||
|
ERR_ServerAddonItems chosen = Find(selected); if (!chosen) return;
|
||||||
|
array<ref ERR_ServerItem> matches = {};
|
||||||
|
foreach (ERR_ServerItem candidate : chosen.Items)
|
||||||
|
if (ERR_ServerItemCatalog.Matches(candidate.SearchLabel, candidate.Prefab.GetPath(), Allowed(candidate.Prefab, role), filter, query)) matches.Insert(candidate);
|
||||||
|
int last = Math.Max(0, (matches.Count() - 1) / ERR_ServerItemCatalog.PAGE_SIZE); page = Math.Clamp(page, 0, last);
|
||||||
|
values.Insert("vehiclesPage=" + selected + "|" + page.ToString() + "|" + last.ToString() + "|" + matches.Count().ToString() + "|" + role.ToString());
|
||||||
|
int end = Math.Min(matches.Count(), (page + 1) * ERR_ServerItemCatalog.PAGE_SIZE);
|
||||||
|
for (int i = page * ERR_ServerItemCatalog.PAGE_SIZE; i < end; i++)
|
||||||
|
{
|
||||||
|
ERR_ServerItem item = matches[i]; string key = ERR_TerrainCatalog.Key(item.Prefab); ERR_VehicleEntry entry = m_Entries.Get(key);
|
||||||
|
bool capable = Capable(key, role), effective = Allowed(item.Prefab, role);
|
||||||
|
int rule = preferences.VehicleRole(selected, key, role);
|
||||||
|
bool selectedChoice = rule == 1 || (rule == -1 && (entry.Defaults & (1 << role)) != 0);
|
||||||
|
string use = RoleName(role) + ": not assigned";
|
||||||
|
if (selectedChoice) use = RoleName(role) + ": selected; fit and crew checked at spawn";
|
||||||
|
if (!preferences.ModEnabled(selected)) use = "Mod disabled - assignments remembered";
|
||||||
|
else if (selectedChoice && !effective) use = "Disabled by another source mod or vehicle switch";
|
||||||
|
if (!capable) use = "Unavailable for this use: missing support or failed spawn checks";
|
||||||
|
values.Insert("serverVehicle=" + key + "|" + item.Label + "|" + ERR_ServerItemCatalog.Clean(item.Prefab.GetPath()) + "|" + use + "|" + ERR_ServerItemCatalog.Flag(selectedChoice) + "|" + ERR_ServerItemCatalog.Flag(effective) + "|" + ERR_ServerItemCatalog.Flag(capable));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_VehicleSelection
|
||||||
|
{
|
||||||
|
static bool Allowed(ResourceName prefab) { return !prefab.IsEmpty() && GetGame().ERR_ItemSelections().AllowsVehicle(prefab); }
|
||||||
|
static ResourceName Choose(array<ResourceName> pool, int role = -1)
|
||||||
|
{
|
||||||
|
array<ResourceName> enabled = {};
|
||||||
|
foreach (ResourceName prefab : pool) if ((role < 0 && Allowed(prefab)) || (role >= 0 && RoleAllowed(prefab, role))) enabled.Insert(prefab);
|
||||||
|
if (enabled.IsEmpty()) return "";
|
||||||
|
return enabled[Math.RandomInt(0, enabled.Count())];
|
||||||
|
}
|
||||||
|
static ResourceName ForRole(int role, ResourceName preferred, bool otherDefaults = true) { return GetGame().ERR_ServerVehicles().Choose(role, preferred, otherDefaults); }
|
||||||
|
static bool RoleAllowed(ResourceName prefab, int role) { return !prefab.IsEmpty() && GetGame().ERR_ServerVehicles().Allowed(prefab, role); }
|
||||||
|
static bool PatrolSeats(int drivers, int turrets, int cargo, int total)
|
||||||
|
{
|
||||||
|
return drivers == 1 && turrets >= 0 && cargo >= 0 && turrets + cargo >= 1 && total == drivers + turrets + cargo && total <= 15;
|
||||||
|
}
|
||||||
|
// A mod cannot enlarge the existing 4m x 9m x 3.5m road deployment envelope.
|
||||||
|
static bool RoadFit(Vehicle vehicle)
|
||||||
|
{
|
||||||
|
if (!vehicle || (!vehicle.FindComponent(ChimeraAIVehicleControlComponent) && !vehicle.FindComponent(AICarMovementComponent)) || !vehicle.FindComponent(SCR_AIVehicleUsageComponent)) return false;
|
||||||
|
vector low, high; vehicle.GetBounds(low, high);
|
||||||
|
return ERR_ForceRules.FiniteVector(low) && ERR_ForceRules.FiniteVector(high)
|
||||||
|
&& low[0] >= -2 && high[0] <= 2 && low[2] >= -4.5 && high[2] <= 4.5 && high[1] - low[1] > 0 && high[1] - low[1] <= 3.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
modded class ERR_AdminMenu
|
||||||
|
{
|
||||||
|
protected ref array<string> m_VehicleMods = {};
|
||||||
|
protected ref array<string> m_VehicleLabels = {};
|
||||||
|
protected ref array<SCR_ButtonTextComponent> m_VehicleButtons = {};
|
||||||
|
protected ref map<string, Widget> m_VehicleRows = new map<string, Widget>();
|
||||||
|
protected ref map<string, int> m_VehicleSaved = new map<string, int>();
|
||||||
|
protected ref map<string, int> m_VehicleStates = new map<string, int>();
|
||||||
|
protected string m_ShownVehicleAddon;
|
||||||
|
protected string m_LastVehicleChoice;
|
||||||
|
protected string m_VehicleRowSignature;
|
||||||
|
protected int m_ShownVehiclePage;
|
||||||
|
protected int m_LastVehiclePage;
|
||||||
|
protected int m_LastVehicleFilter = -1;
|
||||||
|
protected int m_LastVehicleRole = -1;
|
||||||
|
protected int m_ShownVehicleRole;
|
||||||
|
protected ref map<string, int> m_VehicleCapable = new map<string, int>();
|
||||||
|
override void OnMenuOpen()
|
||||||
|
{
|
||||||
|
super.OnMenuOpen();
|
||||||
|
foreach (string name : {"VehiclesShow", "VehiclesClear", "VehiclesPrevious", "VehiclesNext", "VehiclesEnableAll", "VehiclesDisableAll"})
|
||||||
|
{
|
||||||
|
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
||||||
|
if (!button) { Close(); return; }
|
||||||
|
button.m_OnClicked.Insert(OnVehiclesButton); m_VehicleButtons.Insert(button);
|
||||||
|
}
|
||||||
|
SCR_ComboBoxComponent filter = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesFilter", GetRootWidget());
|
||||||
|
filter.AddItem("All"); filter.AddItem("Enabled"); filter.AddItem("Disabled"); filter.SetCurrentItem(0, false, false, false);
|
||||||
|
SCR_ComboBoxComponent roles = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesRole", GetRootWidget());
|
||||||
|
for (int role = 0; role < 5; role++) roles.AddItem("Use for: " + ERR_ServerVehicleCatalog.RoleName(role));
|
||||||
|
roles.SetCurrentItem(0, false, false, false);
|
||||||
|
UpdateActions();
|
||||||
|
}
|
||||||
|
protected void ClearVehicleRows()
|
||||||
|
{
|
||||||
|
foreach (string key, Widget row : m_VehicleRows)
|
||||||
|
{
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Enable", row).m_OnClicked.Remove(OnVehicleRowButton);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Disable", row).m_OnClicked.Remove(OnVehicleRowButton);
|
||||||
|
row.RemoveFromHierarchy();
|
||||||
|
}
|
||||||
|
m_VehicleRows.Clear(); m_VehicleSaved.Clear(); m_VehicleCapable.Clear();
|
||||||
|
}
|
||||||
|
override void OnMenuClose()
|
||||||
|
{
|
||||||
|
foreach (SCR_ButtonTextComponent button : m_VehicleButtons) button.m_OnClicked.Remove(OnVehiclesButton);
|
||||||
|
m_LastVehicleChoice = ""; m_LastVehicleFilter = -1; m_LastVehicleRole = -1; m_ShownVehicleAddon = ""; m_VehicleRowSignature = "";
|
||||||
|
ClearVehicleRows(); m_VehicleButtons.Clear(); m_VehicleMods.Clear(); m_VehicleLabels.Clear(); m_VehicleStates.Clear();
|
||||||
|
super.OnMenuClose();
|
||||||
|
}
|
||||||
|
protected override void UpdateActions()
|
||||||
|
{
|
||||||
|
super.UpdateActions();
|
||||||
|
bool ready = VehicleSelectionReady();
|
||||||
|
foreach (SCR_ButtonTextComponent button : m_VehicleButtons)
|
||||||
|
{
|
||||||
|
string name = button.GetRootWidget().GetName(); bool enabled = ready;
|
||||||
|
if (name == "VehiclesShow" || name == "VehiclesClear") enabled = m_Ready && !m_VehicleMods.IsEmpty();
|
||||||
|
if (name == "VehiclesPrevious") enabled = ready && m_ShownVehiclePage > 0;
|
||||||
|
if (name == "VehiclesNext") enabled = ready && m_ShownVehiclePage < m_LastVehiclePage;
|
||||||
|
button.SetEnabled(enabled);
|
||||||
|
}
|
||||||
|
foreach (string key, Widget row : m_VehicleRows)
|
||||||
|
{
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Enable", row).SetEnabled(ready && m_VehicleCapable.Get(key) == 1 && m_VehicleSaved.Get(key) == 0);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Disable", row).SetEnabled(ready && m_VehicleSaved.Get(key) == 1);
|
||||||
|
ERR_SelectionStyle.Pair(row, "Enable", "Disable", m_VehicleSaved.Get(key));
|
||||||
|
if (!m_Ready) ERR_SelectionStyle.Status(row, "SelectionState", -1);
|
||||||
|
}
|
||||||
|
int state = -1; if (ready && m_VehicleStates.Contains(m_ShownVehicleAddon)) state = m_VehicleStates.Get(m_ShownVehicleAddon);
|
||||||
|
ERR_SelectionStyle.Status(GetRootWidget(), "VehiclesSelectionState", state);
|
||||||
|
}
|
||||||
|
override void ReceiveSnapshot(bool authorized, array<string> values, array<string> status)
|
||||||
|
{
|
||||||
|
super.ReceiveSnapshot(authorized, values, status);
|
||||||
|
if (!authorized || !values) return;
|
||||||
|
array<string> keys = {}, labels = {}, rows = {}; string shown, signature, scan; int page, last, total, role;
|
||||||
|
foreach (string entry : values)
|
||||||
|
{
|
||||||
|
int divider = entry.IndexOf("="); if (divider < 0) continue;
|
||||||
|
string field = entry.Substring(0, divider), value = entry.Substring(divider + 1, entry.Length() - divider - 1);
|
||||||
|
array<string> parts = {}; value.Split("|", parts, false);
|
||||||
|
if (field == "vehiclesScan") scan = value;
|
||||||
|
if (field == "vehicleMod" && parts.Count() == 5)
|
||||||
|
{
|
||||||
|
keys.Insert(parts[0]); labels.Insert(parts[1]);
|
||||||
|
m_VehicleStates.Set(parts[0], ERR_SelectionStyle.Aggregate(parts[2].ToInt(), parts[3].ToInt(), parts[4] == "1"));
|
||||||
|
}
|
||||||
|
if (field == "vehiclesPage" && parts.Count() == 5) { shown = parts[0]; page = parts[1].ToInt(); last = parts[2].ToInt(); total = parts[3].ToInt(); role = parts[4].ToInt(); }
|
||||||
|
if (field == "serverVehicle" && parts.Count() == 7) { rows.Insert(value); signature += parts[0]; }
|
||||||
|
}
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesMod", GetRootWidget());
|
||||||
|
if (keys.Count() != m_VehicleMods.Count())
|
||||||
|
{
|
||||||
|
combo.ClearAll(); foreach (string label : labels) combo.AddItem(label);
|
||||||
|
m_VehicleMods.Copy(keys); m_VehicleLabels.Copy(labels); combo.SetCurrentItem(Math.Max(0, keys.Find(m_ShownVehicleAddon)), false, false, false);
|
||||||
|
}
|
||||||
|
if (!shown.IsEmpty())
|
||||||
|
{
|
||||||
|
bool moved = shown != m_ShownVehicleAddon || page != m_ShownVehiclePage || signature != m_VehicleRowSignature || role != m_ShownVehicleRole;
|
||||||
|
SetText("VehiclesHelp", ERR_ServerVehicleCatalog.RoleHint(role));
|
||||||
|
m_ShownVehicleRole = role; m_ShownVehicleAddon = shown; m_ShownVehiclePage = page; m_LastVehiclePage = last; m_VehicleRowSignature = signature;
|
||||||
|
if (moved) ClearVehicleRows();
|
||||||
|
string scanNote; if (scan != "Vehicle discovery complete") scanNote = " (scanning)";
|
||||||
|
SetText("VehiclesPageState", total.ToString() + " matching vehicles | Page " + (page + 1).ToString() + " of " + (last + 1).ToString() + scanNote);
|
||||||
|
foreach (string data : rows)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; data.Split("|", parts, false); Widget row = m_VehicleRows.Get(parts[0]);
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
row = GetGame().GetWorkspace().CreateWidgets("{93A8120CBE7DA469}UI/layouts/ERR/ItemRow.layout", GetRootWidget().FindAnyWidget("VehiclesContent"));
|
||||||
|
if (!row) continue;
|
||||||
|
m_VehicleRows.Set(parts[0], row);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Enable", row).m_OnClicked.Insert(OnVehicleRowButton);
|
||||||
|
SCR_ButtonTextComponent.GetButtonText("Disable", row).m_OnClicked.Insert(OnVehicleRowButton);
|
||||||
|
}
|
||||||
|
TextWidget.Cast(row.FindAnyWidget("PackLabel")).SetText(WidgetManager.Translate(parts[1]));
|
||||||
|
TextWidget.Cast(row.FindAnyWidget("PackState")).SetText(parts[3]);
|
||||||
|
m_VehicleCapable.Set(parts[0], parts[6].ToInt()); m_VehicleSaved.Set(parts[0], parts[4].ToInt()); ERR_SelectionStyle.Status(row, "SelectionState", parts[5].ToInt());
|
||||||
|
}
|
||||||
|
string empty; if (rows.IsEmpty()) empty = "No vehicles match. Clear search or choose All to see more.";
|
||||||
|
SetText("VehiclesText", empty);
|
||||||
|
GetRootWidget().FindAnyWidget("VehiclesText").SetVisible(!empty.IsEmpty());
|
||||||
|
if (moved) ScrollLayoutWidget.Cast(GetRootWidget().FindAnyWidget("VehiclesScroll")).SetSliderPos(0, 0);
|
||||||
|
}
|
||||||
|
else if (keys.IsEmpty()) SetText("VehiclesText", "Discovering ground vehicles on this server...");
|
||||||
|
UpdateActions();
|
||||||
|
}
|
||||||
|
protected override void OpenVehicleAddon(string addon)
|
||||||
|
{
|
||||||
|
int index = m_VehicleMods.Find(addon); if (index < 0) return;
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesMod", GetRootWidget()).SetCurrentItem(index, false, false, false);
|
||||||
|
SCR_EditBoxComponent.GetEditBoxComponent("VehiclesSearch", GetRootWidget()).SetValue("");
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesFilter", GetRootWidget()).SetCurrentItem(0, false, false, false);
|
||||||
|
ShowPage(ERR_AdminPage.VEHICLE_POOL); BrowseVehicles(0);
|
||||||
|
}
|
||||||
|
protected bool VehicleSelectionReady()
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesMod", GetRootWidget());
|
||||||
|
if (!m_Ready || !combo) return false;
|
||||||
|
int index = combo.GetCurrentIndex();
|
||||||
|
return index >= 0 && index < m_VehicleMods.Count() && m_VehicleMods[index] == m_ShownVehicleAddon && SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesRole", GetRootWidget()).GetCurrentIndex() == m_ShownVehicleRole;
|
||||||
|
}
|
||||||
|
protected void BrowseVehicles(int page)
|
||||||
|
{
|
||||||
|
int index = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesMod", GetRootWidget()).GetCurrentIndex();
|
||||||
|
if (index < 0 || index >= m_VehicleMods.Count()) return;
|
||||||
|
int filter = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesFilter", GetRootWidget()).GetCurrentIndex();
|
||||||
|
string query = SCR_EditBoxComponent.GetEditBoxComponent("VehiclesSearch", GetRootWidget()).GetValue().Trim();
|
||||||
|
if (query.Length() > 64) { ReceiveReply("Search can contain up to 64 characters."); return; }
|
||||||
|
m_LastVehicleChoice = m_VehicleMods[index]; m_LastVehicleFilter = filter;
|
||||||
|
m_LastVehicleRole = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesRole", GetRootWidget()).GetCurrentIndex();
|
||||||
|
SubmitItems("vehicles browse " + m_LastVehicleChoice + " " + page.ToString() + " " + filter.ToString() + " " + m_LastVehicleRole.ToString() + " " + query);
|
||||||
|
UpdateActions();
|
||||||
|
}
|
||||||
|
override void OnMenuUpdate(float tDelta)
|
||||||
|
{
|
||||||
|
super.OnMenuUpdate(tDelta);
|
||||||
|
if (!m_Ready || !IsFocused() || m_ClickDelay > 0 || m_Age > 6 || m_Page != ERR_AdminPage.VEHICLE_POOL) return;
|
||||||
|
int index = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesMod", GetRootWidget()).GetCurrentIndex();
|
||||||
|
int filter = SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesFilter", GetRootWidget()).GetCurrentIndex();
|
||||||
|
if (index >= 0 && index < m_VehicleMods.Count() && (m_VehicleMods[index] != m_LastVehicleChoice || filter != m_LastVehicleFilter || SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesRole", GetRootWidget()).GetCurrentIndex() != m_LastVehicleRole)) BrowseVehicles(0);
|
||||||
|
}
|
||||||
|
protected void OnVehiclesButton(SCR_ButtonBaseComponent button)
|
||||||
|
{
|
||||||
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
||||||
|
string name = button.GetRootWidget().GetName();
|
||||||
|
if (name == "VehiclesEnableAll" || name == "VehiclesDisableAll")
|
||||||
|
{
|
||||||
|
if (!VehicleSelectionReady()) return;
|
||||||
|
string value = "0"; if (name == "VehiclesEnableAll") value = "1";
|
||||||
|
SubmitItems("vehicles role " + m_ShownVehicleAddon + " " + m_ShownVehicleRole.ToString() + " * " + value); return;
|
||||||
|
}
|
||||||
|
if (name == "VehiclesClear")
|
||||||
|
{
|
||||||
|
SCR_EditBoxComponent.GetEditBoxComponent("VehiclesSearch", GetRootWidget()).SetValue("");
|
||||||
|
SCR_ComboBoxComponent.GetComboBoxComponent("VehiclesFilter", GetRootWidget()).SetCurrentItem(0, false, false, false);
|
||||||
|
}
|
||||||
|
int page;
|
||||||
|
if (name == "VehiclesPrevious") page = Math.Max(0, m_ShownVehiclePage - 1);
|
||||||
|
if (name == "VehiclesNext") page = Math.Min(m_LastVehiclePage, m_ShownVehiclePage + 1);
|
||||||
|
BrowseVehicles(page);
|
||||||
|
}
|
||||||
|
protected void OnVehicleRowButton(SCR_ButtonBaseComponent button)
|
||||||
|
{
|
||||||
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0 || !VehicleSelectionReady()) return;
|
||||||
|
foreach (string key, Widget row : m_VehicleRows)
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (button.GetRootWidget() == row.FindAnyWidget("Enable")) value = "1";
|
||||||
|
if (button.GetRootWidget() == row.FindAnyWidget("Disable")) value = "0";
|
||||||
|
if (!value.IsEmpty()) { SubmitItems("vehicles role " + m_ShownVehicleAddon + " " + m_ShownVehicleRole.ToString() + " " + key + " " + value); return; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,13 +9,24 @@ class ERR_Settings
|
|||||||
|
|
||||||
static array<string> Keys()
|
static array<string> Keys()
|
||||||
{
|
{
|
||||||
return {"aiDoctrine", "aiShadow", "motorbikeCount", "planeAltitudeMetres", "planeReplacementSeconds", "planeSectorSeconds", "planeReconEnabled", "fieldCampCount", "fieldHospitalCount", "startWeaponCount", "startMagazineCount", "objectGuardCount", "objectGuardEvery", "objectGuardHQMode", "hunterSpawnDistanceMetres", "roadblockCount", "civilianTrafficCount", "startMode", "keepWeaponOnUnconscious", "reportIntervalSeconds", "supportSquadLimit", "responseRadiusMetres", "aiIntelChancePercent", "intelRevealChancePercent", "radioDefenceSeconds", "startTimeMinutes", "timeMultiplier", "startDateCode", "weatherProfile", "viewDistanceMetres", "antiAirChancePercent", "antiPersonnelMineChancePercent", "automaticEquipmentChancePercent", "automaticConvoyEnabled", "convoyCount", "heliTimerMinutes"};
|
return {"crashLootMode", "crashSiteCount", "crashHelicopterChancePercent", "crashRifleCount", "crashMagazineCount", "crashAntiAirChancePercent", "crashRocketChancePercent", "telemetryEnabled", "aiDoctrine", "aiShadow", "sarkaAngerPerCar", "motorbikeCount", "planeAltitudeMetres", "planeReplacementSeconds", "planeSectorSeconds", "planeReconEnabled", "droneReconCount", "droneCooldownSeconds", "fieldCampCount", "fieldHospitalCount", "startWeaponCount", "startMagazineCount", "objectGuardCount", "objectGuardEvery", "objectGuardHQMode", "hunterSpawnDistanceMetres", "roadblockCount", "largeRoadblockCount", "mainRoadWidthMetres", "civilianTrafficCount", "garageVehicleCount", "garageChancePercent", "garageRadiusMetres", "garageSpawnIntervalSeconds", "startMode", "keepWeaponOnUnconscious", "selfEpinephrine", "restartOnEmpty", "emptyRestartHours", "reportIntervalSeconds", "supportSquadLimit", "responseRadiusMetres", "aiIntelChancePercent", "intelRevealChancePercent", "radioIntelSiteCount", "showAllSites", "radioDefenceSeconds", "startTimeMinutes", "timeMultiplier", "startDateCode", "weatherProfile", "viewDistanceMetres", "antiAirChancePercent", "antiPersonnelMineChancePercent", "automaticEquipmentChancePercent", "automaticConvoyEnabled", "convoyCount", "heliTimerMinutes"};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Valid(string key, int value)
|
static bool Valid(string key, int value)
|
||||||
{
|
{
|
||||||
if (key == "aiDoctrine" || key == "aiShadow") return value == 0 || value == 1;
|
if (key == "crashLootMode") return value == 0 || value == 1;
|
||||||
|
if (key == "crashSiteCount") return value >= 0 && value <= 12;
|
||||||
|
if (key == "crashHelicopterChancePercent") return value >= 0 && value <= 100;
|
||||||
|
if (key == "crashRifleCount") return value >= 1 && value <= 6;
|
||||||
|
if (key == "crashMagazineCount") return value >= 1 && value <= 8;
|
||||||
|
if (key == "crashAntiAirChancePercent") return value >= 0 && value <= 100;
|
||||||
|
if (key == "crashRocketChancePercent") return value >= 0 && value <= 100;
|
||||||
|
if (key == "telemetryEnabled" || key == "aiDoctrine" || key == "aiShadow") return value == 0 || value == 1;
|
||||||
|
if (key == "radioIntelSiteCount") return value >= 0 && value <= 20;
|
||||||
|
if (key == "sarkaAngerPerCar") return value >= 0 && value <= 30;
|
||||||
if (key == "motorbikeCount") return value >= 0 && value <= 6;
|
if (key == "motorbikeCount") return value >= 0 && value <= 6;
|
||||||
|
if (key == "droneReconCount") return value >= 0 && value <= 3;
|
||||||
|
if (key == "droneCooldownSeconds") return value >= 60 && value <= 1800;
|
||||||
if (key == "planeAltitudeMetres") return value >= 150 && value <= 500;
|
if (key == "planeAltitudeMetres") return value >= 150 && value <= 500;
|
||||||
if (key == "planeReplacementSeconds") return value >= 30 && value <= 1800;
|
if (key == "planeReplacementSeconds") return value >= 30 && value <= 1800;
|
||||||
if (key == "planeSectorSeconds") return value >= 30 && value <= 600;
|
if (key == "planeSectorSeconds") return value >= 30 && value <= 600;
|
||||||
@@ -29,9 +40,17 @@ class ERR_Settings
|
|||||||
if (key == "objectGuardCount") return value >= 0 && value <= 16;
|
if (key == "objectGuardCount") return value >= 0 && value <= 16;
|
||||||
if (key == "hunterSpawnDistanceMetres") return value >= 800 && value <= 3000;
|
if (key == "hunterSpawnDistanceMetres") return value >= 800 && value <= 3000;
|
||||||
if (key == "roadblockCount") return value >= 0 && value <= 30;
|
if (key == "roadblockCount") return value >= 0 && value <= 30;
|
||||||
|
if (key == "largeRoadblockCount") return value >= 0 && value <= 30;
|
||||||
|
if (key == "mainRoadWidthMetres") return value >= 5 && value <= 12;
|
||||||
|
if (key == "garageChancePercent") return value >= 0 && value <= 100;
|
||||||
|
if (key == "garageRadiusMetres") return value >= 250 && value <= 1500;
|
||||||
|
if (key == "garageSpawnIntervalSeconds") return value >= 5 && value <= 60;
|
||||||
|
if (key == "garageVehicleCount") return value >= 0 && value <= 24;
|
||||||
if (key == "civilianTrafficCount") return value >= 0 && value <= 6;
|
if (key == "civilianTrafficCount") return value >= 0 && value <= 6;
|
||||||
if (key == "startMode") return value == 0 || value == 1;
|
if (key == "startMode") return value == 0 || value == 1;
|
||||||
if (key == "keepWeaponOnUnconscious") return value == 0 || value == 1;
|
if (key == "showAllSites") return value == 0 || value == 1;
|
||||||
|
if (key == "selfEpinephrine" || key == "keepWeaponOnUnconscious" || key == "restartOnEmpty") return value == 0 || value == 1;
|
||||||
|
if (key == "emptyRestartHours") return value >= 0 && value <= 168;
|
||||||
if (key == "heliTimerMinutes") return value >= 1 && value <= 1440;
|
if (key == "heliTimerMinutes") return value >= 1 && value <= 1440;
|
||||||
if (key == "convoyCount") return value >= 0 && value <= 20;
|
if (key == "convoyCount") return value >= 0 && value <= 20;
|
||||||
if (key == "automaticConvoyEnabled") return value == 0 || value == 1;
|
if (key == "automaticConvoyEnabled") return value == 0 || value == 1;
|
||||||
@@ -115,8 +134,19 @@ class ERR_Settings
|
|||||||
|
|
||||||
static int AddedDefault(string key)
|
static int AddedDefault(string key)
|
||||||
{
|
{
|
||||||
|
if (key == "crashLootMode") return 1;
|
||||||
|
if (key == "crashSiteCount") return 3;
|
||||||
|
if (key == "crashHelicopterChancePercent") return 50;
|
||||||
|
if (key == "crashRifleCount") return 3;
|
||||||
|
if (key == "crashMagazineCount") return 4;
|
||||||
|
if (key == "crashAntiAirChancePercent") return 25;
|
||||||
|
if (key == "crashRocketChancePercent") return 50;
|
||||||
if (key == "aiDoctrine" || key == "aiShadow") return 0;
|
if (key == "aiDoctrine" || key == "aiShadow") return 0;
|
||||||
|
if (key == "radioIntelSiteCount") return 5;
|
||||||
|
if (key == "sarkaAngerPerCar") return 3;
|
||||||
if (key == "motorbikeCount") return 2;
|
if (key == "motorbikeCount") return 2;
|
||||||
|
if (key == "droneReconCount") return 0;
|
||||||
|
if (key == "droneCooldownSeconds") return 300;
|
||||||
if (key == "planeAltitudeMetres") return 250;
|
if (key == "planeAltitudeMetres") return 250;
|
||||||
if (key == "planeReplacementSeconds") return 60;
|
if (key == "planeReplacementSeconds") return 60;
|
||||||
if (key == "planeSectorSeconds") return 120;
|
if (key == "planeSectorSeconds") return 120;
|
||||||
@@ -130,9 +160,17 @@ class ERR_Settings
|
|||||||
if (key == "objectGuardCount") return 8;
|
if (key == "objectGuardCount") return 8;
|
||||||
if (key == "hunterSpawnDistanceMetres") return 1000;
|
if (key == "hunterSpawnDistanceMetres") return 1000;
|
||||||
if (key == "roadblockCount") return 4;
|
if (key == "roadblockCount") return 4;
|
||||||
|
if (key == "largeRoadblockCount") return 4;
|
||||||
|
if (key == "mainRoadWidthMetres") return 6;
|
||||||
if (key == "civilianTrafficCount") return 3;
|
if (key == "civilianTrafficCount") return 3;
|
||||||
if (key == "startMode") return 0;
|
if (key == "garageChancePercent") return 70;
|
||||||
if (key == "keepWeaponOnUnconscious") return 1;
|
if (key == "garageRadiusMetres") return 1000;
|
||||||
|
if (key == "garageSpawnIntervalSeconds") return 5;
|
||||||
|
if (key == "garageVehicleCount") return 16;
|
||||||
|
if (key == "showAllSites") return 0;
|
||||||
|
if (key == "startMode" || key == "selfEpinephrine") return 0;
|
||||||
|
if (key == "telemetryEnabled" || key == "keepWeaponOnUnconscious" || key == "restartOnEmpty") return 1;
|
||||||
|
if (key == "emptyRestartHours") return 5;
|
||||||
if (key == "heliTimerMinutes") return 15;
|
if (key == "heliTimerMinutes") return 15;
|
||||||
if (key == "convoyCount") return 3;
|
if (key == "convoyCount") return 3;
|
||||||
if (key == "automaticConvoyEnabled") return 1;
|
if (key == "automaticConvoyEnabled") return 1;
|
||||||
@@ -148,9 +186,24 @@ class ERR_Settings
|
|||||||
void ERR_Settings(string path = PATH)
|
void ERR_Settings(string path = PATH)
|
||||||
{
|
{
|
||||||
m_Path = path;
|
m_Path = path;
|
||||||
|
m_Values.Set("crashLootMode", AddedDefault("crashLootMode"));
|
||||||
|
m_Values.Set("crashSiteCount", AddedDefault("crashSiteCount"));
|
||||||
|
m_Values.Set("crashHelicopterChancePercent", AddedDefault("crashHelicopterChancePercent"));
|
||||||
|
m_Values.Set("crashRifleCount", AddedDefault("crashRifleCount"));
|
||||||
|
m_Values.Set("crashMagazineCount", AddedDefault("crashMagazineCount"));
|
||||||
|
m_Values.Set("crashAntiAirChancePercent", AddedDefault("crashAntiAirChancePercent"));
|
||||||
|
m_Values.Set("crashRocketChancePercent", AddedDefault("crashRocketChancePercent"));
|
||||||
|
m_Values.Set("telemetryEnabled", AddedDefault("telemetryEnabled"));
|
||||||
m_Values.Set("aiDoctrine", AddedDefault("aiDoctrine"));
|
m_Values.Set("aiDoctrine", AddedDefault("aiDoctrine"));
|
||||||
m_Values.Set("aiShadow", AddedDefault("aiShadow"));
|
m_Values.Set("aiShadow", AddedDefault("aiShadow"));
|
||||||
|
m_Values.Set("sarkaAngerPerCar", AddedDefault("sarkaAngerPerCar"));
|
||||||
|
m_Values.Set("garageChancePercent", AddedDefault("garageChancePercent"));
|
||||||
|
m_Values.Set("garageRadiusMetres", AddedDefault("garageRadiusMetres"));
|
||||||
|
m_Values.Set("garageSpawnIntervalSeconds", AddedDefault("garageSpawnIntervalSeconds"));
|
||||||
|
m_Values.Set("garageVehicleCount", AddedDefault("garageVehicleCount"));
|
||||||
m_Values.Set("motorbikeCount", AddedDefault("motorbikeCount"));
|
m_Values.Set("motorbikeCount", AddedDefault("motorbikeCount"));
|
||||||
|
m_Values.Set("droneReconCount", AddedDefault("droneReconCount"));
|
||||||
|
m_Values.Set("droneCooldownSeconds", AddedDefault("droneCooldownSeconds"));
|
||||||
m_Values.Set("planeAltitudeMetres", AddedDefault("planeAltitudeMetres"));
|
m_Values.Set("planeAltitudeMetres", AddedDefault("planeAltitudeMetres"));
|
||||||
m_Values.Set("planeReplacementSeconds", AddedDefault("planeReplacementSeconds"));
|
m_Values.Set("planeReplacementSeconds", AddedDefault("planeReplacementSeconds"));
|
||||||
m_Values.Set("planeSectorSeconds", AddedDefault("planeSectorSeconds"));
|
m_Values.Set("planeSectorSeconds", AddedDefault("planeSectorSeconds"));
|
||||||
@@ -164,14 +217,21 @@ class ERR_Settings
|
|||||||
m_Values.Set("objectGuardHQMode", AddedDefault("objectGuardHQMode"));
|
m_Values.Set("objectGuardHQMode", AddedDefault("objectGuardHQMode"));
|
||||||
m_Values.Set("hunterSpawnDistanceMetres", AddedDefault("hunterSpawnDistanceMetres"));
|
m_Values.Set("hunterSpawnDistanceMetres", AddedDefault("hunterSpawnDistanceMetres"));
|
||||||
m_Values.Set("roadblockCount", AddedDefault("roadblockCount"));
|
m_Values.Set("roadblockCount", AddedDefault("roadblockCount"));
|
||||||
|
m_Values.Set("largeRoadblockCount", AddedDefault("largeRoadblockCount"));
|
||||||
|
m_Values.Set("mainRoadWidthMetres", AddedDefault("mainRoadWidthMetres"));
|
||||||
m_Values.Set("civilianTrafficCount", AddedDefault("civilianTrafficCount"));
|
m_Values.Set("civilianTrafficCount", AddedDefault("civilianTrafficCount"));
|
||||||
m_Values.Set("startMode", AddedDefault("startMode"));
|
m_Values.Set("startMode", AddedDefault("startMode"));
|
||||||
m_Values.Set("keepWeaponOnUnconscious", AddedDefault("keepWeaponOnUnconscious"));
|
m_Values.Set("keepWeaponOnUnconscious", AddedDefault("keepWeaponOnUnconscious"));
|
||||||
|
m_Values.Set("selfEpinephrine", AddedDefault("selfEpinephrine"));
|
||||||
|
m_Values.Set("restartOnEmpty", AddedDefault("restartOnEmpty"));
|
||||||
|
m_Values.Set("emptyRestartHours", AddedDefault("emptyRestartHours"));
|
||||||
m_Values.Set("reportIntervalSeconds", 10);
|
m_Values.Set("reportIntervalSeconds", 10);
|
||||||
m_Values.Set("supportSquadLimit", 4);
|
m_Values.Set("supportSquadLimit", 4);
|
||||||
m_Values.Set("responseRadiusMetres", 2000);
|
m_Values.Set("responseRadiusMetres", 2000);
|
||||||
m_Values.Set("aiIntelChancePercent", 60);
|
m_Values.Set("aiIntelChancePercent", 60);
|
||||||
m_Values.Set("intelRevealChancePercent", 15);
|
m_Values.Set("intelRevealChancePercent", 15);
|
||||||
|
m_Values.Set("radioIntelSiteCount", 5);
|
||||||
|
m_Values.Set("showAllSites", AddedDefault("showAllSites"));
|
||||||
m_Values.Set("radioDefenceSeconds", 180);
|
m_Values.Set("radioDefenceSeconds", 180);
|
||||||
m_Values.Set("startTimeMinutes", AddedDefault("startTimeMinutes"));
|
m_Values.Set("startTimeMinutes", AddedDefault("startTimeMinutes"));
|
||||||
m_Values.Set("timeMultiplier", AddedDefault("timeMultiplier"));
|
m_Values.Set("timeMultiplier", AddedDefault("timeMultiplier"));
|
||||||
@@ -206,6 +266,19 @@ class ERR_Settings
|
|||||||
values = new map<string, int>();
|
values = new map<string, int>();
|
||||||
foreach (string key : Keys())
|
foreach (string key : Keys())
|
||||||
{
|
{
|
||||||
|
// The former multiplier cannot express a lower frequency. Keep disabled
|
||||||
|
// saves disabled; migrate enabled saves to the new three-points-per-car default.
|
||||||
|
// An explicit new setting always takes precedence over the legacy key.
|
||||||
|
if (key == "sarkaAngerPerCar" && !json.DoesKeyExist(key) && json.DoesKeyExist("sarkaCarsPerAnger"))
|
||||||
|
{
|
||||||
|
float oldCars;
|
||||||
|
if (!json.ReadValue("sarkaCarsPerAnger", oldCars)) return false;
|
||||||
|
int oldMultiplier = Math.Round(oldCars);
|
||||||
|
if (oldCars != oldMultiplier || oldMultiplier < 0 || oldMultiplier > 5) return false;
|
||||||
|
int points = AddedDefault(key);
|
||||||
|
if (oldMultiplier == 0) points = 0;
|
||||||
|
values.Set(key, points); continue;
|
||||||
|
}
|
||||||
// Migrate the former one-in-N setting to the nearest integer percent.
|
// Migrate the former one-in-N setting to the nearest integer percent.
|
||||||
if (key == "antiAirChancePercent" && !json.DoesKeyExist(key) && json.DoesKeyExist("stingerChanceOneIn"))
|
if (key == "antiAirChancePercent" && !json.DoesKeyExist(key) && json.DoesKeyExist("stingerChanceOneIn"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
[BaseContainerProps()]
|
[BaseContainerProps()]
|
||||||
class ERR_SiteStock
|
class ERR_SiteStock
|
||||||
{
|
{
|
||||||
|
// Runtime starting-loadout choice; authored objective stock remains in storage.
|
||||||
|
bool OnGround;
|
||||||
[Attribute("", UIWidgets.ResourceNamePicker, "Physical inventory item", "et")]
|
[Attribute("", UIWidgets.ResourceNamePicker, "Physical inventory item", "et")]
|
||||||
ResourceName Prefab;
|
ResourceName Prefab;
|
||||||
[Attribute("1", UIWidgets.EditBox, "Finite initial count")]
|
[Attribute("1", UIWidgets.EditBox, "Finite initial count")]
|
||||||
@@ -59,7 +61,7 @@ class ERR_SiteDefinition
|
|||||||
ResourceName Prefab;
|
ResourceName Prefab;
|
||||||
[Attribute("0 0 0", UIWidgets.Coords)]
|
[Attribute("0 0 0", UIWidgets.Coords)]
|
||||||
vector Position;
|
vector Position;
|
||||||
[Attribute("0", UIWidgets.CheckBox, "Choose dry clear terrain once per round (prison, radio, mortar, hospital, depot or camp)")]
|
[Attribute("0", UIWidgets.CheckBox, "Choose dry clear terrain once per round (prison, extraction, radio, mortar, hospital, depot or camp)")]
|
||||||
bool RandomClear;
|
bool RandomClear;
|
||||||
[Attribute("0", UIWidgets.EditBox, "Composition heading in degrees")]
|
[Attribute("0", UIWidgets.EditBox, "Composition heading in degrees")]
|
||||||
float Heading;
|
float Heading;
|
||||||
@@ -183,7 +185,7 @@ class ERR_ScenarioDefinition
|
|||||||
if (!site || site.Id.IsEmpty() || ids.Contains(site.Id) || site.Prefab.IsEmpty()) return false;
|
if (!site || site.Id.IsEmpty() || ids.Contains(site.Id) || site.Prefab.IsEmpty()) return false;
|
||||||
if (site.RequireAirfield && site.Kind != ERR_LocationKind.EXTRACTION) return false;
|
if (site.RequireAirfield && site.Kind != ERR_LocationKind.EXTRACTION) return false;
|
||||||
if (site.Kind == ERR_LocationKind.RADIO && !site.Guarded && site.Guards.IsEmpty()) return false;
|
if (site.Kind == ERR_LocationKind.RADIO && !site.Guarded && site.Guards.IsEmpty()) return false;
|
||||||
if (site.RandomClear && site.Kind != ERR_LocationKind.PRISON && site.Kind != ERR_LocationKind.RADIO && site.Kind != ERR_LocationKind.MORTAR && site.Kind != ERR_LocationKind.HOSPITAL && site.Kind != ERR_LocationKind.OUTPOST && site.Kind != ERR_LocationKind.DEPOT) return false;
|
if (site.RandomClear && site.Kind != ERR_LocationKind.EXTRACTION && site.Kind != ERR_LocationKind.PRISON && site.Kind != ERR_LocationKind.RADIO && site.Kind != ERR_LocationKind.MORTAR && site.Kind != ERR_LocationKind.HOSPITAL && site.Kind != ERR_LocationKind.OUTPOST && site.Kind != ERR_LocationKind.DEPOT) return false;
|
||||||
if (site.Label.IsEmpty() || site.Label.Length() > 64) return false;
|
if (site.Label.IsEmpty() || site.Label.Length() > 64) return false;
|
||||||
if (!ERR_SiteDiscoveryRules.ValidRadius(site.Kind, site.DiscoverRadius)) return false;
|
if (!ERR_SiteDiscoveryRules.ValidRadius(site.Kind, site.DiscoverRadius)) return false;
|
||||||
bool optionalSite = site.Kind == ERR_LocationKind.DEPOT || site.Kind == ERR_LocationKind.OUTPOST || site.Kind == ERR_LocationKind.HOSPITAL;
|
bool optionalSite = site.Kind == ERR_LocationKind.DEPOT || site.Kind == ERR_LocationKind.OUTPOST || site.Kind == ERR_LocationKind.HOSPITAL;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ class ERR_StockPlacement
|
|||||||
IEntity Item;
|
IEntity Item;
|
||||||
InventoryStorageManagerComponent Inventory;
|
InventoryStorageManagerComponent Inventory;
|
||||||
bool Accepted;
|
bool Accepted;
|
||||||
|
bool Optional;
|
||||||
|
bool Skipped;
|
||||||
|
bool OnGround;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ERR_SiteRuntime
|
class ERR_SiteRuntime
|
||||||
@@ -387,7 +390,7 @@ class ERR_SiteService
|
|||||||
if (only && spec != only) continue;
|
if (only && spec != only) continue;
|
||||||
if (startupOnly && !ERR_GeneratedSites.StartupSite(spec)) continue;
|
if (startupOnly && !ERR_GeneratedSites.StartupSite(spec)) continue;
|
||||||
vector position = ERR_Actors.Ground(spec.Position);
|
vector position = ERR_Actors.Ground(spec.Position);
|
||||||
if (position[1] < 1) return Fail("site below sea level: " + spec.Id);
|
if (!ERR_Actors.DryGround(position)) return Fail("site ground is submerged or invalid: " + spec.Id);
|
||||||
vector rootPosition = position;
|
vector rootPosition = position;
|
||||||
if (spec.PlacementResolved && spec.Kind == ERR_LocationKind.PRISON) rootPosition = spec.Position;
|
if (spec.PlacementResolved && spec.Kind == ERR_LocationKind.PRISON) rootPosition = spec.Position;
|
||||||
rootPosition[1] = rootPosition[1] + spec.RootHeight;
|
rootPosition[1] = rootPosition[1] + spec.RootHeight;
|
||||||
@@ -395,7 +398,7 @@ class ERR_SiteService
|
|||||||
{
|
{
|
||||||
rootPosition = ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(spec.AircraftOffset, spec.Heading));
|
rootPosition = ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(spec.AircraftOffset, spec.Heading));
|
||||||
if (spec.RequireAirfield && !ERR_AirfieldPlacement.Clear(rootPosition)) return Fail("extraction airfield pad is missing or obstructed; no off-airfield fallback");
|
if (spec.RequireAirfield && !ERR_AirfieldPlacement.Clear(rootPosition)) return Fail("extraction airfield pad is missing or obstructed; no off-airfield fallback");
|
||||||
if (definition.TerrainGenerated && !spec.RequireAirfield && !ERR_AirfieldPlacement.ClearGround(rootPosition)) return Fail("generated extraction landing zone is obstructed");
|
if ((definition.TerrainGenerated || spec.RandomClear) && !spec.RequireAirfield && !ERR_AirfieldPlacement.ClearGround(rootPosition)) return Fail("generated extraction landing zone is obstructed");
|
||||||
}
|
}
|
||||||
// Spawn the replicated marker at the final pickup coordinate from the start.
|
// Spawn the replicated marker at the final pickup coordinate from the start.
|
||||||
IEntity root = ERR_Actors.Spawn(spec.Prefab, rootPosition, Vector(spec.Heading, 0, 0));
|
IEntity root = ERR_Actors.Spawn(spec.Prefab, rootPosition, Vector(spec.Heading, 0, 0));
|
||||||
@@ -428,14 +431,23 @@ class ERR_SiteService
|
|||||||
BaseInventoryStorageComponent storage = BaseInventoryStorageComponent.Cast(site.Container.FindComponent(BaseInventoryStorageComponent));
|
BaseInventoryStorageComponent storage = BaseInventoryStorageComponent.Cast(site.Container.FindComponent(BaseInventoryStorageComponent));
|
||||||
if (!storage) return Fail("container storage: " + spec.Id);
|
if (!storage) return Fail("container storage: " + spec.Id);
|
||||||
inventory.AddStorage(storage);
|
inventory.AddStorage(storage);
|
||||||
if (spec.Stock)
|
array<ref ERR_SiteStock> stockPlan = spec.Stock;
|
||||||
|
bool customStart = spec.Kind == ERR_LocationKind.PRISON && GetGame().ERR_StartingSupplies().Custom();
|
||||||
|
if (customStart)
|
||||||
{
|
{
|
||||||
foreach (ERR_SiteStock stock : spec.Stock)
|
stockPlan = {};
|
||||||
|
// Keep the route's shared map; replace default weapons/ammo with exact selections.
|
||||||
|
ERR_SiteStock mapStock = new ERR_SiteStock(); mapStock.Prefab = ERR_Supplies.Map(); mapStock.Count = 1; stockPlan.Insert(mapStock);
|
||||||
|
GetGame().ERR_StartingSupplies().Stock(stockPlan);
|
||||||
|
}
|
||||||
|
if (stockPlan)
|
||||||
|
{
|
||||||
|
foreach (ERR_SiteStock stock : stockPlan)
|
||||||
{
|
{
|
||||||
ResourceName resource = stock.Prefab;
|
ResourceName resource = stock.Prefab;
|
||||||
if (resource == ERR_Supplies.Map()) resource = fieldMap;
|
if (resource == ERR_Supplies.Map()) resource = fieldMap;
|
||||||
int quantity = stock.Count;
|
int quantity = stock.Count;
|
||||||
if (spec.Kind == ERR_LocationKind.PRISON)
|
if (spec.Kind == ERR_LocationKind.PRISON && !customStart)
|
||||||
{
|
{
|
||||||
if (stock.Prefab == ERR_Supplies.Pistol()) quantity = startWeapons;
|
if (stock.Prefab == ERR_Supplies.Pistol()) quantity = startWeapons;
|
||||||
else if (stock.Prefab == ERR_Supplies.Magazine()) quantity = startMagazines;
|
else if (stock.Prefab == ERR_Supplies.Magazine()) quantity = startMagazines;
|
||||||
@@ -444,6 +456,8 @@ class ERR_SiteService
|
|||||||
{
|
{
|
||||||
// Created exactly once; insertion retries always use this same entity.
|
// Created exactly once; insertion retries always use this same entity.
|
||||||
IEntity item = Spawn(resource, site.Container.GetOrigin());
|
IEntity item = Spawn(resource, site.Container.GetOrigin());
|
||||||
|
if (!item && customStart && stock.Prefab != ERR_Supplies.Map())
|
||||||
|
{ Print("Reintroduced [starting backpack]: unavailable item skipped: " + resource, LogLevel.WARNING); continue; }
|
||||||
if (!item) return Fail("stock resource: " + spec.Id);
|
if (!item) return Fail("stock resource: " + spec.Id);
|
||||||
if (!stock.TargetId.IsEmpty())
|
if (!stock.TargetId.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -459,6 +473,8 @@ class ERR_SiteService
|
|||||||
else if (stock.Prefab == "{B05A816C0BF50802}Prefabs/Weapons/Explosives/Mine_PMN4/Mine_PMN4.et"
|
else if (stock.Prefab == "{B05A816C0BF50802}Prefabs/Weapons/Explosives/Mine_PMN4/Mine_PMN4.et"
|
||||||
&& site.DepotMines.Count() < 2) site.DepotMines.Insert(item);
|
&& site.DepotMines.Count() < 2) site.DepotMines.Insert(item);
|
||||||
}
|
}
|
||||||
|
placement.Optional = customStart && stock.Prefab != ERR_Supplies.Map();
|
||||||
|
placement.OnGround = customStart && stock.OnGround;
|
||||||
placement.Item = item;
|
placement.Item = item;
|
||||||
placement.Inventory = inventory;
|
placement.Inventory = inventory;
|
||||||
m_Placements.Insert(placement);
|
m_Placements.Insert(placement);
|
||||||
@@ -614,6 +630,75 @@ class ERR_SiteService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optional starting items stay usable when native inventory rejects their
|
||||||
|
// dimensions/volume/type. Keep the exact entity; do not spawn copies or delete it.
|
||||||
|
protected void LeaveStartingItem(ERR_StockPlacement placement)
|
||||||
|
{
|
||||||
|
InventoryItemComponent item = InventoryItemComponent.Cast(placement.Item.FindComponent(InventoryItemComponent));
|
||||||
|
// An accepted asynchronous move or an administrator may already own the item.
|
||||||
|
// Never pull it out of another storage while resolving starter overflow.
|
||||||
|
if (!item || !item.GetParentSlot())
|
||||||
|
{
|
||||||
|
vector origin = placement.Inventory.GetOwner().GetOrigin();
|
||||||
|
array<vector> offsets = {"1.2 0 0", "0 0 1.2", "-1.2 0 0", "0 0 -1.2", "0.9 0 0.9", "-0.9 0 0.9", "-0.9 0 -0.9", "0.9 0 -0.9"};
|
||||||
|
foreach (vector offset : offsets)
|
||||||
|
{
|
||||||
|
vector point = ERR_Actors.Ground(origin + offset);
|
||||||
|
if (!ERR_Actors.DryGround(point) || Math.AbsFloat(point[1] - origin[1]) > 0.5 || !BackpackClearance(point)) continue;
|
||||||
|
// Do not place supplies across a cell wall or inside the crash wreckage.
|
||||||
|
TraceParam access = new TraceParam(); access.Start = origin + "0 0.6 0"; access.End = point + "0 0.6 0";
|
||||||
|
access.Flags = TraceFlags.ENTS | TraceFlags.WORLD; access.Exclude = placement.Inventory.GetOwner();
|
||||||
|
if (GetGame().GetWorld().TraceMove(access, null) < 1) continue;
|
||||||
|
placement.Item.SetOrigin(point + "0 0.2 0");
|
||||||
|
Physics physics = placement.Item.GetPhysics();
|
||||||
|
if (physics && physics.IsDynamic()) physics.SetActive(ActiveState.ACTIVE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string resource = "unknown item";
|
||||||
|
if (placement.Item.GetPrefabData()) resource = placement.Item.GetPrefabData().GetPrefabName();
|
||||||
|
if (!placement.OnGround) Print("Reintroduced [starting backpack]: inventory rejected item; retained as starting-area loot: " + resource, LogLevel.WARNING);
|
||||||
|
placement.Skipped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ERR_PrepareResult PrepareStock()
|
||||||
|
{
|
||||||
|
int pending, accepted;
|
||||||
|
string firstRejected;
|
||||||
|
foreach (ERR_StockPlacement placement : m_Placements)
|
||||||
|
{
|
||||||
|
if (placement.Skipped) continue;
|
||||||
|
if (!placement.Item || !placement.Inventory)
|
||||||
|
{
|
||||||
|
if (placement.Optional) { placement.Skipped = true; Print("Reintroduced [starting backpack]: optional item disappeared before insertion", LogLevel.WARNING); continue; }
|
||||||
|
Fail("stock disappeared during initialization"); return ERR_PrepareResult.FAILED;
|
||||||
|
}
|
||||||
|
if (placement.OnGround) { LeaveStartingItem(placement); continue; }
|
||||||
|
array<IEntity> items = {};
|
||||||
|
placement.Inventory.GetItems(items);
|
||||||
|
if (items.Contains(placement.Item)) continue;
|
||||||
|
bool expired = GetGame().GetWorld().GetWorldTime() > m_Deadline;
|
||||||
|
if (placement.Optional && (expired || (!placement.Accepted && !placement.Inventory.CanInsertItem(placement.Item))))
|
||||||
|
{
|
||||||
|
LeaveStartingItem(placement); continue;
|
||||||
|
}
|
||||||
|
pending++;
|
||||||
|
if (firstRejected.IsEmpty() && placement.Item.GetPrefabData()) firstRejected = placement.Item.GetPrefabData().GetPrefabName();
|
||||||
|
if (placement.Accepted) accepted++;
|
||||||
|
if (!placement.Accepted) placement.Accepted = placement.Inventory.TryInsertItem(placement.Item);
|
||||||
|
}
|
||||||
|
if (pending)
|
||||||
|
{
|
||||||
|
if (GetGame().GetWorld().GetWorldTime() > m_Deadline)
|
||||||
|
{
|
||||||
|
Fail(string.Format("physical stock insertion timed out: pending=%1 accepted=%2 sample=%3", pending, accepted, firstRejected));
|
||||||
|
return ERR_PrepareResult.FAILED;
|
||||||
|
}
|
||||||
|
return ERR_PrepareResult.PENDING;
|
||||||
|
}
|
||||||
|
return ERR_PrepareResult.READY;
|
||||||
|
}
|
||||||
|
|
||||||
ERR_PrepareResult Prepare()
|
ERR_PrepareResult Prepare()
|
||||||
{
|
{
|
||||||
if (!Replication.IsServer() || !m_Begun || m_Stopped) return ERR_PrepareResult.FAILED;
|
if (!Replication.IsServer() || !m_Begun || m_Stopped) return ERR_PrepareResult.FAILED;
|
||||||
@@ -622,7 +707,7 @@ class ERR_SiteService
|
|||||||
ERR_PrepareResult aircraftPlacement = ERR_PrepareResult.READY;
|
ERR_PrepareResult aircraftPlacement = ERR_PrepareResult.READY;
|
||||||
if (m_ExtractionPlacement) aircraftPlacement = m_ExtractionPlacement.Poll(GetGame().GetWorld().GetWorldTime());
|
if (m_ExtractionPlacement) aircraftPlacement = m_ExtractionPlacement.Poll(GetGame().GetWorld().GetWorldTime());
|
||||||
if (aircraftPlacement == ERR_PrepareResult.FAILED) { Fail(m_ExtractionPlacement.FailureReason()); return m_State; }
|
if (aircraftPlacement == ERR_PrepareResult.FAILED) { Fail(m_ExtractionPlacement.FailureReason()); return m_State; }
|
||||||
int pending, accepted, pendingGuards;
|
int pendingGuards;
|
||||||
foreach (ERR_SiteRuntime site : m_Sites)
|
foreach (ERR_SiteRuntime site : m_Sites)
|
||||||
{
|
{
|
||||||
if (site.Definition.Transport && !site.Definition.Transport.Optional && !TransportReady(site))
|
if (site.Definition.Transport && !site.Definition.Transport.Optional && !TransportReady(site))
|
||||||
@@ -640,23 +725,7 @@ class ERR_SiteService
|
|||||||
if (mobile == ERR_PrepareResult.PENDING) pendingGuards++;
|
if (mobile == ERR_PrepareResult.PENDING) pendingGuards++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string firstRejected;
|
if (PrepareStock() != ERR_PrepareResult.READY) return m_State;
|
||||||
foreach (ERR_StockPlacement placement : m_Placements)
|
|
||||||
{
|
|
||||||
if (!placement.Item || !placement.Inventory) { Fail("stock disappeared during initialization"); return m_State; }
|
|
||||||
array<IEntity> items = {};
|
|
||||||
placement.Inventory.GetItems(items);
|
|
||||||
if (items.Contains(placement.Item)) continue;
|
|
||||||
pending++;
|
|
||||||
if (firstRejected.IsEmpty() && placement.Item.GetPrefabData()) firstRejected = placement.Item.GetPrefabData().GetPrefabName();
|
|
||||||
if (placement.Accepted) accepted++;
|
|
||||||
if (!placement.Accepted) placement.Accepted = placement.Inventory.TryInsertItem(placement.Item);
|
|
||||||
}
|
|
||||||
if (pending)
|
|
||||||
{
|
|
||||||
if (GetGame().GetWorld().GetWorldTime() > m_Deadline) Fail(string.Format("physical stock insertion timed out: pending=%1 accepted=%2 sample=%3", pending, accepted, firstRejected));
|
|
||||||
return m_State;
|
|
||||||
}
|
|
||||||
if (pendingGuards > 0 || aircraftPlacement == ERR_PrepareResult.PENDING) return m_State;
|
if (pendingGuards > 0 || aircraftPlacement == ERR_PrepareResult.PENDING) return m_State;
|
||||||
// All required scenery, stock and physical guards now exist. Survey optional
|
// All required scenery, stock and physical guards now exist. Survey optional
|
||||||
// parking once against that real population, then bound only vehicle settling.
|
// parking once against that real population, then bound only vehicle settling.
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ class ERR_SpawnLogic : SCR_SpawnLogic
|
|||||||
ERR_GameMode mode = ERR_GameMode.Get();
|
ERR_GameMode mode = ERR_GameMode.Get();
|
||||||
if (mode)
|
if (mode)
|
||||||
{
|
{
|
||||||
|
mode.ObservePlayerDisconnect();
|
||||||
mode.InitialAdmissionStarted(playerId);
|
mode.InitialAdmissionStarted(playerId);
|
||||||
mode.Players().Disconnect(playerId);
|
mode.Players().Disconnect(playerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ class ERR_SpawnPlacement
|
|||||||
foreach (int id, vector reserved : reservations)
|
foreach (int id, vector reserved : reservations)
|
||||||
if (id != ownReservation && vector.DistanceXZ(position, reserved) < 1.2 && Math.AbsFloat(position[1] - reserved[1]) < 2) return false;
|
if (id != ownReservation && vector.DistanceXZ(position, reserved) < 1.2 && Math.AbsFloat(position[1] - reserved[1]) < 2) return false;
|
||||||
vector ground = ERR_Actors.Ground(position);
|
vector ground = ERR_Actors.Ground(position);
|
||||||
if (ground[1] < 1 || Math.AbsFloat(position[1] - ground[1]) > 0.3) return false;
|
if (!ERR_Actors.DryGround(ground) || Math.AbsFloat(position[1] - ground[1]) > 0.3) return false;
|
||||||
// Feet need supported, reasonably level terrain across the character width.
|
// Feet need supported, reasonably level terrain across the character width.
|
||||||
for (int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for (int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
{
|
{
|
||||||
vector sample = ERR_Actors.Ground(position + Vector(x * 0.45, 0, z * 0.45));
|
vector sample = ERR_Actors.Ground(position + Vector(x * 0.45, 0, z * 0.45));
|
||||||
if (Math.AbsFloat(sample[1] - ground[1]) > 0.3) return false;
|
if (!ERR_Actors.DryGround(sample) || Math.AbsFloat(sample[1] - ground[1]) > 0.3) return false;
|
||||||
}
|
}
|
||||||
m_Exclude = exclude;
|
m_Exclude = exclude;
|
||||||
m_Candidate = ground; m_Blocked = false;
|
m_Candidate = ground; m_Blocked = false;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ modded class ERR_AdminSession
|
|||||||
if (!service) { SpeechReply("Speech service is unavailable in this mission."); return; }
|
if (!service) { SpeechReply("Speech service is unavailable in this mission."); return; }
|
||||||
if (action == 0) service.TestAndEnable(this, endpoint, secret);
|
if (action == 0) service.TestAndEnable(this, endpoint, secret);
|
||||||
else if (action == 1) service.Disable(this);
|
else if (action == 1) service.Disable(this);
|
||||||
|
else if (action == 2) service.SetRecordings(this, true);
|
||||||
|
else if (action == 3) service.SetRecordings(this, false);
|
||||||
}
|
}
|
||||||
void SpeechReply(string text)
|
void SpeechReply(string text)
|
||||||
{
|
{
|
||||||
@@ -53,10 +55,11 @@ modded class ERR_AdminMenu
|
|||||||
protected bool m_SpeechBusy;
|
protected bool m_SpeechBusy;
|
||||||
protected bool m_SpeechEnabled;
|
protected bool m_SpeechEnabled;
|
||||||
protected int m_SpeechSelection = -1;
|
protected int m_SpeechSelection = -1;
|
||||||
|
protected int m_RecordingsSelection = -1;
|
||||||
override void OnMenuOpen()
|
override void OnMenuOpen()
|
||||||
{
|
{
|
||||||
super.OnMenuOpen();
|
super.OnMenuOpen();
|
||||||
foreach (string name : {"TTSTest", "TTSDisable", "TTSPasteEndpoint", "TTSPasteToken"})
|
foreach (string name : {"TTSTest", "TTSDisable", "TTSPasteEndpoint", "TTSPasteToken", "RecordingsOn", "RecordingsOff"})
|
||||||
{
|
{
|
||||||
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
||||||
if (!button) { Close(); return; }
|
if (!button) { Close(); return; }
|
||||||
@@ -95,9 +98,12 @@ modded class ERR_AdminMenu
|
|||||||
super.UpdateActions();
|
super.UpdateActions();
|
||||||
bool ready = m_Ready && m_SpeechInitialized;
|
bool ready = m_Ready && m_SpeechInitialized;
|
||||||
ERR_SelectionStyle.Pair(GetRootWidget(), "TTSTest", "TTSDisable", m_SpeechSelection);
|
ERR_SelectionStyle.Pair(GetRootWidget(), "TTSTest", "TTSDisable", m_SpeechSelection);
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "RecordingsOn", "RecordingsOff", m_RecordingsSelection);
|
||||||
foreach (SCR_ButtonTextComponent button : m_SpeechButtons)
|
foreach (SCR_ButtonTextComponent button : m_SpeechButtons)
|
||||||
{
|
{
|
||||||
bool enabled = ready && !m_SpeechBusy;
|
bool enabled = ready && !m_SpeechBusy;
|
||||||
|
string name = button.GetRootWidget().GetName();
|
||||||
|
if (name == "RecordingsOn" || name == "RecordingsOff") enabled = ready;
|
||||||
if (button.GetRootWidget().GetName() == "TTSDisable") enabled = ready && (m_SpeechEnabled || m_SpeechBusy);
|
if (button.GetRootWidget().GetName() == "TTSDisable") enabled = ready && (m_SpeechEnabled || m_SpeechBusy);
|
||||||
button.SetEnabled(enabled);
|
button.SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
@@ -111,12 +117,13 @@ modded class ERR_AdminMenu
|
|||||||
override void ReceiveSnapshot(bool authorized, array<string> values, array<string> status)
|
override void ReceiveSnapshot(bool authorized, array<string> values, array<string> status)
|
||||||
{
|
{
|
||||||
string endpoint, message, tokenSaved; bool ready, present;
|
string endpoint, message, tokenSaved; bool ready, present;
|
||||||
m_SpeechBusy = false; m_SpeechEnabled = false;
|
m_SpeechBusy = false; m_SpeechEnabled = false; m_RecordingsSelection = -1;
|
||||||
if (authorized && values)
|
if (authorized && values)
|
||||||
foreach (string entry : values)
|
foreach (string entry : values)
|
||||||
{
|
{
|
||||||
int divider = entry.IndexOf("="); if (divider < 0) continue;
|
int divider = entry.IndexOf("="); if (divider < 0) continue;
|
||||||
string key = entry.Substring(0, divider), value = entry.Substring(divider + 1, entry.Length() - divider - 1);
|
string key = entry.Substring(0, divider), value = entry.Substring(divider + 1, entry.Length() - divider - 1);
|
||||||
|
if (key == "recordingsEnabled") { m_RecordingsSelection = 0; if (value == "1") m_RecordingsSelection = 1; }
|
||||||
if (key == "ttsUrl") { endpoint = value; present = true; }
|
if (key == "ttsUrl") { endpoint = value; present = true; }
|
||||||
if (key == "ttsStatus") message = value;
|
if (key == "ttsStatus") message = value;
|
||||||
if (key == "ttsTokenSaved") tokenSaved = value;
|
if (key == "ttsTokenSaved") tokenSaved = value;
|
||||||
@@ -152,8 +159,16 @@ modded class ERR_AdminMenu
|
|||||||
if (!m_SpeechBusy) PasteSpeechField(name == "TTSPasteToken");
|
if (!m_SpeechBusy) PasteSpeechField(name == "TTSPasteToken");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (name == "RecordingsOn" || name == "RecordingsOff")
|
||||||
|
{
|
||||||
|
int recordingsAction = 3; if (name == "RecordingsOn") recordingsAction = 2;
|
||||||
|
m_ClickDelay = 0.3;
|
||||||
|
SetText("Feedback", "Saving prerecorded speech setting...");
|
||||||
|
m_Controller.ERR_AdminSpeech(recordingsAction, "", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
int action;
|
int action;
|
||||||
if (button.GetRootWidget().GetName() == "TTSDisable") action = 1;
|
if (name == "TTSDisable") action = 1;
|
||||||
SCR_EditBoxComponent endpoint = SCR_EditBoxComponent.GetEditBoxComponent("TTSEndpoint", GetRootWidget());
|
SCR_EditBoxComponent endpoint = SCR_EditBoxComponent.GetEditBoxComponent("TTSEndpoint", GetRootWidget());
|
||||||
SCR_EditBoxComponent token = SCR_EditBoxComponent.GetEditBoxComponent("TTSToken", GetRootWidget());
|
SCR_EditBoxComponent token = SCR_EditBoxComponent.GetEditBoxComponent("TTSToken", GetRootWidget());
|
||||||
if (!endpoint || !token) return;
|
if (!endpoint || !token) return;
|
||||||
|
|||||||
@@ -77,10 +77,11 @@ class ERR_SpeechService
|
|||||||
protected string m_Endpoint;
|
protected string m_Endpoint;
|
||||||
protected string m_Token;
|
protected string m_Token;
|
||||||
protected bool m_Enabled;
|
protected bool m_Enabled;
|
||||||
|
protected bool m_Bundled = true;
|
||||||
protected bool m_Ready;
|
protected bool m_Ready;
|
||||||
protected bool m_BootAttempted;
|
protected bool m_BootAttempted;
|
||||||
protected bool m_Stopped;
|
protected bool m_Stopped;
|
||||||
protected string m_Status = "Not configured. Existing audio is unchanged.";
|
protected string m_Status = "Bundled recordings are available. Live speech is not configured.";
|
||||||
protected ref ERR_SpeechRequest m_Request;
|
protected ref ERR_SpeechRequest m_Request;
|
||||||
protected float m_Deadline;
|
protected float m_Deadline;
|
||||||
protected float m_LastTest = -60000;
|
protected float m_LastTest = -60000;
|
||||||
@@ -88,6 +89,7 @@ class ERR_SpeechService
|
|||||||
protected string m_StaticURL;
|
protected string m_StaticURL;
|
||||||
string CacheNamespace() { return m_Endpoint; }
|
string CacheNamespace() { return m_Endpoint; }
|
||||||
string StaticURL() { return m_StaticURL; }
|
string StaticURL() { return m_StaticURL; }
|
||||||
|
bool Bundled() { return m_Bundled; }
|
||||||
bool Ready() { return !m_Stopped && m_Enabled && m_Ready; }
|
bool Ready() { return !m_Stopped && m_Enabled && m_Ready; }
|
||||||
bool Busy() { return m_Request != null; }
|
bool Busy() { return m_Request != null; }
|
||||||
bool IdleFor(float milliseconds)
|
bool IdleFor(float milliseconds)
|
||||||
@@ -109,7 +111,12 @@ class ERR_SpeechService
|
|||||||
if (ERR_SpeechRules.Token(token)) m_Token = token;
|
if (ERR_SpeechRules.Token(token)) m_Token = token;
|
||||||
m_Enabled = !m_Endpoint.IsEmpty() && !m_Token.IsEmpty();
|
m_Enabled = !m_Endpoint.IsEmpty() && !m_Token.IsEmpty();
|
||||||
json.ReadValue("ttsEnabled", m_Enabled);
|
json.ReadValue("ttsEnabled", m_Enabled);
|
||||||
if (m_Enabled) m_Status = "Configured; waiting to verify the speech service. Existing audio remains available.";
|
json.ReadValue("bundledSpeech", m_Bundled);
|
||||||
|
bool recordingsEnabled = true;
|
||||||
|
json.ReadValue("recordingsEnabled", recordingsEnabled);
|
||||||
|
m_Mode.ERR_SetRecordingsEnabled(recordingsEnabled);
|
||||||
|
if (m_Bundled) m_Status = "Prerecorded welcome selected. Test & enable to use a live welcome briefing.";
|
||||||
|
else if (m_Enabled) m_Status = "Live welcome configured; waiting to verify the speech service.";
|
||||||
else if (!m_Endpoint.IsEmpty()) m_Status = "Disabled. Existing audio is unchanged.";
|
else if (!m_Endpoint.IsEmpty()) m_Status = "Disabled. Existing audio is unchanged.";
|
||||||
}
|
}
|
||||||
void Snapshot(array<string> values)
|
void Snapshot(array<string> values)
|
||||||
@@ -123,23 +130,37 @@ class ERR_SpeechService
|
|||||||
values.Insert("ttsTokenSaved=" + saved); values.Insert("ttsReady=" + ready);
|
values.Insert("ttsTokenSaved=" + saved); values.Insert("ttsReady=" + ready);
|
||||||
values.Insert("ttsBusy=" + busy); values.Insert("ttsEnabled=" + enabled);
|
values.Insert("ttsBusy=" + busy); values.Insert("ttsEnabled=" + enabled);
|
||||||
values.Insert("ttsStatus=" + m_Status);
|
values.Insert("ttsStatus=" + m_Status);
|
||||||
|
string recordings = "0"; if (m_Mode.ERR_RecordingsEnabled()) recordings = "1";
|
||||||
|
values.Insert("recordingsEnabled=" + recordings);
|
||||||
}
|
}
|
||||||
protected bool Save(string endpoint, string token, bool enabled)
|
protected bool Save(string endpoint, string token, bool enabled, bool recordingsEnabled, bool preserveWelcome = false)
|
||||||
{
|
{
|
||||||
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
||||||
json.WriteValue("welcomeUrl", m_StaticURL); json.WriteValue("briefingUrl", endpoint);
|
json.WriteValue("welcomeUrl", m_StaticURL); json.WriteValue("briefingUrl", endpoint);
|
||||||
json.WriteValue("briefingToken", token); json.WriteValue("ttsEnabled", enabled);
|
json.WriteValue("briefingToken", token); json.WriteValue("ttsEnabled", enabled);
|
||||||
|
bool bundled = !enabled; if (preserveWelcome) bundled = m_Bundled;
|
||||||
|
json.WriteValue("bundledSpeech", bundled);
|
||||||
|
json.WriteValue("recordingsEnabled", recordingsEnabled);
|
||||||
return ERR_ProfileConfig.Save(ERR_ProfileConfig.VOICE, json);
|
return ERR_ProfileConfig.Save(ERR_ProfileConfig.VOICE, json);
|
||||||
}
|
}
|
||||||
|
void SetRecordings(ERR_AdminSession editor, bool enabled)
|
||||||
|
{
|
||||||
|
if (!Current() || !editor || !editor.Valid()) return;
|
||||||
|
if (!Save(m_Endpoint, m_Token, m_Enabled, enabled, true))
|
||||||
|
{ editor.SpeechReply("Could not save. Previous speech settings retained."); return; }
|
||||||
|
m_Mode.ERR_SetRecordingsEnabled(enabled);
|
||||||
|
if (enabled) editor.SpeechReply("Prerecorded speech enabled for everyone.");
|
||||||
|
else editor.SpeechReply("Prerecorded speech disabled for everyone. Text messages remain visible.");
|
||||||
|
}
|
||||||
void Disable(ERR_AdminSession editor)
|
void Disable(ERR_AdminSession editor)
|
||||||
{
|
{
|
||||||
if (!Current() || !editor || !editor.Valid()) return;
|
if (!Current() || !editor || !editor.Valid()) return;
|
||||||
if (!Save(m_Endpoint, m_Token, false)) { editor.SpeechReply("Could not save. Previous speech settings retained."); return; }
|
if (!Save(m_Endpoint, m_Token, false, m_Mode.ERR_RecordingsEnabled())) { editor.SpeechReply("Could not save. Previous speech settings retained."); return; }
|
||||||
if (m_Request) m_Request.Cancel();
|
if (m_Request) m_Request.Cancel();
|
||||||
m_Request = null; m_Enabled = false; m_Ready = false; m_BootAttempted = false;
|
m_Request = null; m_Enabled = false; m_Bundled = true; m_Ready = false; m_BootAttempted = false;
|
||||||
m_Status = "Disabled. Existing audio is unchanged.";
|
m_Status = "Live TTS disabled. Prerecorded speech follows its On / Off setting.";
|
||||||
m_Mode.ERR_RestoreStaticWelcome();
|
m_Mode.ERR_RestoreStaticWelcome();
|
||||||
editor.SpeechReply("TTS disabled. The original welcome remains available.");
|
editor.SpeechReply("Live TTS disabled. Prerecorded speech follows its On / Off setting.");
|
||||||
}
|
}
|
||||||
void TestAndEnable(ERR_AdminSession editor, string endpoint, string token)
|
void TestAndEnable(ERR_AdminSession editor, string endpoint, string token)
|
||||||
{
|
{
|
||||||
@@ -188,6 +209,7 @@ class ERR_SpeechService
|
|||||||
ERR_SpeechRequest expired = m_Request;
|
ERR_SpeechRequest expired = m_Request;
|
||||||
Finished(expired, ""); expired.Cancel();
|
Finished(expired, ""); expired.Cancel();
|
||||||
}
|
}
|
||||||
|
if (m_Mode.ERR_UsesBundledWelcome()) return;
|
||||||
if (Busy() || !m_Enabled || m_BootAttempted || !m_Mode.Active() || !ERR_WelcomeVoiceRules.HTTPReady()) return;
|
if (Busy() || !m_Enabled || m_BootAttempted || !m_Mode.Active() || !ERR_WelcomeVoiceRules.HTTPReady()) return;
|
||||||
m_BootAttempted = true;
|
m_BootAttempted = true;
|
||||||
if (m_Endpoint.IsEmpty() || m_Token.IsEmpty()) { m_Status = "Incomplete settings. Existing audio is unchanged."; return; }
|
if (m_Endpoint.IsEmpty() || m_Token.IsEmpty()) { m_Status = "Incomplete settings. Existing audio is unchanged."; return; }
|
||||||
@@ -213,9 +235,9 @@ class ERR_SpeechService
|
|||||||
}
|
}
|
||||||
if (request.Enable)
|
if (request.Enable)
|
||||||
{
|
{
|
||||||
if (!Save(request.Endpoint, request.Token, true))
|
if (!Save(request.Endpoint, request.Token, true, m_Mode.ERR_RecordingsEnabled()))
|
||||||
{ m_Status = "Test passed, but settings could not be saved. Previous settings retained."; request.Editor.SpeechReply(m_Status); return; }
|
{ m_Status = "Test passed, but settings could not be saved. Previous settings retained."; request.Editor.SpeechReply(m_Status); return; }
|
||||||
m_Endpoint = request.Endpoint; m_Token = request.Token; m_Enabled = true; m_BootAttempted = true;
|
m_Endpoint = request.Endpoint; m_Token = request.Token; m_Enabled = true; m_Bundled = false; m_BootAttempted = true;
|
||||||
}
|
}
|
||||||
m_Ready = true; m_Status = "Enabled. Speech generation verified; repeated text uses the service cache.";
|
m_Ready = true; m_Status = "Enabled. Speech generation verified; repeated text uses the service cache.";
|
||||||
if (request.Enable || request.Boot) m_Mode.ERR_PublishWelcome(url, request.Text);
|
if (request.Enable || request.Boot) m_Mode.ERR_PublishWelcome(url, request.Text);
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
// Exact, finite shared starting supplies. Edits affect the next preparation only.
|
||||||
|
class ERR_StartBackpack
|
||||||
|
{
|
||||||
|
static const string PATH = "$profile:EscapistsStartBackpack.json";
|
||||||
|
protected ref array<string> m_Records = {"default"};
|
||||||
|
protected bool m_ReadOnly;
|
||||||
|
void ERR_StartBackpack()
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer()) { m_ReadOnly = true; return; }
|
||||||
|
array<string> loaded;
|
||||||
|
if (Read(PATH, loaded) || Read(PATH + ".bak", loaded)) m_Records = loaded;
|
||||||
|
else if (ERR_ProfileConfig.Exists(PATH) || ERR_ProfileConfig.Exists(PATH + ".bak")) m_ReadOnly = true;
|
||||||
|
}
|
||||||
|
static string Destination(array<string> parts)
|
||||||
|
{
|
||||||
|
if (parts.Count() == 3) return parts[2];
|
||||||
|
return "backpack";
|
||||||
|
}
|
||||||
|
static bool Valid(array<string> records)
|
||||||
|
{
|
||||||
|
if (!records || records.IsEmpty() || records.Count() > 33) return false;
|
||||||
|
if (records[0] != "default" && records[0] != "custom") return false;
|
||||||
|
set<string> seen = new set<string>(); int total;
|
||||||
|
for (int i = 1; i < records.Count(); i++)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; records[i].Split("|", parts, false);
|
||||||
|
if ((parts.Count() != 2 && parts.Count() != 3) || parts[0].Length() > 512 || !parts[0].EndsWith(".et")) return false;
|
||||||
|
string key = ERR_TerrainCatalog.Key(parts[0]); int count;
|
||||||
|
string destination = Destination(parts);
|
||||||
|
if (destination != "backpack" && destination != "ground") return false;
|
||||||
|
if (!ERR_ItemPreferences.Guid(key) || seen.Contains(key + "|" + destination)) return false;
|
||||||
|
if (!ERR_CommandArguments.Integer(parts[1], count) || count < 1 || count > 48) return false;
|
||||||
|
total += count; if (total > 64) return false;
|
||||||
|
seen.Insert(key + "|" + destination);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
static bool Parse(JsonLoadContext json, out array<string> records)
|
||||||
|
{
|
||||||
|
int version; records = {};
|
||||||
|
return json.ReadValue("version", version) && (version == 1 || version == 2) && json.ReadValue("records", records) && Valid(records);
|
||||||
|
}
|
||||||
|
protected bool Read(string path, out array<string> records)
|
||||||
|
{
|
||||||
|
JsonLoadContext json = new JsonLoadContext();
|
||||||
|
return ERR_ProfileConfig.Load(path, json) && Parse(json, records);
|
||||||
|
}
|
||||||
|
protected bool Save(array<string> records)
|
||||||
|
{
|
||||||
|
if (!Replication.IsServer() || m_ReadOnly || !Valid(records)) return false;
|
||||||
|
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
||||||
|
json.WriteValue("version", 2); json.WriteValue("records", records);
|
||||||
|
if (!ERR_ProfileConfig.Save(PATH, json)) return false;
|
||||||
|
m_Records = records; return true;
|
||||||
|
}
|
||||||
|
bool Custom() { return m_Records[0] == "custom"; }
|
||||||
|
bool SetMode(bool custom)
|
||||||
|
{
|
||||||
|
array<string> next = {}; next.Copy(m_Records);
|
||||||
|
next[0] = "default"; if (custom) next[0] = "custom";
|
||||||
|
return Save(next);
|
||||||
|
}
|
||||||
|
bool Set(ResourceName prefab, int quantity, string destination = "backpack")
|
||||||
|
{
|
||||||
|
if (quantity < 0 || quantity > 48 || (destination != "backpack" && destination != "ground")) return false;
|
||||||
|
string key = ERR_TerrainCatalog.Key(prefab);
|
||||||
|
if (!ERR_ItemPreferences.Guid(key)) return false;
|
||||||
|
array<string> next = {m_Records[0]};
|
||||||
|
for (int i = 1; i < m_Records.Count(); i++)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; m_Records[i].Split("|", parts, false);
|
||||||
|
if (ERR_TerrainCatalog.Key(parts[0]) != key || Destination(parts) != destination) next.Insert(m_Records[i]);
|
||||||
|
}
|
||||||
|
if (quantity > 0) next.Insert(prefab + "|" + quantity.ToString() + "|" + destination);
|
||||||
|
return Save(next);
|
||||||
|
}
|
||||||
|
bool Remove(string key, string destination = "backpack")
|
||||||
|
{
|
||||||
|
for (int i = 1; i < m_Records.Count(); i++)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; m_Records[i].Split("|", parts, false);
|
||||||
|
if (ERR_TerrainCatalog.Key(parts[0]) == key && Destination(parts) == destination) return Set(parts[0], 0, destination);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void Stock(array<ref ERR_SiteStock> stock)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < m_Records.Count(); i++)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; m_Records[i].Split("|", parts, false);
|
||||||
|
ERR_SiteStock item = new ERR_SiteStock(); item.Prefab = parts[0]; item.Count = parts[1].ToInt(); item.OnGround = Destination(parts) == "ground"; stock.Insert(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Snapshot(array<string> values)
|
||||||
|
{
|
||||||
|
values.Insert("starterMode=" + m_Records[0]);
|
||||||
|
string state = "Saved for next round. The shared field map is always included. Oversized items are left nearby. Add matching magazines separately.";
|
||||||
|
if (m_ReadOnly) state = "Read-only: starting backpack configuration needs repair.";
|
||||||
|
values.Insert("starterState=" + state);
|
||||||
|
for (int i = 1; i < m_Records.Count(); i++)
|
||||||
|
{
|
||||||
|
array<string> parts = {}; m_Records[i].Split("|", parts, false);
|
||||||
|
string key = ERR_TerrainCatalog.Key(parts[0]);
|
||||||
|
ERR_ServerItem item = GetGame().ERR_ServerItems().Item(key);
|
||||||
|
string label = FilePath.StripPath(parts[0]); if (item) label = item.Label;
|
||||||
|
values.Insert("starterItem=" + key + "|" + ERR_ServerItemCatalog.Clean(label) + "|" + parts[1] + "|" + Destination(parts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modded class ArmaReforgerScripted
|
||||||
|
{
|
||||||
|
protected ref ERR_StartBackpack m_ERRStartBackpack;
|
||||||
|
ERR_StartBackpack ERR_StartingSupplies()
|
||||||
|
{
|
||||||
|
if (!m_ERRStartBackpack) m_ERRStartBackpack = new ERR_StartBackpack();
|
||||||
|
return m_ERRStartBackpack;
|
||||||
|
}
|
||||||
|
override protected void OnBeforeWorldCleanup()
|
||||||
|
{
|
||||||
|
m_ERRStartBackpack = null; super.OnBeforeWorldCleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// Catalog choices come from the authenticated session, not client prefab paths.
|
||||||
|
modded class ERR_AdminMenu
|
||||||
|
{
|
||||||
|
protected ref array<SCR_ButtonTextComponent> m_StarterButtons = {};
|
||||||
|
protected ref array<string> m_StarterMods = {}, m_StarterCatalog = {}, m_StarterSaved = {};
|
||||||
|
protected string m_StarterCatalogSignature, m_StarterSavedSignature, m_StarterAddon;
|
||||||
|
protected int m_StarterMode = -1;
|
||||||
|
override void OnMenuOpen()
|
||||||
|
{
|
||||||
|
super.OnMenuOpen();
|
||||||
|
foreach (string name : {"StarterDefault", "StarterCustom", "StarterShow", "StarterPrevious", "StarterNext", "StarterAdd", "StarterRemove"})
|
||||||
|
{
|
||||||
|
SCR_ButtonTextComponent button = SCR_ButtonTextComponent.GetButtonText(name, GetRootWidget());
|
||||||
|
if (!button) { Close(); return; }
|
||||||
|
button.m_OnClicked.Insert(OnStarterButton); m_StarterButtons.Insert(button);
|
||||||
|
}
|
||||||
|
SCR_EditBoxComponent.GetEditBoxComponent("StarterQuantity", GetRootWidget()).SetValue("1");
|
||||||
|
SCR_ComboBoxComponent destination = SCR_ComboBoxComponent.GetComboBoxComponent("StarterDestination", GetRootWidget());
|
||||||
|
destination.ClearAll(); destination.AddItem("Inside backpack"); destination.AddItem("On ground beside backpack");
|
||||||
|
destination.SetCurrentItem(0, false, false, false);
|
||||||
|
UpdateActions();
|
||||||
|
}
|
||||||
|
override void OnMenuClose()
|
||||||
|
{
|
||||||
|
foreach (SCR_ButtonTextComponent button : m_StarterButtons) if (button) button.m_OnClicked.Remove(OnStarterButton);
|
||||||
|
m_StarterButtons.Clear(); m_StarterMods.Clear(); m_StarterCatalog.Clear(); m_StarterSaved.Clear();
|
||||||
|
super.OnMenuClose();
|
||||||
|
}
|
||||||
|
protected override void UpdateActions()
|
||||||
|
{
|
||||||
|
super.UpdateActions();
|
||||||
|
ERR_SelectionStyle.Pair(GetRootWidget(), "StarterCustom", "StarterDefault", m_StarterMode);
|
||||||
|
foreach (SCR_ButtonTextComponent button : m_StarterButtons)
|
||||||
|
{
|
||||||
|
string name = button.GetRootWidget().GetName();
|
||||||
|
bool enabled = m_Ready && m_StarterMode >= 0;
|
||||||
|
if (name == "StarterDefault") enabled = enabled && m_StarterMode == 1;
|
||||||
|
if (name == "StarterCustom") enabled = enabled && m_StarterMode == 0;
|
||||||
|
if (name == "StarterShow") enabled = enabled && !m_StarterMods.IsEmpty();
|
||||||
|
if (name == "StarterAdd") enabled = enabled && !m_StarterCatalog.IsEmpty();
|
||||||
|
if (name == "StarterRemove") enabled = enabled && !m_StarterSaved.IsEmpty();
|
||||||
|
if (name == "StarterPrevious") enabled = enabled && !m_StarterAddon.IsEmpty() && m_ShownItemPage > 0;
|
||||||
|
if (name == "StarterNext") enabled = enabled && !m_StarterAddon.IsEmpty() && m_ShownItemPage < m_LastItemPage;
|
||||||
|
button.SetEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Preserve selection across polls and only rebuild a dropdown when its data changes.
|
||||||
|
protected void StarterCombo(string name, array<string> keys, array<string> labels, array<string> previous)
|
||||||
|
{
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent(name, GetRootWidget());
|
||||||
|
if (!combo) return;
|
||||||
|
int index = combo.GetCurrentIndex(); string selected;
|
||||||
|
if (index >= 0 && index < previous.Count()) selected = previous[index];
|
||||||
|
combo.ClearAll(); foreach (string label : labels) combo.AddItem(WidgetManager.Translate(label));
|
||||||
|
combo.SetCurrentItem(Math.Max(0, keys.Find(selected)), false, false, false);
|
||||||
|
previous.Copy(keys);
|
||||||
|
}
|
||||||
|
override void ReceiveSnapshot(bool authorized, array<string> values, array<string> status)
|
||||||
|
{
|
||||||
|
super.ReceiveSnapshot(authorized, values, status);
|
||||||
|
if (!authorized || !values) return;
|
||||||
|
if (m_StarterMods.Count() != m_ServerAddonKeys.Count()) StarterCombo("StarterMod", m_ServerAddonKeys, m_ServerAddonLabels, m_StarterMods);
|
||||||
|
array<string> catalogKeys = {}, catalogLabels = {}, savedKeys = {}, savedLabels = {};
|
||||||
|
string catalogSignature = m_ShownItemAddon, savedSignature;
|
||||||
|
int total;
|
||||||
|
foreach (string entry : values)
|
||||||
|
{
|
||||||
|
int divider = entry.IndexOf("="); if (divider < 0) continue;
|
||||||
|
string field = entry.Substring(0, divider), value = entry.Substring(divider + 1, entry.Length() - divider - 1);
|
||||||
|
array<string> parts = {}; value.Split("|", parts, false);
|
||||||
|
if (field == "starterMode") { m_StarterMode = 0; if (value == "custom") m_StarterMode = 1; }
|
||||||
|
if (field == "starterState") SetText("StarterState", value);
|
||||||
|
if (field == "serverItem" && parts.Count() == 6)
|
||||||
|
{ catalogKeys.Insert(parts[0]); catalogLabels.Insert(parts[1]); catalogSignature += value; }
|
||||||
|
if (field == "starterItem" && parts.Count() == 4)
|
||||||
|
{
|
||||||
|
string location = "Backpack"; if (parts[3] == "ground") location = "Ground";
|
||||||
|
savedKeys.Insert(parts[0] + " " + parts[3]);
|
||||||
|
savedLabels.Insert(location + " | " + parts[2] + " x " + WidgetManager.Translate(parts[1]));
|
||||||
|
savedSignature += value; total += parts[2].ToInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (catalogSignature != m_StarterCatalogSignature)
|
||||||
|
{
|
||||||
|
StarterCombo("StarterCatalogItem", catalogKeys, catalogLabels, m_StarterCatalog);
|
||||||
|
m_StarterCatalogSignature = catalogSignature; m_StarterAddon = m_ShownItemAddon;
|
||||||
|
SCR_ComboBoxComponent combo = SCR_ComboBoxComponent.GetComboBoxComponent("StarterMod", GetRootWidget());
|
||||||
|
if (combo && !m_StarterAddon.IsEmpty()) combo.SetCurrentItem(Math.Max(0, m_StarterMods.Find(m_StarterAddon)), false, false, false);
|
||||||
|
}
|
||||||
|
if (savedSignature != m_StarterSavedSignature)
|
||||||
|
{ StarterCombo("StarterSaved", savedKeys, savedLabels, m_StarterSaved); m_StarterSavedSignature = savedSignature; }
|
||||||
|
string mode = "Default loadout selected"; if (m_StarterMode == 1) mode = "Custom loadout selected";
|
||||||
|
SetText("StarterSummary", mode + " | Custom: " + savedKeys.Count().ToString() + "/32 entries, " + total.ToString() + "/64 items + field map");
|
||||||
|
string page = "Choose a mod, then Show items. Quantity 0 removes an item.";
|
||||||
|
if (!m_StarterAddon.IsEmpty()) page = "Catalog page " + (m_ShownItemPage + 1).ToString() + "/" + (m_LastItemPage + 1).ToString() + " | Select an item above; enter its total desired quantity (0 removes).";
|
||||||
|
SetText("StarterCatalogState", page); UpdateActions();
|
||||||
|
}
|
||||||
|
protected void OnStarterButton(SCR_ButtonBaseComponent button)
|
||||||
|
{
|
||||||
|
if (!button || !m_Ready || !IsFocused() || !m_Controller || m_Age > 6 || m_ClickDelay > 0) return;
|
||||||
|
string name = button.GetRootWidget().GetName();
|
||||||
|
if (name == "StarterDefault") { SubmitStarter("starter mode default"); return; }
|
||||||
|
if (name == "StarterCustom") { SubmitStarter("starter mode custom"); return; }
|
||||||
|
if (name == "StarterRemove")
|
||||||
|
{
|
||||||
|
int selected = SCR_ComboBoxComponent.GetComboBoxComponent("StarterSaved", GetRootWidget()).GetCurrentIndex();
|
||||||
|
if (selected >= 0 && selected < m_StarterSaved.Count()) SubmitStarter("starter remove " + m_StarterSaved[selected]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (name == "StarterAdd")
|
||||||
|
{
|
||||||
|
int selected = SCR_ComboBoxComponent.GetComboBoxComponent("StarterCatalogItem", GetRootWidget()).GetCurrentIndex();
|
||||||
|
int count; string quantity = SCR_EditBoxComponent.GetEditBoxComponent("StarterQuantity", GetRootWidget()).GetValue().Trim();
|
||||||
|
if (!ERR_CommandArguments.Integer(quantity, count) || count < 0 || count > 48) { ReceiveReply("Enter a quantity from 0 to 48; 0 removes the item."); return; }
|
||||||
|
string destination = "backpack";
|
||||||
|
if (SCR_ComboBoxComponent.GetComboBoxComponent("StarterDestination", GetRootWidget()).GetCurrentIndex() == 1) destination = "ground";
|
||||||
|
if (selected >= 0 && selected < m_StarterCatalog.Count() && !m_StarterAddon.IsEmpty()) SubmitStarter("starter set " + m_StarterAddon + " " + m_StarterCatalog[selected] + " " + count.ToString() + " " + destination);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int index = SCR_ComboBoxComponent.GetComboBoxComponent("StarterMod", GetRootWidget()).GetCurrentIndex();
|
||||||
|
if (index < 0 || index >= m_StarterMods.Count()) return;
|
||||||
|
string addon = m_StarterMods[index]; int page;
|
||||||
|
if (name == "StarterPrevious" || name == "StarterNext")
|
||||||
|
{
|
||||||
|
addon = m_StarterAddon; page = m_ShownItemPage - 1;
|
||||||
|
if (name == "StarterNext") page = m_ShownItemPage + 1;
|
||||||
|
}
|
||||||
|
SubmitStarter("items list " + addon + " " + Math.Clamp(page, 0, m_LastItemPage).ToString());
|
||||||
|
}
|
||||||
|
protected void SubmitStarter(string command)
|
||||||
|
{
|
||||||
|
m_ClickDelay = 0.3; SetText("Feedback", "Updating starting backpack...");
|
||||||
|
m_Controller.ERR_AdminSubmit(command, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,443 @@
|
|||||||
|
// The mission only produces facts. Aggregation and public leaderboards belong to
|
||||||
|
// the receiver; retries retain event IDs so they cannot count a result twice.
|
||||||
|
[BaseContainerProps()]
|
||||||
|
class ERR_TelemetryConfig
|
||||||
|
{
|
||||||
|
[Attribute("")] string Endpoint;
|
||||||
|
static const string RESOURCE = "{E72B130684FA492C}Configs/ERR/Telemetry.conf";
|
||||||
|
static const string PATH = "$profile:EscapistsTelemetry.json";
|
||||||
|
string Token;
|
||||||
|
string ServerName;
|
||||||
|
static ERR_TelemetryConfig Load()
|
||||||
|
{
|
||||||
|
ERR_TelemetryConfig config = ERR_TelemetryConfig.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab(RESOURCE));
|
||||||
|
if (!config) config = new ERR_TelemetryConfig();
|
||||||
|
if (FileIO.FileExists(PATH))
|
||||||
|
{
|
||||||
|
JsonLoadContext json = new JsonLoadContext();
|
||||||
|
if (!json.LoadFromFile(PATH)) { config.Endpoint = ""; return config; }
|
||||||
|
json.ReadValue("endpoint", config.Endpoint);
|
||||||
|
json.ReadValue("token", config.Token);
|
||||||
|
json.ReadValue("serverName", config.ServerName);
|
||||||
|
}
|
||||||
|
config.Endpoint.TrimInPlace();
|
||||||
|
if (!config.Endpoint.StartsWith("https://") || !ERR_SpeechRules.Endpoint(config.Endpoint)) config.Endpoint = "";
|
||||||
|
if (config.Token.Length() > 256 || config.ServerName.Length() > 120) config.Endpoint = "";
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_TelemetryPlayer
|
||||||
|
{
|
||||||
|
string id;
|
||||||
|
string name;
|
||||||
|
bool authenticated;
|
||||||
|
bool connected;
|
||||||
|
bool participated;
|
||||||
|
bool escaped;
|
||||||
|
int connectedSeconds;
|
||||||
|
int kills;
|
||||||
|
int friendlyKills;
|
||||||
|
int deaths;
|
||||||
|
int downed;
|
||||||
|
int recoveries;
|
||||||
|
}
|
||||||
|
class ERR_TelemetryMod
|
||||||
|
{
|
||||||
|
string id;
|
||||||
|
string name;
|
||||||
|
string version;
|
||||||
|
}
|
||||||
|
class ERR_TelemetryState
|
||||||
|
{
|
||||||
|
int schemaVersion = 1;
|
||||||
|
string serverId;
|
||||||
|
string endpoint;
|
||||||
|
string previousMissionId;
|
||||||
|
string previousOutcome;
|
||||||
|
int droppedEvents;
|
||||||
|
ref array<string> pending = {};
|
||||||
|
}
|
||||||
|
class ERR_TelemetryRules
|
||||||
|
{
|
||||||
|
static bool Acknowledged(int status) { return status >= 200 && status < 300; }
|
||||||
|
static int RetrySeconds(int failures)
|
||||||
|
{
|
||||||
|
return Math.Min(300, 5 * Math.Pow(2, Math.Min(failures, 6)));
|
||||||
|
}
|
||||||
|
static string Outcome(int phase, bool emptyRestart, bool preparationFailed)
|
||||||
|
{
|
||||||
|
if (preparationFailed) return "preparation_failed";
|
||||||
|
if (emptyRestart) return "restarted_empty";
|
||||||
|
if (phase == ERR_Phase.VICTORY) return "victory";
|
||||||
|
if (phase == ERR_Phase.DEFEAT) return "defeat";
|
||||||
|
return "interrupted";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_Telemetry
|
||||||
|
{
|
||||||
|
static const string STATE = "$profile:EscapistsTelemetryState.json";
|
||||||
|
protected ERR_GameMode m_Mode;
|
||||||
|
protected ref ERR_TelemetryConfig m_Config;
|
||||||
|
protected ref ERR_TelemetryState m_State;
|
||||||
|
protected ref array<ref ERR_TelemetryPlayer> m_Players = {};
|
||||||
|
protected ref array<ref ERR_TelemetryMod> m_Mods = {};
|
||||||
|
protected ref RestCallback m_Callback;
|
||||||
|
protected RestContext m_Context;
|
||||||
|
protected string m_MissionId;
|
||||||
|
protected string m_InFlight;
|
||||||
|
protected string m_FinalEventId;
|
||||||
|
protected string m_FinalOutcome;
|
||||||
|
protected string m_FinalTerrain;
|
||||||
|
protected bool m_CommunityReady;
|
||||||
|
protected int m_Started;
|
||||||
|
protected int m_LastSample;
|
||||||
|
protected int m_NextHeartbeat;
|
||||||
|
protected int m_NextAttempt;
|
||||||
|
protected int m_Peak;
|
||||||
|
protected int m_Failures;
|
||||||
|
protected int m_RequestStarted;
|
||||||
|
protected int m_Delivered;
|
||||||
|
protected bool m_Collected;
|
||||||
|
protected bool m_Partial;
|
||||||
|
protected bool m_Enabled;
|
||||||
|
protected bool m_Ended;
|
||||||
|
protected bool m_Closed;
|
||||||
|
protected bool m_Dirty;
|
||||||
|
protected bool m_TruncatedPlayers;
|
||||||
|
protected bool m_TruncatedMods;
|
||||||
|
protected bool m_CredentialBlocked;
|
||||||
|
|
||||||
|
void ERR_Telemetry(ERR_GameMode mode)
|
||||||
|
{
|
||||||
|
m_Mode = mode; m_Config = ERR_TelemetryConfig.Load();
|
||||||
|
m_State = new ERR_TelemetryState();
|
||||||
|
// A damaged primary can recover from the last fully written generation.
|
||||||
|
if (!LoadState(STATE) && !LoadState(STATE + ".bak"))
|
||||||
|
{
|
||||||
|
if (FileIO.FileExists(STATE) || FileIO.FileExists(STATE + ".bak"))
|
||||||
|
{
|
||||||
|
Print("Reintroduced [telemetry]: unreadable queue; telemetry suspended, files preserved", LogLevel.ERROR);
|
||||||
|
m_Closed = true; return;
|
||||||
|
}
|
||||||
|
m_State.serverId = UUID.GenV4();
|
||||||
|
}
|
||||||
|
if (m_State.endpoint != m_Config.Endpoint)
|
||||||
|
{
|
||||||
|
// Never redirect previously collected player data to a different receiver.
|
||||||
|
Purge(); m_State.endpoint = m_Config.Endpoint;
|
||||||
|
}
|
||||||
|
array<string> addons = {}; GameProject.GetLoadedAddons(addons);
|
||||||
|
foreach (string addon : addons)
|
||||||
|
{
|
||||||
|
if (GameProject.IsVanillaAddon(addon)) continue;
|
||||||
|
if (m_Mods.Count() >= 128) { m_TruncatedMods = true; break; }
|
||||||
|
ERR_TelemetryMod mod = new ERR_TelemetryMod();
|
||||||
|
mod.id = addon; mod.name = GameProject.GetAddonTitle(addon);
|
||||||
|
BackendApi backend = GetGame().GetBackendApi();
|
||||||
|
if (backend && backend.GetWorkshop())
|
||||||
|
{
|
||||||
|
WorkshopItem item = backend.GetWorkshop().FindItem(addon);
|
||||||
|
if (item && item.GetActiveRevision()) mod.version = item.GetActiveRevision().GetVersion();
|
||||||
|
}
|
||||||
|
m_Mods.Insert(mod);
|
||||||
|
}
|
||||||
|
m_MissionId = UUID.GenV4(); m_Started = System.GetTickCount();
|
||||||
|
Refresh();
|
||||||
|
GetGame().GetCallqueue().CallLater(Pulse, 5000, true);
|
||||||
|
}
|
||||||
|
protected bool ReadState(string path, out ERR_TelemetryState state)
|
||||||
|
{
|
||||||
|
string raw;
|
||||||
|
JsonLoadContext json = new JsonLoadContext();
|
||||||
|
if (!ERR_ProfileConfig.Text(path, raw) || !json.LoadFromString(raw) || !json.ReadValue("state", state) || !state || state.schemaVersion != 1 || !UUID.IsUUID(state.serverId) || !state.pending || state.pending.Count() > 64) return false;
|
||||||
|
foreach (string queuedEvent : state.pending)
|
||||||
|
{
|
||||||
|
JsonLoadContext queued = new JsonLoadContext(); string eventId, missionId, serverId;
|
||||||
|
if (queuedEvent.Length() > 65536 || !queued.LoadFromString(queuedEvent) || !queued.ReadValue("eventId", eventId) || !UUID.IsUUID(eventId) || !queued.ReadValue("missionId", missionId) || !UUID.IsUUID(missionId) || !queued.ReadValue("serverId", serverId) || serverId != state.serverId) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected bool LoadState(string path)
|
||||||
|
{
|
||||||
|
ERR_TelemetryState state;
|
||||||
|
if (!ReadState(path, state)) return false;
|
||||||
|
m_State = state; return true;
|
||||||
|
}
|
||||||
|
protected bool Save()
|
||||||
|
{
|
||||||
|
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
||||||
|
json.WriteValue("state", m_State);
|
||||||
|
if (!json.SaveToFile(STATE + ".tmp")) return false;
|
||||||
|
string written;
|
||||||
|
if (!ERR_ProfileConfig.Text(STATE + ".tmp", written) || written != json.SaveToString()) return false;
|
||||||
|
ERR_TelemetryState previous;
|
||||||
|
if (ReadState(STATE, previous) && !FileIO.CopyFile(STATE, STATE + ".bak")) return false;
|
||||||
|
if (!FileIO.CopyFile(STATE + ".tmp", STATE)) return false;
|
||||||
|
string confirmed;
|
||||||
|
if (!ERR_ProfileConfig.Text(STATE, confirmed) || confirmed != written) return false;
|
||||||
|
FileIO.DeleteFile(STATE + ".tmp"); m_Dirty = false; return true;
|
||||||
|
}
|
||||||
|
protected void Purge()
|
||||||
|
{
|
||||||
|
m_State.pending.Clear(); m_State.previousMissionId = ""; m_State.previousOutcome = "";
|
||||||
|
m_Players.Clear(); m_InFlight = ""; m_Callback = null;
|
||||||
|
// Do not retain personal data in recovery files after opting out.
|
||||||
|
FileIO.DeleteFile(STATE); FileIO.DeleteFile(STATE + ".bak"); FileIO.DeleteFile(STATE + ".tmp");
|
||||||
|
m_Dirty = true;
|
||||||
|
}
|
||||||
|
protected bool Current() { return GetGame() && m_Mode && ERR_GameMode.Get() == m_Mode; }
|
||||||
|
string Status()
|
||||||
|
{
|
||||||
|
if (m_Closed) return "Telemetry suspended: queue recovery required.";
|
||||||
|
if (m_Mode.Settings().Get("telemetryEnabled") == 0) return "Disabled. Unsent records discarded.";
|
||||||
|
if (m_Config.Endpoint.IsEmpty()) return "Not sending: receiving URL is missing or invalid.";
|
||||||
|
if (m_Dirty) return "Waiting for profile storage; events have not been sent.";
|
||||||
|
if (m_CredentialBlocked) return "Telemetry credential storage needs attention; delivery suspended.";
|
||||||
|
if (m_Failures > 0) return "Delivery unavailable; pending records will retry.";
|
||||||
|
return string.Format("Configured. %1 delivered this session; %2 pending.", m_Delivered, m_State.pending.Count());
|
||||||
|
}
|
||||||
|
bool Enabled() { return m_Enabled && !m_Closed; }
|
||||||
|
void Refresh()
|
||||||
|
{
|
||||||
|
if (m_Closed || !Current() || !Replication.IsServer() || !m_Mode.Settings()) return;
|
||||||
|
bool enabled = m_Mode.Settings().Get("telemetryEnabled") == 1 && !m_Config.Endpoint.IsEmpty();
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
if (m_Enabled || !m_State.pending.IsEmpty() || !m_State.previousMissionId.IsEmpty())
|
||||||
|
{
|
||||||
|
m_Enabled = false; Purge(); Save();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_Enabled || m_Ended) return;
|
||||||
|
m_Enabled = true;
|
||||||
|
int now = System.GetTickCount(); m_LastSample = now; m_NextHeartbeat = now + 300000;
|
||||||
|
m_Partial = m_Collected || now - m_Started > 1000;
|
||||||
|
m_Peak = 0; m_TruncatedPlayers = false;
|
||||||
|
string previous = m_State.previousMissionId;
|
||||||
|
string outcome = m_State.previousOutcome;
|
||||||
|
m_State.previousMissionId = m_MissionId; m_State.previousOutcome = "unfinished";
|
||||||
|
Sample();
|
||||||
|
if (!m_Collected && !previous.IsEmpty()) Event("mission_restarted", "", previous, outcome);
|
||||||
|
if (m_Collected) Event("telemetry_resumed");
|
||||||
|
else Event("mission_started", "", previous, outcome);
|
||||||
|
m_Collected = true;
|
||||||
|
}
|
||||||
|
protected void Sample()
|
||||||
|
{
|
||||||
|
if (!Enabled() || m_Ended) return;
|
||||||
|
int now = System.GetTickCount();
|
||||||
|
int elapsed = Math.Max(0, (now - m_LastSample) / 1000); m_LastSample = now;
|
||||||
|
foreach (ERR_TelemetryPlayer known : m_Players)
|
||||||
|
{
|
||||||
|
if (known.connected) known.connectedSeconds += elapsed;
|
||||||
|
known.connected = false;
|
||||||
|
}
|
||||||
|
array<int> connections = {}; GetGame().GetPlayerManager().GetPlayers(connections);
|
||||||
|
m_Peak = Math.Max(m_Peak, connections.Count());
|
||||||
|
foreach (int connection : connections)
|
||||||
|
{
|
||||||
|
UUID account = SCR_PlayerIdentityUtils.GetPlayerIdentityId(connection);
|
||||||
|
string key = account;
|
||||||
|
bool authenticated = !account.IsNull();
|
||||||
|
if (!authenticated) key = m_MissionId + ":connection:" + connection.ToString();
|
||||||
|
ERR_TelemetryPlayer player;
|
||||||
|
foreach (ERR_TelemetryPlayer candidate : m_Players) if (candidate.id == key) { player = candidate; break; }
|
||||||
|
if (!player)
|
||||||
|
{
|
||||||
|
if (m_Players.Count() >= 128) { m_TruncatedPlayers = true; continue; }
|
||||||
|
player = new ERR_TelemetryPlayer(); player.id = key; player.authenticated = authenticated; m_Players.Insert(player);
|
||||||
|
}
|
||||||
|
player.name = GetGame().GetPlayerManager().GetPlayerName(connection);
|
||||||
|
if (player.name.Length() > 128) player.name = player.name.Substring(0, 128);
|
||||||
|
player.connected = true;
|
||||||
|
ERR_PlayerLife life = m_Mode.Players().Get(connection);
|
||||||
|
if (life && life.Connected && life.UsedLife) player.participated = true;
|
||||||
|
if (authenticated && m_Mode.Extraction()) player.escaped = m_Mode.Extraction().DidEscape(account);
|
||||||
|
}
|
||||||
|
// Include disconnected escapees/participants with their final authoritative result.
|
||||||
|
array<ref ERR_PlayerLife> lives = {}; m_Mode.Players().Participants(lives);
|
||||||
|
foreach (ERR_PlayerLife participant : lives)
|
||||||
|
foreach (ERR_TelemetryPlayer tracked : m_Players)
|
||||||
|
if (tracked.authenticated && tracked.id == participant.AccountId)
|
||||||
|
{
|
||||||
|
tracked.participated = true;
|
||||||
|
ERR_RoundPlayerStats stats;
|
||||||
|
if (m_Mode.ERR_Statistics()) stats = m_Mode.ERR_Statistics().Find(participant.AccountId);
|
||||||
|
if (stats)
|
||||||
|
{
|
||||||
|
tracked.kills = stats.Kills; tracked.friendlyKills = stats.FriendlyKills;
|
||||||
|
tracked.deaths = stats.Deaths; tracked.downed = stats.Downed; tracked.recoveries = stats.Recoveries;
|
||||||
|
}
|
||||||
|
if (m_Mode.Extraction()) tracked.escaped = m_Mode.Extraction().DidEscape(participant.AccountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void RosterChanged(int playerId) { Sample(); }
|
||||||
|
void PhaseChanged(ERR_Phase previous, ERR_Phase current)
|
||||||
|
{
|
||||||
|
if (!Enabled() || m_Ended) return;
|
||||||
|
if (ERR_MissionRules.Terminal(current)) Finish(ERR_TelemetryRules.Outcome(current, false, false));
|
||||||
|
else Event("phase_changed");
|
||||||
|
}
|
||||||
|
void Finish(string outcome)
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
if (!Enabled() || m_Ended) return;
|
||||||
|
Sample(); m_Ended = true;
|
||||||
|
m_State.previousOutcome = outcome;
|
||||||
|
Event("mission_finished", outcome);
|
||||||
|
}
|
||||||
|
protected string Terrain()
|
||||||
|
{
|
||||||
|
// The loaded root scene identifies the island beneath GM/Conflict scenarios.
|
||||||
|
// Use the same terrain resolver as the mission title, on the reporting server.
|
||||||
|
string world = GetGame().GetWorldFile();
|
||||||
|
if (GetGame().GetWorld() && GetGame().GetWorld().GetNumSubScenes() > 0)
|
||||||
|
{
|
||||||
|
string root = GetGame().GetWorld().GetSubSceneName(0);
|
||||||
|
if (!root.IsEmpty()) world = root;
|
||||||
|
}
|
||||||
|
return ERR_TerrainDisplayName.Resolve(world);
|
||||||
|
}
|
||||||
|
protected void Event(string type, string outcome = "", string previous = "", string previousOutcome = "")
|
||||||
|
{
|
||||||
|
if (!Enabled()) return;
|
||||||
|
if (!m_Ended) Sample();
|
||||||
|
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false);
|
||||||
|
json.WriteValue("schemaVersion", 1);
|
||||||
|
string eventId = UUID.GenV4();
|
||||||
|
json.WriteValue("eventId", eventId); json.WriteValue("missionId", m_MissionId);
|
||||||
|
json.WriteValue("serverId", m_State.serverId); json.WriteValue("serverName", ERR_TelemetryServerName.Resolve(m_Config.ServerName));
|
||||||
|
json.WriteValue("type", type); json.WriteValue("occurredAt", System.GetUnixTime());
|
||||||
|
json.WriteValue("partial", m_Partial);
|
||||||
|
int elapsedSeconds = Math.Max(0, (System.GetTickCount() - m_Started) / 1000);
|
||||||
|
json.WriteValue("elapsedSeconds", elapsedSeconds);
|
||||||
|
json.WriteValue("phase", m_Mode.Phase()); json.WriteValue("outcome", outcome);
|
||||||
|
json.WriteValue("previousMissionId", previous); json.WriteValue("previousOutcome", previousOutcome);
|
||||||
|
string terrain = Terrain();
|
||||||
|
json.WriteValue("terrain", terrain);
|
||||||
|
SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
|
||||||
|
string scenario; if (header) scenario = header.m_sName;
|
||||||
|
json.WriteValue("gameVersion", GetGame().GetBuildVersion());
|
||||||
|
json.WriteValue("scenario", scenario); json.WriteValue("mods", m_Mods);
|
||||||
|
json.WriteValue("modsTruncated", m_TruncatedMods); json.WriteValue("playersTruncated", m_TruncatedPlayers);
|
||||||
|
json.WriteValue("connectedPlayers", GetGame().GetPlayerManager().GetPlayerCount());
|
||||||
|
json.WriteValue("peakPlayers", m_Peak); json.WriteValue("players", m_Players);
|
||||||
|
json.WriteValue("reason", m_Mode.EndReason()); json.WriteValue("preparationError", m_Mode.PreparationError());
|
||||||
|
map<string, int> settings = new map<string, int>();
|
||||||
|
foreach (string key : ERR_Settings.Keys()) settings.Set(key, m_Mode.Settings().Get(key));
|
||||||
|
json.WriteValue("settings", settings); json.WriteValue("droppedEvents", m_State.droppedEvents);
|
||||||
|
string payload = json.SaveToString();
|
||||||
|
if (payload.Length() > 65536) { m_State.droppedEvents++; m_Dirty = true; return; }
|
||||||
|
// Bound disk and memory during long outages. Prefer retaining result records.
|
||||||
|
if (m_State.pending.Count() >= 64)
|
||||||
|
{
|
||||||
|
int remove = -1;
|
||||||
|
for (int i = 0; i < m_State.pending.Count(); i++)
|
||||||
|
{
|
||||||
|
if (m_State.pending[i] == m_InFlight) continue;
|
||||||
|
JsonLoadContext queued = new JsonLoadContext(); string queuedType;
|
||||||
|
if (queued.LoadFromString(m_State.pending[i]) && queued.ReadValue("type", queuedType) && queuedType == "heartbeat") { remove = i; break; }
|
||||||
|
}
|
||||||
|
if (remove < 0) remove = 0;
|
||||||
|
if (remove == 0 && !m_InFlight.IsEmpty()) remove = 1;
|
||||||
|
m_State.pending.Remove(remove); m_State.droppedEvents++;
|
||||||
|
}
|
||||||
|
if (type == "mission_finished")
|
||||||
|
{
|
||||||
|
m_FinalEventId = eventId; m_FinalOutcome = outcome; m_FinalTerrain = terrain;
|
||||||
|
// Finish can arrive while a previous request is in flight. RemoveItem on its
|
||||||
|
// acknowledgement still removes that exact payload, leaving this final first.
|
||||||
|
m_State.pending.InsertAt(payload, 0);
|
||||||
|
if (outcome == "victory" || outcome == "defeat")
|
||||||
|
m_Mode.ERR_PublishCommunityStatistics("This map's community record: waiting for the round result to be recorded...");
|
||||||
|
GetGame().GetCallqueue().CallLater(Pulse, 1, false);
|
||||||
|
}
|
||||||
|
else m_State.pending.Insert(payload);
|
||||||
|
m_Dirty = true;
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
protected void Pulse()
|
||||||
|
{
|
||||||
|
if (m_Closed || ERR_GameMode.Get() != m_Mode) { Close(); return; }
|
||||||
|
Refresh();
|
||||||
|
if (!Enabled()) return;
|
||||||
|
int now = System.GetTickCount();
|
||||||
|
if (!m_Ended)
|
||||||
|
{
|
||||||
|
Sample();
|
||||||
|
if (now >= m_NextHeartbeat) { m_NextHeartbeat = now + 300000; Event("heartbeat"); }
|
||||||
|
}
|
||||||
|
if (m_Dirty && !Save()) { CommunityUnavailable(); return; }
|
||||||
|
if (m_Callback && now - m_RequestStarted > 30000) Failed(m_Callback);
|
||||||
|
if (m_Callback || m_State.pending.IsEmpty() || now < m_NextAttempt) return;
|
||||||
|
if (m_Config.Token.IsEmpty())
|
||||||
|
{
|
||||||
|
string token;
|
||||||
|
if (!ERR_TelemetryCredentials.Resolve(m_Config.Endpoint, m_State.serverId, token))
|
||||||
|
{
|
||||||
|
CommunityUnavailable();
|
||||||
|
m_CredentialBlocked = true; m_NextAttempt = now + 30000; return;
|
||||||
|
}
|
||||||
|
m_Config.Token = token; m_CredentialBlocked = false;
|
||||||
|
}
|
||||||
|
m_Context = GetGame().GetRestApi().GetContext(m_Config.Endpoint);
|
||||||
|
if (!m_Context) { CommunityUnavailable(); m_NextAttempt = now + 300000; return; }
|
||||||
|
m_Callback = new RestCallback(); m_Callback.SetOnSuccess(Delivered); m_Callback.SetOnError(Failed);
|
||||||
|
m_InFlight = m_State.pending[0]; m_RequestStarted = now;
|
||||||
|
JsonSaveContext request = new JsonSaveContext(); request.EnableTypeDiscriminator(false);
|
||||||
|
request.WriteValue("token", m_Config.Token);
|
||||||
|
// Embed the event object as JSON rather than double-encoding a JSON string.
|
||||||
|
string wrapper = request.SaveToString();
|
||||||
|
wrapper = wrapper.Substring(0, wrapper.Length() - 1) + ",\"event\":" + m_InFlight + "}";
|
||||||
|
m_Context.SetHeaders("Content-Type,application/json"); m_Context.SetTimeout(15);
|
||||||
|
m_Context.POST(m_Callback, "", wrapper);
|
||||||
|
}
|
||||||
|
protected void Delivered(RestCallback callback)
|
||||||
|
{
|
||||||
|
if (callback != m_Callback || !Enabled() || !Current()) return;
|
||||||
|
if (!ERR_TelemetryRules.Acknowledged(callback.GetHttpCode())) { Failed(callback); return; }
|
||||||
|
UpdateCommunity(callback);
|
||||||
|
m_State.pending.RemoveItem(m_InFlight); m_InFlight = ""; m_Callback = null;
|
||||||
|
m_Failures = 0; m_Delivered++; m_Dirty = true; Save();
|
||||||
|
if (m_Ended) GetGame().GetCallqueue().CallLater(Pulse, 1, false);
|
||||||
|
}
|
||||||
|
protected void CommunityUnavailable()
|
||||||
|
{
|
||||||
|
if (!m_CommunityReady && Current() && m_Ended && (m_FinalOutcome == "victory" || m_FinalOutcome == "defeat"))
|
||||||
|
m_Mode.ERR_PublishCommunityStatistics("Community map records unavailable. This round's local statistics are shown below.");
|
||||||
|
}
|
||||||
|
protected void UpdateCommunity(RestCallback callback)
|
||||||
|
{
|
||||||
|
if (!m_Ended || m_FinalEventId.IsEmpty() || !Current()) return;
|
||||||
|
JsonLoadContext sent = new JsonLoadContext(); string sentEvent;
|
||||||
|
if (!sent.LoadFromString(m_InFlight) || !sent.ReadValue("eventId", sentEvent) || sentEvent != m_FinalEventId) return;
|
||||||
|
if (m_FinalOutcome != "victory" && m_FinalOutcome != "defeat") return;
|
||||||
|
JsonLoadContext reply = new JsonLoadContext();
|
||||||
|
ERR_CommunityStatistics community;
|
||||||
|
if (callback.GetData().Length() > 8192 || !reply.LoadFromString(callback.GetData()) || !reply.ReadValue("community", community) || !community || !community.Matches(m_State.serverId, m_MissionId, m_FinalEventId, m_FinalTerrain, m_FinalOutcome))
|
||||||
|
{
|
||||||
|
CommunityUnavailable(); return;
|
||||||
|
}
|
||||||
|
m_CommunityReady = true;
|
||||||
|
m_Mode.ERR_PublishCommunityStatistics(community.Summary());
|
||||||
|
}
|
||||||
|
protected void Failed(RestCallback callback)
|
||||||
|
{
|
||||||
|
if (callback != m_Callback || !Enabled()) return;
|
||||||
|
m_Callback = null; m_InFlight = ""; m_Failures = Math.Min(100, m_Failures + 1);
|
||||||
|
m_NextAttempt = System.GetTickCount() + 1000 * ERR_TelemetryRules.RetrySeconds(m_Failures);
|
||||||
|
CommunityUnavailable();
|
||||||
|
if (m_Failures == 1) Print("Reintroduced [telemetry]: delivery failed; queued events will retry", LogLevel.WARNING);
|
||||||
|
}
|
||||||
|
void Close()
|
||||||
|
{
|
||||||
|
if (m_Closed) return;
|
||||||
|
if (Current()) Finish("interrupted");
|
||||||
|
m_Closed = true;
|
||||||
|
if (GetGame()) GetGame().GetCallqueue().Remove(Pulse);
|
||||||
|
m_Callback = null; m_Context = null; m_Mode = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// Each installation claims its random server ID with its own persistent secret.
|
||||||
|
// No receiver administrator secret is bundled with the mod or sent by players.
|
||||||
|
class ERR_TelemetryCredential
|
||||||
|
{
|
||||||
|
string endpoint;
|
||||||
|
string serverId;
|
||||||
|
string token;
|
||||||
|
}
|
||||||
|
class ERR_TelemetryCredentials
|
||||||
|
{
|
||||||
|
static const string PATH = "$profile:EscapistsTelemetryCredentials.json";
|
||||||
|
static bool Valid(ERR_TelemetryCredential entry)
|
||||||
|
{
|
||||||
|
return entry && !entry.endpoint.IsEmpty() && UUID.IsUUID(entry.serverId) && entry.token.Length() >= 32 && entry.token.Length() <= 256;
|
||||||
|
}
|
||||||
|
static bool Resolve(string endpoint, string serverId, out string token)
|
||||||
|
{
|
||||||
|
token = "";
|
||||||
|
ref array<ref ERR_TelemetryCredential> entries = {};
|
||||||
|
if (FileIO.FileExists(PATH))
|
||||||
|
{
|
||||||
|
JsonLoadContext loaded = new JsonLoadContext();
|
||||||
|
// Never silently replace a damaged credential: the receiver already owns its
|
||||||
|
// hash, and a new secret must not take over the same server's history.
|
||||||
|
if (!loaded.LoadFromFile(PATH) || !loaded.ReadValue("credentials", entries) || !entries || entries.Count() > 16) return false;
|
||||||
|
foreach (ERR_TelemetryCredential known : entries)
|
||||||
|
{
|
||||||
|
if (!Valid(known)) return false;
|
||||||
|
if (known.endpoint == endpoint && known.serverId == serverId) token = known.token;
|
||||||
|
}
|
||||||
|
if (!token.IsEmpty()) return true;
|
||||||
|
}
|
||||||
|
if (entries.Count() >= 16) return false;
|
||||||
|
ERR_TelemetryCredential created = new ERR_TelemetryCredential();
|
||||||
|
created.endpoint = endpoint; created.serverId = serverId;
|
||||||
|
string first = UUID.GenV4(); string second = UUID.GenV4();
|
||||||
|
created.token = first + second;
|
||||||
|
entries.Insert(created);
|
||||||
|
JsonSaveContext saved = new JsonSaveContext(); saved.EnableTypeDiscriminator(false);
|
||||||
|
saved.WriteValue("credentials", entries);
|
||||||
|
if (!saved.SaveToFile(PATH + ".tmp")) return false;
|
||||||
|
string written;
|
||||||
|
if (!ERR_ProfileConfig.Text(PATH + ".tmp", written) || written != saved.SaveToString()) return false;
|
||||||
|
if (!FileIO.CopyFile(PATH + ".tmp", PATH)) return false;
|
||||||
|
string confirmed;
|
||||||
|
if (!ERR_ProfileConfig.Text(PATH, confirmed) || confirmed != written) return false;
|
||||||
|
FileIO.DeleteFile(PATH + ".tmp");
|
||||||
|
// Publish to the HTTP sender only after the exact credential is durable.
|
||||||
|
token = created.token;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
// Keep instrumentation outside mission rules: telemetry cannot decide an outcome
|
||||||
|
// or delay vanilla shutdown/restarts. Unsent results survive in the profile queue.
|
||||||
|
modded class ERR_GameMode
|
||||||
|
{
|
||||||
|
protected ref ERR_Telemetry m_ERRTelemetry;
|
||||||
|
protected override void EOnInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.EOnInit(owner);
|
||||||
|
if (SCR_Global.IsEditMode() || !Replication.IsServer() || !Settings()) return;
|
||||||
|
#ifdef WORKBENCH
|
||||||
|
if (!System.IsCLIParam("errTelemetryTest")) return;
|
||||||
|
#endif
|
||||||
|
m_ERRTelemetry = new ERR_Telemetry(this);
|
||||||
|
Admin().Register(new ERR_TelemetryAdminProvider(m_ERRTelemetry));
|
||||||
|
OnPhaseChanged().Insert(m_ERRTelemetry.PhaseChanged);
|
||||||
|
Players().OnChanged().Insert(m_ERRTelemetry.RosterChanged);
|
||||||
|
}
|
||||||
|
void ERR_RefreshTelemetry() { if (m_ERRTelemetry) m_ERRTelemetry.Refresh(); }
|
||||||
|
protected override void FailPreparation(string detail)
|
||||||
|
{
|
||||||
|
super.FailPreparation(detail);
|
||||||
|
if (m_ERRTelemetry && !PreparationError().IsEmpty()) m_ERRTelemetry.Finish("preparation_failed");
|
||||||
|
}
|
||||||
|
protected override void OnGameModeEnd(SCR_GameModeEndData endData)
|
||||||
|
{
|
||||||
|
// Observe the phase BEFORE vanilla maps native interruption/empty restart to defeat.
|
||||||
|
if (m_ERRTelemetry) m_ERRTelemetry.Finish(ERR_TelemetryRules.Outcome(Phase(), m_EmptyRestartRequested, !PreparationError().IsEmpty()));
|
||||||
|
super.OnGameModeEnd(endData);
|
||||||
|
}
|
||||||
|
override void OnGameEnd()
|
||||||
|
{
|
||||||
|
if (m_ERRTelemetry) m_ERRTelemetry.Close();
|
||||||
|
super.OnGameEnd();
|
||||||
|
}
|
||||||
|
void ~ERR_GameMode() { if (m_ERRTelemetry) m_ERRTelemetry.Close(); }
|
||||||
|
}
|
||||||
|
modded class ERR_AdminService
|
||||||
|
{
|
||||||
|
override void Execute(ERR_GameMode mode, bool authorized, string arguments, array<string> replies)
|
||||||
|
{
|
||||||
|
super.Execute(mode, authorized, arguments, replies);
|
||||||
|
// Settings only change through the existing authenticated, save-before-apply path.
|
||||||
|
if (authorized && mode) mode.ERR_RefreshTelemetry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_TelemetryAdminProvider : ERR_AdminProvider
|
||||||
|
{
|
||||||
|
protected ERR_Telemetry m_Service;
|
||||||
|
void ERR_TelemetryAdminProvider(ERR_Telemetry service) { m_Service = service; }
|
||||||
|
override string Id() { return "telemetry"; }
|
||||||
|
override void Capabilities(array<string> values)
|
||||||
|
{
|
||||||
|
if (m_Service) values.Insert("telemetryStatus=" + m_Service.Status());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Resolve on the reporting server for every new event: lobby metadata can be
|
||||||
|
// unavailable during initial startup. Never infer identity from the scenario.
|
||||||
|
class ERR_TelemetryServerName
|
||||||
|
{
|
||||||
|
static string Resolve(string configured)
|
||||||
|
{
|
||||||
|
string name = configured;
|
||||||
|
name.TrimInPlace();
|
||||||
|
if (name.IsEmpty())
|
||||||
|
{
|
||||||
|
BackendApi backend = GetGame().GetBackendApi();
|
||||||
|
SCR_DSConfig dedicated = new SCR_DSConfig();
|
||||||
|
if (backend && backend.GetRunningDSConfig(dedicated) && dedicated.game)
|
||||||
|
name = dedicated.game.name;
|
||||||
|
name.TrimInPlace();
|
||||||
|
}
|
||||||
|
if (name.IsEmpty())
|
||||||
|
{
|
||||||
|
ServerConfig config = ServerLobbyApi.GetServerConfig();
|
||||||
|
if (config) name = config.GetName();
|
||||||
|
name.TrimInPlace();
|
||||||
|
}
|
||||||
|
if (name.IsEmpty())
|
||||||
|
{
|
||||||
|
ServerInfo info = GetGame().GetServerInfo();
|
||||||
|
if (info) name = info.GetName();
|
||||||
|
name.TrimInPlace();
|
||||||
|
}
|
||||||
|
if (name.Length() > 120) name = name.Substring(0, 120);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
// A replicated player controller can arrive in the gap between native mode
|
||||||
|
// removal and Escape's bootstrap. Vanilla deployment initialization dereferences
|
||||||
|
// GetGameMode() and can also retain the outgoing respawn singleton in that gap.
|
||||||
|
// Defer the original initialization intact; never initialize it a second time.
|
||||||
|
modded class SCR_PlayerDeployMenuHandlerComponent
|
||||||
|
{
|
||||||
|
protected IEntity m_ERRDeferredDeployOwner;
|
||||||
|
protected BaseWorld m_ERRDeferredDeployWorld;
|
||||||
|
protected int m_ERRDeployInitAttempts;
|
||||||
|
protected bool m_ERRDeployInitComplete;
|
||||||
|
|
||||||
|
protected override void OnPostInit(IEntity owner)
|
||||||
|
{
|
||||||
|
if (m_ERRDeployInitComplete || m_ERRDeferredDeployOwner) return;
|
||||||
|
if (!GetGame().ERR_ClientTerrainModePending())
|
||||||
|
{
|
||||||
|
m_ERRDeployInitComplete = true;
|
||||||
|
super.OnPostInit(owner);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_ERRDeferredDeployOwner = owner;
|
||||||
|
m_ERRDeferredDeployWorld = owner.GetWorld();
|
||||||
|
GetGame().GetCallqueue().CallLater(ERR_RetryDeployInit, 50, false);
|
||||||
|
}
|
||||||
|
protected void ERR_RetryDeployInit()
|
||||||
|
{
|
||||||
|
IEntity owner = m_ERRDeferredDeployOwner;
|
||||||
|
if (!owner || !GetGame() || GetGame().GetWorld() != m_ERRDeferredDeployWorld) { m_ERRDeferredDeployOwner = null; return; }
|
||||||
|
if (!GetGame().GetGameMode())
|
||||||
|
{
|
||||||
|
if (++m_ERRDeployInitAttempts < 200) GetGame().GetCallqueue().CallLater(ERR_RetryDeployInit, 50, false);
|
||||||
|
else { m_ERRDeferredDeployOwner = null; Print("Reintroduced [terrain client]: deployment initialization timed out waiting for game mode", LogLevel.ERROR); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_ERRDeferredDeployOwner = null;
|
||||||
|
m_ERRDeployInitComplete = true;
|
||||||
|
super.OnPostInit(owner);
|
||||||
|
Print("Reintroduced [terrain client]: deployment initialized after game mode arrived");
|
||||||
|
}
|
||||||
|
override protected void OnDelete(IEntity owner)
|
||||||
|
{
|
||||||
|
if (GetGame()) GetGame().GetCallqueue().Remove(ERR_RetryDeployInit);
|
||||||
|
m_ERRDeferredDeployOwner = null;
|
||||||
|
m_ERRDeferredDeployWorld = null;
|
||||||
|
super.OnDelete(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,21 @@ class ERR_TerrainSites : ERR_GeneratedSites
|
|||||||
protected vector m_Candidate;
|
protected vector m_Candidate;
|
||||||
protected float m_CandidateHeading;
|
protected float m_CandidateHeading;
|
||||||
protected int m_CandidateBegan;
|
protected int m_CandidateBegan;
|
||||||
protected ref ERR_ReconAirports m_Airports = new ERR_ReconAirports();
|
|
||||||
protected bool m_AirportsReady;
|
|
||||||
protected int m_GeometryRejected, m_NavigationRejected, m_PadRejected;
|
protected int m_GeometryRejected, m_NavigationRejected, m_PadRejected;
|
||||||
|
protected string m_NavigationReason;
|
||||||
|
// Keep the same work slice; difficult terrain gets more slices, not larger stalls.
|
||||||
|
static int SearchAttempts() { return 48000; }
|
||||||
|
static int SearchMilliseconds() { return 120000; }
|
||||||
|
static float PrisonAirportBuffer(vector low, vector high)
|
||||||
|
{
|
||||||
|
// The old 1.5km tactical separation could exclude an entire small island.
|
||||||
|
// Physical ground, scenery and navigation checks still apply independently.
|
||||||
|
return Math.Clamp(Math.Min(high[0] - low[0], high[2] - low[2]) * 0.15, 200, 1500);
|
||||||
|
}
|
||||||
static bool Bounds(vector low, vector high)
|
static bool Bounds(vector low, vector high)
|
||||||
{
|
{
|
||||||
float width = high[0] - low[0], depth = high[2] - low[2];
|
float width = high[0] - low[0], depth = high[2] - low[2];
|
||||||
return width >= 2000 && depth >= 2000 && width <= 100000 && depth <= 100000;
|
return width >= 1000 && depth >= 1000 && width <= 100000 && depth <= 100000;
|
||||||
}
|
}
|
||||||
static float Spacing(vector low, vector high)
|
static float Spacing(vector low, vector high)
|
||||||
{
|
{
|
||||||
@@ -23,12 +31,12 @@ class ERR_TerrainSites : ERR_GeneratedSites
|
|||||||
{
|
{
|
||||||
if (m_Started || !Replication.IsServer() || !definition || !definition.Valid() || !GetGame().GetWorldEntity()) return false;
|
if (m_Started || !Replication.IsServer() || !definition || !definition.Valid() || !GetGame().GetWorldEntity()) return false;
|
||||||
GetGame().GetWorldEntity().GetWorldBounds(m_Low, m_High);
|
GetGame().GetWorldEntity().GetWorldBounds(m_Low, m_High);
|
||||||
if (!Bounds(m_Low, m_High)) { m_Error = "Terrain bounds must span 2-100 km on each axis."; return false; }
|
if (!Bounds(m_Low, m_High)) { m_Error = "Terrain bounds must span 1-100 km on each axis."; return false; }
|
||||||
AIWorld world = GetGame().GetAIWorld();
|
AIWorld world = GetGame().GetAIWorld();
|
||||||
if (!world || !world.GetNavmeshWorldComponent("Soldiers")) { m_Error = "Terrain requires its own Soldiers navigation mesh."; return false; }
|
if (!world || !world.GetNavmeshWorldComponent("Soldiers")) { m_Error = "Terrain requires its own Soldiers navigation mesh."; return false; }
|
||||||
m_Started = true; m_Definition = definition; definition.TerrainGenerated = true;
|
m_Started = true; m_Definition = definition; definition.TerrainGenerated = true;
|
||||||
m_Spacing = Spacing(m_Low, m_High);
|
m_Spacing = Spacing(m_Low, m_High);
|
||||||
// Resolve the terrain's airport first, then keep the prison in escape range.
|
// Resolve a clear landing zone first, then keep the prison in escape range.
|
||||||
array<int> order = {ERR_LocationKind.EXTRACTION, ERR_LocationKind.PRISON, ERR_LocationKind.RADIO, ERR_LocationKind.DEPOT, ERR_LocationKind.HOSPITAL, ERR_LocationKind.MORTAR, ERR_LocationKind.OUTPOST};
|
array<int> order = {ERR_LocationKind.EXTRACTION, ERR_LocationKind.PRISON, ERR_LocationKind.RADIO, ERR_LocationKind.DEPOT, ERR_LocationKind.HOSPITAL, ERR_LocationKind.MORTAR, ERR_LocationKind.OUTPOST};
|
||||||
foreach (int kind : order)
|
foreach (int kind : order)
|
||||||
foreach (ERR_SiteDefinition site : definition.Sites)
|
foreach (ERR_SiteDefinition site : definition.Sites)
|
||||||
@@ -37,7 +45,7 @@ class ERR_TerrainSites : ERR_GeneratedSites
|
|||||||
site.PlacementResolved = false;
|
site.PlacementResolved = false;
|
||||||
// The queue, rather than RandomClear, owns placement including extraction.
|
// The queue, rather than RandomClear, owns placement including extraction.
|
||||||
site.RandomClear = false;
|
site.RandomClear = false;
|
||||||
if (kind == ERR_LocationKind.EXTRACTION) { site.RequireAirfield = true; site.AircraftOffset = vector.Zero; }
|
if (kind == ERR_LocationKind.EXTRACTION) { site.RequireAirfield = false; site.Label = "Extraction landing zone"; site.AircraftOffset = vector.Zero; }
|
||||||
if (kind == ERR_LocationKind.DEPOT) site.Label = "Supply cache";
|
if (kind == ERR_LocationKind.DEPOT) site.Label = "Supply cache";
|
||||||
m_Pending.Insert(site);
|
m_Pending.Insert(site);
|
||||||
}
|
}
|
||||||
@@ -62,89 +70,74 @@ class ERR_TerrainSites : ERR_GeneratedSites
|
|||||||
}
|
}
|
||||||
protected bool Navigable(vector position)
|
protected bool Navigable(vector position)
|
||||||
{
|
{
|
||||||
|
m_NavigationReason = "";
|
||||||
NavmeshWorldComponent mesh = GetGame().GetAIWorld().GetNavmeshWorldComponent("Soldiers");
|
NavmeshWorldComponent mesh = GetGame().GetAIWorld().GetNavmeshWorldComponent("Soldiers");
|
||||||
if (!mesh) return false;
|
if (!mesh) { m_NavigationReason = "Soldiers navmesh unavailable"; return false; }
|
||||||
if (!mesh.IsTileLoaded(position)) { m_WaitingNav = mesh.LoadTileIn(position); return false; }
|
if (!mesh.IsTileLoaded(position))
|
||||||
|
{
|
||||||
|
m_WaitingNav = mesh.LoadTileIn(position);
|
||||||
|
m_NavigationReason = "navmesh tile unavailable";
|
||||||
|
if (m_WaitingNav) m_NavigationReason = "waiting for navmesh tile";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
vector reachable;
|
vector reachable;
|
||||||
return mesh.GetReachablePoint(position, 10, reachable);
|
if (mesh.GetReachablePoint(position, 10, reachable)) return true;
|
||||||
|
m_NavigationReason = "no reachable AI ground";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
protected bool Survey(ERR_SiteDefinition site, vector position, float heading, out float floor)
|
protected bool Survey(ERR_SiteDefinition site, vector position, float heading, out float floor)
|
||||||
{
|
{
|
||||||
if (!m_Terrain.Site(site, position, heading, floor)) { m_GeometryRejected++; return false; }
|
if (!m_Terrain.Site(site, position, heading, floor, PrisonAirportBuffer(m_Low, m_High))) { m_GeometryRejected++; RecordRejection(m_Terrain.Rejection()); return false; }
|
||||||
vector ground = Vector(position[0], floor, position[2]);
|
vector ground = Vector(position[0], floor, position[2]);
|
||||||
if (!Navigable(ground)) { m_NavigationRejected++; return false; }
|
// Aircraft spawn at the centre's terrain height, not the camp grid's minimum.
|
||||||
if (site.Guarded && !Navigable(ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.GuardOffset, heading)))) { m_NavigationRejected++; return false; }
|
// Using the minimum here falsely steepens the uphill edge of a valid pad.
|
||||||
if (site.ResponseCount > 0 && !Navigable(ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.ResponseOffset, heading)))) { m_NavigationRejected++; return false; }
|
if (site.Kind == ERR_LocationKind.EXTRACTION)
|
||||||
|
{
|
||||||
|
ground = ERR_Actors.Ground(position);
|
||||||
|
floor = ground[1];
|
||||||
|
}
|
||||||
|
if (!Navigable(ground)) { m_NavigationRejected++; RecordRejection(m_NavigationReason); return false; }
|
||||||
|
if (site.Guarded && !Navigable(ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.GuardOffset, heading)))) { m_NavigationRejected++; RecordRejection("guard area: " + m_NavigationReason); return false; }
|
||||||
|
if (site.ResponseCount > 0 && !Navigable(ERR_Actors.Ground(position + ERR_CampTerrain.Rotate(site.ResponseOffset, heading)))) { m_NavigationRejected++; RecordRejection("patrol area: " + m_NavigationReason); return false; }
|
||||||
if (site.Kind != ERR_LocationKind.EXTRACTION) return true;
|
if (site.Kind != ERR_LocationKind.EXTRACTION) return true;
|
||||||
float padFloor;
|
float padFloor;
|
||||||
if (m_Terrain.Clear(ground, heading, 14, 0.8, padFloor))
|
if (m_Terrain.Clear(ground, heading, 14, 0.8, padFloor))
|
||||||
{
|
{
|
||||||
bool primaryClear;
|
bool primaryClear = ERR_AirfieldPlacement.ClearGround(ground);
|
||||||
if (site.RequireAirfield) primaryClear = ERR_AirfieldPlacement.Clear(ground);
|
if (!primaryClear) RecordRejection("primary aircraft clearance");
|
||||||
else primaryClear = ERR_AirfieldPlacement.ClearGround(ground);
|
else if (!ERR_RescueLanding.Fits(ground)) RecordRejection("secondary aircraft pad");
|
||||||
if (primaryClear && ERR_RescueLanding.Fits(ground)) return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
else RecordRejection("landing zone: " + m_Terrain.Rejection());
|
||||||
m_PadRejected++; return false;
|
m_PadRejected++; return false;
|
||||||
}
|
}
|
||||||
protected vector SamplePosition(ERR_SiteDefinition site)
|
protected vector SamplePosition(ERR_SiteDefinition site)
|
||||||
{
|
{
|
||||||
if (site.Kind != ERR_LocationKind.EXTRACTION || m_Airports.m_Positions.IsEmpty())
|
// Helicopters need a clear pad, not airport infrastructure or an airport-first pass.
|
||||||
return Vector(Math.RandomFloat(m_Low[0] + 60, m_High[0] - 60), 0, Math.RandomFloat(m_Low[2] + 60, m_High[2] - 60));
|
return Vector(Math.RandomFloat(m_Low[0] + 60, m_High[0] - 60), 0, Math.RandomFloat(m_Low[2] + 60, m_High[2] - 60));
|
||||||
vector centre = m_Airports.m_Positions[Math.RandomInt(0, m_Airports.m_Positions.Count())];
|
|
||||||
float angle = Math.RandomFloat(0, Math.PI2), radius = Math.RandomFloat(0, 450);
|
|
||||||
return centre + Vector(Math.Cos(angle) * radius, 0, Math.Sin(angle) * radius);
|
|
||||||
}
|
|
||||||
protected bool PrepareAirports()
|
|
||||||
{
|
|
||||||
if (m_AirportsReady) return true;
|
|
||||||
// The scenario ticks every 250ms. One 2km tile per tick made Chernarus
|
|
||||||
// spend roughly 48 seconds just waiting between airport queries. Batch
|
|
||||||
// inexpensive tiles, but yield after 4ms or eight queries. A native query
|
|
||||||
// itself cannot be interrupted, so check the budget after every call.
|
|
||||||
int started = System.GetTickCount();
|
|
||||||
for (int tile = 0; tile < 8; tile++)
|
|
||||||
{
|
|
||||||
m_Airports.Update();
|
|
||||||
if (m_Airports.Complete() || System.GetTickCount() - started >= 4) break;
|
|
||||||
}
|
|
||||||
if (!m_Airports.Complete()) return false;
|
|
||||||
if (m_Airports.m_Positions.IsEmpty())
|
|
||||||
{
|
|
||||||
// A painted runway or an island without an airport must not require a
|
|
||||||
// connector or administrator coordinates. Survey a helicopter landing zone
|
|
||||||
// with the same ground/navmesh/aircraft checks and finite placement budget.
|
|
||||||
foreach (ERR_SiteDefinition site : m_Pending)
|
|
||||||
if (site.Kind == ERR_LocationKind.EXTRACTION)
|
|
||||||
{
|
|
||||||
site.RequireAirfield = false;
|
|
||||||
site.Label = "Extraction landing zone";
|
|
||||||
}
|
|
||||||
Print("Reintroduced [terrain]: no airport infrastructure found; surveying a clear helicopter extraction landing zone");
|
|
||||||
}
|
|
||||||
PrintFormat("Reintroduced [generation]: airport survey ready in %1 ms; airports=%2", System.GetTickCount() - m_Began, m_Airports.m_Positions.Count());
|
|
||||||
m_AirportsReady = true; m_Began = System.GetTickCount();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
override ERR_PrepareResult Tick()
|
override ERR_PrepareResult Tick()
|
||||||
{
|
{
|
||||||
if (m_Result != ERR_PrepareResult.PENDING) return m_Result;
|
if (m_Result != ERR_PrepareResult.PENDING) return m_Result;
|
||||||
if (!m_Started || !Replication.IsServer()) return ERR_PrepareResult.FAILED;
|
if (!m_Started || !Replication.IsServer()) return ERR_PrepareResult.FAILED;
|
||||||
if (!PrepareAirports()) return m_Result;
|
|
||||||
int tick = System.GetTickCount();
|
int tick = System.GetTickCount();
|
||||||
while (m_Index < m_Pending.Count())
|
while (m_Index < m_Pending.Count())
|
||||||
{
|
{
|
||||||
if (m_StartupOnly && StartupReady()) return ERR_PrepareResult.PENDING;
|
if (m_StartupOnly && StartupReady()) return ERR_PrepareResult.PENDING;
|
||||||
ERR_SiteDefinition site = m_Pending[m_Index];
|
ERR_SiteDefinition site = m_Pending[m_Index];
|
||||||
if (m_Attempts >= 12000 || System.GetTickCount() - m_Began >= 30000)
|
ReportProgress(site);
|
||||||
|
if (m_Attempts >= SearchAttempts() || System.GetTickCount() - m_Began >= SearchMilliseconds())
|
||||||
{
|
{
|
||||||
PrintFormat("Reintroduced [terrain survey exhausted]: id=%1 attempts=%2 rejected geometry=%3 navigation=%4 aircraft=%5", site.Id, m_Attempts, m_GeometryRejected, m_NavigationRejected, m_PadRejected);
|
PrintFormat("Reintroduced [terrain survey exhausted]: id=%1 attempts=%2 rejected geometry=%3 navigation=%4 aircraft=%5", site.Id, m_Attempts, m_GeometryRejected, m_NavigationRejected, m_PadRejected);
|
||||||
|
ReportSearch(site, "exhausted");
|
||||||
if (!SkipOptional(site))
|
if (!SkipOptional(site))
|
||||||
{
|
{
|
||||||
m_Error = "Terrain has no safe navigable placement for " + site.Label + ". Check this map's Soldiers navmesh, terrain clearance and size; no foreign-map fallback was used.";
|
m_Error = "Terrain has no safe navigable placement for " + site.Label + " (" + site.Id + "). Checks: " + RejectionSummary();
|
||||||
m_Result = ERR_PrepareResult.FAILED; return m_Result;
|
m_Result = ERR_PrepareResult.FAILED; return m_Result;
|
||||||
}
|
}
|
||||||
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount(); m_HaveCandidate = false;
|
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount(); m_HaveCandidate = false;
|
||||||
m_GeometryRejected = 0; m_NavigationRejected = 0; m_PadRejected = 0;
|
m_GeometryRejected = 0; m_NavigationRejected = 0; m_PadRejected = 0;
|
||||||
|
ClearDiagnostics();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -157,11 +150,14 @@ class ERR_TerrainSites : ERR_GeneratedSites
|
|||||||
vector position = m_Candidate;
|
vector position = m_Candidate;
|
||||||
float heading = m_CandidateHeading, floor;
|
float heading = m_CandidateHeading, floor;
|
||||||
m_WaitingNav = false;
|
m_WaitingNav = false;
|
||||||
if (Separated(site, position, false) && Survey(site, position, heading, floor))
|
bool separated = Separated(site, position, false);
|
||||||
|
if (!separated) RecordRejection("site spacing / escape boundary");
|
||||||
|
if (separated && Survey(site, position, heading, floor))
|
||||||
{
|
{
|
||||||
position[1] = floor + 0.02;
|
position[1] = floor + 0.02;
|
||||||
site.Position = position; site.Heading = heading; site.PlacementResolved = true;
|
site.Position = position; site.Heading = heading; site.PlacementResolved = true;
|
||||||
PrintFormat("Reintroduced [terrain site]: id=%1 position=%2 heading=%3 attempts=%4", site.Id, position, heading, m_Attempts);
|
PrintFormat("Reintroduced [terrain site]: id=%1 position=%2 heading=%3 attempts=%4", site.Id, position, heading, m_Attempts);
|
||||||
|
ReportSearch(site, "placed"); ClearDiagnostics();
|
||||||
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
m_Index++; m_Attempts = 0; m_Began = System.GetTickCount();
|
||||||
m_GeometryRejected = 0; m_NavigationRejected = 0; m_PadRejected = 0;
|
m_GeometryRejected = 0; m_NavigationRejected = 0; m_PadRejected = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// World-authored pumps survive a game-mode takeover. Their native registrations
|
||||||
|
// belong to the discarded manager and must move to the replacement on each peer.
|
||||||
|
modded class SCR_SupportStationManagerComponent
|
||||||
|
{
|
||||||
|
void ERR_CollectTerrainStations(array<SCR_BaseSupportStationComponent> stations)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_mSupportStations.Count(); i++)
|
||||||
|
{
|
||||||
|
array<SCR_BaseSupportStationComponent> registered = m_mSupportStations.GetElement(i);
|
||||||
|
if (!registered) continue;
|
||||||
|
foreach (SCR_BaseSupportStationComponent station : registered)
|
||||||
|
if (station && !stations.Contains(station)) stations.Insert(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override void OnPostInit(IEntity owner)
|
||||||
|
{
|
||||||
|
super.OnPostInit(owner);
|
||||||
|
if (ERR_TerrainTakeoverMode.Cast(owner) && GetInstance() == this)
|
||||||
|
GetGame().ERR_RestoreTerrainSupportStations(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modded class SCR_BaseSupportStationComponent
|
||||||
|
{
|
||||||
|
bool ERR_CanRestoreTerrainStation()
|
||||||
|
{
|
||||||
|
IEntity owner = GetOwner();
|
||||||
|
return owner && GetGame() && owner.GetWorld() == GetGame().GetWorld()
|
||||||
|
&& UsesRange() && m_eCurrentDamageState != EDamageState.DESTROYED;
|
||||||
|
}
|
||||||
|
void ERR_TerrainStationRestored(SCR_SupportStationManagerComponent manager) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
modded class SCR_BaseItemSupportStationComponent
|
||||||
|
{
|
||||||
|
override void ERR_TerrainStationRestored(SCR_SupportStationManagerComponent manager)
|
||||||
|
{
|
||||||
|
super.ERR_TerrainStationRestored(manager);
|
||||||
|
// Item cleanup must remove the station from the manager it now belongs to.
|
||||||
|
if (m_ERRItemStationInitialized && UsesRange()) m_ERRItemStationManager = manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modded class ArmaReforgerScripted
|
||||||
|
{
|
||||||
|
protected ref array<SCR_BaseSupportStationComponent> m_ERRTerrainSupportStations = {};
|
||||||
|
void ERR_CaptureTerrainSupportStations(SCR_SupportStationManagerComponent original)
|
||||||
|
{
|
||||||
|
m_ERRTerrainSupportStations.Clear();
|
||||||
|
if (original) original.ERR_CollectTerrainStations(m_ERRTerrainSupportStations);
|
||||||
|
}
|
||||||
|
void ERR_RestoreTerrainSupportStations(SCR_SupportStationManagerComponent manager)
|
||||||
|
{
|
||||||
|
if (!manager) return;
|
||||||
|
int restored;
|
||||||
|
foreach (SCR_BaseSupportStationComponent station : m_ERRTerrainSupportStations)
|
||||||
|
{
|
||||||
|
if (!station || !station.ERR_CanRestoreTerrainStation()) continue;
|
||||||
|
manager.AddSupportStation(station);
|
||||||
|
station.ERR_TerrainStationRestored(manager);
|
||||||
|
restored++;
|
||||||
|
}
|
||||||
|
m_ERRTerrainSupportStations.Clear();
|
||||||
|
PrintFormat("Reintroduced [terrain support]: retained %1 existing support stations", restored);
|
||||||
|
}
|
||||||
|
override protected void OnBeforeWorldCleanup()
|
||||||
|
{
|
||||||
|
m_ERRTerrainSupportStations.Clear();
|
||||||
|
super.OnBeforeWorldCleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,11 @@ enum ERR_TerrainTakeoverStage
|
|||||||
|
|
||||||
class ERR_TerrainTakeoverRules
|
class ERR_TerrainTakeoverRules
|
||||||
{
|
{
|
||||||
|
static ResourceName Bootstrap(bool hasNativeChat)
|
||||||
|
{
|
||||||
|
if (hasNativeChat) return "{9D182739ABEF405C}Prefabs/ERR/TerrainTakeover.et";
|
||||||
|
return "{DA8E364BC095712F}Prefabs/ERR/TerrainTakeoverWithChat.et";
|
||||||
|
}
|
||||||
static bool TimedOut(float elapsed) { return elapsed >= 10; }
|
static bool TimedOut(float elapsed) { return elapsed >= 10; }
|
||||||
static bool MayDrain(float elapsed, bool sameMode) { return elapsed >= 0.5 && sameMode; }
|
static bool MayDrain(float elapsed, bool sameMode) { return elapsed >= 0.5 && sameMode; }
|
||||||
static bool MayCreate(float elapsed, bool empty) { return empty && !TimedOut(elapsed); }
|
static bool MayCreate(float elapsed, bool empty) { return empty && !TimedOut(elapsed); }
|
||||||
@@ -68,6 +73,7 @@ modded class ArmaReforgerScripted
|
|||||||
protected ERR_TerrainTakeoverStage m_ERRTerrainStage;
|
protected ERR_TerrainTakeoverStage m_ERRTerrainStage;
|
||||||
protected float m_ERRTerrainElapsed;
|
protected float m_ERRTerrainElapsed;
|
||||||
protected RadioManagerEntity m_ERRTerrainRadio;
|
protected RadioManagerEntity m_ERRTerrainRadio;
|
||||||
|
protected BaseChatEntity m_ERRTerrainChat;
|
||||||
protected EntityID m_ERRTerrainOldLoadoutId;
|
protected EntityID m_ERRTerrainOldLoadoutId;
|
||||||
protected BaseWorld m_ERRTerrainWorld;
|
protected BaseWorld m_ERRTerrainWorld;
|
||||||
protected SCR_BaseGameMode m_ERRTerrainOriginal;
|
protected SCR_BaseGameMode m_ERRTerrainOriginal;
|
||||||
@@ -110,6 +116,7 @@ modded class ArmaReforgerScripted
|
|||||||
m_ERRTerrainStage = ERR_TerrainTakeoverStage.INACTIVE;
|
m_ERRTerrainStage = ERR_TerrainTakeoverStage.INACTIVE;
|
||||||
m_ERRTerrainElapsed = 0;
|
m_ERRTerrainElapsed = 0;
|
||||||
m_ERRTerrainRadio = null;
|
m_ERRTerrainRadio = null;
|
||||||
|
m_ERRTerrainChat = null;
|
||||||
m_ERRTerrainOldLoadoutId = EntityID.INVALID;
|
m_ERRTerrainOldLoadoutId = EntityID.INVALID;
|
||||||
m_ERRTerrainWorld = null;
|
m_ERRTerrainWorld = null;
|
||||||
m_ERRTerrainOriginal = null;
|
m_ERRTerrainOriginal = null;
|
||||||
@@ -130,7 +137,7 @@ modded class ArmaReforgerScripted
|
|||||||
ERR_FailTerrainTakeover("Select a plain scenario with SCR_BaseGameMode and a Soldiers navmesh; original scenario retained.");
|
ERR_FailTerrainTakeover("Select a plain scenario with SCR_BaseGameMode and a Soldiers navmesh; original scenario retained.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Resource prefab = Resource.Load("{9D182739ABEF405C}Prefabs/ERR/TerrainTakeover.et");
|
Resource prefab = Resource.Load(ERR_TerrainTakeoverRules.Bootstrap(GetChat() != null));
|
||||||
if (!prefab || !prefab.IsValid())
|
if (!prefab || !prefab.IsValid())
|
||||||
{
|
{
|
||||||
ERR_FailTerrainTakeover("Escape bootstrap prefab is missing; original scenario retained.");
|
ERR_FailTerrainTakeover("Escape bootstrap prefab is missing; original scenario retained.");
|
||||||
@@ -210,8 +217,13 @@ modded class ArmaReforgerScripted
|
|||||||
{
|
{
|
||||||
SCR_EditorManagerCore editorCore = SCR_EditorManagerCore.Cast(SCR_EditorManagerCore.GetInstance(SCR_EditorManagerCore));
|
SCR_EditorManagerCore editorCore = SCR_EditorManagerCore.Cast(SCR_EditorManagerCore.GetInstance(SCR_EditorManagerCore));
|
||||||
if (editorCore) editorCore.ERR_SetTerrainModeEvents(m_ERRTerrainOriginal, false);
|
if (editorCore) editorCore.ERR_SetTerrainModeEvents(m_ERRTerrainOriginal, false);
|
||||||
array<IEntity> managers = {m_ERRTerrainOriginal, GetLoadoutManager(), GetFactionManager(), GetPerceptionManager(), GetChat()};
|
array<IEntity> managers = {m_ERRTerrainOriginal, GetLoadoutManager(), GetFactionManager(), GetPerceptionManager()};
|
||||||
ERR_TerrainTakeoverReplication.CollectDelegates(SCR_DelegateFactionManagerComponent.GetInstance(), managers);
|
ERR_TerrainTakeoverReplication.CollectDelegates(SCR_DelegateFactionManagerComponent.GetInstance(), managers);
|
||||||
|
// Native chat unregister can clear a newer registration after replication
|
||||||
|
// delivers the replacement. Keep the terrain's chat on both peers instead.
|
||||||
|
m_ERRTerrainChat = GetChat();
|
||||||
|
if (m_ERRTerrainChat && !ERR_TerrainTakeoverReplication.RetainManager(m_ERRTerrainChat, managers))
|
||||||
|
{ ERR_FailTerrainTakeover("Could not retain the native chat service; original scenario retained."); return; }
|
||||||
ChimeraWorld chimera = ChimeraWorld.CastFrom(GetWorld());
|
ChimeraWorld chimera = ChimeraWorld.CastFrom(GetWorld());
|
||||||
if (chimera) m_ERRTerrainRadio = chimera.GetRadioManager();
|
if (chimera) m_ERRTerrainRadio = chimera.GetRadioManager();
|
||||||
// Native radio teardown clears the world pointer even after a replacement
|
// Native radio teardown clears the world pointer even after a replacement
|
||||||
@@ -230,7 +242,8 @@ modded class ArmaReforgerScripted
|
|||||||
ancestor = ancestor.GetParent();
|
ancestor = ancestor.GetParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Print("Reintroduced [terrain takeover]: stopping original scenario; preserving radio manager");
|
Print("Reintroduced [terrain takeover]: stopping original scenario; preserving radio and chat managers");
|
||||||
|
ERR_CaptureTerrainSupportStations(SCR_SupportStationManagerComponent.Cast(m_ERRTerrainOriginal.FindComponent(SCR_SupportStationManagerComponent)));
|
||||||
m_ERRTerrainOriginal.OnGameEnd();
|
m_ERRTerrainOriginal.OnGameEnd();
|
||||||
if (m_DataCollectorComponent && m_DataCollectorComponent.GetOwner() == m_ERRTerrainOriginal) m_DataCollectorComponent = null;
|
if (m_DataCollectorComponent && m_DataCollectorComponent.GetOwner() == m_ERRTerrainOriginal) m_DataCollectorComponent = null;
|
||||||
SCR_EntityCatalogManagerComponent.ERR_ReleaseTerrainCatalog(m_ERRTerrainOriginal);
|
SCR_EntityCatalogManagerComponent.ERR_ReleaseTerrainCatalog(m_ERRTerrainOriginal);
|
||||||
@@ -258,7 +271,7 @@ modded class ArmaReforgerScripted
|
|||||||
protected bool ERR_TerrainRegistrationsEmpty()
|
protected bool ERR_TerrainRegistrationsEmpty()
|
||||||
{
|
{
|
||||||
ChimeraWorld chimera = ChimeraWorld.CastFrom(GetWorld());
|
ChimeraWorld chimera = ChimeraWorld.CastFrom(GetWorld());
|
||||||
return !GetGameMode() && !GetLoadoutManager() && !GetFactionManager() && !GetPerceptionManager() && !GetChat() && (!chimera || chimera.GetRadioManager() == m_ERRTerrainRadio) && !SCR_EntityCatalogManagerComponent.GetInstance() && !m_DataCollectorComponent;
|
return !GetGameMode() && !GetLoadoutManager() && !GetFactionManager() && !GetPerceptionManager() && GetChat() == m_ERRTerrainChat && (!chimera || chimera.GetRadioManager() == m_ERRTerrainRadio) && !SCR_EntityCatalogManagerComponent.GetInstance() && !m_DataCollectorComponent;
|
||||||
}
|
}
|
||||||
protected void ERR_CreateTerrainMode()
|
protected void ERR_CreateTerrainMode()
|
||||||
{
|
{
|
||||||
@@ -277,9 +290,9 @@ modded class ArmaReforgerScripted
|
|||||||
if (!marker) { ERR_FailTerrainTakeover("Could not create configured airport marker; restart the scenario."); return; }
|
if (!marker) { ERR_FailTerrainTakeover("Could not create configured airport marker; restart the scenario."); return; }
|
||||||
marker.SetName("ERR_Airfield_" + m_ERRTerrainMarkerSlots[i].ToString());
|
marker.SetName("ERR_Airfield_" + m_ERRTerrainMarkerSlots[i].ToString());
|
||||||
}
|
}
|
||||||
ERR_GameMode mode = ERR_GameMode.Cast(SpawnEntityPrefab(Resource.Load("{9D182739ABEF405C}Prefabs/ERR/TerrainTakeover.et"), GetWorld()));
|
ERR_GameMode mode = ERR_GameMode.Cast(SpawnEntityPrefab(Resource.Load(ERR_TerrainTakeoverRules.Bootstrap(m_ERRTerrainChat != null)), GetWorld()));
|
||||||
if (!mode || GetGameMode() != mode) { ERR_FailTerrainTakeover("Escape game mode could not register; restart the scenario."); return; }
|
if (!mode || GetGameMode() != mode) { ERR_FailTerrainTakeover("Escape game mode could not register; restart the scenario."); return; }
|
||||||
if (!ERR_TerrainTakeoverReplication.Link(mode)) { ERR_FailTerrainTakeover("Escape replication hierarchy could not register; restart the scenario."); return; }
|
if (!ERR_TerrainTakeoverReplication.Link(mode, !m_ERRTerrainChat)) { ERR_FailTerrainTakeover("Escape replication hierarchy could not register; restart the scenario."); return; }
|
||||||
SCR_EditorManagerCore editorCore = SCR_EditorManagerCore.Cast(SCR_EditorManagerCore.GetInstance(SCR_EditorManagerCore));
|
SCR_EditorManagerCore editorCore = SCR_EditorManagerCore.Cast(SCR_EditorManagerCore.GetInstance(SCR_EditorManagerCore));
|
||||||
if (editorCore) editorCore.ERR_SetTerrainModeEvents(mode, true);
|
if (editorCore) editorCore.ERR_SetTerrainModeEvents(mode, true);
|
||||||
m_ERRTerrainStage = ERR_TerrainTakeoverStage.RUNNING;
|
m_ERRTerrainStage = ERR_TerrainTakeoverStage.RUNNING;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ modded class ArmaReforgerScripted
|
|||||||
protected ref array<IEntity> m_ERRClientOldManagers = {};
|
protected ref array<IEntity> m_ERRClientOldManagers = {};
|
||||||
protected bool m_ERRClientTerrainTakeover;
|
protected bool m_ERRClientTerrainTakeover;
|
||||||
bool ERR_IsClientTerrainTakeover() { return m_ERRClientTerrainTakeover; }
|
bool ERR_IsClientTerrainTakeover() { return m_ERRClientTerrainTakeover; }
|
||||||
|
bool ERR_ClientTerrainModePending()
|
||||||
|
{
|
||||||
|
return !Replication.IsServer() && !GetGameMode() && !m_ERRClientOldManagers.IsEmpty();
|
||||||
|
}
|
||||||
protected SCR_EntityCatalogManagerComponent m_ERROldCatalog;
|
protected SCR_EntityCatalogManagerComponent m_ERROldCatalog;
|
||||||
protected EntityID m_ERROldLoadoutId;
|
protected EntityID m_ERROldLoadoutId;
|
||||||
protected SCR_AdditionalGameModeSettingsComponent m_ERROldSettings;
|
protected SCR_AdditionalGameModeSettingsComponent m_ERROldSettings;
|
||||||
@@ -57,7 +61,6 @@ modded class ArmaReforgerScripted
|
|||||||
m_ERRClientOldManagers.Insert(GetLoadoutManager());
|
m_ERRClientOldManagers.Insert(GetLoadoutManager());
|
||||||
m_ERRClientOldManagers.Insert(GetFactionManager());
|
m_ERRClientOldManagers.Insert(GetFactionManager());
|
||||||
m_ERRClientOldManagers.Insert(GetPerceptionManager());
|
m_ERRClientOldManagers.Insert(GetPerceptionManager());
|
||||||
m_ERRClientOldManagers.Insert(GetChat());
|
|
||||||
}
|
}
|
||||||
override void UnregisterLoadoutManager(SCR_LoadoutManager instance)
|
override void UnregisterLoadoutManager(SCR_LoadoutManager instance)
|
||||||
{
|
{
|
||||||
@@ -89,9 +92,17 @@ modded class ArmaReforgerScripted
|
|||||||
void ERR_BeginClientTerrainTakeover(ERR_TerrainTakeoverMode incoming)
|
void ERR_BeginClientTerrainTakeover(ERR_TerrainTakeoverMode incoming)
|
||||||
{
|
{
|
||||||
if (m_ERRClientOldManagers.IsEmpty()) return;
|
if (m_ERRClientOldManagers.IsEmpty()) return;
|
||||||
|
// Match authority retention before deleting any original parent. No second
|
||||||
|
// chat entity is created when the terrain already supplies one.
|
||||||
|
if (GetChat() && !ERR_TerrainTakeoverReplication.RetainManager(GetChat(), m_ERRClientOldManagers))
|
||||||
|
{
|
||||||
|
Print("Reintroduced [terrain client]: could not retain native chat; original managers retained", LogLevel.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_ERRClientTerrainTakeover = true;
|
m_ERRClientTerrainTakeover = true;
|
||||||
SCR_BaseGameMode mode = SCR_BaseGameMode.Cast(m_ERRClientOldManagers[0]);
|
SCR_BaseGameMode mode = SCR_BaseGameMode.Cast(m_ERRClientOldManagers[0]);
|
||||||
PrintFormat("Reintroduced [terrain client]: drain retained mode=%1 incoming=%2", mode, incoming);
|
PrintFormat("Reintroduced [terrain client]: drain retained mode=%1 incoming=%2", mode, incoming);
|
||||||
|
ERR_CaptureTerrainSupportStations(m_ERROldSupport);
|
||||||
if (mode) mode.OnGameEnd();
|
if (mode) mode.OnGameEnd();
|
||||||
// Owner entities can already be invalid while native destruction is deferred.
|
// Owner entities can already be invalid while native destruction is deferred.
|
||||||
// Compare the captured component itself, never clear a newer singleton.
|
// Compare the captured component itself, never clear a newer singleton.
|
||||||
|
|||||||
@@ -256,6 +256,25 @@ class ERR_TerrainTakeoverReplication
|
|||||||
if (delegate && delegate.GetOwner() && !entities.Contains(delegate.GetOwner())) entities.Insert(delegate.GetOwner());
|
if (delegate && delegate.GetOwner() && !entities.Contains(delegate.GetOwner())) entities.Insert(delegate.GetOwner());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Shared world services must survive removal of an old game-mode hierarchy.
|
||||||
|
static bool RetainManager(IEntity entity, array<IEntity> removed)
|
||||||
|
{
|
||||||
|
if (!entity || !removed || removed.Contains(entity)) return false;
|
||||||
|
IEntity ancestor = entity.GetParent();
|
||||||
|
while (ancestor)
|
||||||
|
{
|
||||||
|
if (removed.Contains(ancestor))
|
||||||
|
{
|
||||||
|
entity.GetParent().RemoveChild(entity, true);
|
||||||
|
if (entity.GetParent()) return false;
|
||||||
|
RplComponent rpl = SCR_EntityHelper.GetEntityRplComponent(entity);
|
||||||
|
if (rpl && rpl.GetNode()) rpl.GetNode().SetParent(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ancestor = ancestor.GetParent();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
protected static bool Parent(IEntity entity, IEntity parent)
|
protected static bool Parent(IEntity entity, IEntity parent)
|
||||||
{
|
{
|
||||||
RplComponent childRpl = SCR_EntityHelper.GetEntityRplComponent(entity);
|
RplComponent childRpl = SCR_EntityHelper.GetEntityRplComponent(entity);
|
||||||
@@ -267,11 +286,14 @@ class ERR_TerrainTakeoverReplication
|
|||||||
if (childNode.GetParent() != parentNode) childNode.SetParent(parentNode);
|
if (childNode.GetParent() != parentNode) childNode.SetParent(parentNode);
|
||||||
return childNode.GetParent() == parentNode;
|
return childNode.GetParent() == parentNode;
|
||||||
}
|
}
|
||||||
static bool Link(ERR_GameMode mode)
|
static bool Link(ERR_GameMode mode, bool ownsChat)
|
||||||
{
|
{
|
||||||
IEntity factions = GetGame().GetFactionManager();
|
IEntity factions = GetGame().GetFactionManager();
|
||||||
if (!factions || !Parent(factions, mode)) return false;
|
if (!factions || !Parent(factions, mode)) return false;
|
||||||
if (!Parent(GetGame().GetLoadoutManager(), mode) || !Parent(GetGame().GetChat(), mode)) return false;
|
if (!Parent(GetGame().GetLoadoutManager(), mode)) return false;
|
||||||
|
// Retained native chat stays world-owned. Only a newly supplied fallback
|
||||||
|
// belongs to this replacement mode's replication node.
|
||||||
|
if (ownsChat && !Parent(GetGame().GetChat(), mode)) return false;
|
||||||
SCR_DelegateFactionManagerComponent manager = SCR_DelegateFactionManagerComponent.GetInstance();
|
SCR_DelegateFactionManagerComponent manager = SCR_DelegateFactionManagerComponent.GetInstance();
|
||||||
if (!manager) return false;
|
if (!manager) return false;
|
||||||
map<Faction, SCR_EditableFactionComponent> delegates = new map<Faction, SCR_EditableFactionComponent>();
|
map<Faction, SCR_EditableFactionComponent> delegates = new map<Faction, SCR_EditableFactionComponent>();
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ class ERR_TerrainDisplayName
|
|||||||
{
|
{
|
||||||
if (seen.Contains(world)) break;
|
if (seen.Contains(world)) break;
|
||||||
seen.Insert(world);
|
seen.Insert(world);
|
||||||
|
// Native subscene names can be plain paths. They are already the loaded
|
||||||
|
// terrain, not GUID resources that LoadContainer can traverse safely.
|
||||||
|
// IsExternal/IsInternal also accept ordinary paths in the native runtime.
|
||||||
|
// Inspect the serialized GUID prefix without invoking resource resolution.
|
||||||
|
if (world.Length() < 18 || world.Substring(0, 1) != "{" || world.Substring(17, 1) != "}") break;
|
||||||
Resource resource = BaseContainerTools.LoadContainer(world);
|
Resource resource = BaseContainerTools.LoadContainer(world);
|
||||||
if (!resource || !resource.IsValid()) break;
|
if (!resource || !resource.IsValid()) break;
|
||||||
BaseContainer container = resource.GetResource().ToBaseContainer();
|
BaseContainer container = resource.GetResource().ToBaseContainer();
|
||||||
@@ -58,6 +63,18 @@ class ERR_TerrainDisplayName
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep the authored Escape header as the source of mission text.
|
||||||
|
class ERR_TerrainMissionText
|
||||||
|
{
|
||||||
|
static bool Load(out string description, out string details)
|
||||||
|
{
|
||||||
|
Resource resource = BaseContainerTools.LoadContainer("{C1E20667DCE324ED}Missions/ERR_Everon.conf");
|
||||||
|
if (!resource || !resource.IsValid()) return false;
|
||||||
|
BaseContainer header = resource.GetResource().ToBaseContainer();
|
||||||
|
return header && header.Get("m_sDescription", description) && header.Get("m_sDetails", details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Scenario selection still loads the terrain's header. Advertise the configured
|
// Scenario selection still loads the terrain's header. Advertise the configured
|
||||||
// Escape mode through the native DS name callback, then update local metadata
|
// Escape mode through the native DS name callback, then update local metadata
|
||||||
// only when the authority actually starts Escape or its bootstrap reaches a client.
|
// only when the authority actually starts Escape or its bootstrap reaches a client.
|
||||||
@@ -66,6 +83,9 @@ modded class ArmaReforgerScripted
|
|||||||
protected ref SCR_MissionHeader m_ERRPresentedTerrainHeader;
|
protected ref SCR_MissionHeader m_ERRPresentedTerrainHeader;
|
||||||
protected string m_ERROriginalTerrainTitle;
|
protected string m_ERROriginalTerrainTitle;
|
||||||
protected string m_ERROriginalTerrainGameMode;
|
protected string m_ERROriginalTerrainGameMode;
|
||||||
|
protected string m_ERROriginalTerrainDescription, m_ERROriginalTerrainDetails;
|
||||||
|
protected string m_ERRAppliedTerrainDescription, m_ERRAppliedTerrainDetails;
|
||||||
|
protected bool m_ERRTerrainTextApplied;
|
||||||
protected string m_ERRAppliedTerrainTitle;
|
protected string m_ERRAppliedTerrainTitle;
|
||||||
protected string m_ERRTitleWorld;
|
protected string m_ERRTitleWorld;
|
||||||
protected string m_ERRTerrainLabel;
|
protected string m_ERRTerrainLabel;
|
||||||
@@ -126,6 +146,14 @@ modded class ArmaReforgerScripted
|
|||||||
m_ERRAppliedTerrainTitle = ERR_TerrainMissionTitle(header);
|
m_ERRAppliedTerrainTitle = ERR_TerrainMissionTitle(header);
|
||||||
header.m_sName = m_ERRAppliedTerrainTitle;
|
header.m_sName = m_ERRAppliedTerrainTitle;
|
||||||
header.m_sGameMode = "Escape";
|
header.m_sGameMode = "Escape";
|
||||||
|
m_ERROriginalTerrainDescription = header.m_sDescription;
|
||||||
|
m_ERROriginalTerrainDetails = header.m_sDetails;
|
||||||
|
m_ERRTerrainTextApplied = ERR_TerrainMissionText.Load(m_ERRAppliedTerrainDescription, m_ERRAppliedTerrainDetails);
|
||||||
|
if (m_ERRTerrainTextApplied)
|
||||||
|
{
|
||||||
|
header.m_sDescription = m_ERRAppliedTerrainDescription;
|
||||||
|
header.m_sDetails = m_ERRAppliedTerrainDetails;
|
||||||
|
}
|
||||||
PrintFormat("Reintroduced [terrain presentation]: mission=%1; source scenario=%2", header.m_sName, header.GetHeaderResourceName());
|
PrintFormat("Reintroduced [terrain presentation]: mission=%1; source scenario=%2", header.m_sName, header.GetHeaderResourceName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,17 +168,30 @@ modded class ArmaReforgerScripted
|
|||||||
PrintFormat("Reintroduced [terrain presentation]: refreshed mission=%1; loaded world=%2", title, GetWorldFile());
|
PrintFormat("Reintroduced [terrain presentation]: refreshed mission=%1; loaded world=%2", title, GetWorldFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCR_MissionHeader ERR_TerrainLoadingHeader(SCR_MissionHeader requested)
|
||||||
|
{
|
||||||
|
if (!requested) return null;
|
||||||
|
SCR_MissionHeader header = SCR_MissionHeader.Cast(GetMissionHeader());
|
||||||
|
// A loading screen may hold a copy. Only replace the confirmed scenario;
|
||||||
|
// another incoming map must never inherit the outgoing world's text.
|
||||||
|
if (!header || header != m_ERRPresentedTerrainHeader || m_ERRPresentedTerrainWorld != GetWorld()) return requested;
|
||||||
|
if (requested != header && (requested.GetHeaderResourceName().IsEmpty() || requested.GetHeaderResourceName() != header.GetHeaderResourceName())) return requested;
|
||||||
|
ERR_RefreshTerrainPresentation();
|
||||||
|
return header;
|
||||||
|
}
|
||||||
string ERR_TerrainLoadingTitle(SCR_MissionHeader requested)
|
string ERR_TerrainLoadingTitle(SCR_MissionHeader requested)
|
||||||
{
|
{
|
||||||
if (!requested) return "";
|
SCR_MissionHeader header = ERR_TerrainLoadingHeader(requested);
|
||||||
SCR_MissionHeader header = SCR_MissionHeader.Cast(GetMissionHeader());
|
if (!header) return "";
|
||||||
// The loading screen can hold a separate copy of the same scenario header.
|
|
||||||
// Never replace another incoming scenario's title with the outgoing world.
|
|
||||||
if (!header || header != m_ERRPresentedTerrainHeader || m_ERRPresentedTerrainWorld != GetWorld()) return requested.m_sName;
|
|
||||||
if (requested != header && (requested.GetHeaderResourceName().IsEmpty() || requested.GetHeaderResourceName() != header.GetHeaderResourceName())) return requested.m_sName;
|
|
||||||
ERR_RefreshTerrainPresentation();
|
|
||||||
return header.m_sName;
|
return header.m_sName;
|
||||||
}
|
}
|
||||||
|
string ERR_TerrainLoadingDescription(SCR_MissionHeader requested)
|
||||||
|
{
|
||||||
|
SCR_MissionHeader header = ERR_TerrainLoadingHeader(requested);
|
||||||
|
if (!header) return "";
|
||||||
|
if (!header.m_sDetails.IsEmpty()) return header.m_sDetails;
|
||||||
|
return header.m_sDescription;
|
||||||
|
}
|
||||||
|
|
||||||
override void OnUpdate(BaseWorld world, float timeslice)
|
override void OnUpdate(BaseWorld world, float timeslice)
|
||||||
{
|
{
|
||||||
@@ -168,6 +209,11 @@ modded class ArmaReforgerScripted
|
|||||||
{
|
{
|
||||||
// A later change by another system belongs to that system.
|
// A later change by another system belongs to that system.
|
||||||
if (m_ERRPresentedTerrainHeader.m_sName == m_ERRAppliedTerrainTitle) m_ERRPresentedTerrainHeader.m_sName = m_ERROriginalTerrainTitle;
|
if (m_ERRPresentedTerrainHeader.m_sName == m_ERRAppliedTerrainTitle) m_ERRPresentedTerrainHeader.m_sName = m_ERROriginalTerrainTitle;
|
||||||
|
if (m_ERRTerrainTextApplied)
|
||||||
|
{
|
||||||
|
if (m_ERRPresentedTerrainHeader.m_sDescription == m_ERRAppliedTerrainDescription) m_ERRPresentedTerrainHeader.m_sDescription = m_ERROriginalTerrainDescription;
|
||||||
|
if (m_ERRPresentedTerrainHeader.m_sDetails == m_ERRAppliedTerrainDetails) m_ERRPresentedTerrainHeader.m_sDetails = m_ERROriginalTerrainDetails;
|
||||||
|
}
|
||||||
if (m_ERRPresentedTerrainHeader.m_sGameMode == "Escape") m_ERRPresentedTerrainHeader.m_sGameMode = m_ERROriginalTerrainGameMode;
|
if (m_ERRPresentedTerrainHeader.m_sGameMode == "Escape") m_ERRPresentedTerrainHeader.m_sGameMode = m_ERROriginalTerrainGameMode;
|
||||||
}
|
}
|
||||||
m_ERRPresentedTerrainHeader = null;
|
m_ERRPresentedTerrainHeader = null;
|
||||||
@@ -175,6 +221,9 @@ modded class ArmaReforgerScripted
|
|||||||
m_ERROriginalTerrainTitle = "";
|
m_ERROriginalTerrainTitle = "";
|
||||||
m_ERROriginalTerrainGameMode = "";
|
m_ERROriginalTerrainGameMode = "";
|
||||||
m_ERRAppliedTerrainTitle = "";
|
m_ERRAppliedTerrainTitle = "";
|
||||||
|
m_ERRTerrainTextApplied = false;
|
||||||
|
m_ERROriginalTerrainDescription = ""; m_ERROriginalTerrainDetails = "";
|
||||||
|
m_ERRAppliedTerrainDescription = ""; m_ERRAppliedTerrainDetails = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void OnBeforeWorldCleanup()
|
override protected void OnBeforeWorldCleanup()
|
||||||
@@ -186,28 +235,38 @@ modded class ArmaReforgerScripted
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vanilla copies the header title once, before the replicated Escape bootstrap
|
// Vanilla copies the header title once, before the replicated Escape bootstrap
|
||||||
// may arrive. Refresh only the title; do not recreate loading widgets/hints.
|
// may arrive. Refresh text in existing widgets; do not recreate widgets/hints.
|
||||||
modded class SCR_LoadingScreenComponent
|
modded class SCR_LoadingScreenComponent
|
||||||
{
|
{
|
||||||
protected ref SCR_MissionHeader m_ERRLoadingTerrainHeader;
|
protected ref SCR_MissionHeader m_ERRLoadingTerrainHeader;
|
||||||
protected string m_ERRLoadingTerrainTitle;
|
protected string m_ERRLoadingTerrainTitle, m_ERRLoadingTerrainDescription;
|
||||||
protected float m_ERRLoadingTerrainWait;
|
protected float m_ERRLoadingTerrainWait;
|
||||||
|
|
||||||
override void OnMissionDataRetrieved(SCR_MissionHeader header)
|
override void OnMissionDataRetrieved(SCR_MissionHeader header)
|
||||||
{
|
{
|
||||||
super.OnMissionDataRetrieved(header);
|
super.OnMissionDataRetrieved(header);
|
||||||
m_ERRLoadingTerrainHeader = header;
|
m_ERRLoadingTerrainHeader = header;
|
||||||
m_ERRLoadingTerrainTitle = ""; m_ERRLoadingTerrainWait = 0;
|
m_ERRLoadingTerrainTitle = ""; m_ERRLoadingTerrainDescription = ""; m_ERRLoadingTerrainWait = 0;
|
||||||
ERR_RefreshLoadingTerrainTitle();
|
ERR_RefreshLoadingTerrainTitle();
|
||||||
}
|
}
|
||||||
protected void ERR_RefreshLoadingTerrainTitle()
|
protected void ERR_RefreshLoadingTerrainTitle()
|
||||||
{
|
{
|
||||||
if (!m_ERRLoadingTerrainHeader || !m_Widgets || !m_Widgets.m_wTitle || !GetGame()) return;
|
if (!m_ERRLoadingTerrainHeader || !m_Widgets || !GetGame()) return;
|
||||||
string title = GetGame().ERR_TerrainLoadingTitle(m_ERRLoadingTerrainHeader);
|
string title = GetGame().ERR_TerrainLoadingTitle(m_ERRLoadingTerrainHeader);
|
||||||
if (title == m_ERRLoadingTerrainTitle) return;
|
if (m_Widgets.m_wTitle && title != m_ERRLoadingTerrainTitle)
|
||||||
|
{
|
||||||
m_ERRLoadingTerrainTitle = title;
|
m_ERRLoadingTerrainTitle = title;
|
||||||
m_Widgets.m_wTitle.SetText(title);
|
m_Widgets.m_wTitle.SetText(title);
|
||||||
}
|
}
|
||||||
|
// Match vanilla details/description precedence, translation and length limit.
|
||||||
|
string description = WidgetManager.Translate(GetGame().ERR_TerrainLoadingDescription(m_ERRLoadingTerrainHeader));
|
||||||
|
if (description.Length() > MAX_DESCRIPTION_LENGTH) description = description.Substring(0, MAX_DESCRIPTION_LENGTH) + "...";
|
||||||
|
if (m_Widgets.m_wDescription && description != m_ERRLoadingTerrainDescription)
|
||||||
|
{
|
||||||
|
m_ERRLoadingTerrainDescription = description;
|
||||||
|
m_Widgets.m_wDescription.SetText(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
override void Update(float timeSlice, float progress = 0, float minDurationRatio = 0)
|
override void Update(float timeSlice, float progress = 0, float minDurationRatio = 0)
|
||||||
{
|
{
|
||||||
super.Update(timeSlice, progress, minDurationRatio);
|
super.Update(timeSlice, progress, minDurationRatio);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user