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