feat(extra-natives-five): add msgpack support for scripted animation natives#3998
Open
Rogui20 wants to merge 3 commits into
Open
feat(extra-natives-five): add msgpack support for scripted animation natives#3998Rogui20 wants to merge 3 commits into
Rogui20 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
This PR makes
TASK_SCRIPTED_ANIMATIONandPLAY_ENTITY_SCRIPTED_ANIMusable from script runtimes by allowing their animation data parameters to be passed as msgpack objects.These natives expect internal animation slot data structs. This PR converts structured script data into the layout expected by the game native before forwarding the call.
...
How is this PR achieving the goal
This PR registers wrappers for:
TASK_SCRIPTED_ANIMATIONPLAY_ENTITY_SCRIPTED_ANIMThe wrappers:
fx::scrObjectmsgpack arguments from the script runtime;std::map<std::string, msgpack::object>;ScriptInitSlotDatalayout expected by the native;Empty or malformed msgpack data falls back to a default empty animation slot, allowing unused slots to be passed as an empty string or an empty msgpack object.
The native behavior itself is unchanged. This PR only adds argument translation.
...
This PR applies to the following area(s)
FiveM
Natives
ScRT: Lua
ScRT: JS
ScRT: C#
...
Successfully tested on
Latest FiveM Build
Game builds: ..
3095
Platforms: Windows, Linux
Windows
Checklist
Fixes issues
Lua usage example
local data = msgpack.pack({
state = 1,
dict0 = "clip@chopper_generic",
clip0 = "hover",
phase0 = 0.0,
rate0 = 1.0,
weight0 = 1.0,
filter = 0,
blendInDuration = 0.1,
blendOutDuration = 0.1,
timeToPlay = -1,
flags = 1,
ikFlags = 0
})
-- Empty strings can be used for unused animation slots.
Citizen.InvokeNative(
0x77A1EEC547E7FCF1,
entity,
data,
"",
"",
0.125,
0.125
)
-- Same argument format also applies to TASK_SCRIPTED_ANIMATION.
Citizen.InvokeNative(
0x126EF75F1E17ABE5,
PlayerPedId(),
data,
"",
"",
0.125,
0.125
)
Scripted animation data fields
Each animation slot object can define up to three clips:
state
dict0, clip0, phase0, rate0, weight0
dict1, clip1, phase1, rate1, weight1
dict2, clip2, phase2, rate2, weight2
filter
blendInDuration
blendOutDuration
timeToPlay
flags
ikFlags
Known state values:
0: disabled / empty slot
1: single clip
2: blended slot using the configured clip entries