DayZ 1.28
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 строка 1385

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