Mercurial > mm7
annotate Events.cpp @ 2459:e5c88c2b02ab
Audio_GetFirstHardwareDigitalDriver
author | Ritor1 |
---|---|
date | Wed, 30 Jul 2014 11:19:53 +0600 |
parents | 51d4f38aca6c |
children | 0f17a30149ec |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2215
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
307 | 6 #include <stdlib.h> |
2336 | 7 #include "mm7_unsorted_subs.h" |
8 #include "ErrorHandling.h" | |
307 | 9 |
1323 | 10 #include "Weather.h" |
1262 | 11 #include "Texture.h" |
12 #include "mm7_data.h" | |
2450 | 13 #include "MediaPlayer.h" |
1016 | 14 #include "Mouse.h" |
15 | |
307 | 16 #include "MapInfo.h" |
17 #include "Game.h" | |
1254 | 18 #include "Render.h" |
307 | 19 #include "GUIWindow.h" |
20 #include "GUIProgressBar.h" | |
2331
9551756f46c4
Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
Grumpy7
parents:
2268
diff
changeset
|
21 #include "SpriteObject.h" |
307 | 22 #include "Chest.h" |
2386 | 23 #include "MapsLongTimer.h" |
307 | 24 #include "LOD.h" |
25 #include "Actor.h" | |
26 #include "Party.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2025
diff
changeset
|
27 #include "OurMath.h" |
307 | 28 #include "AudioPlayer.h" |
29 #include "Indoor.h" | |
30 #include "Viewport.h" | |
31 #include "texts.h" | |
32 #include "stru123.h" | |
33 #include "stru159.h" | |
0 | 34 #include "Events.h" |
35 #include "Events2D.h" | |
1299 | 36 #include "UI\UIHouses.h" |
1052 | 37 #include "Log.h" |
481 | 38 #include "MM7.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1826
diff
changeset
|
39 #include "Level/Decoration.h" |
2052 | 40 #include "LuaVM.h" |
0 | 41 |
42 | |
43 | |
1202 | 44 std::array<EventIndex, 4400> pSomeOtherEVT_Events; |
423 | 45 signed int uSomeOtherEVT_NumEvents; |
0 | 46 char *pSomeOtherEVT; |
1202 | 47 std::array<EventIndex, 4400> pSomeEVT_Events; |
428 | 48 signed int uSomeEVT_NumEvents; |
0 | 49 char *pSomeEVT; |
50 | |
51 unsigned int uGlobalEVT_NumEvents; | |
52 unsigned int uGlobalEVT_Size; | |
1202 | 53 std::array<char, 46080> pGlobalEVT; |
54 std::array<EventIndex, 4400> pGlobalEVT_Index; | |
0 | 55 |
1202 | 56 std::array<unsigned int, 500> pLevelStrOffsets; |
0 | 57 unsigned int uLevelStrNumStrings; |
58 unsigned int uLevelStrFileSize; | |
428 | 59 signed int uLevelEVT_NumEvents; |
0 | 60 unsigned int uLevelEVT_Size; |
1202 | 61 std::array<char, 9216> pLevelStr; |
62 std::array<char, 9216> pLevelEVT; | |
63 std::array<EventIndex, 4400> pLevelEVT_Index; | |
0 | 64 |
1289 | 65 _2devent p2DEvents[525]; |
307 | 66 |
67 | |
68 | |
69 //----- (00443CE1) -------------------------------------------------------- | |
70 unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize) | |
1052 | 71 { |
1490 | 72 FILE *pLodFile; // eax@1 |
73 unsigned int uTextureSize; // esi@3 | |
1545 | 74 //char Args[60]; // [sp+8h] [bp-B4h]@6 |
1490 | 75 void *ptr; // [sp+B8h] [bp-4h]@1 |
76 Texture DstBuf; // [sp+6Ch] [bp-50h]@1 | |
307 | 77 |
1490 | 78 ptr = pEvents_LOD->LoadRaw(pContainerName, 0); |
79 pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); | |
80 if ( !pLodFile ) | |
1545 | 81 Error("Unable to load %s", pContainerName); |
82 | |
1490 | 83 fread(&DstBuf, 1, 48, pLodFile); |
84 uTextureSize = DstBuf.uDecompressedSize; | |
85 if ( !DstBuf.uDecompressedSize ) | |
86 uTextureSize = DstBuf.uTextureSize; | |
87 memset(&DstBuf, 0, 72); | |
88 if ( uTextureSize >= (signed int)uBufferSize ) | |
1545 | 89 Error("File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); |
90 | |
1490 | 91 memcpy(pBuffer, ptr, uTextureSize); |
1583 | 92 free(ptr); |
1490 | 93 return uTextureSize; |
94 } | |
307 | 95 |
96 //----- (00443DA1) -------------------------------------------------------- | |
1458 | 97 void Initialize_GlobalEVT() |
762 | 98 { |
1490 | 99 struct raw_event_header |
100 { | |
101 unsigned char evt_size; | |
102 unsigned char evt_id_l; | |
103 unsigned char evt_id_h; | |
104 unsigned char evt_sequence_num; | |
105 } ; | |
106 uint events_count; | |
107 unsigned int offset_in; | |
108 raw_event_header *current_hdr; | |
109 uGlobalEVT_NumEvents = 0; | |
110 uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT.data(), 46080); | |
111 if ( !uGlobalEVT_Size ) | |
112 return; | |
113 memset(pGlobalEVT_Index.data(), 0x80, sizeof(pGlobalEVT_Index));//52800 | |
114 events_count = uGlobalEVT_NumEvents; | |
115 current_hdr=(raw_event_header *)pGlobalEVT.data(); | |
116 offset_in=0; | |
117 for (events_count = 0, offset_in = 0; offset_in < uGlobalEVT_Size; ++events_count) | |
118 { | |
119 pGlobalEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); | |
120 pGlobalEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; | |
121 pGlobalEVT_Index[events_count].uEventOffsetInEVT=offset_in; | |
122 offset_in+=current_hdr->evt_size+1; | |
1052 | 123 |
1490 | 124 current_hdr=(raw_event_header *)&pGlobalEVT[offset_in]; |
125 } | |
126 uGlobalEVT_NumEvents = events_count; | |
307 | 127 |
762 | 128 assert(uGlobalEVT_NumEvents < 4400); |
129 } | |
307 | 130 |
131 | |
1052 | 132 |
307 | 133 //----- (00443EF8) -------------------------------------------------------- |
134 void LoadLevel_InitializeLevelEvt() | |
1490 | 135 { |
601 | 136 struct raw_event_header |
1490 | 137 { |
601 | 138 unsigned char evt_size; |
139 unsigned char evt_id_l; | |
140 unsigned char evt_id_h; | |
141 unsigned char evt_sequence_num; | |
142 } ; | |
143 uint events_count; | |
1490 | 144 unsigned int offset_in; |
145 raw_event_header *current_hdr; | |
601 | 146 |
1490 | 147 if (!uLevelEVT_Size) |
148 return; | |
307 | 149 |
2386 | 150 memset(MapsLongTimersList, 0, 3200); |
1490 | 151 memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); |
307 | 152 |
1490 | 153 uLevelEVT_NumEvents = 0; |
2386 | 154 MapsLongTimers_count = 0; |
307 | 155 |
1202 | 156 current_hdr=(raw_event_header *)pLevelEVT.data(); |
601 | 157 offset_in=0; |
158 for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count) | |
159 { | |
160 pLevelEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); | |
161 pLevelEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; | |
1490 | 162 pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in; |
601 | 163 offset_in+=current_hdr->evt_size+1; |
1052 | 164 |
601 | 165 current_hdr=(raw_event_header *)&pLevelEVT[offset_in]; |
166 } | |
167 uLevelEVT_NumEvents = events_count; | |
168 | |
169 /* | |
1052 | 170 EmeraldIsle::Variables: |
171 [0] ??? | |
172 [1] ??? | |
173 [2] Luck Fountain uses left | |
174 [3] Gold Fountain used this week | |
175 [4] Gold Fountain total uses | |
176 | |
1053 | 177 |
178 Emerald Isle #110 // Fire Resistance fountain | |
1490 | 179 0 LocationName |
180 0 if (Player.FireResistance < 50) | |
181 { | |
182 1 Set(Player.FireResistance, 50) | |
183 2 SetFooterString(22) // +50 Fire Resistance (temporarily) | |
184 3 Add(Party.Autonotes, 2) | |
185 4 goto return | |
186 } | |
187 5 SetFooterString(11) // Refreshing! | |
188 6 return | |
1053 | 189 |
190 | |
191 | |
1052 | 192 Emerald Isle #111 // ??? |
1490 | 193 Initialize |
194 Set(Map.Variables[0], 30) | |
195 Set(Map.Variables[1], 30) | |
1052 | 196 |
197 | |
198 Emerald Isle #114 // month timer - manage luck fountain | |
1490 | 199 0 LocationName |
200 0 if (Player.BaseLuck >= 15) | |
201 { | |
202 2 SetFooterString(11) // Refreshing! | |
203 3 return | |
204 } | |
205 else | |
206 { | |
207 1 if (Map.Variables[2] >= 1) | |
208 { | |
209 4 Sub(Map.Variables[2], 1) | |
210 5 Add(Player.BaseLuck, 2) | |
211 6 SetFooterString(25) // +2 Luck (Permament) | |
212 7 return | |
213 } | |
214 else | |
215 { | |
216 2 SetFooterString(11) // Refreshing! | |
217 3 return | |
218 } | |
219 } | |
1052 | 220 |
1490 | 221 8 Initialize |
222 9 Set Map.Variables[2], 8 | |
1052 | 223 |
224 | |
225 | |
226 Emerald Isle #115 // week timer - gold fountain in the center of town | |
1490 | 227 0 LocationName |
228 0 if (Map.Variables[4] < 3) | |
229 { | |
230 1 if (Map.Variables[3] == 0) | |
231 { | |
232 2 if (Party.Gold < 201) | |
233 { | |
234 3 if (Player.BaseLuck >= 15) | |
235 { | |
236 5 Add(Map.Variables[3], 1) | |
237 6 Add(Party.Gold, 1000) | |
238 7 Add(Map.Variables[4], 1) | |
239 8 goto return | |
240 } | |
241 else | |
242 { | |
243 4 goto 9 | |
244 } | |
245 } | |
246 } | |
247 } | |
248 9 SetFooterString(11) // Refreshing! | |
249 10 return | |
1052 | 250 |
1490 | 251 11 Initialize |
252 12 Set(Map.Variables[3], 0) | |
1052 | 253 |
254 | |
255 | |
256 | |
257 | |
1490 | 258 Emerald Isle #220 // day timer - monster spawner |
259 0 LocationName | |
260 0 Initialize | |
261 1 if (NumAliveActors(group=20) != 0) | |
262 2 return | |
263 3 SpawnMonsters(1, level=1, count=10, x=-336, y=14512, z=0, group=20) | |
264 4 SpawnMonsters(1, level=2, count=5, x=16, y=16352, z=90, group=20) | |
265 5 SpawnMonsters(1, level=1, count=10, x=480, y=18288, z=6, group=20) | |
1052 | 266 |
267 | |
268 | |
1490 | 269 Emerald Isle #200 // margareth dock tip |
270 0 if (!QBits.QuestDone[17]) | |
271 { | |
272 1 InitiateNPCDialogue(npc=19) | |
273 } | |
274 2 return | |
1052 | 275 |
276 | |
1490 | 277 Emerald Isle #201 // margareth armoury tip |
278 0 if (!QBits.QuestDone[17]) | |
279 { | |
280 1 InitiateNPCDialogue(npc=20) | |
281 } | |
282 2 return | |
1052 | 283 */ |
1490 | 284 } |
307 | 285 |
286 | |
287 //----- (0044684A) -------------------------------------------------------- | |
1052 | 288 void EventProcessor(int uEventID, int targetObj, int canShowMessages, int entry_line) |
289 { | |
1490 | 290 signed int v4; // esi@7 |
291 int v11; // eax@14 | |
292 char *v12; // eax@15 | |
293 const char *v16; // esi@21 | |
294 bool v17; // edx@21 | |
295 int v18; // ecx@22 | |
296 int v19; // ebp@36 | |
297 signed int v20; // ecx@40 | |
298 int v21; // eax@40 | |
299 int v22; // edx@40 | |
300 int v23; // eax@40 | |
301 unsigned __int16 v24; // ax@45 | |
302 LevelDecoration *v26; // eax@55 | |
303 int v27; // eax@57 | |
304 int pEventID; // eax@58 | |
305 int pNPC_ID; // ecx@58 | |
306 int pIndex; // esi@58 | |
307 NPCData *pNPC; // ecx@58 | |
308 int v38; // eax@78 | |
309 int v39; // ecx@78 | |
310 int v42; // eax@84 | |
311 int v43; // ecx@84 | |
312 GUIButton *v48; // ecx@93 | |
313 GUIButton *v49; // esi@94 | |
314 signed int pValue; // ebp@124 | |
315 Player *pPlayer; // esi@125 | |
316 int v83; // eax@212 | |
317 int v84; // ebp@220 | |
318 int v90; // eax@243 | |
319 const char *v91; // ecx@247 | |
320 int v94; // ecx@262 | |
321 int v95; // ebp@262 | |
322 int v96; // edx@262 | |
323 int v97; // eax@262 | |
324 unsigned int v98; // edx@265 | |
325 const char *v99; // esi@267 | |
326 int v100; // edx@267 | |
327 unsigned int v102; // esi@281 | |
328 int v104; // eax@288 | |
329 int v106; // [sp-20h] [bp-4C8h]@278 | |
330 signed int v109; // [sp-14h] [bp-4BCh]@278 | |
331 signed int v110; // [sp-10h] [bp-4B8h]@278 | |
332 int curr_seq_num; // [sp+10h] [bp-498h]@4 | |
333 int v126; // [sp+1Ch] [bp-48Ch]@262 | |
334 int player_choose; // [sp+20h] [bp-488h]@4 | |
335 int v128; // [sp+24h] [bp-484h]@21 | |
336 int v129; // [sp+24h] [bp-484h]@262 | |
337 signed int v130; // [sp+28h] [bp-480h]@0 | |
338 int v132; // [sp+30h] [bp-478h]@262 | |
339 signed int v133; // [sp+34h] [bp-474h]@1 | |
340 int v134; // [sp+38h] [bp-470h]@262 | |
341 int v135; // [sp+3Ch] [bp-46Ch]@262 | |
342 int v136; // [sp+40h] [bp-468h]@40 | |
343 int v137; // [sp+44h] [bp-464h]@40 | |
344 int v138; // [sp+48h] [bp-460h]@40 | |
345 int v139; // [sp+4Ch] [bp-45Ch]@40 | |
346 ItemGen item; // [sp+50h] [bp-458h]@15 | |
347 char Source[120]; // [sp+74h] [bp-434h]@15 | |
348 char Str[120]; // [sp+ECh] [bp-3BCh]@21 | |
349 Actor Dst; // [sp+164h] [bp-344h]@53 | |
307 | 350 |
1490 | 351 v133 = 0; |
352 EvtTargetObj = targetObj; | |
1825
23deb6b09c8c
cancelEventProcessing to dword_5B65C4_cancelEventProcessing
Grumpy7
parents:
1821
diff
changeset
|
353 dword_5B65C4_cancelEventProcessing = 0; |
2455 | 354 /*if ( uEventID == 114 )//for test script |
2050 | 355 { |
2052 | 356 if (!lua->DoFile("out01.lua")) |
2050 | 357 Log::Warning(L"Error opening out01.lua\n"); |
2068 | 358 Log::Warning(L"being tested that well\n"); |
2066 | 359 return; |
2144 | 360 } */ |
1490 | 361 if ( !uEventID ) |
2268 | 362 { |
1490 | 363 if ( !GameUI_Footer_TimeLeft ) |
364 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here | |
365 return; | |
2268 | 366 } |
1490 | 367 player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 |
368 curr_seq_num = entry_line; | |
1052 | 369 |
1490 | 370 if ( activeLevelDecoration ) |
2268 | 371 { |
1490 | 372 uSomeEVT_NumEvents = uGlobalEVT_NumEvents; |
373 pSomeEVT = pGlobalEVT.data(); | |
374 memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts | |
2268 | 375 } |
1490 | 376 else |
2268 | 377 { |
1490 | 378 uSomeEVT_NumEvents = uLevelEVT_NumEvents; |
379 pSomeEVT = pLevelEVT.data(); | |
380 memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400); | |
2268 | 381 } |
307 | 382 |
2268 | 383 for ( v4 = 0; v4 < uSomeEVT_NumEvents; ++v4 ) |
384 { | |
1825
23deb6b09c8c
cancelEventProcessing to dword_5B65C4_cancelEventProcessing
Grumpy7
parents:
1821
diff
changeset
|
385 if ( dword_5B65C4_cancelEventProcessing ) |
2266 | 386 { |
387 if ( v133 == 1 ) | |
388 OnMapLeave(); | |
389 return; | |
390 } | |
1490 | 391 if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) |
392 { | |
1980 | 393 _evt_raw * _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); |
307 | 394 |
1490 | 395 switch (_evt->_e_type) |
2268 | 396 { |
1490 | 397 case EVENT_CheckSeason: |
398 if ( !sub_4465DF_check_season(_evt->v5) ) | |
2268 | 399 { |
1490 | 400 ++curr_seq_num; |
2268 | 401 //v4 = v124; |
1490 | 402 break; |
2268 | 403 } |
404 v4 = -1; | |
1490 | 405 curr_seq_num = _evt->v6 - 1; |
406 ++curr_seq_num; | |
407 break; | |
408 case EVENT_ShowMovie: | |
2268 | 409 { |
1490 | 410 strcpy(Source, (char *)&_evt->v7); |
411 v12 = (char *)&item.uExpireTime + strlen(Source) + 7; | |
412 if ( *v12 == 32 ) | |
413 *v12 = 0; | |
2450 | 414 if (pMediaPlayer->bPlaying_Movie) |
415 pMediaPlayer->Unload(); | |
416 pMediaPlayer->bStopBeforeSchedule = 0; | |
417 // pMediaPlayer->pResetflag = 0; | |
1038 | 418 |
1490 | 419 v128 = pCurrentScreen; |
420 strcpy(Str, Source); | |
421 v16 = RemoveQuotes(Str); | |
2455 | 422 pMediaPlayer->FullscreenMovieLoop(v16, 0/*, _evt->v5*/); |
1490 | 423 if ( !_stricmp(v16, "arbiter good") ) |
2450 | 424 { |
425 pParty->alignment = PartyAlignment_Good; | |
1490 | 426 v18 = 0; |
427 LOBYTE(v17) = 1; | |
428 SetUserInterface(PartyAlignment_Good, v17); | |
2266 | 429 if ( !_evt->v6 || v128 == 3 ) |
2268 | 430 { |
1490 | 431 pCurrentScreen = v128; |
432 if ( v128 == 3 ) | |
433 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
434 if ( v128 == 13 ) | |
2450 | 435 pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); |
2268 | 436 } |
1490 | 437 ++curr_seq_num; |
438 break; | |
2268 | 439 } |
1490 | 440 if ( !_stricmp(v16, "arbiter evil") ) |
2268 | 441 { |
1490 | 442 v18 = 2; |
443 pParty->alignment = PartyAlignment_Evil; | |
444 LOBYTE(v17) = 1; | |
445 SetUserInterface(PartyAlignment_Evil, v17); | |
2266 | 446 if ( !_evt->v6 || v128 == 3 ) |
2268 | 447 { |
1490 | 448 pCurrentScreen = v128; |
449 if ( v128 == 3 ) | |
450 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
451 if ( v128 == 13 ) | |
2450 | 452 pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); |
2268 | 453 } |
1490 | 454 ++curr_seq_num; |
455 break; | |
2268 | 456 } |
1490 | 457 if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle |
2268 | 458 { |
1490 | 459 Rest(0x2760u); |
460 pParty->RestAndHeal(); | |
461 pParty->days_played_without_rest = 0; | |
2268 | 462 } |
2266 | 463 if ( !_evt->v6 || v128 == 3 ) |
2268 | 464 { |
1490 | 465 pCurrentScreen = v128; |
466 if ( v128 == 3 ) | |
467 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
468 if ( v128 == 13 ) | |
2450 | 469 pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); |
2268 | 470 } |
1490 | 471 ++curr_seq_num; |
472 } | |
473 break; | |
474 case EVENT_CheckSkill: | |
2268 | 475 { |
1490 | 476 v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8); |
477 if ( player_choose < 0 ) | |
478 goto LABEL_47; | |
479 if ( player_choose <= 3 ) | |
480 v24 = pParty->pPlayers[0].pActiveSkills[3486 * player_choose + _evt->v5]; | |
481 else | |
482 { | |
483 if ( player_choose == 4 ) | |
484 v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5]; | |
485 else | |
486 { | |
487 if ( player_choose == 5 ) | |
488 { | |
489 v20 = 0; | |
490 v21 = 3486 * v130 + _evt->v5; | |
491 v136 = 1; | |
492 LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21]; | |
493 v137 = v21 & 0x40; | |
494 v138 = v21 & 0x80; | |
495 v22 = v21 & 0x100; | |
496 v23 = v21 & 0x3F; | |
497 v139 = v22; | |
498 while ( v23 < v19 || !*(&v136 + _evt->v6) ) | |
499 { | |
500 ++v20; | |
501 if ( v20 >= 4 ) | |
502 { | |
503 ++curr_seq_num; | |
504 break; | |
505 } | |
506 } | |
2266 | 507 curr_seq_num = _evt->v11 - 1; |
508 ++curr_seq_num; | |
509 break; | |
1490 | 510 } |
307 | 511 LABEL_47: |
1490 | 512 //v10 = (ByteArray *)&v5[v9]; |
513 v24 = pParty->pPlayers[0].pActiveSkills[_evt->v5 + 3486 * rand() % 4]; | |
514 } | |
515 } | |
516 v136 = 1; | |
517 v137 = v24 & 0x40; | |
518 v138 = v24 & 0x80; | |
519 v139 = v24 & 0x100; | |
520 if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) ) | |
521 { | |
2266 | 522 curr_seq_num = _evt->v11 - 1; |
523 ++curr_seq_num; | |
524 break; | |
1490 | 525 } |
526 ++curr_seq_num; | |
527 } | |
528 break; | |
307 | 529 |
1490 | 530 case EVENT_SpeakNPC: |
531 if ( canShowMessages ) | |
532 { | |
533 //Actor::Actor(&Dst); | |
534 memset(&Dst, 0, 0x344u); | |
535 dword_5B65D0_dialogue_actor_npc_id = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); | |
536 Dst.sNPC_ID = dword_5B65D0_dialogue_actor_npc_id; | |
537 GameUI_InitializeDialogue(&Dst, false); | |
538 } | |
539 else | |
540 bDialogueUI_InitializeActor_NPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); | |
541 ++curr_seq_num; | |
542 break; | |
543 case EVENT_ChangeEvent: | |
2266 | 544 if ( EVT_DWORD(_evt->v5) ) |
1736
c6fe09a06712
Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
Grumpy7
parents:
1583
diff
changeset
|
545 stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; |
1490 | 546 else |
2268 | 547 { |
1490 | 548 v26 = (LevelDecoration *)activeLevelDecoration; |
1736
c6fe09a06712
Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
Grumpy7
parents:
1583
diff
changeset
|
549 stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; |
1489 | 550 v26->uFlags |= LEVEL_DECORATION_INVISIBLE; |
2268 | 551 } |
1490 | 552 ++curr_seq_num; |
525 | 553 |
1490 | 554 break; |
555 case EVENT_SetNPCGreeting: | |
556 v27 = EVT_DWORD(_evt->v5); | |
557 pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu; | |
558 pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9); | |
559 ++curr_seq_num; | |
560 break; | |
827 | 561 case EVENT_SetNPCTopic: |
562 { | |
563 //v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
564 pEventID = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8); | |
565 pNPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
566 pIndex = _evt->v9; | |
567 pNPC = &pNPCStats->pNewNPCData[pNPC_ID]; | |
568 if ( pIndex == 0 ) | |
569 pNPC->evt_A = pEventID; | |
570 if ( pIndex == 1 ) | |
571 pNPC->evt_B = pEventID; | |
572 if ( pIndex == 2 ) | |
573 pNPC->evt_C = pEventID; | |
574 if ( pIndex == 3 ) | |
575 pNPC->evt_D = pEventID; | |
576 if ( pIndex == 4 ) | |
577 pNPC->evt_E = pEventID; | |
578 if ( pIndex == 5 ) | |
579 pNPC->evt_F = pEventID; | |
580 if ( pNPC_ID == 8 ) | |
581 { | |
582 if ( pEventID == 78 ) | |
583 { | |
1919 | 584 HouseDialogPressCloseBtn(); |
827 | 585 window_SpeakInHouse->Release(); |
586 pParty->uFlags &= ~2; | |
587 if ( EnterHouse(HOUSE_DARK_GUILD_PIT) ) | |
588 { | |
589 pAudioPlayer->StopChannels(-1, -1); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
590 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 170, 0); |
948 | 591 window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); |
592 window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
593 window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
594 window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
595 window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); | |
827 | 596 current_npc_text = pNPCTopics[90].pText; |
597 } | |
598 } | |
599 } | |
600 ++curr_seq_num; | |
601 } | |
602 break; | |
1490 | 603 case EVENT_NPCSetItem: |
604 sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); | |
605 ++curr_seq_num; | |
606 break; | |
607 case EVENT_SetActorItem: | |
608 Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); | |
609 ++curr_seq_num; | |
610 break; | |
611 case EVENT_SetNPCGroupNews: | |
612 pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8); | |
613 ++curr_seq_num; | |
614 break; | |
615 case EVENT_SetActorGroup: | |
616 __debugbreak(); | |
617 *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
618 ++curr_seq_num; | |
619 break; | |
620 case EVENT_ChangeGroup: | |
621 v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
622 v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
623 __debugbreak(); | |
2268 | 624 for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) |
625 { | |
626 if ( pActors[actor_id].uGroup == v38 ) | |
627 pActors[actor_id].uGroup = v39; | |
628 } | |
1490 | 629 ++curr_seq_num; |
630 break; | |
631 case EVENT_ChangeGroupAlly: | |
632 v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
633 v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
634 __debugbreak(); | |
2268 | 635 for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) |
636 { | |
637 if ( pActors[actor_id].uGroup == v42 ) | |
638 pActors[actor_id].uAlly = v43; | |
639 } | |
1490 | 640 ++curr_seq_num; |
641 break; | |
642 case EVENT_MoveNPC: | |
643 { | |
644 pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); | |
645 if ( window_SpeakInHouse ) | |
646 { | |
310 | 647 |
1490 | 648 if ( window_SpeakInHouse->par1C == 165 ) |
649 { | |
1919 | 650 HouseDialogPressCloseBtn(); |
2450 | 651 pMediaPlayer->Unload(); |
1490 | 652 window_SpeakInHouse->Release(); |
653 pParty->uFlags &= ~2; | |
654 activeLevelDecoration = (LevelDecoration*)1; | |
655 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) | |
656 { | |
657 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
658 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
1490 | 659 v48 = window_SpeakInHouse->pControlsHead; |
2266 | 660 if ( window_SpeakInHouse->pControlsHead ) |
1490 | 661 { |
662 do | |
663 { | |
664 v49 = v48->pNext; | |
1583 | 665 free(v48); |
1490 | 666 v48 = v49; |
667 } | |
668 while ( v49 ); | |
669 } | |
670 window_SpeakInHouse->pControlsHead = 0; | |
671 window_SpeakInHouse->pControlsTail = 0; | |
672 window_SpeakInHouse->uNumControls = 0; | |
673 } | |
674 } | |
675 else | |
676 { | |
677 if ( window_SpeakInHouse->par1C == 553 ) | |
2450 | 678 pMediaPlayer->bLoopPlaying = 0; |
1490 | 679 } |
680 } | |
681 | |
682 } | |
2268 | 683 ++curr_seq_num; |
1490 | 684 break; |
685 case EVENT_Jmp: | |
686 curr_seq_num = _evt->v5 - 1; | |
687 ++curr_seq_num; | |
688 v4 = -1; | |
525 | 689 |
1490 | 690 break; |
691 case EVENT_ShowFace: | |
692 if ( _evt->v5 <= 3u ) //someone | |
693 pParty->pPlayers[_evt->v5].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); | |
694 else if ( _evt->v5 == 4 ) //active | |
695 pParty->pPlayers[uActiveCharacter].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); | |
696 else if ( _evt->v5 == 5 ) //all players | |
697 { | |
2266 | 698 for(int i = 0; i < 4; ++i) |
1490 | 699 pParty->pPlayers[i].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); |
700 } | |
701 else //random player | |
702 pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); | |
703 ++curr_seq_num; | |
704 break; | |
705 case EVENT_CharacterAnimation: | |
2268 | 706 if ( _evt->v5 <= 3 ) //someone |
1490 | 707 pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0); |
708 else if ( _evt->v5 == 4 ) //active | |
709 pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0); | |
710 else if ( _evt->v5 == 5 ) //all | |
2268 | 711 for(int i = 0; i < 4; ++i) |
1490 | 712 pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0); |
713 else //random | |
714 pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0); | |
715 ++curr_seq_num; | |
716 break; | |
717 case EVENT_ForPartyMember: | |
718 player_choose = _evt->v5; | |
719 ++curr_seq_num; | |
720 break; | |
721 case EVENT_SummonItem: | |
2331
9551756f46c4
Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
Grumpy7
parents:
2268
diff
changeset
|
722 SpriteObject::sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), |
1490 | 723 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), |
724 _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8), | |
725 _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8), | |
726 _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8), | |
727 _evt->v25, _evt->v26, 0, 0); | |
728 ++curr_seq_num; | |
729 break; | |
730 case EVENT_Compare: | |
731 pValue = EVT_DWORD(_evt->v7); | |
732 if ( player_choose <= 3 ) | |
733 { | |
734 if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) | |
735 { | |
2268 | 736 // v124 = -1; |
1490 | 737 curr_seq_num = _evt->v11 - 1; |
738 } | |
739 } | |
740 else if ( player_choose == 4 ) //active | |
741 { | |
742 if ( uActiveCharacter ) | |
743 { | |
744 if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) | |
745 { | |
2268 | 746 // v124 = -1; |
1490 | 747 curr_seq_num = _evt->v11 - 1; |
748 } | |
749 } | |
750 } | |
751 else if ( player_choose == 5 )//all | |
752 { | |
2266 | 753 v130 = 0; |
1490 | 754 for(int i = 1; i < 5; ++i) |
755 { | |
756 if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) | |
757 { | |
2268 | 758 // v124 = -1; |
1490 | 759 curr_seq_num = _evt->v11 - 1; |
760 break; | |
761 } | |
762 ++v130; | |
763 } | |
764 } | |
765 else if ( player_choose == 6 ) //random | |
766 { | |
1817
0f1543750bf8
Changing itemlist accesses to helper functions + getting rid of some pPlayers array accesses
Grumpy7
parents:
1736
diff
changeset
|
767 if ( pPlayers[rand() % 4 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) |
1490 | 768 { |
2268 | 769 // v124 = -1; |
1490 | 770 curr_seq_num = _evt->v11 - 1; |
771 } | |
772 } | |
773 ++curr_seq_num; | |
2268 | 774 v4 = -1; |
1490 | 775 break; |
776 case EVENT_IsActorAlive: | |
777 if (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) | |
2268 | 778 { |
779 //v124 = -1; | |
1490 | 780 curr_seq_num = _evt->v11 - 1; |
2268 | 781 } |
1490 | 782 ++curr_seq_num; |
2268 | 783 v4 = -1; |
1490 | 784 break; |
785 case EVENT_Substract: | |
786 pValue = EVT_DWORD(_evt->v7); | |
2025 | 787 /*if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) |
1490 | 788 { |
789 if ( pParty->pPickedItem.uItemID == pValue )//In hand | |
790 { | |
791 pMouse->RemoveHoldingItem(); | |
792 ++curr_seq_num; | |
793 v4 = v124; | |
794 break; | |
795 } | |
2024 | 796 //v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data(); |
1490 | 797 for ( v65 = 0; v65 < 126; ++v65 ) |
798 { | |
2025 | 799 v67 = &pPlayers[uActiveCharacter]->pInventoryMatrix[v65]; |
800 if ( v67 > 0 ) | |
1490 | 801 { |
2025 | 802 if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue ) |
803 { | |
804 pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); | |
805 //++curr_seq_num; | |
806 //v4 = v124; | |
807 goto substract; | |
808 } | |
1490 | 809 } |
2024 | 810 //v67 += 4; |
1490 | 811 } |
2024 | 812 //while ( (signed int)v65 < 126 ); |
2025 | 813 //v69 = (int)&pPlayers[uActiveCharacter]->pEquipment.pIndices; |
1490 | 814 for ( v68 = 0; v68 < 16; ++v68 ) |
815 { | |
2025 | 816 if ( pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.pIndices[v68]].uItemID == pValue ) |
1490 | 817 { |
2025 | 818 pPlayers[uActiveCharacter]->pEquipment.pIndices[v68] = 0; |
819 //++curr_seq_num; | |
820 //v4 = v124; | |
821 goto substract; | |
1490 | 822 } |
2025 | 823 //v69 += 4; |
1490 | 824 } |
825 for (int i = 1; i < 5; i++) | |
826 { | |
2024 | 827 //v72 = (int)pPlayers[i]->pInventoryMatrix.data(); |
1490 | 828 for ( int v71 = 0; v71 < 126; ++v71 ) |
829 { | |
2025 | 830 v72 = &pPlayers[i]->pInventoryMatrix[v71]; |
831 if ( v72 > 0 ) | |
1490 | 832 { |
2025 | 833 if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue ) |
834 { | |
835 pPlayers[i]->RemoveItemAtInventoryIndex(v71); | |
836 goto substract; | |
837 } | |
1490 | 838 } |
2024 | 839 //v72 += 4; |
1490 | 840 } |
2025 | 841 for ( v73 = 0; v73 < 16; ++v73 ) |
1490 | 842 { |
2025 | 843 //v74 = (int)&pPlayers[i]->pEquipment; |
844 if (pPlayers[i]->pEquipment.pIndices[v73]) | |
845 { | |
846 if (pPlayers[i]->pInventoryItemList[pPlayers[i]->pEquipment.pIndices[v73] - 1].uItemID == pValue ) | |
847 { | |
848 pPlayers[i]->pEquipment.pIndices[v73] = 0; | |
849 //v74 += 4; | |
850 goto substract; | |
851 } | |
852 } | |
1490 | 853 } |
854 } | |
2025 | 855 }*/ |
1490 | 856 if ( player_choose <= 3 ) |
2025 | 857 pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 858 else if ( player_choose == 4 ) //active |
859 { | |
860 if ( uActiveCharacter ) | |
2025 | 861 pPlayers[uActiveCharacter]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 862 } |
863 else if ( player_choose == 5 )//all | |
864 { | |
865 for(int i = 1; i < 5; ++i) | |
1820
af7f08135ffb
Player::SubtractVariable changing return val to void, finishing cleanup
Grumpy7
parents:
1817
diff
changeset
|
866 pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 867 } |
868 else if ( player_choose == 6 ) //random | |
2266 | 869 pParty->pPlayers[rand() % 4].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 870 ++curr_seq_num; |
871 break; | |
872 case EVENT_Set: | |
873 pValue = EVT_DWORD(_evt->v7); | |
874 if ( player_choose <= 3 ) | |
2025 | 875 pParty->pPlayers[player_choose].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 876 else if ( player_choose == 4 ) //active |
877 { | |
878 if ( uActiveCharacter ) | |
2025 | 879 pPlayers[uActiveCharacter]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 880 } |
881 else if ( player_choose == 5 )//all | |
882 { | |
2268 | 883 //recheck v130 |
2025 | 884 for ( int i = 1; i < 5; ++i ) |
1490 | 885 pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
886 } | |
887 else if ( player_choose == 6 ) //random | |
2266 | 888 pParty->pPlayers[rand() % 4].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
2025 | 889 ++curr_seq_num; |
890 break; | |
1490 | 891 case EVENT_Add: |
892 pValue = EVT_DWORD(_evt->v7); | |
893 if ( player_choose <= 3 ) | |
894 { | |
895 pPlayer = &pParty->pPlayers[player_choose]; | |
896 pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); | |
897 } | |
898 else if ( player_choose == 4 ) //active | |
899 { | |
900 if ( uActiveCharacter ) | |
2025 | 901 pPlayers[uActiveCharacter]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
1490 | 902 } |
903 else if ( player_choose == 5 )//all | |
904 { | |
905 for(int i = 1; i < 5; ++i) | |
906 pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); | |
907 } | |
908 else if ( player_choose == 6 ) //random | |
2266 | 909 pParty->pPlayers[rand() % 4].AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); |
2025 | 910 v83 = EVT_WORD(_evt->v5); |
911 if (v83 == 21 || // gold well on emerald isle | |
912 v83 == 22 || v83 == 23 || v83 == 24 ) | |
913 { | |
914 //__debugbreak(); // bonfire | |
915 viewparams->bRedrawGameUI = true; | |
916 } | |
917 ++curr_seq_num; | |
918 break; | |
1490 | 919 case EVENT_InputString: |
920 if ( !entry_line ) | |
2268 | 921 { |
1490 | 922 strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); |
2266 | 923 sub_4451A8_press_any_key(uEventID, curr_seq_num, 26); |
1490 | 924 if ( v133 == 1 ) |
925 OnMapLeave(); | |
926 return; | |
2268 | 927 } |
1490 | 928 v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); |
929 if ( !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]]) | |
930 || !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[v84]]) ) | |
2268 | 931 { |
1490 | 932 v11 = _evt->v17; |
933 curr_seq_num = v11 - 1; | |
2268 | 934 } |
1490 | 935 ++curr_seq_num; |
2268 | 936 v4 = -1; |
1490 | 937 break; |
938 case EVENT_RandomGoTo: | |
939 //v124 = -1; | |
940 v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0) | |
941 + (_evt->v10 != 0))); | |
525 | 942 curr_seq_num = v11 - 1; |
787 | 943 ++curr_seq_num; |
2268 | 944 v4 = -1; |
787 | 945 break; |
1490 | 946 case EVENT_ReceiveDamage: |
2266 | 947 if ( (unsigned __int8)_evt->v5 <= 3 ) |
2268 | 948 { |
2266 | 949 pParty->pPlayers[(unsigned __int8)_evt->v5].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); |
1490 | 950 ++curr_seq_num; |
951 break; | |
2268 | 952 } |
2266 | 953 if ( _evt->v5 == 4 ) |
2268 | 954 { |
1490 | 955 if ( !uActiveCharacter ) |
2268 | 956 { |
1490 | 957 ++curr_seq_num; |
958 break; | |
2268 | 959 } |
2266 | 960 pPlayers[uActiveCharacter]->ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); |
1490 | 961 ++curr_seq_num; |
962 break; | |
2268 | 963 } |
2266 | 964 if ( _evt->v5 != 5 ) |
2268 | 965 { |
2266 | 966 pParty->pPlayers[rand() % 4].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); |
1490 | 967 ++curr_seq_num; |
968 break; | |
2268 | 969 } |
2266 | 970 for ( uint pl_id = 0;pl_id < 4; pl_id++ ) |
971 pParty->pPlayers[pl_id].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); | |
1490 | 972 ++curr_seq_num; |
973 break; | |
974 case EVENT_ToggleIndoorLight: | |
975 pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); | |
976 ++curr_seq_num; | |
977 break; | |
978 case EVENT_SetFacesBit: | |
979 sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); | |
980 ++curr_seq_num; | |
981 break; | |
982 case EVENT_ToggleChestFlag: | |
983 Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); | |
984 ++curr_seq_num; | |
985 break; | |
986 case EVENT_ToggleActorFlag: | |
987 Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); | |
988 ++curr_seq_num; | |
989 break; | |
990 case EVENT_ToggleActorGroupFlag: | |
991 ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); | |
992 ++curr_seq_num; | |
993 break; | |
994 case EVENT_SetSnow: | |
995 if ( !_evt->v5 ) | |
996 pWeather->bRenderSnow = _evt->v6 != 0; | |
997 ++curr_seq_num; | |
998 break; | |
999 case EVENT_StatusText: | |
1000 v90 = EVT_DWORD(_evt->v5 ); | |
1001 if ( activeLevelDecoration ) | |
2268 | 1002 { |
1490 | 1003 if ( activeLevelDecoration == (LevelDecoration*)1 ) |
1004 current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; | |
1005 if ( canShowMessages == 1 ) | |
1006 { | |
1007 v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; | |
1008 //LABEL_248: | |
2266 | 1009 ShowStatusBarString(v91, 2); |
1490 | 1010 } |
2268 | 1011 } |
1490 | 1012 else |
2268 | 1013 { |
1014 if ( canShowMessages == 1 ) | |
1490 | 1015 { |
1016 v91 = &pLevelStr[pLevelStrOffsets[v90]]; | |
2268 | 1017 ShowStatusBarString(v91, 2); |
1490 | 1018 } |
2268 | 1019 } |
1490 | 1020 ++curr_seq_num; |
1021 break; | |
1022 case EVENT_ShowMessage: | |
1023 if ( activeLevelDecoration ) | |
2268 | 1024 { |
2266 | 1025 current_npc_text = pNPCTopics[EVT_DWORD(_evt->v5 )-1].pText;//(&dword_721664)[8 * v92]; |
1490 | 1026 byte_5B0938[0] = 0; |
2268 | 1027 } |
1490 | 1028 else |
2266 | 1029 strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); |
1490 | 1030 ++curr_seq_num; |
1031 break; | |
1032 case EVENT_CastSpell: | |
835 | 1033 EventCastSpell(_evt->v5, _evt->v6, _evt->v7, EVT_DWORD(_evt->v8 ), |
525 | 1034 EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), |
1035 EVT_DWORD(_evt->v24 ), EVT_DWORD(_evt->v28 )); | |
835 | 1036 ++curr_seq_num; |
1037 break; | |
1490 | 1038 case EVENT_SetTexture: |
1039 sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); | |
1040 ++curr_seq_num; | |
1041 break; | |
1042 case EVENT_SetSprite: | |
1043 SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); | |
1044 ++curr_seq_num; | |
1045 break; | |
1046 case EVENT_SummonMonsters: | |
1047 sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ), | |
525 | 1048 EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), |
1049 EVT_DWORD(_evt->v24 )); | |
1490 | 1050 ++curr_seq_num; |
1051 break; | |
1052 case EVENT_MouseOver: | |
1053 case EVENT_LocationName: | |
1054 --curr_seq_num; | |
1055 ++curr_seq_num; | |
1056 break; | |
1057 case EVENT_ChangeDoorState: | |
2085 | 1058 Door_switch_animation(_evt->v5, _evt->v6); |
1490 | 1059 ++curr_seq_num; |
1060 break; | |
1061 case EVENT_OpenChest: | |
1062 if ( !Chest::Open(_evt->v5) ) | |
2268 | 1063 { |
2266 | 1064 if ( v133 == 1 ) |
1065 OnMapLeave(); | |
1066 return; | |
2268 | 1067 } |
1490 | 1068 ++curr_seq_num; |
1069 break; | |
1070 case EVENT_MoveToMap: | |
1071 v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
1072 v135 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
1073 v132 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
1074 v126 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); | |
1075 v129 = _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8); | |
1076 v95 = _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8); | |
1077 v96 = _evt->v25; | |
1078 v97 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); | |
1079 v134 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); | |
1080 if ( _evt->v29 || _evt->v30 ) | |
1081 { | |
2153 | 1082 pRenderer->Sub01(); |
1490 | 1083 TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); |
1084 dword_5C3418 = uEventID; | |
1085 dword_5C341C = curr_seq_num + 1; | |
2266 | 1086 if ( v133 == 1 ) |
1087 OnMapLeave(); | |
1088 return; | |
1490 | 1089 } |
1090 _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
1091 _5B65A8_npcdata_uflags_or_other = v94; | |
1092 _5B65B0_npcdata_rep_or_other = v126; | |
1093 if ( v129 == -1 ) | |
1094 v98 = _5B65B4_npcdata_loword_house_or_other; | |
1095 else | |
2268 | 1096 { |
1490 | 1097 v98 = v129 & stru_5C6E00->uDoublePiMask; |
1098 _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask; | |
2268 | 1099 } |
1490 | 1100 v99 = (char *)&_evt->v31; |
1101 _5B65B8_npcdata_hiword_house_or_other = v95; | |
1102 dword_5B65BC = v97; | |
1103 v100 = v94 | v132 | v126 | v95 | v97 | v98; | |
1104 dword_5B65C0 = v100; | |
1105 if ( *v99 == 48 ) | |
1106 { | |
1107 if ( v100 ) | |
1108 { | |
1109 pParty->vPosition.x = v135; | |
1110 pParty->vPosition.y = v132; | |
1111 pParty->vPosition.z = v126; | |
1112 pParty->uFallStartY = v126; | |
1113 if ( _5B65B4_npcdata_loword_house_or_other != -1 ) | |
1114 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; | |
1115 _5B65B4_npcdata_loword_house_or_other = -1; | |
1116 pParty->sRotationX = v95; | |
1117 pParty->uFallSpeed = v134; | |
1118 dword_5B65C0 = 0; | |
1119 dword_5B65BC = 0; | |
1120 _5B65B8_npcdata_hiword_house_or_other = 0; | |
1121 _5B65B0_npcdata_rep_or_other = 0; | |
1122 _5B65AC_npcdata_fame_or_other = 0; | |
1123 _5B65A8_npcdata_uflags_or_other = 0; | |
1124 v106 = 232; | |
2266 | 1125 pAudioPlayer->PlaySound((SoundID)v106, 0, 0, -1, 0, 0, 0, 0); |
1490 | 1126 } |
1127 } | |
1128 else | |
1129 { | |
1130 pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); | |
2101 | 1131 Transition_StopSound_Autosave(v99, MapStartPoint_Party); |
1490 | 1132 v133 = 1; |
1133 if ( pCurrentScreen == SCREEN_HOUSE ) | |
1134 { | |
2124 | 1135 if ( uGameState == GAME_STATE_CHANGE_LOCATION ) |
1490 | 1136 { |
1137 pAudioPlayer->StopChannels(-1, -1); | |
1138 dialog_menu_id = HOUSE_DIALOGUE_NULL; | |
1919 | 1139 while ( HouseDialogPressCloseBtn() ) |
1490 | 1140 ; |
2450 | 1141 pMediaPlayer->Unload(); |
1490 | 1142 window_SpeakInHouse->Release(); |
1143 window_SpeakInHouse = 0; | |
1144 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1145 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
1146 pCurrentScreen = SCREEN_GAME; | |
1147 viewparams->bRedrawGameUI = 1; | |
1148 pDialogueNPCCount = 0; | |
1149 pDialogueWindow->Release(); | |
1150 dialog_menu_id = HOUSE_DIALOGUE_NULL; | |
1151 pDialogueWindow = 0; | |
1152 pIcons_LOD->SyncLoadedFilesCount(); | |
1153 } | |
1154 OnMapLeave(); | |
1155 return; | |
1156 } | |
1157 } | |
1158 ++curr_seq_num; | |
1159 break; | |
1160 case EVENT_PlaySound: | |
1161 v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); | |
1162 v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); | |
1163 v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); | |
2266 | 1164 pAudioPlayer->PlaySound((SoundID)v106, 0, 0, v109, v110, 0, 0, 0); |
1165 ++curr_seq_num; | |
1166 break; | |
1490 | 1167 case EVENT_GiveItem: |
1168 item.Reset(); | |
2266 | 1169 v102 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); |
1490 | 1170 pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item); |
1171 if ( v102 ) | |
1172 item.uItemID = v102; | |
1173 pParty->SetHoldingItem(&item); | |
1174 ++curr_seq_num; | |
1175 break; | |
1176 case EVENT_SpeakInHouse: | |
1177 if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) | |
1178 { | |
2153 | 1179 pRenderer->Sub01(); |
1490 | 1180 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); |
1181 pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0); | |
1182 v104 = 187; | |
1183 if ( uCurrentHouse_Animation != 167 ) | |
1184 v104 = EVT_DWORD(_evt->v5); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1185 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, v104, 0); |
1490 | 1186 window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); |
1187 window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
1188 window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
1189 window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
1190 window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); | |
1191 } | |
1192 ++curr_seq_num; | |
1193 break; | |
1194 case EVENT_PressAnyKey: | |
2266 | 1195 sub_4451A8_press_any_key(uEventID, curr_seq_num + 1, 33); |
1196 if ( v133 == 1 ) | |
1197 OnMapLeave(); | |
1198 return; | |
1490 | 1199 case EVENT_Exit: |
1200 if ( v133 == 1 ) | |
1201 OnMapLeave(); | |
1202 return; | |
1203 default: | |
1204 ++curr_seq_num; | |
1205 break; | |
1206 } | |
1207 } | |
2266 | 1208 } |
2268 | 1209 if ( v133 == 1 ) |
1210 OnMapLeave(); | |
1211 return; | |
1490 | 1212 } |
307 | 1213 |
1295 | 1214 //----- (00444732) -------------------------------------------------------- |
1215 char *GetEventHintString(unsigned int uEventID) | |
1216 { | |
1217 signed int event_index; // edx@1 | |
1218 int event_pos; // esi@4 | |
1219 char *result; // eax@6 | |
1220 unsigned int str_index; // eax@9 | |
1221 int i; // esi@11 | |
1222 _evt_raw* test_evt; | |
1223 _evt_raw* last_evt; | |
1224 | |
1225 event_index = 0; | |
1226 if ( uLevelEVT_NumEvents <= 0 ) | |
1227 return NULL; | |
1490 | 1228 |
1295 | 1229 //v2 = (char *)&pLevelEVT_Index[0].uEventOffsetInEVT; |
1230 while ( 1 ) | |
1231 { | |
1232 if ( pLevelEVT_Index[event_index].uEventID == uEventID ) | |
1233 { | |
2268 | 1234 test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; |
1235 last_evt=test_evt; | |
1295 | 1236 event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; |
1237 if ( test_evt->_e_type == EVENT_MouseOver ) | |
1238 break; | |
1239 } | |
1240 ++event_index; | |
1241 if ( event_index >= uLevelEVT_NumEvents ) | |
1242 return NULL; | |
1243 } | |
2268 | 1244 test_evt=(_evt_raw*)&pLevelEVT[event_pos]; |
1295 | 1245 if ( test_evt->_e_type== EVENT_SpeakInHouse ) |
1246 { | |
1247 str_index = EVT_DWORD(test_evt->v5); | |
1248 result = (char *)p2DEvents[str_index - 1].pName; | |
1249 } | |
1250 else | |
1251 { | |
2268 | 1252 for ( i = event_index + 1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) |
1295 | 1253 { |
1254 event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; | |
2268 | 1255 test_evt=(_evt_raw*)&pLevelEVT[event_pos]; |
1295 | 1256 if ( test_evt->_e_type == EVENT_SpeakInHouse ) |
1257 { | |
1258 str_index = EVT_DWORD(test_evt->v5); | |
1259 if ( str_index < 600 ) | |
1260 return (char *)p2DEvents[str_index - 1].pName; | |
1261 } | |
1262 } | |
1263 result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; | |
1264 } | |
1490 | 1265 |
1295 | 1266 return result; |
1267 } |