Commit Graph
64 Commits
Author SHA1 Message Date
andrew e61922678b Add server validation, profile store, session launch
Introduce server validation and a session launch flow with persistent server profiles.

- Add ConnectAndValidateServer to Networking to validate handshake/timeouts and return human-friendly errors; avoid auto-connecting in transform send path and remove unconditional local connect on startup.
- Add ServerProfileStore (header + implementation) to persist server->saveFile bindings under Documents/My Games/.../CommonwealthOnline/server-profiles.json with thread-safe load/save, lookup, touch and bind operations.
- Add SessionLaunch (header + implementation) to handle launching validated sessions, first-time join flow (auto coc to SanctuaryExt, character creation menus, save binding), F4SE message handling and periodic Update processing.
- Update ServerBrowserBridge to parse/validate ports, use ConnectAndValidateServer, display joinLoading UI events, schedule validated session launch on the game task thread, and centralize join success/failure handling.
- Wire SessionLaunch into main.cpp (update loop and F4SE message hook).
- Improve direct-connect UI in app.js with client-side validation, port parsing, and handling of joinLoading events.

These changes provide better connection validation, user feedback during joins, and automatic handling for first-time server joins with persistence of associated saves.
2026-06-09 16:26:33 +12:00
andrew fb4e238fcc Add dynamic UI theme for server browser
Introduce runtime-driven UI theming for the server browser

- Expose PushUITheme() in F4TServerBrowserBridge and implement ColorToJson + PushUIThemeInternal to serialize HUD colors and invoke a JS hook.
- Call PushUITheme on UI initialization and when the browser is shown so the webview receives current HUD colors.
- Add frontend handler for "uiTheme" in app.js and a new components/theme.js that implements window.applyCoTheme to set CSS vars and tint the cursor SVG.
- Update styles.css to use RGB component CSS variables (--co-r/--co-g/--co-b and background equivalents) so colors can be overridden at runtime.
- Update index.html to include the new theme script and tweak cursor SVG stroke width; cursor asset updated as well.

This enables the plugin to synchronize the in-game HUD colors with the browser UI dynamically.
2026-06-09 15:19:03 +12:00
andrew 1f80b8ea49 Ensure main menu in MAIN_STATE before multiplayer
Add EnsureMainMenuMainState to try returning the main menu to MAIN_STATE by repeatedly invoking onCancelPress (up to 12 attempts with args true,false). Modify OpenMultiplayerMenu to early-return on null, call the new helper and log a warning if it cannot restore MAIN_STATE before proceeding, and preserve the existing uiMovie handling.
2026-06-09 14:56:38 +12:00
andrew d4d3268b12 Add runtime MainMenu injection and docs
Introduce a C++ runtime injection that adds a Multiplayer row to the Fallout 4 main menu instead of patching MainMenu.swf. Adds F4TMainMenuInject.h/cpp implementing injection, ITEM_PRESS handling, accept/button hooks, resync tasks and logging; integrates installation by calling MainMenuInject::Install() from PrismaUI init. Update PrismaUI to use the new helper and remove a duplicate IsMainMenuOnMainPanel implementation. Documentation updated to deprecate FFDec SWF patching (new docs/MainMenu_Injection.md, note in FFDEC guide, and setup.md) and restore-vanilla-mainmenu.ps1 messaging updated to instruct using the runtime injection.
2026-06-09 14:52:27 +12:00
andrew 9c84c9d4bc Add FFDec docs/tools and server-browser fixes
Add comprehensive FFDec walkthrough and short patch docs for safely adding a Multiplayer item to MainMenu.swf, plus helper scripts to extract the vanilla SWF and restore it (tools/extract_ba2.py, tools/restore-vanilla-mainmenu.ps1). Update exported MainMenu.as with a warning comment and remove an outdated exported PATCH markdown. Patch binary Interface/MainMenu.swf (updated).

Hardening fixes in the plugin: include GFx headers, avoid leaving the PrismaUI overlay focused after menu changes, only call OnBrowserHidden when the browser was actually visible, and add IsMainMenuOnMainPanel() so WatchMainMenuState ignores MainMenu when not on the MAIN_STATE. Ensure events are only dispatched when the browser is valid & visible (CanDispatchToBrowser) and make Scaleform UI hide the browser immediately during transitions. These changes prevent the overlay from staying focused during Settings transitions and stop JS events from being sent to a hidden/invalid view.
2026-06-08 22:26:00 +12:00
andrew fe620020be Add PrismaUI HTML server browser & integration
Integrate a PrismaUI_F4-based HTML server browser and related tooling. Adds a ThirdParty submodule (framework-F4-Conversion), UI views (CommonwealthOnline browser HTML/JS/CSS), and multiple plugin headers/sources to bridge PrismaUI/Scaleform, handle menu input, and manage server browser data and actions (mock server list, join/connect flow).

Key changes:
- New build/deploy scripts: build-prismaui.bat, build-all.bat, deploy-all.bat, deploy-ui.bat and a PowerShell helper for linking the Ultralight SDK (ULTRALIGHT_SDK_PATH, default F:\\UltralightSDK).
- Plugin additions: F4TPrismaUI, F4TScaleformUI, F4TServerBrowserBridge, F4TServerBrowserData, F4TMenuInput, F4TDebugOverlay and implementations to create/show/hide the HTML view, forward controller input, register Scaleform functions (openManager/closeManager), and push UI events.
- Networking: add ConnectToServer(host,port) and keep ConnectToLocalServer() as wrapper; update connection logs and error handling.
- Main menu SWF/AS updates: updated MainMenu.swf and MainMenu.as to call closeManager() when leaving multiplayer and to integrate open/close hooks.
- Documentation: plugin/setup.md updated with PrismaUI build/deploy instructions.
- Removed Main_ModManager.swf (deleted).

