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

◆ ModCommandHandlerBefore()

override bool DayZCreature::ModCommandHandlerBefore ( float pDt,
int pCurrentCommandID,
bool pCurrentCommandFinished )
inlineprotected

sprint

jog

walk

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

434 {
436 {
437 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
438 }
439
440 UAInterface input = m_CinematicPlayer.GetInputInterface();
441
442 DayZCreatureAIInputController controller;
443 g_Game.GameScript.CallFunction(this, "GetInputController", controller, 0);
444
445 if (!input || !controller)
446 {
447 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
448 }
449
450 float movementX = input.SyncedValue_ID(UAAimRight) - input.SyncedValue_ID(UAAimLeft);
451
452 float maxTurnSpeed = 100.0;
453 movementX = Math.Clamp(movementX * maxTurnSpeed * pDt, -180, 180);
454
455 if (input.SyncedValue_ID(UALookAround) > 0)
456 {
457 movementX = 0;
458 }
459
460 bool isJump = input.SyncedValue_ID(UAGetOver) > 0;
461 bool isMove = input.SyncedValue_ID(UAMoveForward) > 0;
462
463 bool isRest = input.SyncedValue_ID(UAMoveBack) > 0;
464 bool isSleep = input.SyncedValue_ID(UAReloadMagazine) > 0;
465
466 float heading = GetOrientation()[0] + movementX;
467
468 int iAlert = 0;
469 float fAlert = 0;
470 int iSpeed = 0;
471 float fSpeed = 0;
472
473 if (isMove)
474 {
475 iAlert = 1;
476 fAlert = 0.2;
477
478 bool isSprint = input.SyncedValue_ID(UATurbo) > 0;
479 bool isJog = input.SyncedValue_ID(UAWalkRunTemp) > 0;
480 bool isWalk = !isSprint && !isJog;
481 if (isSprint)
482 {
484 iSpeed = 3;
485 }
486 else if (isJog)
487 {
489 iSpeed = 2;
490 }
491 else if (isWalk)
492 {
494 iSpeed = 1;
495 }
496 }
497
498 DayZAnimalInputController animalController;
499 if (Class.CastTo(animalController, controller))
500 {
501 animalController.OverrideBehaviourSlot(true, DayZAnimalBehaviourSlot.NON_SPECIFIC_THREAT);
502 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.TRAVELING_INPUT);
503
504 if (!isMove)
505 {
506 if (isRest)
507 {
508 iSpeed = 0;
509 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.IDLE1_INPUT);
510 }
511
512 if (isSleep)
513 {
514 iSpeed = 0;
515 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.WALKING_INPUT);
516 }
517 }
518 }
519
520 bool lowVel = GetVelocity(this).Length() < 0.5;
521 if (iSpeed > 0 && lowVel)
522 {
523 iAlert = 4;
524 fAlert = 1.0;
525
526 iSpeed = 3;
527 }
528
529 if (animalController)
530 {
531 switch (iSpeed)
532 {
533 case 0:
534 fSpeed = 0;
535 break;
536 case 1:
537 fSpeed = 2;
538 break;
539 case 2:
540 fSpeed = 3;
541 break;
542 case 3:
543 fSpeed = 5;
544 break;
545 }
546 }
547
548 controller.OverrideTurnSpeed(true, Math.PI2 / pDt);
549 controller.OverrideMovementSpeed(true, fSpeed);
550 controller.OverrideHeading(true, heading * Math.DEG2RAD);
551 controller.OverrideAlertLevel(true, true, iAlert, fAlert);
552
553 if (CinematicCanJump() && isJump)
554 {
555 controller.OverrideJump(true, 101, 2.0);
556 }
557
558 return true;
559 }
vector GetOrientation()
Определения AreaDamageManager.c:306
DayZAnimalBehaviourSlot
defined in C++
Определения DayZAnimalInputController.c:3
DayZAnimalBehaviourAction
defined in C++
Определения DayZAnimalInputController.c:27
DayZGame g_Game
Определения DayZGame.c:3942
proto native void OverrideBehaviourAction(bool state, int action)
DayZPlayer m_CinematicPlayer
Определения DayZAnimal.c:212
bool CinematicCanJump()
Определения DayZAnimal.c:428
proto native void OverrideAlertLevel(bool state, bool alerted, int level, float inLevel)
proto native void OverrideJump(bool state, int jumpType, float jumpHeight=0)
proto native void OverrideBehaviourSlot(bool state, int slot)
proto native void OverrideMovementSpeed(bool state, float movementSpeed)
proto native void OverrideHeading(bool state, float heading)
proto native void OverrideTurnSpeed(bool state, float turnSpeed)
proto native float SyncedValue_ID(int action, bool check_focus=true)
Get action state.
proto native float Length()
Returns length of vector (magnitude)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.

Перекрестные ссылки Class::CastTo(), CinematicCanJump(), Math::Clamp(), Math::DEG2RAD, g_Game, GetOrientation(), GetVelocity(), vector::Length(), m_CinematicPlayer, DayZCreatureAIInputController::OverrideAlertLevel(), DayZAnimalInputController::OverrideBehaviourAction(), DayZCreatureAIInputController::OverrideBehaviourSlot(), DayZCreatureAIInputController::OverrideHeading(), DayZCreatureAIInputController::OverrideJump(), DayZCreatureAIInputController::OverrideMovementSpeed(), DayZCreatureAIInputController::OverrideTurnSpeed(), Math::PI2 и UAInterface::SyncedValue_ID().