Mercurial > mm7
annotate Arcomage.cpp @ 2459:e5c88c2b02ab
Audio_GetFirstHardwareDigitalDriver
author | Ritor1 |
---|---|
date | Wed, 30 Jul 2014 11:19:53 +0600 |
parents | 2a8010d99cf8 |
children | 104fdbea0386 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2216
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include <string> |
2336 | 7 #include "mm7_unsorted_subs.h" |
0 | 8 |
1254 | 9 #include "Render.h" |
0 | 10 #include "Arcomage.h" |
2450 | 11 #include "MediaPlayer.h" |
0 | 12 #include "AudioPlayer.h" |
13 #include "Mouse.h" | |
14 #include "Game.h" | |
15 #include "Viewport.h" | |
2044 | 16 #include "Timer.h" |
0 | 17 #include "GUIFont.h" |
18 #include "Party.h" | |
19 #include "GUIWindow.h" | |
20 #include "Events2D.h" | |
21 #include "VectorTypes.h" | |
189 | 22 #include "texts.h" |
1183 | 23 #include <windef.h> |
1262 | 24 #include "mm7_data.h" |
2453 | 25 #include "UI/UIHouses.h" |
0 | 26 |
27 | |
28 | |
1197 | 29 void SetStartConditions(); |
30 void SetStartGameData(); | |
31 void FillPlayerDeck(); | |
1200 | 32 void InitalHandsFill(); |
33 void GetNextCardFromDeck(int player_num); | |
1185 | 34 int GetEmptyCardSlotIndex(int player_num); |
1197 | 35 void IncreaseResourcesInTurn(int player_num); |
1263 | 36 void TurnChange(); |
1256 | 37 bool IsGameOver(); |
38 int CalculateCardPower(ArcomagePlayer* player, ArcomagePlayer* enemy, ArcomageCard* pCard, int mastery); | |
39 char PlayerTurn(int player_num); | |
1263 | 40 void DrawGameUI(int animation_stage); |
41 void DrawSparks(); | |
1197 | 42 void DrawRectanglesForText(); |
43 void DrawPlayersText(); | |
1263 | 44 void DrawPlayerLevels(int a1, char *text, POINT *pXY); |
45 void DrawBricksCount(int a1, char* text, POINT *pXY); | |
1197 | 46 void DrawGemsCount(int a1, char* text, POINT* pXY); |
1263 | 47 void DrawBeastsCount(int a1, char *text, POINT *pXY); |
1209 | 48 void DrawPlayersTowers(); |
49 void DrawPlayersWall(); | |
50 void DrawCards(); | |
1218 | 51 void DrawCardAnimation(int a1); |
1185 | 52 int GetPlayerHandCardCount(int player_num); |
1679 | 53 int DrawCardsRectangles(int player_num); |
54 bool DiscardCard(int player_num, int card_slot_index); | |
55 bool PlayCard(int player_num, int card_slot_num); | |
1200 | 56 bool CanCardBePlayed(int player_num, int hand_card_indx); |
1263 | 57 void ApplyCardToPlayer(int player_num, unsigned int uCardID); |
1185 | 58 int am_40D2B4(POINT* a1, int a2); // weak |
1246 | 59 int ApplyDamageToBuildings(int player_num, int damage); // weak |
1218 | 60 void GameResultsApply(); |
1183 | 61 |
1679 | 62 void am_DrawText(int a1, const char *pText, POINT *pXY); |
2154 | 63 void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb |
64 void am_EndScene(); | |
1263 | 65 void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill); |
1679 | 66 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ); |
67 void DrawPixel(POINT *pTargetXY, unsigned __int16 uColor); | |
1263 | 68 int rand_interval(int min, int max); // idb |
1679 | 69 void __fastcall am_IntToString(int val, char *pOut); |
938 | 70 |
1393 | 71 //----- (0040DEDB) -------------------------------------------------------- |
72 unsigned int R8G8B8_to_TargetFormat(int uColor) | |
73 { | |
2069 | 74 return Color16(LOBYTE(uColor), BYTE1(uColor), BYTE2(uColor)); |
1393 | 75 } |
76 | |
938 | 77 /* 388 */ |
78 #pragma pack(push, 1) | |
1197 | 79 struct ArcomageStartConditions |
938 | 80 { |
1197 | 81 __int16 max_tower; |
82 __int16 max_resources; | |
83 __int16 tower_height; | |
84 __int16 wall_height; | |
85 __int16 quarry_level; | |
86 __int16 magic_level; | |
1200 | 87 __int16 zoo_level; |
1197 | 88 __int16 bricks_amount; |
89 __int16 gems_amount; | |
90 __int16 beasts_amount; | |
1256 | 91 int mastery_lvl; |
938 | 92 }; |
93 #pragma pack(pop) | |
1256 | 94 const ArcomageStartConditions start_conditions[13] = |
938 | 95 { |
96 { 30, 100, 15, 5, 2, 2, 2, 10, 10, 10, 0}, | |
97 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 1}, | |
98 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 2}, | |
99 { 75, 200, 25, 10, 3, 3, 3, 5, 5, 5, 2}, | |
100 { 75, 200, 20, 10, 3, 3, 3, 5, 5, 5, 1}, | |
101 {100, 300, 30, 15, 4, 4, 4, 10, 10, 10, 1}, | |
102 {100, 300, 30, 15, 4, 4, 4, 10, 10, 10, 2}, | |
103 {150, 400, 20, 10, 5, 5, 5, 25, 25, 25, 0}, | |
104 {200, 500, 20, 10, 1, 1, 1, 15, 15, 15, 2}, | |
105 {100, 300, 20, 50, 1, 1, 5, 5, 5, 25, 0}, | |
106 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 2}, | |
107 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 1}, | |
108 {100, 300, 50, 50, 5, 3, 5, 20, 10, 20, 0} | |
109 }; | |
110 | |
1184 | 111 #define SIG_trpg 0x67707274 |
112 #define SIG_xxxx 0x78787878 | |
0 | 113 |
114 ArcomageGame *pArcomageGame = new ArcomageGame; | |
1194 | 115 |
1679 | 116 ArcomagePlayer am_Players[2]; // 00505708 |
117 AcromageCardOnTable shown_cards[10]; // 004FAA78 | |
118 stru272 array_4FABD0[10]; // 4FABD0 | |
119 | |
120 | |
121 ArcomageDeck playDeck; // 00505288 | |
122 ArcomageDeck deckMaster; // 005054C8 | |
1201 | 123 |
124 char Player2Name[] = "Enemy"; | |
125 char Player1Name[] = "Player"; | |
0 | 126 |
127 /* 267 */ | |
128 #pragma pack(push, 1) | |
129 struct stru273 | |
130 { | |
131 bool _40DD2F(); | |
1185 | 132 bool Inside(RECT*pXYZW); |
0 | 133 |
134 int x; | |
135 int y; | |
1263 | 136 char curr_mouse_left; |
137 char mouse_left_state_changed; | |
138 char curr_mouse_right; | |
139 char mouse_right_state_changed; | |
0 | 140 }; |
141 #pragma pack(pop) | |
142 | |
1186 | 143 |
1256 | 144 #pragma pack(push, 1) |
145 struct am_2 | |
146 { | |
147 int slot_index; | |
148 int card_power; | |
149 }; | |
150 #pragma pack(pop) | |
151 | |
1263 | 152 am_2 cards_power[10]; |
1256 | 153 std::array<__int16, 12> am_sounds; |
154 | |
1218 | 155 char byte_4E185C = 1; // weak |
156 char am_byte_4E185D = 1; // weak | |
1263 | 157 char use_start_bonus = 1; // weak |
1185 | 158 |
1201 | 159 int start_tower_height; |
160 int start_wall_height; | |
161 int start_quarry_level; | |
162 int start_magic_level; | |
163 int start_zoo_level; | |
164 | |
165 | |
1679 | 166 int minimum_cards_at_hand = 5; // 004E1874 |
1201 | 167 int quarry_bonus = 1; |
168 int magic_bonus = 1; | |
169 int zoo_bonus = 1; | |
170 | |
171 int max_tower_height = 50; | |
172 int max_resources_amount = 100 ; | |
1185 | 173 |
1256 | 174 int opponent_mastery = 1 ; // weak |
1185 | 175 |
1679 | 176 bool am_gameover; // 004FAA2C |
1186 | 177 char byte_4FAA2D; // weak |
178 | |
2154 | 179 int am_default_starting_player = 0; // 505890 |
1679 | 180 int current_player_num; // 004FAA6C |
181 char need_to_discard_card; // 04FAA77 | |
182 | |
183 int current_card_slot_index; // 004FABBC | |
184 int played_card_id; // 4FABC0 | |
185 int uCardID; // 4FAA50 | |
186 | |
187 int deck_walk_index; // 004FABC8 | |
1201 | 188 |
189 int start_bricks_amount; | |
190 int start_gems_amount; | |
191 int start_beasts_amount; | |
1197 | 192 |
1209 | 193 POINT amuint_4FAA3C_blt_xy; |
194 POINT am_uint_4FAA44_blt_xy; | |
195 POINT amuint_4FAA54_blt_xy; | |
196 POINT amuint_4FAA5C_blt_xy; | |
197 | |
1245 | 198 int dword_4FAA64; // weak |
199 int dword_4FAA68; // weak | |
1209 | 200 |
201 int dword_4FABB8; // weak | |
202 | |
1256 | 203 char byte_4FAA00; // weak |
204 | |
205 int amuint_4FAA34; // weak | |
206 int amuint_4FAA38; // weak | |
207 int amuint_4FAA4C; // weak | |
208 | |
209 char byte_4FAA2E; // weak | |
210 | |
211 int dword_4FAA70; // weak | |
212 char byte_4FAA74; // weak | |
213 char am_byte_4FAA75; // weak | |
214 char am_byte_4FAA76; // weak | |
215 | |
216 int amuint_4FABC4; // weak | |
217 | |
218 | |
219 char byte_505880; // weak | |
220 char byte_505881; // weak | |
0 | 221 |
222 //----- (0040DD2F) -------------------------------------------------------- | |
223 bool stru273::_40DD2F() | |
224 { | |
225 | |
226 this->x = pArcomageGame->mouse_x; | |
227 this->y = pArcomageGame->mouse_y; | |
1263 | 228 this->curr_mouse_left = pArcomageGame->mouse_left; |
229 this->mouse_left_state_changed = pArcomageGame->mouse_left == pArcomageGame->prev_mouse_left; | |
230 this->curr_mouse_right = pArcomageGame->mouse_right; | |
231 this->mouse_right_state_changed = pArcomageGame->mouse_right == pArcomageGame->prev_mouse_right; | |
232 pArcomageGame->prev_mouse_left = pArcomageGame->mouse_left; | |
233 pArcomageGame->prev_mouse_right = pArcomageGame->mouse_right; | |
1183 | 234 return true; |
0 | 235 } |
236 | |
237 //----- (0040DD93) -------------------------------------------------------- | |
1185 | 238 bool stru273::Inside(RECT*pXYZW ) |
239 { | |
240 | |
241 return (x >= pXYZW->left) && (x <= pXYZW->right) && | |
242 (y>= pXYZW->top) && (y <= pXYZW->bottom); | |
0 | 243 } |
244 | |
1184 | 245 //----- (0040DFD1) -------------------------------------------------------- |
1679 | 246 stru272_stru0 *stru272_stru0::New() |
247 { | |
248 stru272_stru0 *v2 = (stru272_stru0 *)malloc(0x5Cu); | |
1184 | 249 v2->signature = SIG_trpg; |
1263 | 250 v2->position_in_sparks_arr = 0; |
1184 | 251 v2->field_30 = 0.0; |
252 v2->field_58 = 0; | |
253 v2->field_59 = 0; | |
1679 | 254 |
255 return v2; | |
256 } | |
1184 | 257 |
258 //----- (0040DFFE) -------------------------------------------------------- | |
1679 | 259 int stru272_stru0::Free() |
2213 | 260 { |
261 if ( this->signature == SIG_trpg ) | |
262 { | |
263 this->signature = SIG_xxxx; | |
264 free(this); | |
265 return 0; | |
266 } | |
267 else | |
268 return 2; | |
269 } | |
1184 | 270 |
271 //----- (0040E01A) -------------------------------------------------------- | |
1263 | 272 int stru272_stru0::StartFill( stru272_stru2* a2 ) |
2213 | 273 { |
274 //stru272_stru0* a1 = this; | |
275 if ( this->signature == SIG_trpg ) | |
276 { | |
277 this->field_4 = a2->field_20; | |
278 this->field_C = a2->effect_area.left << 16; | |
279 this->field_10 = a2->effect_area.top << 16; | |
280 this->field_14 = a2->effect_area.right << 16; | |
281 this->field_18 = a2->effect_area.bottom << 16; | |
282 this->field_1C = a2->field_10; | |
283 this->field_20 = a2->field_14; | |
284 this->field_24 = a2->field_18; | |
285 this->field_28 = (float)(a2->field_1Cf * 65536.0); | |
286 this->field_2C = a2->field_24f; | |
287 this->field_34 = (int)(a2->field_28f * 65536.0); | |
288 this->field_38 = (int)(a2->field_2Cf * 65536.0); | |
289 this->field_3C = a2->field_30; | |
290 this->field_40 = a2->field_34; | |
291 this->field_54 = a2->sparks_array; | |
292 this->field_59 = 1; | |
293 return 0; | |
294 } | |
295 else | |
296 return 2; | |
297 } | |
1184 | 298 |
299 //----- (0040E0F5) -------------------------------------------------------- | |
1679 | 300 int stru272_stru0::Clear(char a2, char a3) |
1184 | 301 { |
1185 | 302 if ( signature == SIG_trpg) |
1184 | 303 { |
304 if ( a2 ) | |
305 { | |
1263 | 306 position_in_sparks_arr = 0; |
1185 | 307 field_30 = 0.0; |
1184 | 308 } |
1185 | 309 if ( field_59 && a3 ) |
1184 | 310 { |
1185 | 311 |
312 for (int i=0; i<field_4; ++i) | |
1263 | 313 field_54[i].have_spark = 0; |
1185 | 314 field_58 = 0; |
1184 | 315 } |
1185 | 316 return 0; |
1184 | 317 } |
318 else | |
1185 | 319 return 2; |
1184 | 320 } |
321 | |
322 //----- (0040E133) -------------------------------------------------------- | |
1263 | 323 int stru272_stru0::DrawEffect() |
2213 | 324 { |
325 // stru272_stru0 *v1; // edi@1 | |
326 int v3; // ST18_4@3 | |
327 double v4; // st7@3 | |
328 double v5; // st6@4 | |
329 char v6; // bl@8 | |
330 stru272_stru1 *v7; // esi@8 | |
331 int v8; // ecx@10 | |
332 signed int v9; // eax@10 | |
333 int v10; // ecx@10 | |
334 signed int v11; // eax@10 | |
335 int v12; // ebx@12 | |
336 int v13; // ST1C_4@12 | |
337 int v14; // ebx@12 | |
338 int v15; // ST1C_4@12 | |
339 signed int v16; // edx@12 | |
340 int v17; // ebx@12 | |
341 int v18; // ST1C_4@12 | |
342 signed int v19; // edx@12 | |
343 int v20; // [sp+8h] [bp-10h]@8 | |
344 int v21; // [sp+Ch] [bp-Ch]@8 | |
345 float v22; // [sp+14h] [bp-4h]@3 | |
346 | |
347 if ( this->signature != SIG_trpg ) | |
348 return 2; | |
349 v3 = this->position_in_sparks_arr; | |
350 v22 = this->field_30; | |
351 v4 = v3; | |
352 if ( v3 > 0 ) | |
353 { | |
354 v5 = v22 + this->field_2C; | |
355 v22 = v5; | |
356 if ( v5 > v4 ) | |
357 v22 = v4; | |
358 } | |
359 if ( v22 >= 1.0 || this->field_58 ) | |
360 { | |
361 v6 = 0; | |
362 v7 = this->field_54; | |
363 v20 = this->field_28; | |
364 | |
365 for ( v21 = this->field_4; v21; v21-- ) | |
1184 | 366 { |
2213 | 367 if ( v7->have_spark > 0 ) |
368 { | |
369 v8 = v7->field_14; | |
370 --v7->have_spark; | |
371 v9 = v8 + v7->field_C; | |
372 v10 = v20 + v7->field_18; | |
373 v7->field_C = v9; | |
374 v7->spark_position.x = v9 >> 16; | |
375 v11 = v10 + v7->field_10; | |
376 v7->field_18 = v10; | |
377 v7->field_10 = v11; | |
378 v7->spark_position.y = v11 >> 16; | |
379 v6 = 1; | |
380 //goto LABEL_14; | |
381 } | |
382 else | |
383 { | |
384 if ( v22 >= 1.0 ) | |
385 { | |
386 v12 = this->field_40; | |
387 v13 = this->field_3C; | |
388 v7->have_spark = rand_interval(v13,v12); | |
389 v7->field_14 = (rand() % 17 - 8) << 16; | |
390 v7->field_18 = (rand() % 17 - 8) << 16; | |
391 v14 = this->field_14 - 1; | |
392 v15 = this->field_C; | |
393 v16 = rand_interval(v15,v14); | |
394 v7->field_C = v16; | |
395 v7->spark_position.x = v16 >> 16; | |
396 v17 = this->field_18 - 1; | |
397 v18 = this->field_10; | |
398 v19 = rand_interval(v17, v18); | |
399 v7->field_10 = v19; | |
400 v7->spark_position.y = v19 >> 16; | |
401 --this->position_in_sparks_arr; | |
402 v22 = v22 - 1.0; | |
1184 | 403 v6 = 1; |
2213 | 404 } |
405 } | |
406 //LABEL_14: | |
407 ++v7; | |
408 //--v21; | |
409 //if ( !v21 ) | |
410 //{ | |
411 //this->field_58 = v6; | |
412 //this->field_30 = v22; | |
413 //return 0; | |
414 //} | |
1184 | 415 } |
2213 | 416 this->field_58 = v6; |
417 this->field_30 = v22; | |
418 } | |
419 return 0; | |
420 } | |
1184 | 421 |
422 //----- (0040E2A7) -------------------------------------------------------- | |
423 int stru272_stru0::_40E2A7() | |
2213 | 424 { |
425 if (signature == SIG_trpg ) | |
426 { | |
427 if ( position_in_sparks_arr <= 0 ) | |
428 return field_58 != 0 ? 2 : 0; | |
1184 | 429 else |
2213 | 430 return 1; |
431 } | |
432 else | |
433 return 3; | |
434 } | |
0 | 435 |
436 //----- (0040DFAF) -------------------------------------------------------- | |
437 void ArcomageGame::OnMouseClick(char right_left, bool bDown) | |
438 { | |
439 if ( right_left ) | |
440 pArcomageGame->mouse_right = bDown; | |
441 else | |
442 pArcomageGame->mouse_left = bDown; | |
443 } | |
444 | |
445 //----- (0040DFC1) -------------------------------------------------------- | |
1532 | 446 void ArcomageGame::OnMouseMove(int x, int y) |
0 | 447 { |
1532 | 448 pArcomageGame->mouse_x = x; |
449 pArcomageGame->mouse_y = y; | |
0 | 450 } |
451 | |
452 //----- (0040DF47) -------------------------------------------------------- | |
453 void DoBlt_Copy(unsigned __int16 *pPixels) | |
454 { | |
1183 | 455 RECT pSrcRect; |
456 POINT pTargetPoint; // [sp+1Ch] [bp-8h]@1 | |
457 | |
0 | 458 pRenderer->Present(); |
1183 | 459 |
460 pTargetPoint.x = 0; | |
461 pTargetPoint.y = 0; | |
462 | |
1256 | 463 pSrcRect.left = 0; |
464 pSrcRect.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
465 pSrcRect.right = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
466 pSrcRect.bottom = window->GetHeight(); |
1183 | 467 |
0 | 468 pRenderer->BeginScene(); |
1183 | 469 pArcomageGame->pBlit_Copy_pixels = pPixels; |
2154 | 470 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); |
0 | 471 pRenderer->EndScene(); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2356
diff
changeset
|
472 pArcomageGame->pBlit_Copy_pixels = nullptr; |
0 | 473 } |
474 | |
475 //----- (0040DDC9) -------------------------------------------------------- | |
1183 | 476 void ArcomageGame::PlaySound( unsigned int event_id ) |
2213 | 477 { |
1183 | 478 SoundID play_sound_id; // eax@10 |
479 | |
480 switch ( event_id ) | |
481 { | |
482 case 40: | |
483 case 43: | |
484 case 46: | |
485 play_sound_id = SOUND_Arcomage_LoseResources; | |
486 break; | |
487 case 39: | |
488 case 41: | |
489 case 42: | |
490 case 44: | |
491 case 45: | |
492 case 47: | |
493 play_sound_id = SOUND_Arcomage_AddResources; | |
494 break; | |
495 case 0: | |
496 case 12: | |
497 case 14: | |
498 case 15: | |
499 case 16: | |
500 case 48: | |
501 case 50: | |
502 case 53: | |
503 play_sound_id = SOUND_Arcomage_TowerWallDamage; | |
504 break; | |
505 case 21: | |
506 case 22: | |
507 case 23: | |
508 play_sound_id = SOUND_Arcomage_DrawCard; | |
509 break; | |
510 case 56: | |
511 play_sound_id = SOUND_Arcomage_124; | |
0 | 512 break; |
1183 | 513 case 31: |
514 case 34: | |
515 case 37: | |
516 play_sound_id = SOUND_Arcomage_ProductionDamage; | |
517 break; | |
518 case 1: | |
519 case 30: | |
520 case 32: | |
521 case 33: | |
522 case 35: | |
523 case 36: | |
524 case 38: | |
525 play_sound_id = SOUND_Arcomage_ProductionUpgrade; | |
526 break; | |
527 case 20: | |
528 play_sound_id = SOUND_Arcomage_127; | |
529 break; | |
530 case 3: | |
531 play_sound_id = SOUND_Arcomage_128; | |
532 break; | |
533 case 52: | |
534 case 54: | |
535 play_sound_id = SOUND_Arcomage_TowerUpgrade; | |
536 break; | |
537 case 10: | |
538 case 11: | |
539 case 13: | |
540 play_sound_id = SOUND_Arcomage_130; | |
541 break; | |
542 case 55u: | |
543 play_sound_id = SOUND_Arcomage_131; | |
544 break; | |
545 case 49: | |
546 case 51: | |
547 play_sound_id = SOUND_Arcomage_WallUpgrade; | |
548 break; | |
549 default: | |
0 | 550 return; |
2213 | 551 } |
1183 | 552 pAudioPlayer->PlaySound(play_sound_id, 0, 0, -1, 0, 0, 0, 0); |
0 | 553 } |
554 | |
555 //----- (0040DC2D) -------------------------------------------------------- | |
556 bool ArcomageGame::MsgLoop(int a1, ArcomageGame_stru1 *a2) | |
557 { | |
558 void *v2; // ebp@1 | |
2459 | 559 //BOOL v3; // eax@1 |
0 | 560 |
561 v2 = a2; | |
562 pArcomageGame->field_0 = 0; | |
563 pArcomageGame->stru1.field_0 = 0; | |
2459 | 564 //v3 = PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE); |
565 //if ( pArcomageGame->msg.message == WM_QUIT ) | |
566 //Game_DeinitializeAndTerminate(0); | |
567 if ( PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE) ) | |
0 | 568 { |
2459 | 569 if ( pArcomageGame->msg.message == WM_QUIT ) |
570 Game_DeinitializeAndTerminate(0); | |
0 | 571 TranslateMessage(&pArcomageGame->msg); |
572 DispatchMessageA(&pArcomageGame->msg); | |
573 } | |
1038 | 574 /*if (pAsyncMouse) |
0 | 575 { |
576 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); | |
577 v4 = *((unsigned int *)pAsyncMouse + 7); | |
578 pArcomageGame->mouse_x = *((unsigned int *)pAsyncMouse + 6); | |
579 pArcomageGame->mouse_y = v4; | |
580 v5 = *((unsigned int *)pAsyncMouse + 27); | |
581 v6 = *(unsigned int *)v5; | |
582 if ( *(unsigned int *)v5 != v5 ) | |
583 { | |
584 do | |
585 { | |
586 v7 = *(unsigned int *)(v6 + 20); | |
587 if ( v7 & 1 ) | |
588 { | |
589 pArcomageGame->stru1.field_0 = 7; | |
590 } | |
591 else | |
592 { | |
593 if ( v7 & 2 ) | |
594 pArcomageGame->stru1.field_0 = 8; | |
595 } | |
596 v6 = *(unsigned int *)v6; | |
597 } | |
598 while ( v6 != *((unsigned int *)pAsyncMouse + 27) ); | |
599 } | |
600 pAsyncMouse->_46B944(); | |
601 if ( !*((unsigned char *)pAsyncMouse + 90) ) | |
602 pArcomageGame->field_F6 = 1; | |
603 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); | |
1038 | 604 }*/ |
0 | 605 memcpy(v2, &pArcomageGame->stru1, 0xCu); |
606 return pArcomageGame->stru1.field_0 != 0; | |
607 } | |
608 | |
609 //----- (0040D7D5) -------------------------------------------------------- | |
610 void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3) | |
611 { | |
612 pRenderer->BeginScene(); | |
1183 | 613 pArcomageGame->pBlit_Copy_pixels = pPcxPixels; |
0 | 614 } |
615 | |
616 //----- (0040D7EC) -------------------------------------------------------- | |
2154 | 617 void Render::am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode) |
0 | 618 { |
2213 | 619 unsigned __int16 *pSrc; // eax@2 |
620 int uSrcTotalWidth; // ecx@4 | |
621 unsigned int v10; // esi@9 | |
622 int v21; // [sp+Ch] [bp-18h]@8 | |
623 unsigned __int16 *src_surf_pos; // [sp+10h] [bp-14h]@9 | |
624 __int32 src_width; // [sp+14h] [bp-10h]@3 | |
625 __int32 src_height; // [sp+18h] [bp-Ch]@3 | |
626 int uSrcPitch; // [sp+1Ch] [bp-8h]@5 | |
627 | |
628 if ( !uNumSceneBegins ) | |
1183 | 629 return; |
2213 | 630 if ( !pArcomageGame->pBlit_Copy_pixels ) |
0 | 631 return; |
1183 | 632 |
2213 | 633 //dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch]; |
634 src_width = pSrcRect->right - pSrcRect->left; | |
635 src_height = pSrcRect->bottom - pSrcRect->top; | |
636 | |
637 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels ) | |
1183 | 638 uSrcTotalWidth = pArcomageGame->pGameBackground.uWidth; |
2213 | 639 else if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels ) |
1183 | 640 uSrcTotalWidth = pArcomageGame->pSprites.uWidth; |
641 | |
2213 | 642 //v20 = 157; |
643 //v19 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp"; | |
644 //v21 = &v18; | |
645 //std__string_char_40E2C8(&v18, "Problem in Blit_Chroma", &a3a); | |
646 //466D09_xcpt_string(&v21, v18, v19, v20); | |
647 //pSrc = pArcomageGame.pBlit_Copy_pixels; | |
648 //LABEL_9: | |
649 pSrc = pArcomageGame->pBlit_Copy_pixels; | |
650 uSrcPitch = uSrcTotalWidth; | |
651 src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top]; | |
652 v10 = 0x1F;//0xFF >> (8 - (unsigned __int8)uTargetBBits); | |
653 v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF); | |
654 if ( blend_mode == 2 ) | |
655 { | |
656 uSrcPitch = (uSrcPitch - src_width); | |
657 for ( int i = 0; i < src_height; ++i ) | |
0 | 658 { |
2213 | 659 for ( int j = 0; j < src_width; ++j ) |
660 { | |
661 if ( *src_surf_pos != v10 ) | |
662 { | |
2216 | 663 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
664 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 665 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos); |
666 } | |
667 ++src_surf_pos; | |
668 } | |
669 src_surf_pos += uSrcPitch; | |
0 | 670 } |
2213 | 671 } |
672 else | |
673 { | |
674 uSrcPitch = (uSrcPitch - src_width); | |
675 for ( int i = 0; i < src_height; ++i ) | |
0 | 676 { |
2213 | 677 for ( int j = 0; j < src_width; ++j ) |
678 { | |
679 if ( *src_surf_pos != v10 ) | |
0 | 680 { |
2216 | 681 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
682 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 683 //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1))); |
684 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2))); | |
0 | 685 } |
2213 | 686 ++src_surf_pos; |
687 } | |
688 src_surf_pos+=uSrcPitch; | |
0 | 689 } |
2213 | 690 } |
0 | 691 } |
692 | |
693 //----- (0040D9B1) -------------------------------------------------------- | |
2154 | 694 void Render::am_Blt_Copy( RECT *pSrcRect, POINT *pTargetPoint, int blend_mode ) |
2213 | 695 { |
696 unsigned __int16 *pSrc; // eax@2 | |
697 int uSrcTotalWidth; // ecx@4 | |
698 int v21; // [sp+Ch] [bp-18h]@8 | |
699 unsigned __int16 *src_surf_pos; // [sp+10h] [bp-14h]@9 | |
700 __int32 src_width; // [sp+14h] [bp-10h]@3 | |
701 __int32 src_height; // [sp+18h] [bp-Ch]@3 | |
702 int uSrcPitch; // [sp+1Ch] [bp-8h]@5 | |
703 | |
704 if ( !uNumSceneBegins ) | |
705 return; | |
706 if ( !pArcomageGame->pBlit_Copy_pixels ) | |
707 return; | |
1183 | 708 |
2069 | 709 //dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch]; |
2213 | 710 src_width = pSrcRect->right - pSrcRect->left; |
711 src_height = pSrcRect->bottom - pSrcRect->top; | |
712 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels ) | |
713 uSrcTotalWidth = pArcomageGame->pGameBackground.uWidth; | |
714 else if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels ) | |
715 uSrcTotalWidth = pArcomageGame->pSprites.uWidth; | |
716 | |
717 //v20 = 157; | |
718 //v19 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp"; | |
719 //v21 = &v18; | |
720 //std__string_char_40E2C8(&v18, "Problem in Blit_Chroma", &a3a); | |
721 //466D09_xcpt_string(&v21, v18, v19, v20); | |
722 //pSrc = pArcomageGame.pBlit_Copy_pixels; | |
723 //LABEL_9: | |
724 pSrc = pArcomageGame->pBlit_Copy_pixels; | |
725 uSrcPitch = uSrcTotalWidth; | |
726 src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top]; | |
727 v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF); | |
728 | |
729 if ( blend_mode == 2 ) | |
730 { | |
731 uSrcPitch = (uSrcPitch - src_width); | |
732 for ( int i = 0; i < src_height; ++i ) | |
733 { | |
734 for ( int j = 0; j < src_width; ++j ) | |
735 { | |
736 if ( *src_surf_pos != v21 ) | |
0 | 737 { |
2216 | 738 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
739 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 740 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos); |
0 | 741 } |
2213 | 742 ++src_surf_pos; |
743 } | |
744 src_surf_pos += uSrcPitch; | |
745 } | |
746 } | |
747 else | |
748 { | |
749 uSrcPitch = (uSrcPitch - src_width); | |
750 for ( int i = 0; i < src_height; ++i ) | |
751 { | |
752 for ( int j = 0; j < src_width; ++j ) | |
753 { | |
754 if ( *src_surf_pos != v21 ) | |
0 | 755 { |
2216 | 756 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
757 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 758 //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) / 2)) + (v21 & (*src_surf_pos / 2))); |
759 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2))); | |
0 | 760 } |
2213 | 761 ++src_surf_pos; |
762 } | |
763 src_surf_pos += uSrcPitch; | |
764 } | |
765 } | |
0 | 766 } |
767 | |
768 //----- (0040DB10) -------------------------------------------------------- | |
2154 | 769 void am_EndScene() |
0 | 770 { |
771 pRenderer->EndScene(); | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2356
diff
changeset
|
772 pArcomageGame->pBlit_Copy_pixels = nullptr; |
0 | 773 } |
774 | |
775 //----- (0040D7B7) -------------------------------------------------------- | |
776 bool ArcomageGame::LoadSprites() | |
777 { | |
778 pArcomageGame->pSprites.Load("sprites.pcx", 2); | |
779 pArcomageGame->pSpritesPixels = pArcomageGame->pSprites.pPixels; | |
1183 | 780 return true; |
0 | 781 } |
782 | |
783 //----- (0040D799) -------------------------------------------------------- | |
784 bool ArcomageGame::LoadBackground() | |
785 { | |
786 pArcomageGame->pGameBackground.Load("layout.pcx", 2); | |
787 pArcomageGame->pBackgroundPixels = pArcomageGame->pGameBackground.pPixels; | |
1183 | 788 return true; |
0 | 789 } |
790 | |
1256 | 791 int CalculateCardPower(ArcomagePlayer* player, ArcomagePlayer* enemy, ArcomageCard* pCard, int mastery) |
2213 | 792 { |
793 enum V_INDX{ | |
1256 | 794 P_TOWER_M10, |
795 P_WALL_M10, | |
796 E_TOWER, | |
797 E_WALL, | |
798 E_BUILDINGS, | |
799 E_QUARRY, | |
800 E_MAGIC, | |
801 E_ZOO, | |
802 E_RES, | |
803 V_INDEX_MAX | |
804 }; | |
805 | |
806 const int mastery_coeff[V_INDEX_MAX][2]= {{10, 5}, //P_TOWER_M10 | |
807 {2, 1}, //P_WALL_M10 | |
808 {1, 10}, //E_TOWER | |
809 {1, 3}, //E_WALL | |
810 {1, 7}, //E_BUILDINGS | |
811 {1, 5}, //E_QUARRY | |
812 {1, 40}, //E_MAGIC | |
813 {1, 40}, //E_ZOO | |
814 {1, 2} //E_RES | |
815 }; | |
816 int card_power= 0; | |
817 int element_power; | |
818 | |
819 if ( pCard->to_player_tower == 99 || pCard->to_pl_enm_tower == 99|| | |
820 pCard->to_player_tower2 == 99 || pCard->to_pl_enm_tower2 == 99 ) | |
821 element_power = enemy->tower_height - player->tower_height; | |
822 else | |
823 element_power = pCard->to_player_tower + pCard->to_pl_enm_tower + pCard->to_player_tower2 + pCard->to_pl_enm_tower2; | |
824 | |
825 if ( player->tower_height >= 10 ) | |
826 card_power += mastery_coeff[P_TOWER_M10][mastery]*element_power; | |
827 else | |
828 card_power += 20*element_power; | |
829 | |
830 | |
831 if ( pCard->to_player_wall == 99 || pCard->to_pl_enm_wall == 99 || | |
832 pCard->to_player_wall2 == 99 || pCard->to_pl_enm_wall2 == 99 ) | |
833 element_power = enemy->wall_height - player->wall_height; | |
834 else | |
835 element_power = pCard->to_player_wall + pCard->to_pl_enm_wall + | |
836 pCard->to_player_wall2 + pCard->to_pl_enm_wall2; | |
837 if ( player->wall_height >= 10 ) | |
838 card_power += mastery_coeff[P_WALL_M10][mastery]*element_power; //1 | |
839 else | |
840 card_power += 5*element_power; | |
841 | |
842 | |
843 card_power += 7 * (pCard->to_player_buildings + pCard->to_pl_enm_buildings + | |
844 pCard->to_player_buildings2 + pCard->to_pl_enm_buildings2); | |
845 | |
846 if ( pCard->to_player_quarry_lvl == 99 || pCard->to_pl_enm_quarry_lvl == 99 || | |
847 pCard->to_player_quarry_lvl2 == 99 || pCard->to_pl_enm_quarry_lvl2 == 99 ) | |
848 element_power = enemy->quarry_level - player->quarry_level; | |
849 else | |
850 element_power = pCard->to_player_quarry_lvl + pCard->to_pl_enm_quarry_lvl + | |
851 pCard->to_player_quarry_lvl2 + pCard->to_pl_enm_quarry_lvl; | |
852 | |
853 card_power += 40 * element_power; | |
854 | |
855 if ( pCard->to_player_magic_lvl == 99 || pCard->to_pl_enm_magic_lvl == 99 || | |
856 pCard->to_player_magic_lvl2 == 99 || pCard->to_pl_enm_magic_lvl2 == 99 ) | |
857 element_power = enemy->magic_level - player->magic_level; | |
858 else | |
859 element_power = pCard->to_player_magic_lvl + pCard->to_pl_enm_magic_lvl + | |
860 pCard->to_player_magic_lvl2 + pCard->to_pl_enm_magic_lvl2; | |
861 card_power += 40 *element_power; | |
862 | |
863 if ( pCard->to_player_zoo_lvl == 99 || pCard->to_pl_enm_zoo_lvl == 99 || | |
864 pCard->to_player_zoo_lvl2 == 99 || pCard->to_pl_enm_zoo_lvl2 == 99 ) | |
865 element_power = enemy->zoo_level - player->zoo_level; | |
866 else | |
867 element_power = pCard->to_player_zoo_lvl + pCard->to_pl_enm_zoo_lvl + | |
868 pCard->to_player_zoo_lvl2 + pCard->to_pl_enm_zoo_lvl2; | |
869 card_power += 40 *element_power; | |
870 | |
871 if ( pCard->to_player_bricks == 99 || pCard->to_pl_enm_bricks == 99 || | |
872 pCard->to_player_bricks2 == 99 || pCard->to_pl_enm_bricks2 == 99 ) | |
873 element_power = enemy->resource_bricks - player->resource_bricks; | |
874 else | |
875 element_power = pCard->to_player_bricks + pCard->to_pl_enm_bricks + | |
876 pCard->to_player_bricks2 + pCard->to_pl_enm_bricks2; | |
877 card_power += 2 *element_power; | |
878 | |
879 | |
880 if ( pCard->to_player_gems == 99 || pCard->to_pl_enm_gems == 99 || | |
881 pCard->to_player_gems2 == 99 || pCard->to_pl_enm_gems2 == 99 ) | |
882 element_power = enemy->resource_gems - player->resource_gems; | |
883 else | |
884 element_power = pCard->to_player_gems + pCard->to_pl_enm_gems + | |
885 pCard->to_player_gems2 + pCard->to_pl_enm_gems2; | |
886 card_power += 2 *element_power; | |
887 | |
888 if ( pCard->to_player_beasts == 99 || pCard->to_pl_enm_beasts == 99 || | |
889 pCard->to_player_beasts2 == 99 || pCard->to_pl_enm_beasts2 == 99 ) | |
890 element_power = enemy->resource_beasts - player->resource_beasts; | |
891 else | |
892 element_power = pCard->to_player_beasts + pCard->to_pl_enm_beasts + | |
893 pCard->to_player_beasts2 + pCard->to_pl_enm_beasts2; | |
894 card_power += 2 *element_power; | |
895 | |
896 if ( pCard->to_enemy_tower == 99 || pCard->to_enemy_tower2 == 99 ) | |
897 element_power = player->tower_height - enemy->tower_height; | |
898 else | |
899 element_power = -(pCard->to_enemy_tower + pCard->to_enemy_tower2); | |
900 card_power += mastery_coeff[E_TOWER][mastery]*element_power; | |
901 | |
902 if ( pCard->to_enemy_wall == 99 || pCard->to_enemy_wall2 == 99 ) | |
903 element_power = player->wall_height - enemy->wall_height; | |
904 else | |
905 element_power = -(pCard->to_enemy_wall + pCard->to_enemy_wall2); | |
906 card_power += mastery_coeff[E_WALL][mastery]*element_power; | |
907 | |
908 card_power -= mastery_coeff[E_BUILDINGS][mastery]*(pCard->to_enemy_buildings + pCard->to_enemy_buildings2); | |
909 | |
910 if ( pCard->to_enemy_quarry_lvl == 99 || pCard->to_enemy_quarry_lvl2 == 99 ) | |
911 element_power = player->quarry_level - enemy->quarry_level; //5 | |
912 else | |
913 element_power = -(pCard->to_enemy_quarry_lvl + pCard->to_enemy_quarry_lvl2); //5 | |
914 card_power += mastery_coeff[E_QUARRY][mastery]*element_power; | |
915 | |
916 if ( pCard->to_enemy_magic_lvl == 99 || pCard->to_enemy_magic_lvl2 == 99 ) | |
917 element_power = player->magic_level - enemy->magic_level; //40 | |
918 else | |
919 element_power = -(pCard->to_enemy_magic_lvl + pCard->to_enemy_magic_lvl2); | |
920 card_power += mastery_coeff[E_MAGIC][mastery]*element_power; | |
921 | |
922 if ( pCard->to_enemy_zoo_lvl == 99 || pCard->to_enemy_zoo_lvl2 == 99 ) | |
923 element_power = player->zoo_level - enemy->zoo_level; //40 | |
924 else | |
925 element_power = -(pCard->to_enemy_zoo_lvl + pCard->to_enemy_zoo_lvl2); | |
926 card_power += mastery_coeff[E_ZOO][mastery]*element_power; | |
927 | |
928 if ( pCard->to_enemy_bricks == 99 || pCard->to_enemy_bricks2 == 99 ) | |
929 element_power = player->resource_bricks - enemy->resource_bricks; //2 | |
930 else | |
931 element_power = -(pCard->to_enemy_bricks + pCard->to_enemy_bricks2); | |
932 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
933 | |
934 if ( pCard->to_enemy_gems == 99 || pCard->to_enemy_gems2 == 99 ) | |
935 element_power = player->resource_gems - enemy->resource_gems; //2 | |
936 else | |
937 element_power = -(pCard->to_enemy_gems + pCard->to_enemy_gems2); | |
938 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
939 | |
940 if ( pCard->to_enemy_beasts == 99 || pCard->to_enemy_beasts2 == 99 ) | |
941 element_power = player->resource_beasts - enemy->resource_beasts; //2 | |
942 else | |
943 element_power = -(pCard->to_enemy_beasts + pCard->to_enemy_beasts2); | |
944 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
945 | |
946 if ( pCard->field_30 || pCard->field_4D ) | |
947 card_power *= 10; | |
948 | |
949 if ( pCard->field_24 == 1 ) | |
950 element_power = player->resource_bricks - pCard->needed_bricks; | |
951 else if ( pCard->field_24 == 2 ) | |
952 element_power = player->resource_gems - pCard->needed_gems; | |
953 else if (pCard->field_24 == 3) | |
954 element_power = player->resource_beasts - pCard->needed_beasts; | |
955 if ( element_power > 3 ) | |
956 element_power = 3; | |
957 card_power += 5 * element_power; | |
958 | |
959 if ( enemy->tower_height <= pCard->to_enemy_tower2 + pCard->to_enemy_tower ) | |
960 card_power += 9999; | |
2213 | 961 |
1256 | 962 if (pCard->to_enemy_tower2 + pCard->to_enemy_tower + |
963 pCard->to_enemy_wall + pCard->to_enemy_wall2 + | |
964 pCard->to_enemy_buildings + pCard->to_enemy_buildings2 >= enemy->wall_height + enemy->tower_height) | |
965 card_power += 9999; | |
966 | |
2213 | 967 if ( (pCard->to_player_tower2 + pCard->to_pl_enm_tower2 + pCard->to_player_tower + pCard->to_pl_enm_tower + player->tower_height) |
968 >= max_tower_height ) | |
969 card_power += 9999; | |
970 | |
971 return card_power; | |
972 } | |
1256 | 973 |
0 | 974 //----- (00408BB4) -------------------------------------------------------- |
1256 | 975 bool OpponentsAITurn(int player_num) |
0 | 976 { |
2213 | 977 int all_player_cards_count; // eax@9 |
978 int random_card_slot; // edi@9 | |
979 ArcomageCard *v12; // ecx@20 | |
980 int v56; // ecx@141 | |
981 int v57; // edx@141 | |
2334 | 982 // int v64; // eax@169 |
983 // ArcomageCard *pCard; // ecx@169 | |
984 // char v66; // dl@169 | |
985 // char v67; // dl@173 | |
986 // int v68; // edx@174 | |
2213 | 987 int v132; // [sp-14h] [bp-14h]@0 |
988 ArcomagePlayer *enemy; // [sp-10h] [bp-10h]@5 | |
989 ArcomagePlayer *player; // [sp-Ch] [bp-Ch]@5 | |
990 | |
991 byte_4FAA00 = 1; | |
992 if ( opponent_mastery == 0) | |
993 { | |
994 if ( need_to_discard_card == 0 ) //am_byte_4FAA77 | |
995 { | |
996 for(int i = 0; i < 10; ++i ) | |
997 { | |
998 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
999 random_card_slot = rand_interval(0, all_player_cards_count - 1); | |
1000 if ( CanCardBePlayed(player_num, random_card_slot) ) | |
1001 return PlayCard(player_num, random_card_slot); | |
1002 } | |
1003 } | |
1004 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
1005 random_card_slot= rand_interval(0, all_player_cards_count - 1); | |
1006 return DiscardCard(player_num, random_card_slot); | |
1007 } | |
1008 else if (( opponent_mastery == 1 )|| ( opponent_mastery == 2 )) | |
1009 { | |
1010 player = &am_Players[player_num]; | |
1011 enemy = &am_Players[(player_num + 1) % 2]; | |
1012 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
1013 for(int i = 0; i < 10 ; ++i ) | |
1014 { | |
1015 if ( i >= all_player_cards_count ) | |
1016 { | |
1017 cards_power[i].slot_index = -1; | |
1018 cards_power[i].card_power = -9999; | |
1019 } | |
1020 else | |
1021 { | |
1022 cards_power[i].slot_index = i; | |
1023 cards_power[i].card_power = 0; | |
1024 } | |
1025 } | |
1026 for(int i = 0; i < all_player_cards_count ; ++i ) | |
1027 { | |
1028 v12 = &pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]]; | |
1029 cards_power[i].card_power = CalculateCardPower(player, enemy, v12, opponent_mastery-1); | |
1030 } | |
1031 | |
1032 for (int j = all_player_cards_count - 1; j >= 0; --j ) | |
1033 { | |
1034 for (int m = 0; m < j; ++m ) | |
1035 { | |
1036 if ( cards_power[m].card_power < cards_power[m + 1].card_power ) | |
1256 | 1037 { |
2213 | 1038 v56 = cards_power[m].slot_index; |
1039 v57 = cards_power[m].card_power; | |
1040 cards_power[m].slot_index = cards_power[m + 1].slot_index; | |
1041 cards_power[m].card_power = cards_power[m + 1].card_power; | |
1042 cards_power[m + 1].slot_index = cards_power[m].slot_index; | |
1043 cards_power[m + 1].card_power = cards_power[m].card_power; | |
1256 | 1044 } |
2213 | 1045 } |
1046 } | |
1047 if ( need_to_discard_card ) | |
1048 { | |
1049 for ( int i = all_player_cards_count - 1; i; --i ) | |
1050 { | |
1051 if ( pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]].can_be_discarded ) | |
1052 v132 = cards_power[i].slot_index; | |
1053 } | |
1054 } | |
1055 else | |
1056 { | |
1057 for ( int i = all_player_cards_count - 1; i; --i ) | |
1058 { | |
1059 if ( pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]].can_be_discarded ) | |
1060 v132 = cards_power[i].slot_index; | |
1061 } | |
1062 for ( int i = 0; i < all_player_cards_count - 1; ++i ) | |
1063 { | |
1064 if ( CanCardBePlayed(player_num, cards_power[i].slot_index) && cards_power[i].card_power ) | |
1065 return PlayCard(player_num, cards_power[i].slot_index); | |
1066 } | |
1067 } | |
1068 return DiscardCard(player_num, v132); | |
1069 } | |
1183 | 1070 return true;//result != 0; |
0 | 1071 } |
1072 | |
1073 //----- (00409E6A) -------------------------------------------------------- | |
1074 void ArcomageGame::Loop() | |
1075 { | |
1197 | 1076 while ( !pArcomageGame->GameOver ) |
0 | 1077 { |
1078 pArcomageGame->field_F6 = 1; | |
1079 byte_4FAA24 = 1; | |
1197 | 1080 IncreaseResourcesInTurn(current_player_num); |
0 | 1081 LABEL_8: |
1185 | 1082 while ( byte_4FAA24 ) |
0 | 1083 { |
1200 | 1084 played_card_id = -1; |
1085 GetNextCardFromDeck(current_player_num); | |
0 | 1086 while ( 1 ) |
1087 { | |
1256 | 1088 byte_4FAA24 = PlayerTurn(current_player_num); |
1200 | 1089 if ( GetPlayerHandCardCount(current_player_num) <= minimum_cards_at_hand ) |
0 | 1090 break; |
1263 | 1091 need_to_discard_card = 1; |
0 | 1092 if ( pArcomageGame->field_F4 ) |
1093 goto LABEL_8; | |
1094 } | |
1263 | 1095 need_to_discard_card = 0; |
1185 | 1096 } |
1197 | 1097 pArcomageGame->GameOver = IsGameOver(); |
1098 if ( !pArcomageGame->GameOver ) | |
1256 | 1099 TurnChange(); |
0 | 1100 if ( pArcomageGame->field_F4 ) |
1197 | 1101 pArcomageGame->GameOver = 1; |
0 | 1102 } |
1197 | 1103 GameResultsApply(); |
1679 | 1104 if ( am_gameover ) |
1183 | 1105 dword_4FAA70 = 0; |
0 | 1106 else |
1107 dword_4FAA70 = -1; | |
2213 | 1108 |
1109 for( int i = 0; i < 10; ++i ) | |
1679 | 1110 { |
1111 array_4FABD0[i].field_40->Clear(1, 1); | |
1112 array_4FABD0[i].field_40->Free(); | |
1113 } | |
1038 | 1114 |
0 | 1115 pArcomageGame->pGameBackground.Release(); |
1116 pArcomageGame->pSprites.Release(); | |
1679 | 1117 pArcomageGame->bGameInProgress = false; |
1118 viewparams->bRedrawGameUI = true; | |
2394 | 1119 if ( pMovie_Track ) |
2453 | 1120 BackToHouseMenu(); |
2213 | 1121 for( int i = 0; i < 12; ++i ) |
1183 | 1122 pSoundList->UnloadSound(am_sounds[i], 1); |
0 | 1123 } |
938 | 1124 |
0 | 1125 //----- (00409FE9) -------------------------------------------------------- |
1197 | 1126 void SetStartGameData() |
1679 | 1127 { |
1194 | 1128 signed int j; // edx@7 |
1129 int card_id_counter; // edx@13 | |
1130 signed int i; // ecx@13 | |
1131 signed int card_dispenser_counter; // eax@13 | |
0 | 1132 |
2154 | 1133 current_player_num = am_default_starting_player; |
1197 | 1134 SetStartConditions(); |
2213 | 1135 for( i = 0; i < 2; ++i ) |
0 | 1136 { |
1194 | 1137 if ( i ) |
0 | 1138 { |
1194 | 1139 strcpy(am_Players[1].pPlayerName, pArcomageGame->pPlayer2Name); |
0 | 1140 if ( byte_4E185C ) |
1197 | 1141 am_Players[1].IsHisTurn = 0; |
0 | 1142 else |
1197 | 1143 am_Players[1].IsHisTurn = 1; |
0 | 1144 } |
1145 else | |
1146 { | |
1194 | 1147 strcpy(am_Players[0].pPlayerName, pArcomageGame->pPlayer1Name); |
1197 | 1148 am_Players[0].IsHisTurn = 1; |
0 | 1149 } |
1200 | 1150 am_Players[i].tower_height = start_tower_height; |
1151 am_Players[i].wall_height = start_wall_height; | |
1152 am_Players[i].quarry_level = start_quarry_level; | |
1153 am_Players[i].magic_level = start_magic_level; | |
1154 am_Players[i].zoo_level = start_zoo_level; | |
1197 | 1155 am_Players[i].resource_bricks = start_bricks_amount; |
1156 am_Players[i].resource_gems = start_gems_amount; | |
1157 am_Players[i].resource_beasts = start_beasts_amount; | |
1194 | 1158 |
2213 | 1159 for ( j = 0; j < 10; ++j ) |
0 | 1160 { |
1194 | 1161 am_Players[i].cards_at_hand[j] = -1; |
0 | 1162 if ( am_byte_4E185D ) |
1163 { | |
1256 | 1164 am_Players[i].card_shift[j].x = -1; |
1165 am_Players[i].card_shift[j].y = -1; | |
0 | 1166 } |
1167 else | |
1168 { | |
1256 | 1169 am_Players[i].card_shift[j].x = 0; |
1170 am_Players[i].card_shift[j].y = 0; | |
0 | 1171 } |
1263 | 1172 } |
0 | 1173 } |
1679 | 1174 strcpy(deckMaster.name, "Master Deck"); |
2213 | 1175 for ( i = 0, card_dispenser_counter = -2, card_id_counter = 0; i < DECK_SIZE; ++i, ++card_dispenser_counter) |
1176 { | |
1177 deckMaster.cardsInUse[i] = 0; | |
1178 deckMaster.cards_IDs[i] = card_id_counter; | |
1179 switch ( card_dispenser_counter ) | |
1180 { | |
0 | 1181 case 0: |
1182 case 2: | |
1183 case 6: | |
1184 case 9: | |
1185 case 13: | |
1186 case 18: | |
1187 case 23: | |
1188 case 33: | |
1189 case 36: | |
1190 case 38: | |
1191 case 44: | |
1192 case 46: | |
1193 case 52: | |
1194 case 57: | |
1195 case 69: | |
1196 case 71: | |
1197 case 75: | |
1198 case 79: | |
1199 case 81: | |
1200 case 84: | |
1201 case 89: | |
2213 | 1202 break; |
1185 | 1203 default: |
2213 | 1204 ++card_id_counter; |
1205 } | |
1206 } | |
1207 FillPlayerDeck(); | |
0 | 1208 } |
1209 | |
1210 //----- (0040A198) -------------------------------------------------------- | |
1197 | 1211 void FillPlayerDeck() |
1194 | 1212 { |
1263 | 1213 signed int m; |
1214 int rand_deck_pos; | |
1215 char card_taken_flags[DECK_SIZE]; | |
1194 | 1216 int i,j; |
0 | 1217 |
1218 | 1218 ArcomageGame::PlaySound(20); |
1194 | 1219 memset(deckMaster.cardsInUse, 0,DECK_SIZE ); |
1220 memset(card_taken_flags, 0, DECK_SIZE); | |
1221 | |
2213 | 1222 for ( i = 0; i < 2; ++i ) |
0 | 1223 { |
2213 | 1224 for ( j = 0; j < 10; ++j ) |
0 | 1225 { |
1194 | 1226 if ( am_Players[i].cards_at_hand[j] > -1 ) |
0 | 1227 { |
1263 | 1228 for (m = 0; m<DECK_SIZE; ++m) |
2213 | 1229 { |
1230 if (deckMaster.cards_IDs[m] == am_Players[i].cards_at_hand[j] && deckMaster.cardsInUse[m] == 0) | |
1231 { | |
1232 deckMaster.cardsInUse[m] = 1; | |
1233 break; | |
1234 } | |
1235 } | |
0 | 1236 } |
1237 } | |
1238 } | |
1194 | 1239 |
2213 | 1240 for ( i = 0; i < DECK_SIZE; ++i ) |
0 | 1241 { |
1242 do | |
1263 | 1243 rand_deck_pos = rand() % DECK_SIZE; |
1244 while (card_taken_flags[rand_deck_pos] == 1 ); | |
1245 | |
1246 card_taken_flags[rand_deck_pos]=1; | |
1247 playDeck.cards_IDs[i] = deckMaster.cards_IDs[rand_deck_pos]; | |
1248 playDeck.cardsInUse[i] = deckMaster.cardsInUse[rand_deck_pos]; | |
0 | 1249 } |
1194 | 1250 |
1200 | 1251 deck_walk_index = 0; |
0 | 1252 amuint_4FABC4 = -1; |
1253 pArcomageGame->field_F6 = 1; | |
1194 | 1254 |
0 | 1255 } |
1256 | |
1257 //----- (0040A255) -------------------------------------------------------- | |
1200 | 1258 void InitalHandsFill() |
2213 | 1259 { |
1200 | 1260 for (int i = 0; i < minimum_cards_at_hand; ++i ) |
0 | 1261 { |
2213 | 1262 GetNextCardFromDeck(0); |
1263 GetNextCardFromDeck(1); | |
0 | 1264 } |
1265 pArcomageGame->field_F6 = 1; | |
1266 } | |
1267 // 4E1874: using guessed type int dword_4E1874; | |
1268 | |
1269 //----- (0040A283) -------------------------------------------------------- | |
1200 | 1270 void GetNextCardFromDeck( int player_num ) |
2213 | 1271 { |
1200 | 1272 signed int deck_index; // eax@1 |
1273 int new_card_id; // edi@1 | |
1274 signed int card_slot_indx; // eax@7 | |
1275 | |
1276 deck_index = deck_walk_index; | |
1277 for(;;) | |
0 | 1278 { |
1200 | 1279 if ( deck_index >= DECK_SIZE ) |
0 | 1280 { |
1197 | 1281 FillPlayerDeck(); |
1200 | 1282 deck_index = deck_walk_index; |
0 | 1283 } |
1200 | 1284 if ( !playDeck.cardsInUse[deck_index] ) |
2213 | 1285 { |
1286 new_card_id = playDeck.cards_IDs[deck_index]; | |
1287 ++deck_index; | |
1288 deck_walk_index = deck_index; | |
1289 break; | |
1290 } | |
1200 | 1291 ++deck_index; |
1292 deck_walk_index = deck_index; | |
0 | 1293 } |
2213 | 1294 |
1197 | 1295 ArcomageGame::PlaySound(21); |
1200 | 1296 card_slot_indx = GetEmptyCardSlotIndex(player_num); |
1297 if ( card_slot_indx != -1 ) | |
0 | 1298 { |
1200 | 1299 amuint_4FAA4C = card_slot_indx; |
1300 am_Players[player_num].cards_at_hand[card_slot_indx] = new_card_id; | |
1256 | 1301 am_Players[player_num].card_shift[card_slot_indx].x = rand_interval(-4, 4); |
1302 am_Players[player_num].card_shift[card_slot_indx].y = rand_interval(-4, 4); | |
0 | 1303 pArcomageGame->field_F6 = 1; |
1304 byte_4FAA2D = 1; | |
1305 } | |
1306 } | |
1186 | 1307 |
0 | 1308 //----- (0040A324) -------------------------------------------------------- |
1185 | 1309 int GetEmptyCardSlotIndex( int player_num ) |
2213 | 1310 { |
1311 for ( int i = 0; i < 10; ++i ) | |
1312 { | |
1313 if (am_Players[player_num].cards_at_hand[i] == -1) | |
1314 return i; | |
1315 } | |
1316 return -1; | |
0 | 1317 } |
1318 | |
1319 //----- (0040A346) -------------------------------------------------------- | |
1679 | 1320 void IncreaseResourcesInTurn(int player_num) |
1185 | 1321 { |
1197 | 1322 am_Players[player_num].resource_bricks += quarry_bonus + am_Players[player_num].quarry_level; |
1323 am_Players[player_num].resource_gems += magic_bonus + am_Players[player_num].magic_level; | |
1263 | 1324 am_Players[player_num].resource_beasts += zoo_bonus + am_Players[player_num].zoo_level; |
0 | 1325 } |
1183 | 1326 |
0 | 1327 |
1328 //----- (0040A383) -------------------------------------------------------- | |
1256 | 1329 void TurnChange() |
1679 | 1330 { |
1263 | 1331 char player_name[64]; // [sp+4h] [bp-64h]@4 |
1332 // RECT v6; // [sp+44h] [bp-24h]@6 | |
0 | 1333 ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7 |
1194 | 1334 POINT v11; // [sp+60h] [bp-8h]@4 |
0 | 1335 |
1336 if ( !pArcomageGame->field_F4 ) | |
1337 { | |
1197 | 1338 if ( am_Players[0].IsHisTurn != 1 || am_Players[1].IsHisTurn != 1 ) |
0 | 1339 { |
1197 | 1340 ++current_player_num; |
0 | 1341 am_byte_4FAA75 = 1; |
1197 | 1342 if ( current_player_num >= 2 ) |
1343 current_player_num = 0; | |
0 | 1344 } |
1345 else | |
1346 { | |
1347 //nullsub_1(); | |
1218 | 1348 // v11.x = 0; |
1349 // v11.y = 0; | |
1679 | 1350 strcpy(player_name, "The Next Player is: ");//"Ñëåä" |
2213 | 1351 // v0 = 0; |
1194 | 1352 v11.y = 200; |
1218 | 1353 v11.x = 320; // - 12 * v0 / 2; |
1679 | 1354 am_DrawText(-1, player_name, &v11); |
0 | 1355 am_byte_4FAA75 = 1; |
1263 | 1356 ++current_player_num; |
1357 if ( current_player_num >= 2 ) | |
1197 | 1358 current_player_num = 0; |
1263 | 1359 strcpy(player_name, am_Players[current_player_num].pPlayerName); |
2213 | 1360 // v4 = 0; |
1194 | 1361 v11.y = 260; |
1218 | 1362 v11.x = 320;// - 12 * v4 / 2; |
1679 | 1363 am_DrawText(-1, player_name, &v11); |
2213 | 1364 /* v6.left = 0; |
1194 | 1365 v6.right = 640; |
1366 v6.top = 0; | |
1197 | 1367 v6.bottom = 480;*/ |
0 | 1368 //nullsub_1(); |
1679 | 1369 pRenderer->Present(); |
0 | 1370 //nullsub_1(); |
1371 while ( 1 ) | |
2213 | 1372 { |
1373 while ( !ArcomageGame::MsgLoop(20, &v10) ) | |
1374 ; | |
1375 if ( v10.field_0 == 1 ) | |
1376 { | |
1377 if ( v10.field_4 ) | |
1378 break; | |
1379 //nullsub_1(); | |
1380 continue; | |
1381 } | |
1382 if (( v10.field_0 > 4 ) && ( v10.field_0 <= 8 )) | |
1383 break; | |
1384 if ( v10.field_0 == 10 ) | |
1385 { | |
1386 pArcomageGame->field_F4 = 1; | |
1387 byte_4FAA74 = 1; | |
1388 break; | |
1389 } | |
0 | 1390 } |
1197 | 1391 /* v11.x = 0; |
1194 | 1392 v11.y = 0; |
1393 v6.left = 0; | |
1394 v6.right = 640; | |
1395 v6.top = 0; | |
1197 | 1396 v6.bottom = 480;*/ |
0 | 1397 //nullsub_1(); |
1679 | 1398 pRenderer->Present(); |
0 | 1399 } |
1400 } | |
1401 } | |
1402 | |
1403 //----- (0040A514) -------------------------------------------------------- | |
1197 | 1404 bool IsGameOver() |
1679 | 1405 { |
0 | 1406 bool result; // eax@1 |
1183 | 1407 |
1408 result = false; | |
2213 | 1409 for( int i = 0; i < 2; ++i ) |
0 | 1410 { |
1197 | 1411 if ( am_Players[i].tower_height <= 0 ) |
1412 result = true; | |
1413 if ( am_Players[i].tower_height >= max_tower_height ) | |
1183 | 1414 result = true; |
1197 | 1415 if ( am_Players[i].resource_bricks >= max_resources_amount |
1416 || am_Players[i].resource_gems >= max_resources_amount | |
1417 || am_Players[i].resource_beasts >= max_resources_amount ) | |
1183 | 1418 result = true; |
0 | 1419 } |
1679 | 1420 |
1421 return am_gameover = result; | |
0 | 1422 } |
1197 | 1423 |
0 | 1424 //----- (0040A560) -------------------------------------------------------- |
1256 | 1425 char PlayerTurn( int player_num ) |
2213 | 1426 { |
2334 | 1427 // int v1; // ebp@0 |
1428 // unsigned __int64 v2; // qax@3 | |
0 | 1429 unsigned __int64 v3; // kr00_8@3 |
1218 | 1430 |
2334 | 1431 // int v5; // esi@67 |
1432 // char Dest[100]; // [sp+8h] [bp-A8h]@67 | |
1433 // int v8; // [sp+6Ch] [bp-44h]@3 | |
1194 | 1434 RECT pSrcXYZW; // [sp+70h] [bp-40h]@75 |
2334 | 1435 // int v10[4]; // [sp+80h] [bp-30h]@69 |
1194 | 1436 POINT pTargetXY; // [sp+90h] [bp-20h]@75 |
0 | 1437 ArcomageGame_stru1 a2; // [sp+98h] [bp-18h]@8 |
1263 | 1438 int animation_stage; // [sp+A4h] [bp-Ch]@1 |
2334 | 1439 // char v15; // [sp+AEh] [bp-2h]@63 |
1263 | 1440 bool break_loop; // [sp+AFh] [bp-1h]@1 |
0 | 1441 |
1442 uCardID = -1; | |
1263 | 1443 break_loop = false; |
1444 animation_stage = 20; | |
0 | 1445 byte_4FAA00 = 0; |
1446 dword_4FAA68 = 0; | |
1447 amuint_4FAA38 = 10; | |
1448 amuint_4FAA34 = 5; | |
1449 if ( amuint_4FAA4C != -1 ) | |
1450 byte_4FAA2D = 1; | |
1451 do | |
1452 { | |
2213 | 1453 do |
1454 { | |
1455 v3 = pEventTimer->Time() - pArcomageGame->event_timer_time; | |
1456 } | |
1457 while (v3 < 6); | |
1679 | 1458 pArcomageGame->event_timer_time = (unsigned int)pEventTimer->Time(); |
0 | 1459 if ( pArcomageGame->field_F4 ) |
2213 | 1460 break_loop = true; |
0 | 1461 ArcomageGame::MsgLoop(0, &a2); |
1462 switch ( a2.field_0 ) | |
1463 { | |
1464 case 2: | |
1465 if ( a2.field_4 == 129 && a2.field_8 == 1 ) | |
1466 { | |
1467 pAudioPlayer->StopChannels(-1, -1); | |
1468 dword_4FAA68 = 0; | |
1263 | 1469 break_loop = true; |
1185 | 1470 pArcomageGame->field_F4 = 1; |
0 | 1471 } |
1472 break; | |
1473 case 9: | |
1474 pArcomageGame->field_F6 = 1; | |
1475 break; | |
1194 | 1476 case 10: |
0 | 1477 pAudioPlayer->StopChannels(-1, -1); |
1478 byte_4FAA74 = 1; | |
1263 | 1479 break_loop = true; |
0 | 1480 pArcomageGame->field_F4 = 1; |
1481 break; | |
1482 } | |
1218 | 1483 |
1263 | 1484 if (am_Players[current_player_num].IsHisTurn != 1 && |
1485 !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D ) | |
0 | 1486 { |
1487 if ( am_byte_4FAA75 ) | |
1488 am_byte_4FAA76 = 1; | |
1256 | 1489 OpponentsAITurn(current_player_num); |
0 | 1490 byte_4FAA2E = 1; |
1491 } | |
1492 if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 ) | |
1493 amuint_4FAA38 = 10; | |
1218 | 1494 if ( byte_4FAA2E || byte_4FAA2D ||am_Players[current_player_num].IsHisTurn != 1 ) |
0 | 1495 { |
1496 pArcomageGame->field_F6 = 1; | |
1497 if ( byte_4FAA2D ) | |
1498 { | |
1499 --amuint_4FAA38; | |
1500 if ( amuint_4FAA38 < 0 ) | |
1501 { | |
1502 byte_4FAA2D = 0; | |
1503 amuint_4FAA38 = 10; | |
1263 | 1504 break_loop = false; |
0 | 1505 } |
1506 } | |
1507 if ( byte_4FAA2E ) | |
1508 { | |
1263 | 1509 --animation_stage; |
1510 if ( animation_stage < 0 ) | |
0 | 1511 { |
1512 if ( dword_4FAA68 > 1 ) | |
1513 { | |
1514 --dword_4FAA68; | |
1515 byte_4FAA00 = 0; | |
1516 } | |
1517 else | |
1263 | 1518 break_loop = true; |
0 | 1519 byte_4FAA2E = 0; |
1263 | 1520 animation_stage = 20; |
0 | 1521 } |
1522 } | |
1523 } | |
1524 else | |
1525 { | |
1263 | 1526 if ( need_to_discard_card ) |
0 | 1527 { |
1256 | 1528 if ( a2.field_0 == 7 && DiscardCard(player_num, current_card_slot_index) ) |
0 | 1529 { |
1530 if ( am_byte_4FAA75 ) | |
1531 am_byte_4FAA76 = 1; | |
1532 if ( dword_4FAA64 > 0 ) | |
1533 { | |
1534 --dword_4FAA64; | |
1263 | 1535 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
0 | 1536 } |
1537 byte_4FAA2E = 1; | |
1538 } | |
1256 | 1539 if ( a2.field_0 == 8 && DiscardCard(player_num, current_card_slot_index) ) |
0 | 1540 { |
1541 if ( am_byte_4FAA75 ) | |
1542 am_byte_4FAA76 = 1; | |
1543 if ( dword_4FAA64 > 0 ) | |
1544 { | |
1545 --dword_4FAA64; | |
1263 | 1546 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
0 | 1547 } |
1548 byte_4FAA2E = 1; | |
1549 } | |
1550 } | |
1551 else | |
1552 { | |
1553 if ( a2.field_0 == 7 ) | |
1554 { | |
1200 | 1555 if ( PlayCard(player_num, current_card_slot_index) ) |
0 | 1556 { |
1557 byte_4FAA2E = 1; | |
1558 if ( am_byte_4FAA75 ) | |
1559 am_byte_4FAA76 = 1; | |
1560 } | |
1561 } | |
1562 if ( a2.field_0 == 8 ) | |
1563 { | |
1256 | 1564 if ( DiscardCard(player_num, current_card_slot_index) ) |
0 | 1565 { |
1566 byte_4FAA2E = 1; | |
1567 if ( am_byte_4FAA75 ) | |
1568 am_byte_4FAA76 = 1; | |
1569 } | |
1570 } | |
1571 } | |
1572 } | |
1573 //nullsub_1(); | |
1218 | 1574 //if ( false ) |
1575 //{ | |
1576 // if ( !v15 ) | |
1577 // { | |
1578 // //nullsub_1(); | |
1579 // v15 = 1; | |
1580 // } | |
1581 //} | |
1582 //else | |
1583 //{ | |
1584 // v15 = 0; | |
1585 // } | |
1586 //if ( false ) | |
1587 //{ | |
1588 // //nullsub_1(); | |
1589 // //nullsub_1(); | |
1590 // // assert(false && "Invalid strcpy params"); | |
1591 // // inv_strcpy(nullptr, Dest); | |
1592 // v5 = 0;//unk::const_0(&unk_4E19FC, 0); | |
1593 // //nullsub_1(); | |
1594 // if ( v5 == 1 ) | |
1595 // { | |
1596 // pAudioPlayer->StopChannels(-1, -1); | |
1597 // v16 = 1; | |
1598 // pArcomageGame->field_F4 = 1; | |
1599 // dword_4FAA68 = 0; | |
1600 // } | |
1601 // /*v10[0] = 0; | |
1602 // v10[2] = 640; | |
1603 // v10[1] = 0; | |
1604 // v10[3] = 480;*/ | |
1605 // //nullsub_1(); | |
1606 //} | |
1209 | 1607 if ( dword_4FABB8 != DrawCardsRectangles(player_num) ) |
0 | 1608 { |
1263 | 1609 dword_4FABB8 = DrawCardsRectangles(player_num); |
1610 pArcomageGame->field_F6 = 1; | |
1209 | 1611 } |
0 | 1612 if ( pArcomageGame->field_F6 ) |
1613 { | |
1263 | 1614 DrawGameUI(animation_stage); |
0 | 1615 DoBlt_Copy(pArcomageGame->pBackgroundPixels); |
1616 pArcomageGame->field_F6 = 0; | |
1617 } | |
1618 if ( pArcomageGame->field_F9 ) | |
1619 { | |
1194 | 1620 pTargetXY.x = 0; |
1621 pTargetXY.y = 0; | |
1622 pSrcXYZW.left = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
1623 pSrcXYZW.right = window->GetWidth(); |
1194 | 1624 pSrcXYZW.top = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
1625 pSrcXYZW.bottom = window->GetHeight(); |
0 | 1626 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1); |
2154 | 1627 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); |
0 | 1628 am_EndScene(); |
1263 | 1629 DrawGameUI(animation_stage); |
0 | 1630 pRenderer->Present(); |
1631 pArcomageGame->field_F9 = 0; | |
1632 } | |
1633 } | |
1263 | 1634 while ( !break_loop ); |
0 | 1635 return dword_4FAA68 > 0; |
1636 } | |
1194 | 1637 |
0 | 1638 |
1639 //----- (0040A9AF) -------------------------------------------------------- | |
1263 | 1640 void DrawGameUI( int animation_stage ) |
1679 | 1641 { |
0 | 1642 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
1197 | 1643 DrawRectanglesForText(); |
0 | 1644 am_EndScene(); |
1197 | 1645 |
0 | 1646 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
2213 | 1647 DrawCards();//ðèñóåì êàðòû |
1648 DrawPlayersTowers();//ðèñóåì áàøíþ | |
1649 DrawPlayersWall();//ðèñóåì ñòåíó | |
1650 DrawPlayersText();//ðèñóåì òåêñò | |
0 | 1651 am_EndScene(); |
1197 | 1652 |
0 | 1653 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
1263 | 1654 DrawCardAnimation(animation_stage); |
1185 | 1655 |
2213 | 1656 for( int i = 0; i < 10; ++i ) |
1657 { | |
1658 if (array_4FABD0[i].have_effect) | |
1659 array_4FABD0[i].field_40->DrawEffect(); | |
1660 } | |
1200 | 1661 current_card_slot_index = DrawCardsRectangles(current_player_num); |
1263 | 1662 DrawSparks(); |
0 | 1663 am_EndScene(); |
1664 } | |
1665 | |
1666 //----- (0040AA4E) -------------------------------------------------------- | |
1263 | 1667 void DrawSparks() |
2213 | 1668 { |
1263 | 1669 int rgb_pixel_color; // [sp-4h] [bp-2Ch]@4 |
1670 unsigned int pixel_color; | |
1185 | 1671 |
2213 | 1672 for ( int i = 0; i < 10; ++i ) |
1673 { | |
1674 if(array_4FABD0[i].have_effect && (array_4FABD0[i].field_40->_40E2A7()==2)) | |
1675 { | |
1676 rgb_pixel_color = 0x0000FF00; | |
1677 if ( !array_4FABD0[i].effect_sign ) | |
1678 rgb_pixel_color = 0x000000FF; | |
1679 pixel_color = R8G8B8_to_TargetFormat(rgb_pixel_color); | |
1680 for( int j = 0; j < 150; ++j ) | |
0 | 1681 { |
2213 | 1682 if (array_4FABD0[i].effect_sparks[j].have_spark > 0) |
1683 { | |
1684 if ( j%2 ) | |
1685 DrawPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); | |
1686 else | |
1687 DrawSquare(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); | |
1688 } | |
0 | 1689 } |
2213 | 1690 } |
1691 } | |
0 | 1692 } |
1693 | |
1694 //----- (0040AB0A) -------------------------------------------------------- | |
1197 | 1695 void DrawRectanglesForText() |
2213 | 1696 { |
1183 | 1697 RECT pSrcRect; // [sp+Ch] [bp-18h]@1 |
1698 POINT pTargetXY; // [sp+1Ch] [bp-8h]@1 | |
1679 | 1699 |
1197 | 1700 //resources rectangles |
1263 | 1701 pSrcRect.left = 765; |
1183 | 1702 pSrcRect.top = 0; |
1703 pSrcRect.right = 843; | |
1704 pSrcRect.bottom = 216; | |
1705 | |
1706 pTargetXY.x = 8; | |
1707 pTargetXY.y = 56; | |
2154 | 1708 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2); |
1183 | 1709 |
1710 pTargetXY.x = 555; | |
1711 pTargetXY.y = 56; | |
2154 | 1712 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2); |
1183 | 1713 |
1197 | 1714 //players name rectangle |
1183 | 1715 pSrcRect.left = 283; |
1263 | 1716 pSrcRect.top = 166; |
1183 | 1717 pSrcRect.right = 361; |
1718 pSrcRect.bottom = 190; | |
1719 pTargetXY.x = 8; | |
1720 pTargetXY.y = 13; | |
2154 | 1721 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1722 |
1723 pTargetXY.x = 555; | |
1724 pTargetXY.y = 13; | |
2154 | 1725 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1726 |
1241 | 1727 //tower height rectangle |
1183 | 1728 pSrcRect.left = 234; |
1263 | 1729 pSrcRect.top = 166; |
1183 | 1730 pSrcRect.right = 283; |
1731 pSrcRect.bottom = 190; | |
1732 pTargetXY.x = 100; | |
1733 pTargetXY.y = 296; | |
2154 | 1734 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1735 |
1736 pTargetXY.x = 492; | |
1737 pTargetXY.y = 296; | |
2154 | 1738 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1739 |
1241 | 1740 //wall height rectangle |
1263 | 1741 pSrcRect.left = 192; |
1742 pSrcRect.top = 166; | |
1183 | 1743 pSrcRect.right = 234; |
1744 pSrcRect.bottom = 190; | |
1745 pTargetXY.x = 168; | |
1746 pTargetXY.y = 296; | |
2154 | 1747 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1748 |
1749 pTargetXY.x = 430; | |
1750 pTargetXY.y = 296; | |
2154 | 1751 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
0 | 1752 } |
1753 | |
1754 //----- (0040AC5F) -------------------------------------------------------- | |
1197 | 1755 void DrawPlayersText() |
2213 | 1756 { |
1197 | 1757 int res_value; // ecx@18 |
1758 char text_buff[32]; // [sp+Ch] [bp-28h]@2 | |
1759 POINT text_position; // [sp+2Ch] [bp-8h]@2 | |
0 | 1760 |
1263 | 1761 if ( need_to_discard_card ) |
0 | 1762 { |
1209 | 1763 strcpy(text_buff, pGlobalTXT_LocalizationStrings[266]);// DISCARD A CARD |
1197 | 1764 text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2; |
1765 text_position.y = 306; | |
1679 | 1766 am_DrawText(-1, text_buff, &text_position); |
0 | 1767 } |
1209 | 1768 strcpy( text_buff, am_Players[0].pPlayerName); |
1197 | 1769 if ( !current_player_num ) |
1209 | 1770 strcat(text_buff, "***"); |
1197 | 1771 text_position.x = 47 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1772 text_position.y = 21; | |
1679 | 1773 am_DrawText(-1, text_buff, &text_position); |
1197 | 1774 |
1209 | 1775 strcpy(text_buff, am_Players[1].pPlayerName); |
1197 | 1776 if ( current_player_num == 1 ) |
1209 | 1777 strcat(text_buff, "***" ); |
1197 | 1778 text_position.x = 595 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1779 text_position.y = 21; | |
1679 | 1780 am_DrawText(-1, text_buff, &text_position); |
1781 | |
1782 am_IntToString(am_Players[0].tower_height, text_buff); | |
1197 | 1783 text_position.x = 123 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1784 text_position.y = 305; | |
1679 | 1785 am_DrawText(-1, text_buff, &text_position); |
1786 | |
1787 am_IntToString(am_Players[1].tower_height, text_buff); | |
1197 | 1788 text_position.x = 515 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1789 text_position.y = 305; | |
1679 | 1790 am_DrawText(-1, text_buff, &text_position); |
1791 | |
1792 am_IntToString(am_Players[0].wall_height, text_buff); | |
1197 | 1793 text_position.x = 188 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1794 text_position.y = 305; | |
1679 | 1795 am_DrawText(-1, text_buff, &text_position); |
1796 | |
1797 am_IntToString(am_Players[1].wall_height, text_buff); | |
1197 | 1798 text_position.x = 451 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1799 text_position.y = 305; | |
1679 | 1800 am_DrawText(-1, text_buff, &text_position); |
1197 | 1801 |
1802 res_value = am_Players[0].quarry_level; | |
1263 | 1803 if ( use_start_bonus ) |
1197 | 1804 res_value =am_Players[0].quarry_level + quarry_bonus; |
1679 | 1805 am_IntToString(res_value, text_buff); |
1197 | 1806 text_position.x = 14;// - 6 * 0 / 2; |
1807 text_position.y = 92; | |
1808 DrawPlayerLevels(-1, text_buff, &text_position); | |
1809 | |
1810 res_value = am_Players[1].quarry_level; | |
1263 | 1811 if ( use_start_bonus ) |
1197 | 1812 res_value = am_Players[1].quarry_level + quarry_bonus; |
1679 | 1813 am_IntToString(res_value, text_buff); |
1197 | 1814 // v2 = 0; |
1815 text_position.y = 92; | |
1816 text_position.x = 561; //- 6 * v2 / 2; | |
1817 DrawPlayerLevels(-1, text_buff, &text_position); | |
1818 | |
1819 res_value = am_Players[0].magic_level; | |
1263 | 1820 if ( use_start_bonus ) |
1197 | 1821 res_value = am_Players[0].magic_level + magic_bonus; |
1679 | 1822 am_IntToString(res_value, text_buff); |
1197 | 1823 // v4 = 0; |
1824 text_position.y = 164; | |
1825 text_position.x = 14; //- 6 * v4 / 2; | |
1826 DrawPlayerLevels(-1, text_buff, &text_position); | |
1827 | |
1828 res_value = am_Players[1].magic_level; | |
1263 | 1829 if ( use_start_bonus ) |
1830 res_value = am_Players[1].magic_level + magic_bonus; | |
1679 | 1831 am_IntToString(res_value, text_buff); |
1197 | 1832 // v6 = 0; |
1833 text_position.y = 164; | |
1834 text_position.x = 561; //- 6 * v6 / 2; | |
1835 DrawPlayerLevels(-1, text_buff, &text_position); | |
1836 | |
1200 | 1837 res_value = am_Players[0].zoo_level; |
1263 | 1838 if ( use_start_bonus ) |
1201 | 1839 res_value = am_Players[0].zoo_level + zoo_bonus; |
1679 | 1840 am_IntToString(res_value, text_buff); |
1197 | 1841 // v8 = 0; |
1842 text_position.y = 236; | |
1843 text_position.x = 14;// - 6 * v8 / 2; | |
1844 DrawPlayerLevels(-1, text_buff, &text_position); | |
1845 | |
1200 | 1846 res_value = am_Players[1].zoo_level; |
1263 | 1847 if ( use_start_bonus ) |
1201 | 1848 res_value = am_Players[1].zoo_level + zoo_bonus; |
1679 | 1849 am_IntToString(res_value, text_buff); |
1197 | 1850 // v10 = 0; |
1851 text_position.y = 236; | |
1852 text_position.x = 561;// - 6 * v10 / 2; | |
1853 DrawPlayerLevels(-1, text_buff, &text_position); | |
1854 | |
1679 | 1855 am_IntToString(am_Players[0].resource_bricks, text_buff); |
1197 | 1856 text_position.y = 114; |
1857 text_position.x = 10; | |
1858 DrawBricksCount(-1, text_buff, &text_position); | |
1859 | |
1679 | 1860 am_IntToString(am_Players[1].resource_bricks, text_buff); |
1197 | 1861 text_position.x = 557; |
1862 text_position.y = 114; | |
1863 DrawBricksCount(-1, text_buff, &text_position); | |
1864 | |
1679 | 1865 am_IntToString(am_Players[0].resource_gems, text_buff); |
1197 | 1866 text_position.x = 10; |
1867 text_position.y = 186; | |
1868 DrawGemsCount(-1, text_buff, &text_position); | |
1869 | |
1679 | 1870 am_IntToString(am_Players[1].resource_gems, text_buff); |
1197 | 1871 text_position.x = 557; |
1872 text_position.y = 186; | |
1873 DrawGemsCount(-1, text_buff, &text_position); | |
1874 | |
1679 | 1875 am_IntToString(am_Players[0].resource_beasts, text_buff); |
1197 | 1876 text_position.x = 10; |
1877 text_position.y = 258; | |
1878 DrawBeastsCount(-1, text_buff, &text_position); | |
1879 | |
1679 | 1880 am_IntToString(am_Players[1].resource_beasts, text_buff); |
1197 | 1881 text_position.x = 557; |
1882 text_position.y = 258; | |
1883 DrawBeastsCount(-1, text_buff, &text_position); | |
0 | 1884 } |
1197 | 1885 |
0 | 1886 |
1887 //----- (0040B102) -------------------------------------------------------- | |
1197 | 1888 void DrawPlayerLevels( int a1, char *text, POINT *pXY ) |
2213 | 1889 { |
1194 | 1890 char *v3; // esi@1 |
1891 unsigned char test_char; // bl@2 | |
1892 int v7; // eax@3 | |
1893 RECT pSrcRect; | |
1894 POINT pTargetPoint; | |
1895 | |
1896 v3 = text; | |
1897 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1898 pTargetPoint.x = pXY->x; | |
1899 pTargetPoint.y = pXY->y; | |
1900 do | |
1901 { | |
1902 test_char = *v3; | |
1903 ++v3; | |
1904 if ( test_char ) | |
1905 { | |
1906 v7 = 22 * test_char; | |
1907 pSrcRect.right = v7 - 842; | |
1908 pSrcRect.left = v7 - 864; | |
1909 pSrcRect.top = 190; | |
1910 pSrcRect.bottom = 207; | |
2154 | 1911 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetPoint, pArcomageGame->field_54, 1); |
1194 | 1912 pTargetPoint.x += 22; |
1913 } | |
1914 } | |
1915 while ( test_char!= 0 ); | |
1916 am_EndScene(); | |
0 | 1917 } |
1918 | |
1919 //----- (0040B17E) -------------------------------------------------------- | |
1197 | 1920 void DrawBricksCount( int a1, char* text, POINT *pXY ) |
2213 | 1921 { |
1922 char *v3; // esi@1 | |
1923 unsigned char test_char; // bl@2 | |
1924 int v7; // eax@3 | |
1925 RECT pSrcRect; | |
1926 POINT pTargetPoint; | |
1927 | |
1928 v3 = text; | |
1929 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1930 pTargetPoint.x = pXY->x; | |
1931 pTargetPoint.y = pXY->y; | |
1932 do | |
1933 { | |
1934 test_char = *v3; | |
1935 ++v3; | |
1936 if ( test_char ) | |
0 | 1937 { |
2213 | 1938 v7 = 13 * test_char; |
1939 pSrcRect.left = v7 - 370; | |
1940 pSrcRect.right = v7 - 357; | |
1941 pSrcRect.top = 128; | |
1942 pSrcRect.bottom = 138; | |
1943 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
1944 pTargetPoint.x += 13; | |
1945 } | |
1946 } | |
1947 while ( test_char!= 0 ); | |
1948 am_EndScene(); | |
0 | 1949 } |
1950 | |
1951 //----- (0040B1F3) -------------------------------------------------------- | |
1197 | 1952 void DrawGemsCount( int a1, char* text, POINT* pXY ) |
2213 | 1953 { |
1954 char *v3; // esi@1 | |
1955 unsigned char test_char; // bl@2 | |
1956 int v7; // eax@3 | |
1957 RECT pSrcRect; | |
1958 POINT pTargetPoint; | |
1959 | |
1960 v3 = text; | |
1961 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1962 pTargetPoint.x = pXY->x; | |
1963 pTargetPoint.y = pXY->y; | |
1964 do | |
1965 { | |
1966 test_char = *v3; | |
1967 ++v3; | |
1968 if ( test_char ) | |
0 | 1969 { |
2213 | 1970 v7 = 13 * test_char; |
1971 pSrcRect.left = v7 - 370; | |
1972 pSrcRect.right = v7 - 357; | |
1973 pSrcRect.top = 138; | |
1974 pSrcRect.bottom = 148; | |
1975 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
1976 pTargetPoint.x += 13; | |
1977 } | |
1978 } | |
1979 while ( test_char!= 0 ); | |
1980 am_EndScene(); | |
0 | 1981 } |
1982 | |
1983 //----- (0040B268) -------------------------------------------------------- | |
1197 | 1984 void DrawBeastsCount( int a1, char *text, POINT *pXY ) |
2213 | 1985 { |
1986 char *v3; // esi@1 | |
1987 unsigned char test_char; // bl@2 | |
1988 int v7; // eax@3 | |
1989 RECT pSrcRect; | |
1990 POINT pTargetPoint; | |
1991 | |
1992 v3 = text; | |
1993 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1994 pTargetPoint.x = pXY->x; | |
1995 pTargetPoint.y = pXY->y; | |
1996 do | |
1997 { | |
1998 test_char = *v3; | |
1999 ++v3; | |
2000 if ( test_char ) | |
0 | 2001 { |
2213 | 2002 v7 = 13 * test_char; |
2003 pSrcRect.left = v7 - 370; | |
2004 pSrcRect.right = v7 - 357; | |
2005 pSrcRect.top = 148; | |
2006 pSrcRect.bottom = 158; | |
2007 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
2008 pTargetPoint.x += 13; | |
2009 } | |
2010 } | |
2011 while ( test_char!= 0 ); | |
2012 am_EndScene(); | |
0 | 2013 } |
2014 | |
2015 //----- (0040B2DD) -------------------------------------------------------- | |
1197 | 2016 void DrawPlayersTowers() |
2213 | 2017 { |
2018 int tower_height; // eax@1 | |
2019 int tower_top; // esi@3 | |
2020 RECT pSrcXYZW; // [sp+0h] [bp-18h]@3 | |
2021 POINT pTargetXY; // [sp+10h] [bp-8h]@3 | |
2022 | |
2023 tower_height= am_Players[0].tower_height; | |
2024 if ( am_Players[0].tower_height > max_tower_height ) | |
1197 | 2025 tower_height = max_tower_height; |
2213 | 2026 pSrcXYZW.top = 0; |
2027 pSrcXYZW.left = 892; | |
2028 pSrcXYZW.right = 937; | |
2029 tower_top = 200 * tower_height / max_tower_height; | |
2030 pSrcXYZW.bottom = tower_top; | |
2031 pTargetXY.x = 102; | |
2032 pTargetXY.y = 297 - tower_top; | |
2033 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ñòåíà áàøíè | |
2034 | |
2035 pSrcXYZW.top = 0; | |
2036 pSrcXYZW.left = 384; | |
2037 pSrcXYZW.right = 452; | |
2038 pSrcXYZW.bottom = 94; | |
2039 pTargetXY.y = 203 - tower_top; | |
2040 pTargetXY.x = 91; | |
2041 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);//âåðõóøêà áàøíè | |
2042 | |
2043 tower_height = am_Players[1].tower_height; | |
2044 if (am_Players[1].tower_height > max_tower_height ) | |
2045 tower_height = max_tower_height; | |
2046 tower_top = 200 * tower_height / max_tower_height; | |
2047 pSrcXYZW.top = 0; | |
2048 pSrcXYZW.left = 892; | |
2049 pSrcXYZW.right = 937; | |
2050 pSrcXYZW.bottom = tower_top; | |
2051 | |
2052 pTargetXY.x = 494; | |
2053 pTargetXY.y = 297 - tower_top; | |
2054 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2055 //draw tower up cone | |
2056 pSrcXYZW.left = 384; | |
2057 pSrcXYZW.right = 452; | |
2058 pSrcXYZW.top = 94; | |
2059 pSrcXYZW.bottom = 188; | |
2060 | |
2061 pTargetXY.x = 483; | |
2062 pTargetXY.y = 203 - tower_top; | |
2063 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
0 | 2064 } |
2065 // 4E1884: using guessed type int dword_4E1884; | |
2066 | |
2067 //----- (0040B400) -------------------------------------------------------- | |
1197 | 2068 void DrawPlayersWall() |
2213 | 2069 { |
2070 int v0; // eax@1 | |
2071 int v1; // eax@4 | |
2334 | 2072 // LONG v2; // ecx@4 |
2213 | 2073 int v3; // eax@5 |
2074 int v4; // eax@8 | |
2334 | 2075 // LONG v5; // esi@8 |
2213 | 2076 RECT pSrcXYZW; // [sp+4h] [bp-18h]@4 |
2077 POINT pTargetXY; // [sp+14h] [bp-8h]@4 | |
2078 | |
2079 v0 = am_Players[0].wall_height; | |
2080 | |
2081 if ( am_Players[0].wall_height > 100 ) | |
1194 | 2082 v0 = 100; |
1218 | 2083 |
2213 | 2084 if ( am_Players[0].wall_height > 0 ) |
2085 { | |
2086 pSrcXYZW.top = 0; | |
2087 pSrcXYZW.left = 843; | |
2088 v1 = 200 * v0 / 100; | |
2089 pSrcXYZW.right = 867; | |
2090 pSrcXYZW.bottom = v1; | |
2091 pTargetXY.x = 177; | |
2092 pTargetXY.y = 297 - v1; | |
2093 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2094 } | |
2095 v3 = am_Players[1].wall_height; | |
2096 if ( am_Players[1].wall_height > 100 ) | |
2097 v3 = 100; | |
2098 if ( am_Players[1].wall_height > 0 ) | |
2099 { | |
2100 pSrcXYZW.top = 0; | |
2101 pSrcXYZW.left = 843; | |
2102 v4 = 200 * v3 / 100; | |
2103 pSrcXYZW.right = 867; | |
2104 pSrcXYZW.bottom = v4; | |
2105 pTargetXY.x = 439; | |
2106 pTargetXY.y = 297 - v4; | |
2107 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2108 } | |
0 | 2109 } |
2110 | |
2111 //----- (0040B4B9) -------------------------------------------------------- | |
1209 | 2112 void DrawCards() |
2213 | 2113 { |
2114 int v0; // esi@1 | |
2334 | 2115 // char v1; // bl@1 |
2213 | 2116 int v2; // edi@1 |
2117 //int v3; // edx@2 | |
2334 | 2118 // int v4; // eax@3 |
2119 // int v5; // ecx@3 | |
2120 // int v6; // eax@3 | |
2213 | 2121 unsigned int v7; // ecx@4 |
2334 | 2122 // int v8; // eax@16 |
2123 // int v9; // ecx@16 | |
2124 // int v10; // eax@16 | |
2213 | 2125 signed int v11; // edi@18 |
2334 | 2126 // signed int v12; // esi@20 |
2127 // int v13; // ecx@20 | |
2128 // int v14; // eax@23 | |
2129 // signed int v15; // eax@25 | |
2130 // int v16; // ecx@25 | |
2131 // POINT *v17; // esi@26 | |
2132 // signed int v18; // eax@29 | |
2133 // AcromageCardOnTable *v19; // ecx@29 | |
2134 // int v20; // ecx@31 | |
2135 // int v21; // [sp-4h] [bp-2Ch]@8 | |
2213 | 2136 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@8 |
2137 POINT pTargetXY; // [sp+1Ch] [bp-Ch]@1 | |
2138 int v24; // [sp+24h] [bp-4h]@1 | |
2139 | |
2140 v0 = GetPlayerHandCardCount(current_player_num); | |
2141 pTargetXY.y = 327; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2142 v24 = (window->GetWidth() - 96 * v0) / (v0 + 1); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2143 pTargetXY.x = (window->GetWidth() - 96 * v0) / (v0 + 1); |
2213 | 2144 for ( v2 = 0; v2 < v0; ++v2 ) |
2145 { | |
2146 //v3 = current_player_num; | |
2147 if ( am_byte_4E185D) | |
1200 | 2148 { |
2213 | 2149 pTargetXY.x += am_Players[current_player_num].card_shift[v2].x; |
2150 pTargetXY.y += am_Players[current_player_num].card_shift[v2].y; | |
2151 } | |
1200 | 2152 v7 = am_Players[current_player_num].cards_at_hand[v2]; |
2213 | 2153 if ( am_Players[current_player_num].cards_at_hand[v2] == -1 ) |
2154 { | |
2155 ++v0; | |
2156 goto LABEL_15; | |
2157 } | |
1200 | 2158 if ( v2 != amuint_4FAA4C ) |
2213 | 2159 { |
2160 if ( am_Players[current_player_num].IsHisTurn == 0 && byte_505881 == 0 ) | |
2161 { | |
2162 pSrcXYZW.left = 192; | |
2163 pSrcXYZW.right = 288; | |
2164 pSrcXYZW.top = 0; | |
2165 pSrcXYZW.bottom = 128; | |
2166 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ðèñóåòñÿ îáîðîòíûå ñòîðîíû êàðò ïðîòèâíèêà | |
2167 pTargetXY.x += v24 + 96; | |
2168 goto LABEL_15; | |
2169 } | |
2170 pArcomageGame->GetCardRect(v7, &pSrcXYZW); | |
2171 if ( !CanCardBePlayed(current_player_num, v2) ) | |
2172 { | |
2173 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);//ðèñóþòñÿ íåàêòèâíûå êàðòû | |
2174 pTargetXY.x += v24 + 96; | |
2175 goto LABEL_15; | |
2176 } | |
2177 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ðèñóþòñÿ àêòèâíûå êàðòû | |
2178 } | |
1200 | 2179 pTargetXY.x += v24 + 96; |
2180 LABEL_15: | |
1241 | 2181 if ( am_byte_4E185D ) |
2213 | 2182 { |
2183 pTargetXY.x -= am_Players[current_player_num].card_shift[v2].x; | |
2184 pTargetXY.y -= am_Players[current_player_num].card_shift[v2].y; | |
1200 | 2185 } |
2213 | 2186 } |
2187 | |
2188 for ( v11 = 0; v11 < 10; ++v11 ) | |
2189 { | |
1200 | 2190 if ( am_byte_4FAA76 == 0 ) |
2213 | 2191 { |
2192 if ( shown_cards[v11].uCardId != -1 ) | |
2193 { | |
2194 pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW); | |
2195 pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0); | |
2196 } | |
2197 if ( shown_cards[v11].field_4 != 0 ) | |
2198 { | |
2199 pTargetXY.x = shown_cards[v11].field_18_point.x + 12; | |
2200 pTargetXY.y = shown_cards[v11].field_18_point.y + 40; | |
2201 pSrcXYZW.left = 843; | |
2202 pSrcXYZW.right = 916; | |
2203 pSrcXYZW.top = 200; | |
2204 pSrcXYZW.bottom = 216; | |
2205 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2206 } | |
2207 } | |
1200 | 2208 else if ( amuint_4FAA34 <= 0 ) |
2213 | 2209 { |
2210 if ( v11 == 9 ) | |
2211 { | |
2212 am_byte_4FAA76 = 0; | |
2213 am_byte_4FAA75 = 0; | |
2214 amuint_4FAA34 = 5; | |
2215 } | |
2216 if ( shown_cards[v11].uCardId != -1 ) | |
2217 amuint_4FABC4 = shown_cards[v11].uCardId; | |
2218 shown_cards[v11].uCardId = -1; | |
2219 shown_cards[v11].field_18_point.x = shown_cards[v11].field_8.x; | |
2220 shown_cards[v11].field_18_point.y = shown_cards[v11].field_8.y; | |
2221 shown_cards[v11].field_4 = 0; | |
2222 } | |
1200 | 2223 else |
2213 | 2224 { |
2225 if ( shown_cards[v11].uCardId != -1 ) | |
2226 { | |
2227 shown_cards[v11].field_18_point.x += shown_cards[v11].field_10_xplus; | |
2228 shown_cards[v11].field_18_point.y += shown_cards[v11].field_14_y_plus; | |
2229 pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW); | |
2230 pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0); | |
2231 } | |
1200 | 2232 } |
2213 | 2233 } |
2234 if ( am_byte_4FAA76 != 0 ) | |
2235 --amuint_4FAA34; | |
2236 pSrcXYZW.left = 192; | |
2237 pSrcXYZW.right = 288; | |
2238 pSrcXYZW.top = 0; | |
2239 pSrcXYZW.bottom = 128; | |
2240 pTargetXY.x = 120; | |
2241 pTargetXY.y = 18; | |
2242 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); | |
0 | 2243 } |
2244 | |
2245 //----- (0040B76F) -------------------------------------------------------- | |
1218 | 2246 void DrawCardAnimation( int animation_stage ) |
2213 | 2247 { |
2248 int v1; // eax@3 | |
2249 int v2; // eax@3 | |
2334 | 2250 // int v3; // esi@4 |
2213 | 2251 int v4; // eax@4 |
2334 | 2252 // POINT *v5; // edx@6 |
2253 // RECT *v6; // ecx@6 | |
2213 | 2254 int v8; // eax@15 |
2334 | 2255 // AcromageCardOnTable *v9; // ecx@15 |
2256 // int v10; // ecx@19 | |
2257 // int v11; // eax@20 | |
2258 // int v12; // ecx@20 | |
2259 // int v13; // eax@20 | |
2260 // unsigned int v14; // ecx@21 | |
2213 | 2261 double v15; // st7@22 |
2334 | 2262 // POINT *v16; // edx@23 |
2213 | 2263 int v17; // eax@32 |
2264 char v18; // zf@37 | |
2265 int v19; // eax@41 | |
2334 | 2266 // int v20; // eax@46 |
2267 // int v21; // ecx@46 | |
2268 // int v22; // eax@46 | |
2269 // int v23; // [sp-4h] [bp-2Ch]@28 | |
2213 | 2270 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@6 |
2271 POINT pTargetXY; // [sp+1Ch] [bp-Ch]@20 | |
2272 int v26; // [sp+24h] [bp-4h]@1 | |
2273 | |
2274 v26 = animation_stage; | |
2275 if ( amuint_4FAA4C != -1 ) | |
2276 { | |
2277 if ( amuint_4FAA38 >= 9 ) | |
1218 | 2278 { |
2213 | 2279 am_uint_4FAA44_blt_xy.y = 18; |
2280 am_uint_4FAA44_blt_xy.x = 120; | |
2281 v1 = GetPlayerHandCardCount(current_player_num); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2282 v2 = (window->GetWidth() - 96 * v1) / v1 + 96; |
2213 | 2283 if ( am_byte_4E185D ) |
2284 { | |
2285 // v3 = 188 * current_player_num + 8 * amuint_4FAA4C; | |
2286 // amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 + *(am_Players[0].arr_6C[0] + v3) - 120) / 10; | |
2287 amuint_4FAA3C_blt_xy.x=(amuint_4FAA4C * v2 + am_Players[current_player_num].card_shift[amuint_4FAA4C].x-120)/10; | |
2288 v4 = (am_Players[current_player_num].card_shift[amuint_4FAA4C].y+309) /10;//(*(&am_Players[0].arr_6C[0][1] + v3) + 309) / 10; | |
2289 } | |
2290 else | |
2291 { | |
2292 amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 - 120) / 10; | |
2293 v4 = 30; | |
2294 } | |
2295 am_uint_4FAA44_blt_xy.y += v4; | |
2296 am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; | |
2297 amuint_4FAA3C_blt_xy.y = v4; | |
2298 pSrcXYZW.left = 192; | |
2299 pSrcXYZW.top = 0; | |
2300 pSrcXYZW.right = 288; | |
2301 pSrcXYZW.bottom = 128; | |
2302 pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2); | |
2303 } | |
2304 else | |
1209 | 2305 { |
2213 | 2306 pSrcXYZW.left = 192; |
2307 pSrcXYZW.top = 0; | |
2308 pSrcXYZW.right = 288; | |
2309 pSrcXYZW.bottom = 128; | |
2310 am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; | |
2311 am_uint_4FAA44_blt_xy.y += amuint_4FAA3C_blt_xy.y; | |
2312 pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2); | |
2313 if ( !amuint_4FAA38 ) | |
2314 amuint_4FAA4C = -1; | |
2315 } | |
2316 } | |
2317 if ( uCardID != -1 ) | |
2318 { | |
2319 if ( v26 <= 10 ) | |
2320 { | |
2321 if ( v26 == 10 ) | |
2322 { | |
2323 pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); | |
2324 // v8 = 0; | |
2325 for ( v8 = 0; v8 < 10; ++v8 ) | |
1209 | 2326 { |
2213 | 2327 if (shown_cards[v8].uCardId==-1) |
2328 { | |
2329 shown_cards[v8].uCardId = uCardID; | |
2330 shown_cards[v8].field_4 = 1; | |
2331 break; | |
2332 } | |
1209 | 2333 } |
2213 | 2334 /* v9 = shown_cards; |
2335 while ( v9->uCardId != -1 ) | |
1218 | 2336 { |
2213 | 2337 ++v9; |
2338 ++v8; | |
2339 if ( v9 >= &dword_4FABB8 ) | |
2340 goto LABEL_20; | |
1218 | 2341 } |
2213 | 2342 v10 = v8; |
2343 shown_cards[v10].uCardId = uCardID; | |
2344 shown_cards[v10].field_4 = 1;*/ | |
2345 //LABEL_20: | |
2346 pTargetXY.x = shown_cards[v8].field_8.x; | |
2347 pTargetXY.y = shown_cards[v8].field_8.y; | |
2348 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); | |
2349 uCardID = -1; | |
2350 } | |
1209 | 2351 } |
2213 | 2352 else |
2353 { | |
2354 pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); | |
2355 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; | |
2356 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2357 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); | |
2358 } | |
2359 } | |
2360 if ( played_card_id != -1 ) | |
2361 { | |
2362 v15 = v26; | |
2363 if ( v15 > 15.0 ) | |
2364 { | |
2365 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2366 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; | |
2367 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2368 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 2); | |
2369 return; | |
2370 } | |
2371 if ( v15 == 15.0 ) | |
1209 | 2372 { |
2213 | 2373 ApplyCardToPlayer(current_player_num, played_card_id); |
2374 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2375 pTargetXY.x = 272; | |
2376 pTargetXY.y = 173; | |
2377 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2378 return; | |
2379 } | |
2380 if ( v15 == 5.0 ) | |
2381 { | |
2382 amuint_4FAA5C_blt_xy.x = 272; | |
2383 amuint_4FAA5C_blt_xy.y = 173; | |
2384 for ( v17 = 0; v17 < 10; ++v17 ) | |
2385 { | |
2386 if (shown_cards[v17].uCardId == -1) | |
2387 break; | |
2388 } | |
2389 amuint_4FAA54_blt_xy.x = (shown_cards[v17].field_8.x - 272) / 5; | |
2390 amuint_4FAA54_blt_xy.y = (shown_cards[v17].field_8.y - 173) / 5; | |
2391 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2392 pTargetXY.x = 272; | |
2393 pTargetXY.y = 173; | |
2394 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2395 return; | |
2396 } | |
2397 if ( v15 >= 5.0 ) | |
2398 v18 = v26 == 0; | |
1209 | 2399 else |
2213 | 2400 { |
2401 v18 = v26 == 0; | |
2402 if ( v26 > 0 ) | |
2403 { | |
2404 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
1209 | 2405 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; |
2406 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2154 | 2407 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); |
2213 | 2408 return; |
2409 } | |
1209 | 2410 } |
2213 | 2411 if ( !v18 ) |
1209 | 2412 { |
2213 | 2413 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); |
2414 pTargetXY.x = 272; | |
2415 pTargetXY.y = 173; | |
2416 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2417 return; | |
2418 } | |
1209 | 2419 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); |
2213 | 2420 for ( v19 = 0; v19 < 10; ++v19 ) |
2421 { | |
2422 if (shown_cards[v19].uCardId == -1) | |
2423 { | |
2424 shown_cards[v19].uCardId = played_card_id; | |
2425 break; | |
2426 } | |
2427 } | |
2428 pTargetXY.x = shown_cards[v19].field_8.x; | |
1209 | 2429 pTargetXY.y = shown_cards[v19].field_8.y; |
2154 | 2430 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); |
1209 | 2431 played_card_id = -1; |
2213 | 2432 } |
0 | 2433 } |
2434 | |
2435 //----- (0040BB12) -------------------------------------------------------- | |
1183 | 2436 void ArcomageGame::GetCardRect(unsigned int uCardID, RECT *pCardRect) |
0 | 2437 { |
2438 int v3; // edx@1 | |
2439 int v4; // ecx@1 | |
2440 | |
2441 v3 = pCards[uCardID].slot % 10; | |
2442 v4 = (pCards[uCardID].slot / 10 << 7) + 220; | |
1183 | 2443 pCardRect->top = v4; |
2444 pCardRect->left = 96 * v3; | |
2445 pCardRect->bottom = v4 + 128; | |
2446 pCardRect->right = 96 * v3 + 96; | |
0 | 2447 } |
2448 | |
2449 //----- (0040BB49) -------------------------------------------------------- | |
1185 | 2450 int GetPlayerHandCardCount( int player_num ) |
2213 | 2451 { |
1185 | 2452 int card_count; // eax@1 |
2453 | |
2454 card_count = 0; | |
2455 for(int i=0; i<10; ++i) | |
2213 | 2456 { |
2457 if (am_Players[player_num].cards_at_hand[i]!=-1) | |
2458 ++card_count; | |
2459 } | |
1185 | 2460 return card_count; |
0 | 2461 } |
2462 | |
2463 //----- (0040BB67) -------------------------------------------------------- | |
1200 | 2464 signed int DrawCardsRectangles( int player_num ) |
1679 | 2465 { |
2213 | 2466 int v5; // eax@3 |
2334 | 2467 // int i; // ecx@6 |
2213 | 2468 int color; // ST00_4@19 |
2469 RECT pXYZW; // [sp+Ch] [bp-3Ch]@3 | |
2470 stru273 v26; // [sp+1Ch] [bp-2Ch]@2 | |
2471 __int32 var18; // [sp+30h] [bp-18h]@3 | |
2472 int hand_index; // [sp+3Ch] [bp-Ch]@3 | |
2209 | 2473 |
2474 //__debugbreak(); // need do fix rectangle not fit to card | |
2475 | |
2476 if ( am_Players[player_num].IsHisTurn ) | |
2477 { | |
2478 if ( v26._40DD2F() ) | |
1194 | 2479 { |
2209 | 2480 v5 = GetPlayerHandCardCount(player_num); |
2481 pXYZW.top = 327; | |
2482 pXYZW.bottom = 455; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2483 pXYZW.left = (window->GetWidth() - 96 * v5) / (v5 + 1); |
2209 | 2484 var18 = pXYZW.left + 96; |
2485 pXYZW.right = pXYZW.left + 96; | |
2213 | 2486 for( hand_index = 0; hand_index < v5; hand_index++) |
2209 | 2487 { |
2213 | 2488 //for ( i = 0; i < 10; ++i ) |
2489 //{ | |
2490 if (am_Players[player_num].cards_at_hand[hand_index] != -1 ) | |
0 | 2491 { |
2213 | 2492 //break; |
2493 //} | |
2209 | 2494 if ( am_byte_4E185D ) |
2495 { | |
2213 | 2496 pXYZW.left += am_Players[player_num].card_shift[hand_index].x; |
2497 pXYZW.right += am_Players[player_num].card_shift[hand_index].x; | |
2498 pXYZW.top += am_Players[player_num].card_shift[hand_index].y; | |
2499 pXYZW.bottom += am_Players[player_num].card_shift[hand_index].y; | |
2209 | 2500 } |
2213 | 2501 if ( v26.Inside(&pXYZW) ) |
2209 | 2502 { |
2503 if ( CanCardBePlayed(player_num, hand_index) ) | |
2213 | 2504 color = 0x00FFFFFF;//áåëûé öâåò |
1194 | 2505 else |
2213 | 2506 color = 0x000000FF;//êðàñíûé öâåò |
2507 DrawRect(&pXYZW, R8G8B8_to_TargetFormat(color), 0); | |
2209 | 2508 return hand_index; |
2509 } | |
2510 DrawRect(&pXYZW, R8G8B8_to_TargetFormat(0), 0);//ðàìêà ÷¸ðíîãî öâåòà | |
2511 if ( am_byte_4E185D ) | |
2512 { | |
2213 | 2513 pXYZW.left -= am_Players[player_num].card_shift[hand_index].x; |
2514 pXYZW.right -= am_Players[player_num].card_shift[hand_index].x; | |
2515 pXYZW.top -= am_Players[player_num].card_shift[hand_index].y; | |
2516 pXYZW.bottom -= am_Players[player_num].card_shift[hand_index].y; | |
2209 | 2517 } |
2213 | 2518 pXYZW.left += var18; |
2519 pXYZW.right += var18; | |
0 | 2520 } |
2209 | 2521 } |
0 | 2522 } |
2209 | 2523 } |
2213 | 2524 return -1; |
0 | 2525 } |
2526 // 4E185D: using guessed type char am_byte_4E185D; | |
2527 | |
2528 //----- (0040BCFB) -------------------------------------------------------- | |
1256 | 2529 bool DiscardCard( int player_num, signed int card_slot_index ) |
2213 | 2530 { |
0 | 2531 int v2; // esi@2 |
2334 | 2532 // signed int v3; // edi@2 |
2533 // char *v4; // eax@2 | |
2534 // int v5; // ecx@7 | |
2535 // int v6; // ebx@7 | |
2536 // int v7; // esi@8 | |
0 | 2537 int v8; // eax@8 |
2334 | 2538 // int v9; // esi@8 |
0 | 2539 int v10; // ecx@8 |
2334 | 2540 // int v11; // eax@8 |
0 | 2541 int v12; // eax@8 |
2334 | 2542 // signed int v13; // edx@9 |
2543 // unsigned int v14; // eax@12 | |
2544 // char result; // al@12 | |
1194 | 2545 int i; |
0 | 2546 |
1200 | 2547 if ( card_slot_index <= -1 ) |
1209 | 2548 return false; |
0 | 2549 v2 = 0; |
1194 | 2550 |
2213 | 2551 for( i = 0; i < 10; ++i ) |
0 | 2552 { |
1200 | 2553 if ( am_Players[player_num].cards_at_hand[i] != -1 ) |
0 | 2554 { |
1200 | 2555 if ( card_slot_index == v2 ) |
0 | 2556 break; |
2557 ++v2; | |
2558 } | |
2559 } | |
1194 | 2560 |
1263 | 2561 if ( pCards[am_Players[player_num].cards_at_hand[i]].can_be_discarded) |
0 | 2562 { |
1209 | 2563 ArcomageGame::PlaySound(22); |
1197 | 2564 v8 = GetPlayerHandCardCount(current_player_num); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2565 v10 = am_Players[player_num].card_shift[i].x + (window->GetWidth() - 96 * v8) / (v8 + 1); |
1209 | 2566 amuint_4FAA5C_blt_xy.x = v10; |
1256 | 2567 amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[i].y + 327;//v11; |
0 | 2568 v12 = 0; |
1209 | 2569 |
0 | 2570 if ( !am_byte_4FAA75 ) |
2571 { | |
2213 | 2572 for ( v12 = 0; v12 < 10; ++v12 ) |
2573 { | |
2574 if (shown_cards[v12].uCardId == -1) | |
2575 break; | |
2576 } | |
0 | 2577 } |
2578 pArcomageGame->field_F6 = 1; | |
1209 | 2579 amuint_4FAA54_blt_xy.x = (shown_cards[v12].field_8.x - v10) / 10; |
2580 amuint_4FAA54_blt_xy.y = (shown_cards[v12].field_8.y - 327) / 10; | |
2581 uCardID = am_Players[player_num].cards_at_hand[i]; | |
2582 am_Players[player_num].cards_at_hand[i] = -1; | |
1263 | 2583 need_to_discard_card = 0; |
1209 | 2584 return true; |
0 | 2585 } |
2586 else | |
1209 | 2587 return false; |
0 | 2588 } |
1263 | 2589 |
0 | 2590 //----- (0040BE0E) -------------------------------------------------------- |
1679 | 2591 bool PlayCard( int player_num, int card_slot_num ) |
2592 { | |
2334 | 2593 // int v3; // ebp@1 |
0 | 2594 int v4; // ecx@2 |
2334 | 2595 // ArcomagePlayer *v5; // esi@2 |
1263 | 2596 int card_index; // edi@2 |
2334 | 2597 // int v7; // eax@2 |
2598 // int v8; // ebx@8 | |
1263 | 2599 int cards_at_hand; // eax@8 |
2334 | 2600 // int v10; // ebx@8 |
2601 // int v11; // ebp@8 | |
0 | 2602 int v12; // ecx@8 |
2334 | 2603 // int v13; // eax@8 |
1263 | 2604 ArcomageCard *pCard; // eax@8 |
2334 | 2605 // int v15; // ecx@8 |
2606 // int v16; // ecx@8 | |
0 | 2607 |
1197 | 2608 if ( card_slot_num <= -1 ) |
2609 return false; | |
1263 | 2610 |
0 | 2611 v4 = 0; |
1263 | 2612 for (card_index=0; card_index<10; ++card_index) |
0 | 2613 { |
1263 | 2614 if ( am_Players[player_num].cards_at_hand[card_index] != -1 ) |
0 | 2615 { |
1197 | 2616 if ( card_slot_num == v4 ) |
0 | 2617 break; |
2618 ++v4; | |
2619 } | |
2620 } | |
1209 | 2621 |
1263 | 2622 if (CanCardBePlayed(player_num, card_index) ) |
0 | 2623 { |
1209 | 2624 ArcomageGame::PlaySound(23); |
1263 | 2625 cards_at_hand = GetPlayerHandCardCount(current_player_num); |
0 | 2626 pArcomageGame->field_F6 = 1; |
1263 | 2627 v12 = am_Players[player_num].card_shift[card_index].x + |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2628 (window->GetWidth() - 96 * cards_at_hand) / (cards_at_hand + 1)+ |
1263 | 2629 96 * card_index ; |
2630 | |
1185 | 2631 // v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327; |
1218 | 2632 amuint_4FAA5C_blt_xy.x = v12;//v12; |
1263 | 2633 amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[card_index].y + 327;//v13; |
1209 | 2634 |
2635 amuint_4FAA54_blt_xy.x = (272 - v12) / 5; | |
2636 amuint_4FAA54_blt_xy.y = -30; | |
1200 | 2637 |
1263 | 2638 pCard = &pCards[am_Players[player_num].cards_at_hand[card_index]]; |
2639 am_Players[player_num].resource_bricks -= pCard->needed_bricks; | |
2640 am_Players[player_num].resource_beasts -= pCard->needed_beasts; | |
2641 am_Players[player_num].resource_gems -= pCard->needed_gems; | |
2642 played_card_id = am_Players[player_num].cards_at_hand[card_index]; | |
2643 am_Players[player_num].cards_at_hand[card_index] = -1; | |
2644 return true; | |
0 | 2645 } |
2646 else | |
1197 | 2647 return false; |
2648 | |
0 | 2649 } |
2650 | |
2651 //----- (0040BF15) -------------------------------------------------------- | |
1679 | 2652 bool CanCardBePlayed(int player_num, int hand_card_indx) |
2653 { | |
0 | 2654 bool result; // eax@1 |
1197 | 2655 ArcomageCard *test_card; // ecx@1 |
2656 ArcomagePlayer *pPlayer; // esi@1 | |
2657 | |
2658 pPlayer = &am_Players[player_num]; | |
1185 | 2659 result = true; |
1197 | 2660 test_card = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]]; |
2661 if ( test_card->needed_quarry_level > pPlayer->quarry_level ) | |
1185 | 2662 result = false; |
1197 | 2663 if ( test_card->needed_magic_level > pPlayer->magic_level ) |
1185 | 2664 result = false; |
1679 | 2665 if ( test_card->needed_zoo_level > pPlayer->zoo_level ) |
1185 | 2666 result = false; |
1197 | 2667 if ( test_card->needed_bricks > pPlayer->resource_bricks ) |
1185 | 2668 result = false; |
1197 | 2669 if ( test_card->needed_gems > pPlayer->resource_gems ) |
1185 | 2670 result = false; |
1197 | 2671 if ( test_card->needed_beasts > pPlayer->resource_beasts ) |
1185 | 2672 result = false; |
0 | 2673 return result; |
2674 } | |
2675 | |
2676 //----- (0040BF77) -------------------------------------------------------- | |
1218 | 2677 void ApplyCardToPlayer( int player_num, unsigned int uCardID ) |
2678 { | |
1245 | 2679 |
2680 | |
2681 #define APPLY_TO_PLAYER( PLAYER, ENEMY,FIELD, VAL, RES )\ | |
1246 | 2682 if (VAL != 0) {\ |
2683 if (VAL == 99) {\ | |
2684 if ( PLAYER->##FIELD < ENEMY->##FIELD ) {\ | |
2685 PLAYER->##FIELD = ENEMY->##FIELD;\ | |
2686 RES = ENEMY->##FIELD - PLAYER->##FIELD;\ | |
2687 }\ | |
2688 } else {\ | |
2689 PLAYER->##FIELD += (signed int)(VAL);\ | |
2690 if ( PLAYER->##FIELD<0 ) PLAYER->##FIELD= 0;\ | |
2691 RES = (signed int)(VAL);\ | |
1245 | 2692 }\ |
1246 | 2693 } |
1245 | 2694 |
2695 #define APPLY_TO_ENEMY( PLAYER, ENEMY,FIELD, VAL, RES ) APPLY_TO_PLAYER(ENEMY, PLAYER, FIELD, VAL, RES) | |
2696 | |
2697 #define APPLY_TO_BOTH( PLAYER, ENEMY, FIELD, VAL, RES_P, RES_E ) \ | |
1246 | 2698 if ( VAL != 0) {\ |
2699 if ( VAL == 99 ) { \ | |
1245 | 2700 if ( PLAYER->##FIELD != ENEMY->##FIELD ) { \ |
2701 if ( PLAYER->##FIELD <= ENEMY->##FIELD ) { \ | |
2702 PLAYER->##FIELD = ENEMY->##FIELD; \ | |
2703 RES_P = ENEMY->##FIELD - PLAYER->##FIELD; \ | |
2704 } else { \ | |
2705 ENEMY->##FIELD = PLAYER->##FIELD; \ | |
2706 RES_E = PLAYER->##FIELD - ENEMY->##FIELD; \ | |
2707 } \ | |
2708 }\ | |
1246 | 2709 } else { \ |
1245 | 2710 PLAYER->##FIELD += (signed int)(VAL);\ |
2711 ENEMY->##FIELD += (signed int)(VAL); if (PLAYER->##FIELD < 0 ) {PLAYER->##FIELD = 0;} \ | |
2712 if ( ENEMY->##FIELD < 0 ) {ENEMY->##FIELD = 0;} \ | |
1246 | 2713 RES_P = (signed int)(VAL); RES_E = (signed int)(VAL); \ |
2714 }\ | |
2715 } | |
1245 | 2716 ArcomagePlayer *player; // esi@1 |
2334 | 2717 // int v3; // eax@1 |
1245 | 2718 ArcomagePlayer *enemy; // edi@1 |
2334 | 2719 // int v5; // eax@2 |
2720 // char v6; // sf@2 | |
2721 // unsigned __int8 v7; // of@2 | |
2722 // int v8; // eax@3 | |
2723 // int v9; // eax@4 | |
2724 // char v10; // zf@5 | |
2725 // int v11; // eax@8 | |
2726 // unsigned __int8 v12; // zf@8 | |
2727 // char v13; // sf@8 | |
2728 // unsigned __int8 v14; // of@8 | |
2729 // int v15; // eax@9 | |
2730 // int v16; // eax@10 | |
2731 // char v17; // zf@12 | |
2732 // char v18; // al@15 | |
2733 // int v19; // eax@16 | |
2734 // int v20; // eax@17 | |
2735 // int v21; // eax@22 | |
2736 // int v22; // eax@23 | |
1245 | 2737 int v23; // eax@26 |
2738 signed int v24; // ebx@26 | |
2739 int v103; | |
2740 int v104; | |
2741 | |
2742 POINT v184; // [sp+Ch] [bp-64h]@488 | |
2743 int enemy_num; // [sp+14h] [bp-5Ch]@1 | |
2744 ArcomageCard *pCard; // [sp+18h] [bp-58h]@1 | |
2745 int buildings_e; // [sp+1Ch] [bp-54h]@1 | |
2746 int buildings_p; // [sp+20h] [bp-50h]@1 | |
2747 int quarry_p; // [sp+28h] [bp-48h]@1 | |
2748 int dmg_e; // [sp+2Ch] [bp-44h]@1 | |
2749 int dmg_p; // [sp+30h] [bp-40h]@1 | |
2750 int bricks_p; // [sp+34h] [bp-3Ch]@1 | |
2751 int tower_e; // [sp+38h] [bp-38h]@1 | |
2752 int tower_p; // [sp+3Ch] [bp-34h]@1 | |
2753 int wall_e; // [sp+40h] [bp-30h]@1 | |
2754 int wall_p; // [sp+44h] [bp-2Ch]@1 | |
2755 int beasts_e; // [sp+48h] [bp-28h]@1 | |
2756 int beasts_p; // [sp+4Ch] [bp-24h]@1 | |
2757 int gems_e; // [sp+50h] [bp-20h]@1 | |
2758 int gems_p; // [sp+54h] [bp-1Ch]@1 | |
2759 int bricks_e; // [sp+58h] [bp-18h]@1 | |
2760 int zoo_e; // [sp+5Ch] [bp-14h]@1 | |
2761 int zoo_p; // [sp+60h] [bp-10h]@1 | |
2762 int magic_e; // [sp+64h] [bp-Ch]@1 | |
2763 int magic_p; // [sp+68h] [bp-8h]@1 | |
2764 int quarry_e; // [sp+6Ch] [bp-4h]@1 | |
2765 | |
1246 | 2766 quarry_p = 0; |
2767 magic_p = 0; | |
2768 zoo_p = 0; | |
2769 bricks_p = 0; | |
2770 gems_p = 0; | |
2771 beasts_p = 0; | |
2772 wall_p = 0; | |
2773 tower_p = 0; | |
1245 | 2774 buildings_p = 0; |
1246 | 2775 dmg_p = 0; |
2776 quarry_e = 0; | |
2777 magic_e = 0; | |
2778 zoo_e = 0; | |
2779 bricks_e = 0; | |
2780 gems_e = 0; | |
2781 beasts_e = 0; | |
2782 wall_e = 0; | |
2783 tower_e = 0; | |
1245 | 2784 buildings_e = 0; |
1246 | 2785 dmg_e = 0; |
1245 | 2786 |
2787 player = &am_Players[player_num]; | |
2788 pCard = &pCards[uCardID]; | |
2789 enemy_num = (player_num + 1) % 2; | |
2790 enemy = &am_Players[enemy_num]; | |
2791 switch ( pCard->compare_param ) | |
2213 | 2792 { |
1245 | 2793 case 2: |
2213 | 2794 if ( player->quarry_level < enemy->quarry_level )//åñëè ðóäíèêè < ðóäíèêà âðàãà |
2795 goto LABEL_26; | |
2796 goto LABEL_231; | |
1245 | 2797 case 3: |
2213 | 2798 if ( player->magic_level < enemy->magic_level ) |
2799 goto LABEL_26; | |
2800 goto LABEL_231; | |
1245 | 2801 case 4: |
2213 | 2802 if ( player->zoo_level < enemy->zoo_level )//åñëè çâåðèíåö < çâåðèíöà âðàãà |
2803 goto LABEL_26; | |
2804 goto LABEL_231; | |
1245 | 2805 case 5: |
2213 | 2806 if ( player->quarry_level == enemy->quarry_level ) |
2807 goto LABEL_26; | |
2808 goto LABEL_231; | |
1245 | 2809 case 6: |
2213 | 2810 if ( player->magic_level == enemy->magic_level ) |
2811 goto LABEL_26; | |
2812 goto LABEL_231; | |
1245 | 2813 case 7: |
2213 | 2814 if ( player->zoo_level == enemy->zoo_level ) |
2815 goto LABEL_26; | |
2816 goto LABEL_231; | |
1245 | 2817 case 8: |
2213 | 2818 if ( player->quarry_level < enemy->quarry_level ) |
2819 goto LABEL_26; | |
2820 goto LABEL_231; | |
1245 | 2821 case 9: |
2213 | 2822 if ( player->magic_level < enemy->magic_level ) |
2823 goto LABEL_26; | |
2824 goto LABEL_231; | |
1245 | 2825 case 10: |
2213 | 2826 if ( player->zoo_level < enemy->zoo_level ) |
2827 goto LABEL_26; | |
2828 goto LABEL_231; | |
1245 | 2829 case 11: |
2213 | 2830 if ( !player->wall_height ) |
2831 goto LABEL_26; | |
2832 goto LABEL_231; | |
1245 | 2833 case 12: |
2213 | 2834 if ( player->wall_height ) |
2835 goto LABEL_26; | |
2836 goto LABEL_231; | |
1245 | 2837 case 13: |
2213 | 2838 if ( !enemy->wall_height ) |
2839 goto LABEL_26; | |
2840 goto LABEL_231; | |
1245 | 2841 case 14: |
2213 | 2842 if ( enemy->wall_height ) |
2843 goto LABEL_26; | |
2844 goto LABEL_231; | |
1245 | 2845 case 15: |
2213 | 2846 if ( player->wall_height < enemy->wall_height ) |
2847 goto LABEL_26; | |
2848 goto LABEL_231; | |
1245 | 2849 case 16: |
2213 | 2850 if ( player->tower_height < enemy->tower_height ) |
2851 goto LABEL_26; | |
2852 goto LABEL_231; | |
1245 | 2853 case 17: |
2213 | 2854 if ( player->wall_height == enemy->wall_height ) |
2855 goto LABEL_26; | |
2856 goto LABEL_231; | |
1245 | 2857 case 18: |
2213 | 2858 if ( player->tower_height == enemy->tower_height ) |
2859 goto LABEL_26; | |
2860 goto LABEL_231; | |
1245 | 2861 case 19: |
2213 | 2862 if ( player->wall_height < enemy->wall_height ) |
2863 goto LABEL_26; | |
2864 goto LABEL_231; | |
1245 | 2865 case 20: |
2213 | 2866 if ( player->tower_height < enemy->tower_height ) |
1245 | 2867 goto LABEL_26; |
2868 goto LABEL_231; | |
2869 default: | |
2870 LABEL_26: | |
1263 | 2871 v23 = pCard->draw_extra_card_count; |
1245 | 2872 v24 = 0; |
2873 dword_4FAA68 = v23 + (pCard->field_30 == 1); | |
2874 dword_4FAA64 = v23; | |
2875 if ( v23 > 0 ) | |
2213 | 2876 { |
2877 do | |
2878 { | |
2879 GetNextCardFromDeck(player_num); | |
2880 ++v24; | |
2881 } | |
2882 while ( v24 < pCard->draw_extra_card_count ); | |
2883 } | |
1245 | 2884 |
1263 | 2885 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
1245 | 2886 |
2887 APPLY_TO_PLAYER(player, enemy, quarry_level, pCard->to_player_quarry_lvl, quarry_p); | |
2888 APPLY_TO_PLAYER(player, enemy, magic_level, pCard->to_player_magic_lvl, magic_p); | |
2889 APPLY_TO_PLAYER(player, enemy, zoo_level, pCard->to_player_zoo_lvl, zoo_p); | |
2890 APPLY_TO_PLAYER(player, enemy, resource_bricks, pCard->to_player_bricks, bricks_p); | |
2891 APPLY_TO_PLAYER(player, enemy, resource_gems, pCard->to_player_gems, gems_p); | |
2892 APPLY_TO_PLAYER(player, enemy, resource_beasts, pCard->to_player_beasts, beasts_p); | |
1246 | 2893 if ( pCard->to_player_buildings ) |
1245 | 2894 { |
1246 | 2895 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_player_buildings); |
2896 buildings_p = (signed int)pCard->to_player_buildings - dmg_p; | |
1245 | 2897 } |
1246 | 2898 APPLY_TO_PLAYER(player, enemy, wall_height, pCard->to_player_wall, wall_p); |
2899 APPLY_TO_PLAYER(player, enemy, tower_height, pCard->to_player_tower, tower_p); | |
1245 | 2900 |
2901 APPLY_TO_ENEMY(player, enemy, quarry_level, pCard->to_enemy_quarry_lvl, quarry_e); | |
2902 APPLY_TO_ENEMY(player, enemy, magic_level, pCard->to_enemy_magic_lvl, magic_e); | |
2903 APPLY_TO_ENEMY(player, enemy, zoo_level, pCard->to_enemy_zoo_lvl, zoo_e); | |
2904 APPLY_TO_ENEMY(player, enemy, resource_bricks, pCard->to_enemy_bricks, bricks_e); | |
2905 APPLY_TO_ENEMY(player, enemy, resource_gems, pCard->to_enemy_gems, gems_e); | |
2906 APPLY_TO_ENEMY(player, enemy, resource_beasts, pCard->to_enemy_beasts, beasts_e); | |
2907 if ( pCard->to_enemy_buildings ) | |
2908 { | |
1246 | 2909 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_enemy_buildings); |
2910 buildings_e = (signed int)pCard->to_enemy_buildings - dmg_e; | |
1245 | 2911 } |
2912 APPLY_TO_ENEMY(player, enemy, wall_height, pCard->to_enemy_wall, wall_e); | |
2913 APPLY_TO_ENEMY(player, enemy, tower_height, pCard->to_enemy_tower, tower_e); | |
2914 | |
2915 APPLY_TO_BOTH(player, enemy, quarry_level, pCard->to_pl_enm_quarry_lvl, quarry_p, quarry_e); | |
2916 APPLY_TO_BOTH(player, enemy, magic_level, pCard->to_pl_enm_magic_lvl, magic_p, magic_e); | |
2917 APPLY_TO_BOTH(player, enemy, zoo_level, pCard->to_pl_enm_zoo_lvl, zoo_p, zoo_e); | |
2918 APPLY_TO_BOTH(player, enemy, resource_bricks, pCard->to_pl_enm_bricks, bricks_p, bricks_e); | |
2919 APPLY_TO_BOTH(player, enemy, resource_gems, pCard->to_pl_enm_gems, gems_p, gems_e); | |
2920 APPLY_TO_BOTH(player, enemy, resource_beasts, pCard->to_pl_enm_beasts, beasts_p, beasts_e); | |
2921 if ( pCard->to_pl_enm_buildings ) | |
2922 { | |
1246 | 2923 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_pl_enm_buildings); |
2924 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_pl_enm_buildings); | |
2925 buildings_p = (signed int)pCard->to_pl_enm_buildings - dmg_p; | |
2926 buildings_e = (signed int)pCard->to_pl_enm_buildings - dmg_e; | |
1245 | 2927 } |
2928 APPLY_TO_BOTH(player, enemy, wall_height, pCard->to_pl_enm_wall, wall_p, wall_e); | |
2929 APPLY_TO_BOTH(player, enemy, tower_height, pCard->to_pl_enm_tower, tower_p, tower_e); | |
2930 break; | |
2931 case 0: | |
2932 LABEL_231: | |
2933 v103 = pCard->can_draw_extra_card2; | |
2934 v104 = 0; | |
2935 dword_4FAA68 = v103 + (pCard->field_4D == 1); | |
2936 dword_4FAA64 = v103; | |
2937 if ( v103 > 0 ) | |
2938 { | |
2939 do | |
2940 { | |
2941 GetNextCardFromDeck(player_num); | |
2942 ++v104; | |
2943 } | |
2944 while ( v104 < pCard->can_draw_extra_card2 ); | |
2945 } | |
2946 | |
1263 | 2947 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
1245 | 2948 |
2949 APPLY_TO_PLAYER(player, enemy, quarry_level, pCard->to_player_quarry_lvl2, quarry_p); | |
2950 APPLY_TO_PLAYER(player, enemy, magic_level, pCard->to_player_magic_lvl2, magic_p); | |
2951 APPLY_TO_PLAYER(player, enemy, zoo_level, pCard->to_player_zoo_lvl2, zoo_p); | |
2952 APPLY_TO_PLAYER(player, enemy, resource_bricks, pCard->to_player_bricks2, bricks_p); | |
2953 APPLY_TO_PLAYER(player, enemy, resource_gems, pCard->to_player_gems2, gems_p); | |
2954 APPLY_TO_PLAYER(player, enemy, resource_beasts, pCard->to_player_beasts2, beasts_p); | |
2955 if ( pCard->to_player_buildings2 ) | |
2956 { | |
1246 | 2957 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_player_buildings2); |
2958 buildings_p = (signed int)pCard->to_player_buildings2 - dmg_p; | |
1245 | 2959 } |
2960 APPLY_TO_PLAYER(player, enemy, wall_height, pCard->to_player_wall2, wall_p); | |
2961 APPLY_TO_PLAYER(player, enemy, tower_height, pCard->to_player_tower2, tower_p); | |
2962 | |
2963 APPLY_TO_ENEMY(player, enemy, quarry_level, pCard->to_enemy_quarry_lvl2, quarry_e); | |
2964 APPLY_TO_ENEMY(player, enemy, magic_level, pCard->to_enemy_magic_lvl2, magic_e); | |
2965 APPLY_TO_ENEMY(player, enemy, zoo_level, pCard->to_enemy_zoo_lvl2, zoo_e); | |
2966 APPLY_TO_ENEMY(player, enemy, resource_bricks, pCard->to_enemy_bricks2, bricks_e); | |
2967 APPLY_TO_ENEMY(player, enemy, resource_gems, pCard->to_enemy_gems2, gems_e); | |
2968 APPLY_TO_ENEMY(player, enemy, resource_beasts, pCard->to_enemy_beasts2, beasts_e); | |
2969 if ( pCard->to_enemy_buildings2 ) | |
2970 { | |
1246 | 2971 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_enemy_buildings2); |
2972 buildings_e = (signed int)pCard->to_enemy_buildings2 - dmg_e; | |
1245 | 2973 } |
2974 APPLY_TO_ENEMY(player, enemy, wall_height, pCard->to_enemy_wall2, wall_e); | |
2975 APPLY_TO_ENEMY(player, enemy, tower_height, pCard->to_enemy_tower2, tower_e); | |
2976 | |
2977 APPLY_TO_BOTH(player, enemy, quarry_level, pCard->to_pl_enm_quarry_lvl2, quarry_p, quarry_e); | |
2978 APPLY_TO_BOTH(player, enemy, magic_level, pCard->to_pl_enm_magic_lvl2, magic_p, magic_e); | |
2979 APPLY_TO_BOTH(player, enemy, zoo_level, pCard->to_pl_enm_zoo_lvl2, zoo_p, zoo_e); | |
2980 APPLY_TO_BOTH(player, enemy, resource_bricks, pCard->to_pl_enm_bricks2, bricks_p, bricks_e); | |
2981 APPLY_TO_BOTH(player, enemy, resource_gems, pCard->to_pl_enm_gems2, gems_p, gems_e); | |
2982 APPLY_TO_BOTH(player, enemy, resource_beasts, pCard->to_pl_enm_beasts2, beasts_p, beasts_e); | |
2983 | |
2984 if ( pCard->to_pl_enm_buildings2 ) | |
2985 { | |
1246 | 2986 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_pl_enm_buildings2); |
2987 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_pl_enm_buildings2); | |
2988 buildings_p = (signed int)pCard->to_pl_enm_buildings2 - dmg_p; | |
2989 buildings_e = (signed int)pCard->to_pl_enm_buildings2 - dmg_e; | |
1245 | 2990 } |
2991 APPLY_TO_BOTH(player, enemy, wall_height, pCard->to_pl_enm_wall2, wall_p, wall_e); | |
2992 APPLY_TO_BOTH(player, enemy, tower_height, pCard->to_pl_enm_tower2, tower_p, tower_e); | |
2993 break; | |
2994 } | |
2995 // } | |
2996 if ( quarry_p > 0 || quarry_e > 0 ) | |
2997 pArcomageGame->PlaySound(30); | |
2998 if ( quarry_p < 0 || quarry_e < 0 ) | |
2999 pArcomageGame->PlaySound(31); | |
3000 if ( magic_p > 0 || magic_e > 0 ) | |
3001 pArcomageGame->PlaySound(33); | |
3002 if ( magic_p < 0 || magic_e < 0 ) | |
3003 pArcomageGame->PlaySound(34); | |
3004 if ( zoo_p > 0 || zoo_e > 0 ) | |
3005 pArcomageGame->PlaySound(36); | |
3006 if ( zoo_p < 0 || zoo_e < 0 ) | |
3007 pArcomageGame->PlaySound(37); | |
3008 if ( bricks_p > 0 || bricks_e > 0 ) | |
3009 pArcomageGame->PlaySound(39); | |
3010 if ( bricks_p < 0 || bricks_e < 0 ) | |
3011 pArcomageGame->PlaySound(40); | |
3012 if ( gems_p > 0 || gems_e > 0 ) | |
3013 pArcomageGame->PlaySound(42); | |
3014 if ( gems_p < 0 || gems_e < 0 ) | |
3015 pArcomageGame->PlaySound(43); | |
3016 if ( beasts_p > 0 || beasts_e > 0 ) | |
3017 pArcomageGame->PlaySound(45u); | |
3018 if ( beasts_p < 0 || beasts_e < 0 ) | |
3019 pArcomageGame->PlaySound(46); | |
3020 if ( buildings_p || buildings_e || dmg_p || dmg_e ) | |
3021 pArcomageGame->PlaySound(48); | |
3022 if ( wall_p > 0 || wall_e > 0 ) | |
3023 pArcomageGame->PlaySound(49); | |
3024 if ( wall_p < 0 || wall_e < 0 ) | |
3025 pArcomageGame->PlaySound(50); | |
3026 if ( tower_p > 0 || tower_e > 0 ) | |
3027 pArcomageGame->PlaySound(52); | |
3028 if ( tower_p < 0 || tower_e < 0 ) | |
3029 pArcomageGame->PlaySound(53); | |
3030 if ( player_num ) | |
3031 { | |
3032 if ( quarry_p ) | |
3033 { | |
3034 v184.x = 573; | |
3035 v184.y = 92; | |
3036 am_40D2B4(&v184, quarry_p); | |
3037 } | |
3038 if ( quarry_e ) | |
3039 { | |
3040 v184.x = 26; | |
3041 v184.y = 92; | |
3042 am_40D2B4(&v184, quarry_e); | |
3043 } | |
3044 if ( magic_p ) | |
3045 { | |
3046 v184.x = 573; | |
3047 v184.y = 164; | |
3048 am_40D2B4(&v184, magic_p); | |
3049 } | |
3050 if ( magic_e ) | |
3051 { | |
3052 v184.x = 26; | |
3053 v184.y = 164; | |
3054 am_40D2B4(&v184, magic_e); | |
3055 } | |
3056 if ( zoo_p ) | |
3057 { | |
3058 v184.x = 573; | |
3059 v184.y = 236; | |
3060 am_40D2B4(&v184, zoo_p); | |
3061 } | |
3062 if ( zoo_e ) | |
3063 { | |
3064 v184.x = 26; | |
3065 v184.y = 236; | |
3066 am_40D2B4(&v184, zoo_e); | |
3067 } | |
3068 if ( bricks_p ) | |
3069 { | |
3070 v184.x = 563; | |
3071 v184.y = 114; | |
3072 am_40D2B4(&v184, bricks_p); | |
3073 } | |
3074 if ( bricks_e ) | |
3075 { | |
3076 v184.x = 16; | |
3077 v184.y = 114; | |
3078 am_40D2B4(&v184, bricks_e); | |
3079 } | |
3080 if ( gems_p ) | |
3081 { | |
3082 v184.x = 563; | |
3083 v184.y = 186; | |
3084 am_40D2B4(&v184, gems_p); | |
3085 } | |
3086 if ( gems_e ) | |
3087 { | |
3088 v184.x = 16; | |
3089 v184.y = 186; | |
3090 am_40D2B4(&v184, gems_e); | |
3091 } | |
3092 if ( beasts_p ) | |
3093 { | |
3094 v184.x = 563; | |
3095 v184.y = 258; | |
3096 am_40D2B4(&v184, beasts_p); | |
3097 } | |
3098 if ( beasts_e ) | |
3099 { | |
3100 v184.x = 16; | |
3101 v184.y = 258; | |
3102 am_40D2B4(&v184, beasts_e); | |
3103 } | |
3104 if ( wall_p ) | |
3105 { | |
3106 v184.x = 442; | |
3107 v184.y = 296; | |
3108 am_40D2B4(&v184, wall_p); | |
3109 } | |
3110 if ( wall_e ) | |
3111 { | |
3112 v184.x = 180; | |
3113 v184.y = 296; | |
3114 am_40D2B4(&v184, wall_e); | |
3115 } | |
3116 if ( tower_p ) | |
3117 { | |
3118 v184.x = 514; | |
3119 v184.y = 296; | |
3120 am_40D2B4(&v184, tower_p); | |
3121 } | |
3122 if ( tower_e ) | |
3123 { | |
3124 v184.x = 122; | |
3125 v184.y = 296; | |
3126 am_40D2B4(&v184, tower_e); | |
3127 } | |
3128 if ( dmg_p ) | |
3129 { | |
3130 v184.x = 442; | |
3131 v184.y = 296; | |
3132 am_40D2B4(&v184, dmg_p); | |
3133 } | |
3134 if ( buildings_p ) | |
3135 { | |
3136 v184.x = 514; | |
3137 v184.y = 296; | |
3138 am_40D2B4(&v184, buildings_p); | |
3139 } | |
3140 if ( dmg_e ) | |
3141 { | |
3142 v184.x = 180; | |
3143 v184.y = 296; | |
3144 am_40D2B4(&v184, dmg_e); | |
3145 } | |
3146 if ( buildings_e ) | |
3147 { | |
3148 v184.x = 122; | |
3149 v184.y = 296; | |
3150 am_40D2B4(&v184, buildings_e); | |
3151 } | |
3152 } | |
3153 else | |
3154 { | |
3155 if ( quarry_p ) | |
3156 { | |
3157 v184.x = 26; | |
3158 v184.y = 92; | |
3159 am_40D2B4(&v184, quarry_p); | |
3160 } | |
3161 if ( quarry_e ) | |
3162 { | |
3163 v184.x = 573; | |
3164 v184.y = 92; | |
3165 am_40D2B4(&v184, quarry_e); | |
3166 } | |
3167 if ( magic_p ) | |
3168 { | |
3169 v184.x = 26; | |
3170 v184.y = 164; | |
3171 am_40D2B4(&v184, magic_p); | |
3172 } | |
3173 if ( magic_e ) | |
3174 { | |
3175 v184.x = 573; | |
3176 v184.y = 164; | |
3177 am_40D2B4(&v184, magic_e); | |
3178 } | |
3179 if ( zoo_p ) | |
3180 { | |
3181 v184.x = 26; | |
3182 v184.y = 236; | |
3183 am_40D2B4(&v184, zoo_p); | |
3184 } | |
3185 if ( zoo_e ) | |
3186 { | |
3187 v184.x = 573; | |
3188 v184.y = 236; | |
3189 am_40D2B4(&v184, zoo_e); | |
3190 } | |
3191 if ( bricks_p ) | |
3192 { | |
3193 v184.x = 16; | |
3194 v184.y = 114; | |
3195 am_40D2B4(&v184, bricks_p); | |
3196 } | |
3197 if ( bricks_e ) | |
3198 { | |
3199 v184.x = 563; | |
3200 v184.y = 114; | |
3201 am_40D2B4(&v184, bricks_e); | |
3202 } | |
3203 if ( gems_p ) | |
3204 { | |
3205 v184.x = 16; | |
3206 v184.y = 186; | |
3207 am_40D2B4(&v184, gems_p); | |
3208 } | |
3209 if ( gems_e ) | |
3210 { | |
3211 v184.x = 563; | |
3212 v184.y = 186; | |
3213 am_40D2B4(&v184, gems_e); | |
3214 } | |
3215 if ( beasts_p ) | |
3216 { | |
3217 v184.x = 16; | |
3218 v184.y = 258; | |
3219 am_40D2B4(&v184, beasts_p); | |
3220 } | |
3221 if ( beasts_e ) | |
3222 { | |
3223 v184.x = 563; | |
3224 v184.y = 258; | |
3225 am_40D2B4(&v184, beasts_e); | |
3226 } | |
3227 if ( wall_p ) | |
3228 { | |
3229 v184.x = 180; | |
3230 v184.y = 296; | |
3231 am_40D2B4(&v184, wall_p); | |
3232 } | |
3233 if ( wall_e ) | |
3234 { | |
3235 v184.x = 442; | |
3236 v184.y = 296; | |
3237 am_40D2B4(&v184, wall_e); | |
3238 } | |
3239 if ( tower_p ) | |
3240 { | |
3241 v184.x = 122; | |
3242 v184.y = 296; | |
3243 am_40D2B4(&v184, tower_p); | |
3244 } | |
3245 if ( tower_e ) | |
3246 { | |
3247 v184.x = 514; | |
3248 v184.y = 296; | |
3249 am_40D2B4(&v184, tower_e); | |
3250 } | |
3251 if ( dmg_p ) | |
3252 { | |
3253 v184.x = 180; | |
3254 v184.y = 296; | |
3255 am_40D2B4(&v184, dmg_p); | |
3256 } | |
3257 if ( buildings_p ) | |
3258 { | |
3259 v184.x = 122; | |
3260 v184.y = 296; | |
3261 am_40D2B4(&v184, buildings_p); | |
3262 } | |
3263 if ( dmg_e ) | |
3264 { | |
3265 v184.x = 442; | |
3266 v184.y = 296; | |
3267 am_40D2B4(&v184, dmg_e); | |
3268 } | |
3269 if ( buildings_e ) | |
3270 { | |
3271 v184.x = 514; | |
3272 v184.y = 296; | |
3273 am_40D2B4(&v184, buildings_e); | |
3274 } | |
3275 } | |
3276 #undef APPLY_TO_BOTH | |
2213 | 3277 #undef APPLY_TO_ENEMY |
1245 | 3278 #undef APPLY_TO_PLAYER |
3279 | |
0 | 3280 } |
3281 | |
3282 //----- (0040D2B4) -------------------------------------------------------- | |
1263 | 3283 int am_40D2B4( POINT* startXY, int effect_value ) |
2213 | 3284 { |
0 | 3285 int v2; // ebp@1 |
2334 | 3286 // POINT *v3; // edi@1 |
0 | 3287 int result; // eax@3 |
1194 | 3288 int v6; |
0 | 3289 stru272_stru0 *v8; // ecx@12 |
3290 signed int v11; // [sp+10h] [bp-8h]@1 | |
3291 | |
3292 v11 = 0; | |
1263 | 3293 v2 = effect_value; |
3294 | |
2213 | 3295 while ( array_4FABD0[v11].have_effect )//Ritor1: needed refactoring |
3296 { | |
3297 result = array_4FABD0[v11].field_40->_40E2A7(); | |
3298 if ( !result ) | |
3299 { | |
3300 array_4FABD0[v11].have_effect = 0; | |
3301 --v11; | |
3302 } | |
3303 ++v11; | |
3304 if ( v11 >= 10 ) | |
3305 return result; | |
3306 } | |
1185 | 3307 v6 = v11; |
1263 | 3308 array_4FABD0[v11].have_effect = 1; |
3309 if ( effect_value <= 0 ) | |
2213 | 3310 { |
3311 array_4FABD0[v6].effect_sign = 0; | |
3312 effect_value = -effect_value; | |
3313 } | |
0 | 3314 else |
2213 | 3315 array_4FABD0[v6].effect_sign = 1; |
1263 | 3316 array_4FABD0[v6].field_4.effect_area.left = startXY->x - 20; |
3317 array_4FABD0[v6].field_4.effect_area.right = startXY->x + 20; | |
3318 array_4FABD0[v6].field_4.effect_area.top = startXY->y - 20; | |
3319 array_4FABD0[v6].field_4.effect_area.bottom = startXY->y + 20; | |
1186 | 3320 array_4FABD0[v6].field_4.field_10 = -60; |
3321 array_4FABD0[v6].field_4.field_14 = 60; | |
3322 array_4FABD0[v6].field_4.field_18 = 180; | |
3323 array_4FABD0[v6].field_4.field_1Cf = 0.5; | |
3324 array_4FABD0[v6].field_4.field_20 = 150; | |
3325 array_4FABD0[v6].field_4.field_24f= 50.0; | |
3326 array_4FABD0[v6].field_4.field_28f = 3.0; | |
3327 array_4FABD0[v6].field_4.field_2Cf = 8.0; | |
3328 array_4FABD0[v6].field_4.field_30 = 5; | |
3329 array_4FABD0[v6].field_4.field_34 = 15; | |
1263 | 3330 array_4FABD0[v6].field_4.sparks_array = &array_4FABD0[v6].effect_sparks[0]; |
1185 | 3331 v8 = array_4FABD0[v6].field_40; |
1263 | 3332 v8->StartFill(&array_4FABD0[v6].field_4); |
3333 if ( 10 * effect_value > 150 ) | |
3334 effect_value = 15; | |
1185 | 3335 |
1184 | 3336 if ( v8->signature != SIG_trpg ) |
0 | 3337 return 2; |
3338 if ( !v8->field_59 ) | |
3339 return 3; | |
1263 | 3340 v8->position_in_sparks_arr = 10 * effect_value; |
0 | 3341 v8->field_30 = 0.0; |
3342 v8->field_58 = 0; | |
3343 v8->field_44 = 0; | |
3344 v8->field_4C = 0; | |
3345 v8->field_48 = 0; | |
3346 v8->field_50 = 0; | |
2213 | 3347 for (int i = 0; i < v8->field_4; ++i) |
3348 v8->field_54[i].have_spark = 0; | |
0 | 3349 return 0; |
3350 } | |
1185 | 3351 |
0 | 3352 //----- (0040D402) -------------------------------------------------------- |
1246 | 3353 int ApplyDamageToBuildings( int player_num, int damage ) |
2213 | 3354 { |
2334 | 3355 // ArcomagePlayer *v2; // ecx@1 |
0 | 3356 int v3; // esi@1 |
3357 int result; // eax@3 | |
3358 | |
1218 | 3359 v3 = am_Players[player_num].wall_height; |
2213 | 3360 //if ( v3 <= 0 ) |
0 | 3361 result = 0; |
2213 | 3362 //else |
3363 //{ | |
1218 | 3364 if ( v3 >= -damage ) |
0 | 3365 { |
1218 | 3366 result = damage; |
3367 am_Players[player_num].wall_height += damage; | |
0 | 3368 } |
1209 | 3369 else |
2213 | 3370 { |
3371 damage += v3; | |
3372 result = -v3; | |
3373 am_Players[player_num].wall_height = 0; | |
3374 am_Players[player_num].tower_height += damage; | |
3375 } | |
3376 //} | |
1218 | 3377 if ( am_Players[player_num].tower_height < 0 ) |
3378 am_Players[player_num].tower_height = 0; | |
0 | 3379 return result; |
3380 } | |
3381 // 40D402: using guessed type int __fastcall am_40D402(uint, uint); | |
3382 | |
3383 //----- (0040D444) -------------------------------------------------------- | |
1218 | 3384 void GameResultsApply() |
2213 | 3385 { |
2214 | 3386 int winner; // esi@1 |
3387 int victory_type; // edi@1 | |
3388 int pl_resource; // edx@25 | |
3389 int en_resource; // eax@28 | |
3390 unsigned int tavern_num; // eax@54 | |
2334 | 3391 // char pText[64]; // [sp+Ch] [bp-48h]@1 |
3392 // POINT xy; // [sp+4Ch] [bp-8h]@1 | |
0 | 3393 |
2214 | 3394 winner = -1; |
3395 victory_type = -1; | |
0 | 3396 //nullsub_1(); |
2214 | 3397 /*strcpy(pText, "The Winner is: ");//"Ïîáåäèë: " Ritor1: àðõàèçì |
1218 | 3398 xy.y = 160; |
3399 xy.x = 320; //- 12 * v2 / 2; | |
2214 | 3400 am_DrawText(-1, pText, &xy);*/ |
2213 | 3401 |
3402 //ïðîâåðêà ïîñòðîåíà ëè áàøíÿ | |
3403 if ( am_Players[0].tower_height < max_tower_height && am_Players[1].tower_height >= max_tower_height )//íàøà áàøíÿ íå ïîñòðîåíà, à ó âðàãà ïîñòðîåíà | |
2214 | 3404 { |
3405 winner = 2;//ïîáåäèë èãðîê 2(âðàã) | |
3406 victory_type = 0; | |
3407 } | |
2213 | 3408 else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height < max_tower_height )//íàøà áàøíÿ ïîñòðîåíà, à ó âðàãà íåò |
2214 | 3409 { |
3410 winner = 1;//ïîáåäèë èãðîê 1(ìû) | |
3411 victory_type = 0; | |
3412 } | |
2213 | 3413 else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height >= max_tower_height )//è ó íàñ, è ó âðàãà ïîñòðîåíà |
0 | 3414 { |
2213 | 3415 if ( am_Players[0].tower_height == am_Players[1].tower_height )//íàøè áàøíè ðàâíû |
0 | 3416 { |
2214 | 3417 winner = 0;//íèêòî íå ïîáåäèë |
3418 victory_type = 4;//íè÷üÿ | |
0 | 3419 } |
2214 | 3420 else//íàøè áàøíè íå ðàâíû |
3421 { | |
3422 winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;//ïîáåäèë òîò, ó êîãî âûøå | |
3423 victory_type = 0; | |
3424 } | |
2213 | 3425 } |
3426 | |
3427 //ïðîâåðêà ðàçðóøåíà ëè áàøíÿ | |
3428 if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height > 0 )//íàøà áàøíÿ ðàçðóøåíà, à ó âðàãà íåò | |
2214 | 3429 { |
3430 winner = 2;// ïîáåäèë èãðîê 2(âðàã) | |
3431 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
3432 } | |
2213 | 3433 else if ( am_Players[0].tower_height > 0 && am_Players[1].tower_height <= 0 )//ó âðàãà áàøíÿ ðàçðóøåíà, à ó íàñ íåò |
3434 { | |
2214 | 3435 winner = 1;//ïîáåäèë èãðîê 1(ìû) |
3436 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
2213 | 3437 } |
3438 else if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height <= 0 )//íàøà áàøíÿ ðàçðóøåíà, è ó âðàãà ðàçðóøåíà | |
3439 { | |
3440 if ( am_Players[0].tower_height == am_Players[1].tower_height )//åñëè áàøíè ðàâíû | |
0 | 3441 { |
2213 | 3442 if ( am_Players[0].wall_height == am_Players[1].wall_height )//åñëè ñòåíû ðàâíû |
0 | 3443 { |
2214 | 3444 winner = 0; |
3445 victory_type = 4; | |
0 | 3446 } |
2213 | 3447 else//åñëè ñòåíû íå ðàâíû |
3448 { | |
2214 | 3449 winner = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;//ïîáåäèë òîò, ó êîãî ñòåíà âûøå |
3450 victory_type = 1;//ïîáåäà êîãäà áîëüøå ñòåíà ïðè íè÷üå | |
2213 | 3451 } |
0 | 3452 } |
2214 | 3453 else//áàøíè íå ðàâíû |
0 | 3454 { |
2214 | 3455 winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;// ïîáåæäàåò òîò ó êîãî áàøíÿ áîëüøå |
3456 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
0 | 3457 } |
3458 } | |
2214 | 3459 |
3460 //ïðîâåðêà íàáðàíû ëè ðåñóðñû | |
3461 //ïðîâåðêà êàêîãî ðåñóðñà áîëüøå âñåãî ó èãðîêà 1(íàñ) | |
3462 pl_resource = am_Players[0].resource_bricks;//êèðïè÷åé áîëüøå ÷åì äð. ðåñóðñîâ | |
3463 if ( am_Players[0].resource_gems > am_Players[0].resource_bricks | |
3464 && am_Players[0].resource_gems > am_Players[0].resource_beasts )//äðàã.êàìíåé áîëüøå âñåãî | |
3465 pl_resource = am_Players[0].resource_gems; | |
3466 else if ( am_Players[0].resource_beasts > am_Players[0].resource_gems | |
3467 && am_Players[0].resource_beasts > am_Players[0].resource_bricks )//çâåðåé áîëüøå âñåãî | |
3468 pl_resource = am_Players[0].resource_beasts; | |
3469 | |
3470 //ïðîâåðêà êàêîãî ðåñóðñà áîëüøå ó èãðîêà 2(âðàãà) | |
3471 en_resource = am_Players[1].resource_bricks;//êèðïè÷åé áîëüøå ÷åì äð. ðåñóðñîâ | |
3472 if ( am_Players[1].resource_gems > am_Players[1].resource_bricks | |
3473 && am_Players[1].resource_gems > am_Players[1].resource_beasts )//äðàã.êàìíåé áîëüøå âñåãî | |
3474 en_resource = am_Players[1].resource_gems; | |
3475 else if ( am_Players[1].resource_beasts > am_Players[1].resource_gems | |
3476 && am_Players[1].resource_beasts > am_Players[1].resource_bricks )//çâåðåé áîëüøå âñåãî | |
3477 en_resource = am_Players[1].resource_beasts; | |
3478 | |
3479 //ñðàâíåíèå ðåñóðñîâ èãðîêîâ | |
3480 if ( winner == -1 && victory_type == -1 )//íåò ïîáåäèòåëÿ ïî áàøíÿì | |
0 | 3481 { |
2214 | 3482 if ( pl_resource < max_resources_amount && en_resource >= max_resources_amount )//âðàã íàáðàë íóæíîå êîëè÷åñòâî |
3483 { | |
3484 winner = 2;// âðàã ïîáåäèë | |
3485 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
3486 } | |
3487 else if ( pl_resource >= max_resources_amount && en_resource < max_resources_amount )//ìû íàáðàëè íóæíîå êîëè÷åñòâî | |
0 | 3488 { |
2214 | 3489 winner = 1;// ìû ïîáåäèëè |
3490 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3491 } |
2214 | 3492 else if ( pl_resource >= max_resources_amount && en_resource >= max_resources_amount )//è ó íàñ è ó âðàãà íóæíîå êîëè÷åñòâî ðåñóðñîâ |
0 | 3493 { |
2214 | 3494 if ( pl_resource == en_resource )// ðåñóðñû ðàâíû |
3495 { | |
3496 winner = 0;//ðåñóðñû ðàâíû | |
3497 victory_type = 4; //íè÷üÿ | |
3498 } | |
0 | 3499 else |
3500 { | |
2214 | 3501 winner = (pl_resource <= en_resource) + 1;//ðåñóðñû íå ðàâíû, ïîáåæäàåò òîò ó êîãî áîëüøå |
3502 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3503 } |
3504 } | |
3505 } | |
2214 | 3506 else if ( winner == 0 && victory_type == 4 )// ïðè íè÷üå ïî áàøíÿì è ñòåíå |
0 | 3507 { |
2214 | 3508 if ( pl_resource != en_resource )//ðåñóðñû íå ðàâíû |
0 | 3509 { |
2214 | 3510 winner = (pl_resource <= en_resource) + 1;//ïîáåäèë òîò ó êîãî áîëüøå |
3511 victory_type = 5;//ïîáåäà êîãäà ïðè íè÷üå áîëüøåå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3512 } |
2214 | 3513 else //ðåñóðñû ðàâíû |
3514 { | |
3515 winner = 0;//íåò ïîáåäèòåëÿ | |
3516 victory_type = 4; //íè÷üÿ | |
3517 } | |
0 | 3518 } |
2214 | 3519 |
3520 //ïîäâåäåíèå èòîãîâ | |
3521 pArcomageGame->Victory_type = victory_type; | |
3522 pArcomageGame->uGameWinner = winner; | |
3523 if ( winner == 1 )//ïîáåäèòåëü èãðîê 1(ìû) | |
0 | 3524 { |
2214 | 3525 if (( window_SpeakInHouse->par1C >= 108 ) && ( window_SpeakInHouse->par1C <= 120 ))//òàâåðíû |
0 | 3526 { |
2214 | 3527 if ( !pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] ) |
3528 { | |
3529 pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] = 1; | |
3530 pParty->PartyFindsGold(p2DEvents[ window_SpeakInHouse->par1C - 1].fPriceMultiplier * 100.0, 0);//âîçíàãðàæäåíèå | |
3531 } | |
0 | 3532 } |
2214 | 3533 //ïðîâåðêà âûïîëíåí ëè êâåñò ïî àðêîìàãó |
3534 tavern_num = 0; | |
3535 for ( uint i = 108; i <= 120; ++i ) | |
0 | 3536 { |
2214 | 3537 if ( !pParty->pArcomageWins[i - 108] ) |
0 | 3538 break; |
2214 | 3539 tavern_num++; |
0 | 3540 } |
2214 | 3541 if ( tavern_num == 13 ) |
3542 _449B7E_toggle_bit(pParty->_quest_bits, 238, 1);// 238 - Won all Arcomage games | |
3543 | |
3544 for ( int i = 0; i < 4; ++i )//âíåñåíèå çàïèñè â Çàñëóãè | |
0 | 3545 { |
2214 | 3546 if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) |
3547 _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1); | |
0 | 3548 } |
949 | 3549 ++pParty->uNumArcomageWins; |
2214 | 3550 if ( pParty->uNumArcomageWins > 1000000 )//îãðàíè÷åíèå êîëè÷åñòâà ïîáåä |
949 | 3551 pParty->uNumArcomageWins = 1000000; |
0 | 3552 } |
2214 | 3553 else//ïðîèãðûø |
0 | 3554 { |
2214 | 3555 for ( int i = 0; i < 4; ++i )//âíåñåíèå çàïèñè â Çàñëóãè |
2213 | 3556 { |
2214 | 3557 if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) |
3558 _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1); | |
0 | 3559 } |
949 | 3560 ++pParty->uNumArcomageLoses; |
2214 | 3561 if ( pParty->uNumArcomageLoses > 1000000 )//îãðàíè÷åíèå êîëè÷åñòâà ïðîèãðûøåé |
949 | 3562 pParty->uNumArcomageLoses = 1000000; |
0 | 3563 } |
3564 } | |
3565 | |
3566 //----- (00409C8B) -------------------------------------------------------- | |
2339 | 3567 void ArcomageGame::PrepareArcomage() |
2213 | 3568 { |
2334 | 3569 // signed __int64 v1; // qax@4 |
0 | 3570 int v2; // esi@4 |
1183 | 3571 int v3; // esi@5 |
0 | 3572 signed int v4; // edi@5 |
2334 | 3573 // int v6; // edx@9 |
1183 | 3574 RECT pXYZW; // [sp+8h] [bp-1Ch]@5 |
3575 POINT pXY; // [sp+18h] [bp-Ch]@5 | |
0 | 3576 |
3577 pAudioPlayer->StopChannels(-1, -1); | |
1201 | 3578 strcpy(pArcomageGame->pPlayer1Name, Player1Name); |
3579 strcpy(pArcomageGame->pPlayer2Name, Player2Name); | |
0 | 3580 am_byte_4FAA76 = 0; |
3581 am_byte_4FAA75 = 0; | |
1183 | 3582 |
2213 | 3583 for (int i = 0; i < 10; ++i) |
3584 { | |
3585 v2 = (i+1) % 4; | |
3586 v3 = (i+1) / 4; | |
3587 shown_cards[i].uCardId = -1; | |
3588 shown_cards[i].field_4 = 0; | |
3589 shown_cards[i].field_8.x = 100 * v2 + 120; | |
3590 shown_cards[i].field_8.y = 138 * v3 + 18; | |
3591 shown_cards[i].field_10_xplus = -100 * v2 / 5; | |
3592 shown_cards[i].field_14_y_plus = -138 * v3 / 5; | |
3593 shown_cards[i].field_18_point.x = shown_cards[i].field_8.x; | |
3594 shown_cards[i].field_18_point.y = shown_cards[i].field_8.y; | |
3595 } | |
1183 | 3596 |
3597 pXY.x = 0; | |
3598 pXY.y = 0; | |
0 | 3599 ArcomageGame::LoadBackground(); |
1183 | 3600 pXYZW.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
3601 pXYZW.right = window->GetWidth(); |
1183 | 3602 pXYZW.top = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
3603 pXYZW.bottom = window->GetHeight(); |
0 | 3604 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1); |
2154 | 3605 pRenderer->am_Blt_Copy(&pXYZW, &pXY, 2); |
0 | 3606 am_EndScene(); |
3607 pRenderer->Present(); | |
3608 ArcomageGame::LoadSprites(); | |
1679 | 3609 pRenderer->Present(); |
1183 | 3610 |
0 | 3611 v4 = 120; |
2213 | 3612 for ( int i = 0; i < 12; ++i ) |
1183 | 3613 am_sounds[i] = pSoundList->LoadSound(v4++, 0); |
3614 | |
2213 | 3615 for (int i = 0; i < 10; ++i) |
1679 | 3616 array_4FABD0[i].field_40 = stru272_stru0::New(); |
1184 | 3617 |
1200 | 3618 current_card_slot_index = -1; |
0 | 3619 amuint_4FAA4C = -1; |
3620 byte_4FAA74 = 0; | |
3621 pArcomageGame->field_F4 = 0; | |
1679 | 3622 am_gameover = false; |
0 | 3623 byte_505880 = 0; |
3624 dword_4FAA70 = 0; | |
1263 | 3625 need_to_discard_card = 0; |
1197 | 3626 SetStartGameData(); |
1200 | 3627 InitalHandsFill(); |
0 | 3628 //nullsub_1(); |
1197 | 3629 pArcomageGame->GameOver = 0; |
1183 | 3630 pArcomageGame->pfntComic = pFontComic; |
3631 pArcomageGame->pfntArrus = pFontArrus; | |
0 | 3632 } |
3633 | |
3634 //----- (0040D711) -------------------------------------------------------- | |
3635 ArcomageGame::ArcomageGame() | |
3636 { | |
1183 | 3637 field_4 = 0; |
0 | 3638 //RGBTexture::RGBTexture(&this->pGameBackground); |
3639 //RGBTexture::RGBTexture(&v1->pSprites); | |
1183 | 3640 bGameInProgress = 0; |
3641 field_F9 = 0; | |
0 | 3642 } |
938 | 3643 |
3644 //----- (00409BE8) -------------------------------------------------------- | |
1197 | 3645 void SetStartConditions() |
938 | 3646 { |
1256 | 3647 const ArcomageStartConditions *st_cond; // eax@1 |
2213 | 3648 |
1200 | 3649 st_cond = &start_conditions[window_SpeakInHouse->par1C - 108]; |
3650 start_tower_height = st_cond->tower_height; | |
3651 start_wall_height = st_cond->wall_height; | |
3652 start_quarry_level = st_cond->quarry_level - 1; | |
3653 start_magic_level = st_cond->magic_level - 1; | |
3654 start_zoo_level = st_cond->zoo_level - 1; | |
3655 minimum_cards_at_hand = 5; | |
1197 | 3656 quarry_bonus = 1; |
3657 magic_bonus = 1; | |
1201 | 3658 zoo_bonus = 1; |
1200 | 3659 max_tower_height = st_cond->max_tower; |
3660 max_resources_amount = st_cond->max_resources; | |
3661 | |
1256 | 3662 opponent_mastery = st_cond->mastery_lvl; |
1200 | 3663 |
3664 start_bricks_amount = st_cond->bricks_amount; | |
3665 start_gems_amount = st_cond->gems_amount; | |
3666 start_beasts_amount = st_cond->beasts_amount; | |
1183 | 3667 } |
3668 | |
3669 //----- (0040D75D) -------------------------------------------------------- | |
1679 | 3670 void am_DrawText( int a1, const char *pText, POINT *pXY ) |
2213 | 3671 { |
2214 | 3672 pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) / 2) + 3, 0, pText, 0, 0, 0); |
2213 | 3673 } |
1183 | 3674 |
3675 //----- (0040DB27) -------------------------------------------------------- | |
1263 | 3676 void DrawRect( RECT *pXYZW, unsigned __int16 uColor, char bSolidFill ) |
2213 | 3677 { |
3678 pRenderer->BeginScene(); | |
2216 | 3679 pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); |
2213 | 3680 if ( bSolidFill ) |
3681 { | |
2216 | 3682 for ( int i = pXYZW->top; i <= pXYZW->bottom; ++i ) |
3683 pRenderer->RasterLine2D(pXYZW->left, i, pXYZW->right, i, uColor); | |
2213 | 3684 } |
3685 else | |
3686 { | |
2216 | 3687 pRenderer->RasterLine2D(pXYZW->left, pXYZW->top, pXYZW->right, pXYZW->top, uColor); |
3688 pRenderer->RasterLine2D(pXYZW->right, pXYZW->top, pXYZW->right, pXYZW->bottom, uColor); | |
3689 pRenderer->RasterLine2D(pXYZW->right, pXYZW->bottom, pXYZW->left, pXYZW->bottom, uColor); | |
3690 pRenderer->RasterLine2D(pXYZW->left, pXYZW->bottom, pXYZW->left, pXYZW->top, uColor); | |
2213 | 3691 } |
3692 pRenderer->EndScene(); | |
3693 } | |
1183 | 3694 |
1679 | 3695 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ) |
2069 | 3696 { |
2213 | 3697 pRenderer->BeginScene(); |
3698 //if ( uNumSceneBegins ) | |
3699 { | |
2216 | 3700 if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1 |
3701 && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1) | |
2069 | 3702 { |
3703 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor); | |
3704 pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y, uColor); | |
3705 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y + 1, uColor); | |
3706 pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y + 1, uColor); | |
2213 | 3707 } |
3708 pRenderer->EndScene(); | |
3709 } | |
2069 | 3710 } |
1185 | 3711 |
3712 //----- (0040DBD3) -------------------------------------------------------- | |
1679 | 3713 void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor ) |
2069 | 3714 { |
2213 | 3715 pRenderer->BeginScene(); |
3716 //if ( pRenderer->uNumSceneBegins ) | |
3717 { | |
2216 | 3718 if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1 |
3719 && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1) | |
2213 | 3720 { |
3721 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor); | |
3722 /*int xVal = pTargetXY->x; | |
3723 int yVal = pTargetXY->y; | |
3724 if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479) | |
3725 { | |
3726 pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * yVal] = uColor; | |
3727 }*/ | |
3728 } | |
3729 pRenderer->EndScene(); | |
3730 } | |
2069 | 3731 } |
1185 | 3732 |
1183 | 3733 //----- (0040DDB1) -------------------------------------------------------- |
1263 | 3734 int rand_interval( int min, int max ) |
2213 | 3735 { |
3736 return min + rand() % (max - min + 1); | |
3737 } | |
1183 | 3738 |
3739 //----- (0040DEC8) -------------------------------------------------------- | |
1679 | 3740 void __fastcall am_IntToString(int val, char *pOut) |
2213 | 3741 { |
3742 sprintfex(pOut, "%d", val); | |
3743 } | |
1303 | 3744 |
3745 void set_stru1_field_8_InArcomage(int inValue) | |
3746 { | |
3747 switch(inValue) | |
3748 { | |
3749 case 91:LOBYTE(pArcomageGame->stru1.field_8) = 123;break; | |
3750 case 92:LOBYTE(pArcomageGame->stru1.field_8) = 124;break; | |
3751 case 93:LOBYTE(pArcomageGame->stru1.field_8) = 125;break; | |
3752 case 96:LOBYTE(pArcomageGame->stru1.field_8) = 126;break; | |
3753 case 61:LOBYTE(pArcomageGame->stru1.field_8) = 43;break; | |
3754 case 55:LOBYTE(pArcomageGame->stru1.field_8) = 38;break; | |
3755 case 56:LOBYTE(pArcomageGame->stru1.field_8) = 42;break; | |
3756 case 57:LOBYTE(pArcomageGame->stru1.field_8) = 40;break; | |
3757 case 59:LOBYTE(pArcomageGame->stru1.field_8) = 58;break; | |
3758 case 54:LOBYTE(pArcomageGame->stru1.field_8) = 94;break; | |
3759 case 50:LOBYTE(pArcomageGame->stru1.field_8) = 64;break; | |
3760 case 51:LOBYTE(pArcomageGame->stru1.field_8) = 35;break; | |
3761 case 52:LOBYTE(pArcomageGame->stru1.field_8) = 36;break; | |
3762 case 53:LOBYTE(pArcomageGame->stru1.field_8) = 37;break; | |
3763 case 49:LOBYTE(pArcomageGame->stru1.field_8) = 33;break; | |
3764 case 39:LOBYTE(pArcomageGame->stru1.field_8) = 34;break; | |
3765 case 44:LOBYTE(pArcomageGame->stru1.field_8) = 60;break; | |
3766 case 46:LOBYTE(pArcomageGame->stru1.field_8) = 62;break; | |
3767 case 47:LOBYTE(pArcomageGame->stru1.field_8) = 63;break; | |
3768 case 48:LOBYTE(pArcomageGame->stru1.field_8) = 41;break; | |
3769 default:LOBYTE(pArcomageGame->stru1.field_8) = inValue;break; | |
3770 } | |
3771 } |