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

◆ ModCommandHandlerBefore()

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

sprint

jog

walk

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

390 {
392 {
393 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
394 }
395
396 UAInterface input = m_CinematicPlayer.GetInputInterface();
397
398 DayZCreatureAIInputController controller;
399 GetGame().GameScript.CallFunction(this, "GetInputController", controller, 0);
400
401 if (!input || !controller)
402 {
403 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
404 }
405
406 float movementX = input.SyncedValue_ID(UAAimRight) - input.SyncedValue_ID(UAAimLeft);
407
408 float maxTurnSpeed = 100.0;
409 movementX = Math.Clamp(movementX * maxTurnSpeed * pDt, -180, 180);
410
411 if (input.SyncedValue_ID(UALookAround) > 0)
412 {
413 movementX = 0;
414 }
415
416 bool isJump = input.SyncedValue_ID(UAGetOver) > 0;
417 bool isMove = input.SyncedValue_ID(UAMoveForward) > 0;
418
419 bool isRest = input.SyncedValue_ID(UAMoveBack) > 0;
420 bool isSleep = input.SyncedValue_ID(UAReloadMagazine) > 0;
421
422 float heading = GetOrientation()[0] + movementX;
423
424 int iAlert = 0;
425 float fAlert = 0;
426 int iSpeed = 0;
427 float fSpeed = 0;
428
429 if (isMove)
430 {
431 iAlert = 1;
432 fAlert = 0.2;
433
434 bool isSprint = input.SyncedValue_ID(UATurbo) > 0;
435 bool isJog = input.SyncedValue_ID(UAWalkRunTemp) > 0;
436 bool isWalk = !isSprint && !isJog;
437 if (isSprint)
438 {
440 iSpeed = 3;
441 }
442 else if (isJog)
443 {
445 iSpeed = 2;
446 }
447 else if (isWalk)
448 {
450 iSpeed = 1;
451 }
452 }
453
454 DayZAnimalInputController animalController;
455 if (Class.CastTo(animalController, controller))
456 {
457 animalController.OverrideBehaviourSlot(true, DayZAnimalBehaviourSlot.NON_SPECIFIC_THREAT);
458 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.TRAVELING_INPUT);
459
460 if (!isMove)
461 {
462 if (isRest)
463 {
464 iSpeed = 0;
465 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.IDLE1_INPUT);
466 }
467
468 if (isSleep)
469 {
470 iSpeed = 0;
471 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.WALKING_INPUT);
472 }
473 }
474 }
475
476 bool lowVel = GetVelocity(this).Length() < 0.5;
477 if (iSpeed > 0 && lowVel)
478 {
479 iAlert = 4;
480 fAlert = 1.0;
481
482 iSpeed = 3;
483 }
484
485 if (animalController)
486 {
487 switch (iSpeed)
488 {
489 case 0:
490 fSpeed = 0;
491 break;
492 case 1:
493 fSpeed = 2;
494 break;
495 case 2:
496 fSpeed = 3;
497 break;
498 case 3:
499 fSpeed = 5;
500 break;
501 }
502 }
503
504 controller.OverrideTurnSpeed(true, Math.PI2 / pDt);
505 controller.OverrideMovementSpeed(true, fSpeed);
506 controller.OverrideHeading(true, heading * Math.DEG2RAD);
507 controller.OverrideAlertLevel(true, true, iAlert, fAlert);
508
509 if (CinematicCanJump() && isJump)
510 {
511 controller.OverrideJump(true, 101, 2.0);
512 }
513
514 return true;
515 }
vector GetOrientation()
Определения AreaDamageManager.c:306
DayZAnimalBehaviourSlot
defined in C++
Определения DayZAnimalInputController.c:3
DayZAnimalBehaviourAction
defined in C++
Определения DayZAnimalInputController.c:27
ScriptModule GameScript
Определения Game.c:12
proto native void OverrideBehaviourAction(bool state, int action)
DayZPlayer m_CinematicPlayer
Определения DayZAnimal.c:168
bool CinematicCanJump()
Определения DayZAnimal.c:384
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().