DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ UseWeaponObstruction()

bool Weapon::UseWeaponObstruction ( PlayerBase player,
float obstructionValue,
Object hitObject )
inlineprotected

Returns whether this weapon can use obstruction instead of weapon lift. Implement simple conditions only (e.g. checking for attachments, weapon types, ...) to prevent possible desyncs.

Аргументы
obstructionValueThe percentage of penetration into hit object
hitObjectThe object obstructing the weapon

CFGGAMEPLAY

См. определение в файле Weapon_Base.c строка 1379

1380 {
1381 HumanMovementState ms = new HumanMovementState();
1382 player.GetMovementState(ms);
1383
1384 #ifdef DIAG_DEVELOPER
1385 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 2) // allow always
1386 return true;
1387 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 6) // neverEver
1388 return false;
1389 #endif
1390
1391 // Obstruction in prone does not really work well, the weapon has no physical room
1392 // to move, so we instead always lift in such stance
1393 if (ms.IsInProne() || ms.IsInRaisedProne())
1394 {
1395 return false;
1396 }
1397
1398 // if ( m_ObstructionDistance != 0 && m_ObstructionDistance < 0.7 && ZombieBase.Cast( hitObject ) ) return true;
1399
1400 bool isDynamic;
1401 bool isStatic;
1402 if (hitObject)
1403 {
1404 isDynamic = dBodyIsDynamic(hitObject);
1405 isStatic = !isDynamic;
1406 }
1407
1408 #ifdef DIAG_DEVELOPER
1409 // alwaysDynamic || alwaysDynamicNeverStatic
1410 bool diagAlwaysDynamic = DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 3 || DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 5;
1411 if (diagAlwaysDynamic && isDynamic) // alwaysDynamic
1412 return true;
1413
1414 // neverStatic || alwaysDynamicNeverStatic
1415 bool diagNeverStatic = DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 4 || DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 5;
1416 if (diagNeverStatic && isStatic) // neverStatic
1417 return false;
1418 #endif
1419
1420 //CFGGAMEPLAY
1421 EWeaponObstructionMode staticMode = CfgGameplayHandler.GetWeaponObstructionModeStatic();
1422 EWeaponObstructionMode dynamicMode = CfgGameplayHandler.GetWeaponObstructionModeDynamic();
1423 if (hitObject) // Can determine logic reliably
1424 {
1425 if ((isStatic && staticMode == EWeaponObstructionMode.DISABLED) || (isDynamic && dynamicMode == EWeaponObstructionMode.DISABLED))
1426 {
1427 return false;
1428 }
1429 else if ((isStatic && staticMode == EWeaponObstructionMode.ALWAYS) || (isDynamic && dynamicMode == EWeaponObstructionMode.ALWAYS))
1430 {
1431 return true;
1432 }
1433 }
1434 else if (obstructionValue > 0) // With no hit we have to guess whether object was dynamic or static
1435 {
1436 // Allow obstruction if it was already going on (and it is allowed in either mode)
1437 return staticMode != EWeaponObstructionMode.DISABLED && dynamicMode != EWeaponObstructionMode.DISABLED;
1438 }
1440
1441
1442 // Create a buffer between entering and leaving the lift to prevent
1443 // continuous state changes while the value is near the edge. (hysteresis)
1444 bool isLift = player.IsLiftWeapon();
1445
1446 if (isLift && obstructionValue > 0.9) // Retain lift while already lifted
1447 {
1448 return false;
1449 }
1450
1451 if (!isLift && obstructionValue >= 1.0) // Enter lift while not lifted and obstructed enough
1452 {
1453 return false;
1454 }
1455
1456 #ifdef DIAG_DEVELOPER // Keep this diag below all state conditions but above weapon type checks
1457 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_FORCEALLOW_OBSTRUCTION) == 1) // allow conditionally
1458 return true;
1459 #endif
1460
1461 // Allow obstruction with weapons that have their distance defined, otherwise don't
1462 return m_ObstructionDistance != 0;
1463 }
EWeaponObstructionMode
Определения CfgGameplayDataJson.c:376
EWeaponObstructionMode staticMode
!! all member variables must correspond with the cfggameplay.json file contents !!...
Определения CfgGameplayDataJson.c:395
EWeaponObstructionMode dynamicMode
Определения CfgGameplayDataJson.c:396
DiagMenuIDs
Определения EDiagMenuIDs.c:2
bool IsInProne()
Определения human.c:1202
bool IsInRaisedProne()
Определения human.c:1208
float m_ObstructionDistance
Определения Weapon_Base.c:67
proto native bool dBodyIsDynamic(notnull IEntity ent)

Перекрестные ссылки dBodyIsDynamic(), dynamicMode, DiagMenu::GetValue(), CfgGameplayHandler::GetWeaponObstructionModeDynamic(), CfgGameplayHandler::GetWeaponObstructionModeStatic(), HumanMovementState::IsInProne(), HumanMovementState::IsInRaisedProne(), m_ObstructionDistance и staticMode.