Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CollisionDamageContainer.c
Go to the documentation of this file.
2{
3 IEntity m_Other;
4 IEntity m_OtherPilot;
5 vector m_vOwnerOriginAtThePointOfImpact;
6 vector m_vOtherOriginAtThePointOfImpact;
7 vector m_vImpactNormal;
8 float m_fImpulse;
9 float m_fTotalMomentumOwner;
10 float m_fTotalMomentumOther;
11 float m_fDamageShare = 1;
12 int m_iOtherResponseIndex
13 bool m_bOtherIsDynamic;
14 bool m_bOtherIsDestructible;
15
16 protected int m_iCollisionsCounter;
20
21 //------------------------------------------------------------------------------------------------
27
28 //------------------------------------------------------------------------------------------------
36
37 //------------------------------------------------------------------------------------------------
43
44 //------------------------------------------------------------------------------------------------
50
51 //------------------------------------------------------------------------------------------------
52 // constructor
62 void SCR_CollisionDamageContainer(notnull IEntity owner, notnull IEntity other, float impulse, vector velocityBefore1, vector velocityAfter1, vector velocityBefore2, vector velocityAfter2, vector impactPosition, vector impactNormal)
63 {
64 m_Other = other;
65 m_fImpulse = impulse;
66 m_vOwnerVelocityBefore = velocityBefore1;
67 m_vOtherVelocityBefore = velocityBefore2;
68 m_vImpactNormal = impactNormal;
69 m_vImpactPosition = impactPosition;
71
72 m_vOwnerOriginAtThePointOfImpact = owner.GetOrigin();
73 m_vOtherOriginAtThePointOfImpact = other.GetOrigin();
74
75 Physics ownerPhysics = owner.GetPhysics();
76 if (!ownerPhysics)
77 return;
78
79 float ownerMass = ownerPhysics.GetMass();
80 float momentumB = velocityBefore1.Length() * ownerMass;
81 float momentumA = velocityAfter1.Length() * ownerMass;
82 float dotMultiplier = vector.Dot(velocityAfter1.Normalized(), velocityBefore1.Normalized());
83
84 m_fTotalMomentumOwner = Math.AbsFloat(momentumB - momentumA * dotMultiplier);
85
86 Vehicle vehicle = Vehicle.Cast(other);
87 if (vehicle)
88 m_OtherPilot = vehicle.GetPilot();
89 else
90 m_bOtherIsDestructible = other.FindComponent(SCR_DestructionDamageManagerComponent) != null;
91
92 Physics otherPhysics = other.GetPhysics();
93 if (!otherPhysics)
94 return;
95
96 m_iOtherResponseIndex = otherPhysics.GetResponseIndex();
97 m_bOtherIsDynamic = otherPhysics.IsDynamic();
98
99 float otherMass = otherPhysics.GetMass();
100 if (otherMass > 0)
101 m_fDamageShare -= ownerMass / (ownerMass + otherMass);
102
103 momentumB = velocityBefore2.Length() * otherMass;
104 momentumA = velocityAfter2.Length() * otherMass;
105 dotMultiplier = vector.Dot(velocityAfter2.Normalized(), velocityBefore2.Normalized());
106 m_fTotalMomentumOther = Math.AbsFloat(momentumB - momentumA * dotMultiplier);
107 }
108}
SCR_DestructibleTreeV2Class impulse
vector position
Definition Math.c:13
void SCR_CollisionDamageContainer(notnull IEntity owner, notnull IEntity other, float impulse, vector velocityBefore1, vector velocityAfter1, vector velocityBefore2, vector velocityAfter2, vector impactPosition, vector impactNormal)
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24