Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TreeHitZoneV2.c
Go to the documentation of this file.
2 {
3  [Attribute("0", UIWidgets.EditBox, "Enter the tree part number.")]
4  private int m_iTreePartIndex;
5 
6 #ifdef ENABLE_DESTRUCTION
7  private SCR_TreePartV2 m_OwnerPart;
8  private SCR_DestructibleTreeV2 m_OwnerTree;
9  private IEntity m_OwnerEntity;
10 
11  //------------------------------------------------------------------------------------------------
12  override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
13  {
14  //Determine whether this hit zone is on a tree part or a destructible tree
15  m_OwnerPart = SCR_TreePartV2.Cast(pOwnerEntity);
16  if (!m_OwnerPart)
17  {
18  m_OwnerEntity = pOwnerEntity;
19  while (m_OwnerEntity)
20  {
21  m_OwnerTree = SCR_DestructibleTreeV2.Cast(m_OwnerEntity);
22  if (m_OwnerTree)
23  return;
24 
25  m_OwnerEntity = m_OwnerEntity.GetParent();
26  }
27  }
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  override void OnDamage(float damage,
33  IEntity pHitEntity,
34  inout vector outMat[3],
35  IEntity damageSource,
36  notnull Instigator instigator,
37  int colliderID,
38  float speed)
39  {
40  if (RplSession.Mode() == RplMode.Client)
41  return;
42 
43  //Calculate direction vector based on normal of the hit
44  vector directionVector = -outMat[2];
45  directionVector.Normalize();
46 
47  AddDamage(damage);
48  //If the damage / impulse was big enough to move the tree part
49  if (GetDamageState() == EDamageState.DESTROYED)
50  {
51  //Calculate impulse vector from direction vector and damage
52  vector positionVector = outMat[0];
53 
54  if (type == EDamageType.EXPLOSIVE)
55  {
56  positionVector = "0 0 0";
57  if (m_OwnerEntity)
58  directionVector = (m_OwnerEntity.GetOrigin() - outMat[0]) * damage;
59  }
60 
61  directionVector.Normalize();
62  vector impulseVector = directionVector * (damage / 10);
63  if (m_OwnerPart)
64  {
65  m_OwnerPart.SetToBreak(positionVector: positionVector, impulseVector: impulseVector, damageType: type);
66  return;
67  }
68 
69  if (m_OwnerTree)
70  {
71  //m_OwnerTree.SetToDestroy(positionVector, impulseVector, m_iTreePartIndex);
72  }
73  }
74  }
75 #endif
76 }
OnDamage
override protected void OnDamage(notnull BaseDamageContext damageContext)
Definition: SCR_ArmorDamageManagerComponent.c:11
SCR_TreeHitZoneV2
Definition: SCR_TreeHitZoneV2.c:1
EDamageState
EDamageState
Definition: EDamageState.c:12
Instigator
Definition: Instigator.c:6
SCR_TreePartV2
Definition: SCR_TreePartV2.c:8
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_DestructibleTreeV2
Encapsulates the functionality of a destructible tree entity in the world.
Definition: SCR_DestructibleTreeV2.c:55
SCR_HitZone
Definition: SCR_HitZone.c:1
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
EDamageType
EDamageType
Definition: EDamageType.c:12
OnInit
override protected void OnInit(IEntity owner)
Definition: SCR_CharacterCommandHandler_Tests.c:523
m_OwnerEntity
SCR_AIUtilityComponentClass m_OwnerEntity