DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CfgGameplayHandler.c
Go to the documentation of this file.
2{
3 private static string m_Path = "$mission:cfgGameplay.json";
5
7
8 //---------------------------------------------------------------------------------------
9 static void RegisterItem(ITEM_DataBase item)
10 {
11 m_Items.Insert(item);
12 }
13 //---------------------------------------------------------------------------------------
14 private static void ValidateItems()
15 {
16 foreach (ITEM_DataBase item:m_Items)
17 {
18 if (!item.ValidateServer())
19 {
20 string itemName = item.Type().ToString();
21 itemName.Replace("ITEM_", "");
22 PrintToRPT("Validation failed during loading of 'cfgGameplay.json' for " + itemName);
23 item.InitServer();
24 }
25 }
26 }
27
28 //---------------------------------------------------------------------------------------
29 private static void InitData()
30 {
31 foreach (ITEM_DataBase item:m_Items)
32 {
33 item.InitServer();
34 }
35 }
36 #ifdef DEVELOPER
37 //---------------------------------------------------------------------------------------
38 static void Output()
39 {
40 Print(m_Items.Count());
41 }
42 #endif
43 //---------------------------------------------------------------------------------------
44 static bool LoadData()
45 {
46 if ( !FileExist( m_Path ) )
47 {
48 m_Path = "";
50 m_Path = string.Format("DZ/worlds/%1/ce/cfgGameplay.json", m_Path );
51 }
52
53 if (!GetGame().ServerConfigGetInt( "enableCfgGameplayFile" ) || !FileExist( m_Path ))
54 {
55 m_Data.InitServer();//legacy call
56 InitData();
57 OnLoaded();
58 return false;
59 }
60
61 JsonFileLoader<CfgGameplayJson>.JsonLoadFile( m_Path, m_Data );//we are allowed to read the file, so we replace the default data with data from json
63 OnLoaded();
64
65 return true;
66 }
67
68 //---------------------------------------------------------------------------------------
69 static void OnLoaded()
70 {
72 DayZGame.Cast(GetGame()).OnGameplayDataHandlerLoad();
73 }
74
75 //---------------------------------------------------------------------------------------
76 static void SyncDataSend(notnull Man player)
77 {
78 GetGame().RPCSingleParam(player, ERPCs.RPC_CFG_GAMEPLAY_SYNC, new Param1<CfgGameplayJson>(m_Data), true, player.GetIdentity());
79 }
80
81 //---------------------------------------------------------------------------------------
82 static void SyncDataSendEx(notnull PlayerIdentity identity)
83 {
84 //Debug.Log("SyncDataSendEx");
85 GetGame().RPCSingleParam(null, ERPCs.RPC_CFG_GAMEPLAY_SYNC, new Param1<CfgGameplayJson>(m_Data), true, identity);
86 }
87
88 //---------------------------------------------------------------------------------------
89
90 static void OnRPC(Man player, ParamsReadContext ctx)
91 {
92 Param1<CfgGameplayJson> data = new Param1<CfgGameplayJson>(null);
93
94 if ( ctx.Read(data) )
95 {
96 m_Data = data.param1;
97 }
98 else
99 {
100 ErrorEx("CfgGameplayHandler - client failed to read incoming data");
101 }
102 }
103
104
105 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
109 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110
111 //========================
112 // !!! ONLY GETTERS BELLOW
113 //========================
114
115
116 //----------------------------------------------------------------------------------
118 {
120 }
121 //----------------------------------------------------------------------------------
122
123 //------------------------------- WorldsData -----------------------------------
124 static int GetLightingConfig()
125 {
126 return m_Data.WorldsData.lightingConfig;
127 }
128
130 {
131 return m_Data.WorldsData.objectSpawnersArr;
132 }
133
135 {
136 return m_Data.WorldsData.environmentMinTemps;
137 }
138
140 {
141 return m_Data.WorldsData.environmentMaxTemps;
142 }
144 {
145 return m_Data.WorldsData.wetnessWeightModifiers;
146 }
147 //----------------------------------------------------------------------------------
148
149
151 {
152 return m_Data.GeneralData.disableBaseDamage;
153 }
154 //----------------------------------------------------------------------------------
155
157 {
158 return m_Data.GeneralData.disableContainerDamage;
159 }
160 //----------------------------------------------------------------------------------
162 {
163 return m_Data.GeneralData.disableRespawnDialog;
164 }
165 //----------------------------------------------------------------------------------
167 {
169 }
170 //----------------------------------------------------------------------------------
172 {
174 }
175 //----------------------------------------------------------------------------------
177 {
179 }//----------------------------------------------------------------------------------
181 {
183 }
184 //----------------------------------------------------------------------------------
186 {
188 }
189 //----------------------------------------------------------------------------------
190 static float GetStaminaMax()
191 {
193 }
194 //----------------------------------------------------------------------------------
196 {
198 }
199 //----------------------------------------------------------------------------------
200 static float GetStaminaMinCap()
201 {
203 }
204 //----------------------------------------------------------------------------------
206 {
208 }
209 //----------------------------------------------------------------------------------
211 {
213 }
214 //----------------------------------------------------------------------------------
216 {
218 }
219 //----------------------------------------------------------------------------------
221 {
223 }
224 //----------------------------------------------------------------------------------
226 {
228 }
229 //----------------------------------------------------------------------------------
231 {
233 }
234 //----------------------------------------------------------------------------------
236 {
238 }
239 //----------------------------------------------------------------------------------
241 {
243 }
244 //----------------------------------------------------------------------------------
245 static bool GetDisable2dMap()
246 {
248 }
249 //----------------------------------------------------------------------------------
251 {
253 }
254 //----------------------------------------------------------------------------------
256 {
258 }
259 //----------------------------------------------------------------------------------
261 {
263 }
264 //----------------------------------------------------------------------------------
266 {
268 }
269 //----------------------------------------------------------------------------------
271 {
273 }
274 //----------------------------------------------------------------------------------
276 {
278 }
279 //----------------------------------------------------------------------------------
281 {
283 }
284 //----------------------------------------------------------------------------------
286 {
288 }
289 //----------------------------------------------------------------------------------
291 {
293 }
294 //----------------------------------------------------------------------------------
296 {
298 }
299 //----------------------------------------------------------------------------------
301 {
303 }
304 //----------------------------------------------------------------------------------
306 {
308 }
309 //----------------------------------------------------------------------------------
311 {
313 }
314 //----------------------------------------------------------------------------------
315 static bool GetHitIndicationOverrideEnabled() //TODO - ?
316 {
318 }
319 //----------------------------------------------------------------------------------
321 {
323 }
324 //----------------------------------------------------------------------------------
326 {
328 }
329 //----------------------------------------------------------------------------------
331 {
333 }
334 //----------------------------------------------------------------------------------
336 {
338 }
339 //----------------------------------------------------------------------------------
341 {
343 }
344 //----------------------------------------------------------------------------------
346 {
348 }
349 //----------------------------------------------------------------------------------
351 {
353 }
354 //----------------------------------------------------------------------------------
355 static bool GetUse3DMap()
356 {
357 return m_Data.UIData.use3DMap;
358 }
359 //----------------------------------------------------------------------------------
361 {
363 }
364 //----------------------------------------------------------------------------------
366 {
368 }
369 //----------------------------------------------------------------------------------
371 {
373 }
374
375 //--- MapData ----------------------------------------------------------------------
377 {
379 }
380 //----------------------------------------------------------------------------------
382 {
384 }
385 //----------------------------------------------------------------------------------
387 {
389 }
390 //----------------------------------------------------------------------------------
392 {
394 }
395 //----------------------------------------------------------------------------------
397 {
398 return m_Data.PlayerData.DrowningData.staminaDepletionSpeed;
399 }
400 //----------------------------------------------------------------------------------
402 {
403 return m_Data.PlayerData.DrowningData.healthDepletionSpeed;
404 }
405 //----------------------------------------------------------------------------------
407 {
408 return m_Data.PlayerData.DrowningData.shockDepletionSpeed;
409 }
410 //----------------------------------------------------------------------------------
412 {
414 }
415 //----------------------------------------------------------------------------------
416}
ERPCs
Definition ERPCs.c:2
proto void GetWorldName(out string world_name)
proto native Mission GetMission()
void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
Definition Game.c:882
static float GetShockRefillSpeedUnconscious()
static bool GetAllowStaminaAffectInertia()
static bool GetDisableDistanceCheck()
static int GetHitIndicationTypeID()
static bool GetDisableIsCollidingPlayerCheck()
static TStringArray GetObjectSpawnersArr()
static void OnRPC(Man player, ParamsReadContext ctx)
static float GetObstacleTraversalStaminaModifier()
static int GetHitIndicationMode()
static float GetStaminaMinCap()
static private string m_Path
static bool GetDisableIsClippingRoofCheck()
static float GetHitIndicationScatter()
static bool GetDisableBaseDamage()
static float GetStaminaKgToStaminaPercentPenalty()
static float GetHitIndicationMaxDuration()
static float GetMovementTimeToStrafeJog()
static float GetShockDepletionSpeed()
static bool GetHitIndicationOverrideEnabled()
static float GetSprintSwimmingStaminaModifier()
static float GetMovementRotationSpeedJog()
static void RegisterItem(ITEM_DataBase item)
static float GetMovementTimeToSprint()
static bool GetDisableIsCollidingGPlotCheck()
static bool GetMapDisplayNavigationInfo()
static float GetHoldBreathStaminaModifier()
static bool GetAllowRefillSpeedModifier()
static float GetMovementRotationSpeedSprint()
static bool GetDisableIsCollidingBBoxCheck()
static private void ValidateItems()
static bool GetDisableIsCollidingCheck()
static void SyncDataSendEx(notnull PlayerIdentity identity)
static bool GetDisableIsInTerrainCheck()
static float GetShockRefillSpeedConscious()
static private void InitData()
static bool GetDisableIsCollidingAngleCheck()
static private ref array< ref ITEM_DataBase > m_Items
static float GetHealthDepletionSpeed()
static bool GetMapIgnoreMapOwnership()
static bool GetMapIgnoreNavItemsOwnership()
static bool GetMapDisplayPlayerPosition()
static bool GetDisablePerformRoofCheck()
static bool GetDisableIsPlacementPermittedCheck()
static float GetMovementTimeToStrafeSprint()
static bool GetDisable2dMap()
static bool GetDisableHeightPlacementCheck()
static bool GetDisableIsBaseViableCheck()
static float GetStaminaDepletionSpeed()
static void SyncDataSend(notnull Man player)
static float GetSprintLadderStaminaModifier()
static float GetSprintStaminaModifierCro()
static bool GetHitIndicationPPEEnabled()
static float GetSprintStaminaModifierErc()
static int GetLightingConfig()
static array< float > GetWetnessWeightModifiers()
static array< float > GetEnvironmentMinTemps()
static bool GetDisableIsUnderwaterCheck()
static int GetHitIndicationIndicatorColor()
static bool GetDisableContainerDamage()
static bool GetDisableRespawnDialog()
static float GetStaminaWeightLimitThreshold()
static float GetMeleeStaminaModifier()
static float GetHitIndicationBreakPoint()
static bool GetDisablePersonalLight()
static float GetStaminaMax()
static ref CfgGameplayJson m_Data
static array< float > GetEnvironmentMaxTemps()
contents of this class will be transfered to client upon connecting, with the variables in either ini...
ref ITEM_PlayerData PlayerData
ref ITEM_BaseBuildingData BaseBuildingData
ref ITEM_UIData UIData
ref ITEM_MapData MapData
ref ITEM_WorldData WorldsData
ref ITEM_GeneralData GeneralData
!! all member variables must correspond with the cfggameplay.json file contents !!...
void InitServer()
Obsolete, 'InitServer' on individual json items is now called centrally.
ref ITEM_HologramData HologramData
!! all member variables must correspond with the cfggameplay.json file contents !!...
ref ITEM_ConstructionData ConstructionData
bool disablePerformRoofCheck
!! all member variables must correspond with the cfggameplay.json file contents !!...
bool disableIsCollidingBBoxCheck
!! all member variables must correspond with the cfggameplay.json file contents !!...
bool ignoreMapOwnership
!! all member variables must correspond with the cfggameplay.json file contents !!...
float timeToStrafeJog
!! all member variables must correspond with the cfggameplay.json file contents !!...
ref ITEM_ShockHandlingData ShockHandlingData
bool disablePersonalLight
!! all member variables must correspond with the cfggameplay.json file contents !!...
ref ITEM_DrowningData DrowningData
ref ITEM_MovementData MovementData
ref ITEM_StaminaData StaminaData
float shockRefillSpeedConscious
!! all member variables must correspond with the cfggameplay.json file contents !!...
float staminaWeightLimitThreshold
!! all member variables must correspond with the cfggameplay.json file contents !!...
ref ITEM_HitIndicationData HitIndicationData
!! all member variables must correspond with the cfggameplay.json file contents !!...
Definition EnMath.c:7
void OnGameplayDataHandlerLoad()
Definition gameplay.c:695
The class that will be instanced (moddable)
Definition gameplay.c:378
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
enum ShapeType ErrorEx
proto bool FileExist(string name)
Check existence of file.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto native int HexToInt()
Converts string to integer.
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.