Primary intent: provide an in-game HTML server browser (toggleable with F9 or Scaleform calls), wire up controller input, and add build/deploy workflow for PrismaUI/Ultralight so developers can build and deploy the UI and plugin together. Mock server data is used for now; network join/connect plumbing is provided for local/dev servers.
2026-06-08 14:02:49 +12:00
andrew 2ced73f7b9 Handle runtime proxy 3D unload/recovery
Track and recover runtime proxy actors when their 3D meshes unload and reload. Adds slot flags (proxyObservedLoaded3D, proxyPending3DRecovery, proxy3DResetQueued), MaintainRuntimeProxy3DState and RecoverRuntimeProxyAfter3DReload to defer animation/puppet updates while mesh is missing, queue Reset3D and restore animation/locomotion state once fully loaded. Integrates checks throughout controller logic to skip smoothing/updates for proxies without 3D and updates slot initialization/reset. Also prevents puppet-driven motion/graph speed writes when the actor's 3D is unloaded to avoid corrupted PlaceAtMe proxies, with logging for diagnostics.
2026-06-07 21:31:28 +12:00
andrew 9b133b3109 Add proxy positioning API and CK-placed pool
Add a ProxyGameAPI (F4TProxyGameAPI.h/.cpp) exposing PositionRemoteActor which centralizes positioning logic, play-space resolution, MoveRefrToPosition-style moves, and 20Hz throttling bypass for forced moves. Replace ad-hoc SetPosition/SetHeading calls across the proxy controller to use the new API, ensuring correct cell/worldspace migration, logging, and move-rate throttling.

Introduce support for Creation Kit placed proxy refs: detect CK-placed proxies by editor ID prefix or base form, populate a per-cell proxy pool, and prefer assigning CK-placed proxies for runtime remotes (with fallbacks). Update proxy spawn/holding logic (skip smooth frame once, handle settle states, preserve/reuse CK pool entries) and improve worldspace/cell mismatch checks to avoid incorrect movement across play spaces.

Other changes: add CommonwealthOnline.esp resource file, update setup.md with the new local FormID (0x002666) for COPlayerProxy, enable animation sync gating to require loaded 3D, and small logging/message improvements.
2026-06-07 21:24:07 +12:00
andrew cc4d8aac5a Add Papyrus sync scripts and proxy spawn refactor
Add new Papyrus scripts (CoSync.psc, CoSyncPlayer.psc, CoSyncQuest.psc) providing native bindings and quest/player proxy logic for networking: connection/session APIs, entity management, world/weather/workshop/companion sync, consumable/pipboy/door/power-armor events, and proxy animation/initialization handlers. Refactor the proxy actor controller (F4TProxyActorController.cpp) to support dynamic/runtime proxy spawning and improved lifecycle/visibility handling: change proxy base/form IDs to COPlayerProxy/CommonwealthOnline, add process-list actor lookup, spawn helpers, play-space/cell checks, 3D visibility refresh, ActorHandle usage, and spawn mutexes and globals for safer spawning. Update docs and setup (architecture.md, limitations.md, plugin/setup.md) to describe global dynamic spawn behavior, max runtime proxies (kMaxRuntimeProxyActors = 4), and validation checklist; update launch-two-fallout4.bat to show instance log locations. Misc: small tweaks to logging and debug flags to gate diagnostics.
2026-06-07 20:31:51 +12:00
andrew 21c8bf9593 Smooth remote proxy rotation and conditional snapping
Add interpolation for remote proxy rotation and conditional snapping logic. Introduces kProxyRotationLerpAlpha and a ShouldSnapRemoteMovement declaration, and uses LerpRotation to smoothly apply headings for non-slot proxies (and slot-backed proxies in frame smoothing) unless movement type or large drift forces a snap. Adds a kLargeDriftSnapDistance threshold and threads a computed headingToApply through proxy locomotion/animation calls. Also updates the informational log to mention rotation lerp and removes an unused void cast.
2026-06-07 16:34:21 +12:00
andrew 8dfec0a4b3 Rename project to Commonwealth Online
Replace occurrences of "Fallout 4 Together" with "Commonwealth Online" across docs and testing guidance. Add Interface assets and tooling: MainMenu/Pipboy SWFs, translation/fonts, exported scripts (Interface/exported/scripts/MainMenu.as) and a PATCH_MainMenu_Multiplayer.md describing how to add a Multiplayer menu entry that calls root.f4se.plugins.commonwealthOnline.openManager(). Also add build/run batch scripts and apply assorted updates to README, plugin, server and protocol documentation/source to align with the rename and UI changes.
2026-06-07 16:22:50 +12:00
andrew c4a7b6dedb Fix proxy stop/land animation linger & snap
Prevent proxies from continuing jog/landing animations after a remote stops and fix snap desyncs. Treat network-authoritative idle (graphSpeed < 0) as definitive and stop falling back to measured lerp speed; pin/snap position when remote is not locomoting and ensure transforms snap on stop receive. Shorten sender-side hold times for movement and jump states to reduce stale motion in packets, and use isMoving (not stale graphSpeed) for landing resume decisions. Changes in plugin sources and main config, plus an updated dev log entry.
2026-06-05 16:12:34 +12:00
andrew 9412fcf8ea Improve proxy jump sync and event handling
Handle remote jump state more robustly and avoid locomotion graph clobbering. Changes: detect jumping early in ActorController and short-circuit to apply jump animation/state; suppress locomotion (Speed/Sprint) while airborne and keep graphSpeed for landing-tier selection; add ApplyJumpStateToGraph helper to set jump vars; only write bulk descriptor fields when not airborne to avoid stomping jump graph; change snapshot writes so in-jump vars are not overwritten by descriptor bulk writes; reorder and refine jump/movement event logic so jump start/up/down/land are handled before locomotion tier events and preserve the pre-jump locomotion tier for landing transitions; ensure graph updates are applied while jumping; set puppet locomotion speed to -1 when jumping or idle so the engine's idle speed remains; and increase the network jump hold duration from 200ms to 400ms. These changes prevent missed/incorrect jump animations and improve landing clip selection.
2026-06-05 15:59:35 +12:00
andrew f4b37b6d12 Improve proxy animation motion handling
Add explicit motion-driven animation sync and strengthen moving logic to reduce desyncs. Initialize puppetGraphSpeed and reset applied animation state for non-moving puppets on restore. Introduce SyncProxyAnimationFromMotion to drive proxy animation from measured per-frame speed (with a 8.0F threshold) and to clear puppet graph speed when the remote isn't locomoting. Replace previous inline motion/graph merge logic in ApplySmoothFrameMovement with this helper. In F4TProxyAnimationSync, make isMoving authoritative (require both isMoving flag and movementSpeed >= idle threshold) and clear movingHoldUntil when the remote is not moving to avoid stale hold states.
2026-06-05 15:52:01 +12:00
andrew a137821406 Improve proxy locomotion, tier & jump sync
Fix multiple proxy animation issues: stale graph Speed collapsing jog into walk, missing slow-walk/jog tiers, and jump takeoff/landing not playing. Key changes:

