Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
broom.c
Go to the documentation of this file.
1class BroomBase : FlammableBase
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();
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 ( g_Game.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 (g_Game.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.RED));
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 (g_Game.IsServer() || !g_Game.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
136class Broom: BroomBase
137{
138 override string GetBurningMaterial()
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";
147};
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
void AddAction(typename actionName)
override bool IsIgnited()
Definition torch.c:141
bool CanTransformIntoStick()
Definition torch.c:471
override void OnIgnitedThis(EntityAI fire_source)
Definition torch.c:204
override void SetActions()
Definition torch.c:761
string GetBurningMaterial()
Definition torch.c:803
override void OnWorkStart()
Definition torch.c:523
void CalculateQuantity()
Definition torch.c:422
bool CanReceiveUpgrade()
Definition torch.c:430
void UpdateParticle()
Definition torch.c:667
void Init()
Definition torch.c:47
string GetBurntMaterial()
Definition torch.c:808
Definition enmath.c:7
DayZGame g_Game
Definition dayzgame.c:3942
EActions
Definition eactions.c:2
Serializer ParamsReadContext
Definition gameplay.c:15
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EmitorParam
Definition envisual.c:114
const int SAT_DEBUG_ACTION
Definition constants.c:457
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override float GetQuantity()
Definition itembase.c:8398
float GetEnergy()
Definition itembase.c:8525
override int GetQuantityMax()
Definition itembase.c:8349
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).