DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CatchingResultBasic.c
См. документацию.
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(GetGame().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)
Определения CatchingContextBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
void UpdateCatchQuality(CatchingContextBase ctx)
Определения CatchingResultBasic.c:52
YieldItemBase m_YItem
Определения CatchingResultBasic.c:8
float RollChanceSeeded()
Определения CatchingResultBasic.c:92
bool m_OverrideQualityActive
Определения CatchingResultBasic.c:5
void UpdateCatchChance(CatchingContextBase ctx)
Определения CatchingResultBasic.c:64
float m_CatchChance
Определения CatchingResultBasic.c:6
void CatchingResultBasic(EntityAI owner)
Определения CatchingResultBasic.c:10
void SetCatchChanceOverride(bool ovrd, float val=0.0)
Определения CatchingResultBasic.c:38
EntityAI SpawnAndSetup(out int yItemIdx, vector v=vector.Zero)
Определения CatchingResultBasic.c:97
bool RollChance()
Определения CatchingResultBasic.c:76
void SetQuality(float val)
Определения CatchingResultBasic.c:33
float m_Quality
Определения CatchingResultBasic.c:7
void SetQualityOverride(bool ovrd, float val=0.0)
Определения CatchingResultBasic.c:45
bool m_OverrideChanceActive
Определения CatchingResultBasic.c:4
void SetCatchChance(float val)
Определения CatchingResultBasic.c:28
void SetYieldItem(YieldItemBase yItem)
Определения CatchingResultBasic.c:15
EntityAI m_Owner
Определения CatchingResultBasic.c:3
int GetYieldItemParticleId()
Определения CatchingResultBasic.c:20
Определения Building.c:6
Определения EnMath.c:7
static const int INVALID
Определения ParticleList.c:20
Определения ParticleList.c:12
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
proto native CGame GetGame()
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
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'.