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