Mercurial > mm7
comparison mm7_3.cpp @ 1332:1e35cfed7928
turn engine file added
author | Gloval |
---|---|
date | Fri, 05 Jul 2013 01:46:44 +0400 |
parents | f0be1fecd642 |
children | 8bfdc44cebfd |
comparison
equal
deleted
inserted
replaced
1331:f0be1fecd642 | 1332:1e35cfed7928 |
---|---|
12416 return -pCosTable[uIntegerPi - v2]; | 12416 return -pCosTable[uIntegerPi - v2]; |
12417 else | 12417 else |
12418 return pCosTable[v2]; | 12418 return pCosTable[v2]; |
12419 } | 12419 } |
12420 | 12420 |
12421 //----- (00404544) -------------------------------------------------------- | |
12422 void stru262_TurnBased::_404544() | |
12423 { | |
12424 stru262_TurnBased *v1; // ebx@1 | |
12425 TurnBased_QueueElem *v2; // esi@2 | |
12426 Actor *v3; // edi@4 | |
12427 Actor *v4; // ecx@4 | |
12428 Player *v5; // eax@7 | |
12429 int v6; // ecx@15 | |
12430 TurnBased_QueueElem *v7; // eax@16 | |
12431 TurnBased_QueueElem *v8; // ecx@18 | |
12432 int v9; // edx@19 | |
12433 int v10; // esi@19 | |
12434 int v11; // esi@21 | |
12435 int v12; // ST0C_4@25 | |
12436 int v13; // ST10_4@25 | |
12437 int v14; // ST14_4@25 | |
12438 int v15; // ST18_4@25 | |
12439 signed int result; // eax@28 | |
12440 TurnBased_QueueElem *v17; // edi@32 | |
12441 int v18; // [sp+20h] [bp-Ch]@17 | |
12442 int v19; // [sp+24h] [bp-8h]@1 | |
12443 int v20; // [sp+28h] [bp-4h]@1 | |
12444 signed int v21; // [sp+28h] [bp-4h]@16 | |
12445 int v22; // [sp+28h] [bp-4h]@31 | |
12446 | |
12447 int i; | |
12448 | |
12449 v20 = 0; | |
12450 v1 = this; | |
12451 v19 = this->uActorQueueSize; | |
12452 if ( this->uActorQueueSize > 0 ) | |
12453 { | |
12454 v2 = this->pQueue; | |
12455 do | |
12456 { | |
12457 if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) | |
12458 { | |
12459 v3 = &pActors[PID_ID(v2->uPackedID)]; | |
12460 v4 = &pActors[PID_ID(v2->uPackedID)]; | |
12461 LOBYTE(v4->uAttributes) |= 0x80u; | |
12462 if ( !v4->CanAct() ) | |
12463 { | |
12464 --v19; | |
12465 v2->field_4 = 1001; | |
12466 LOBYTE(v3->uAttributes) &= 0x7Fu; | |
12467 } | |
12468 } | |
12469 | |
12470 if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) | |
12471 { | |
12472 v5 = &pParty->pPlayers[v2->uPackedID >> 3]; | |
12473 if ( v5->pConditions[Player::Condition_Dead] | |
12474 || v5->pConditions[Player::Condition_Eradicated] | |
12475 || v5->pConditions[Player::Condition_Pertified] | |
12476 || v5->pConditions[Player::Condition_Unconcious] | |
12477 || v5->pConditions[Player::Condition_Paralyzed] | |
12478 || v5->pConditions[Player::Condition_Sleep] ) | |
12479 { | |
12480 --v19; | |
12481 v2->field_4 = 1001; | |
12482 } | |
12483 } | |
12484 ++v20; | |
12485 ++v2; | |
12486 } | |
12487 while ( v20 < v1->uActorQueueSize ); | |
12488 } | |
12489 | |
12490 //sort | |
12491 v6 = v1->uActorQueueSize; | |
12492 if ( v6 > 0 ) | |
12493 { | |
12494 v21 = 1; | |
12495 v7 = v1->pQueue; | |
12496 do | |
12497 { | |
12498 v18 = v21; | |
12499 if ( v21 < v6 ) | |
12500 { | |
12501 v8 = v7 + 1; | |
12502 do | |
12503 { | |
12504 v9 = v8->field_4; | |
12505 v10 = v7->field_4; | |
12506 if ( v8->field_4 < v7->field_4 || v8->field_4 == v7->field_4 | |
12507 && (( PID_TYPE(v8->uPackedID) == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor | |
12508 || PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID) && | |
12509 (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) | |
12510 { | |
12511 v12 = v7->uPackedID; | |
12512 v13 = v7->field_4; | |
12513 v14 = v7->uActionLength; | |
12514 v15 = v7->field_C; | |
12515 v7->uPackedID = v8->uPackedID; | |
12516 v7->field_4 = v8->field_4; | |
12517 v7->uActionLength = v8->uActionLength; | |
12518 v7->field_C = v8->field_C; | |
12519 v8->uPackedID = v12; | |
12520 v8->field_4 = v13; | |
12521 v8->uActionLength = v14; | |
12522 v8->field_C = v15; | |
12523 } | |
12524 ++v18; | |
12525 ++v8; | |
12526 } | |
12527 while ( v18 < v1->uActorQueueSize ); | |
12528 } | |
12529 ++v21; | |
12530 v6 = v1->uActorQueueSize; | |
12531 ++v7; | |
12532 } | |
12533 while ( v21 - 1 < v6 ); | |
12534 } | |
12535 v1->uActorQueueSize = v19; | |
12536 | |
12537 | |
12538 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) | |
12539 { | |
12540 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; | |
12541 field_18 |= 4u; | |
12542 } | |
12543 else | |
12544 { | |
12545 uActiveCharacter = 0; | |
12546 field_18 &= 0xFFFFFFFBu; | |
12547 } | |
12548 | |
12549 for(i=0; i<uActorQueueSize; ++i) | |
12550 { | |
12551 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) | |
12552 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); | |
12553 } | |
12554 | |
12555 | |
12556 } | |
12557 | |
12558 //----- (0040471C) -------------------------------------------------------- | |
12559 void stru262_TurnBased::_40471C() | |
12560 { | |
12561 if ( pParty->bTurnBasedModeOn == 1 ) | |
12562 { | |
12563 if ( pTurnEngine->field_4 == 2 ) | |
12564 _406457(0); | |
12565 } | |
12566 } | |
12567 | |
12568 //----- (004059DB) -------------------------------------------------------- | |
12569 void stru262_TurnBased::Start() | |
12570 { | |
12571 //stru262_TurnBased *v1; // ebx@1 | |
12572 int v3; // esi@1 | |
12573 int v4; // eax@5 | |
12574 unsigned int actor_id; // esi@7 | |
12575 Actor *pActor; // edi@7 | |
12576 unsigned int v7; // eax@9 | |
12577 unsigned int v8; // edx@10 | |
12578 //unsigned __int8 v9; // zf@14 | |
12579 //unsigned __int8 v10; // sf@14 | |
12580 //unsigned __int8 v11; // of@14 | |
12581 //char *v12; // esi@15 | |
12582 //int v13; // ecx@16 | |
12583 //unsigned __int16 v14; // ax@17 | |
12584 int v15; // ecx@18 | |
12585 signed __int64 v16; // qax@19 | |
12586 int v17; // edx@22 | |
12587 unsigned int v18; // esi@27 | |
12588 char *v19; // esi@32 | |
12589 int v20; // edx@33 | |
12590 char *v21; // eax@33 | |
12591 int v22; // ecx@33 | |
12592 int v23; // eax@34 | |
12593 char *v24; // eax@34 | |
12594 char *v25; // ecx@34 | |
12595 int v26; // edx@34 | |
12596 int v27; // eax@38 | |
12597 int v28; // ecx@38 | |
12598 AIDirection v30; // [sp+Ch] [bp-68h]@10 | |
12599 AIDirection v31; // [sp+28h] [bp-4Ch]@10 | |
12600 AIDirection a3; // [sp+44h] [bp-30h]@10 | |
12601 //int v33; // [sp+60h] [bp-14h]@10 | |
12602 int *v34; // [sp+64h] [bp-10h]@6 | |
12603 int v35; // [sp+68h] [bp-Ch]@5 | |
12604 Player *pPlayer; // [sp+6Ch] [bp-8h]@1 | |
12605 int v40b; | |
12606 unsigned int v37; // [sp+70h] [bp-4h]@7 | |
12607 int activ_players[4]; | |
12608 int players_recovery_time[4]; | |
12609 int a_players_count; | |
12610 int i,j; | |
12611 int temp; | |
12612 | |
12613 | |
12614 pTurnEngine->field_18 &= 0xFFFFFFFDu; | |
12615 //v1 = this; | |
12616 pEventTimer->TrackGameTime(); | |
12617 pAudioPlayer->StopChannels(-1, -1); | |
12618 pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); | |
12619 pPlayer = pParty->pPlayers; | |
12620 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; | |
12621 dword_50C994 = 0; | |
12622 | |
12623 this->field_10 = 100; | |
12624 this->field_0 = 0; | |
12625 this->field_8 = 64; | |
12626 this->field_4 = 1; | |
12627 this->uActorQueueSize = 0; | |
12628 | |
12629 for ( v3 = 0; v3 < 4 ; ++v3 ) | |
12630 { | |
12631 if ( pParty->pPlayers[v3].CanAct() ) | |
12632 { | |
12633 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3); | |
12634 this->pQueue[this->uActorQueueSize].field_C = 2; | |
12635 this->pQueue[this->uActorQueueSize].uActionLength = 0; | |
12636 pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; | |
12637 ++this->uActorQueueSize; | |
12638 } | |
12639 } | |
12640 | |
12641 for ( v3 = 0; v3 < ai_arrays_size ; ++v3 ) | |
12642 { | |
12643 actor_id = ai_near_actors_ids[v3]; | |
12644 if (actor_id == 10) | |
12645 continue; | |
12646 if ( pActors[actor_id].CanAct() ) | |
12647 { | |
12648 if ( pActors[actor_id].uAttributes & 0x8000 ) | |
12649 { | |
12650 v8 = ai_near_actors_targets_pid[actor_id]; | |
12651 pActors[actor_id].uAttributes |= 0x80; | |
12652 memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection)); | |
12653 memcpy(&v30, &v31, sizeof(AIDirection)); | |
12654 Actor::AI_StandOrBored(actor_id, 4, 32, &v30); | |
12655 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id); | |
12656 this->pQueue[this->uActorQueueSize].field_C = 2; | |
12657 this->pQueue[this->uActorQueueSize].uActionLength = 0; | |
12658 ++this->uActorQueueSize; | |
12659 } | |
12660 } | |
12661 } | |
12662 | |
12663 a_players_count=0; | |
12664 for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b ) | |
12665 { | |
12666 //v13 = PID_TYPE(this->pQueue[0].uPackedID); | |
12667 if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player ) | |
12668 { | |
12669 if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 ) | |
12670 { | |
12671 //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; | |
12672 v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875); | |
12673 this->pQueue[v40b].field_4 = v16; | |
12674 } | |
12675 else | |
12676 { | |
12677 activ_players[a_players_count] = v40b; | |
12678 ++a_players_count; | |
12679 } | |
12680 } | |
12681 else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor ) | |
12682 { | |
12683 v17 = rand() % 99; | |
12684 if ( v17 < 33 ) | |
12685 this->pQueue[v40b].field_4 = 1; | |
12686 else | |
12687 this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3; | |
12688 } | |
12689 else | |
12690 { | |
12691 this->pQueue[v40b].field_4 = 666; | |
12692 } | |
12693 this->pQueue[v40b].field_4 += 16; | |
12694 } | |
12695 | |
12696 | |
12697 if ( a_players_count > 0 ) | |
12698 { | |
12699 for (i=0; i<a_players_count; ++i) | |
12700 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); | |
12701 //sort players by recovery time | |
12702 for (i=0; i < a_players_count; ++i) | |
12703 { | |
12704 for(j=i+1; j<a_players_count;++j ) | |
12705 { | |
12706 if (players_recovery_time[j] < players_recovery_time[i]) //swap values | |
12707 { | |
12708 temp = players_recovery_time[i]; | |
12709 players_recovery_time[i] = players_recovery_time[j]; | |
12710 players_recovery_time[j] = temp; | |
12711 | |
12712 temp = activ_players[i]; | |
12713 activ_players[i] = activ_players[j]; | |
12714 activ_players[j] = temp; | |
12715 } | |
12716 } | |
12717 } | |
12718 | |
12719 for (i=0; i<a_players_count; ++i) | |
12720 { | |
12721 this->pQueue[activ_players[i]].field_4 = i+2; | |
12722 } | |
12723 } | |
12724 this->_404544(); | |
12725 } |