Mercurial > mm7
comparison Player.cpp @ 1361:b3ac17fd12de
Moved condition checking to a separate class, extracted it from player::SetCondition
author | Grumpy7 |
---|---|
date | Sun, 14 Jul 2013 23:22:43 +0200 |
parents | a47d9282ea7c |
children | d6cf8ead9242 |
comparison
equal
deleted
inserted
replaced
1360:a47d9282ea7c | 1361:b3ac17fd12de |
---|---|
696 case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break; | 696 case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break; |
697 default: return 1; break; | 697 default: return 1; break; |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 | |
702 //----- (00492D65) -------------------------------------------------------- | 701 //----- (00492D65) -------------------------------------------------------- |
703 int Player::SetCondition(unsigned int uConditionIdx, int a3) | 702 void Player::SetCondition( unsigned int uConditionIdx, int a3 ) |
704 { | 703 { |
705 signed int player_sex; // ecx@77 | 704 signed int player_sex; // ecx@77 |
706 char zombi_face; // al@80 | |
707 signed int remainig_player; // ebx@82 | 705 signed int remainig_player; // ebx@82 |
708 int players_before; // [sp+10h] [bp-4h]@2 | 706 int players_before; // [sp+10h] [bp-4h]@2 |
709 int players_after; // [sp+20h] [bp+Ch]@82 | 707 int players_after; // [sp+20h] [bp+Ch]@82 |
710 | 708 |
711 if ( pConditions[uConditionIdx] ) | 709 if ( pConditions[uConditionIdx] ) |
712 return 0; | 710 return; |
713 | 711 |
714 players_before = 0; | 712 players_before = 0; |
715 | 713 |
716 for (int i = 1; i < 5; ++i) | 714 for (int i = 1; i < 5; ++i) |
717 { | 715 { |
718 if ( pPlayers[i]->CanAct() ) | 716 if ( pPlayers[i]->CanAct() ) |
719 ++players_before; | 717 ++players_before; |
720 } | 718 } |
719 | |
720 if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3)) | |
721 { | |
722 return; | |
723 } | |
721 | 724 |
722 switch ( uConditionIdx ) | 725 switch ( uConditionIdx ) |
723 { | 726 { |
724 case Condition_Cursed: | 727 case Condition_Cursed: PlaySound(SPEECH_30, 0); break; |
725 PlaySound((PlayerSpeech)30, 0); | 728 case Condition_Weak: PlaySound(SPEECH_25, 0); break; |
726 break; | 729 case Condition_Sleep: break; //nosound |
727 case Condition_Weak: | 730 case Condition_Fear: PlaySound(SPEECH_26, 0); break; |
728 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 ) | 731 case Condition_Drunk: PlaySound(SPEECH_31, 0); break; |
729 { | 732 case Condition_Insane: PlaySound(SPEECH_29, 0); break; |
730 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
731 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
732 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
733 return 0; | |
734 } | |
735 PlaySound((PlayerSpeech)25, 0); | |
736 break; | |
737 case Condition_Sleep: | |
738 if ( a3 == 1 && (HasEnchantedItemEquipped(22) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR))) | |
739 return 0; | |
740 break; | |
741 | |
742 case Condition_Fear: | |
743 PlaySound((PlayerSpeech)26, 0); | |
744 break; | |
745 case Condition_Drunk: | |
746 PlaySound((PlayerSpeech)31, 0); | |
747 break; | |
748 case Condition_Insane: | |
749 if ( a3 == 1 && (HasEnchantedItemEquipped(19) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) ) | |
750 return 0; | |
751 PlaySound((PlayerSpeech)29, 0); | |
752 break; | |
753 case Condition_Poison1: | 733 case Condition_Poison1: |
754 case Condition_Poison2: | 734 case Condition_Poison2: |
755 case Condition_Poison3: | 735 case Condition_Poison3: PlaySound(SPEECH_27, 0); break; |
756 if ( a3 == 1 ) | |
757 { | |
758 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) | |
759 { | |
760 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
761 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
762 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
763 return 0; | |
764 } | |
765 if ( HasEnchantedItemEquipped(21) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) ) | |
766 return 0; | |
767 } | |
768 PlaySound((PlayerSpeech)27, 0); | |
769 break; | |
770 case Condition_Disease1: | 736 case Condition_Disease1: |
771 case Condition_Disease2: | 737 case Condition_Disease2: |
772 case Condition_Disease3: | 738 case Condition_Disease3: PlaySound(SPEECH_28, 0);break; |
773 if ( a3 == 1 ) | 739 case Condition_Paralyzed: break; //nosound |
774 { | |
775 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) | |
776 { | |
777 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
778 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
779 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
780 return 0; | |
781 } | |
782 if ( HasEnchantedItemEquipped(18) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) ) | |
783 return 0; | |
784 } | |
785 PlaySound((PlayerSpeech)28, 0); | |
786 break; | |
787 case Condition_Paralyzed: | |
788 if ( a3 == 1 ) | |
789 { | |
790 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) | |
791 { | |
792 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
793 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
794 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
795 return 0; | |
796 } | |
797 if ( HasEnchantedItemEquipped(20) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || WearsItem(ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY) || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) | |
798 return 0; | |
799 } | |
800 break; | |
801 case Condition_Unconcious: | 740 case Condition_Unconcious: |
802 PlaySound(SPEECH_32, 0); | 741 PlaySound(SPEECH_32, 0); |
803 if ( sHealth > 0 ) | 742 if ( sHealth > 0 ) |
804 sHealth = 0; | 743 sHealth = 0; |
805 break; | 744 break; |
806 case Condition_Dead: | 745 case Condition_Dead: |
807 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u ) | 746 PlaySound(SPEECH_33, 0); |
808 { | |
809 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
810 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
811 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
812 return 0; | |
813 } | |
814 PlaySound((PlayerSpeech)33, 0); | |
815 if ( sHealth > 0 ) | 747 if ( sHealth > 0 ) |
816 sHealth = 0; | 748 sHealth = 0; |
817 if ( sMana > 0 ) | 749 if ( sMana > 0 ) |
818 sMana = 0; | 750 sMana = 0; |
819 break; | 751 break; |
820 case Condition_Pertified: | 752 case Condition_Pertified: |
821 if ( a3 == 1 ) | |
822 { | |
823 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) | |
824 { | |
825 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
826 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
827 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
828 return 0; | |
829 } | |
830 if ( HasEnchantedItemEquipped(23) || WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) ) | |
831 return 0; | |
832 } | |
833 PlaySound((PlayerSpeech)34, 0); | 753 PlaySound((PlayerSpeech)34, 0); |
834 break; | 754 break; |
835 case Condition_Eradicated: | 755 case Condition_Eradicated: |
836 if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 ) &&( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u )) | |
837 { | |
838 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; | |
839 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) | |
840 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); | |
841 return 0; | |
842 } | |
843 PlaySound(SPEECH_35, 0); | 756 PlaySound(SPEECH_35, 0); |
844 if (sHealth > 0 ) | 757 if (sHealth > 0 ) |
845 sHealth = 0; | 758 sHealth = 0; |
846 if ( sMana > 0 ) | 759 if ( sMana > 0 ) |
847 sMana = 0; | 760 sMana = 0; |
848 break; | 761 break; |
849 case Condition_Zombie: | 762 case Condition_Zombie: |
850 if ( classType == PLAYER_CLASS_LICH || Eradicated() || Zombie() || !Dead()) | 763 if ( classType == PLAYER_CLASS_LICH || Eradicated() || Zombie() || !Dead()) |
851 return 0; | 764 return; |
852 memset(&pConditions[0], 0, sizeof(pConditions)); | 765 memset(&pConditions[0], 0, sizeof(pConditions)); |
853 sHealth = GetMaxHealth(); | 766 sHealth = GetMaxHealth(); |
854 sMana = 0; | 767 sMana = 0; |
855 player_sex = 0; | 768 player_sex = 0; |
856 uPrevFace = uCurrentFace; | 769 uPrevFace = uCurrentFace; |
863 else | 776 else |
864 { | 777 { |
865 uCurrentFace = 24; | 778 uCurrentFace = 24; |
866 uVoiceID = 24; | 779 uVoiceID = 24; |
867 } | 780 } |
868 PlaySound((PlayerSpeech)SPEECH_99, 0); | 781 PlaySound(SPEECH_99, 0); |
869 break; | 782 break; |
870 } | 783 } |
871 | 784 |
872 remainig_player = 0; | 785 remainig_player = 0; |
873 pConditions[uConditionIdx] = pParty->uTimePlayed; | 786 pConditions[uConditionIdx] = 1; |
874 players_after = 0; | 787 players_after = 0; |
875 for (int i = 1; i < 5; ++i) | 788 for (int i = 1; i < 5; ++i) |
876 { | 789 { |
877 if ( pPlayers[i]->CanAct() ) | 790 if ( pPlayers[i]->CanAct() ) |
878 { | 791 { |
882 } | 795 } |
883 if (( players_before == 2 ) && ( players_after == 1 )) | 796 if (( players_before == 2 ) && ( players_after == 1 )) |
884 { | 797 { |
885 pPlayers[remainig_player]->PlaySound(SPEECH_107, 0); | 798 pPlayers[remainig_player]->PlaySound(SPEECH_107, 0); |
886 } | 799 } |
887 return 1; | 800 return; |
888 } | 801 } |
889 | 802 |
890 //----- (00492528) -------------------------------------------------------- | 803 //----- (00492528) -------------------------------------------------------- |
891 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) | 804 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) |
892 { | 805 { |
9058 *v11 = v7 + 1; | 8971 *v11 = v7 + 1; |
9059 pMouse->RemoveHoldingItem(); | 8972 pMouse->RemoveHoldingItem(); |
9060 } | 8973 } |
9061 } | 8974 } |
9062 } | 8975 } |
8976 | |
8977 | |
9063 //----- (0049387A) -------------------------------------------------------- | 8978 //----- (0049387A) -------------------------------------------------------- |
9064 int CycleCharacter(unsigned int _this) | 8979 int CycleCharacter(unsigned int _this) |
9065 { | 8980 { |
9066 signed int result; // eax@1 | 8981 signed int result; // eax@1 |
9067 signed int v2; // ecx@2 | 8982 signed int v2; // ecx@2 |
9861 } | 9776 } |
9862 } | 9777 } |
9863 } | 9778 } |
9864 } | 9779 } |
9865 } | 9780 } |
9781 | |
9782 | |
9783 bool Player::Weak() | |
9784 { | |
9785 return pConditions[Condition_Weak] != 0; | |
9786 } | |
9787 | |
9788 bool Player::Dead() | |
9789 { | |
9790 return pConditions[Condition_Dead] != 0; | |
9791 } | |
9792 | |
9793 bool Player::Eradicated() | |
9794 { | |
9795 return pConditions[Condition_Eradicated] != 0; | |
9796 } | |
9797 | |
9798 bool Player::Zombie() | |
9799 { | |
9800 return pConditions[Condition_Zombie] != 0; | |
9801 } | |
9802 | |
9803 bool Player::Cursed() | |
9804 { | |
9805 return pConditions[Condition_Cursed] != 0; | |
9806 } | |
9807 | |
9808 bool Player::Pertified() | |
9809 { | |
9810 return pConditions[Condition_Pertified] != 0; | |
9811 } | |
9812 | |
9813 bool Player::Unconcious() | |
9814 { | |
9815 return pConditions[Condition_Unconcious] != 0; | |
9816 } | |
9817 | |
9818 void Player::SetCursed( bool state ) | |
9819 { | |
9820 pConditions[Condition_Cursed] = state; | |
9821 } | |
9822 | |
9823 void Player::SetWeak( bool state ) | |
9824 { | |
9825 pConditions[Condition_Weak] = state; | |
9826 } | |
9827 | |
9828 void Player::SetAsleep( bool state ) | |
9829 { | |
9830 pConditions[Condition_Sleep] = state; | |
9831 } | |
9832 | |
9833 void Player::SetAfraid( bool state ) | |
9834 { | |
9835 pConditions[Condition_Fear] = state; | |
9836 } | |
9837 | |
9838 void Player::SetDrunk( bool state ) | |
9839 { | |
9840 pConditions[Condition_Drunk] = state; | |
9841 } | |
9842 | |
9843 void Player::SetInsane( bool state ) | |
9844 { | |
9845 pConditions[Condition_Insane] = state; | |
9846 } | |
9847 | |
9848 void Player::SetPoison1( bool state ) | |
9849 { | |
9850 pConditions[Condition_Poison1] = state; | |
9851 } | |
9852 | |
9853 void Player::SetDisease1( bool state ) | |
9854 { | |
9855 pConditions[Condition_Disease1] = state; | |
9856 } | |
9857 | |
9858 void Player::SetPoison2( bool state ) | |
9859 { | |
9860 pConditions[Condition_Poison2] = state; | |
9861 } | |
9862 | |
9863 void Player::SetDisease2( bool state ) | |
9864 { | |
9865 pConditions[Condition_Disease2] = state; | |
9866 } | |
9867 | |
9868 void Player::SetPoison3( bool state ) | |
9869 { | |
9870 pConditions[Condition_Poison3] = state; | |
9871 } | |
9872 | |
9873 void Player::SetDisease3( bool state ) | |
9874 { | |
9875 pConditions[Condition_Disease3] = state; | |
9876 } | |
9877 | |
9878 void Player::SetParalyzed( bool state ) | |
9879 { | |
9880 pConditions[Condition_Paralyzed] = state; | |
9881 } | |
9882 | |
9883 void Player::SetUnconcious( bool state ) | |
9884 { | |
9885 pConditions[Condition_Unconcious] = state; | |
9886 } | |
9887 | |
9888 void Player::SetDead( bool state ) | |
9889 { | |
9890 pConditions[Condition_Dead] = state; | |
9891 } | |
9892 | |
9893 void Player::SetPertified( bool state ) | |
9894 { | |
9895 pConditions[Condition_Pertified] = state; | |
9896 } | |
9897 | |
9898 void Player::SetEradicated( bool state ) | |
9899 { | |
9900 pConditions[Condition_Eradicated] = state; | |
9901 } | |
9902 | |
9903 void Player::SetZombie( bool state ) | |
9904 { | |
9905 pConditions[Condition_Zombie] = state; | |
9906 } | |
9907 | |
9908 void Player::SetCondWeakWithBlockCheck( int blockable ) | |
9909 { | |
9910 SetCondition(Condition_Weak, blockable); | |
9911 } | |
9912 | |
9913 void Player::SetCondInsaneWithBlockCheck( int blockable ) | |
9914 { | |
9915 SetCondition(Condition_Insane, blockable); | |
9916 } | |
9917 | |
9918 void Player::SetCondDeadWithBlockCheck( int blockable ) | |
9919 { | |
9920 SetCondition(Condition_Dead, blockable); | |
9921 } |