- Prefer position-derived movementSpeed when animationGraphSpeed is missing/stale (ResolveLocomotionGraphSpeed) and fall back to graph Speed only when it agrees within a tolerance; sender now transmits movementSpeed when local graph read is 0 and TryReadLocalAnimationGraphSpeed falls back to SpeedSmoothed.
- Introduce locomotion tiers (Walk/Jog/Run) with ComputeLocomotionTier and sync ints (iSyncWalkRun/iSyncLocomotionSpeed/iSyncJumpState) to the graph; fire corresponding tier events when starting or changing tier.
- Fix proxy motion application: persist per-proxy velocity and worldDelta so the Update hook does not zero-out controller motion; use measured frame motion to drive animation when network flags are sparse.
- Restore correct jump behavior: fire MT/weapon-compatible jump events for takeoff and landing (JumpUp/JumpStartFrom*/jumpLand/jumpLandTo*), clear bInJumpState on landing and remove the extra proxy-side jump hold so landings exit the jump loop.
- Misc: add constants and thresholds for tier/run/walk/run-land decisions and update logs to include tier labels.

Files updated: plugin/include/F4TProxyAnimationSync.h, plugin/src/F4TProxyAnimationSync.cpp, plugin/src/F4AnimationDescriptor.cpp, plugin/src/F4TProxyPuppet.cpp, plugin/src/F4TProxyActorController.cpp, plugin/src/main.cpp, and docs/dev-log.md.
2026-06-05 15:48:16 +12:00
andrew 6a38e7226c Use authoritative FO4 animation variable names
Replace previously guessed graph variable names/types with the real FO4 humanoid movement behavior names (from MTBehavior.hkx) and update syncing logic accordingly. F4AnimationDescriptor now lists only the variables F4T drives (Speed, SpeedSmoothed, IsSprinting, bInJumpState, iIsInSneak) to avoid clobbering graph state; Direction is intentionally not written. Enable proxy sneak sync using the INT32 iIsInSneak, change SpeedSampled -> SpeedSmoothed, and update all Set/Get calls and diagnostic logging to the new names. Fix jump detection by relying on the actor IsJumping() API (removing the noisy vertical-speed heuristic that produced false positives and caused proxies to remain in jump state). Changes touch descriptor, proxy sync, puppet, main logic, and related docs to explain the rationale and testing notes.
2026-06-05 15:29:31 +12:00
andrew 5ba440ab5d Add crouch state and fix jump sync
Add isCrouching to network, state and animation systems; enable proxy jump syncing with a jump-hold debounce and update animation descriptor and server tooling.

Key changes:
- Networking: F4TNetworking.h/cpp: added a_isCrouching, include "isCrouching" in transform packets and parsing, and logging.
- Remote state: F4TRemotePlayerState.h: added isCrouching field.
- Proxy animation: F4TProxyAnimationSync.*: added crouch fields, enabled jump sync, implemented ApplyJumpHoldState and jump hold timing, wrote crouch/jump bools into descriptors when available, updated event firing and logs.
- Animation descriptor: F4AnimationDescriptor.cpp: added isJumping and isCrouching to bool variable list.
- Local detection: main.cpp: added isCrouching in movement state, stubbed GetCrouchState(), adjusted jump hold timing and included crouch in outgoing transform calls.
- Server/dev tooling: server/dev_server_app.py, fake_client.py, fake_player.py, README.md: added crouch reporting, toggle UI/control and fake client support for crouch, and updated docs/logging.
- Docs: docs/dev-log.md updated with notes on jump/crouch fixes and testing.

Rationale: ensure remote players can report crouch state and make jump animations transition reliably by debouncing jump state on proxies and writing available graph bools; also provide dev-server controls and fake-client support for testing.
2026-06-05 14:22:17 +12:00
andrew 7f1aa11281 Update F4TProxyPuppet.cpp 2026-06-05 13:32:06 +12:00
andrew 65553a0c61 Drive proxy cadence from measured motion
Tie proxy locomotion/cadence to actual per-frame movement and motion-feedback instead of only replaying transmitted Speed.

Changes:
- docs/dev-log.md: add detailed dev log describing measured-cadence fix and cadence/animationSpeed work.
- plugin/include/F4TProxyPuppet.h: added NiPoint3 include and new API: SetProxyLocomotionState, SetProxyDesiredSpeed (legacy alias), and ApplyProxyLocomotionFrame.
- plugin/lib/commonlibf4/include/RE/A/ActorMotionFeedbackOutput.h: new tentative struct for motion-feedback output.
- plugin/lib/commonlibf4/include/RE/Fallout.h: include new ActorMotionFeedbackOutput header.
- plugin/src/F4TProxyActorController.cpp: track per-frame timing/puppet state, compute frame delta, use proxy->Move() with measured frameDelta and call ApplyProxyLocomotionFrame (instead of SetPosition/Lerp-only), and pass measured graph speed/direction to proxy.
- plugin/src/F4TProxyAnimationSync.cpp: use SetProxyLocomotionState to include direction when writing proxy locomotion state.
- plugin/src/F4TProxyPuppet.cpp: introduce ProxyLocomotionState map, sync controller motion fields, compute/push engine motion-feedback (via Compute/Update feedback vtable calls), use UpdateNoAI + manual motion feedback to drive cadence, implement ApplyProxyLocomotionFrame which derives velocity from world delta, clamps/chooses feedback speed (uses measured horizontal speed unless provided graph speed is valid), applies an idle threshold (<8 u/s -> idle), and writes graph speed back to the animation graph.

