Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
cfgplayerspawndatajson.c
Go to the documentation of this file.
2{
4
5 bool IsValid()
6 {
7 return true;
8 }
9}
10
11class PlayerSpawnJsonData : PlayerSpawnJsonDataBase
12{
14}
15
17{
18 int spawnWeight; //spawn probability weight
19 string name; //optional
23
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
52
58}
59
60class PlayerSpawnPresetSlotData : PlayerSpawnJsonDataBase
61{
62 string slotName;
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
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
128
129//base for DISCRETE item sets
130class PlayerSpawnPresetDiscreteItemSetBase : PlayerSpawnPresetItemSetBase
131{
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
149class PlayerSpawnPresetDiscreteItemSetSlotData : PlayerSpawnPresetDiscreteItemSetBase
150{
151 string itemType;
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
179class PlayerSpawnPresetDiscreteCargoSetData : PlayerSpawnPresetDiscreteItemSetBase
180{
181 string name;
182}
183
186{
187 string itemType;
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
204class PlayerSpawnAttributesData : PlayerSpawnJsonDataBase
205{
210 //ref array<string> magazineAmmoOrdered;
211}
proto bool IsValid()
Checks if the ScriptCaller is valid.
float quantityMax
ref array< ref PlayerSpawnPresetDiscreteItemSetSlotData > discreteItemSets
PlayerSpawnJsonDataBase presets
bool TranslateAndValidateSlot(EntityAI parent, inout int slotID)
Translates slot name to match something from both 'CfgSlots' and 'attachments[]' in entity's config.
float quantityMin
float healthMax
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
PlayerSpawnPresetItemSetBase spawnWeight
PlayerSpawnPresetComplexChildrenType healthMin
Definition debug.c:2
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
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
static proto native bool IsSlotIdValid(int slotId)
TODO doc.
Definition enscript.c:118
bool IsValid()
sets default values throughout the freshly created structure as required
used for specific hierarchical child spawning
bool HasAttachmentSlotSetsDefined()
preset might be valid even with no attachmentSlotItemSets configured, checked separately
ref array< string > characterTypes
ref array< ref PlayerSpawnPresetSlotData > attachmentSlotItemSets
ref array< ref PlayerSpawnPresetDiscreteCargoSetData > discreteUnsortedItemSets
bool HasDiscreteUnsortedItemSetsDefined()
preset might be valid even with no unsorted item sets configured, checked separately
ref PlayerSpawnAttributesData attributes
ref array< ref PlayerSpawnPresetComplexChildrenType > complexChildrenTypes
Result for an object found in CGame.IsBoxCollidingGeometryProxy.