Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
broom.c
Go to the documentation of this file.
2 {
3  override void Init()
4  {
5  super.Init();
6  m_DecraftResult = "LongWoodenStick";
7  m_ParticleLocalPos = Vector(0, 1.2, 0);
8  }
9 
10  override void SetActions()
11  {
12  super.SetActions();
13 
16  }
17 
18  override bool CanReceiveUpgrade()
19  {
20  return false;
21  }
22 
23  override void OnWorkStart()
24  {
25  super.OnWorkStart();
26  CalculateQuantity();
27  }
28 
29  override void ApplyResultModifications(ItemBase result)
30  {
31  result.SetHealth(result.GetHealthLevelValue(2,""));
32  result.SetQuantity(1);
33  }
34 
35  override bool CanTransformIntoStick()
36  {
37  if ( GetGame().IsServer() && !IsIgnited() && GetEnergy() < 1 && !IsSetForDeletion())
38  return true;
39  else
40  return false;
41  }
42 
43 
44  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
45  {
46  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
47 
48  GetCompEM().SetEnergy0To1(GetHealth01("",""));
49  }
50 
51 
52  override void CalculateQuantity()
53  {
54  if (GetGame().IsServer())
55  {
56  float currentHealth01 = GetHealth01();
57  float currentEnergy01 = GetCompEM().GetEnergy0To1();
58 
59  //Health needs to copy internal energy, but only if that means it will be going down from its current value(the item can't heal itself after obtaining damage just because it has full internal energy)
60  SetHealth01("","",Math.Min(currentHealth01,currentEnergy01));
61  //Energy needs to copy health, but only if it is higher(in 01 terms) than health, that means if an item with full energy gets damaged and lit, the internal energy needs to be adjusted to follow the health. Situations where internal energy is lower than health are handled on the line above
62  GetCompEM().SetEnergy0To1(GetHealth01());
63  }
64  }
65 
66  override void UpdateParticle()
67  {
68  float normalizedQuant = GetQuantity() / GetQuantityMax();
69 
70  if (!m_FireParticle)
71  {
72  m_FireParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.BROOM_TORCH_T1, this, m_ParticleLocalPos);
73  }
74  m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY, 1.0);
75  m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY_RND, 1.0);
76  if (m_FireParticle)
77  {
78  float scale = Math.Max(normalizedQuant * 2.4, 0.4);
79 
80  m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.SIZE, scale);
81  }
82  }
83 
84  // DEBUG BELLOW
85  void DebugSetHealthAndEnergy(float time)
86  {
87  float max_energy = GetCompEM().GetEnergyMaxPristine();
88  float health01 = Math.InverseLerp(0, max_energy, time);
89  SetHealth01("","", health01);
90  GetCompEM().SetEnergy( time );
91  }
92 
93  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
94  {
95  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BROOM_BURN_VERY_SHORT, "SetBurnTimeTo15Secs", FadeColors.LIGHT_GREY));
96  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BROOM_BURN_SHORT, "SetBurnTimeTo1Min", FadeColors.LIGHT_GREY));
97  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BROOM_BURN_MEDIUM, "SetBurnTimeTo10Min", FadeColors.LIGHT_GREY));
98  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BROOM_BURN_LONG, "SetBurnTimeToMax", FadeColors.LIGHT_GREY));
99  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
100 
101  super.GetDebugActions(outputList);
102  }
103 
104  override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
105  {
106  if (super.OnAction(action_id, player, ctx))
107  return true;
108  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
109  {
110  if (action_id == EActions.BROOM_BURN_VERY_SHORT)
111  {
112  DebugSetHealthAndEnergy(15);
113  OnIgnitedThis(null);
114  }
115  else if (action_id == EActions.BROOM_BURN_SHORT)
116  {
117  DebugSetHealthAndEnergy(60);
118  OnIgnitedThis(null);
119  }
120  else if (action_id == EActions.BROOM_BURN_MEDIUM)
121  {
122  DebugSetHealthAndEnergy(600);
123  OnIgnitedThis(null);
124  }
125  else if (action_id == EActions.BROOM_BURN_LONG)
126  {
127  DebugSetHealthAndEnergy(GetCompEM().GetEnergyMaxPristine());
128  OnIgnitedThis(null);
129  }
130  }
131  return false;
132  }
133 
134 }
135 
136 class Broom: BroomBase
137 {
138  override string GetBurningMaterial()
139  {
140  return "DZ\\gear\\tools\\data\\broom_emissive.rvmat";
141  }
142 
143  override string GetBurntMaterial()
144  {
145  return "DZ\\gear\\tools\\data\\broom_burn.rvmat";
146  }
147 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
OnIgnitedThis
override void OnIgnitedThis(EntityAI fire_source)
Executed on Server when some item ignited this one.
Definition: fireworksbase.c:96
GetBurntMaterial
override string GetBurntMaterial()
Definition: broom.c:143
ActionBreakLongWoodenStick
Definition: actionbreaklongwoodenstick.c:12
BroomBase
Definition: broom.c:1
GetQuantityMax
override int GetQuantityMax()
Definition: itembase.c:3262
GetQuantity
override float GetQuantity()
Definition: itembase.c:3316
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
EmitorParam
EmitorParam
Definition: envisual.c:113
ActionClapBearTrapWithThisItem
Definition: actionclapbeartrapwiththisitem.c:1
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
ParticleList
Definition: particlelist.c:11
vector
Definition: enconvert.c:105
TotalDamageResult
Definition: damagesystem.c:1
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
EActions
EActions
Definition: eactions.c:1
GetEnergy
float GetEnergy()
Definition: itembase.c:3461
GetBurningMaterial
BroomBase FlammableBase GetBurningMaterial()
Definition: broom.c:138
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
FlammableBase
Definition: torch.c:1
Math
Definition: enmath.c:6
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EntityAI
Definition: building.c:5