Why: This makes foot cadence reflect on-screen translation (eliminating mild foot slide/stop-overstay) by measuring applied displacement each frame, updating controller velocity/motion-feedback, and re-asserting animation graph inputs after UpdateNoAI.
2026-06-04 21:39:26 +12:00
andrew abef899505 Add proxy puppet hook and graph speed sync
Introduce a puppet vtable hook to preserve networked locomotion Speed and fix proxy cadence. Added F4TProxyPuppet (header + impl) which installs an Actor::Update hook that writes the desired graph Speed and calls UpdateNoAI for proxy actors so the engine does not recompute/zero Speed from controller velocity. Publish active proxy FormIDs and per-proxy desired speeds so the hook targets only proxy actors.

Wire animationGraphSpeed through networking: parse/send a new "animationGraphSpeed" field and store it on RemotePlayerState. Proxy animation sync now prefers the authoritative animationGraphSpeed when present, otherwise maps movementSpeed ~1:1 to graph Speed (with sprint floor and clamping). Added graph variables speedSampled/speedDamped alongside Speed and updated snapshot population and diagnostics. Removed character-controller velocity injection (was causing physics/animation conflicts) and adjusted proxy movement logic to rely on graph variables plus kinematic SetPosition.

Also: Publish puppet diagnostics from the controller, add sender-side local graph speed read diagnostic, update fake_player to compute and send animationGraphSpeed, and append detailed dev-log entries describing the root cause, diagnostics, and fixes. Build and runtime diagnostics added to verify hook behavior and cadence changes.
2026-06-04 20:18:34 +12:00
andrew 2aab83087f Debounce movement stop for animations/network
Add a short "moving" hold to reduce flicker when movement briefly stops. Introduces a 300ms stop-hold for both proxy animation sync and local player movement sampling: add chrono include and movingHoldUntil to ProxyAppliedAnimationState, a kProxyMovingStopHoldDuration constant, ApplyMovingHoldState and BuildDebouncedDesiredState in F4TProxyAnimationSync, and replace direct desired-state usage with the debounced version. In main.cpp add kMovementStopHoldDuration, ResolveMovementHoldState, refactor BuildPlayerMovementState, add an overloaded GetPlayerMovementState, and separate debug vs network sampling (with separate movingHoldUntil variables) so logging uses per-frame debug state while network sends use the debounced network state. Also gate diagnostic logging behind a flag. These changes aim to stabilize isMoving/isSprinting transitions and avoid rapid toggles between frames and network updates.
2026-06-04 17:34:16 +12:00
andrew feec915f35 Inject controller velocity & send anim events
Add runtime velocity injection to the proxy character controller so the engine has velocity available when evaluating animation graphs (accessed via Actor::currentProcess->middleHigh->charController). Introduce animation graph event constants, TrySendGraphEvent helper, and SendLocomotionTransitionEvents to fire move/sprint/sneak start/stop events on state transitions (with diagnostic logging). Call SendLocomotionTransitionEvents before applying the new graph state so FSM transitions are driven correctly. Respect compile-time flags (kEnableProxyLocomotionSync, kEnableProxySneakSync).
2026-06-03 23:09:42 +12:00
andrew a11c7d4475 Add interpolation system and integrate into proxy
Introduce a waypoint-based interpolation system and integrate it into the proxy actor controller. Added F4T::InterpolationSystem (header + implementation) with TimePoint, InterpolationComponent, Lerp helpers and Update() logic. Integrates per-slot InterpolationComponent into F4TProxyActorController, switches to kinematic SetPosition-based smoothing (per-frame Lerp with snap thresholds) and removes character-controller velocity injection to prevent drift; also clears waypoints on hard snaps and uses steady_clock for timing. Added a descriptor-based bulk animation write (ApplyDesiredStateToGraphDescriptorBased) in ProxyAnimationSync for efficient graph variable updates with failure logging. Also included testing and debugging docs (phase2-interpolation-testing.md and phase2-interpolation-debugging.md) and flipped some debug flags to false.
2026-06-03 22:46:57 +12:00
andrew b128729ebf Stabilize proxy visibility and smooth movement
Fix proxy orbiting and improve motion/visibility handling.

- Capture a per-slot visibleDebugAnchorPosition (reset on reassignment) to keep pre-placed proxies visually stable and avoid orbiting when the local player moves.
- Remove the debug +20Z offset so pre-placed actors remain grounded.
- Add GetRuntimeProxyVisibleTargetPosition to compute a stable visible target (anchored base + scaled remote delta).
- Replace teleport-heavy updates with smooth movement: add InjectProxyMovementVelocity to publish velocity into bhkCharacterController, call Actor::Move() per-frame and inject velocity for animation blending.
- Prefer reusing pre-placed pool proxies before attempting dynamic spawn.
- Implement dynamic spawn via NEW_REFR_DATA / TESDataHandler::CreateReferenceAtLocation, apply debug visibility to spawned actors, and store handles in the dynamic pool.
- Harden debug visibility setup: explicitly enable/disable 3D, alpha, display geometry, set 3D update flags and queue a TaskQueueInterface 3D update; expand debug logging.
- Remove unsafe currentProcess target-clearing code and other minor cleanups.
- Add dev-log entries describing Phase 6 debugging and fixes.
2026-06-03 18:27:06 +12:00
andrewandCursor fb59eea0a2 fix: resolve Phase 6 compilation errors - unblock testing
- Made F4AnimationDescriptor constructor public
- Fixed logging macros by using std::string_view and renaming helpers
- Fixed int32_t/uint32_t type mismatch in animation variable reads/writes
- Disabled actor state flag setting (needs bitfield mapping in Phase 7)
- Disabled dynamic spawn APIs pending CommonLibF4 verification (Phase 7)
- Added move semantics to RemoteActionQueue for ProxyActorSlot

