DayZ 1.24
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
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
61{
62 string slotName;
64
67 {
68 string tmp = slotName;
69 if (slotName == "shoulderL")
70 tmp = "Shoulder";
71 else if (slotName == "shoulderR")
72 tmp = "Melee";
73
76 {
77 Debug.Log("Wrong slot name used: " + slotName, "n/a", "Validation", "PlayerSpawnPresetSlotData");
78 return false;
79 }
80 if (!parent)
81 {
82 Debug.Log("No parent entity found when trying to populate slot: " + slotName, "n/a", "Validation", "PlayerSpawnPresetSlotData");
83 return false;
84 }
85 if (!parent.GetInventory().HasAttachmentSlot(slotID))
86 {
87 Debug.Log("Slot: " + slotName + " undefined on entity: " + parent.GetType(), "n/a", "Validation", "PlayerSpawnPresetSlotData");
88 return false;
89 }
90
91 return true;
92 }
93
95 override bool IsValid()
96 {
97 if (!super.IsValid())
98 return false;
99
100 if (discreteItemSets == null || discreteItemSets.Count() < 1)
101 {
102 Debug.Log("discreteItemSets for slot: " + slotName + " undefined", "n/a", "Validation", "PlayerSpawnPresetSlotData");
103 return false;
104 }
105
106 return true;
107 }
108}
109
124
125//base for DISCRETE item sets
126class PlayerSpawnPresetDiscreteItemSetBase : PlayerSpawnPresetItemSetBase
127{
129
130 override bool IsValid()
131 {
132 if (!super.IsValid())
133 return false;
134
135 if (spawnWeight < 1)
136 {
137 Debug.Log("Invalid spawnWeight set for a discrete item set!", "n/a", "Validation", "PlayerSpawnPresetDiscreteItemSetBase");
138 return false;
139 }
140 return true;
141 }
142}
143
145class PlayerSpawnPresetDiscreteItemSetSlotData : PlayerSpawnPresetDiscreteItemSetBase
146{
147 string itemType;
149
150 override bool IsValid()
151 {
152 if (!super.IsValid())
153 return false;
154
155 //empty 'itemType' is valid alternative here
156
157 if (!attributes)
158 {
159 Debug.Log("No attributes defined for a discrete item set!", "n/a", "Validation", "PlayerSpawnPresetDiscreteItemSetSlotData");
160 return false;
161 }
162
163 //unable to verify any of the other integers, since they always default to '0'. Needs to be configured carefully!
164
165 return true;
166 }
167
168 override int GetQuickbarIdx()
169 {
170 return quickBarSlot;
171 }
172}
173
175class PlayerSpawnPresetDiscreteCargoSetData : PlayerSpawnPresetDiscreteItemSetBase
176{
177 string name;
178}
179
182{
183 string itemType;
185
186 override bool IsValid()
187 {
188 if (!super.IsValid())
189 return false;
190
191 return itemType != string.Empty; //needs item type to function
192 }
193
194 override int GetQuickbarIdx()
195 {
196 return quickBarSlot;
197 }
198}
199
201{
206 //ref array<string> magazineAmmoOrdered;
207}
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:14
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:133
provides access to slot configuration
static proto native bool IsSlotIdValid(int slotId)
verifies existence of the slot id
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
TODO doc.
Definition EnScript.c:118
bool IsValid()
sets default values throughout the freshly created structure as required
used for specific hierarchical child spawning
ref array< ref PlayerSpawnPresetDiscreteCargoSetData > discreteUnsortedItemSets
ref array< ref PlayerSpawnPresetSlotData > attachmentSlotItemSets
bool HasDiscreteUnsortedItemSetsDefined()
preset might be valid even with no unsorted item sets configured, checked separately
bool HasAttachmentSlotSetsDefined()
preset might be valid even with no attachmentSlotItemSets configured, checked separately
ref array< string > characterTypes
ref PlayerSpawnAttributesData attributes
ref array< ref PlayerSpawnPresetComplexChildrenType > complexChildrenTypes
static const string Empty
Definition EnString.c:7