DayZ 1.29
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.IsDedicatedServer())
226 {
227 ShowReddot(true);
228 }
229 }
230
231 override void OnWorkStop()
232 {
233 if (!g_Game.IsDedicatedServer())
234 {
235 ShowReddot(false);
236 }
237 }
238
240 {
241 if (GetCompEM() && GetCompEM().CanWork())
242 return true;
243 return false;
244 }
245
247 {
248 if (IsWorking() && !m_reddot_displayed)
249 {
250 ShowReddot(true);
251 }
252 else if (!IsWorking() && m_reddot_displayed)
253 {
254 ShowReddot(false);
255 }
256 }
257
258 override void OnWasAttached( EntityAI parent, int slot_id )
259 {
260 super.OnWasAttached(parent, slot_id);
261
262 SetTakeable(false);
263
264 Weapon wep;
265 if (Class.CastTo(wep,parent))
266 {
267 SetZeroingClampDist(wep.GetZeroingClamp(wep.GetCurrentMuzzle()));
268 }
269 }
270
271 override void OnWasDetached( EntityAI parent, int slot_id )
272 {
273 super.OnWasDetached(parent, slot_id);
274
275 PlayerBase player;
276 if (PlayerBase.CastTo(player, GetHierarchyRootPlayer()))
277 {
278 player.SetReturnToOptics(false);
279 }
280
281 SetTakeable(true);
282
283 Weapon wep;
284 if (Class.CastTo(wep,parent))
285 {
287 }
288 }
289
290 override void OnInventoryExit(Man player)
291 {
292 super.OnInventoryExit(player);
293
294 PlayerBase playerPB;
295 if (PlayerBase.CastTo(playerPB, player))
296 {
297 playerPB.SetReturnToOptics(false);
298 }
299
300 SetTakeable(true);
301 }
302
304 {
305 super.OnStoreSave(ctx);
306
308 }
309
310 override bool OnStoreLoad(ParamsReadContext ctx, int version)
311 {
312 if ( !super.OnStoreLoad(ctx,version) )
313 {
314 return false;
315 }
316 m_IsStoreLoad = true;
317
318 if ( version >= 126 )
319 {
320 if ( !ctx.Read(m_CurrentOpticMode) )
321 {
322 m_IsStoreLoad = false;
323 return false;
324 }
325 }
326
328 SetSynchDirty();
329
330 m_IsStoreLoad = false;
331 return true;
332 }
333
335 {
336 super.OnVariablesSynchronized();
337
339 {
342 }
343 }
344
346 {
347 bool isUsing2D = IsUsingOptics2DModel();
348
349 string path;
350 if (isUsing2D)
351 {
352 path = "cfgVehicles " + GetType() + " OpticsModelInfo";
353 }
354 else
355 {
356 path = "cfgVehicles " + GetType() + " OpticsInfo";
357 }
358 string temp;
359
360 if (g_Game.ConfigIsExisting(path))
361 {
362 if (isUsing2D)
364 else
365 m_reddot_index = GetHiddenSelectionIndex("reddot");
366
367 if (g_Game.ConfigIsExisting(path + " opticSightTexture"))
368 {
369 g_Game.ConfigGetText(path + " opticSightTexture", temp);
371 temp = "";
372 }
373 if (g_Game.ConfigIsExisting(path + " opticSightMaterial"))
374 {
375 g_Game.ConfigGetText(path + " opticSightMaterial", temp);
377 temp = "";
378 }
379 }
380 m_data_set = true;
381 }
382
383 void ShowReddot(bool state)
384 {
385 if (g_Game.IsDedicatedServer())
386 {
387 ErrorEx("should not be called on the server!",ErrorExSeverity.INFO);
388 return;
389 }
390
391 if (!m_data_set)
392 {
394 }
395
396 // does not have reddot
397 if (m_reddot_index == -1)
398 {
399 return;
400 }
401
402 // 2D model has special handling in `OnDrawOptics2D`
404 {
405 if (state)
406 {
407 if (m_optic_sight_texture != "")
408 SetObjectTexture(m_reddot_index, m_optic_sight_texture);
409 if (m_optic_sight_material != "")
410 SetObjectMaterial(m_reddot_index, m_optic_sight_material);
411 }
412 else
413 {
414 SetObjectTexture(m_reddot_index, "");
415 SetObjectMaterial(m_reddot_index, "");
416 }
417 }
418 m_reddot_displayed = state;
419 }
420
422 {
425
426 m_isNVOptic = ConfigGetBool("NVOptic");
427 }
428
431 {
432 float fov_max;
433 string path = "cfgVehicles " + GetType() + " OpticsInfo";
434
435 /*
436 Weapon_Base weapon = Weapon_Base.Cast(GetHierarchyParent());
437 if (!weapon)
438 return false; // no DOF for handheld optics
439 */
440 fov_max = g_Game.ConfigGetFloat(path + " opticsZoomMax");
442 {
443 return true;
444 }
445 return false;
446 }
447
449 void InitOpticsPP(out array<float> mask_array, out array<float> lens_array, out float blur_float)
450 {
451 string path = "cfgVehicles " + GetType() + " OpticsInfo";
452 g_Game.ConfigGetFloatArray(path + " PPMaskProperties", mask_array);
453 g_Game.ConfigGetFloatArray(path + " PPLensProperties", lens_array);
454 blur_float = g_Game.ConfigGetFloat(path + " PPBlurProperties");
455 }
456
458 {
459 string path = "cfgVehicles " + GetType() + " OpticsInfo";
460 if ( g_Game.ConfigIsExisting(path + " nearPlaneDistanceOverride") )
461 {
462 m_nearplane_override = Math.Max(g_Game.ConfigGetFloat(path + " nearPlaneDistanceOverride"),DayZPlayerCameraBase.CONST_NEARPLANE_OPTICS_MIN);
463 }
464 else
465 {
466 m_nearplane_override = DayZPlayerCameraOptics.CONST_NEARPLANE_OPTICS;
467 }
468 }
469
472 {
473 if (g_Game.ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties"))
474 {
475 g_Game.ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfo PPDOFProperties", temp_array);
476 return true;
477 }
478 else if (g_Game.ConfigIsExisting("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties"))
479 {
480 g_Game.ConfigGetFloatArray("cfgVehicles " + GetType() + " OpticsInfoWeaponOverride PPDOFProperties", temp_array);
481 return true;
482 }
483 return false;
484 }
485
488 {
489 return m_allowsDOF;
490 }
491
493 {
494 return m_isNVOptic;
495 }
496
498 {
499 /*
500 //TODO - implement this into NV optics and modify (KazuarOptic example below)
501 if (IsWorking())
502 {
503 switch (m_CurrentOpticMode)
504 {
505 case GameConstants.OPTICS_STATE_DAY:
506 return NVTypes.NV_OPTICS_KAZUAR_DAY;
507
508 case GameConstants.OPTICS_STATE_NIGHTVISION:
509 return NVTypes.NV_OPTICS_KAZUAR_NIGHT;
510 }
511 }
512 else
513 {
514 return NVTypes.NV_OPTICS_OFF;
515 }
516 */
517 return NVTypes.NONE;
518 }
519
520 void SetCurrentOpticMode(int mode)
521 {
522 m_CurrentOpticMode = mode;
524 }
525
527 {
528 return m_CurrentOpticMode;
529 }
530
534 {
535 if ( g_Game && !g_Game.IsDedicatedServer() )
536 {
537 HideSelection("hide");
538 }
539 }
541 {
542 if ( g_Game && !g_Game.IsDedicatedServer() )
543 {
544 ShowSelection("hide");
545 }
546 }
547
549 {
551 }
553 {
554 return m_mask_array;
555 }
557 {
558 return m_lens_array;
559 }
561 {
562 return m_blur_float;
563 }
564
566 {
568 }
569
571 {
572 string path = "cfgVehicles " + GetType() + " OpticsInfo preloadOpticType";
573 string type_2d;
574
575 if ( g_Game.ConfigIsExisting(path) )
576 {
577 g_Game.ConfigGetText(path, type_2d);
578 m_2D_preload_type = type_2d;
579 }
580 }
581
586
588
589 override void SetActions()
590 {
591 super.SetActions();
592
594 }
595
596 override void OnDebugSpawn()
597 {
598 GetInventory().CreateAttachment("Battery9V");
599 }
600}
601
602typedef ItemOptics OpticBase;
603
604
eBleedingSourceType GetType()
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
DayZGame g_Game
Определения DayZGame.c:3942
NVTypes
Определения DayZPlayerCamera_Base.c:55
void DayZPlayerCameraOptics(DayZPlayer pPlayer, HumanInputController pInput)
Определения DayZPlayerCameraIronsights.c:365
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
bool m_IsStoreLoad
Определения ItemBase.c:4966
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:532
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:449
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:596
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:582
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:540
override void OnWorkStart()
Определения ItemOptics.c:223
void InitReddotData()
Определения ItemOptics.c:345
int GetCurrentOpticMode()
Определения ItemOptics.c:526
ref array< float > GetOpticsPPLens()
Определения ItemOptics.c:556
bool IsWorking()
Определения ItemOptics.c:239
bool IsUsableWithNV()
Определения ItemOptics.c:218
bool m_reddot_displayed bool m_isNVOptic
Определения ItemOptics.c:6
override void OnStoreSave(ParamsWriteContext ctx)
Определения ItemOptics.c:303
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:487
int GetCurrentNVType()
Определения ItemOptics.c:497
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:552
float GetNearPlaneValue()
Определения ItemOptics.c:565
proto native bool IsUsingWeaponIronsightsOverride()
is optics using ironsights override settings or not
void OnOpticEnter()
Определения ItemOptics.c:533
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:246
void UpdateSelectionVisibility()
Определения ItemOptics.c:587
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:430
void InitOpticsPPInfo()
Определения ItemOptics.c:421
float GetOpticsPPBlur()
Определения ItemOptics.c:560
override void OnVariablesSynchronized()
Определения ItemOptics.c:334
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:589
float m_blur_float
Определения ItemOptics.c:10
bool IsNVOptic()
Определения ItemOptics.c:492
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:471
proto native bool HasWeaponIronsightsOverride()
is weapon in optics mode or not
ref array< float > GetOpticsDOF()
Определения ItemOptics.c:548
proto native float GetZeroingDistanceZoomMin()
Gets Zeroing distance at opticsZoomMin.
proto native float GetZoomInit()
gets FOV value, when entering optics
void Init2DPreloadType()
Определения ItemOptics.c:570
void SetCurrentOpticMode(int mode)
Определения ItemOptics.c:520
override void OnWasAttached(EntityAI parent, int slot_id)
Определения ItemOptics.c:258
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:290
float m_nearplane_override
Определения ItemOptics.c:11
void InitCameraOverrideProperties()
Определения ItemOptics.c:457
proto native int GetStepZeroing()
returns position of currently used value in zeroing config array
void ShowReddot(bool state)
Определения ItemOptics.c:383
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:310
override void OnWorkStop()
Определения ItemOptics.c:231
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:271
Определения 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:983
const int OPTICS_STATE_DAY
Определения 3_Game/DayZ/constants.c:910
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.