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

◆ ModCommandHandlerBefore()

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

sprint

jog

walk

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

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

Перекрестные ссылки ScriptModule::CallFunction(), Class::CastTo(), CinematicCanJump(), Math::Clamp(), Math::DEG2RAD, CGame::GameScript, GetGame(), 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().