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