Build status: clean compilation, Phase 6 testing ready with pre-placed proxies

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 17:18:15 +12:00
andrew 40bc637103 Add RemoteActionQueue and descriptor animation sync
Add a RemoteActionComponent (header + impl) implementing RemoteActionSnapshot and RemoteActionQueue to capture, queue (max 16) and replay discrete remote actions with comprehensive logging. Integrate the action queue into ProxyActorSlot by including the new header and adding an actionQueue member. Replace string-based per-frame animation writes with a descriptor-based bulk sync function (ApplyProxyAnimationFromRemoteStateDescriptorBased) that builds indexed AnimationVariableSnapshot and calls descriptor.LoadAnimationVariablesToCache for a single bulk write (reduces string lookups and improves performance). Update docs/dev-log with Phase 5 summary and details of the action replay and descriptor-based animation sync changes.
2026-06-03 17:05:49 +12:00
andrew e14b91d94e Dynamic proxy spawning, velocity & state sync
Implements Phase 4 dynamic proxy spawning and actor state synchronization. Adds a dynamic proxy pool (g_dynamicProxyPool), SpawnDynamicProxyActor and GetOrSpawnDynamicProxy to spawn/reuse actors via Player::PlaceAtMe, and updates slot resolution to prefer dynamic proxies with a pre-placed pool fallback. Verifies/integrates existing character-controller velocity injection and clamps speed, and applies remote actor state flags to proxies before animation sync. Enhanced logging for spawn, velocity and state transitions. Changes in plugin/src/F4TProxyActorController.cpp and updated dev log (docs/dev-log.md).
2026-06-03 17:01:41 +12:00
andrew a6b2505242 Add animation sync docs and descriptor infra
Add detailed design and implementation scaffolding for TiltedEvolution-style animation synchronization. New documentation: animation-architecture-alignment.md, animation-sync-analysis.md, f4-animation-descriptor.md, phase1-3-completion-report.md and updates to dev-log.md describing Phase 1-3 progress. Plugin: introduce F4AnimationDescriptor (plugin/include/F4AnimationDescriptor.h, plugin/src/F4AnimationDescriptor.cpp) and extend remote state handling (plugin/include/F4TRemotePlayerState.h). Integrate protocol/state extensions and refactor points: plugin/src/F4TNetworking.cpp now parses optional actorStateFlags and actionEvents; proxy controller and animation sync files (F4TProxyActorController.cpp, F4TProxyAnimationSync.cpp) updated to support descriptor-based bulk variable snapshots and actor state replication. Server/tools: update server/dev_server_app.py and server/fake_client.py to handle and display the new optional fields. These changes are additive and backward-compatible and set up phases for action capture, dynamic proxy spawn, and action-replay integration.
2026-06-03 16:52:47 +12:00
andrewandCursor 9d05344e4c fix: actually assign proxies from pool to remote player slots
KEY FIX:
We were discovering pre-placed proxies into a pool, but NEVER
actually USING them when assigning remote players to slots!

CHANGES:
- Modified TryResolveSlotProxy() to grab from proxy pool
- If slot has no proxyHandle, try TryGetProxyFromPool()
- Assign pooled proxy to slot on first resolution
- Log when proxy is assigned from pool

Now the flow is:
1. InitializeProxyPool() discovers pre-placed proxies  
2. Remote player connects, slot is created  
3. TryResolveSlotProxy() called - grabs from pool   NEW!
4. Proxy assigned to remote player   NEW!
5. Movement and animations work!  

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 15:22:50 +12:00
andrewandCursor 7b3a2b51bb feat: initialize proxy pool on first remote player update
Calls InitializeProxyPool() when first remote player is processed.
This discovers all pre-placed proxies in the current cell and logs:
- Number of proxies found
- Max concurrent players supported
- Warning if no proxies found

The proxy pool is now ready for use when assigning proxies to
remote players. Since we only use pre-placed proxies with proper
AI, animations should now work smoothly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 15:10:57 +12:00
andrewandCursor 3edce921c0 feat: implement proxy pool architecture using pre-placed proxies
ARCHITECTURE SHIFT:
Instead of dynamically spawning proxies (which lack proper AI),
use a pre-placed proxy pool from the Creation Kit.

