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