Mercurial > mm7
diff mm7_3.cpp @ 1332:1e35cfed7928
turn engine file added
author | Gloval |
---|---|
date | Fri, 05 Jul 2013 01:46:44 +0400 |
parents | f0be1fecd642 |
children | 8bfdc44cebfd |
line wrap: on
line diff
--- a/mm7_3.cpp Wed Jul 03 23:21:29 2013 +0400 +++ b/mm7_3.cpp Fri Jul 05 01:46:44 2013 +0400 @@ -12418,308 +12418,3 @@ return pCosTable[v2]; } -//----- (00404544) -------------------------------------------------------- -void stru262_TurnBased::_404544() - { - stru262_TurnBased *v1; // ebx@1 - TurnBased_QueueElem *v2; // esi@2 - Actor *v3; // edi@4 - Actor *v4; // ecx@4 - Player *v5; // eax@7 - int v6; // ecx@15 - TurnBased_QueueElem *v7; // eax@16 - TurnBased_QueueElem *v8; // ecx@18 - int v9; // edx@19 - int v10; // esi@19 - int v11; // esi@21 - int v12; // ST0C_4@25 - int v13; // ST10_4@25 - int v14; // ST14_4@25 - int v15; // ST18_4@25 - signed int result; // eax@28 - TurnBased_QueueElem *v17; // edi@32 - int v18; // [sp+20h] [bp-Ch]@17 - int v19; // [sp+24h] [bp-8h]@1 - int v20; // [sp+28h] [bp-4h]@1 - signed int v21; // [sp+28h] [bp-4h]@16 - int v22; // [sp+28h] [bp-4h]@31 - - int i; - - v20 = 0; - v1 = this; - v19 = this->uActorQueueSize; - if ( this->uActorQueueSize > 0 ) - { - v2 = this->pQueue; - do - { - if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) - { - v3 = &pActors[PID_ID(v2->uPackedID)]; - v4 = &pActors[PID_ID(v2->uPackedID)]; - LOBYTE(v4->uAttributes) |= 0x80u; - if ( !v4->CanAct() ) - { - --v19; - v2->field_4 = 1001; - LOBYTE(v3->uAttributes) &= 0x7Fu; - } - } - - if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) - { - v5 = &pParty->pPlayers[v2->uPackedID >> 3]; - if ( v5->pConditions[Player::Condition_Dead] - || v5->pConditions[Player::Condition_Eradicated] - || v5->pConditions[Player::Condition_Pertified] - || v5->pConditions[Player::Condition_Unconcious] - || v5->pConditions[Player::Condition_Paralyzed] - || v5->pConditions[Player::Condition_Sleep] ) - { - --v19; - v2->field_4 = 1001; - } - } - ++v20; - ++v2; - } - while ( v20 < v1->uActorQueueSize ); - } - - //sort - v6 = v1->uActorQueueSize; - if ( v6 > 0 ) - { - v21 = 1; - v7 = v1->pQueue; - do - { - v18 = v21; - if ( v21 < v6 ) - { - v8 = v7 + 1; - do - { - v9 = v8->field_4; - v10 = v7->field_4; - if ( v8->field_4 < v7->field_4 || v8->field_4 == v7->field_4 - && (( PID_TYPE(v8->uPackedID) == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor - || PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID) && - (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) - { - v12 = v7->uPackedID; - v13 = v7->field_4; - v14 = v7->uActionLength; - v15 = v7->field_C; - v7->uPackedID = v8->uPackedID; - v7->field_4 = v8->field_4; - v7->uActionLength = v8->uActionLength; - v7->field_C = v8->field_C; - v8->uPackedID = v12; - v8->field_4 = v13; - v8->uActionLength = v14; - v8->field_C = v15; - } - ++v18; - ++v8; - } - while ( v18 < v1->uActorQueueSize ); - } - ++v21; - v6 = v1->uActorQueueSize; - ++v7; - } - while ( v21 - 1 < v6 ); - } - v1->uActorQueueSize = v19; - - - if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) - { - uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; - field_18 |= 4u; - } - else - { - uActiveCharacter = 0; - field_18 &= 0xFFFFFFFBu; - } - - for(i=0; i<uActorQueueSize; ++i) - { - if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) - pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); - } - - -} - -//----- (0040471C) -------------------------------------------------------- -void stru262_TurnBased::_40471C() -{ - if ( pParty->bTurnBasedModeOn == 1 ) - { - if ( pTurnEngine->field_4 == 2 ) - _406457(0); - } -} - -//----- (004059DB) -------------------------------------------------------- -void stru262_TurnBased::Start() - { - //stru262_TurnBased *v1; // ebx@1 - int v3; // esi@1 - int v4; // eax@5 - unsigned int actor_id; // esi@7 - Actor *pActor; // edi@7 - unsigned int v7; // eax@9 - unsigned int v8; // edx@10 - //unsigned __int8 v9; // zf@14 - //unsigned __int8 v10; // sf@14 - //unsigned __int8 v11; // of@14 - //char *v12; // esi@15 - //int v13; // ecx@16 - //unsigned __int16 v14; // ax@17 - int v15; // ecx@18 - signed __int64 v16; // qax@19 - int v17; // edx@22 - unsigned int v18; // esi@27 - char *v19; // esi@32 - int v20; // edx@33 - char *v21; // eax@33 - int v22; // ecx@33 - int v23; // eax@34 - char *v24; // eax@34 - char *v25; // ecx@34 - int v26; // edx@34 - int v27; // eax@38 - int v28; // ecx@38 - AIDirection v30; // [sp+Ch] [bp-68h]@10 - AIDirection v31; // [sp+28h] [bp-4Ch]@10 - AIDirection a3; // [sp+44h] [bp-30h]@10 - //int v33; // [sp+60h] [bp-14h]@10 - int *v34; // [sp+64h] [bp-10h]@6 - int v35; // [sp+68h] [bp-Ch]@5 - Player *pPlayer; // [sp+6Ch] [bp-8h]@1 - int v40b; - unsigned int v37; // [sp+70h] [bp-4h]@7 - int activ_players[4]; - int players_recovery_time[4]; - int a_players_count; - int i,j; - int temp; - - - pTurnEngine->field_18 &= 0xFFFFFFFDu; - //v1 = this; - pEventTimer->TrackGameTime(); - pAudioPlayer->StopChannels(-1, -1); - pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); - pPlayer = pParty->pPlayers; - dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; - dword_50C994 = 0; - - this->field_10 = 100; - this->field_0 = 0; - this->field_8 = 64; - this->field_4 = 1; - this->uActorQueueSize = 0; - - for ( v3 = 0; v3 < 4 ; ++v3 ) - { - if ( pParty->pPlayers[v3].CanAct() ) - { - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3); - this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; - ++this->uActorQueueSize; - } - } - - for ( v3 = 0; v3 < ai_arrays_size ; ++v3 ) - { - actor_id = ai_near_actors_ids[v3]; - if (actor_id == 10) - continue; - if ( pActors[actor_id].CanAct() ) - { - if ( pActors[actor_id].uAttributes & 0x8000 ) - { - v8 = ai_near_actors_targets_pid[actor_id]; - pActors[actor_id].uAttributes |= 0x80; - memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection)); - memcpy(&v30, &v31, sizeof(AIDirection)); - Actor::AI_StandOrBored(actor_id, 4, 32, &v30); - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id); - this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - ++this->uActorQueueSize; - } - } - } - - a_players_count=0; - for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b ) - { - //v13 = PID_TYPE(this->pQueue[0].uPackedID); - if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player ) - { - if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 ) - { - //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; - v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875); - this->pQueue[v40b].field_4 = v16; - } - else - { - activ_players[a_players_count] = v40b; - ++a_players_count; - } - } - else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor ) - { - v17 = rand() % 99; - if ( v17 < 33 ) - this->pQueue[v40b].field_4 = 1; - else - this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3; - } - else - { - this->pQueue[v40b].field_4 = 666; - } - this->pQueue[v40b].field_4 += 16; - } - - - if ( a_players_count > 0 ) - { - for (i=0; i<a_players_count; ++i) - players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); - //sort players by recovery time - for (i=0; i < a_players_count; ++i) - { - for(j=i+1; j<a_players_count;++j ) - { - if (players_recovery_time[j] < players_recovery_time[i]) //swap values - { - temp = players_recovery_time[i]; - players_recovery_time[i] = players_recovery_time[j]; - players_recovery_time[j] = temp; - - temp = activ_players[i]; - activ_players[i] = activ_players[j]; - activ_players[j] = temp; - } - } - } - - for (i=0; i<a_players_count; ++i) - { - this->pQueue[activ_players[i]].field_4 = i+2; - } - } - this->_404544(); - }