Dayz Explorer 1.28.160049
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)
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
52 void UpdateCatchQuality(CatchingContextBase ctx)
53 {
55 return;
56
57 if (!m_YItem)
58 return;
59
60 float val = m_YItem.GetQualityForYieldItem(ctx);
61 SetQuality(val);
62 }
63
64 void UpdateCatchChance(CatchingContextBase ctx)
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(GetGame().CreateObjectEx(m_YItem.GetType(), pos, ECE_PLACE_ON_SURFACE));
108 if (ret)
110
111 return ret;
112 }
113};
const int ECE_PLACE_ON_SURFACE
void UpdateCatchQuality(CatchingContextBase ctx)
void UpdateCatchChance(CatchingContextBase ctx)
void CatchingResultBasic(EntityAI owner)
void SetCatchChanceOverride(bool ovrd, float val=0.0)
EntityAI SpawnAndSetup(out int yItemIdx, vector v=vector.Zero)
void SetQuality(float val)
void SetQualityOverride(bool ovrd, float val=0.0)
void SetCatchChance(float val)
void SetYieldItem(YieldItemBase yItem)
Definition enmath.c:7
float GetChanceForYieldItem(CatchingContextBase ctx)
void OnEntityYieldSpawned(EntityAI spawn)
called on item spawn
float GetQualityForYieldItem(CatchingContextBase ctx)
proto native CGame GetGame()