Mercurial > mm7
comparison Events.cpp @ 2464:104fdbea0386
cleaning project part 2
author | zipi |
---|---|
date | Sun, 17 Aug 2014 17:49:34 +0100 |
parents | 0f17a30149ec |
children | b054ea5daf45 |
comparison
equal
deleted
inserted
replaced
2463:0f17a30149ec | 2464:104fdbea0386 |
---|---|
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <crtdbg.h> | 3 #include <crtdbg.h> |
4 | 4 |
5 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include "mm7_unsorted_subs.h" | 7 |
8 #include "ErrorHandling.h" | 8 #include "ErrorHandling.h" |
9 | 9 |
10 #include "Weather.h" | 10 #include "Weather.h" |
11 #include "Texture.h" | 11 #include "Texture.h" |
12 #include "mm7_data.h" | 12 #include "mm7_data.h" |
1265 } | 1265 } |
1266 | 1266 |
1267 return result; | 1267 return result; |
1268 } | 1268 } |
1269 | 1269 |
1270 //----- (004613C4) -------------------------------------------------------- | |
1271 void init_event_triggers() | |
1272 { | |
1273 uint id = pDecorationList->GetDecorIdByName("Event Trigger"); | |
1274 | |
1275 num_event_triggers = 0; | |
1276 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1277 if (pLevelDecorations[i].uDecorationDescID == id) | |
1278 event_triggers[num_event_triggers++] = i; | |
1279 } | |
1280 | |
1281 //----- (0046CC4B) -------------------------------------------------------- | |
1282 void check_event_triggers() | |
1283 { | |
1284 for (size_t i = 0; i < num_event_triggers; i++) | |
1285 { | |
1286 if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH | |
1287 && pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pParty->vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) | |
1288 { | |
1289 EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, PID(OBJECT_Decoration, i), 1); | |
1290 } | |
1291 else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) | |
1292 { | |
1293 for (size_t j = 0; j < uNumActors; j++) | |
1294 { | |
1295 if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pActors[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) | |
1296 EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); | |
1297 } | |
1298 } | |
1299 else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) | |
1300 { | |
1301 for (size_t j = 0; j < uNumSpriteObjects; j++) | |
1302 { | |
1303 if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) | |
1304 EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); | |
1305 } | |
1306 } | |
1307 } | |
1308 } | |
1309 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; | |
1310 | |
1311 //----- (004465DF) -------------------------------------------------------- | |
1312 bool sub_4465DF_check_season(int a1) | |
1313 { | |
1314 unsigned int monthPlusOne; // eax@1 | |
1315 unsigned int daysPlusOne; // edx@1 | |
1316 | |
1317 monthPlusOne = pParty->uCurrentMonth + 1; | |
1318 daysPlusOne = pParty->uDaysPlayed + 1; | |
1319 | |
1320 switch (a1) | |
1321 { | |
1322 case 3: //winter 12.21 -> 3.20 | |
1323 return (monthPlusOne == 12 && daysPlusOne >= 21 || monthPlusOne == 1 || monthPlusOne == 2 || monthPlusOne == 3 && daysPlusOne <= 20); | |
1324 break; | |
1325 case 2:// autumn/fall 9.21 -> 12.20 | |
1326 return (monthPlusOne == 9 && daysPlusOne >= 21 || monthPlusOne == 10 || monthPlusOne == 11 || monthPlusOne == 12 && daysPlusOne <= 20); | |
1327 break; | |
1328 case 1://summer 6.21 -> 9.20 | |
1329 return (monthPlusOne == 6 && daysPlusOne >= 21 || monthPlusOne == 7 || monthPlusOne == 8 || monthPlusOne == 9 && daysPlusOne <= 20); | |
1330 break; | |
1331 case 0: //spring 3.21 -> 6.20 | |
1332 return (monthPlusOne == 3 && daysPlusOne >= 21 || monthPlusOne == 4 || monthPlusOne == 5 || monthPlusOne == 6 && daysPlusOne <= 20); | |
1333 break; | |
1334 } | |
1335 Error("Unknown season"); | |
1336 return false; | |
1337 } | |
1338 | |
1339 //----- (00448CF4) -------------------------------------------------------- | |
1340 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) | |
1341 { | |
1342 unsigned int map_id; // eax@1 | |
1343 size_t old_num_actors; // ebx@2 | |
1344 AIDirection v15; // [sp+28h] [bp-34h]@2 | |
1345 SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1 | |
1346 | |
1347 pSpawnPoint.vPosition.x = x; | |
1348 pSpawnPoint.vPosition.y = y; | |
1349 pSpawnPoint.vPosition.z = z; | |
1350 pSpawnPoint.uGroup = group; | |
1351 pSpawnPoint.uRadius = 32; | |
1352 pSpawnPoint.uKind = 3; | |
1353 pSpawnPoint.uIndex = typeindex + 2 * level + level; | |
1354 map_id = pMapStats->GetMapInfo(pCurrentMapName); | |
1355 if (map_id) | |
1356 { | |
1357 old_num_actors = uNumActors; | |
1358 SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0); | |
1359 Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1); | |
1360 for (uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i) | |
1361 { | |
1362 pActors[i].PrepareSprites(0); | |
1363 pActors[i].uYawAngle = v15.uYawAngle; | |
1364 pActors[i].dword_000334_unique_name = uUniqueName; | |
1365 } | |
1366 } | |
1367 } |