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