DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ItemOptics.c
См. документацию.
2{
4 bool m_allowsDOF; //true if optics DOES NOT have magnification (FOV >= DZPLAYER_CAMERA_FOV_IRONSIGHTS)
5 bool m_reddot_displayed
6 bool m_isNVOptic = false;
7 int m_CurrentOpticMode; //generic optic mode, currently used for NV optics only (could be expanded)
8 int m_CurrentOpticModeLocal; //local mirror for sync purposes;
11 float m_nearplane_override; //override value for DayZPlayerCameraOptics only!
18
20 {
24
31
33 RegisterNetSyncVariableInt( "m_CurrentOpticMode", 0, 63 );
34 }
35
40 proto native bool EnterOptics ();
41
46 proto native bool IsInOptics ();
47
52 proto native bool ExitOptics ();
53
58 proto native bool HasWeaponIronsightsOverride ();
59
64 proto native bool UseWeaponIronsightsOverride(bool state);
65
71
75 proto native int GetStepFOVCount ();
76
81 proto native int GetStepFOVIndex ();
82
88 proto native bool SetStepFOVIndex (int step);
89
94 proto native bool StepFOVUp ();
95
100 proto native bool StepFOVDown ();
101
105 proto native float GetCurrentStepFOV ();
106
111 proto native int GetStepZeroing ();
112
118 proto native bool SetStepZeroing (int step);
119
125 proto native bool StepZeroingUp ();
126
132 proto native bool StepZeroingDown ();
133
138 proto native void GetCameraPoint (out vector pos, out vector dir);
139
144 proto native float GetZoomInit();
145
150 proto native float GetZoomMin();
151
156 proto native float GetZoomMax();
157
162 proto native float GetZeroingDistanceZoomMin();
163
168 proto native float GetZeroingDistanceZoomMax();
169
174 proto native void SetZeroingClampDist(float dist);
175
176 override void OnWorkStart()
177 {
178 if (!GetGame().IsDedicatedServer())
179 {
180 ShowReddot(true);
181 }
182 }
183
184 override void OnWorkStop()
185 {
186 if (!GetGame().IsDedicatedServer())
187 {
188 ShowReddot(false);
189 }
190 }
191
193 {
194 if (GetCompEM() && GetCompEM().CanWork())
195 return true;
196 return false;
197 }
198
200 {
201 if (IsWorking() && !m_reddot_displayed)
202 {
203 ShowReddot(true);
204 }
205 else if (!IsWorking() && m_reddot_displayed)
206 {
207 ShowReddot(false);
208 }
209 }
210
211 override void OnWasAttached( EntityAI parent, int slot_id )
212 {
213 super.OnWasAttached(parent, slot_id);
214
215 SetTakeable(false);
216
217 Weapon wep;
218 if (Class.CastTo(wep,parent))
219 {
220 SetZeroingClampDist(wep.GetZeroingClamp(wep.GetCurrentMuzzle()));
221 }
222 }
223
224 override void OnWasDetached( EntityAI parent, int slot_id )
225 {
226 super.OnWasDetached(parent, slot_id);
227
228 PlayerBase player;
229 if (PlayerBase.CastTo(player, GetHierarchyRootPlayer()))
230 {
231 player.SetReturnToOptics(false);
232 }
233
234 SetTakeable(true);
235
236 Weapon wep;
237 if (Class.CastTo(wep,parent))
238 {
240 }
241 }
242
243 override void OnInventoryExit(Man player)
244 {
245 super.OnInventoryExit(player);
246
247 PlayerBase playerPB;
248 if (PlayerBase.CastTo(playerPB, player))
249 {
250 playerPB.SetReturnToOptics(false);
251 }
252
253 SetTakeable(true);
254 }
255
257 {
258 super.OnStoreSave(ctx);
259
261 }
262
263 override bool OnStoreLoad(ParamsReadContext ctx, int version)
264 {
265 if ( !super.OnStoreLoad(ctx,version) )
266 {
267 return false;
268 }
269 m_IsStoreLoad = true;
270
271 if ( version >= 126 )
272 {
273 if ( !ctx.Read(m_CurrentOpticMode) )
274 {
275 m_IsStoreLoad = false;
276 return false;
277 }
278 }
279
281 SetSynchDirty();
282
283 m_IsStoreLoad = false;
284 return true;
285 }
286
288 {
289 super.OnVariablesSynchronized();
290
292 {
295 }
296 }
297
299 {
300 string path = "cfgVehicles " + GetType() + " OpticsInfo";
301 string temp;
302
303 if (GetGame().ConfigIsExisting(path))
304 {
305 m_reddot_index = GetHiddenSelectionIndex("reddot");
306 if (GetGame().ConfigIsExisting(path + " opticSightTexture"))
307 {
308 GetGame().ConfigGetText(path + " opticSightTexture", temp);
310 temp = "";
311 }
312 if (GetGame().ConfigIsExisting(path + " opticSightMaterial"))
313 {
314 GetGame().ConfigGetText(path + " opticSightMaterial", temp);
316 temp = "";
317 }
318 }
319 m_data_set = true;
320 }
321
322 void ShowReddot(bool state)
323 {
324 if (GetGame().IsDedicatedServer())
325 {
326 ErrorEx("should not be called on the server!",ErrorExSeverity.INFO);
327 return;
328 }
329
330 if (!m_data_set)
331 {
333 }
334
335 // does not have reddot
336 if (m_reddot_index == -1)
337 {
338 return;
339 }
340
341 if (state)
342 {
343 if (m_optic_sight_texture != "")
344 SetObjectTexture(m_reddot_index, m_optic_sight_texture);
345 if (m_optic_sight_material != "")
346 SetObjectMaterial(m_reddot_index, m_optic_sight_material);
347 }
348 else
349 {
350 SetObjectTexture(m_reddot_index, "");
351 SetObjectMaterial(m_reddot_index, "");
352 }
353 m_reddot_displayed = state;
354 }
355
357 {
360
361 m_isNVOptic = ConfigGetBool("NVOptic");
362 }
363
366 {
367 float fov_max;
368 string path = "cfgVehicles " + GetType() + " OpticsInfo";
369
370 /*
371 Weapon_Base weapon = Weapon_Base.Cast(GetHierarchyParent());
372 if (!weapon)
373 return false; // no DOF for handheld optics
374 */
375 fov_max = GetGame().ConfigGetFloat(path + " opticsZoomMax");
377 {
378 return true;
379 }
380 return false;
381 }
382
384 void InitOpticsPP(out array<float> mask_array, out array<float> lens_array, out float blur_float)
385 {
386 string path = "cfgVehicles " + GetType() + " OpticsInfo";
387 GetGame().ConfigGetFloatArray(path + " PPMaskProperties", mask_array);
388 GetGame().ConfigGetFloatArray(path + " PPLensProperties", lens_array);
389 blur_float = GetGame().ConfigGetFloat(path + " PPBlurProperties");
390 }
391
393 {
394 string path = "cfgVehicles " + GetType() + " OpticsInfo";
395 if ( GetGame().ConfigIsExisting(path + " nearPlaneDistanceOverride") )
396 {
397 m_nearplane_override = Math.Max(GetGame().ConfigGetFloat(path + " nearPlaneDistanceOverride"),DayZPlayerCameraBase.CONST_NEARPLANE_OPTICS_MIN);
398 }
399 else
400 {
401 m_nearplane_override = DayZPlayerCameraOptics.CONST_NEARPLANE_OPTICS;
402 }
403 }
404
407 {
408 if (GetGame().ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties"))
409 {
410 GetGame().ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties", temp_array);
411 return true;
412 }
413 else if (GetGame().ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties"))
414 {
415 GetGame().ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties", temp_array);
416 return true;
417 }
418 return false;
419 }
420
423 {
424 return m_allowsDOF;
425 }
426
428 {
429 return m_isNVOptic;
430 }
431
433 {
434 /*
435 //TODO - implement this into NV optics and modify (KazuarOptic example below)
436 if (IsWorking())
437 {
438 switch (m_CurrentOpticMode)
439 {
440 case GameConstants.OPTICS_STATE_DAY:
441 return NVTypes.NV_OPTICS_KAZUAR_DAY;
442
443 case GameConstants.OPTICS_STATE_NIGHTVISION:
444 return NVTypes.NV_OPTICS_KAZUAR_NIGHT;
445 }
446 }
447 else
448 {
449 return NVTypes.NV_OPTICS_OFF;
450 }
451 */
452 return NVTypes.NONE;
453 }
454
455 void SetCurrentOpticMode(int mode)
456 {
457 m_CurrentOpticMode = mode;
459 }
460
462 {
463 return m_CurrentOpticMode;
464 }
465
469 {
470 if ( GetGame() && !GetGame().IsDedicatedServer() )
471 {
472 HideSelection("hide");
473 }
474 }
476 {
477 if ( GetGame() && !GetGame().IsDedicatedServer() )
478 {
479 ShowSelection("hide");
480 }
481 }
482
484 {
486 }
488 {
489 return m_mask_array;
490 }
492 {
493 return m_lens_array;
494 }
496 {
497 return m_blur_float;
498 }
499
501 {
503 }
504
506 {
507 string path = "cfgVehicles " + GetType() + " OpticsInfo preloadOpticType";
508 string type_2d;
509
510 if ( GetGame().ConfigIsExisting(path) )
511 {
512 GetGame().ConfigGetText(path, type_2d);
513 m_2D_preload_type = type_2d;
514 }
515 }
516
521
523
524 override void SetActions()
525 {
526 super.SetActions();
527
529 }
530
531 override void OnDebugSpawn()
532 {
533 GetInventory().CreateAttachment("Battery9V");
534 }
535}
536
537typedef ItemOptics OpticBase;
538
539
eBleedingSourceType GetType()
Определения BleedingSource.c:63
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
NVTypes
Определения DayZPlayerCamera_Base.c:55
void DayZPlayerCameraOptics(DayZPlayer pPlayer, HumanInputController pInput)
Определения DayZPlayerCameraIronsights.c:365
override void SetTakeable(bool pState)
Определения ItemBase.c:9042
bool m_IsStoreLoad
Определения ItemBase.c:4838
string path
Определения OptionSelectorMultistate.c:142
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
Super root of all classes in Enforce script.
Определения EnScript.c:11
this is main camera class
Определения DayZPlayerCamera1stPerson.c:5
Определения Building.c:6
Определения constants.c:659
proto native bool SetStepZeroing(int step)
proto native bool StepFOVDown()
sets zoom to previous (respective to current) defined value in zoom fov config array
void OnOpticModeChange()
optic-specific behaviour to be defined here (override)
Определения ItemOptics.c:467
proto native float GetZeroingDistanceZoomMax()
Gets Zeroing distance at opticsZoomMax.
void InitOpticsPP(out array< float > mask_array, out array< float > lens_array, out float blur_float)
initializes values for optics' post-processes
Определения ItemOptics.c:384
bool m_allowsDOF
Определения ItemOptics.c:4
proto native bool StepZeroingUp()
sets zeroing to next defined (respective to current) value in zeroing config array
proto native bool ExitOptics()
switches out of optics mode (if possible)
override void OnDebugSpawn()
Определения ItemOptics.c:531
int m_reddot_index
Определения ItemOptics.c:9
int m_CurrentOpticModeLocal
Определения ItemOptics.c:8
proto native bool StepFOVUp()
sets zoom to next defined (respective to current) value in zoom fov config array
void InitOpticMode()
Определения ItemOptics.c:517
string m_2D_preload_type
Определения ItemOptics.c:14
void OnOpticExit()
Определения ItemOptics.c:475
override void OnWorkStart()
Определения ItemOptics.c:176
void InitReddotData()
Определения ItemOptics.c:298
int GetCurrentOpticMode()
Определения ItemOptics.c:461
ref array< float > GetOpticsPPLens()
Определения ItemOptics.c:491
bool IsWorking()
Определения ItemOptics.c:192
bool m_reddot_displayed bool m_isNVOptic
Определения ItemOptics.c:6
override void OnStoreSave(ParamsWriteContext ctx)
Определения ItemOptics.c:256
proto native bool IsInOptics()
is weapon in optics mode or not
proto native void SetZeroingClampDist(float dist)
Sets zeroing clamp for the optics and updates the clamp if dist > 0. Used when attached to weapon.
proto native int GetStepFOVIndex()
returns index of currently used value in 'discretefov' config array
bool AllowsDOF()
returns 'true' for non-magnifying optics
Определения ItemOptics.c:422
int GetCurrentNVType()
Определения ItemOptics.c:432
proto native void GetCameraPoint(out vector pos, out vector dir)
gets camera position & direction in model space of optics entity
ref array< float > GetOpticsPPMask()
Определения ItemOptics.c:487
float GetNearPlaneValue()
Определения ItemOptics.c:500
proto native bool IsUsingWeaponIronsightsOverride()
is optics using ironsights override settings or not
void OnOpticEnter()
Определения ItemOptics.c:468
proto native bool EnterOptics()
switches to optics mode if possible
ref array< float > m_mask_array
Определения ItemOptics.c:15
proto native bool UseWeaponIronsightsOverride(bool state)
switches into ironsights override settings
override void ShowSelection(string selection_name)
Определения HuntingOptic.c:44
void UpdateOpticsReddotVisibility()
Определения ItemOptics.c:199
void UpdateSelectionVisibility()
Определения ItemOptics.c:522
bool m_data_set
Определения ItemOptics.c:3
override void HideSelection(string selection_name)
Определения HuntingOptic.c:34
bool InitDOFAvailability()
optics with more than 1x zoom do not allow DOF changes
Определения ItemOptics.c:365
void InitOpticsPPInfo()
Определения ItemOptics.c:356
float GetOpticsPPBlur()
Определения ItemOptics.c:495
override void OnVariablesSynchronized()
Определения ItemOptics.c:287
int m_CurrentOpticMode
Определения ItemOptics.c:7
proto native bool StepZeroingDown()
sets zeroing to previous (respective to current) defined value in zeroing config array
override void SetActions()
Определения ItemOptics.c:524
float m_blur_float
Определения ItemOptics.c:10
bool IsNVOptic()
Определения ItemOptics.c:427
ref array< float > m_OpticsDOFProperties
Определения ItemOptics.c:17
proto native float GetZoomMax()
gets FOV maximum
bool InitOpticsDOFProperties(out array< float > temp_array)
Initializes DOF properties for optic's alternate ironsights (ACOG etc.)
Определения ItemOptics.c:406
proto native bool HasWeaponIronsightsOverride()
is weapon in optics mode or not
ref array< float > GetOpticsDOF()
Определения ItemOptics.c:483
proto native float GetZeroingDistanceZoomMin()
Gets Zeroing distance at opticsZoomMin.
proto native float GetZoomInit()
gets FOV value, when entering optics
void Init2DPreloadType()
Определения ItemOptics.c:505
void SetCurrentOpticMode(int mode)
Определения ItemOptics.c:455
override void OnWasAttached(EntityAI parent, int slot_id)
Определения ItemOptics.c:211
proto native int GetStepFOVCount()
returns number of configured steps
string m_optic_sight_material
Определения ItemOptics.c:13
void ItemOptics()
Определения ItemOptics.c:19
override void OnInventoryExit(Man player)
Определения ItemOptics.c:243
float m_nearplane_override
Определения ItemOptics.c:11
void InitCameraOverrideProperties()
Определения ItemOptics.c:392
proto native int GetStepZeroing()
returns position of currently used value in zeroing config array
void ShowReddot(bool state)
Определения ItemOptics.c:322
proto native float GetZoomMin()
gets FOV minimum
proto native bool SetStepFOVIndex(int step)
sets zoom to fov value defined at given in 'discretefov' config array
ref array< float > m_lens_array
Определения ItemOptics.c:16
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения ItemOptics.c:263
override void OnWorkStop()
Определения ItemOptics.c:184
proto native float GetCurrentStepFOV()
returns fov value at current index, or 'OpticsInfo.opticsZoomInit' config value (non-zooming optics)
string m_optic_sight_texture
Определения ItemOptics.c:12
override void OnWasDetached(EntityAI parent, int slot_id)
Определения ItemOptics.c:224
Определения ItemOptics.c:2
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
proto bool Write(void value_out)
proto bool Read(void value_in)
script counterpart to engine's class Weapon
Определения InventoryItem.c:49
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
const float DZPLAYER_CAMERA_FOV_IRONSIGHTS
Определения constants.c:978
const int OPTICS_STATE_DAY
Определения constants.c:905
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Max(float x, float y)
Returns bigger of two given values.