Mercurial > mm7
comparison mm7_2.cpp @ 2376:bcd7fadbf7d2
Слияние
author | Ritor1 |
---|---|
date | Mon, 12 May 2014 12:28:06 +0600 |
parents | bddcaf5d5db2 |
children | b4a79e3ef2f0 |
comparison
equal
deleted
inserted
replaced
2375:14c05b876218 | 2376:bcd7fadbf7d2 |
---|---|
576 { | 576 { |
577 if ( pMessageQueue_50CBD0->uNumMessages ) | 577 if ( pMessageQueue_50CBD0->uNumMessages ) |
578 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | 578 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; |
579 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED); | 579 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED); |
580 pKeyActionMap->ResetKeys(); | 580 pKeyActionMap->ResetKeys(); |
581 activeLevelDecoration = NULL; | 581 activeLevelDecoration = nullptr; |
582 current_npc_text = 0; | 582 current_npc_text = 0; |
583 if ( pDialogueNPCCount == 0) | 583 if ( pDialogueNPCCount == 0) |
584 return 0; | 584 return 0; |
585 | 585 |
586 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL && ShopTexture ) | 586 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL && ShopTexture ) |
957 } | 957 } |
958 //while(v231 < dstHeight); | 958 //while(v231 < dstHeight); |
959 return result; | 959 return result; |
960 } | 960 } |
961 | 961 |
962 //----- (0044F57C) -------------------------------------------------------- | |
963 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) | |
964 { | |
965 //MapInfo *v5; // esi@1 | |
966 //SpawnPointMM7 *v6; // ebx@1 | |
967 int v7; // eax@2 | |
968 char v8; // zf@5 | |
969 // int v9; // edi@9 | |
970 // int v10; // eax@9 | |
971 // int v11; // ecx@9 | |
972 int v12; // edx@9 | |
973 // int v13; // eax@9 | |
974 // int v14; // eax@14 | |
975 // int v15; // ecx@14 | |
976 // int v16; // eax@19 | |
977 // int v17; // ecx@19 | |
978 int v18; // esi@31 | |
979 //int pPosX; // ecx@32 | |
980 //int v20; // edx@32 | |
981 //int v21; // eax@32 | |
982 Actor *pMonster; // esi@35 | |
983 int v23; // edx@36 | |
984 signed int v24; // edi@36 | |
985 int v25; // ecx@36 | |
986 // unsigned __int16 v26; // ax@47 | |
987 MonsterDesc *v27; // edi@48 | |
988 signed int v28; // eax@48 | |
989 // __int16 v29; // cx@50 | |
990 // __int16 v30; // ax@50 | |
991 // __int16 v31; // ax@50 | |
992 int v32; // eax@50 | |
993 // int v33; // edi@50 | |
994 // int v34; // eax@50 | |
995 // int v35; // eax@50 | |
996 // int v36; // eax@50 | |
997 int v37; // eax@51 | |
998 int v38; // eax@52 | |
999 int v39; // edi@52 | |
1000 std::string v40; // [sp-18h] [bp-100h]@60 | |
1001 // void *v41; // [sp-14h] [bp-FCh]@50 | |
1002 //void *v42; // [sp-10h] [bp-F8h]@50 | |
1003 //size_t v43; // [sp-Ch] [bp-F4h]@50 | |
1004 const char *v44; // [sp-8h] [bp-F0h]@13 | |
1005 char *pTexture; // [sp-4h] [bp-ECh]@9 | |
1006 char Str[32]; // [sp+Ch] [bp-DCh]@60 | |
1007 char Str2[120]; // [sp+2Ch] [bp-BCh]@29 | |
1008 unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 | |
1009 MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 | |
1010 int v50; // [sp+ACh] [bp-3Ch]@47 | |
1011 char Source[32]; // [sp+B0h] [bp-38h]@20 | |
1012 int v52; // [sp+D0h] [bp-18h]@34 | |
1013 int v53; // [sp+D4h] [bp-14h]@34 | |
1014 int pSector; // [sp+D8h] [bp-10h]@32 | |
1015 int pPosX; // [sp+DCh] [bp-Ch]@32 | |
1016 int v56; // [sp+E0h] [bp-8h]@8 | |
1017 int v57; // [sp+E4h] [bp-4h]@1 | |
1018 | |
1019 //auto a2 = spawn; | |
1020 v57 = 0; | |
1021 //v5 = pMapInfo; | |
1022 //v6 = spawn; | |
1023 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1024 v7 = pOutdoor->ddm.field_C_alert; | |
1025 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1026 v7 = pIndoor->dlv.field_C_alert; | |
1027 else | |
1028 v7 = 0; | |
1029 if (v7) | |
1030 v8 = (spawn->uAttributes & 1) == 0; | |
1031 else | |
1032 v8 = (spawn->uAttributes & 1) == 1; | |
1033 if (v8) | |
1034 return; | |
1035 //result = (void *)(spawn->uIndex - 1); | |
1036 v56 = 1; | |
1037 switch (spawn->uIndex - 1) | |
1038 { | |
1039 case 0: | |
1040 //v9 = pMapInfo->uEncounterMonster1AtLeast; | |
1041 //v10 = rand(); | |
1042 //v11 = pMapInfo->uEncounterMonster1AtMost; | |
1043 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
1044 v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1); | |
1045 //v13 = pMapInfo->Dif_M1; | |
1046 v57 = pMapInfo->Dif_M1; | |
1047 v56 = pMapInfo->uEncounterMonster1AtLeast + v12; | |
1048 strcpy(Source, pMapInfo->pEncounterMonster1Texture); | |
1049 break; | |
1050 case 3: | |
1051 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
1052 //v44 = "%s A"; | |
1053 sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture); | |
1054 break; | |
1055 case 4: | |
1056 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
1057 //v44 = "%s A"; | |
1058 sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture); | |
1059 break; | |
1060 case 5: | |
1061 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
1062 //v44 = "%s A"; | |
1063 sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture); | |
1064 break; | |
1065 case 1: | |
1066 //v9 = pMapInfo->uEncounterMonster2AtLeast; | |
1067 //v14 = rand(); | |
1068 //v15 = pMapInfo->uEncounterMonster2AtMost; | |
1069 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
1070 v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1); | |
1071 //v13 = pMapInfo->Dif_M2; | |
1072 v57 = pMapInfo->Dif_M2; | |
1073 v56 = pMapInfo->uEncounterMonster2AtLeast + v12; | |
1074 strcpy(Source, pMapInfo->pEncounterMonster2Texture); | |
1075 break; | |
1076 case 6: | |
1077 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
1078 //v44 = "%s B"; | |
1079 sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture); | |
1080 break; | |
1081 case 7: | |
1082 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
1083 //v44 = "%s B"; | |
1084 sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture); | |
1085 break; | |
1086 case 8: | |
1087 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
1088 //v44 = "%s B"; | |
1089 sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture); | |
1090 break; | |
1091 case 2: | |
1092 //v9 = pMapInfo->uEncounterMonster3AtLeast; | |
1093 //v16 = rand(); | |
1094 //v17 = pMapInfo->uEncounterMonster3AtMost; | |
1095 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
1096 v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1); | |
1097 //v13 = pMapInfo->Dif_M3; | |
1098 v57 = pMapInfo->Dif_M3; | |
1099 v56 = pMapInfo->uEncounterMonster3AtLeast + v12; | |
1100 strcpy(Source, pMapInfo->pEncounterMonster3Texture); | |
1101 break; | |
1102 case 9: | |
1103 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
1104 //v44 = "%s C"; | |
1105 sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture); | |
1106 break; | |
1107 case 10: | |
1108 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
1109 //v44 = "%s C"; | |
1110 sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture); | |
1111 break; | |
1112 case 11: | |
1113 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
1114 //v44 = "%s C"; | |
1115 sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture); | |
1116 break; | |
1117 default: | |
1118 return; | |
1119 } | |
1120 if (Source[0] == '0') | |
1121 return; | |
1122 v57 += a3; | |
1123 if ( v57 > 4 ) | |
1124 v57 = 4; | |
1125 strcpy(Str2, Source); | |
1126 if ( a4 ) | |
1127 v56 = a4; | |
1128 v18 = v56; | |
1129 if ( (signed int)(v56 + uNumActors) >= 500 ) | |
1130 return; | |
1131 pSector = 0; | |
1132 pPosX = spawn->vPosition.x; | |
1133 a4 = spawn->vPosition.y; | |
1134 a3 = spawn->vPosition.z; | |
1135 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1136 pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); | |
1137 v53 = 0; | |
1138 v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
1139 if ( v18 <= 0 ) | |
1140 return; | |
1141 for (uint i = v53; i < v56; ++i) | |
1142 { | |
1143 pMonster = &pActors[uNumActors]; | |
1144 pActors[uNumActors].Reset(); | |
1145 if ( v57 ) | |
1146 { | |
1147 v23 = rand() % 100; | |
1148 v24 = 3; | |
1149 v25 = (unsigned __int16)word_4E8152[3 * v57]; | |
1150 if ( v23 >= v25 ) | |
1151 { | |
1152 if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) | |
1153 v24 = 2; | |
1154 } | |
1155 else | |
1156 { | |
1157 v24 = 1; | |
1158 } | |
1159 if ( v24 == 1 ) | |
1160 { | |
1161 pTexture = Source; | |
1162 v44 = "%s A"; | |
1163 } | |
1164 else | |
1165 { | |
1166 if ( v24 == 2 ) | |
1167 { | |
1168 pTexture = Source; | |
1169 v44 = "%s B"; | |
1170 } | |
1171 else | |
1172 { | |
1173 if ( v24 != 3 ) | |
1174 continue; | |
1175 pTexture = Source; | |
1176 v44 = "%s C"; | |
1177 } | |
1178 } | |
1179 sprintf(Str2, v44, pTexture); | |
1180 } | |
1181 v50 = pMonsterList->GetMonsterIDByName(Str2); | |
1182 pTexture = Str2; | |
1183 if ( (signed __int16)v50 == -1 ) | |
1184 { | |
1185 sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); | |
1186 MessageBoxA(nullptr, Str, nullptr, 0); | |
1187 ExitProcess(0); | |
1188 } | |
1189 v27 = &pMonsterList->pMonsters[(signed __int16)v50]; | |
1190 v28 = pMonsterStats->FindMonsterByTextureName(pTexture); | |
1191 if ( !v28 ) | |
1192 v28 = 1; | |
1193 Src = &pMonsterStats->pInfos[v28]; | |
1194 strcpy(pMonster->pActorName, Src->pName); | |
1195 pMonster->sCurrentHP = Src->uHP; | |
1196 assert(sizeof(MonsterInfo) == 88); | |
1197 memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo)); | |
1198 pMonster->word_000086_some_monster_id = v50 + 1; | |
1199 pMonster->uActorRadius = v27->uMonsterRadius; | |
1200 pMonster->uActorHeight = v27->uMonsterHeight; | |
1201 pMonster->uMovementSpeed = v27->uMovementSpeed; | |
1202 pMonster->vInitialPosition.x = spawn->vPosition.x; | |
1203 pMonster->vPosition.x = spawn->vPosition.x; | |
1204 pMonster->uTetherDistance = 256; | |
1205 pMonster->vInitialPosition.y = a4; | |
1206 pMonster->vPosition.y = a4; | |
1207 pMonster->vInitialPosition.z = a3; | |
1208 pMonster->vPosition.z = a3; | |
1209 pMonster->uSectorID = pSector; | |
1210 pMonster->uGroup = spawn->uGroup; | |
1211 pMonster->PrepareSprites(0); | |
1212 pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
1213 v32 = rand(); | |
1214 a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52); | |
1215 pPosX = a3 + spawn->vPosition.x; | |
1216 a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52); | |
1217 a4 = a3 + spawn->vPosition.y; | |
1218 a3 = spawn->vPosition.z; | |
1219 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1220 { | |
1221 if ( a5 ) | |
1222 pMonster->uAttributes |= 0x080000; | |
1223 ++uNumActors; | |
1224 continue; | |
1225 } | |
1226 v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z); | |
1227 if ( v37 == pSector ) | |
1228 { | |
1229 v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); | |
1230 v39 = v38; | |
1231 if ( v38 != -30000 ) | |
1232 { | |
1233 if ( abs(v38 - a3) <= 1024 ) | |
1234 { | |
1235 a3 = v39; | |
1236 if ( a5 ) | |
1237 pMonster->uAttributes |= 0x080000; | |
1238 ++uNumActors; | |
1239 continue; | |
1240 } | |
1241 } | |
1242 } | |
1243 ; | |
1244 //v53 = (char *)v53 + 1; | |
1245 //result = v53; | |
1246 } | |
1247 //while ( (signed int)v53 < v56 ); | |
1248 } | |
1249 | |
1250 //----- (0044FA4C) -------------------------------------------------------- | |
1251 signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) | |
1252 { | |
1253 signed int v3; // ecx@6 | |
1254 Actor *v4; // edx@7 | |
1255 signed int result; // eax@13 | |
1256 Actor *v6; // esi@16 | |
1257 char *v7; // ebx@16 | |
1258 MonsterDesc *v8; // edi@16 | |
1259 unsigned __int16 v9; // ax@16 | |
1260 int v10; // ebx@16 | |
1261 //int v11; // edi@16 | |
1262 //int v12; // eax@16 | |
1263 //int v13; // ecx@16 | |
1264 //int v14; // ebx@16 | |
1265 const char *v15; // [sp-4h] [bp-24h]@2 | |
1266 //unsigned __int16 v16; // [sp+0h] [bp-20h]@1 | |
1267 //int v17; // [sp+4h] [bp-1Ch]@1 | |
1268 unsigned int uFaceID; // [sp+8h] [bp-18h]@16 | |
1269 int v19; // [sp+Ch] [bp-14h]@16 | |
1270 size_t v20; // [sp+10h] [bp-10h]@6 | |
1271 int v21; // [sp+14h] [bp-Ch]@14 | |
1272 //int v22; // [sp+18h] [bp-8h]@14 | |
1273 unsigned int v23; // [sp+1Ch] [bp-4h]@6 | |
1274 | |
1275 //v16 = a2; | |
1276 //v17 = a1; | |
1277 if ( a2 == 4 ) | |
1278 { | |
1279 v15 = "Elemental Light C"; | |
1280 } | |
1281 else if ( a2 == 3 ) | |
1282 v15 = "Elemental Light B"; | |
1283 else | |
1284 v15 = "Elemental Light A"; | |
1285 | |
1286 v23 = pMonsterList->GetMonsterIDByName(v15); | |
1287 v3 = 0; | |
1288 v20 = uNumActors; | |
1289 if ( (signed int)uNumActors > 0 ) | |
1290 { | |
1291 v4 = pActors.data();//[0].uAIState; | |
1292 while ( v4->uAIState != Removed ) | |
1293 { | |
1294 ++v3; | |
1295 ++v4; | |
1296 if ( v3 >= (signed int)uNumActors ) | |
1297 break; | |
1298 } | |
1299 if( v3 < (signed int)uNumActors ) | |
1300 v20 = v3; | |
1301 } | |
1302 if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) ) | |
1303 { | |
1304 v21 = 0; | |
1305 //v22 = pParty->vPosition.z; | |
1306 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1307 v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1308 v6 = &pActors[v20]; | |
1309 v7 = (char *)&pMonsterStats->pInfos[v23 + 1]; | |
1310 v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
1311 v6->Reset(); | |
1312 v8 = &pMonsterList->pMonsters[v23]; | |
1313 strcpy(v6->pActorName, *(const char **)v7); | |
1314 v6->sCurrentHP = *((short *)v7 + 32); | |
1315 memcpy(&v6->pMonsterInfo, v7, 0x58u); | |
1316 v6->word_000086_some_monster_id = v23 + 1; | |
1317 v6->uActorRadius = v8->uMonsterRadius; | |
1318 v6->uActorHeight = v8->uMonsterHeight; | |
1319 v9 = v8->uMovementSpeed; | |
1320 v6->pMonsterInfo.uTreasureDiceRolls = 0; | |
1321 v6->pMonsterInfo.uTreasureType = 0; | |
1322 v6->pMonsterInfo.uExp = 0; | |
1323 v6->uMovementSpeed = v9; | |
1324 v10 = rand() % 2048; | |
1325 //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); | |
1326 uFaceID = stru_5C6E00->Sin(v10); | |
1327 //v12 = pParty->vPosition.y; | |
1328 //v13 = fixpoint_mul(uFaceID, v19); | |
1329 //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); | |
1330 //LOWORD(v12) = v22; | |
1331 v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); | |
1332 v6->vPosition.x = v6->vInitialPosition.x; | |
1333 v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); | |
1334 v6->vPosition.y = v6->vInitialPosition.y; | |
1335 v6->vInitialPosition.z = pParty->vPosition.z; | |
1336 v6->vPosition.z = v6->vInitialPosition.z; | |
1337 //LOWORD(v12) = v21; | |
1338 v6->uTetherDistance = 256; | |
1339 v6->uSectorID = v21; | |
1340 v6->PrepareSprites(0); | |
1341 v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
1342 v6->uAlly = 9999; | |
1343 v6->uGroup = 0; | |
1344 v6->uCurrentActionTime = 0; | |
1345 v6->uAIState = Summoned; | |
1346 v6->uCurrentActionLength = 256; | |
1347 v6->UpdateAnimation(); | |
1348 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor | |
1349 || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z), | |
1350 result == v21) | |
1351 && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000) | |
1352 && (result = abs(result - pParty->vPosition.z), result <= 1024) ) | |
1353 { | |
1354 if ( v20 == uNumActors ) | |
1355 ++uNumActors; | |
1356 v6->uSummonerID = PID(OBJECT_Player, a1); | |
1357 result = v6->pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, | |
1358 a2, | |
1359 a1, | |
1360 0, | |
1361 0); | |
1362 } | |
1363 } | |
1364 return result; | |
1365 } | |
1366 | |
1367 //----- (00450521) -------------------------------------------------------- | |
1368 int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6) | |
1369 { | |
1370 int v6; // edi@1 | |
1371 int v7; // esi@1 | |
1372 signed int v8; // edi@1 | |
1373 unsigned __int16 v9; // cx@1 | |
1374 // char *v10; // edx@2 | |
1375 unsigned __int16 v11; // ax@5 | |
1376 SpriteObject a1; // [sp+8h] [bp-70h]@1 | |
1377 | |
1378 v6 = ecx0; | |
1379 v7 = a2; | |
1380 pItemsTable->GenerateItem(v6, v7, &a1.stru_24); | |
1381 v8 = 0; | |
1382 v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; | |
1383 a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; | |
1384 v11 = 0; | |
1385 for( int i = 0; i < pObjectList->uNumObjects; i++ ) | |
1386 { | |
1387 if( v9 == pObjectList->pObjects[i].uObjectID ) | |
1388 { | |
1389 v11 = i; | |
1390 break; | |
1391 } | |
1392 } | |
1393 a1.uObjectDescID = v11; | |
1394 a1.vPosition.y = a4; | |
1395 a1.vPosition.x = a3; | |
1396 a1.vPosition.z = a5; | |
1397 a1.uFacing = a6; | |
1398 a1.uAttributes = 0; | |
1399 a1.uSectorID = pIndoor->GetSector(a3, a4, a5); | |
1400 a1.uSpriteFrameID = 0; | |
1401 return a1.Create(0, 0, 0, 0); | |
1402 } | |
1403 | |
1404 //----- (0045063B) -------------------------------------------------------- | |
1405 int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) | |
1406 { | |
1407 int result; // eax@8 | |
1408 int v6; // edi@11 | |
1409 int v7; // ebx@11 | |
1410 int v8; // edi@11 | |
1411 int v9; // ebx@12 | |
1412 int v10; // eax@12 | |
1413 char v11; // zf@16 | |
1414 int v12; // edi@20 | |
1415 int v13; // eax@20 | |
1416 int v14; // ebx@20 | |
1417 int v15; // eax@20 | |
1418 int v16; // eax@20 | |
1419 int v17; // eax@20 | |
1420 int v18; // eax@21 | |
1421 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 | |
1422 int v22; // [sp+2Ch] [bp-18h]@3 | |
1423 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 | |
1424 int v26; // [sp+3Ch] [bp-8h]@11 | |
1425 int v27; // [sp+40h] [bp-4h]@11 | |
1426 | |
1427 if (!uNumActors) | |
1428 return 0; | |
1429 | |
1430 for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) | |
1431 { | |
1432 if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C | |
1433 (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C | |
1434 (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C | |
1435 pActors[mon_id].CanAct()) | |
1436 { | |
1437 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1438 { | |
1439 v22 = 0; | |
1440 uint face_id = 0; | |
1441 for ( face_id; face_id < 100; ++face_id ) | |
1442 { | |
1443 v6 = rand() % 1024 + 512; | |
1444 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1445 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); | |
1446 v8 = 0; | |
1447 v19.uIndex = a2; | |
1448 v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; | |
1449 v19.vPosition.z = pParty->vPosition.z; | |
1450 v26 = 0; | |
1451 v27 = 0; | |
1452 v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); | |
1453 for( int i = 0; i < pOutdoor->uNumBModels; i++ ) | |
1454 { | |
1455 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); | |
1456 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); | |
1457 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) | |
1458 { | |
1459 v22 = 1; | |
1460 break; | |
1461 } | |
1462 } | |
1463 if ( v22 ) | |
1464 { | |
1465 v11 = face_id == 100; | |
1466 break; | |
1467 } | |
1468 } | |
1469 v11 = face_id == 100; | |
1470 } | |
1471 else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1472 { | |
1473 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1474 for ( uint i = 0; i < 100; ++i ) | |
1475 { | |
1476 v12 = rand() % 512 + 256; | |
1477 v13 = rand(); | |
1478 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1479 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1480 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); | |
1481 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1482 v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; | |
1483 v19.vPosition.z = pParty->vPosition.z; | |
1484 v19.uIndex = a2; | |
1485 v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); | |
1486 if ( v17 == v22 ) | |
1487 { | |
1488 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); | |
1489 v19.vPosition.z = v18; | |
1490 if ( v18 != -30000 ) | |
1491 { | |
1492 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1493 break; | |
1494 } | |
1495 } | |
1496 } | |
1497 v11 = v26 == 100; | |
1498 } | |
1499 if ( v11 ) | |
1500 result = 0; | |
1501 else | |
1502 { | |
1503 SpawnEncounter(a1, &v19, 0, 0, 1); | |
1504 result = a2; | |
1505 } | |
1506 } | |
1507 | |
1508 //break; | |
1509 //v22 = v3->pMonsterInfo.uID - 1; | |
1510 //v4 = (signed __int64)((double)v22 * 0.3333333333333333); | |
1511 //if ( (int)v4 != 40 ) | |
1512 //{ | |
1513 // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) | |
1514 // break; | |
1515 //} | |
1516 //++v2; | |
1517 //++v3; | |
1518 //if ( v2 >= (signed int)uNumActors ) | |
1519 // goto LABEL_8; | |
1520 } | |
1521 return result; | |
1522 } | |
1523 | |
1524 //----- (00450AAA) -------------------------------------------------------- | |
1525 void RespawnGlobalDecorations() | |
1526 { | |
1527 memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125); | |
1528 | |
1529 uint decorEventIdx = 0; | |
1530 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1531 { | |
1532 LevelDecoration* decor = &pLevelDecorations[i]; | |
1533 | |
1534 if (!decor->uEventID) | |
1535 { | |
1536 if (decor->IsInteractive()) | |
1537 { | |
1538 if (decorEventIdx < 124) | |
1539 { | |
1540 decor->_idx_in_stru123 = decorEventIdx + 75; | |
1541 stru_5E4C90_MapPersistVars._decor_events[decorEventIdx++] = decor->GetGlobalEvent(); | |
1542 } | |
1543 } | |
1544 } | |
1545 } | |
1546 } | |
1547 | |
1548 //----- (00450B0A) -------------------------------------------------------- | |
1549 bool __fastcall SpawnActor(unsigned int uMonsterID) | |
1550 { | |
1551 unsigned int v1; // ebx@1 | |
1552 bool result; // eax@2 | |
1553 MonsterDesc *v3; // esi@5 | |
1554 MonsterInfo *v4; // edi@5 | |
1555 Vec3_int_ v5; // ST08_12@5 | |
1556 unsigned int v6; // ecx@5 | |
1557 Actor *v7; // eax@7 | |
1558 Actor actor; // [sp+4h] [bp-350h]@5 | |
1559 Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 | |
1560 | |
1561 v1 = uMonsterID; | |
1562 if ( uNumActors == 499 ) | |
1563 { | |
1564 result = 0; | |
1565 } | |
1566 else | |
1567 { | |
1568 if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) | |
1569 v1 = 0; | |
1570 v3 = &pMonsterList->pMonsters[v1]; | |
1571 v4 = &pMonsterStats->pInfos[v1 + 1]; | |
1572 memset(&actor, 0, 0x344u); | |
1573 strcpy(actor.pActorName, v4->pName); | |
1574 actor.sCurrentHP = LOWORD(v4->uHP); | |
1575 memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u); | |
1576 actor.word_000086_some_monster_id = v1 + 1; | |
1577 actor.uActorRadius = v3->uMonsterRadius; | |
1578 actor.uActorHeight = v3->uMonsterHeight; | |
1579 actor.uMovementSpeed = v3->uMovementSpeed; | |
1580 v5 = pParty->vPosition; | |
1581 Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y); | |
1582 actor.vInitialPosition.x = pOut.x; | |
1583 actor.vPosition.x = pOut.x; | |
1584 actor.uTetherDistance = 256; | |
1585 actor.vInitialPosition.y = LOWORD(pOut.z); | |
1586 actor.vPosition.y = LOWORD(pOut.z); | |
1587 actor.vInitialPosition.z = LOWORD(pOut.y); | |
1588 actor.vPosition.z = LOWORD(pOut.y); | |
1589 pSprites_LOD->DeleteSomeSprites(); | |
1590 pPaletteManager->ResetNonTestLocked(); | |
1591 v6 = uNumActors - 1; | |
1592 if ( dword_5C6DF8 == 1 ) | |
1593 { | |
1594 dword_5C6DF8 = 0; | |
1595 v6 = uNumActors++; | |
1596 } | |
1597 v7 = &pActors[v6]; | |
1598 memcpy(v7, &actor, 0x344u); | |
1599 v7->PrepareSprites(1); | |
1600 result = 1; | |
1601 } | |
1602 return result; | |
1603 } | |
1604 // 5C6DF8: using guessed type int dword_5C6DF8; | |
1605 | |
1606 //----- (00450DA3) -------------------------------------------------------- | |
1607 int GetAlertStatus() | |
1608 { | |
1609 int result; // eax@2 | |
1610 | |
1611 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1612 result = pOutdoor->ddm.field_C_alert; | |
1613 else | |
1614 result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0; | |
1615 return result; | |
1616 } | |
1617 | 962 |
1618 //----- (00450DDE) -------------------------------------------------------- | 963 //----- (00450DDE) -------------------------------------------------------- |
1619 stru350 *stru350::_450DDE() | 964 stru350 *stru350::_450DDE() |
1620 { | 965 { |
1621 _450DF1(&stru_4E82A4, &stru_4E82A4); | 966 _450DF1(&stru_4E82A4, &stru_4E82A4); |
1892 unsigned int temp_str_len; | 1237 unsigned int temp_str_len; |
1893 char* tmp_pos; | 1238 char* tmp_pos; |
1894 int decode_step; | 1239 int decode_step; |
1895 // int item_counter; | 1240 // int item_counter; |
1896 | 1241 |
1897 if ( pHostileTXT_Raw ) | 1242 free(pHostileTXT_Raw); |
1898 free(pHostileTXT_Raw); | |
1899 pHostileTXT_Raw = NULL; | |
1900 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); | 1243 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); |
1901 strtok(pHostileTXT_Raw, "\r"); | 1244 strtok(pHostileTXT_Raw, "\r"); |
1902 for ( i=0; i < 89; ++i ) | 1245 for ( i=0; i < 89; ++i ) |
1903 { | 1246 { |
1904 test_string = strtok(NULL, "\r") + 1; | 1247 test_string = strtok(NULL, "\r") + 1; |
1927 ++decode_step; | 1270 ++decode_step; |
1928 test_string=tmp_pos+1; | 1271 test_string=tmp_pos+1; |
1929 } | 1272 } |
1930 while ((decode_step < 92) && !break_loop ); | 1273 while ((decode_step < 92) && !break_loop ); |
1931 } | 1274 } |
1932 if ( pHostileTXT_Raw) | 1275 free(pHostileTXT_Raw); |
1933 { | 1276 pHostileTXT_Raw = nullptr; |
1934 free(pHostileTXT_Raw); | |
1935 pHostileTXT_Raw = NULL; | |
1936 } | |
1937 } | 1277 } |
1938 | 1278 |
1939 | 1279 |
1940 | 1280 |
1941 //----- (004610AA) -------------------------------------------------------- | 1281 //----- (004610AA) -------------------------------------------------------- |