comparison Player.cpp @ 1014:a704435d3285

comtinue player cleaning
author Gloval
date Sun, 19 May 2013 20:38:49 +0400
parents 9e823ad5eaa6
children 9ac94d00012e 32ec62bbaa2c
comparison
equal deleted inserted replaced
1012:9e823ad5eaa6 1014:a704435d3285
220 return false; 220 return false;
221 } 221 }
222 222
223 223
224 //----- (004BE2DD) -------------------------------------------------------- 224 //----- (004BE2DD) --------------------------------------------------------
225 void Player::SalesProcess(unsigned int a2, int a3, int _2devent_idx) 225 void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx )
226 { 226 {
227 Player *v4; // edi@1
228 char *v5; // esi@1
229 float v6; // ST04_4@1 227 float v6; // ST04_4@1
230 signed int v7; // eax@1 228 signed int item_value; // eax@1
231 signed int v8; // ebx@1 229 signed int sell_price; // ebx@1
232 230
233 auto a4 = _2devent_idx; 231 item_value =pOwnItems[item_index].GetValue();
234 v4 = this; 232 v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier;
235 v5 = (char *)this + 36 * a3; 233 sell_price = GetPriceSell(item_value, v6);
236 v6 = p2DEvents[a4 - 1].fPriceMultiplier; 234 if ( pOwnItems[item_index].Broken() )
237 //v6 = p2DEvents_minus1__20[13 * a4]; 235 sell_price = 1;
238 v7 = ((ItemGen *)(v5 + 532))->GetValue(); 236 if ( sell_price < 1 )
239 v8 = GetPriceSell(v7, v6); 237 sell_price = 1;
240 if ( v5[552] & 2 ) 238 RemoveItemAtInventoryIndex(inventory_idnx);
241 v8 = 1; 239 Party::SetGold(pParty->uNumGold + sell_price);
242 if ( v8 < 1 )
243 v8 = 1;
244 RemoveItemAtInventoryIndex(a2);
245 Party::SetGold(pParty->uNumGold + v8);
246 } 240 }
247 241
248 242
249 243
250 //----- (0043EEF3) -------------------------------------------------------- 244 //----- (0043EEF3) --------------------------------------------------------
251 bool Player::_43EEF3() 245 bool Player::_43EEF3()
252 { 246 {
253 signed int v1; // esi@1 247 signed int item_idx; // esi@1
254 PlayerEquipment *v2; // edx@1 248 signed int item_id; // esi@1
255 bool result; // eax@2 249 for (int i=0; i<16;++i)
256 250 {
257 v1 = 0; 251 item_idx=pEquipment.pIndices[i];
258 v2 = &this->pEquipment; 252 if (item_idx)
259 while ( 1 ) 253 {
260 { 254 item_id=pOwnItems[item_idx-1].uItemID;
261 result = v2->uShield; 255 if (item_id!=64 && item_id!= 65 ) //blaster& blaster rifle
262 if ( v2->uShield ) 256 return false;
263 { 257 }
264 result = *(int *)&this->pInventoryItems[result-1]; 258 }
265 if ( result ) 259 return true;
266 { 260 }
267 if ( result != 64 && result != 65 ) 261
268 break;
269 }
270 }
271 ++v1;
272 v2 = (PlayerEquipment *)((char *)v2 + 4);
273 if ( v1 >= 16 )
274 {
275 LOBYTE(result) = 1;
276 return result;
277 }
278 }
279 LOBYTE(result) = 0;
280 return result;
281 }
282 262
283 263
284 264
285 //----- (004B8040) -------------------------------------------------------- 265 //----- (004B8040) --------------------------------------------------------
286 int Player::_4B8040_condition_time(unsigned int uCondition) 266 int Player::_4B8040_condition_time(unsigned int uCondition)
456 signed int v2; // eax@1 436 signed int v2; // eax@1
457 char v3; // zf@4 437 char v3; // zf@4
458 438
459 v1 = this; 439 v1 = this;
460 v2 = (signed int)window_SpeakInHouse->ptr_1C; 440 v2 = (signed int)window_SpeakInHouse->ptr_1C;
461 if ( v2 == 78 || v2 > 80 && v2 <= 82 ) 441 if ( (v2 == 78 || v2 > 80) && v2 <= 82 )
462 { 442 {
463 if ( GetMajorConditionIdx() == 18 ) 443 if ( GetMajorConditionIdx() == 18 )
464 goto LABEL_6; 444 goto LABEL_6;
465 v3 = GetMajorConditionIdx() == 17; 445 v3 = GetMajorConditionIdx() == 17;
466 } 446 }
667 goto LABEL_12; 647 goto LABEL_12;
668 if ( v3 > 8 ) 648 if ( v3 > 8 )
669 { 649 {
670 if ( v3 > 11 ) 650 if ( v3 > 11 )
671 { 651 {
672 if ( v3 == CHARACTER_EXPRESSION_PERTIFIED || v3 > 97 && v3 <= 99 ) 652 if ( v3 == CHARACTER_EXPRESSION_PERTIFIED ||( v3 > 97 && v3 <= 99) )
673 return; 653 return;
674 goto LABEL_15; 654 goto LABEL_15;
675 } 655 }
676 LABEL_12: 656 LABEL_12:
677 if (new_expression != CHARACTER_EXPRESSION_34 && new_expression != CHARACTER_EXPRESSION_35 && new_expression != CHARACTER_EXPRESSION_36) 657 if (new_expression != CHARACTER_EXPRESSION_34 && new_expression != CHARACTER_EXPRESSION_35 && new_expression != CHARACTER_EXPRESSION_36)
1071 return 0; 1051 return 0;
1072 } 1052 }
1073 1053
1074 //----- (00492D65) -------------------------------------------------------- 1054 //----- (00492D65) --------------------------------------------------------
1075 int Player::SetCondition(unsigned int uConditionIdx, int a3) 1055 int Player::SetCondition(unsigned int uConditionIdx, int a3)
1076 { 1056 {
1077 Player *v3; // esi@1 1057
1078 Player **v4; // ebx@2 1058 signed int player_sex; // ecx@77
1079 Player *v5; // ecx@21 1059 char zombi_face; // al@80
1080 Player *v6; // ecx@22 1060 signed int remainig_player; // ebx@82
1081 Player *v7; // ecx@29 1061 int players_before; // [sp+10h] [bp-4h]@2
1082 Player *v8; // ecx@29 1062 int players_after; // [sp+20h] [bp+Ch]@82
1083 1063
1084 Player *v11; // ecx@45 1064 if ( pConditions[uConditionIdx] )
1085 Player *v12; // ecx@46 1065 return 0;
1086 char *v13; // eax@49 1066 players_before = 0;
1087 Player *v14; // ecx@58 1067 for (int i=1;i<5;++i)
1088 Player *v15; // ecx@59 1068 if ( pPlayers[i]->CanAct() )
1089 Player *v16; // ecx@60 1069 ++players_before;
1090 signed int result; // eax@76 1070
1091 signed int v18; // ecx@77
1092 int v19; // eax@77
1093 char v20; // al@80
1094 signed int v21; // ebx@82
1095 signed int v22; // esi@82
1096 int v23; // [sp-8h] [bp-1Ch]@7
1097 int v24; // [sp-8h] [bp-1Ch]@15
1098 int v25; // [sp-8h] [bp-1Ch]@53
1099 int v26; // [sp-4h] [bp-18h]@7
1100 signed int v27; // [sp-4h] [bp-18h]@15
1101 int v28; // [sp-4h] [bp-18h]@53
1102 char *v29; // [sp+Ch] [bp-8h]@1
1103 int v30; // [sp+10h] [bp-4h]@2
1104 int v31; // [sp+20h] [bp+Ch]@82
1105
1106 v3 = this;
1107 v29 = (char *)this + 8 * uConditionIdx;
1108 if ( *(_QWORD *)v29 )
1109 {
1110 LABEL_76:
1111 result = 0;
1112 }
1113 else
1114 {
1115 v4 = &pPlayers[1];
1116 v30 = 0;
1117 do
1118 {
1119 if ( (*v4)->CanAct() )
1120 ++v30;
1121 ++v4;
1122 }
1123 while ( (signed int)v4 <= (signed int)&pPlayers[4] );
1124 switch ( uConditionIdx ) 1071 switch ( uConditionIdx )
1125 { 1072 {
1126 case 0u: 1073 case Condition_Cursed:
1127 v26 = 0; 1074 PlaySound((PlayerSpeech)30, 0);
1128 v23 = 30; 1075 break;
1129 goto LABEL_81; 1076 case Condition_Weak:
1130 case 1u:
1131 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 ) 1077 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )
1132 goto LABEL_10; 1078 {--pParty->pPartyBuffs[13].uPower;
1133 v26 = 0; 1079 if ( pParty->pPartyBuffs[13].uPower < 1u )
1134 v23 = 25; 1080 pParty->pPartyBuffs[13].Reset();
1135 goto LABEL_81; 1081 return 0;
1136 case 2u: 1082 }
1137 if ( a3 != 1 ) 1083
1138 goto LABEL_82; 1084 PlaySound((PlayerSpeech)25, 0);
1139 if ( v3->HasEnchantedItemEquipped(22) ) 1085 break;
1140 goto LABEL_76; 1086 case Condition_Sleep:
1141 v27 = 3; 1087 if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||WearsItem(505, 3)))
1142 v24 = 505; 1088 return 0;
1143 goto LABEL_16; 1089 break;
1144 case 3u: 1090
1145 v26 = 0; 1091 case Condition_Fear:
1146 v23 = 26; 1092 PlaySound((PlayerSpeech)26, 0);
1147 goto LABEL_81; 1093 break;
1148 case 4u: 1094 case Condition_Drunk:
1149 v26 = 0; 1095 PlaySound((PlayerSpeech)31, 0);
1150 v23 = 31; 1096 break;
1151 goto LABEL_81; 1097
1152 case 5u: 1098 case Condition_Insane:
1153 if ( a3 == 1 1099 if ( a3 == 1
1154 && (v3->HasEnchantedItemEquipped(19) || v5->WearsItem(505, 3) || v6->WearsItem(530, 6)) ) 1100 && (HasEnchantedItemEquipped(19) || WearsItem(505, 3) || WearsItem(530, 6)) )
1155 goto LABEL_76; 1101 return 0;
1156 v26 = 0; 1102
1157 v23 = 29; 1103 PlaySound((PlayerSpeech)29, 0);
1158 goto LABEL_81; 1104 break;
1159 case 6u: 1105 case Condition_Poison1:
1160 case 8u: 1106 case Condition_Poison2:
1161 case 0xAu: 1107 case Condition_Poison3:
1162 if ( a3 == 1 ) 1108 if ( a3 == 1 )
1163 { 1109 {
1164 if ( (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 ) 1110 if ( (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 )
1165 { 1111 {
1112 --pParty->pPartyBuffs[13].uPower;
1113 if ( pParty->pPartyBuffs[13].uPower < 1u )
1114 pParty->pPartyBuffs[13].Reset();
1115 }
1116 if ( HasEnchantedItemEquipped(21)
1117 || WearsItem(505, 3)
1118 || WearsItem(530, 6) )
1119 //goto LABEL_76;
1120 return 0;
1121 }
1122
1123 //v23 = 27;
1124 PlaySound((PlayerSpeech)27, 0);
1125 break;
1126
1127 case Condition_Disease1:
1128 case Condition_Disease2:
1129 case Condition_Disease3:
1130 if ( a3 == 1 )
1131 {
1132 if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 )
1133 {
1134 --pParty->pPartyBuffs[13].uPower;
1135 if ( pParty->pPartyBuffs[13].uPower < 1u )
1136 pParty->pPartyBuffs[13].Reset();
1137 return 0;
1138 }
1139
1140 if ( HasEnchantedItemEquipped(18) ||WearsItem(505, 3) || WearsItem(530, 6) )
1141 return 0;
1142 }
1143 PlaySound((PlayerSpeech)28, 0);
1144 break;
1145 case Condition_Paralyzed:
1146 if ( a3 == 1 )
1147 {
1148 if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 )
1149 {
1150 --pParty->pPartyBuffs[13].uPower;
1151 if ( pParty->pPartyBuffs[13].uPower < 1u )
1152 pParty->pPartyBuffs[13].Reset();
1153 return 0;
1154 }
1155
1156 if ( HasEnchantedItemEquipped(20)|| WearsItem(505, 3)|| WearsItem(507, 16)||WearsItem(530, 6))
1157 return 0;
1158 }
1159 break;
1160 case Condition_Unconcious:
1161 PlaySound(SPEECH_32, 0);
1162 if ( sHealth > 0 )
1163 sHealth = 0;
1164 break;
1165 case Condition_Dead:
1166 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 && pParty->pPartyBuffs[13].uSkill >= 4u )
1167 {
1166 --pParty->pPartyBuffs[13].uPower; 1168 --pParty->pPartyBuffs[13].uPower;
1167 if ( pParty->pPartyBuffs[13].uPower < 1u ) 1169 if ( pParty->pPartyBuffs[13].uPower < 1u )
1168 pParty->pPartyBuffs[13].Reset(); 1170 pParty->pPartyBuffs[13].Reset();
1169 } 1171 }
1170 if ( v3->HasEnchantedItemEquipped(21) 1172
1171 || v7->WearsItem(505, 3) 1173 PlaySound((PlayerSpeech)33, 0);
1172 || v8->WearsItem(530, 6) ) 1174 if ( sHealth > 0 )
1173 goto LABEL_76; 1175 sHealth = 0;
1176 if ( sMana > 0 )
1177 sMana = 0;
1178 break;
1179 case Condition_Pertified:
1180 if ( a3 == 1
1181 &&((pParty->pPartyBuffs[13].uExpireTime > 0i64)
1182 || HasEnchantedItemEquipped(23)|| WearsItem(520, 16) || WearsItem(505, 3) || WearsItem(530, 6)) )
1183
1184 return 0;
1185 PlaySound((PlayerSpeech)34, 0);
1186 break;
1187 case Condition_Eradicated:
1188 if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )&&( pParty->pPartyBuffs[13].uSkill >= 4u ))
1189 {
1190 --pParty->pPartyBuffs[13].uPower;
1191 if ( pParty->pPartyBuffs[13].uPower < 1u )
1192 pParty->pPartyBuffs[13].Reset();
1193 return 0;
1194 }
1195 PlaySound(SPEECH_35, 0);
1196 if (sHealth > 0 )
1197 sHealth = 0;
1198 if ( sMana > 0 )
1199 sMana = 0;
1200 break;
1201 case Condition_Zombie:
1202 if ( classType == PLAYER_CLASS_LICH || Eradicated() ||Zombie() || !Dead())
1203 return 0;
1204 memset(&pConditions[0], 0, sizeof(pConditions));
1205 sHealth = GetMaxHealth();
1206 sMana = 0;
1207 player_sex = 0;
1208 uPrevFace = uCurrentFace;
1209 uPrevVoiceID = uVoiceID;
1210 switch ( uVoiceID )
1211 {
1212 case 0:
1213 case 1:
1214 case 2:
1215 case 3:
1216 case 8:
1217 case 9:
1218 case 12:
1219 case 13:
1220 case 16:
1221 case 17:
1222 case 20:
1223 case 23:
1224 player_sex = 0;
1225 break;
1226 case 4:
1227 case 5:
1228 case 6:
1229 case 7:
1230 case 10:
1231 case 11:
1232 case 14:
1233 case 15:
1234 case 18:
1235 case 19:
1236 case 21:
1237 case 24:
1238 player_sex = 1;
1239 break;
1240 default:
1241 break;
1242 }
1243
1244 zombi_face = (player_sex != 0) + 23;
1245 uCurrentFace = zombi_face;
1246 uVoiceID = zombi_face;
1247 PlaySound((PlayerSpeech)SPEECH_99, 0);
1248 break;
1174 } 1249 }
1175 v26 = 0; 1250
1176 v23 = 27; 1251 remainig_player = 0;
1177 goto LABEL_81; 1252 pConditions[uConditionIdx] = pParty->uTimePlayed;
1178 case 7u: 1253 players_after = 0;
1179 case 9u: 1254 for (int i=1;i<5;++i)
1180 case 0xBu:
1181 if ( a3 != 1 )
1182 goto LABEL_40;
1183 if ( SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
1184 && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0) )
1185 goto LABEL_10;
1186 if ( v3->HasEnchantedItemEquipped(18) || v3->WearsItem(505, 3) || v3->WearsItem(530, 6) )
1187 goto LABEL_76;
1188 LABEL_40:
1189 v26 = 0;
1190 v23 = 28;
1191 goto LABEL_81;
1192 case 0xCu:
1193 if ( a3 != 1 )
1194 goto LABEL_82;
1195 if ( SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
1196 && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0) )
1197 goto LABEL_10;
1198 if ( v3->HasEnchantedItemEquipped(20)
1199 || v11->WearsItem(505, 3)
1200 || v12->WearsItem(507, 16) )
1201 goto LABEL_76;
1202 v27 = 6;
1203 v24 = 530;
1204 LABEL_16:
1205 if ( v3->WearsItem(v24, v27) )
1206 goto LABEL_76;
1207 goto LABEL_82;
1208 case 0xDu:
1209 v3->PlaySound(SPEECH_32, 0);
1210 v13 = (char *)&v3->sHealth;
1211 goto LABEL_70;
1212 case 0xEu:
1213 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 && pParty->pPartyBuffs[13].uSkill >= 4u )
1214 goto LABEL_10;
1215 v28 = 0;
1216 v25 = 33;
1217 goto LABEL_67;
1218 case 0xFu:
1219 if ( a3 == 1
1220 && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
1221 && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0)
1222 || v3->HasEnchantedItemEquipped(23)
1223 || v14->WearsItem(520, 16)
1224 || v15->WearsItem(505, 3)
1225 || v16->WearsItem(530, 6)) )
1226 goto LABEL_76;
1227 v26 = 0;
1228 v23 = 34;
1229 goto LABEL_81;
1230 case 0x10u:
1231 if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 && pParty->pPartyBuffs[13].uSkill >= 4u )
1232 { 1255 {
1233 LABEL_10: 1256
1234 --pParty->pPartyBuffs[13].uPower; 1257
1235 if ( pParty->pPartyBuffs[13].uPower < 1u ) 1258 if ( pPlayers[i]->CanAct() )
1236 pParty->pPartyBuffs[13].Reset(); 1259 {
1237 goto LABEL_76; 1260 remainig_player=i;
1261 ++players_after;
1262 }
1238 } 1263 }
1239 v28 = 0; 1264 if (( players_before == 2 )&&( players_after == 1 ))
1240 v25 = SPEECH_35;
1241 LABEL_67:
1242 v3->PlaySound((PlayerSpeech)v25, v28);
1243 if ( v3->sHealth > 0 )
1244 v3->sHealth = 0;
1245 v13 = (char *)&v3->sMana;
1246 LABEL_70:
1247 if ( *(int *)v13 > 0 )
1248 *(int *)v13 = 0;
1249 LABEL_82:
1250 v21 = 0;
1251 *(_QWORD *)v29 = pParty->uTimePlayed;
1252 v31 = 0;
1253 v22 = 1;
1254 do
1255 { 1265 {
1256 if ( pPlayers[v22]->CanAct() ) 1266 pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);
1257 {
1258 ++v31;
1259 v21 = v22;
1260 }
1261 ++v22;
1262 } 1267 }
1263 while ( v22 <= 4 ); 1268 return 1;
1264 if ( v30 == 2 ) 1269 }
1265 {
1266 if ( v31 == 1 )
1267 pPlayers[v21]->PlaySound(SPEECH_107, 0);
1268 }
1269 result = 1;
1270 break;
1271 case 0x11u:
1272 if ( v3->classType == PLAYER_CLASS_LICH || v3->Eradicated() ||
1273 v3->Zombie() || !v3->Dead())
1274 goto LABEL_76;
1275 memset(v3, 0, 0xA0u);
1276 v3->sHealth = v3->GetMaxHealth();
1277 v18 = 0;
1278 v3->field_1928 = v3->uFace;
1279 v19 = v3->uVoiceID;
1280 v3->sMana = 0;
1281 v3->field_1924 = v19;
1282 switch ( v19 )
1283 {
1284 case 0:
1285 case 1:
1286 case 2:
1287 case 3:
1288 case 8:
1289 case 9:
1290 case 12:
1291 case 13:
1292 case 16:
1293 case 17:
1294 case 20:
1295 case 23:
1296 v18 = 0;
1297 break;
1298 case 4:
1299 case 5:
1300 case 6:
1301 case 7:
1302 case 10:
1303 case 11:
1304 case 14:
1305 case 15:
1306 case 18:
1307 case 19:
1308 case 21:
1309 case 24:
1310 v18 = 1;
1311 break;
1312 default:
1313 break;
1314 }
1315 v26 = 0;
1316 v20 = (v18 != 0) + 23;
1317 v23 = SPEECH_99;
1318 v3->uFace = v20;
1319 v3->uVoiceID = v20;
1320 LABEL_81:
1321 v3->PlaySound((PlayerSpeech)v23, v26);
1322 goto LABEL_82;
1323 default:
1324 goto LABEL_82;
1325 }
1326 }
1327 return result;
1328 }
1329 1270
1330 //----- (00492528) -------------------------------------------------------- 1271 //----- (00492528) --------------------------------------------------------
1331 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) 1272 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
1332 { 1273 {
1333 //unsigned int v3; // eax@1 1274 //unsigned int v3; // eax@1
1504 } 1445 }
1505 return 0; 1446 return 0;
1506 } 1447 }
1507 1448
1508 //----- (004927A8) -------------------------------------------------------- 1449 //----- (004927A8) --------------------------------------------------------
1509 int Player::AddItem(unsigned int uSlot, unsigned int uItemID) 1450 int Player::AddItem(int uSlot, unsigned int uItemID)
1510 { 1451 {
1511 signed int v3; // ebx@2 1452 signed int v3; // ebx@2
1512 signed int v4; // edi@3 1453 signed int v4; // edi@3
1513 unsigned int v5; // esi@3 1454 unsigned int v5; // esi@3
1514 unsigned int v7; // [sp-8h] [bp-18h]@8 1455 unsigned int v7; // [sp-8h] [bp-18h]@8
1517 1458
1518 thisa = this; 1459 thisa = this;
1519 if ( uSlot == -1 ) 1460 if ( uSlot == -1 )
1520 { 1461 {
1521 v3 = 0; 1462 v3 = 0;
1522 while ( 2 ) 1463 while ( true )
1523 { 1464 {
1524 v4 = 0; 1465 v4 = 0;
1525 v5 = v3; 1466 v5 = v3;
1526 do 1467 do
1527 { 1468 {
1551 v7 = uSlot; 1492 v7 = uSlot;
1552 return CreateItemInInventory(v7, v8); 1493 return CreateItemInInventory(v7, v8);
1553 } 1494 }
1554 1495
1555 //----- (00492826) -------------------------------------------------------- 1496 //----- (00492826) --------------------------------------------------------
1556 int Player::AddItem2(unsigned int uSlot, ItemGen *Src) 1497 int Player::AddItem2(int uSlot, ItemGen *Src)
1557 { 1498 {
1558 unsigned int v3; // ebx@1 1499 unsigned int v3; // ebx@1
1559 unsigned int v4; // esi@3 1500 unsigned int v4; // esi@3
1560 signed int v5; // edi@3 1501 signed int v5; // edi@3
1561 unsigned int v7; // [sp-8h] [bp-18h]@9 1502 unsigned int v7; // [sp-8h] [bp-18h]@9
1567 v3 = Src->uItemID; 1508 v3 = Src->uItemID;
1568 pItemsTable->SetSpecialBonus(Src); 1509 pItemsTable->SetSpecialBonus(Src);
1569 if ( uSlot == -1 ) 1510 if ( uSlot == -1 )
1570 { 1511 {
1571 uSlota = 0; 1512 uSlota = 0;
1572 while ( 2 ) 1513 while ( true )
1573 { 1514 {
1574 v4 = uSlota; 1515 v4 = uSlota;
1575 v5 = 0; 1516 v5 = 0;
1576 do 1517 do
1577 { 1518 {
1604 { 1545 {
1605 signed int v3; // ebx@1 1546 signed int v3; // ebx@1
1606 ItemGen *v4; // eax@1 1547 ItemGen *v4; // eax@1
1607 int result; // eax@6 1548 int result; // eax@6
1608 //unsigned int v6; // eax@7 1549 //unsigned int v6; // eax@7
1609 Texture *v7; // esi@7 1550 Texture *item_texture; // esi@7
1610 unsigned int v8; // edx@9 1551 unsigned int v8; // edx@9
1611 void *v9; // esi@10 1552 int *pInvPos; // esi@10
1612 unsigned int v10; // [sp+4h] [bp-Ch]@7 1553 unsigned int slot_width; // [sp+4h] [bp-Ch]@7
1613 unsigned int v11; // [sp+8h] [bp-8h]@7 1554 unsigned int slot_height; // [sp+8h] [bp-8h]@7
1614 Player *v12; // [sp+Ch] [bp-4h]@1 1555 Player *v12; // [sp+Ch] [bp-4h]@1
1615 unsigned int uSlota; // [sp+18h] [bp+8h]@10 1556
1616 1557
1617 v12 = this; 1558 v12 = this;
1618 v3 = 0; 1559 v3 = 0;
1619 v4 = this->pInventoryItems; 1560 v4 = this->pInventoryItems;
1620 while ( v4->uItemID ) 1561 while ( v4->uItemID )
1631 { 1572 {
1632 result = 0; 1573 result = 0;
1633 } 1574 }
1634 else 1575 else
1635 { 1576 {
1636 v7 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1577 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1637 v10 = GetSizeInInventorySlots(v7->uTextureWidth); 1578 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
1638 v11 = GetSizeInInventorySlots(v7->uTextureHeight); 1579 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
1639 if ( !areWeLoadingTexture ) 1580 if ( !areWeLoadingTexture )
1640 { 1581 {
1641 v7->Release(); 1582 item_texture->Release();
1642 pIcons_LOD->SyncLoadedFilesCount(); 1583 pIcons_LOD->SyncLoadedFilesCount();
1643 } 1584 }
1644 v8 = uSlot; 1585 if ( slot_height > 0 )
1645 if ( (signed int)v11 > 0 ) 1586 {
1646 { 1587 pInvPos = &pInventoryIndices[uSlot];
1647 uSlota = v11;
1648 v9 = &v12->pInventoryIndices[v8];
1649 do 1588 do
1650 { 1589 {
1651 if ( (signed int)v10 > 0 ) 1590 if ( slot_width > 0 )
1652 memset32(v9, -1 - v8, v10); 1591 memset32(pInvPos, -1 - uSlot, slot_width);
1653 v9 = (char *)v9 + 56; 1592 pInvPos +=14;
1654 --uSlota; 1593 --slot_height;
1655 } 1594 }
1656 while ( uSlota ); 1595 while ( slot_height );
1657 } 1596 }
1658 v12->pInventoryIndices[v8] = v3 + 1; 1597 pInventoryIndices[uSlot] = v3 + 1;
1659 memcpy(&v12->pInventoryItems[v3], Src, 0x24u); 1598 memcpy(&pInventoryItems[v3], Src, sizeof(ItemGen));
1660 result = v3 + 1; 1599 result = v3 + 1;
1661 } 1600 }
1662 return result; 1601 return result;
1663 } 1602 }
1664 // 506128: using guessed type int areWeLoadingTexture; 1603 // 506128: using guessed type int areWeLoadingTexture;
1665 1604
1666 //----- (0049298B) -------------------------------------------------------- 1605 //----- (0049298B) --------------------------------------------------------
1667 bool Player::_49298B(ItemGen *a2, int a3, int a4) 1606 int Player::PutItemArInventoryIndex( ItemGen *item, int item_id, int uSlot )
1668 { 1607 {
1669 //Player *v4; // ebx@1 1608 //Player *v4; // ebx@1
1670 //unsigned int v5; // eax@1 1609 //unsigned int v5; // eax@1
1671 Texture *v6; // esi@1 1610 Texture *item_texture; // esi@1
1672 void *v7; // esi@4 1611 int *pInvPos; // esi@4
1673 unsigned int v9; // [sp+Ch] [bp-4h]@1 1612 unsigned int slot_width; // [sp+Ch] [bp-4h]@1
1674 unsigned int a2a; // [sp+18h] [bp+8h]@1 1613 unsigned int slot_height; // [sp+18h] [bp+8h]@1
1675 1614
1676 v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[a2->uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1615 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1677 v9 = GetSizeInInventorySlots(v6->uTextureWidth); 1616 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
1678 a2a = GetSizeInInventorySlots(v6->uTextureHeight); 1617 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
1679 if ( !areWeLoadingTexture ) 1618 if ( !areWeLoadingTexture )
1680 { 1619 {
1681 v6->Release(); 1620 item_texture->Release();
1682 pIcons_LOD->SyncLoadedFilesCount(); 1621 pIcons_LOD->SyncLoadedFilesCount();
1683 } 1622 }
1684 if ( (signed int)a2a > 0 ) 1623 if ( (signed int)slot_height > 0 )
1685 { 1624 {
1686 v7 = &pInventoryIndices[a4]; 1625 pInvPos = &pInventoryIndices[uSlot]; //14x9
1687 do 1626 do
1688 { 1627 {
1689 if ( (signed int)v9 > 0 ) 1628 if ( (signed int)slot_width > 0 )
1690 memset32(v7, -1 - a4, v9); 1629 memset32(pInvPos, -1 - uSlot, slot_width);
1691 v7 = (char *)v7 + 56; 1630 pInvPos +=14;
1692 --a2a; 1631 --slot_height;
1693 } 1632 }
1694 while ( a2a ); 1633 while ( slot_height );
1695 } 1634 }
1696 pInventoryIndices[a4] = a3 + 1; 1635 pInventoryIndices[uSlot] = item_id + 1;
1697 return 1; 1636 return 1;
1698 } 1637 }
1699 1638
1700 // 506128: using guessed type int areWeLoadingTexture; 1639 // 506128: using guessed type int areWeLoadingTexture;
1701 1640
1702 //----- (00492A36) -------------------------------------------------------- 1641 //----- (00492A36) --------------------------------------------------------
1703 void Player::RemoveItemAtInventoryIndex( unsigned int uSlot ) 1642 void Player::RemoveItemAtInventoryIndex( unsigned int uSlot )
1704 { 1643 {
1705 int *pIndices; // edi@1 1644
1706 ItemGen *v3; // ecx@1 1645 ItemGen *item_in_slot; // ecx@1
1707 unsigned int v4; // esi@1 1646 Texture *item_texture; // esi@1
1708 //unsigned int v5; // eax@1 1647 unsigned int slot_height; // ebp@1
1709 Texture *v6; // esi@1 1648 int *pInvPos; // edx@4
1710 unsigned int result; // eax@1 1649 unsigned int slot_width; // [sp+14h] [bp+4h]@1
1711 unsigned int v8; // ebp@1 1650
1712 void *v9; // edx@4 1651 item_in_slot = &this->pInventoryItems[pInventoryIndices[uSlot]-1];
1713 unsigned int uSlota; // [sp+14h] [bp+4h]@1 1652 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item_in_slot->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1714 1653 item_in_slot->Reset();
1715 pIndices = &this->pInventoryIndices[uSlot]; 1654 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
1716 v3 = &this->pInventoryItems[*pIndices-1]; 1655 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
1717 v4 = v3->uItemID;
1718 v3->Reset();
1719 v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE);
1720 uSlota = GetSizeInInventorySlots(v6->uTextureWidth);
1721 result = GetSizeInInventorySlots(v6->uTextureHeight);
1722 v8 = result;
1723 if ( !areWeLoadingTexture ) 1656 if ( !areWeLoadingTexture )
1724 { 1657 {
1725 v6->Release(); 1658 item_texture->Release();
1726 pIcons_LOD->SyncLoadedFilesCount(); 1659 pIcons_LOD->SyncLoadedFilesCount();
1727 } 1660 }
1728 if ( (signed int)v8 > 0 ) 1661 if ( slot_height > 0 )
1729 { 1662 {
1730 v9 = pIndices; 1663 pInvPos = &pInventoryIndices[uSlot];
1731 do 1664 do
1732 { 1665 {
1733 if ( (signed int)uSlota > 0 ) 1666 if (slot_width > 0 )
1734 { 1667 memset32(pInvPos, 0, slot_width);
1735 result = 0; 1668 pInvPos += 14;
1736 memset(v9, 0, 4 * uSlota); 1669 --slot_height;
1737 } 1670 }
1738 v9 = (char *)v9 + 56; 1671 while ( slot_height );
1739 --v8;
1740 }
1741 while ( v8 );
1742 } 1672 }
1743 1673
1744 } 1674 }
1745 // 506128: using guessed type int areWeLoadingTexture; 1675 // 506128: using guessed type int areWeLoadingTexture;
1746 1676
2034 unsigned __int16 v2; // ax@1 1964 unsigned __int16 v2; // ax@1
2035 unsigned __int16 v3; // bx@1 1965 unsigned __int16 v3; // bx@1
2036 int v4; // eax@3 1966 int v4; // eax@3
2037 int v5; // edi@7 1967 int v5; // edi@7
2038 signed int v6; // ebp@7 1968 signed int v6; // ebp@7
2039 char v8; // al@10
2040 signed int v10; // [sp-4h] [bp-14h]@2 1969 signed int v10; // [sp-4h] [bp-14h]@2
2041 1970
2042 1971
2043 auto v7 = &pItemsTable->pItems[a2->uItemID]; 1972 auto v7 = &pItemsTable->pItems[a2->uItemID];
2044 if (CheckHiredNPCSpeciality(Smith) && v7->uEquipType <= 2 || 1973 if (CheckHiredNPCSpeciality(Smith) && v7->uEquipType <= 2 ||
2242 pPlayerBuffs[i].uCaster = 0; 2171 pPlayerBuffs[i].uCaster = 0;
2243 pPlayerBuffs[i].uFlags = 0; 2172 pPlayerBuffs[i].uFlags = 0;
2244 } 2173 }
2245 2174
2246 pName[0] = 0; 2175 pName[0] = 0;
2247 uFace = 0; 2176 uCurrentFace = 0;
2248 uVoiceID = 0; 2177 uVoiceID = 0;
2249 memset(pConditions, 0, 20 * sizeof(__int64)); 2178 memset(pConditions, 0, 20 * sizeof(__int64));
2250 2179
2251 field_BB = 0; 2180 field_BB = 0;
2252 2181
2379 v8 = 0; 2308 v8 = 0;
2380 while ( 1 ) 2309 while ( 1 )
2381 { 2310 {
2382 v9 = &v20->pPlayers[v15[v8]]; 2311 v9 = &v20->pPlayers[v15[v8]];
2383 v19 = &v20->pPlayers[v15[v8]]; 2312 v19 = &v20->pPlayers[v15[v8]];
2384 v10 = v19->AddItem(0xFFFFFFFFu, pItem->uItemID); 2313 v10 = v19->AddItem(-1, pItem->uItemID);
2385 if ( v10 ) 2314 if ( v10 )
2386 break; 2315 break;
2387 ++v8; 2316 ++v8;
2388 if ( v8 >= 4 ) 2317 if ( v8 >= 4 )
2389 { 2318 {
4445 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) 4374 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2)
4446 { 4375 {
4447 signed int v2; // edi@1 4376 signed int v2; // edi@1
4448 Player *v3; // esi@1 4377 Player *v3; // esi@1
4449 enum CHARACTER_RACE v4; // ebx@1 4378 enum CHARACTER_RACE v4; // ebx@1
4450 Player *v5; // ecx@8
4451 char v6; // zf@18 4379 char v6; // zf@18
4452 int v7; // ebx@28 4380 int v7; // ebx@28
4453 int result; // eax@28 4381 int result; // eax@28
4454 signed int v9; // [sp+10h] [bp-8h]@1 4382 signed int v9; // [sp+10h] [bp-8h]@1
4455 signed int v10; // [sp+14h] [bp-4h]@1 4383 signed int v10; // [sp+14h] [bp-4h]@1
6293 // 22 underwater suits (unused) 6221 // 22 underwater suits (unused)
6294 // 23 zombie male 6222 // 23 zombie male
6295 // 24 zombie female 6223 // 24 zombie female
6296 enum CHARACTER_RACE Player::GetRace() 6224 enum CHARACTER_RACE Player::GetRace()
6297 { 6225 {
6298 if ( uFace > 15 ) 6226 if ( uCurrentFace > 15 )
6299 { 6227 {
6300 if ( uFace >= 16 && uFace <= 19 ) 6228 if ( uCurrentFace >= 16 && uCurrentFace <= 19 )
6301 return CHARACTER_RACE_GOBLIN; 6229 return CHARACTER_RACE_GOBLIN;
6302 } 6230 }
6303 else 6231 else
6304 { 6232 {
6305 if ( uFace >= 12 ) 6233 if ( uCurrentFace >= 12 )
6306 { 6234 {
6307 return CHARACTER_RACE_DWARF; 6235 return CHARACTER_RACE_DWARF;
6308 } 6236 }
6309 else 6237 else
6310 { 6238 {
6311 if ( uFace >= 0 ) 6239
6312 { 6240 if ( uCurrentFace <= 7 )
6313 if ( uFace <= 7 )
6314 { 6241 {
6315 return CHARACTER_RACE_HUMAN; 6242 return CHARACTER_RACE_HUMAN;
6316 } 6243 }
6317 else 6244 else
6318 { 6245 {
6319 if ( uFace <= 11 ) 6246 if ( uCurrentFace <= 11 )
6320 return CHARACTER_RACE_ELF; 6247 return CHARACTER_RACE_ELF;
6321 } 6248 }
6322 }
6323 } 6249 }
6324 } 6250 }
6325 return CHARACTER_RACE_HUMAN; 6251 return CHARACTER_RACE_HUMAN;
6326 } 6252 }
6327 6253
6861 int attribute_value; // edx@1 6787 int attribute_value; // edx@1
6862 unsigned __int8 pBaseAttrValue; // of@1 6788 unsigned __int8 pBaseAttrValue; // of@1
6863 __int16 uGreen; // [sp+8h] [bp-8h]@1 6789 __int16 uGreen; // [sp+8h] [bp-8h]@1
6864 __int16 uRed; // [sp+Ch] [bp-4h]@1 6790 __int16 uRed; // [sp+Ch] [bp-4h]@1
6865 6791
6866 uRed = TargetColor(0xFFu, 0x23u, 0); 6792 uRed = TargetColor(255, 35, 0);
6867 uGreen = TargetColor(0, 0xFFu, 0); 6793 uGreen = TargetColor(0, 255, 0);
6868 uWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); 6794 uWhite = TargetColor(255, 255, 255);
6869 pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue; 6795 pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue;
6870 6796
6871 switch (uStat) 6797 switch (uStat)
6872 { 6798 {
6873 case 0: attribute_value = uMight; break; 6799 case 0: attribute_value = uMight; break;
6888 } 6814 }
6889 6815
6890 //----- (004908A8) -------------------------------------------------------- 6816 //----- (004908A8) --------------------------------------------------------
6891 bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime) 6817 bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime)
6892 { 6818 {
6893 unsigned __int64 *result; // eax@1 6819 if ( pConditions[uCondition] && (uTime < pConditions[uCondition]) )
6894 6820 {
6895 result = (unsigned __int64 *)((char *)this + 8 * uCondition); 6821 pConditions[uCondition]=0i64;
6896 if ( *result && (signed __int64)uTime < (signed __int64)*result ) 6822 return true;
6897 {
6898 *(int *)result = 0;
6899 *((int *)result + 1) = 0;
6900 LOBYTE(result) = 1;
6901 } 6823 }
6902 else 6824 else
6903 { 6825 return false;
6904 LOBYTE(result) = 0;
6905 }
6906 return (bool)result;
6907 } 6826 }
6908 6827
6909 //----- (004680ED) -------------------------------------------------------- 6828 //----- (004680ED) --------------------------------------------------------
6910 void Player::UseItem_DrinkPotion_etc(signed int a2, int a3) 6829 void Player::UseItem_DrinkPotion_etc(signed int a2, int a3)
6911 { 6830 {
8598 if ( v4->sResEarthBase < 20 ) 8517 if ( v4->sResEarthBase < 20 )
8599 v4->sResEarthBase = 20; 8518 v4->sResEarthBase = 20;
8600 v4->sResMindBase = 200; 8519 v4->sResMindBase = 200;
8601 v4->sResBodyBase = 200; 8520 v4->sResBodyBase = 200;
8602 v11 = v4->GetSexByVoice(); 8521 v11 = v4->GetSexByVoice();
8603 v4->field_1924 = v4->uVoiceID; 8522 v4->uPrevVoiceID = v4->uVoiceID;
8604 v4->field_1928 = v4->uFace; 8523 v4->uPrevFace = v4->uCurrentFace;
8605 if ( v11 ) 8524 if ( v11 )
8606 { 8525 {
8607 v4->uFace = 21; 8526 v4->uCurrentFace = 21;
8608 v4->uVoiceID = 21; 8527 v4->uVoiceID = 21;
8609 } 8528 }
8610 else 8529 else
8611 { 8530 {
8612 v4->uFace = 20; 8531 v4->uCurrentFace = 20;
8613 v4->uVoiceID = 20; 8532 v4->uVoiceID = 20;
8614 } 8533 }
8615 ReloadPlayerPortraits(currPlayerId, v4->uFace); 8534 ReloadPlayerPortraits(currPlayerId, v4->uCurrentFace);
8616 goto LABEL_124; 8535 goto LABEL_124;
8617 } 8536 }
8618 LABEL_64: 8537 LABEL_64:
8619 this->uMightBonus = (unsigned __int8)var_value; 8538 this->uMightBonus = (unsigned __int8)var_value;
8620 LABEL_111: 8539 LABEL_111: