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