Dayz Explorer 1.28.160049
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
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
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
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
116{
117 bool simpleChildrenUseDefaultAttributes;
118 ref PlayerSpawnAttributesData attributes;
120 ref array<string> simpleChildrenTypes;
121
123 int GetQuickbarIdx()
124 {
125 return -1;
126 }
127}
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;
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
179class PlayerSpawnPresetDiscreteCargoSetData : PlayerSpawnPresetDiscreteItemSetBase
180{
181 string name;
182}
183
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
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
provides access to slot configuration
TODO doc.
Definition enscript.c:118
used for specific hierarchical child spawning
Result for an object found in CGame.IsBoxCollidingGeometryProxy.