Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_CollisionDamageContainer.c
Go to the documentation of this file.
1
class
SCR_CollisionDamageContainer
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
;
17
protected
vector
m_vImpactPosition
;
18
protected
vector
m_vOwnerVelocityBefore
;
19
protected
vector
m_vOtherVelocityBefore
;
20
21
//------------------------------------------------------------------------------------------------
23
vector
GetAverageImpactPosition
()
24
{
25
return
m_vImpactPosition
/
m_iCollisionsCounter
;
26
}
27
28
//------------------------------------------------------------------------------------------------
31
void
UpdateImpactPosition
(
vector
position
)
32
{
33
m_iCollisionsCounter
++;
34
m_vImpactPosition
+=
position
;
35
}
36
37
//------------------------------------------------------------------------------------------------
39
vector
GetOwnerVelocityBefore
()
40
{
41
return
m_vOwnerVelocityBefore
;
42
}
43
44
//------------------------------------------------------------------------------------------------
46
vector
GetOtherVelocityBefore
()
47
{
48
return
m_vOtherVelocityBefore
;
49
}
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;
70
m_iCollisionsCounter
= 1;
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
}
impulse
SCR_DestructibleTreeV2Class impulse
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
IEntity
Definition
IEntity.c:13
Math
Definition
Math.c:13
Physics
Definition
Physics.c:22
SCR_CollisionDamageContainer::m_vImpactPosition
vector m_vImpactPosition
Definition
SCR_CollisionDamageContainer.c:17
SCR_CollisionDamageContainer::GetOwnerVelocityBefore
vector GetOwnerVelocityBefore()
Definition
SCR_CollisionDamageContainer.c:39
SCR_CollisionDamageContainer::m_vOwnerVelocityBefore
vector m_vOwnerVelocityBefore
Definition
SCR_CollisionDamageContainer.c:18
SCR_CollisionDamageContainer::GetOtherVelocityBefore
vector GetOtherVelocityBefore()
Definition
SCR_CollisionDamageContainer.c:46
SCR_CollisionDamageContainer::m_iCollisionsCounter
int m_iCollisionsCounter
Definition
SCR_CollisionDamageContainer.c:16
SCR_CollisionDamageContainer::m_vOtherVelocityBefore
vector m_vOtherVelocityBefore
Definition
SCR_CollisionDamageContainer.c:19
SCR_CollisionDamageContainer::SCR_CollisionDamageContainer
void SCR_CollisionDamageContainer(notnull IEntity owner, notnull IEntity other, float impulse, vector velocityBefore1, vector velocityAfter1, vector velocityBefore2, vector velocityAfter2, vector impactPosition, vector impactNormal)
Definition
SCR_CollisionDamageContainer.c:62
SCR_CollisionDamageContainer::GetAverageImpactPosition
vector GetAverageImpactPosition()
Definition
SCR_CollisionDamageContainer.c:23
SCR_CollisionDamageContainer::UpdateImpactPosition
void UpdateImpactPosition(vector position)
Definition
SCR_CollisionDamageContainer.c:31
vector
Definition
vector.c:13
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
scripts
Game
Components
Damage
SCR_CollisionDamageContainer.c
Generated by
1.17.0