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