BENEFITS:
-  All proxies have full AI, character controllers, and animations
-  Pre-placed = guaranteed proper setup and initialization
-  Simpler architecture (no dynamic spawning complexity)
-  Predictable player limits (# of placed proxies = max players)

IMPLEMENTATION:
- Added InitializeProxyPool() to discover pre-placed proxies in cell
- Added TryGetProxyFromPool() to get available proxies
- Logs number of available proxies and max concurrent players
- Falls back gracefully if no proxies found (warns user)

USAGE:
1. Create proxy actor references in Creation Kit
2. Place them in the game cell
3. Ensure they have AI packages (for animations to work)
4. Plugin finds and manages them automatically

LIMITATIONS:
- Max concurrent players = number of pre-placed proxies
- Users must place proxies in CK (documented requirement)

This is a pragmatic solution for testing and can remain for release.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 15:10:05 +12:00
andrewandCursor 47a7caac0e fix: disable PlaceAtMe spawning, use pre-placed proxies instead
ROOT CAUSE IDENTIFIED:
User found that pre-placed CK proxy HAS AI while spawned proxies DON'T.
This explains ALL the issues:
- Move() calls don't work without AIProcess
- No animations play (AI drives animation state)
- Movement is jerky (no character controller velocity management)
- AI goes neutral (proxy was never properly alive as NPC)

THE ISSUE:
PlaceAtMe spawned actors don't get proper AIProcess initialization.
They are shells without AI.

THE SOLUTION:
Disable PlaceAtMe spawning (kUsePlaceAtMeBackedRuntimeProxySpawn = false)
Use pre-placed proxy references from the Creation Kit instead.
These have full AI, character controllers, and can run naturally.

EXPECTED RESULT:
-  Proxies have active AI
-  Move() will work properly (AI + character controller)
-  Smooth animations (velocity updates trigger animation graph)
-  Natural NPC behavior (aggro state is maintained)
-  No more jerky movement (continuous character controller)

NEXT:
The plugin will search for pre-placed proxy refs in the cell.
If none exist, needs fallback or user must place proxies in CK.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 15:04:46 +12:00
andrewandCursor 2449525175 fix: eliminate frequent SetPosition calls that break AI
BREAKTHROUGH INSIGHT:
The user reported: AI goes aggressive then immediately returns to neutral.
This matches the symptom of SetPosition() breaking the character controller.

ROOT CAUSE:
- We were calling SetPosition() every 500ms
- SetPosition() bypasses character controller → kills all movement
- Between SetPosition calls, Move() had to re-establish control
- This constant switching BREAKS the AI's ability to function

THE FIX:
- ONLY use SetPosition() for emergencies (drift > 300 units OR > 2 seconds)
- Always use Move() with small, bounded deltas (max 50 units/frame)
- This lets the character controller and AI run continuously
- AI can now maintain state and play animations properly

CRITICAL CHANGES:
1. Emergency thresholds: 300 unit drift OR 2 second timeout (not 200/500ms)
2. Normal movement: Use Move() with small incremental deltas
3. Never SetPosition during normal gameplay
4. SetPosition only as emergency correction

EXPECTED RESULT:
-  Smooth continuous movement (no more jerky jumps)
-  AI stays active (can get aggro and respond naturally)
-  Proper animations (velocity continuous, not reset every 500ms)
-  Network sync maintained (emergency corrections prevent drift)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:59:08 +12:00
andrewandCursor e156d048ec fix: call Move() EVERY FRAME for smooth animations
CRITICAL FIX:
The problem wasn't that we needed less SetPosition() - it was that we needed
MORE Move() calls!

ROOT CAUSE:
The AI doesn't automatically call Move(). We have to call it ourselves.
Without frequent Move() calls, there's no velocity updates, no animations.

THE FIX:
- Call Move() EVERY FRAME with the calculated delta (0.016F frame time)
- This updates character controller velocity every frame
- Havok animation graph sees velocity and evaluates animations
- SetPosition() only every 500ms to correct accumulated position error

RESULT:
- Smooth continuous movement (Move() every frame = smooth locomotion)
- Proper animations (velocity updates trigger graph evaluation)
- Network sync (SetPosition() prevents drift)

The key insight: We're not letting AI do it naturally - we're DRIVING the
Move() calls ourselves! The proxy is a puppet, but we can control it properly
by actively updating its velocity via Move() every frame.

Expected behavior:
- Proxy moves smoothly and continuously
- Walking/running animations play
- Position stays synchronized with network data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:53:53 +12:00
andrewandCursor 90ddcb19d8 feat: implement hybrid movement for AI-driven animations
IMPLEMENTATION BREAKTHROUGH:
- Proxies are real NPCs with active AIProcess
- AIProcess naturally calls Move() each game frame
- Move() updates character controller velocity
- Animation graph evaluates velocity and plays animations
- Solution: Let AI drive movement naturally, not just SetPosition()

CHANGES:
1. Added lastPositionSyncTime to ProxyActorSlot
   - Tracks when position was last overridden for sync

2. Rewrote ApplyRuntimeProxyTransform():
   - New parameter: optional ProxyActorSlot pointer
   - Hybrid logic:
     * Don't override position most of the time
     * AI's natural Move() calls update velocity automatically
     * Animations play because velocity is real
     * Override position only when needed:
       - Snap required (cell change, teleport)
       - Sync timer expired (~300ms)
       - Drift exceeds threshold (>150 units)
   - Falls back to always-sync for fallback proxy (no slot)

3. Updated call sites:
   - MoveSlotProxyToRemotePlayer: passes &a_slot
   - RestoreSlotProxyForRemotePlayer: passes &a_slot
   - MoveProxyToRemotePlayer: uses default nullptr (fallback)

RESULT:
- Proxy uses natural AI movement most of the time
- Animation system sees real velocity updates
- Animations should now play automatically
- Network sync maintained with periodic position override
- Smooth visual movement + proper animations = immersion!

Next: TEST IN GAME to verify animations work
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:49:49 +12:00
andrewandCursor 2ac4b8f07c docs: animation breakthrough - proxies ARE real NPCs with AI
Key discovery: The proxy is a real NPC (has voice lines, can aggro) which means
it has a full active AIProcess. This changes everything!

ROOT CAUSE IDENTIFIED:
- We use SetPosition() which bypasses the character controller
- This prevents Move() from being called
- Without Move(), velocity is never updated
- Animation graph never sees velocity, so no animations

SOLUTION:
- Let the proxy's AIProcess drive Move() calls naturally
- This will update velocity and trigger animations automatically
- Use SetPosition() only occasionally (~200ms) to correct network drift
- Result: Smooth networked movement WITH proper animations

Why this wasn't realized before:
- Previous investigation assumed proxies were 'puppets'
- We now know they're real NPCs with full AI capability
- We were just bypassing the animation pipeline with SetPosition()

Added:
- ApplyRuntimeProxyTransformWithAI() function (hybrid approach template)
- Comprehensive breakthrough notes in dev-log

Next: Implement actual hybrid movement that lets AI drive animations
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:46:09 +12:00
andrewandCursor 89249db2d1 chore: add AI state diagnostics for animation investigation
Added diagnostic functions to inspect proxy actor AI state:
- DiagnosticProxyAIState(): logs AIProcess presence, current package, pathfinding state
- EnableProxyAIAnimationMode(): placeholder for AI animation enablement
- Called on proxy spawn to gather evidence about AI setup

This is part of the AI approach investigation - we need to verify if proxies
already have active AIProcess instances and what packages they have assigned.
If the animation issue is just about calling Move() naturally (which happens
when the AI runs), we can potentially enable this by assigning proper packages
to the proxy and letting the game loop drive movement.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:41:19 +12:00
andrewandCursor b9ea0ac8a7 docs: proxy animation investigation conclusive - animations not feasible
Investigation summary:
- Tested velocity-based animation triggering: graph variable writes, animation
  events, character controller velocity manipulation, and Move() API calls
- All approaches failed: animations do not play on SetPosition-backed proxy actors
- Root cause: Fallout 4's animation system requires active AIProcess-driven
  locomotion packages, which are incompatible with networked puppet actors
- Fallout 4's animation system fundamentally ties animation evaluation to the
  character controller's actual velocity AND active AI-driven locomotion state
- PlaceAtMe proxies updated via SetPosition cannot provide either requirement

Proxy actors currently work correctly for:
- Smooth position synchronization
- Heading/rotation updates
- Jump animations (via Z-position)
- Network sync and lifecycle

What remains impossible without deep engine access:
- Walk/run/sneak animation playback
- Animation graph variable manipulation affecting behavior
- Character controller velocity synthesis for puppets

Recommendation: Accept this architectural limitation and provide alternative
visual feedback (particles, glows, state indicators) instead of animations.

Files changed:
- plugin/src/F4TProxyActorController.cpp: Reverted to SetPosition-only approach
- docs/dev-log.md: Added comprehensive investigation summary and conclusions

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 14:33:48 +12:00
andrew 3d301a436b Add local animation graph read-only debug
Introduce a game-thread-only, read-only diagnostic helper to probe local player animation graph variables and (optionally) numeric cache IDs. Adds F4TLocalAnimationGraphDebug.h/cpp with UpdateLocalPlayerAnimationGraphDebug(...) and wires a call into plugin/src/main.cpp immediately after GetPlayerMovementState. The helper probes curated variable names via CommonLibF4 read-only APIs, logs availability/changes, and includes a disabled-by-default numeric cache ID scan (kEnableLocalPlayerAnimationGraphCacheIdReadOnlyDebug = false) due to a reported crash during testing. Update also adds extensive dev-log documentation (docs/dev-log.md) describing behavior, testing notes, and rollback instructions. Build succeeded; manual F4SE in-game verification remains pending.
2026-06-03 12:40:26 +12:00
andrew 1aecccefb7 proxy: document visual sneak SetSneaking result 2026-06-03 12:12:42 +12:00
andrew 18379f2b28 Add proxy visual sneak scaffolding
Introduce default-off scaffolding for proxy visual sneak experiments: add kEnableProxyVisualSneakSync and kEnableProxyVisualSneakExperimentalGraph flags (false), include ACTOR_STANCE, and add a non-mutating ApplyProxyVisualSneakIfEnabled helper that reads proxy sneak/stance/forceSneak and emits one-time diagnostics when visual sneak is disabled. Add per-slot tracking fields (hasAppliedVisualSneakingState, hasLoggedVisualSneakDisabled, lastAppliedVisualSneakingState), ResetSlotVisualSneakTracking and calls to reset tracking when holding/reusing/disconnecting slots, and switch UpdateProxyAnimationStateDebug to accept a non-const RE::Actor&. Update docs/dev-log.md with an entry describing the change. Comments/TODOs note a future, separately approved experiment to call RE::Actor::SetSneaking(...) behind a disabled gate; current scaffolding intentionally avoids mutating actors, animation graph writes/events, or AI/package crouch logic. Build tested locally (plugin rebuild).
2026-06-03 11:51:04 +12:00
andrew 44ea1b98da Add data-only proxy animation debug logging
Track and log per-slot animation/movement diagnostics for runtime proxy actors without applying any visual animation. Adds a ProxyAnimationSpeedBucket enum and GetProxyAnimationSpeedBucket/GetProxyAnimationSpeedBucketLabel helpers, a new UpdateProxyAnimationStateDebug() routine, and fields on ProxyActorSlot to remember last-observed moving, sprinting, sneaking, jumping, weapon-drawn, movement type, and coarse speed-bucket state. Resets observation state when slots are created/reused and emits initial/transition-only logs including playerId and proxy FormID. Documentation and dev-log entries updated; visual animation, animation graph changes, and AI/movement behavior remain intentionally unmodified.
2026-06-03 11:36:38 +12:00
andrew 3d1abc66ad Neutralize runtime proxy actors and docs
Add a safe neutralization pass for Stage 4 runtime proxy actors and document the change. Introduces NeutralizeProxyActor and supporting helpers (ProxyNeutralizationReason, GetProxyNeutralizationReasonLabel, FormatPosition, IsProxyMovementPackageType, IsProxyFleeOrAlarmPackageType) plus kProxyNeutralizationInterval and a compile-time gate kEnableProxyAIMovementIntentSuppression (default=false). Adds SuppressProxyAIMovementIntent (default-disabled due to a crash observed during testing) which attempts safe package/process interruption using only confirmed CommonLibF4 APIs (EndInterruptPackage, InitiateDoNothingPackage, SetAvoidanceDisabled, command/process handle clears) and extensive throttled logs and TODOs for further unsafe changes. Neutralization is invoked after spawn promotion, on slot reassignment, during active maintenance, and while holding. Updates plugin logic to call neutralization at these points. Updates docs/architecture.md and docs/dev-log.md with the design, testing notes, and rationale (including the safety gate and next steps). Builds succeed; manual in-game validations are still pending.
2026-06-03 11:24:45 +12:00
andrew 5394250ef2 Improve runtime proxy slot lifecycle & spawn
Refine Stage 4 runtime proxy management: introduce explicit lifecycle states (HeldNoRemote, HeldDisconnected, HeldLeftCell, Reusable, SpawnFailed), add a 30s disconnected-slot reuse delay, and implement per-slot hidden holding positions with spacing. Add a held-position correction pass (correct drift >25 units) and make disconnected-held slots become reusable after the grace period; reusable slots can be reassigned to later playerIds. Capture a remote player's current transform before performing the PlaceAtMe-backed Stage 4 spawn and apply that transform immediately when the isolated proxy is promoted, preventing a brief visual spawn near the local player. Misc: improved logging/throttling, slot assignment/reassignment logic, and various helper functions. Docs updated (architecture.md, dev-log.md) and plugin/src/F4TProxyActorController.cpp implements the behavior.
2026-06-03 10:47:15 +12:00
andrew b4ec928c67 Add Stage 4 runtime proxy slots (max 4)
Introduce a controller-local runtime proxy slot manager (ProxyActorSlot) and g_proxySlots map capped at kMaxRuntimeProxyActors = 4. Transition the proxy flow from a single active runtime proxy to per-remote-player slots: sorted remote snapshots, per-slot pre-spawn candidate snapshots, PlaceAtMe-backed spawn attempts (one in-progress spawn globally), isolation/settle/promotion of placed refs into slot.proxyHandle, per-slot movement smoothing/hold logic, and validation/restore of handles. Preserve the single placed fallback reference for one selected player and keep slots session-sticky (no reuse/despawn yet). Update docs (architecture.md, dev-log.md) and header/source (F4TProxyActorController.{h,cpp}) to reflect Stage 4 behavior and diagnostics.
2026-06-02 22:49:50 +12:00
andrew 37ef52549c Runtime proxy spawn: Stage 3 PlaceAtMe
Promote a single runtime-spawned proxy as the preferred active remote-player representation (Stage 3 / 3.7) while preserving the placed reference as a fallback. Updates include: detailed architecture and dev-log additions describing staged diagnostics (3.1–3.7), PlaceAtMe-backed spawn candidate isolation/settle, vanilla/Codsworth diagnostics, console PlaceAtMe testing, near-player visibility holds, and PASS/PARTIAL/FAIL diagnostic outcomes.

Code changes (plugin/include & plugin/src): adjust header comment and implement numerous runtime proxy features and diagnostics: new constants, enums, structs, state variables, logging helpers, position/distance helpers, absolute FormID lookup, runtime actor base selection (custom vs vanilla), PlaceAtMe-backed spawn state machine, debug placement/hold timing, candidate snapshot/isolation, promotion to active runtime proxy, and many throttled/logged diagnostics. The placed CK reference remains the fallback if runtime spawn/validation fails. Docs changed: docs/architecture.md and docs/dev-log.md updated to describe the new Stage 3 behavior and testing notes.

Files changed: docs/architecture.md, docs/dev-log.md, plugin/include/F4TProxyActorController.h, plugin/src/F4TProxyActorController.cpp.

Behavioral notes: single-proxy only (Stage 4 mapping deferred), extensive diagnostic logging added, and in-game validation/testing remains pending.
2026-06-02 22:27:42 +12:00
andrew 9b19143477 Add one-shot runtime proxy spawn diagnostic
Introduce a Stage 2 diagnostic that attempts a single runtime spawn of F4T_RemotePlayerProxy in F4TTestCell01 from the game-thread proxy controller. Changes include a new enable flag (kEnableRuntimeProxySpawnDiagnostic), diagnostic offset constant, new diagnostic ObjectRefHandle and boolean state flags, and a TrySpawnRuntimeProxyDiagnostic function that builds NEW_REFR_DATA, calls TESDataHandler::CreateReferenceAtLocation, validates the returned handle/actor/cell, logs a single attempt and success/failure outcome, and intentionally leaves the spawned actor in place. The diagnostic spawn is run before placed-proxy lookup and the spawned reference is skipped during placed proxy scanning so the placed proxy remains the active visual fallback. Updated header comment and documentation (architecture.md and dev-log.md) to describe the new diagnostic behavior and testing notes.
2026-06-02 16:41:37 +12:00
andrew df5b0c32cc Add runtime proxy actor lookup diagnostics
Introduce Stage 1 runtime lookup diagnostics for the proxy actor base: adds ResolveProxyActorBase and ResolveProxyActorBaseByPluginLocalFormId along with helper checks (IsTestPluginLoaded, IsUsableProxyActorBase, editor/fullname helpers). The code logs plugin load status, editor-ID resolution, and a plugin-local FormID fallback (0x0020A1) while refusing to spawn actors (runtime spawning remains disabled). Adds throttled and one-shot log flags to avoid spam and invokes the diagnostic early on the game-thread before placed-proxy fallback and remote-player selection. Documentation updated (docs/architecture.md and docs/dev-log.md) to record the new diagnostic behavior and next steps.
2026-06-02 16:27:39 +12:00
andrew a0563a6849 Hold proxy in hidden position when no remote
Add a temporary in-cell holding fallback for the single placed proxy actor when no valid same-cell remote player is available. Introduces kProxyHiddenHoldingPosition, ProxyLifecycleState, RemotePlayerSelection, MoveProxyToHoldingPosition and RestoreProxyForRemotePlayer, plus selection/state-tracking and throttled logs. The controller now moves the proxy to the hidden position on disconnect, disappearance, or cell-mismatch and snaps it back when a valid same-cell remote appears. Documentation and dev log updated to describe the lifecycle and rationale (docs/architecture.md, docs/dev-log.md, protocol/player-sync.md).
2026-06-02 13:59:32 +12:00
andrew d36140c76e Log local sneak detection and proxy sneak observer
Add diagnostics and a log-only proxy observation for sneak state changes.

- docs/dev-log.md: Add entries documenting proxy sneak observation and local sneak detection diagnostics, scope notes, and next steps.
- plugin/src/main.cpp: Introduce SneakDetectionState, GetSneakDetectionState, and ShouldLogSneakDetection to combine API and actor-state signals; throttle diagnostic logs; use the combined finalIsSneaking in player movement state decisions; add include for ACTOR_STANCE.
- plugin/src/F4TProxyActorController.cpp: Add controller-local tracking for the represented remote player sneak state, reset helpers, and ApplyRemoteMovementStateToProxy which logs sneak transitions for the represented remote player (no visual crouch applied yet).

Notes: This change is log-only — it does not force animations or ActorState writes. Networking protocol and receive-thread behavior remain unchanged. A TODO is left to safely apply visual crouch once a supported API is confirmed.
2026-06-02 13:44:24 +12:00