Mercurial > mm7
comparison Keyboard.cpp @ 2333:82851980e3d8
Слияние
author | Ritor1 |
---|---|
date | Wed, 02 Apr 2014 20:53:47 +0600 |
parents | 9551756f46c4 |
children | ddb803517a48 |
comparison
equal
deleted
inserted
replaced
2332:defd2526c94c | 2333:82851980e3d8 |
---|---|
6 #include "mm7_data.h" | 6 #include "mm7_data.h" |
7 #include "mm7_unsorted_subs.h" | 7 #include "mm7_unsorted_subs.h" |
8 #include "Vis.h" | 8 #include "Vis.h" |
9 #include "MM7.h" | 9 #include "MM7.h" |
10 #include "Actor.h" | 10 #include "Actor.h" |
11 #include "Party.h" | |
12 #include "Timer.h" | |
13 #include "TurnEngine.h" | |
14 #include "Weather.h" | |
15 #include "CastSpellInfo.h" | |
11 #include "DecorationList.h" | 16 #include "DecorationList.h" |
12 #include "Indoor.h" | 17 #include "Indoor.h" |
13 #include "viewport.h" | 18 #include "viewport.h" |
14 #include "AudioPlayer.h" | 19 #include "AudioPlayer.h" |
15 #include "Level/Decoration.h" | 20 #include "Level/Decoration.h" |
476 LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); | 481 LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); |
477 if ( !(char)v1 ) | 482 if ( !(char)v1 ) |
478 break; | 483 break; |
479 }*/ | 484 }*/ |
480 } | 485 } |
486 | |
487 | |
488 //----- (0042FC4E) -------------------------------------------------------- | |
489 void Keyboard::ProcessInputActions() | |
490 { | |
491 char v4; // al@9 | |
492 //char v8; // bl@100 | |
493 unsigned __int16 v9; // ax@102 | |
494 int spell_price; // eax@103 | |
495 char v14; // al@159 | |
496 unsigned int v15; // eax@168 | |
497 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 | |
498 InputAction inputAction; // [sp+0h] [bp-8h]@7 | |
499 //int v24; // [sp+4h] [bp-4h]@87 | |
500 | |
501 pGame->pKeyboardInstance->EnterCriticalSection(); | |
502 Keyboard* pKeyboard = pGame->pKeyboardInstance; | |
503 if (!bAlwaysRun) | |
504 { | |
505 if (pKeyboard->IsShiftHeld()) | |
506 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
507 else | |
508 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
509 } | |
510 else | |
511 { | |
512 if (pKeyboard->IsShiftHeld()) | |
513 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
514 else | |
515 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
516 } | |
517 | |
518 //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
519 | |
520 | |
521 // WUT? double event trigger | |
522 /*for ( uint i = 0; i < 30; ++i ) | |
523 { | |
524 if ( pKeyActionMap->pToggleTypes[i] ) | |
525 v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
526 else | |
527 v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
528 if ( v14 ) | |
529 { | |
530 if (pCurrentScreen == SCREEN_GAME) | |
531 { | |
532 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
533 continue; | |
534 } | |
535 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) | |
536 { | |
537 v15 = pMessageQueue_50CBD0->uNumMessages; | |
538 if ( pMessageQueue_50CBD0->uNumMessages ) | |
539 { | |
540 v15 = 0; | |
541 if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) | |
542 { | |
543 v15 = 1; | |
544 pMessageQueue_50CBD0->uNumMessages = 0; | |
545 pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; | |
546 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
547 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
548 ++pMessageQueue_50CBD0->uNumMessages; | |
549 continue; | |
550 } | |
551 pMessageQueue_50CBD0->uNumMessages = 0; | |
552 } | |
553 //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
554 } | |
555 } | |
556 }*/ | |
557 if ( !pEventTimer->bPaused ) | |
558 { | |
559 for ( uint i = 0; i < 30; ++i ) | |
560 { | |
561 inputAction = (InputAction)i; | |
562 if ( pKeyActionMap->pToggleTypes[inputAction] ) | |
563 v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[inputAction]); | |
564 else | |
565 v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[inputAction]); | |
566 if ( v4 ) | |
567 { | |
568 switch ( inputAction ) | |
569 { | |
570 case INPUT_MoveForward: | |
571 if (pCurrentScreen != SCREEN_GAME) | |
572 break; | |
573 if (!pParty->bTurnBasedModeOn) | |
574 { | |
575 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
576 partyAction = PARTY_RunForward; | |
577 else | |
578 partyAction = PARTY_WalkForward; | |
579 pPartyActionQueue->Add(partyAction); | |
580 break; | |
581 } | |
582 if (pTurnEngine->turn_stage != TE_WAIT && pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->uActionPointsLeft > 0 ) | |
583 { | |
584 pTurnEngine->uActionPointsLeft -= 26; | |
585 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
586 partyAction = PARTY_RunForward; | |
587 else | |
588 partyAction = PARTY_WalkForward; | |
589 pPartyActionQueue->Add(partyAction); | |
590 break; | |
591 } | |
592 break; | |
593 case INPUT_MoveBackwards: | |
594 if (pCurrentScreen != SCREEN_GAME) | |
595 break; | |
596 if (!pParty->bTurnBasedModeOn) | |
597 { | |
598 if ( pParty->uFlags2 & 2 ) | |
599 partyAction = PARTY_RunBackward; | |
600 else | |
601 partyAction = PARTY_WalkBackward; | |
602 pPartyActionQueue->Add(partyAction); | |
603 break; | |
604 } | |
605 if ( pTurnEngine->turn_stage != TE_WAIT && pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->uActionPointsLeft > 0 ) | |
606 { | |
607 pTurnEngine->uActionPointsLeft -= 26; | |
608 if ( pParty->uFlags2 & 2 ) | |
609 partyAction = PARTY_RunBackward; | |
610 else | |
611 partyAction = PARTY_WalkBackward; | |
612 pPartyActionQueue->Add(partyAction); | |
613 break; | |
614 } | |
615 break; | |
616 case INPUT_StrafeLeft: | |
617 if (pCurrentScreen != SCREEN_GAME) | |
618 break; | |
619 if (!pParty->bTurnBasedModeOn) | |
620 { | |
621 partyAction = PARTY_StrafeLeft; | |
622 pPartyActionQueue->Add(partyAction); | |
623 break; | |
624 } | |
625 if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) | |
626 break; | |
627 pTurnEngine->uActionPointsLeft -= 26; | |
628 partyAction = PARTY_StrafeLeft; | |
629 pPartyActionQueue->Add(partyAction); | |
630 break; | |
631 case INPUT_StrafeRight: | |
632 if (pCurrentScreen != SCREEN_GAME) | |
633 break; | |
634 if (!pParty->bTurnBasedModeOn) | |
635 { | |
636 partyAction = PARTY_StrafeRight; | |
637 pPartyActionQueue->Add(partyAction); | |
638 break; | |
639 } | |
640 if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) | |
641 break; | |
642 pTurnEngine->uActionPointsLeft -= 26; | |
643 partyAction = PARTY_StrafeRight; | |
644 pPartyActionQueue->Add(partyAction); | |
645 break; | |
646 case INPUT_TurnLeft: | |
647 if (pCurrentScreen != SCREEN_GAME) | |
648 break; | |
649 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing | |
650 { | |
651 if (pParty->bTurnBasedModeOn) | |
652 { | |
653 if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) | |
654 break; | |
655 pTurnEngine->uActionPointsLeft -= 26; | |
656 } | |
657 partyAction = PARTY_StrafeLeft; | |
658 } | |
659 else | |
660 { | |
661 if ( pParty->uFlags2 & 2 ) | |
662 partyAction = PARTY_FastTurnLeft; | |
663 else | |
664 partyAction = PARTY_TurnLeft; | |
665 } | |
666 pPartyActionQueue->Add(partyAction); | |
667 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) | |
668 pWeather->OnPlayerTurn(10); | |
669 break; | |
670 case INPUT_TurnRight: | |
671 if (pCurrentScreen != SCREEN_GAME) | |
672 break; | |
673 if ( GetAsyncKeyState(17) ) // strafing | |
674 { | |
675 if (pParty->bTurnBasedModeOn) | |
676 { | |
677 if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) | |
678 break; | |
679 pTurnEngine->uActionPointsLeft -= 26; | |
680 } | |
681 partyAction = PARTY_StrafeRight; | |
682 } | |
683 else | |
684 { | |
685 if ( pParty->uFlags2 & 2 ) | |
686 partyAction = PARTY_FastTurnRight; | |
687 else | |
688 partyAction = PARTY_TurnRight; | |
689 } | |
690 pPartyActionQueue->Add(partyAction); | |
691 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) | |
692 pWeather->OnPlayerTurn(-10); | |
693 break; | |
694 case INPUT_Jump: | |
695 if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) | |
696 break; | |
697 partyAction = (PartyAction)12; | |
698 pPartyActionQueue->Add(partyAction); | |
699 break; | |
700 case INPUT_Yell: | |
701 if (!pCurrentScreen && uActiveCharacter) | |
702 { | |
703 pParty->Yell(); | |
704 pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); | |
705 } | |
706 break; | |
707 case INPUT_Pass: | |
708 if ( pCurrentScreen ) | |
709 break; | |
710 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) | |
711 { | |
712 pTurnEngine->field_18 |= TE_FLAG_8; | |
713 break; | |
714 } | |
715 if ( uActiveCharacter ) | |
716 { | |
717 if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) | |
718 { | |
719 if ( !pParty->bTurnBasedModeOn ) | |
720 pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false) * 2.133333333333333)); | |
721 CastSpellInfoHelpers::_427D48(); | |
722 pTurnEngine->ApplyPlayerAction(); | |
723 } | |
724 } | |
725 break; | |
726 case INPUT_Combat://if press ENTER | |
727 if (pCurrentScreen == SCREEN_GAME) | |
728 { | |
729 if (pParty->bTurnBasedModeOn) | |
730 { | |
731 if (pTurnEngine->turn_stage == TE_MOVEMENT || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) | |
732 { | |
733 pParty->bTurnBasedModeOn = 0; | |
734 pTurnEngine->End(true); | |
735 } | |
736 } | |
737 else | |
738 { | |
739 pTurnEngine->Start(); | |
740 pParty->bTurnBasedModeOn = true; | |
741 } | |
742 } | |
743 break; | |
744 case INPUT_CastReady: | |
745 if (pCurrentScreen != SCREEN_GAME) | |
746 break; | |
747 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) | |
748 { | |
749 pTurnEngine->field_18 |= TE_FLAG_8; | |
750 break; | |
751 } | |
752 if ( !uActiveCharacter ) | |
753 break; | |
754 v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 + 12]; | |
755 if ( !pPlayers[uActiveCharacter]->uQuickSpell || bUnderwater | |
756 || (( !(HIBYTE(v9) & 1)) ? | |
757 ((v9 & 0x80) == 0 ? | |
758 ((v9 & 0x40) == 0 ? spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uNormalLevelMana : spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uExpertLevelMana) : | |
759 spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMasterLevelMana) : | |
760 spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMagisterLevelMana, | |
761 spell_price > pPlayers[uActiveCharacter]->sMana) ) | |
762 { | |
763 pPartyActionQueue = pPartyActionQueue; | |
764 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
765 break; | |
766 } | |
767 else | |
768 pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); | |
769 break; | |
770 case INPUT_Attack: | |
771 if (pCurrentScreen != SCREEN_GAME) | |
772 break; | |
773 if (pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT) | |
774 { | |
775 pTurnEngine->field_18 |= TE_FLAG_8; | |
776 break; | |
777 } | |
778 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
779 break; | |
780 case INPUT_EventTrigger: | |
781 if (pCurrentScreen == SCREEN_GAME) | |
782 { | |
783 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
784 break; | |
785 } | |
786 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) | |
787 { | |
788 if ( pMessageQueue_50CBD0->uNumMessages ) | |
789 { | |
790 pMessageQueue_50CBD0->uNumMessages = 0; | |
791 if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) | |
792 { | |
793 pMessageQueue_50CBD0->uNumMessages = 1; | |
794 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
795 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
796 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0; | |
797 ++pMessageQueue_50CBD0->uNumMessages; | |
798 break; | |
799 } | |
800 break; | |
801 } | |
802 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
803 } | |
804 break; | |
805 case INPUT_CharCycle: | |
806 if ( pCurrentScreen == SCREEN_SPELL_BOOK ) | |
807 break; | |
808 | |
809 pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); | |
810 break; | |
811 case INPUT_LookUp: | |
812 if ( pEventTimer->bPaused ) | |
813 break; | |
814 partyAction = (PartyAction)7; | |
815 pPartyActionQueue->Add(partyAction); | |
816 break; | |
817 case INPUT_CenterView: | |
818 if ( pEventTimer->bPaused ) | |
819 break; | |
820 partyAction = (PartyAction)9; | |
821 pPartyActionQueue->Add(partyAction); | |
822 break; | |
823 case INPUT_LookDown: | |
824 if ( pEventTimer->bPaused ) | |
825 break; | |
826 partyAction = (PartyAction)8; | |
827 pPartyActionQueue->Add(partyAction); | |
828 break; | |
829 case INPUT_FlyUp: | |
830 if ( pCurrentScreen || pEventTimer->bPaused ) | |
831 break; | |
832 partyAction = (PartyAction)13; | |
833 pPartyActionQueue->Add(partyAction); | |
834 break; | |
835 case INPUT_Land: | |
836 if ( pCurrentScreen || pEventTimer->bPaused ) | |
837 break; | |
838 partyAction = (PartyAction)15; | |
839 pPartyActionQueue->Add(partyAction); | |
840 break; | |
841 case INPUT_FlyDown: | |
842 if ( !pCurrentScreen | |
843 && !pEventTimer->bPaused ) | |
844 { | |
845 partyAction = (PartyAction)14; | |
846 pPartyActionQueue->Add(partyAction); | |
847 } | |
848 break; | |
849 case INPUT_ZoomIn: | |
850 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); | |
851 break; | |
852 case INPUT_ZoomOut: | |
853 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); | |
854 break; | |
855 case INPUT_AlwaysRun: | |
856 bAlwaysRun = bAlwaysRun == 0; | |
857 break; | |
858 default: | |
859 break; | |
860 } | |
861 } | |
862 } | |
863 } | |
864 } |