Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
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();
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 {
73 }
74 m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY, 1.0);
75 m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY_RND, 1.0);
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 {
113 OnIgnitedThis(null);
114 }
115 else if (action_id == EActions.BROOM_BURN_SHORT)
116 {
118 OnIgnitedThis(null);
119 }
120 else if (action_id == EActions.BROOM_BURN_MEDIUM)
121 {
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 CanTransformIntoStick()
Definition broom.c:35
void DebugSetHealthAndEnergy(float time)
Definition broom.c:85
override void ApplyResultModifications(ItemBase result)
Definition broom.c:29
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition broom.c:104
override void Init()
Definition broom.c:3
override bool CanReceiveUpgrade()
Definition broom.c:18
override void UpdateParticle()
Definition broom.c:66
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition broom.c:44
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition broom.c:93
override void OnWorkStart()
Definition broom.c:23
override void CalculateQuantity()
Definition broom.c:52
override void SetActions()
Definition broom.c:10
string GetBurningMaterial()
Definition torch.c:803
vector m_ParticleLocalPos
Definition torch.c:29
Particle m_FireParticle
Definition torch.c:15
override bool IsIgnited()
Definition torch.c:141
string GetBurntMaterial()
Definition torch.c:808
override void OnIgnitedThis(EntityAI fire_source)
Definition torch.c:204
string m_DecraftResult
Definition torch.c:31
void FlammableBase()
Definition torch.c:9
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Definition enmath.c:7
static const int BROOM_TORCH_T1
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.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Min(float x, float y)
Returns smaller of two given values.
EmitorParam
Definition envisual.c:114
const int SAT_DEBUG_ACTION
Definition constants.c:457
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
float GetEnergy()
Definition itembase.c:8525
override float GetQuantity()
Definition itembase.c:8398
override int GetQuantityMax()
Definition itembase.c:8349
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).