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