DayZ
1.29
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
CatchingResultBasic.c
См. документацию.
1
class
CatchingResultBasic
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
8
protected
YieldItemBase
m_YItem
;
9
10
void
CatchingResultBasic
(
EntityAI
owner)
11
{
12
m_Owner
= owner;
13
}
14
15
void
SetYieldItem
(
YieldItemBase
yItem)
16
{
17
m_YItem
= yItem;
18
}
19
20
int
GetYieldItemParticleId
()
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;
42
m_OverrideChanceActive
= ovrd;
43
}
44
45
void
SetQualityOverride
(
bool
ovrd,
float
val = 0.0)
46
{
47
if
(ovrd)
48
m_Quality
= val;
49
m_OverrideQualityActive
= ovrd;
50
}
51
52
void
UpdateCatchQuality
(
CatchingContextBase
ctx)
53
{
54
if
(
m_OverrideQualityActive
)
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
{
66
if
(
m_OverrideChanceActive
)
67
return
;
68
69
if
(!
m_YItem
)
70
return
;
71
72
float
val =
m_YItem
.GetChanceForYieldItem(ctx);
73
SetCatchChance
(val);
74
}
75
76
bool
RollChance
()
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
};
CatchingContextBase
void CatchingContextBase(Param par)
Определения
CatchingContextBase.c:29
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Определения
CentralEconomy.c:37
g_Game
DayZGame g_Game
Определения
DayZGame.c:3942
CatchingResultBasic::UpdateCatchQuality
void UpdateCatchQuality(CatchingContextBase ctx)
Определения
CatchingResultBasic.c:52
CatchingResultBasic::m_YItem
YieldItemBase m_YItem
Определения
CatchingResultBasic.c:8
CatchingResultBasic::RollChanceSeeded
float RollChanceSeeded()
Определения
CatchingResultBasic.c:92
CatchingResultBasic::m_OverrideQualityActive
bool m_OverrideQualityActive
Определения
CatchingResultBasic.c:5
CatchingResultBasic::UpdateCatchChance
void UpdateCatchChance(CatchingContextBase ctx)
Определения
CatchingResultBasic.c:64
CatchingResultBasic::m_CatchChance
float m_CatchChance
Определения
CatchingResultBasic.c:6
CatchingResultBasic::CatchingResultBasic
void CatchingResultBasic(EntityAI owner)
Определения
CatchingResultBasic.c:10
CatchingResultBasic::SetCatchChanceOverride
void SetCatchChanceOverride(bool ovrd, float val=0.0)
Определения
CatchingResultBasic.c:38
CatchingResultBasic::SpawnAndSetup
EntityAI SpawnAndSetup(out int yItemIdx, vector v=vector.Zero)
Определения
CatchingResultBasic.c:97
CatchingResultBasic::RollChance
bool RollChance()
Определения
CatchingResultBasic.c:76
CatchingResultBasic::SetQuality
void SetQuality(float val)
Определения
CatchingResultBasic.c:33
CatchingResultBasic::m_Quality
float m_Quality
Определения
CatchingResultBasic.c:7
CatchingResultBasic::SetQualityOverride
void SetQualityOverride(bool ovrd, float val=0.0)
Определения
CatchingResultBasic.c:45
CatchingResultBasic::m_OverrideChanceActive
bool m_OverrideChanceActive
Определения
CatchingResultBasic.c:4
CatchingResultBasic::SetCatchChance
void SetCatchChance(float val)
Определения
CatchingResultBasic.c:28
CatchingResultBasic::SetYieldItem
void SetYieldItem(YieldItemBase yItem)
Определения
CatchingResultBasic.c:15
CatchingResultBasic::m_Owner
EntityAI m_Owner
Определения
CatchingResultBasic.c:3
CatchingResultBasic::GetYieldItemParticleId
int GetYieldItemParticleId()
Определения
CatchingResultBasic.c:20
EntityAI
Определения
3_Game/DayZ/Entities/InventoryItem.c:2
Math
Определения
EnMath.c:7
ParticleList::INVALID
static const int INVALID
Определения
ParticleList.c:20
ParticleList
Определения
ParticleList.c:12
YieldItemBase
Определения
CatchYieldItemBase.c:2
vector::Zero
static const vector Zero
Определения
EnConvert.c:123
vector
Определения
EnConvert.c:119
Math::RandomFloat01
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения
EnMath.c:126
Math::Clamp
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'.
Ishodniki
scripts
3_Game
DayZ
Systems
AnimalCatching
CatchingResultBasic.c
Создано системой
1.13.2