comparison Events.cpp @ 307:72faa54ff319

Events stuff moved to its file
author Gloval
date Wed, 20 Feb 2013 00:26:17 +0400
parents 9c0607679772
children 4c2cdda88562
comparison
equal deleted inserted replaced
304:f16ac5e65438 307:72faa54ff319
1 #include <stdlib.h>
2
3 #include "MapInfo.h"
4 #include "Game.h"
5 #include "GUIWindow.h"
6 #include "GUIFont.h"
7 #include "GUIButton.h"
8 #include "GUIProgressBar.h"
9 #include "Chest.h"
10 #include "stru176.h"
11 #include "LOD.h"
12 #include "NPC.h"
13 #include "Actor.h"
14 #include "Party.h"
15 #include "Math.h"
16 #include "AudioPlayer.h"
17 #include "Indoor.h"
18 #include "Viewport.h"
19 #include "texts.h"
20 #include "Texture.h"
21 #include "Allocator.h"
22 #include "mm7_data.h"
23 #include "stru123.h"
24 #include "stru159.h"
1 #include "Events.h" 25 #include "Events.h"
2 #include "Events2D.h" 26 #include "Events2D.h"
3 27 #include "Weather.h"
4 28
5 29
6 Event pSomeOtherEVT_Events[4400]; 30
31 EventIndex pSomeOtherEVT_Events[4400];
7 unsigned int uSomeOtherEVT_NumEvents; 32 unsigned int uSomeOtherEVT_NumEvents;
8 char *pSomeOtherEVT; 33 char *pSomeOtherEVT;
9 Event pSomeEVT_Events[4400]; 34 EventIndex pSomeEVT_Events[4400];
10 unsigned int uSomeEVT_NumEvents; 35 unsigned int uSomeEVT_NumEvents;
11 char *pSomeEVT; 36 char *pSomeEVT;
12 37
13 unsigned int uGlobalEVT_NumEvents; 38 unsigned int uGlobalEVT_NumEvents;
14 unsigned int uGlobalEVT_Size; 39 unsigned int uGlobalEVT_Size;
15 char pGlobalEVT[46080]; 40 char pGlobalEVT[46080];
16 Event pGlobalEVT_Events[4400]; 41 EventIndex pGlobalEVT_Index[4400];
17 42
18 unsigned int pLevelStrOffsets[500]; 43 unsigned int pLevelStrOffsets[500];
19 unsigned int uLevelStrNumStrings; 44 unsigned int uLevelStrNumStrings;
20 unsigned int uLevelStrFileSize; 45 unsigned int uLevelStrFileSize;
21 unsigned int uLevelEVT_NumEvents; 46 unsigned int uLevelEVT_NumEvents;
22 unsigned int uLevelEVT_Size; 47 unsigned int uLevelEVT_Size;
23 char pLevelStr[9216]; 48 char pLevelStr[9216];
24 char pLevelEVT[9216]; 49 char pLevelEVT[9216];
25 Event pLevelEVT_Events[4400]; 50 EventIndex pLevelEVT_Index[4400];
26 51
27 52
28 _2devent p2DEvents[525]; // weak 53 _2devent p2DEvents[525]; // weak
54
55
56
57 //----- (00443CE1) --------------------------------------------------------
58 unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize)
59 {
60 FILE *pLodFile; // eax@1
61 unsigned int uTextureSize; // esi@3
62 char Args[60]; // [sp+8h] [bp-B4h]@6
63 void *ptr; // [sp+B8h] [bp-4h]@1
64 Texture DstBuf; // [sp+6Ch] [bp-50h]@1
65
66 ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
67 pLodFile = pEvents_LOD->FindContainer(pContainerName, 0);
68 if ( !pLodFile )
69 Abortf("Unable to load %s", pContainerName);
70 fread(&DstBuf, 1, 48, pLodFile);
71 uTextureSize = DstBuf.uDecompressedSize;
72 if ( !DstBuf.uDecompressedSize )
73 uTextureSize = DstBuf.uTextureSize;
74 memset(&DstBuf, 0, 72);
75 if ( uTextureSize >= (signed int)uBufferSize )
76 {
77 sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize);
78 Abortf(Args);
79 }
80 memcpy(pBuffer, ptr, uTextureSize);
81 pAllocator->FreeChunk(ptr);
82 return uTextureSize;
83 }
84
85 //----- (00443DA1) --------------------------------------------------------
86 void __cdecl Initialize_GlobalEVT()
87 {
88 struct raw_event_header
89 {
90 unsigned char evt_size;
91 unsigned char evt_id_l;
92 unsigned char evt_id_h;
93 unsigned char evt_sequence_num;
94 } ;
95 uint events_count;
96 unsigned int offset_in;
97 raw_event_header *current_hdr;
98 uGlobalEVT_NumEvents = 0;
99 uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT, 46080);
100 if ( !uGlobalEVT_Size )
101 return;
102 memset(pGlobalEVT_Index, 0x80, sizeof(pGlobalEVT_Index));//52800
103 events_count = uGlobalEVT_NumEvents;
104 current_hdr=(raw_event_header *)pGlobalEVT;
105 offset_in=0;
106 for (events_count = 0, offset_in = 0; offset_in < uGlobalEVT_Size; ++events_count)
107 {
108 pGlobalEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8);
109 pGlobalEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num;
110 pGlobalEVT_Index[events_count].uEventOffsetInEVT=offset_in;
111 offset_in+=current_hdr->evt_size+1;
112 current_hdr=(raw_event_header *)&pGlobalEVT[offset_in];
113 }
114 uGlobalEVT_NumEvents = events_count;
115
116 }
117
118
119 //----- (00443EF8) --------------------------------------------------------
120 void LoadLevel_InitializeLevelEvt()
121 {
122 if (!uLevelEVT_Size)
123 return;
124
125 memset(array_5B5928, 0, 3200);
126 memset(pLevelEVT_Index, 80, 52800);
127
128 uLevelEVT_NumEvents = 0;
129 dword_5B65C8 = 0;
130
131 for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i)
132 {
133 pLevelEVT_Index[i].uEventID = pLevelEVT[j + 1] + ((unsigned short)pLevelEVT[j + 2] << 8);
134 pLevelEVT_Index[i].event_sequence_num = pLevelEVT[j + 3];
135 pLevelEVT_Index[i].uEventOffsetInEVT = j;
136 j += pLevelEVT[j] + 1;
137 uLevelEVT_NumEvents++;
138 }
139 }
140
141
142 //----- (0044684A) --------------------------------------------------------
143 void EventProcessor(int uEventID, int a2, int a3)
144 {
145 unsigned int v3; // eax@5
146 //signed int v4; // esi@7
147 //char *v5; // eax@8
148 Player *v6; // ecx@8
149 //char *v7; // ebp@8
150 //signed int v8; // edx@10
151 //int v9; // edi@12
152 //ByteArray *v10; // esi@12
153 int v11; // eax@14
154 char *v12; // eax@15
155 //char *v13; // edi@21
156 int v14; // ebp@21
157 int v15; // edi@21
158 const char *v16; // esi@21
159 bool v17; // edx@21
160 int v18; // ecx@22
161 int v19; // ebp@36
162 signed int v20; // ecx@40
163 int v21; // eax@40
164 int v22; // edx@40
165 int v23; // eax@40
166 unsigned __int16 v24; // ax@45
167 int v25; // eax@54
168 LevelDecoration *v26; // eax@55
169 int v27; // eax@57
170 int v28; // ecx@57
171 int v29; // edx@58
172 int v30; // eax@58
173 int v31; // ecx@58
174 int v32; // esi@58
175 NPCData *v33; // ecx@58
176 int v34; // esi@59
177 int v35; // esi@60
178 int v36; // esi@61
179 int v37; // esi@62
180 int v38; // eax@78
181 int v39; // ecx@78
182 size_t v40; // edx@78
183 Actor *v41; // esi@79
184 int v42; // eax@84
185 int v43; // ecx@84
186 size_t v44; // edx@84
187 Actor *v45; // esi@85
188 void *v46; // eax@91
189 GUIWindow *v47; // eax@93
190 GUIButton *v48; // ecx@93
191 GUIButton *v49; // esi@94
192 char v50; // al@100
193 Player *v51; // esi@103
194 Player *v52; // ecx@106
195 int v53; // ecx@107
196 char v54; // al@111
197 Player *v55; // esi@114
198 Player *v56; // ecx@117
199 int v57; // ecx@118
200 signed int v58; // ebp@124
201 Player *v59; // esi@125
202 int v60; // eax@126
203 int v61; // edx@133
204 int v62; // eax@139
205 void *v63; // ebp@145
206 signed int v64; // edi@146
207 unsigned int v65; // edx@148
208 Player *v66; // ecx@148
209 int v67; // esi@148
210 signed int v68; // eax@151
211 int v69; // esi@151
212 Player *v70; // ecx@158
213 unsigned int v71; // eax@159
214 int v72; // esi@159
215 signed int v73; // eax@162
216 int v74; // esi@162
217 int v75; // edx@172
218 Player *v76; // esi@173
219 signed int v77; // ebp@186
220 int v78; // edx@186
221 Player *v79; // esi@187
222 signed int v80; // ebp@200
223 int v81; // edx@200
224 Player *v82; // esi@201
225 int v83; // eax@212
226 int v84; // ebp@220
227 signed int v85; // ebp@224
228 char v86; // al@224
229 Player *v87; // esi@227
230 Player *v88; // ecx@231
231 int v89; // ecx@232
232 int v90; // eax@243
233 const char *v91; // ecx@247
234 int v92; // eax@251
235 char *v93; // eax@252
236 int v94; // ecx@262
237 int v95; // ebp@262
238 int v96; // edx@262
239 int v97; // eax@262
240 unsigned int v98; // edx@265
241 const char *v99; // esi@267
242 int v100; // edx@267
243 //char *v101; // edi@281
244 unsigned int v102; // esi@281
245 int v103; // edi@284
246 int v104; // eax@288
247 int v105; // edx@294
248 int v106; // [sp-20h] [bp-4C8h]@278
249 signed int v107; // [sp-1Ch] [bp-4C4h]@278
250 unsigned int v108; // [sp-18h] [bp-4C0h]@278
251 signed int v109; // [sp-14h] [bp-4BCh]@278
252 signed int v110; // [sp-10h] [bp-4B8h]@278
253 int v111; // [sp-Ch] [bp-4B4h]@278
254 // Event *v112; // [sp-8h] [bp-4B0h]@5
255 int v113; // [sp-8h] [bp-4B0h]@106
256 int v114; // [sp-8h] [bp-4B0h]@117
257 signed int v115; // [sp-8h] [bp-4B0h]@231
258 unsigned int v116; // [sp-8h] [bp-4B0h]@278
259 int v117; // [sp-4h] [bp-4ACh]@106
260 int v118; // [sp-4h] [bp-4ACh]@117
261 int v119; // [sp-4h] [bp-4ACh]@231
262 int v120; // [sp-4h] [bp-4ACh]@278
263 int v121; // [sp-4h] [bp-4ACh]@294
264 int v122; // [sp+10h] [bp-498h]@4
265 //char *v123; // [sp+14h] [bp-494h]@0
266 //signed int v124; // [sp+18h] [bp-490h]@7
267 signed int v125; // [sp+1Ch] [bp-48Ch]@155
268 int v126; // [sp+1Ch] [bp-48Ch]@262
269 int v127; // [sp+20h] [bp-488h]@4
270 int v128; // [sp+24h] [bp-484h]@21
271 int v129; // [sp+24h] [bp-484h]@262
272 signed int v130; // [sp+28h] [bp-480h]@0
273 //int v131; // [sp+2Ch] [bp-47Ch]@1
274 int v132; // [sp+30h] [bp-478h]@262
275 signed int v133; // [sp+34h] [bp-474h]@1
276 int v134; // [sp+38h] [bp-470h]@262
277 int v135; // [sp+3Ch] [bp-46Ch]@262
278 int v136; // [sp+40h] [bp-468h]@40
279 int v137; // [sp+44h] [bp-464h]@40
280 int v138; // [sp+48h] [bp-460h]@40
281 int v139; // [sp+4Ch] [bp-45Ch]@40
282 ItemGen item; // [sp+50h] [bp-458h]@15
283 char Source[120]; // [sp+74h] [bp-434h]@15
284 char Str[120]; // [sp+ECh] [bp-3BCh]@21
285 Actor Dst; // [sp+164h] [bp-344h]@53
286
287 //v131 = uEventID;
288 v133 = 0;
289 dword_5B5920 = a2;
290 dword_5B65C4 = 0;
291 if ( !a1 )
292 {
293 if ( !GameUI_StatusBar_TimedStringTimeLeft )
294 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
295 return;
296 }
297 v127 = 2 * (uActiveCharacter == 0) + 4;
298 v122 = dword_597F18;
299 if ( _5C3420_pDecoration )
300 {
301 uSomeEVT_NumEvents = uGlobalEVT_NumEvents;
302 pSomeEVT = pGlobalEVT;
303 memcpy(pSomeEVT_Events, pGlobalEVT_Index, 52800); //4400 evts
304 }
305 else
306 {
307 uSomeEVT_NumEvents = uLevelEVT_NumEvents;
308 pSomeEVT = pLevelEVT;
309 memcpy(pSomeEVT_Events, pLevelEVT_Index, 52800);
310 }
311
312
313 //v4 = 0;
314 //v124 = 0;
315 for (uint i = 0; i < uSomeEVT_NumEvents; ++i)
316 {
317 //v5 = pSomeEVT;
318 //v6 = v123;
319 //v7 = "";
320 //while ( 1 )
321 //{
322 if ( dword_5B65C4 )
323 goto LABEL_301;
324 //v8 = v4;
325 if ( pSomeEVT_Events[i/*v4*/].uEventID == uEventID && pSomeEVT_Events[i/*v4*/].event_sequence_num == v122 )
326 {
327 //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT;
328 //v10 = (ByteArray *)&v5[v9];
329 auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[i/*v4*/].uEventOffsetInEVT);
330
331 switch (_evt->v4)
332 {
333 case EVENT_CheckSeason:
334 if ( !sub_4465DF_check_season(_evt->v5) )
335 {
336 ++v122;
337 //v4 = v124;
338 //v5 = pSomeEVT;
339 //v6 = v123;
340 //v7 = "";
341 break;
342 }
343 v11 = _evt->v6;
344 goto LABEL_130;
345 case EVENT_ShowMovie:
346 {
347 strcpy(Source, (char *)&_evt->v7);
348 v12 = (char *)&item.uExpireTime + strlen(Source) + 7;
349 if ( *v12 == 32 )
350 *v12 = 0;
351 if ( pVideoPlayer->field_54 )
352 pVideoPlayer->Unload();
353 pVideoPlayer->bStopBeforeSchedule = 0;
354 pVideoPlayer->pResetflag = 0;
355 if (pAsyncMouse)
356 pAsyncMouse->Suspend();
357 v128 = pCurrentScreen;
358 //v13 = &pSomeEVT[v9];
359 //v14 = (unsigned __int8)v13[5];
360 //v15 = (unsigned __int8)v13[6];
361 v14 = _evt->v5;
362 v15 = _evt->v6;
363 strcpy(Str, Source);
364 v16 = RemoveQuotes(Str);
365 VideoPlayer::MovieLoop(v16, 0, v14, 1);
366 if ( !_strcmpi(v16, "arbiter good") )
367 {
368 pParty->uAlignment = 0;
369 v18 = 0;
370 LOBYTE(v17) = 1;
371 SetUserInterface(v18, v17);
372 if ( !v15 || v128 == 3 )
373 {
374 pCurrentScreen = v128;
375 if ( v128 == 3 )
376 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
377 if ( v128 == 13 )
378 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
379 }
380 if (pAsyncMouse)
381 pAsyncMouse->Resume();
382 ++v122;
383 //v4 = v124;
384 //v5 = pSomeEVT;
385 //v6 = v123;
386 //v7 = "";
387 break;
388 }
389 if ( !_strcmpi(v16, "arbiter evil") )
390 {
391 v18 = 2;
392 pParty->uAlignment = 2;
393 LOBYTE(v17) = 1;
394 SetUserInterface(v18, v17);
395 if ( !v15 || v128 == 3 )
396 {
397 pCurrentScreen = v128;
398 if ( v128 == 3 )
399 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
400 if ( v128 == 13 )
401 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
402 }
403 if (pAsyncMouse)
404 pAsyncMouse->Resume();
405 ++v122;
406 //v4 = v124;
407 //v5 = pSomeEVT;
408 //v6 = v123;
409 //v7 = "";
410
411 break;
412 }
413 if ( !_strcmpi(v16, "pcout01") ) // moving to harmondale from emerald isle
414 {
415 Rest(0x2760u);
416 pParty->RestAndHeal();
417 pParty->field_764 = 0;
418 }
419 if ( !v15 || v128 == 3 )
420 {
421 pCurrentScreen = v128;
422 if ( v128 == 3 )
423 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
424 if ( v128 == 13 )
425 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
426 }
427 if (pAsyncMouse)
428 pAsyncMouse->Resume();
429 ++v122;
430 //v4 = v124;
431 //v5 = pSomeEVT;
432 //v6 = v123;
433 //v7 = "";
434 }
435 break;
436 case EVENT_CheckSkill:
437 {
438 v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8);
439 if ( v127 < 0 )
440 goto LABEL_47;
441 if ( v127 <= 3 )
442 {
443 v24 = pParty->pPlayers[0].pActiveSkills[3486 * v127 + _evt->v5];
444 }
445 else
446 {
447 if ( v127 == 4 )
448 {
449 v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5];
450 }
451 else
452 {
453 if ( v127 == 5 )
454 {
455 v20 = 0;
456 v21 = 3486 * v130 + _evt->v5;
457 v136 = 1;
458 LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21];
459 v137 = v21 & 0x40;
460 v138 = v21 & 0x80;
461 v22 = v21 & 0x100;
462 v23 = v21 & 0x3F;
463 v139 = v22;
464 while ( v23 < v19 || !*(&v136 + _evt->v6) )
465 {
466 ++v20;
467 if ( v20 >= 4 )
468 {
469 ++v122;
470 //v4 = v124;
471 //v5 = pSomeEVT;
472 //v6 = v123;
473 //v7 = "";
474 break;
475 }
476 }
477 v11 = _evt->v11;
478 goto LABEL_130;
479 }
480 LABEL_47:
481 //v10 = (ByteArray *)&v5[v9];
482 v24 = pParty->pPlayers[0].pActiveSkills[_evt->v5 + 3486 * rand() % 4];
483 }
484 }
485 v136 = 1;
486 v137 = v24 & 0x40;
487 v138 = v24 & 0x80;
488 v139 = v24 & 0x100;
489 if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) )
490 {
491 v11 = _evt->v11;
492 goto LABEL_130;
493 }
494 ++v122;
495 //v4 = v124;
496 //v5 = pSomeEVT;
497 //v6 = v123;
498 //v7 = "";
499 }
500 break;
501
502 case EVENT_SpeakNPC:
503 if ( a3 )
504 {
505 //Actor::Actor(&Dst);
506 memset(&Dst, 0, 0x344u);
507 dword_5B65D0_dialogue_actor_npc_id = _evt->v5
508 + ((_evt->v6
509 + ((_evt->v7
510 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
511 Dst.uNPC_ID = dword_5B65D0_dialogue_actor_npc_id;
512 Dst.InitializeDialogue(0);
513 }
514 else
515 {
516 bDialogueUI_InitializeActor_NPC_ID = _evt->v5
517 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
518 }
519 ++v122;
520 //v4 = v124;
521 //v5 = pSomeEVT;
522 //v6 = v123;
523 //v7 = "";
524 break;
525 case EVENT_ChangeEvent:
526 v25 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
527 if ( v25 )
528 {
529 stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = _evt->v5 - 124;
530 }
531 else
532 {
533 v26 = _5C3420_pDecoration;
534 stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = 0;
535 LOBYTE(v26->field_2) |= 0x20u;
536 }
537 ++v122;
538 //v4 = v124;
539 //v5 = pSomeEVT;
540 //v6 = v123;
541 //v7 = "";
542 break;
543 case EVENT_SetNPCGreeting:
544 v27 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
545 v28 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
546 pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
547 pNPCStats->pNewNPCData[v27].greet = v28;
548 ++v122;
549 //v4 = v124;
550 //v5 = pSomeEVT;
551 //v6 = v123;
552 //v7 = "";
553 break;
554 case EVENT_SetNPCTopic:
555 v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
556 v30 = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8);
557 v31 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
558 v32 = _evt->v9;
559 v33 = &pNPCStats->pNewNPCData[v31];
560 if ( v32 )
561 {
562 v34 = v32 - 1;
563 if ( v34 )
564 {
565 v35 = v34 - 1;
566 if ( v35 )
567 {
568 v36 = v35 - 1;
569 if ( v36 )
570 {
571 v37 = v36 - 1;
572 if ( v37 )
573 {
574 if ( v37 == 1 )
575 v33->evt_F = v30;
576 }
577 else
578 {
579 v33->evt_E = v30;
580 }
581 }
582 else
583 {
584 v33->evt_D = v30;
585 }
586 }
587 else
588 {
589 v33->evt_C = v30;
590 }
591 }
592 else
593 {
594 v33->evt_B = v30;
595 }
596 }
597 else
598 {
599 v33->evt_A = v30;
600 }
601 if ( v29 == 8 )
602 {
603 if ( v30 == 78 )
604 {
605 sub_4BD8B5();
606 ptr_507BC0->Release();
607 pParty->uFlags &= 0xFFFFFFFDu;
608 if ( EnterHouse((enum HOUSE_TYPE)170) )
609 {
610 pAudioPlayer->StopChannels(-1, -1);
611 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
612 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
613 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
614 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
615 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
616 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
617 ptr_F8B1E8 = pNPCTopics[90].pText;
618 }
619 }
620 }
621 ++v122;
622 //v4 = v124;
623 //v5 = pSomeEVT;
624 //v6 = v123;
625 //v7 = "";
626 break;
627 case EVENT_NPCSetItem:
628 sub_448518_npc_set_item(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
629 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
630 ++v122;
631 //v4 = v124;
632 //v5 = pSomeEVT;
633 //v6 = v123;
634 //v7 = "";
635 break;
636 case EVENT_SetActorItem:
637 Actor::GiveItem(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
638 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
639 ++v122;
640 //v4 = v124;
641 //v5 = pSomeEVT;
642 //v6 = v123;
643 //v7 = "";
644 break;
645 case EVENT_SetNPCGroupNews:
646 pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8);
647 ++v122;
648 //v4 = v124;
649 //v5 = pSomeEVT;
650 //v6 = v123;
651 //v7 = "";
652 break;
653 case EVENT_SetActorGroup:
654 __debugbreak();
655 *(&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);
656 ++v122;
657 //v4 = v124;
658 //v5 = pSomeEVT;
659 //v6 = v123;
660 //v7 = "";
661 break;
662 case EVENT_ChangeGroup:
663 v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
664 v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
665 v40 = uNumActors;
666 __debugbreak();
667 if ( (signed int)uNumActors > 0 )
668 {
669 v41 = pActors;//[0].uGroup;
670 do
671 {
672 if ( v41->uGroup == v38 )
673 v41->uGroup = v39;
674 ++v41;
675 --v40;
676 }
677 while ( v40 );
678 }
679 ++v122;
680 //v4 = v124;
681 //v5 = pSomeEVT;
682 //v6 = v123;
683 //v7 = "";
684 break;
685 case EVENT_ChangeGroupAlly:
686 v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
687 v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
688 v44 = uNumActors;
689 __debugbreak();
690 if ( (signed int)uNumActors > 0 )
691 {
692 v45 = pActors;//[0].uAlly;
693 do
694 {
695 if ( v45->uGroup == v42 )
696 v45->uAlly = v43;
697 ++v45;
698 --v44;
699 }
700 while ( v44 );
701 }
702 ++v122;
703 //v4 = v124;
704 //v5 = pSomeEVT;
705 //v6 = v123;
706 //v7 = "";
707 break;
708 case EVENT_MoveNPC:
709 pNPCStats->pNewNPCData[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)].Location2D = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
710 if ( ptr_507BC0 )
711 {
712 v46 = ptr_507BC0->ptr_1C;
713 if ( v46 == (void *)165 )
714 {
715 sub_4BD8B5();
716 pVideoPlayer->Unload();
717 ptr_507BC0->Release();
718 pParty->uFlags &= 0xFFFFFFFDu;
719 _5C3420_pDecoration = (LevelDecoration *)1;
720 if ( EnterHouse((enum HOUSE_TYPE)165) )
721 {
722 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
723 v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
724 ptr_507BC0 = v47;
725 v48 = v47->pControlsHead;
726 if ( v48 )
727 {
728 do
729 {
730 v49 = v48->pNext;
731 pAllocator->FreeChunk(v48);
732 v48 = v49;
733 }
734 while ( v49 );
735 v47 = ptr_507BC0;
736 }
737 v47->pControlsHead = 0;
738 ptr_507BC0->pControlsTail = 0;
739 ptr_507BC0->uNumControls = 0;
740 }
741 }
742 else
743 {
744 if ( v46 == (void *)553 )
745 pVideoPlayer->bLoopPlaying = 0;
746 }
747 }
748 ++v122;
749 //v4 = v124;
750 //v5 = pSomeEVT;
751 //v6 = v123;
752 //v7 = "";
753 break;
754 case EVENT_Jmp:
755 //v124 = -1;
756 v122 = _evt->v5 - 1;
757 ++v122;
758 //v4 = v124;
759 //v5 = pSomeEVT;
760 //v6 = v123;
761 //v7 = "";
762 break;
763 case EVENT_ShowFace:
764 v50 = _evt->v5;
765 if ( (unsigned __int8)v50 <= 3u )
766 {
767 v117 = 0;
768 v113 = _evt->v6;
769 v53 = (unsigned __int8)v50;
770 v52 = &pParty->pPlayers[v53];
771 v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
772 ++v122;
773 //v4 = v124;
774 //v5 = pSomeEVT;
775 //v6 = v123;
776 //v7 = "";
777 break;
778 }
779 if ( v50 == 4 )
780 {
781 v117 = 0;
782 v113 = _evt->v6;
783 v52 = pPlayers[uActiveCharacter];
784 v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
785 ++v122;
786 //v4 = v124;
787 //v5 = pSomeEVT;
788 //v6 = v123;
789 //v7 = "";
790 break;
791 }
792 if ( v50 != 5 )
793 {
794 v117 = 0;
795 v113 = _evt->v6;
796 v53 = rand() % 4;
797 v52 = &pParty->pPlayers[v53];
798 v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
799 ++v122;
800 //v4 = v124;
801 //v5 = pSomeEVT;
802 //v6 = v123;
803 //v7 = "";
804 break;
805 }
806 v51 = pParty->pPlayers;
807 do
808 {
809 v51->PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
810 ++v51;
811 }
812 while ( (signed int)v51 < (signed int)pParty->pHirelings );
813 //LABEL_291:
814 ++v122;
815 //v4 = v124;
816 //v5 = pSomeEVT;
817 //v6 = v123;
818 //v7 = "";
819 break;
820 case EVENT_CharacterAnimation:
821 v54 = _evt->v5;
822 if ( (unsigned __int8)v54 <= 3u )
823 {
824 v118 = 0;
825 v114 = _evt->v6;
826 v57 = (unsigned __int8)v54;
827 goto LABEL_119;
828 }
829 if ( v54 == 4 )
830 {
831 v118 = 0;
832 v114 = _evt->v6;
833 v56 = pPlayers[uActiveCharacter];
834 goto LABEL_120;
835 }
836 if ( v54 != 5 )
837 {
838 v118 = 0;
839 v114 = _evt->v6;
840 v57 = rand() % 4;
841 LABEL_119:
842 v56 = &pParty->pPlayers[v57];
843 LABEL_120:
844 v56->PlaySound((PlayerSpeech)v114, v118);
845 ++v122;
846 //v4 = v124;
847 //v5 = pSomeEVT;
848 //v6 = v123;
849 //v7 = "";
850 break;
851 }
852 v55 = pParty->pPlayers;
853 for (int iii = 0; iii < 4; ++iii)
854 {
855 v55->PlaySound((PlayerSpeech)_evt->v6, 0);
856 ++v55;
857 }
858 //while ( (signed int)v55 < (signed int)pParty->pHirelings );
859 ++v122;
860 //v4 = v124;
861 //v5 = pSomeEVT;
862 //v6 = v123;
863 //v7 = "";
864 break;
865 case EVENT_ForPartyMember:
866 v127 = _evt->v5;
867 ++v122;
868 //v4 = v124;
869 //v5 = pSomeEVT;
870 //v6 = v123;
871 //v7 = "";
872 break;
873 case EVENT_SummonItem:
874 sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
875 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
876 _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8),
877 _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8),
878 _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8),
879 _evt->v25, _evt->v26, 0, 0);
880 ++v122;
881 //v4 = v124;
882 //v5 = pSomeEVT;
883 //v6 = v123;
884 //v7 = "";
885 break;
886 case EVENT_Compare:
887 v58 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
888 if ( v127 == 5 )
889 {
890 v130 = 0;
891 v59 = pParty->pPlayers;
892 while ( 1 )
893 {
894 LOBYTE(v60) = v59->CompareVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v58);
895 if ( v60 )
896 break;
897 ++v130;
898 ++v59;
899 if ( (signed int)v59 >= (signed int)pParty->pHirelings )
900 {
901 ++v122;
902 //v4 = v124;
903 //v5 = pSomeEVT;
904 //v6 = v123;
905 //v7 = "";
906 break;
907 }
908 }
909 LABEL_129:
910 v11 = _evt->v11;
911 goto LABEL_130;
912 }
913 if ( v127 < 0 )
914 goto LABEL_139;
915 v61 = v127;
916 if ( v127 <= 3 )
917 goto LABEL_137;
918 if ( v127 == 4 )
919 {
920 if ( uActiveCharacter )
921 {
922 v6 = pPlayers[uActiveCharacter];
923 goto LABEL_138;
924 }
925 }
926 else
927 {
928 if ( v127 != 6 )
929 goto LABEL_139;
930 }
931 v61 = rand() % 4;
932 //v5 = pSomeEVT;
933 LABEL_137:
934 v6 = &pParty->pPlayers[v61];
935 LABEL_138:
936 //v123 = v6;
937 LABEL_139:
938 LOBYTE(v62) = ((Player *)v6)->CompareVariable(
939 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
940 v58);
941 LABEL_140:
942 if ( v62 )
943 goto LABEL_129;
944 ++v122;
945 //v4 = v124;
946 //v5 = pSomeEVT;
947 //v6 = v123;
948 //v7 = "";
949 break;
950 case EVENT_IsActorAlive:
951 v62 = IsActorAlive(
952 _evt->v5,
953 _evt->v6 + ((_evt->v7 + ((_evt->v8 + ((uint)_evt->v9 << 8)) << 8)) << 8),
954 _evt->v10);
955 goto LABEL_140;
956 case EVENT_Substract:
957 v63 = (void *)(_evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8));
958 if ( _evt->v5 + ((uint)_evt->v6 << 8) == VAR_PlayerItemInHands )
959 {
960 v64 = 0;
961 if ( (void *)pParty->pPickedItem.uItemID == v63 )
962 {
963 pMouse->RemoveHoldingItem();
964 ++v122;
965 //v4 = v124;
966 //v5 = pSomeEVT;
967 //v6 = v123;
968 //v7 = "";
969 break;
970 }
971 v65 = 0;
972 v66 = pPlayers[uActiveCharacter];
973 v67 = (int)v66->pInventoryIndices;
974 do
975 {
976 if ( *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 )
977 {
978 v66->RemoveItemAtInventoryIndex(v65);
979 ++v122;
980 //v4 = v124;
981 //v5 = pSomeEVT;
982 //v6 = v123;
983 //v7 = "";
984 break;
985 }
986 ++v65;
987 v67 += 4;
988 }
989 while ( (signed int)v65 < 126 );
990 v68 = 0;
991 v69 = (int)&v66->pEquipment;
992 do
993 {
994 if ( *(int *)v69 && *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 )
995 {
996 *(&v66->pEquipment.uOffHand + v68) = 0;
997 ++v122;
998 //v4 = v124;
999 //v5 = pSomeEVT;
1000 //v6 = v123;
1001 //v7 = "";
1002 break;
1003 }
1004 ++v68;
1005 v69 += 4;
1006 }
1007 while ( v68 < 16 );
1008 v125 = (signed int)&pPlayers[1];
1009 while ( 1 )
1010 {
1011 v70 = *(Player **)v125;
1012 if ( !v64 )
1013 {
1014 v71 = 0;
1015 v72 = (int)v70->pInventoryIndices;
1016 do
1017 {
1018 if ( *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 )
1019 {
1020 v70->RemoveItemAtInventoryIndex(v71);
1021 goto LABEL_169;
1022 }
1023 ++v71;
1024 v72 += 4;
1025 }
1026 while ( (signed int)v71 < 126 );
1027 v73 = 0;
1028 v74 = (int)&v70->pEquipment;
1029 while ( !*(int *)v74
1030 || *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 )
1031 {
1032 ++v73;
1033 v74 += 4;
1034 if ( v73 >= 16 )
1035 goto LABEL_170;
1036 }
1037 *(&v70->pEquipment.uOffHand + v73) = 0;
1038 LABEL_169:
1039 v64 = 1;
1040 }
1041 LABEL_170:
1042 v125 += 4;
1043 if ( v125 > (signed int)&pPlayers[4] )
1044 {
1045 ++v122;
1046 //v4 = v124;
1047 //v5 = pSomeEVT;
1048 //v6 = v123;
1049 //v7 = "";
1050 break;
1051 }
1052 }
1053 }
1054 v75 = v127;
1055 if ( v127 != 5 )
1056 {
1057 if ( v127 < 0 )
1058 goto LABEL_183;
1059 if ( v127 > 3 )
1060 {
1061 if ( v127 != 4 )
1062 {
1063 if ( v127 == 6 )
1064 goto LABEL_180;
1065 LABEL_183:
1066 ((Player *)v6)->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
1067 ++v122;
1068 //v4 = v124;
1069 //v5 = pSomeEVT;
1070 //v6 = v123;
1071 //v7 = "";
1072 break;
1073 }
1074 if ( uActiveCharacter )
1075 {
1076 v6 = pPlayers[uActiveCharacter];
1077 goto LABEL_182;
1078 }
1079 LABEL_180:
1080 v75 = rand() % 4;
1081 //v5 = pSomeEVT;
1082 }
1083 v6 = &pParty->pPlayers[v75];
1084 LABEL_182:
1085 //v123 = v6;
1086 goto LABEL_183;
1087 }
1088 v76 = pParty->pPlayers;
1089 v130 = 4;
1090 do
1091 {
1092 v76->SubtractVariable(
1093 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
1094 v63);
1095 ++v76;
1096 }
1097 while ( (signed int)v76 < (signed int)pParty->pHirelings );
1098 ++v122;
1099 //v4 = v124;
1100 //v5 = pSomeEVT;
1101 //v6 = v123;
1102 //v7 = "";
1103 break;
1104 case EVENT_Set:
1105 v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1106 v78 = v127;
1107 if ( v127 != 5 )
1108 {
1109 if ( v127 < 0 )
1110 goto LABEL_197;
1111 if ( v127 > 3 )
1112 {
1113 if ( v127 != 4 )
1114 {
1115 if ( v127 == 6 )
1116 goto LABEL_194;
1117 LABEL_197:
1118 ((Player *)v6)->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77);
1119 ++v122;
1120 //v4 = v124;
1121 //v5 = pSomeEVT;
1122 //v6 = v123;
1123 //v7 = "";
1124 break;
1125 }
1126 if ( uActiveCharacter )
1127 {
1128 v6 = pPlayers[uActiveCharacter];
1129 goto LABEL_196;
1130 }
1131 LABEL_194:
1132 v78 = rand() % 4;
1133 //v5 = pSomeEVT;
1134 }
1135 v6 = &pParty->pPlayers[v78];
1136 LABEL_196:
1137 //v123 = v6;
1138 goto LABEL_197;
1139 }
1140 v79 = pParty->pPlayers;
1141 v130 = 4;
1142 do
1143 {
1144 v79->SetVariable(
1145 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
1146 v77);
1147 ++v79;
1148 }
1149 while ( (signed int)v79 < (signed int)pParty->pHirelings );
1150 ++v122;
1151 //v4 = v124;
1152 //v5 = pSomeEVT;
1153 //v6 = v123;
1154 //v7 = "";
1155 break;
1156 case EVENT_Add:
1157 v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1158 v81 = v127;
1159 if ( v127 != 5 )
1160 {
1161 if ( v127 < 0 )
1162 goto LABEL_211;
1163 if ( v127 > 3 )
1164 {
1165 if ( v127 != 4 )
1166 {
1167 if ( v127 == 6 )
1168 goto LABEL_208;
1169 LABEL_211:
1170 ((Player *)v6)->AddVariable(
1171 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
1172 v80);
1173 goto LABEL_212;
1174 }
1175 if ( uActiveCharacter )
1176 {
1177 v6 = pPlayers[uActiveCharacter];
1178 goto LABEL_210;
1179 }
1180 LABEL_208:
1181 v81 = rand() % 4;
1182 //v5 = pSomeEVT;
1183 }
1184 v6 = &pParty->pPlayers[v81];
1185 LABEL_210:
1186 //v123 = v6;
1187 goto LABEL_211;
1188 }
1189 v82 = pParty->pPlayers;
1190 v130 = 4;
1191 do
1192 {
1193 v82->AddVariable(
1194 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
1195 v80);
1196 ++v82;
1197 }
1198 while ( (signed int)v82 < (signed int)pParty->pHirelings );
1199 LABEL_212:
1200 v83 = _evt->v5 + ((uint)_evt->v6 << 8);
1201 if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
1202 viewparams->bRedrawGameUI = 1;
1203 ++v122;
1204 //v4 = v124;
1205 //v5 = pSomeEVT;
1206 //v6 = v123;
1207 //v7 = "";
1208 break;
1209 case EVENT_InputString:
1210 if ( !dword_597F18 )
1211 {
1212 strcpy(
1213 GameUI_StatusBar_TimedString,
1214 &pLevelStr[pLevelStrOffsets[_evt->v5
1215 + ((_evt->v6
1216 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)]]);
1217 v105 = v122;
1218 v121 = 26;
1219 LABEL_295:
1220 sub_4451A8_press_any_key(uEventID, v105, v121);
1221 LABEL_301:
1222 if ( v133 == 1 )
1223 LABEL_302:
1224 OnMapLeave();
1225 return;
1226 }
1227 v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
1228 if ( !_strcmpi(
1229 GameUI_StatusBar_TimedString,
1230 &pLevelStr[pLevelStrOffsets[_evt->v9
1231 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]])
1232 || !_strcmpi(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[v84]]) )
1233 {
1234 v11 = _evt->v17;
1235 LABEL_130:
1236 //v124 = -1;
1237 LABEL_131:
1238 v122 = v11 - 1;
1239 }
1240 ++v122;
1241 //v4 = v124;
1242 //v5 = pSomeEVT;
1243 //v6 = v123;
1244 //v7 = "";
1245 break;
1246 case EVENT_RandomGoTo:
1247 //v124 = -1;
1248 v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0)
1249 + (_evt->v10 != 0)));
1250 goto LABEL_131;
1251 case EVENT_ReceiveDamage:
1252 v85 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1253 v86 = _evt->v5;
1254 if ( (unsigned __int8)v86 <= 3u )
1255 {
1256 v119 = _evt->v6;
1257 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1258 v89 = (unsigned __int8)v86;
1259 goto LABEL_233;
1260 }
1261 if ( v86 == 4 )
1262 {
1263 if ( !uActiveCharacter )
1264 {
1265 ++v122;
1266 //v4 = v124;
1267 //v5 = pSomeEVT;
1268 //v6 = v123;
1269 //v7 = "";
1270 break;
1271 }
1272 v119 = _evt->v6;
1273 v88 = pPlayers[uActiveCharacter];
1274 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1275 goto LABEL_234;
1276 }
1277 if ( v86 != 5 )
1278 {
1279 v119 = _evt->v6;
1280 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v1 << 8)) << 8)) << 8);
1281 v89 = rand() % 4;
1282 LABEL_233:
1283 v88 = &pParty->pPlayers[v89];
1284 LABEL_234:
1285 v88->ReceiveDamage(v115, v119);
1286 ++v122;
1287 //v4 = v124;
1288 //v5 = pSomeEVT;
1289 //v6 = v123;
1290 //v7 = "";
1291 break;
1292 }
1293 v87 = pParty->pPlayers;
1294 do
1295 {
1296 v87->ReceiveDamage(v85, _evt->v6);
1297 ++v87;
1298 }
1299 while ( (signed int)v87 < (signed int)pParty->pHirelings );
1300 ++v122;
1301 //v4 = v124;
1302 //v5 = pSomeEVT;
1303 //v6 = v123;
1304 //v7 = "";
1305 break;
1306 case EVENT_ToggleIndoorLight:
1307 pIndoor->ToggleLight(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9);
1308 ++v122;
1309 //v4 = v124;
1310 //v5 = pSomeEVT;
1311 //v6 = v123;
1312 //v7 = "";
1313 break;
1314 case EVENT_SetFacesBit:
1315 sub_44892E_set_faces_bit(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
1316 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
1317 ++v122;
1318 //v4 = v124;
1319 //v5 = pSomeEVT;
1320 //v6 = v123;
1321 //v7 = "";
1322 break;
1323 case EVENT_ToggleChestFlag:
1324 Chest::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
1325 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
1326 ++v122;
1327 //v4 = v124;
1328 //v5 = pSomeEVT;
1329 //v6 = v123;
1330 //v7 = "";
1331 break;
1332 case EVENT_ToggleActorFlag:
1333 Actor::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
1334 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
1335 ++v122;
1336 //v4 = v124;
1337 //v5 = pSomeEVT;
1338 //v6 = v123;
1339 //v7 = "";
1340 break;
1341 case EVENT_ToggleActorGroupFlag:
1342 ToggleActorGroupFlag(
1343 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
1344 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
1345 _evt->v13);
1346 ++v122;
1347 //v4 = v124;
1348 //v5 = pSomeEVT;
1349 //v6 = v123;
1350 //v7 = "";
1351 break;
1352 case EVENT_SetSnow:
1353 if ( !_evt->v5 )
1354 pWeather->bRenderSnow = _evt->v6 != 0;
1355 ++v122;
1356 //v4 = v124;
1357 //v5 = pSomeEVT;
1358 //v6 = v123;
1359 //v7 = "";
1360 break;
1361 case EVENT_StatusText:
1362 v90 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1363 if ( _5C3420_pDecoration )
1364 {
1365 if ( _5C3420_pDecoration == (LevelDecoration *)1 )
1366 {
1367 ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
1368 ++v122;
1369 //v4 = v124;
1370 //v5 = pSomeEVT;
1371 //v6 = v123;
1372 //v7 = "";
1373 break;
1374 }
1375 if ( a3 == 1 )
1376 {
1377 v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
1378 //LABEL_248:
1379 ShowStatusBarString(v91, 2u);
1380 ++v122;
1381 //v4 = v124;
1382 //v5 = pSomeEVT;
1383 //v6 = v123;
1384 //v7 = "";
1385 break;
1386 }
1387 }
1388 else
1389 {
1390 if ( a3 == 1 )
1391 {
1392 v91 = &pLevelStr[pLevelStrOffsets[v90]];
1393 ShowStatusBarString(v91, 2u);
1394 ++v122;
1395 //v4 = v124;
1396 //v5 = pSomeEVT;
1397 //v6 = v123;
1398 //v7 = "";
1399 break;
1400 }
1401 }
1402 ++v122;
1403 //v4 = v124;
1404 //v5 = pSomeEVT;
1405 //v6 = v123;
1406 //v7 = "";
1407 break;
1408 case EVENT_ShowMessage:
1409 v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1410 if ( _5C3420_pDecoration )
1411 {
1412 v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92];
1413 byte_5B0938[0] = 0;
1414 ptr_F8B1E8 = v93;
1415 }
1416 else
1417 {
1418 strcpy(byte_5B0938, &pLevelStr[pLevelStrOffsets[v92]]);
1419 }
1420 ++v122;
1421 //v4 = v124;
1422 //v5 = pSomeEVT;
1423 //v6 = v123;
1424 //v7 = "";
1425 break;
1426 case EVENT_CastSpell:
1427 sub_448DF8_cast_spell(_evt->v5, _evt->v6, _evt->v7, _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
1428 _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
1429 _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
1430 _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
1431 _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8),
1432 _evt->v28 + ((_evt->v29 + ((_evt->v30 + ((uint)_evt->v31 << 8)) << 8)) << 8));
1433 ++v122;
1434 //v4 = v124;
1435 //v5 = pSomeEVT;
1436 //v6 = v123;
1437 //v7 = "";
1438 break;
1439 case EVENT_SetTexture:
1440 sub_44861E_set_texture(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), (char *)&_evt->v9);
1441 ++v122;
1442 //v4 = v124;
1443 //v5 = pSomeEVT;
1444 //v6 = v123;
1445 //v7 = "";
1446 break;
1447 case EVENT_SetSprite:
1448 SetDecorationSprite(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9, (char *)&_evt->v10);
1449 ++v122;
1450 //v4 = v124;
1451 //v5 = pSomeEVT;
1452 //v6 = v123;
1453 //v7 = "";
1454 break;
1455 case EVENT_SummonMonsters:
1456 sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,
1457 _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
1458 _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
1459 _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
1460 _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
1461 _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8));
1462 ++v122;
1463 //v4 = v124;
1464 //v5 = pSomeEVT;
1465 //v6 = v123;
1466 //v7 = "";
1467 break;
1468 case EVENT_MouseOver:
1469 case EVENT_LocationName:
1470 --v122;
1471 ++v122;
1472 //v4 = v124;
1473 //v5 = pSomeEVT;
1474 //v6 = v123;
1475 //v7 = "";
1476 break;
1477 case EVENT_ChangeDoorState:
1478 sub_449A49_door_switch_animation(_evt->v5, _evt->v6);
1479 ++v122;
1480 //v4 = v124;
1481 //v5 = pSomeEVT;
1482 //v6 = v123;
1483 //v7 = "";
1484 break;
1485 case EVENT_OpenChest:
1486 if ( !Chest::Open(_evt->v5) )
1487 goto LABEL_301;
1488 ++v122;
1489 //v4 = v124;
1490 //v5 = pSomeEVT;
1491 //v6 = v123;
1492 //v7 = "";
1493 break;
1494 case EVENT_MoveToMap:
1495 v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1496 v135 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1497 v132 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
1498 v126 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
1499 v129 = _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8);
1500 v95 = _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8);
1501 v96 = _evt->v25;
1502 v97 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8);
1503 v134 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8);
1504 if ( _evt->v29 || _evt->v30 )
1505 {
1506 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
1507 pRenderer->_49FD3A();
1508 sub_444839_move_map(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31);
1509 dword_5C3418 = uEventID;
1510 dword_5C341C = v122 + 1;
1511 goto LABEL_301;
1512 }
1513 _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
1514 _5B65A8_npcdata_uflags_or_other = v94;
1515 _5B65B0_npcdata_rep_or_other = v126;
1516 if ( v129 == -1 )
1517 {
1518 v98 = _5B65B4_npcdata_loword_house_or_other;
1519 }
1520 else
1521 {
1522 v98 = v129 & stru_5C6E00->uDoublePiMask;
1523 _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask;
1524 }
1525 v99 = (char *)&_evt->v31;
1526 _5B65B8_npcdata_hiword_house_or_other = v95;
1527 dword_5B65BC = v97;
1528 v100 = v94 | v132 | v126 | v95 | v97 | v98;
1529 dword_5B65C0 = v100;
1530 if ( *v99 == 48 )
1531 {
1532 if ( v100 )
1533 {
1534 pParty->vPosition.x = v135;
1535 pParty->vPosition.y = v132;
1536 pParty->vPosition.z = v126;
1537 pParty->uFallStartY = v126;
1538 if ( _5B65B4_npcdata_loword_house_or_other != -1 )
1539 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
1540 _5B65B4_npcdata_loword_house_or_other = -1;
1541 v120 = 0;
1542 v116 = 0;
1543 v111 = 0;
1544 v110 = 0;
1545 v109 = -1;
1546 v108 = 0;
1547 v107 = 0;
1548 pParty->sRotationX = v95;
1549 pParty->uFallSpeed = v134;
1550 dword_5B65C0 = 0;
1551 dword_5B65BC = 0;
1552 _5B65B8_npcdata_hiword_house_or_other = 0;
1553 _5B65B0_npcdata_rep_or_other = 0;
1554 _5B65AC_npcdata_fame_or_other = 0;
1555 _5B65A8_npcdata_uflags_or_other = 0;
1556 v106 = 232;
1557 LABEL_280:
1558 pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120);
1559 }
1560 }
1561 else
1562 {
1563 pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((_5C3420_pDecoration == 0) + 1);
1564 sub_44987B(v99, 0);
1565 v133 = 1;
1566 if ( pCurrentScreen == SCREEN_HOUSE )
1567 {
1568 if ( uGameState == 2 )
1569 {
1570 pAudioPlayer->StopChannels(-1, -1);
1571 dword_F8B19C = 0;
1572 while ( sub_4BD8B5() )
1573 ;
1574 pVideoPlayer->Unload();
1575 ptr_507BC0->Release();
1576 ptr_507BC0 = 0;
1577 if ( pMessageQueue_50CBD0->uNumMessages )
1578 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1579 pCurrentScreen = SCREEN_GAME;
1580 viewparams->bRedrawGameUI = 1;
1581 array_5913D8[6] = 0;
1582 pDialogueWindow->Release();
1583 dword_F8B19C = 0;
1584 pDialogueWindow = 0;
1585 pIcons_LOD->_40F9C5();
1586 }
1587 goto LABEL_302;
1588 }
1589 }
1590 ++v122;
1591 //v4 = v124;
1592 //v5 = pSomeEVT;
1593 //v6 = v123;
1594 //v7 = "";
1595 break;
1596 case EVENT_PlaySound:
1597 v120 = 0;
1598 v116 = 0;
1599 v111 = 0;
1600 v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
1601 v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
1602 v108 = 0;
1603 v107 = 0;
1604 v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1605 goto LABEL_280;
1606 case EVENT_GiveItem:
1607 item.Reset();
1608 //v101 = &pSomeEVT[v9];
1609 v102 = _evt->v7
1610 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
1611 pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item);
1612 if ( v102 )
1613 item.uItemID = v102;
1614 pParty->SetHoldingItem(&item);
1615 ++v122;
1616 //v4 = v124;
1617 //v5 = pSomeEVT;
1618 //v6 = v123;
1619 //v7 = "";
1620 break;
1621 case EVENT_SpeakInHouse:
1622 v103 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
1623 if ( EnterHouse((enum HOUSE_TYPE)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
1624 {
1625 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
1626 pRenderer->_49FD3A();
1627 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
1628 pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0);
1629 v104 = 187;
1630 if ( uCurrentHouse_Animation != 167 )
1631 v104 = v103;
1632 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
1633 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
1634 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
1635 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
1636 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
1637 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
1638 }
1639 ++v122;
1640 //v4 = v124;
1641 //v5 = pSomeEVT;
1642 //v6 = v123;
1643 //v7 = "";
1644 break;
1645 case EVENT_PressAnyKey:
1646 v121 = 33;
1647 v105 = v122 + 1;
1648 goto LABEL_295;
1649 case EVENT_Exit:
1650 goto LABEL_301;
1651 default:
1652 ++v122;
1653 //v4 = v124;
1654 //v5 = pSomeEVT;
1655 //v6 = v123;
1656 //v7 = "";
1657 break;
1658 }
1659 }
1660 //++v4;
1661 //v124 = v4;
1662 //if ( v4 >= (signed int)uSomeEVT_NumEvents )
1663 //goto LABEL_301;
1664 //}
1665 }
1666 }
1667