Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
arrowmanagerplayer.c
Go to the documentation of this file.
1
class
ArrowManagerPlayer
:
ArrowManagerBase
2
{
3
private
static
ref
map<int,typename>
m_TypeHashTable
;
4
5
void
ArrowManagerPlayer
(
EntityAI
owner)
6
{
7
if
(!
m_TypeHashTable
)
8
{
9
InitializeHash
();
10
}
11
}
12
13
private
static
void
InitializeHash
()
14
{
15
m_TypeHashTable
=
new
map<int,typename>
();
16
17
AddArrowTypeToHash
(
"Ammo_HuntingBolt"
);
18
AddArrowTypeToHash
(
"Ammo_ImprovisedBolt_1"
);
19
AddArrowTypeToHash
(
"Ammo_ImprovisedBolt_2"
);
20
AddArrowTypeToHash
(
"Ammo_ImprovisedBolt_3"
);
21
}
22
23
private
static
void
AddArrowTypeToHash
(
string
ArrowType)
24
{
25
m_TypeHashTable
.Insert(ArrowType.
Hash
(), ArrowType.
ToType
());
26
}
27
28
private
static
typename
GetArrowTypeFromHash
(
int
hash)
29
{
30
return
m_TypeHashTable
.Get(hash);
31
}
32
33
bool
Save
(
ParamsWriteContext
ctx)
34
{
35
ctx.
Write
(
VERSION
);
36
int
count =
m_Arrows
.Count();
37
int
i;
38
//TODO MW Delete after find why sometimes arrow missing - most likely Life span
39
for
(i = count - 1; i >= 0; i--)
40
{
41
if
(!
m_Arrows
.Get(i))
42
{
43
m_Arrows
.Remove(i);
44
}
45
}
46
count =
m_Arrows
.Count();
47
48
ctx.
Write
(count);
49
50
for
(i = 0; i < count; i++)
51
{
52
EntityAI
arrow =
m_Arrows
.Get(i);
53
54
string
type = arrow.GetType();
55
ctx.
Write
(type.
Hash
());
56
57
vector
angle = arrow.GetLocalYawPitchRoll();
58
vector
pos = arrow.GetLocalPosition();
59
60
ctx.
Write
(angle[0]);
61
ctx.
Write
(angle[1]);
62
ctx.
Write
(angle[2]);
63
ctx.
Write
(pos[0]);
64
ctx.
Write
(pos[1]);
65
ctx.
Write
(pos[2]);
66
67
int
pivot = arrow.GetHierarchyPivot();
68
ctx.
Write
(pivot);
69
}
70
71
return
true
;
72
}
73
74
75
bool
Load
(
ParamsReadContext
ctx)
76
{
77
int
version;
78
if
(!ctx.
Read
(version))
79
{
80
return
false
;
81
}
82
83
int
count;
84
if
(!ctx.
Read
(count))
85
{
86
return
false
;
87
}
88
89
for
(
int
i = 0; i < count; i++)
90
{
91
92
if
(version >= 1)
93
{
94
int
hash;
95
if
(!ctx.
Read
(hash))
96
{
97
return
false
;
98
}
99
100
float
angleF[3];
101
float
posF[3];
102
float
value;
103
104
if
(!ctx.
Read
(value))
105
{
106
return
false
;
107
}
108
angleF[0] = value;
109
110
if
(!ctx.
Read
(value))
111
{
112
return
false
;
113
}
114
angleF[1] = value;
115
116
if
(!ctx.
Read
(value))
117
{
118
return
false
;
119
}
120
angleF[2] = value;
121
122
if
(!ctx.
Read
(value))
123
{
124
return
false
;
125
}
126
posF[0] = value;
127
128
if
(!ctx.
Read
(value))
129
{
130
return
false
;
131
}
132
posF[1] = value;
133
134
if
(!ctx.
Read
(value))
135
{
136
return
false
;
137
}
138
posF[2] = value;
139
140
vector
angle =
"0 0 0"
;
141
vector
pos =
"0 0 0"
;
142
143
angle =
vector
.
ArrayToVec
(angleF);
144
pos =
vector
.
ArrayToVec
(posF);
145
146
int
pivot;
147
if
(!ctx.
Read
(pivot))
148
{
149
return
false
;
150
}
151
152
if
(version >= 2)
153
{
154
#ifdef SERVER
155
int
spawnFlags =
ECE_KEEPHEIGHT
|
ECE_DYNAMIC_PERSISTENCY
;
156
#else
157
int
spawnFlags =
ECE_LOCAL
|
ECE_KEEPHEIGHT
|
ECE_DYNAMIC_PERSISTENCY
;
158
#endif
159
160
typename
arrowType =
GetArrowTypeFromHash
(hash);
161
EntityAI
arrow =
EntityAI
.Cast(
g_Game
.CreateObjectEx(arrowType.ToString(), pos, spawnFlags));
162
if
(arrow)
163
{
164
arrow.SetQuantityToMinimum();
165
arrow.SetYawPitchRoll(angle);
166
m_Owner
.AddChild(arrow, pivot);
167
}
168
}
169
}
170
171
}
172
173
return
true
;
174
}
175
}
ECE_LOCAL
const int ECE_LOCAL
Definition
centraleconomy.c:24
ECE_KEEPHEIGHT
const int ECE_KEEPHEIGHT
Definition
centraleconomy.c:27
ECE_DYNAMIC_PERSISTENCY
const int ECE_DYNAMIC_PERSISTENCY
Definition
centraleconomy.c:32
ArrowManagerBase::m_Owner
EntityAI m_Owner
Definition
arrowmanagerbase.c:5
ArrowManagerBase::VERSION
const int VERSION
Definition
arrowmanagerbase.c:3
ArrowManagerBase::ArrowManagerBase
void ArrowManagerBase(EntityAI owner)
Definition
arrowmanagerbase.c:7
ArrowManagerBase::m_Arrows
ref array< EntityAI > m_Arrows
Definition
arrowmanagerbase.c:4
ArrowManagerPlayer::m_TypeHashTable
static ref map< int, typename > m_TypeHashTable
Definition
arrowmanagerplayer.c:3
ArrowManagerPlayer::AddArrowTypeToHash
static void AddArrowTypeToHash(string ArrowType)
Definition
arrowmanagerplayer.c:23
ArrowManagerPlayer::Load
bool Load(ParamsReadContext ctx)
Definition
arrowmanagerplayer.c:75
ArrowManagerPlayer::Save
bool Save(ParamsWriteContext ctx)
Definition
arrowmanagerplayer.c:33
ArrowManagerPlayer::GetArrowTypeFromHash
static GetArrowTypeFromHash(int hash)
Definition
arrowmanagerplayer.c:28
ArrowManagerPlayer::ArrowManagerPlayer
void ArrowManagerPlayer(EntityAI owner)
Definition
arrowmanagerplayer.c:5
ArrowManagerPlayer::InitializeHash
static void InitializeHash()
Definition
arrowmanagerplayer.c:13
EntityAI
Definition
inventoryitem.c:2
Serializer::Write
proto bool Write(void value_out)
Serializer::Read
proto bool Read(void value_in)
map
Definition
cachedequipmentstorage.c:4
vector
Definition
enconvert.c:119
vector::ArrayToVec
static vector ArrayToVec(float arr[])
Convert static array of floats into a vector.
Definition
enconvert.c:515
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
ParamsWriteContext
Serializer ParamsWriteContext
Definition
gameplay.c:16
string::ToType
proto native ToType()
Returns internal type representation.
string::Hash
proto native int Hash()
Returns hash of string.
Games
Dayz
scripts
4_world
classes
arrowmanager
arrowmanagerplayer.c
Generated by
1.17.0