Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
AttachBonePositionPlayerTrackModifier.c
Go to the documentation of this file.
2{
3
4 [Attribute(defvalue:"", desc:"Bone we want be attached to")]
5 string boneToAttach;
6
7 [Attribute(defvalue:"false", desc:"If we want to rotate with parent")]
8 bool applyRotation;
9
10 IEntity player;
11 vector transform[4];
12 vector boneTransform[4];
13 vector originalVector[4];
14 ChimeraWorld chimeraWorld;
15
16 override void OnInit(World world)
17 {
18 chimeraWorld = world;
19
20 array<int> playerIDs = {};
21 GetGame().GetPlayerManager().GetPlayers(playerIDs);
22 foreach (int playerID : playerIDs)
23 {
24 player = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
25 if (!player)
26 continue;
27 }
28 }
29
30 override vector OnApplyModifierVector(float time, vector originalValue)
31 {
32
33 if (!player)
34 return originalValue;
35
36 player.GetTransform(transform);
37
38 if (boneToAttach != "") //attach to bone
39 {
40 Animation entityAnimation = player.GetAnimation();
41
42 if (!entityAnimation)
43 return originalValue;
44
45 TNodeId boneId = entityAnimation.GetBoneIndex(boneToAttach);
46
47 if (boneId == -1)
48 return originalValue;
49
50 entityAnimation.GetBoneMatrix(boneId, boneTransform);
51 Math3D.MatrixMultiply4(transform, boneTransform, transform);
52
53 if (applyRotation)
54 {
55 originalVector = { "1 0 0", "0 1 0", "0 0 1", originalValue};
56 Math3D.MatrixMultiply4(transform, originalVector, transform);
57
58 return transform[3];
59 }
60 else
61 {
62 return transform[3] + originalValue;
63 }
64 }
65
66 return originalValue;
67 }
68};
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition World.c:16
SCR_FieldOfViewSettings Attribute
int TNodeId
Node global id is a hash of name of the node.
Definition EnEntity.c:18