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