DayZ 1.30
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
180 protected void OnDrawOptics2D()
181 {
182 if (m_reddot_index == -1)
183 return;
184
185 ItemOpticsType opticsType = GetItemOpticsType();
186 if (m_reddot_displayed)
187 {
188 if (m_optic_sight_texture != "")
190 if (m_optic_sight_material != "")
192 }
193 else
194 {
195 opticsType.SetOptics2DTexture(m_reddot_index, "");
196 opticsType.SetOptics2DMaterial(m_reddot_index, "");
197 }
198 }
199
202 {
203 return ItemOpticsType.Cast(GetInventoryItemType());
204 }
205
208 {
210 return type.IsUsingOptics2DModel();
211 }
212
214 {
215 return false;
216 }
217
219 {
220 return false;
221 }
222
223 override void OnWorkStart()
224 {
225 if (!g_Game.IsHeadlessOrDedicatedServer())
226 {
227 if (IsSwitchedOn())
228 {
229 ShowReddot(true);
230 }
231 }
232 }
233
234 override void OnWorkStop()
235 {
236 if (!g_Game.IsHeadlessOrDedicatedServer())
237 {
238 ShowReddot(false);
239 }
240 }
241
243 {
244 if (GetCompEM() && GetCompEM().CanWork())
245 return true;
246 return false;
247 }
248
249 override void OnSwitchOn()
250 {
251 if (!g_Game.IsHeadlessOrDedicatedServer())
252 {
253 if (IsWorking())
254 {
255 ShowReddot(true);
256 }
257 }
258 }
259
260 override void OnSwitchOff()
261 {
262 if (!g_Game.IsHeadlessOrDedicatedServer())
263 {
264 ShowReddot(false);
265 }
266 }
267
269 {
270 if (GetCompEM() && GetCompEM().IsSwitchedOn())
271 return true;
272 return false;
273 }
274
276 {
277 if (IsWorking() && IsSwitchedOn() && !m_reddot_displayed)
278 {
279 ShowReddot(true);
280 }
281 else if ((!IsWorking() || !IsSwitchedOn()) && m_reddot_displayed)
282 {
283 ShowReddot(false);
284 }
285 }
286
287 override void OnWasAttached( EntityAI parent, int slot_id )
288 {
289 super.OnWasAttached(parent, slot_id);
290
291 SetTakeable(false);
292
293 Weapon wep;
294 if (Class.CastTo(wep,parent))
295 {
296 SetZeroingClampDist(wep.GetZeroingClamp(wep.GetCurrentMuzzle()));
297 }
298 }
299
300 override void OnWasDetached( EntityAI parent, int slot_id )
301 {
302 super.OnWasDetached(parent, slot_id);
303
304 PlayerBase player;
305 if (PlayerBase.CastTo(player, GetHierarchyRootPlayer()))
306 {
307 player.SetReturnToOptics(false);
308 }
309
310 SetTakeable(true);
311
312 Weapon wep;
313 if (Class.CastTo(wep,parent))
314 {
316 }
317 }
318
319 override void OnInventoryExit(Man player)
320 {
321 super.OnInventoryExit(player);
322
323 PlayerBase playerPB;
324 if (PlayerBase.CastTo(playerPB, player))
325 {
326 playerPB.SetReturnToOptics(false);
327 }
328
329 SetTakeable(true);
330 }
331
333 {
334 super.OnStoreSave(ctx);
335
337 }
338
339 override bool OnStoreLoad(ParamsReadContext ctx, int version)
340 {
341 if ( !super.OnStoreLoad(ctx,version) )
342 {
343 return false;
344 }
345 m_IsStoreLoad = true;
346
347 if ( version >= 126 )
348 {
349 if ( !ctx.Read(m_CurrentOpticMode) )
350 {
351 m_IsStoreLoad = false;
352 return false;
353 }
354 }
355
357 SetSynchDirty();
358
359 m_IsStoreLoad = false;
360 return true;
361 }
362
364 {
365 super.OnVariablesSynchronized();
366
368 {
371 }
372 }
373
375 {
376 bool isUsing2D = IsUsingOptics2DModel();
377
378 string path;
379 if (isUsing2D)
380 {
381 path = "cfgVehicles " + GetType() + " OpticsModelInfo";
382 }
383 else
384 {
385 path = "cfgVehicles " + GetType() + " OpticsInfo";
386 }
387 string temp;
388
389 if (g_Game.ConfigIsExisting(path))
390 {
391 if (isUsing2D)
393 else
394 m_reddot_index = GetHiddenSelectionIndex("reddot");
395
396 if (g_Game.ConfigIsExisting(path + " opticSightTexture"))
397 {
398 g_Game.ConfigGetText(path + " opticSightTexture", temp);
400 temp = "";
401 }
402 if (g_Game.ConfigIsExisting(path + " opticSightMaterial"))
403 {
404 g_Game.ConfigGetText(path + " opticSightMaterial", temp);
406 temp = "";
407 }
408 }
409 m_data_set = true;
410 }
411
412 void ShowReddot(bool state)
413 {
414 if (g_Game.IsHeadlessOrDedicatedServer())
415 {
416 ErrorEx("should not be called on the server/headless!",ErrorExSeverity.INFO);
417 return;
418 }
419
420 if (!m_data_set)
421 {
423 }
424
425 // does not have reddot
426 if (m_reddot_index == -1)
427 {
428 return;
429 }
430
431 // 2D model has special handling in `OnDrawOptics2D`
433 {
434 if (state)
435 {
436 if (m_optic_sight_texture != "")
437 SetObjectTexture(m_reddot_index, m_optic_sight_texture);
438 if (m_optic_sight_material != "")
439 SetObjectMaterial(m_reddot_index, m_optic_sight_material);
440 }
441 else
442 {
443 SetObjectTexture(m_reddot_index, "");
444 SetObjectMaterial(m_reddot_index, "");
445 }
446 }
447 m_reddot_displayed = state;
448 }
449
451 {
454
455 m_isNVOptic = ConfigGetBool("NVOptic");
456 }
457
460 {
461 float fov_max;
462 string path = "cfgVehicles " + GetType() + " OpticsInfo";
463
464 /*
465 Weapon_Base weapon = Weapon_Base.Cast(GetHierarchyParent());
466 if (!weapon)
467 return false; // no DOF for handheld optics
468 */
469 fov_max = g_Game.ConfigGetFloat(path + " opticsZoomMax");
471 {
472 return true;
473 }
474 return false;
475 }
476
478 void InitOpticsPP(out array<float> mask_array, out array<float> lens_array, out float blur_float)
479 {
480 string path = "cfgVehicles " + GetType() + " OpticsInfo";
481 g_Game.ConfigGetFloatArray(path + " PPMaskProperties", mask_array);
482 g_Game.ConfigGetFloatArray(path + " PPLensProperties", lens_array);
483 blur_float = g_Game.ConfigGetFloat(path + " PPBlurProperties");
484 }
485
487 {
488 string path = "cfgVehicles " + GetType() + " OpticsInfo";
489 if ( g_Game.ConfigIsExisting(path + " nearPlaneDistanceOverride") )
490 {
491 m_nearplane_override = Math.Max(g_Game.ConfigGetFloat(path + " nearPlaneDistanceOverride"),DayZPlayerCameraBase.CONST_NEARPLANE_OPTICS_MIN);
492 }
493 else
494 {
495 m_nearplane_override = DayZPlayerCameraOptics.CONST_NEARPLANE_OPTICS;
496 }
497 }
498
501 {
502 if (g_Game.ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties"))
503 {
504 g_Game.ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties", temp_array);
505 return true;
506 }
507 else if (g_Game.ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties"))
508 {
509 g_Game.ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties", temp_array);
510 return true;
511 }
512 return false;
513 }
514
517 {
518 return m_allowsDOF;
519 }
520
522 {
523 return m_isNVOptic;
524 }
525
527 {
528 /*
529 //TODO - implement this into NV optics and modify (KazuarOptic example below)
530 if (IsWorking())
531 {
532 switch (m_CurrentOpticMode)
533 {
534 case GameConstants.OPTICS_STATE_DAY:
535 return NVTypes.NV_OPTICS_KAZUAR_DAY;
536
537 case GameConstants.OPTICS_STATE_NIGHTVISION:
538 return NVTypes.NV_OPTICS_KAZUAR_NIGHT;
539 }
540 }
541 else
542 {
543 return NVTypes.NV_OPTICS_OFF;
544 }
545 */
546 return NVTypes.NONE;
547 }
548
549 void SetCurrentOpticMode(int mode)
550 {
551 m_CurrentOpticMode = mode;
553 }
554
556 {
557 return m_CurrentOpticMode;
558 }
559
563 {
564 if ( g_Game && !g_Game.IsHeadlessOrDedicatedServer() )
565 {
566 HideSelection("hide");
567 }
568 }
570 {
571 if ( g_Game && !g_Game.IsHeadlessOrDedicatedServer() )
572 {
573 ShowSelection("hide");
574 }
575 }
576
578 {
580 }
582 {
583 return m_mask_array;
584 }
586 {
587 return m_lens_array;
588 }
590 {
591 return m_blur_float;
592 }
593
595 {
597 }
598
600 {
601 string path = "cfgVehicles " + GetType() + " OpticsInfo preloadOpticType";
602 string type_2d;
603
604 if ( g_Game.ConfigIsExisting(path) )
605 {
606 g_Game.ConfigGetText(path, type_2d);
607 m_2D_preload_type = type_2d;
608 }
609 }
610
615
617
618 override void SetActions()
619 {
620 super.SetActions();
621
623 }
624
625 override void OnDebugSpawn()
626 {
627 GetInventory().CreateAttachment("Battery9V");
628 }
629}
630
631typedef ItemOptics OpticBase;
632
633
eBleedingSourceType GetType()
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
DayZGame g_Game
Определения DayZGame.c:4074
NVTypes
Определения DayZPlayerCamera_Base.c:55
void DayZPlayerCameraOptics(DayZPlayer pPlayer, HumanInputController pInput)
Определения DayZPlayerCameraIronsights.c:367
override void SetTakeable(bool pState)
Определения ItemBase.c:4362
bool m_IsStoreLoad
Определения ItemBase.c:64
string path
Определения OptionSelectorMultistate.c:142
Super root of all classes in Enforce script.
Определения EnScript.c:11
this is main camera class
Определения DayZPlayerCamera1stPerson.c:5
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:561
override void OnSwitchOff()
Определения ItemOptics.c:260
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:478
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:625
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:611
string m_2D_preload_type
Определения ItemOptics.c:14
bool IsUsingOptics2DModel()
Returns whether this ItemOptics uses the 2D optics model.
Определения ItemOptics.c:207
void OnOpticExit()
Определения ItemOptics.c:569
override void OnWorkStart()
Определения ItemOptics.c:223
void InitReddotData()
Определения ItemOptics.c:374
int GetCurrentOpticMode()
Определения ItemOptics.c:555
ref array< float > GetOpticsPPLens()
Определения ItemOptics.c:585
bool IsWorking()
Определения ItemOptics.c:242
bool IsUsableWithNV()
Определения ItemOptics.c:218
bool m_reddot_displayed bool m_isNVOptic
Определения ItemOptics.c:6
override void OnStoreSave(ParamsWriteContext ctx)
Определения ItemOptics.c:332
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:516
int GetCurrentNVType()
Определения ItemOptics.c:526
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:581
float GetNearPlaneValue()
Определения ItemOptics.c:594
proto native bool IsUsingWeaponIronsightsOverride()
is optics using ironsights override settings or not
void OnOpticEnter()
Определения ItemOptics.c:562
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:275
void UpdateSelectionVisibility()
Определения ItemOptics.c:616
void OnDrawOptics2D()
Определения ItemOptics.c:180
bool m_data_set
Определения ItemOptics.c:3
bool IsSightOnly()
Определения ItemOptics.c:213
override void HideSelection(string selection_name)
Определения HuntingOptic.c:34
bool InitDOFAvailability()
optics with more than 1x zoom do not allow DOF changes
Определения ItemOptics.c:459
void InitOpticsPPInfo()
Определения ItemOptics.c:450
float GetOpticsPPBlur()
Определения ItemOptics.c:589
override void OnSwitchOn()
Определения ItemOptics.c:249
override void OnVariablesSynchronized()
Определения ItemOptics.c:363
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:618
float m_blur_float
Определения ItemOptics.c:10
bool IsNVOptic()
Определения ItemOptics.c:521
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:500
proto native bool HasWeaponIronsightsOverride()
is weapon in optics mode or not
ref array< float > GetOpticsDOF()
Определения ItemOptics.c:577
proto native float GetZeroingDistanceZoomMin()
Gets Zeroing distance at opticsZoomMin.
proto native float GetZoomInit()
gets FOV value, when entering optics
void Init2DPreloadType()
Определения ItemOptics.c:599
void SetCurrentOpticMode(int mode)
Определения ItemOptics.c:549
override void OnWasAttached(EntityAI parent, int slot_id)
Определения ItemOptics.c:287
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:319
float m_nearplane_override
Определения ItemOptics.c:11
void InitCameraOverrideProperties()
Определения ItemOptics.c:486
proto native int GetStepZeroing()
returns position of currently used value in zeroing config array
void ShowReddot(bool state)
Определения ItemOptics.c:412
ItemOpticsType GetItemOpticsType()
Returns the ItemOpticsType of this ItemOptics instance.
Определения ItemOptics.c:201
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:339
override void OnWorkStop()
Определения ItemOptics.c:234
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:300
bool IsSwitchedOn()
Определения ItemOptics.c:268
Определения ItemOptics.c:2
proto native bool IsUsingOptics2DModel()
Whether 2D model (modelOptics) is set and used for this type.
proto native int FindOptics2DSelection(string selectionName, bool ignoreCase=true)
Finds selection index by name.
proto native void SetOptics2DMaterial(int index, string materialName)
Set optics 2D material at provided selection index.
proto native void SetOptics2DTexture(int index, string textureName)
Set optics 2D model texture at provided selection index.
Определения 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
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
const float DZPLAYER_CAMERA_FOV_IRONSIGHTS
Определения 3_Game/DayZ/constants.c:1041
const int OPTICS_STATE_DAY
Определения 3_Game/DayZ/constants.c:968
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.