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