Mercurial > mm7
comparison Player.cpp @ 1374:2e5c994f0833
Player::AddItem, Player::WearItem cleanup
author | Grumpy7 |
---|---|
date | Mon, 15 Jul 2013 23:59:04 +0200 |
parents | 8f339c3bbdaf |
children | 132a6a0d5cef |
comparison
equal
deleted
inserted
replaced
1366:8f339c3bbdaf | 1374:2e5c994f0833 |
---|---|
82 {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, | 82 {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, |
83 {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0} // some of these are started at 4ED94C, but needs to be here | 83 {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0} // some of these are started at 4ED94C, but needs to be here |
84 }; | 84 }; |
85 | 85 |
86 | 86 |
87 unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398 | |
88 { | |
89 1, // EQUIP_OFF_HAND | |
90 1, // EQUIP_MAIN_HAND | |
91 2, // EQUIP_BOW | |
92 3, // EQUIP_ARMOUR | |
93 0, // EQUIP_SHIELD | |
94 4, // EQUIP_HELMET | |
95 5, // EQUIP_BELT | |
96 6, // EQUIP_CLOAK | |
97 7, // EQUIP_GAUNTLETS | |
98 8, // EQUIP_BOOTS | |
99 10, // EQUIP_RING | |
100 9, // EQUIP_AMULET | |
101 1, // EQUIP_WAND | |
102 0, // EQUIP_REAGENT | |
103 0, // EQUIP_POTION | |
104 0, // EQUIP_SPELL_SCROLL | |
105 0, // EQUIP_BOOK | |
106 0, // EQUIP_MESSAGE_SCROLL | |
107 0, // EQUIP_GOLD | |
108 0, // EQUIP_GEM | |
109 0 // EQUIP_NONE | |
110 }; | |
87 | 111 |
88 | 112 |
89 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; | 113 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; |
90 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0}; | 114 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0}; |
91 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; | 115 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; |
115 | 139 |
116 short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175, | 140 short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175, |
117 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, | 141 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, |
118 19, 17, 15, 13, 11, 9, 7, 5, 3, 0}; | 142 19, 17, 15, 13, 11, 9, 7, 5, 3, 0}; |
119 signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; | 143 signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; |
120 | |
121 | |
122 unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0}; | |
123 | 144 |
124 | 145 |
125 unsigned short base_recovery_times_per_weapon_type[12] = | 146 unsigned short base_recovery_times_per_weapon_type[12] = |
126 { | 147 { |
127 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill | 148 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill |
902 //----- (00492700) -------------------------------------------------------- | 923 //----- (00492700) -------------------------------------------------------- |
903 int Player::HasSkill(unsigned int uSkillType) | 924 int Player::HasSkill(unsigned int uSkillType) |
904 { | 925 { |
905 signed int result; // eax@3 | 926 signed int result; // eax@3 |
906 | 927 |
907 if ( (signed int)uSkillType >= 37 || this->pActiveSkills[uSkillType] ) | 928 if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] ) |
908 { | 929 { |
909 result = 1; | 930 return 1; |
910 } | 931 } |
911 else | 932 else |
912 { | 933 { |
913 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); | 934 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); |
914 ShowStatusBarString(pTmpBuf.data(), 2u); | 935 ShowStatusBarString(pTmpBuf.data(), 2u); |
915 result = 0; | 936 return 0; |
916 } | 937 } |
917 return result; | |
918 } | 938 } |
919 | 939 |
920 //----- (00492745) -------------------------------------------------------- | 940 //----- (00492745) -------------------------------------------------------- |
921 int Player::WearItem(unsigned int uItemID) | 941 int Player::WearItem(unsigned int uItemID) |
922 { | 942 { |
923 int item_body_anch; // edi@6 | 943 int item_body_anch; // edi@6 |
924 int item_indx; | 944 int item_indx; |
925 //find empty slot | 945 item_indx = FindFreeInventorySlot(); |
926 for(item_indx=0;item_indx<126;++item_indx) | |
927 if (pInventoryItems[item_indx].uItemID==0) | |
928 break; | |
929 if (item_indx==126) //not found | |
930 item_indx=-1; | |
931 | 946 |
932 if ( item_indx != -1 ) | 947 if ( item_indx != -1 ) |
933 { | 948 { |
934 | 949 pInventoryItems[item_indx].uItemID = uItemID; |
935 pInventoryItems[item_indx].uItemID=uItemID; | 950 item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; |
936 item_body_anch=pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; | 951 pEquipment.pIndices[item_body_anch] = item_indx + 1; |
937 pEquipment.pIndices[item_body_anch]=item_indx+1; | 952 pInventoryItems[item_indx].uBodyAnchor = item_body_anch + 1; |
938 pInventoryItems[item_indx].uBodyAnchor=item_body_anch+1; | |
939 | |
940 } | 953 } |
941 return 0; | 954 return 0; |
942 } | 955 } |
943 | 956 |
944 //----- (004927A8) -------------------------------------------------------- | 957 //----- (004927A8) -------------------------------------------------------- |
945 int Player::AddItem(int uSlot, unsigned int uItemID) | 958 int Player::AddItem(int uSlot, unsigned int uItemID) |
946 { | 959 { |
947 signed int v3; // ebx@2 | 960 int xStartValue = 0; |
948 signed int v4; // edi@3 | 961 |
949 unsigned int v5; // esi@3 | |
950 unsigned int v7; // [sp-8h] [bp-18h]@8 | |
951 unsigned int v8; // [sp-4h] [bp-14h]@8 | |
952 Player *thisa; // [sp+Ch] [bp-4h]@1 | |
953 | |
954 thisa = this; | |
955 if ( uSlot == -1 ) | 962 if ( uSlot == -1 ) |
956 { | 963 { |
957 v3 = 0; | 964 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) |
958 while ( true ) | 965 { |
959 { | 966 for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) |
960 v4 = 0; | 967 { |
961 v5 = v3; | 968 if ( CanFitItem(xcoord, uItemID) ) |
962 do | |
963 { | |
964 if ( CanFitItem(v5, uItemID) ) | |
965 { | 969 { |
966 v8 = uItemID; | 970 return CreateItemInInventory(xcoord, uItemID); |
967 v7 = v5; | |
968 return CreateItemInInventory(v7, v8); | |
969 } | 971 } |
970 ++v4; | 972 } |
971 v5 += 14; | 973 xStartValue += INVETORYSLOTSWIDTH; |
972 } | |
973 while ( v4 < 9 ); | |
974 ++v3; | |
975 if ( v3 < 14 ) | |
976 continue; | |
977 break; | |
978 } | 974 } |
979 return 0; | 975 return 0; |
980 } | 976 } |
981 if ( !CanFitItem(uSlot, uItemID) ) | 977 if ( !CanFitItem(uSlot, uItemID) ) |
982 { | 978 { |
983 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | 979 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); |
984 return 0; | 980 return 0; |
985 } | 981 } |
986 v8 = uItemID; | 982 return CreateItemInInventory(uSlot, uItemID); |
987 v7 = uSlot; | |
988 return CreateItemInInventory(v7, v8); | |
989 } | 983 } |
990 | 984 |
991 //----- (00492826) -------------------------------------------------------- | 985 //----- (00492826) -------------------------------------------------------- |
992 int Player::AddItem2(int uSlot, ItemGen *Src) | 986 int Player::AddItem2(int uSlot, ItemGen *Src) |
993 { | 987 { |
8871 ItemGen _this; // [sp+Ch] [bp-30h]@1 | 8865 ItemGen _this; // [sp+Ch] [bp-30h]@1 |
8872 //Player *v9; // [sp+30h] [bp-Ch]@1 | 8866 //Player *v9; // [sp+30h] [bp-Ch]@1 |
8873 int v10; // [sp+34h] [bp-8h]@1 | 8867 int v10; // [sp+34h] [bp-8h]@1 |
8874 int *v11; // [sp+38h] [bp-4h]@1 | 8868 int *v11; // [sp+38h] [bp-4h]@1 |
8875 | 8869 |
8876 static unsigned char byte_4E8398[200] = // 4E8398 | |
8877 { | |
8878 1, // EQUIP_OFF_HAND | |
8879 1, // EQUIP_MAIN_HAND | |
8880 2, // EQUIP_BOW | |
8881 3, // EQUIP_ARMOUR | |
8882 0, // EQUIP_SHIELD | |
8883 4, // EQUIP_HELMET | |
8884 5, // EQUIP_BELT | |
8885 6, // EQUIP_CLOAK | |
8886 7, // EQUIP_GAUNTLETS | |
8887 8, // EQUIP_BOOTS | |
8888 10, // EQUIP_RING | |
8889 9, // EQUIP_AMULET | |
8890 1, // EQUIP_WAND | |
8891 0, // EQUIP_REAGENT | |
8892 0, // EQUIP_POTION | |
8893 0, // EQUIP_SPELL_SCROLL | |
8894 0, // EQUIP_BOOK | |
8895 0, // EQUIP_MESSAGE_SCROLL | |
8896 0, // EQUIP_GOLD | |
8897 0, // EQUIP_GEM | |
8898 0, // EQUIP_NONE | |
8899 // ??? | |
8900 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, | |
8901 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, | |
8902 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, | |
8903 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
8904 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, | |
8905 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, | |
8906 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
8907 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 | |
8908 }; | |
8909 | 8870 |
8910 _this.Reset(); | 8871 _this.Reset(); |
8911 v2 = byte_4E8398[uEquipType]; | 8872 v2 = pEquipTypeToBodyAnchor[uEquipType]; |
8912 v3 = pPlayers[uActiveCharacter]; | 8873 v3 = pPlayers[uActiveCharacter]; |
8913 v11 = (int *)&v3->pEquipment.pIndices[v2]; | 8874 v11 = (int *)&v3->pEquipment.pIndices[v2]; |
8914 v4 = *v11; | 8875 v4 = *v11; |
8915 v10 = *v11; | 8876 v10 = *v11; |
8916 if ( v10 ) | 8877 if ( v10 ) |