Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TreeHitZoneV2.c
Go to the documentation of this file.
1//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2// TODO: Data redundancy is very high, variables are private and replication handling is invalid
4{
5 [Attribute("0", UIWidgets.EditBox, "Enter the tree part number.")]
6 private int m_iTreePartIndex;
7
8#ifdef ENABLE_DESTRUCTION
9 private SCR_TreePartV2 m_OwnerPart;
10 private SCR_DestructibleTreeV2 m_OwnerTree;
11 private IEntity m_OwnerEntity;
12
13 //------------------------------------------------------------------------------------------------
14 override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
15 {
16 //Determine whether this hit zone is on a tree part or a destructible tree
17 m_OwnerPart = SCR_TreePartV2.Cast(pOwnerEntity);
18 if (!m_OwnerPart)
19 {
20 m_OwnerEntity = pOwnerEntity;
21 while (m_OwnerEntity)
22 {
23 m_OwnerTree = SCR_DestructibleTreeV2.Cast(m_OwnerEntity);
24 if (m_OwnerTree)
25 return;
26
27 m_OwnerEntity = m_OwnerEntity.GetParent();
28 }
29 }
30 }
31
32 //------------------------------------------------------------------------------------------------
33 override void OnDamage(float damage,
35 IEntity pHitEntity,
36 inout vector outMat[3],
37 IEntity damageSource,
38 notnull Instigator instigator,
39 int colliderID,
40 float speed)
41 {
42 if (RplSession.Mode() == RplMode.Client)
43 return;
44
45 //Calculate direction vector based on normal of the hit
46 vector directionVector = -outMat[2];
47 directionVector.Normalize();
48
49 AddDamage(damage);
50 //If the damage / impulse was big enough to move the tree part
51 if (GetDamageState() == EDamageState.DESTROYED)
52 {
53 //Calculate impulse vector from direction vector and damage
54 vector positionVector = outMat[0];
55
56 if (type == EDamageType.EXPLOSIVE)
57 {
58 positionVector = "0 0 0";
59 if (m_OwnerEntity)
60 directionVector = (m_OwnerEntity.GetOrigin() - outMat[0]) * damage;
61 }
62
63 directionVector.Normalize();
64 vector impulseVector = directionVector * (damage / 10);
65 if (m_OwnerPart)
66 {
67 m_OwnerPart.SetToBreak(positionVector: positionVector, impulseVector: impulseVector, damageType: type);
68 return;
69 }
70
71 if (m_OwnerTree)
72 {
73 //m_OwnerTree.SetToDestroy(positionVector, impulseVector, m_iTreePartIndex);
74 }
75 }
76 }
77#endif
78}
79//---- REFACTOR NOTE END ----
RplMode
Mode of replication.
Definition RplMode.c:9
SCR_AIUtilityComponentClass m_OwnerEntity
SCR_CharacterBloodHitZone OnDamage
Resilience - incapacitation or death, depending on game mode settings.
EDamageType type
Encapsulates the functionality of a destructible tree entity in the world.
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13
EDamageState