Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
cfgplayerspawndatajson.c
Go to the documentation of this file.
1
class
PlayerSpawnJsonDataBase
:
Managed
2
{
4
5
bool
IsValid
()
6
{
7
return
true
;
8
}
9
}
10
11
class
PlayerSpawnJsonData :
PlayerSpawnJsonDataBase
12
{
13
ref
array<ref PlayerSpawnPreset>
presets
;
14
}
15
16
class
PlayerSpawnPreset
:
PlayerSpawnJsonDataBase
17
{
18
int
spawnWeight
;
//spawn probability weight
19
string
name
;
//optional
20
ref
array<string>
characterTypes
;
21
ref
array<ref PlayerSpawnPresetSlotData>
attachmentSlotItemSets
;
22
ref
array<ref PlayerSpawnPresetDiscreteCargoSetData>
discreteUnsortedItemSets
;
23
24
string
GetRandomCharacterType
()
25
{
26
if
(
characterTypes
&&
characterTypes
.Count() > 0)
27
return
characterTypes
.GetRandomElement();
28
29
Debug
.
Log
(
"No characterTypes defined. Falling back to 'default' character type, or random, if undefined"
,
"n/a"
,
"n/a"
,
"PlayerSpawnPreset"
);
30
return
string
.Empty;
31
}
32
33
override
bool
IsValid
()
34
{
35
if
(!super.IsValid())
36
return
false
;
37
38
if
(
spawnWeight
< 1)
39
{
40
Debug
.
Log
(
"Invalid spawn weight, skipping preset: "
+
name
,
"n/a"
,
"Validation"
,
"PlayerSpawnPreset"
);
41
return
false
;
42
}
43
44
return
true
;
45
}
46
48
bool
HasAttachmentSlotSetsDefined
()
49
{
50
return
attachmentSlotItemSets
&&
attachmentSlotItemSets
.Count() > 0;
51
}
52
54
bool
HasDiscreteUnsortedItemSetsDefined
()
55
{
56
return
discreteUnsortedItemSets
&&
discreteUnsortedItemSets
.Count() > 0;
57
}
58
}
59
60
class
PlayerSpawnPresetSlotData :
PlayerSpawnJsonDataBase
61
{
62
string
slotName
;
63
ref
array<ref PlayerSpawnPresetDiscreteItemSetSlotData>
discreteItemSets
;
64
66
bool
TranslateAndValidateSlot
(
EntityAI
parent, inout
int
slotID)
67
{
68
string
tmp =
slotName
;
69
if
(
slotName
==
"shoulderL"
)
70
{
71
tmp =
"Shoulder"
;
72
}
73
else
if
(
slotName
==
"shoulderR"
)
74
{
75
tmp =
"Melee"
;
76
}
77
78
slotID =
InventorySlots
.
GetSlotIdFromString
(tmp);
79
if
(!
InventorySlots
.
IsSlotIdValid
(slotID))
80
{
81
Debug
.
Log
(
"Wrong slot name used: "
+
slotName
,
"n/a"
,
"Validation"
,
"PlayerSpawnPresetSlotData"
);
82
return
false
;
83
}
84
if
(!parent)
85
{
86
Debug
.
Log
(
"No parent entity found when trying to populate slot: "
+
slotName
,
"n/a"
,
"Validation"
,
"PlayerSpawnPresetSlotData"
);
87
return
false
;
88
}
89
if
(!parent.GetInventory().HasAttachmentSlot(slotID))
90
{
91
Debug
.
Log
(
"Slot: "
+
slotName
+
" undefined on entity: "
+ parent.GetType(),
"n/a"
,
"Validation"
,
"PlayerSpawnPresetSlotData"
);
92
return
false
;
93
}
94
95
return
true
;
96
}
97
99
override
bool
IsValid
()
100
{
101
if
(!super.IsValid())
102
return
false
;
103
104
if
(
discreteItemSets
== null ||
discreteItemSets
.Count() < 1)
105
{
106
Debug
.
Log
(
"discreteItemSets for slot: "
+
slotName
+
" undefined"
,
"n/a"
,
"Validation"
,
"PlayerSpawnPresetSlotData"
);
107
return
false
;
108
}
109
110
return
true
;
111
}
112
}
113
115
class
PlayerSpawnPresetItemSetBase
:
PlayerSpawnJsonDataBase
116
{
117
bool
simpleChildrenUseDefaultAttributes
;
118
ref PlayerSpawnAttributesData
attributes
;
119
ref
array<ref PlayerSpawnPresetComplexChildrenType>
complexChildrenTypes
;
120
ref
array<string>
simpleChildrenTypes
;
121
123
int
GetQuickbarIdx
()
124
{
125
return
-1;
126
}
127
}
128
129
//base for DISCRETE item sets
130
class
PlayerSpawnPresetDiscreteItemSetBase :
PlayerSpawnPresetItemSetBase
131
{
132
int
spawnWeight
;
133
134
override
bool
IsValid
()
135
{
136
if
(!super.IsValid())
137
return
false
;
138
139
if
(
spawnWeight
< 1)
140
{
141
Debug
.
Log
(
"Invalid spawnWeight set for a discrete item set!"
,
"n/a"
,
"Validation"
,
"PlayerSpawnPresetDiscreteItemSetBase"
);
142
return
false
;
143
}
144
return
true
;
145
}
146
}
147
149
class
PlayerSpawnPresetDiscreteItemSetSlotData
: PlayerSpawnPresetDiscreteItemSetBase
150
{
151
string
itemType
;
152
int
quickBarSlot
;
153
154
override
bool
IsValid
()
155
{
156
if
(!super.IsValid())
157
return
false
;
158
159
//empty 'itemType' is valid alternative here
160
161
if
(!attributes)
162
{
163
Debug
.
Log
(
"No attributes defined for a discrete item set!"
,
"n/a"
,
"Validation"
,
"PlayerSpawnPresetDiscreteItemSetSlotData"
);
164
return
false
;
165
}
166
167
//unable to verify any of the other integers, since they always default to '0'. Needs to be configured carefully!
168
169
return
true
;
170
}
171
172
override
int
GetQuickbarIdx
()
173
{
174
return
quickBarSlot
;
175
}
176
}
177
179
class
PlayerSpawnPresetDiscreteCargoSetData : PlayerSpawnPresetDiscreteItemSetBase
180
{
181
string
name
;
182
}
183
185
class
PlayerSpawnPresetComplexChildrenType
:
PlayerSpawnPresetItemSetBase
186
{
187
string
itemType
;
188
int
quickBarSlot
;
189
190
override
bool
IsValid
()
191
{
192
if
(!super.IsValid())
193
return
false
;
194
195
return
itemType
!=
string
.Empty;
//needs item type to function
196
}
197
198
override
int
GetQuickbarIdx
()
199
{
200
return
quickBarSlot
;
201
}
202
}
203
204
class
PlayerSpawnAttributesData :
PlayerSpawnJsonDataBase
205
{
206
float
healthMin
;
207
float
healthMax
;
208
float
quantityMin
;
209
float
quantityMax
;
210
//ref array<string> magazineAmmoOrdered;
211
}
IsValid
proto bool IsValid()
Checks if the ScriptCaller is valid.
Definition
cfgplayerspawndatajson.c:134
quantityMax
float quantityMax
Definition
cfgplayerspawndatajson.c:209
discreteItemSets
ref array< ref PlayerSpawnPresetDiscreteItemSetSlotData > discreteItemSets
Definition
cfgplayerspawndatajson.c:63
presets
PlayerSpawnJsonDataBase presets
TranslateAndValidateSlot
bool TranslateAndValidateSlot(EntityAI parent, inout int slotID)
Translates slot name to match something from both 'CfgSlots' and 'attachments[]' in entity's config.
Definition
cfgplayerspawndatajson.c:66
quantityMin
float quantityMin
Definition
cfgplayerspawndatajson.c:208
healthMax
float healthMax
Definition
cfgplayerspawndatajson.c:207
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
slotName
PlayerSpawnPreset slotName
spawnWeight
PlayerSpawnPresetItemSetBase spawnWeight
healthMin
PlayerSpawnPresetComplexChildrenType healthMin
Debug
Definition
debug.c:2
Debug::Log
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition
debug.c:182
EntityAI
Definition
inventoryitem.c:2
InventorySlots
provides access to slot configuration
Definition
inventoryslots.c:6
InventorySlots::GetSlotIdFromString
static proto native int GetSlotIdFromString(string slot_name)
InventorySlots::IsSlotIdValid
static proto native bool IsSlotIdValid(int slotId)
Managed
TODO doc.
Definition
enscript.c:118
PlayerSpawnJsonDataBase
Definition
cfgplayerspawndatajson.c:2
PlayerSpawnJsonDataBase::IsValid
bool IsValid()
sets default values throughout the freshly created structure as required
Definition
cfgplayerspawndatajson.c:5
PlayerSpawnPresetComplexChildrenType
used for specific hierarchical child spawning
Definition
cfgplayerspawndatajson.c:186
PlayerSpawnPresetComplexChildrenType::GetQuickbarIdx
override int GetQuickbarIdx()
Definition
cfgplayerspawndatajson.c:198
PlayerSpawnPresetComplexChildrenType::itemType
string itemType
Definition
cfgplayerspawndatajson.c:187
PlayerSpawnPresetComplexChildrenType::IsValid
override bool IsValid()
Definition
cfgplayerspawndatajson.c:190
PlayerSpawnPresetComplexChildrenType::quickBarSlot
int quickBarSlot
Definition
cfgplayerspawndatajson.c:188
PlayerSpawnPresetDiscreteItemSetSlotData
one item set for slot
Definition
cfgplayerspawndatajson.c:150
PlayerSpawnPresetDiscreteItemSetSlotData::GetQuickbarIdx
override int GetQuickbarIdx()
Definition
cfgplayerspawndatajson.c:172
PlayerSpawnPresetDiscreteItemSetSlotData::itemType
string itemType
Definition
cfgplayerspawndatajson.c:151
PlayerSpawnPresetDiscreteItemSetSlotData::IsValid
override bool IsValid()
Definition
cfgplayerspawndatajson.c:154
PlayerSpawnPresetDiscreteItemSetSlotData::quickBarSlot
int quickBarSlot
Definition
cfgplayerspawndatajson.c:152
PlayerSpawnPreset
Definition
cfgplayerspawndatajson.c:17
PlayerSpawnPreset::HasAttachmentSlotSetsDefined
bool HasAttachmentSlotSetsDefined()
preset might be valid even with no attachmentSlotItemSets configured, checked separately
Definition
cfgplayerspawndatajson.c:48
PlayerSpawnPreset::GetRandomCharacterType
string GetRandomCharacterType()
Definition
cfgplayerspawndatajson.c:24
PlayerSpawnPreset::characterTypes
ref array< string > characterTypes
Definition
cfgplayerspawndatajson.c:20
PlayerSpawnPreset::spawnWeight
int spawnWeight
Definition
cfgplayerspawndatajson.c:18
PlayerSpawnPreset::name
string name
Definition
cfgplayerspawndatajson.c:19
PlayerSpawnPreset::IsValid
override bool IsValid()
Definition
cfgplayerspawndatajson.c:33
PlayerSpawnPreset::attachmentSlotItemSets
ref array< ref PlayerSpawnPresetSlotData > attachmentSlotItemSets
Definition
cfgplayerspawndatajson.c:21
PlayerSpawnPreset::discreteUnsortedItemSets
ref array< ref PlayerSpawnPresetDiscreteCargoSetData > discreteUnsortedItemSets
Definition
cfgplayerspawndatajson.c:22
PlayerSpawnPreset::HasDiscreteUnsortedItemSetsDefined
bool HasDiscreteUnsortedItemSetsDefined()
preset might be valid even with no unsorted item sets configured, checked separately
Definition
cfgplayerspawndatajson.c:54
PlayerSpawnPresetItemSetBase
base for any item set
Definition
cfgplayerspawndatajson.c:116
PlayerSpawnPresetItemSetBase::simpleChildrenTypes
ref array< string > simpleChildrenTypes
Definition
cfgplayerspawndatajson.c:120
PlayerSpawnPresetItemSetBase::GetQuickbarIdx
int GetQuickbarIdx()
overriden later
Definition
cfgplayerspawndatajson.c:123
PlayerSpawnPresetItemSetBase::attributes
ref PlayerSpawnAttributesData attributes
Definition
cfgplayerspawndatajson.c:118
PlayerSpawnPresetItemSetBase::simpleChildrenUseDefaultAttributes
bool simpleChildrenUseDefaultAttributes
Definition
cfgplayerspawndatajson.c:117
PlayerSpawnPresetItemSetBase::complexChildrenTypes
ref array< ref PlayerSpawnPresetComplexChildrenType > complexChildrenTypes
Definition
cfgplayerspawndatajson.c:119
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
Games
Dayz
scripts
4_world
classes
playergearspawn
cfgplayerspawndatajson.c
Generated by
1.17.0