Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cfgplayerspawndatajson.c
Go to the documentation of this file.
2 {
4 
5  bool IsValid()
6  {
7  return true;
8  }
9 }
10 
11 class 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 
60 class 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;
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 
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 }
healthMax
float healthMax
Definition: cfgplayerspawndatajson.c:207
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
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
presets
PlayerSpawnJsonDataBase presets
Managed
TODO doc.
Definition: enscript.c:117
PlayerSpawnPresetItemSetBase
base for any item set
Definition: cfgplayerspawndatajson.c:115
PlayerSpawnJsonDataBase
Definition: cfgplayerspawndatajson.c:1
PlayerSpawnPresetDiscreteItemSetSlotData
one item set for slot
Definition: cfgplayerspawndatajson.c:149
slotName
PlayerSpawnPreset slotName
spawnWeight
PlayerSpawnPresetItemSetBase spawnWeight
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
quantityMax
float quantityMax
Definition: cfgplayerspawndatajson.c:209
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Debug
Definition: debug.c:13
quantityMin
float quantityMin
Definition: cfgplayerspawndatajson.c:208
healthMin
PlayerSpawnPresetComplexChildrenType healthMin
IsValid
override bool IsValid()
slot name validity checked separately
Definition: cfgplayerspawndatajson.c:99
PlayerSpawnPresetComplexChildrenType
used for specific hierarchical child spawning
Definition: cfgplayerspawndatajson.c:185
EntityAI
Definition: building.c:5
PlayerSpawnPreset
Definition: cfgplayerspawndatajson.c:16
discreteItemSets
ref array< ref PlayerSpawnPresetDiscreteItemSetSlotData > discreteItemSets
Definition: cfgplayerspawndatajson.c:63