Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
propertymodifiers.c
Go to the documentation of this file.
2 {
3  vector m_RecoilModifiers;
4  vector m_SwayModifiers;
5  vector m_SightMisalignment;
6 
7  float m_BarrelLength;
8  //ref Timer test_timer;
9  ItemBase m_OwnerItem;
10  float m_Weapon
11 
12  void PropertyModifiers(ItemBase owner)
13  {
14  //test_timer = new Timer();
15  //test_timer.Run(5, this, "Refresh", NULL, true);
16  m_OwnerItem = owner;
17  UpdateModifiers();
18  m_BarrelLength = CalculateBarrelLength(owner);
19  }
20 
22  float GetBarrelLength()
23  {
24  //return m_BarrelLength * 1000:
25  return CalculateBarrelLength(m_OwnerItem) * 1000;
26  }
27 
28  float CalculateBarrelLength(ItemBase owner)
29  {
30  vector usti_hlavne_position = owner.GetSelectionPositionLS( "usti hlavne" );//usti hlavne
31  vector konec_hlavne_position = owner.GetSelectionPositionLS( "konec hlavne" );//konec hlavne
32  usti_hlavne_position = owner.ModelToWorld(usti_hlavne_position);
33  konec_hlavne_position = owner.ModelToWorld(konec_hlavne_position);
34  return vector.Distance(usti_hlavne_position, konec_hlavne_position);
35  }
36 
37 
38  void UpdateModifiers()
39  {
40  m_RecoilModifiers = GetModifierRaw(m_OwnerItem, "recoilModifier");
41  m_SwayModifiers = GetModifierRaw(m_OwnerItem, "swayModifier");
42  m_SightMisalignment = GetModifierRaw(m_OwnerItem, "sightMisalignmentModifier");
43 
44  for (int i = 0; i < m_OwnerItem.GetInventory().AttachmentCount(); i++)
45  {
46  ItemBase attachment = ItemBase.Cast(m_OwnerItem.GetInventory().GetAttachmentFromIndex(i));
47 
48  vector temp_value = PropertyModifiers.GetModifierRaw(attachment, "recoilModifier");
49  m_RecoilModifiers[0] = m_RecoilModifiers[0] * temp_value[0];
50  m_RecoilModifiers[1] = m_RecoilModifiers[1] * temp_value[1];
51  m_RecoilModifiers[2] = m_RecoilModifiers[2] * temp_value[2];
52 
53  temp_value = PropertyModifiers.GetModifierRaw(attachment, "swayModifier");
54  m_SwayModifiers[0] = m_SwayModifiers[0] * temp_value[0];
55  m_SwayModifiers[1] = m_SwayModifiers[1] * temp_value[1];
56  m_SwayModifiers[2] = m_SwayModifiers[2] * temp_value[2];
57 
58  temp_value = PropertyModifiers.GetModifierRaw(attachment, "sightMisalignmentModifier");
59  m_SightMisalignment[0] = m_SightMisalignment[0] * temp_value[0];
60  m_SightMisalignment[1] = m_SightMisalignment[1] * temp_value[1];
61  m_SightMisalignment[2] = m_SightMisalignment[2] * temp_value[2];
62  }
63  }
64 
65  static vector GetModifierRaw(ItemBase item, string modifier_name, vector value = "1 1 1")
66  {
67  if( item.ConfigIsExisting(modifier_name) )
68  {
69  value = item.ConfigGetVector(modifier_name);
70  }
71  return value;
72  }
73 
74 }
ItemBase
Definition: inventoryitem.c:730
m_Weapon
protected InventoryItem m_Weapon
Weapons - cache.
Definition: dayzplayerimplementmeleecombat.c:57
vector
Definition: enconvert.c:105
PropertyModifiers
Definition: propertymodifiers.c:1