Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
catchingresultbasic.c
Go to the documentation of this file.
2{
3 protected EntityAI m_Owner;
4 protected bool m_OverrideChanceActive = false; //do not perform chance updates
5 protected bool m_OverrideQualityActive = false; //overrides quality
6 protected float m_CatchChance = 1.0; //guaranteed catch by default
7 protected float m_Quality = 1.0; //max quality default
9
11 {
12 m_Owner = owner;
13 }
14
16 {
17 m_YItem = yItem;
18 }
19
21 {
22 if (m_YItem)
23 return m_YItem.GetCatchParticleID();
24
25 return ParticleList.INVALID;
26 }
27
28 protected void SetCatchChance(float val)
29 {
30 m_CatchChance = Math.Clamp(val,0,1);
31 }
32
33 protected void SetQuality(float val)
34 {
35 m_Quality = Math.Clamp(val,0,1);
36 }
37
38 void SetCatchChanceOverride(bool ovrd, float val = 0.0)
39 {
40 if (ovrd)
41 m_CatchChance = val;
43 }
44
45 void SetQualityOverride(bool ovrd, float val = 0.0)
46 {
47 if (ovrd)
48 m_Quality = val;
50 }
51
53 {
55 return;
56
57 if (!m_YItem)
58 return;
59
60 float val = m_YItem.GetQualityForYieldItem(ctx);
61 SetQuality(val);
62 }
63
65 {
67 return;
68
69 if (!m_YItem)
70 return;
71
72 float val = m_YItem.GetChanceForYieldItem(ctx);
73 SetCatchChance(val);
74 }
75
77 {
78 if (m_CatchChance >= 1)
79 return true;
80 if (m_CatchChance <= 0)
81 return false;
82
83 float roll;
84 if (m_Owner && m_Owner.GetHierarchyRootPlayer())
85 roll = RollChanceSeeded();
86 else
87 roll = Math.RandomFloat01();
88
89 return roll < m_CatchChance;
90 }
91
92 protected float RollChanceSeeded()
93 {
94 return 1.0;
95 }
96
97 EntityAI SpawnAndSetup(out int yItemIdx, vector v = vector.Zero)
98 {
99 vector pos = v;
100 if (v == vector.Zero && m_Owner != null)
101 pos = m_Owner.GetPosition();
102
103 if (!m_YItem)
104 return null;
105
106 yItemIdx = m_YItem.GetRegistrationIdx();
107 EntityAI ret = EntityAI.Cast(g_Game.CreateObjectEx(m_YItem.GetType(), pos, ECE_PLACE_ON_SURFACE));
108 if (ret)
109 m_YItem.OnEntityYieldSpawned(ret);
110
111 return ret;
112 }
113};
void CatchingContextBase(Param par)
const int ECE_PLACE_ON_SURFACE
void SetCatchChance(float val)
void UpdateCatchQuality(CatchingContextBase ctx)
void SetQuality(float val)
void SetYieldItem(YieldItemBase yItem)
void CatchingResultBasic(EntityAI owner)
void SetCatchChanceOverride(bool ovrd, float val=0.0)
void UpdateCatchChance(CatchingContextBase ctx)
EntityAI SpawnAndSetup(out int yItemIdx, vector v=vector.Zero)
void SetQualityOverride(bool ovrd, float val=0.0)
Definition enmath.c:7
static const int INVALID
static const vector Zero
Definition enconvert.c:123
DayZGame g_Game
Definition dayzgame.c:3942
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition enmath.c:126