Mercurial > mm7
changeset 1448:5a5d0c713d47
some turn engine renaming
author | Gloval |
---|---|
date | Tue, 06 Aug 2013 00:52:46 +0400 |
parents | 6b4a1c44a56f |
children | 27b7ee003c7c |
files | Actor.cpp CastSpellInfo.cpp Game.cpp Player.cpp TurnEngine.cpp TurnEngine.h mm7_5.cpp mm7_6.cpp |
diffstat | 8 files changed, 186 insertions(+), 213 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/Actor.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -2322,7 +2322,7 @@ v8 = 30; if ( !pParty->bTurnBasedModeOn ) pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v8 * 2.133333333333333)); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); result = 1; } return result; @@ -4158,7 +4158,7 @@ if (pParty->bTurnBasedModeOn) { - pTurnEngine->_405E14(); + pTurnEngine->AITurnBasedAction(); return; }
--- a/CastSpellInfo.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/CastSpellInfo.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -430,7 +430,7 @@ //v649 = pPlayer; pParty->pTurnBasedPlayerRecoveryTimes[this[n].uPlayerID] = 100; pPlayer->SetRecoveryTime(sRecoveryTime); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed" pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -4048,7 +4048,7 @@ pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime; pPlayer->SetRecoveryTime(v645); if ( !some_active_character ) - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } else {
--- a/Game.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/Game.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -480,7 +480,7 @@ if ( pParty->bTurnBasedModeOn == 1 ) { - pTurnEngine->End(1); + pTurnEngine->End(true); pParty->bTurnBasedModeOn = 0; } //pHealth = &pParty->pPlayers[0].sHealth;//193C
--- a/Player.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/Player.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -6060,7 +6060,7 @@ { pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; thisb->SetRecoveryTime(100); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } else { @@ -6356,7 +6356,7 @@ { pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; thisb->SetRecoveryTime(100); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } else { @@ -6477,7 +6477,7 @@ { pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; thisb->SetRecoveryTime(100); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } else {
--- a/TurnEngine.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/TurnEngine.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -44,7 +44,7 @@ if ( !pActors[p_id].CanAct() ) { --active_actors; - pQueue[i].field_4 = 1001; + pQueue[i].actor_initiative = 1001; pActors[p_id].uAttributes &= ~0x80; } } @@ -53,7 +53,7 @@ if ( !pParty->pPlayers[p_id].CanAct() ) { --active_actors; - pQueue[i].field_4 = 1001; + pQueue[i].actor_initiative = 1001; } } } @@ -66,8 +66,8 @@ for(j=i+1; j<uActorQueueSize;++j ) { v8=&pQueue[j]; - if ( v8->field_4 < v7->field_4 || - ((v8->field_4 == v7->field_4) && + if ( v8->actor_initiative < v7->actor_initiative || + ((v8->actor_initiative == v7->actor_initiative) && ( ((PID_TYPE(v8->uPackedID) == OBJECT_Player) && (PID_TYPE(v7->uPackedID) == OBJECT_Actor)) || ((PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID)) && (PID_ID(v8->uPackedID) < PID_ID(v7->uPackedID))) @@ -96,14 +96,14 @@ 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); + pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].actor_initiative * 0.46875); } } //----- (0040471C) -------------------------------------------------------- -void stru262_TurnBased::_40471C() +void stru262_TurnBased::ApplyPlayerAction() { if ( pParty->bTurnBasedModeOn == 1 ) { @@ -141,9 +141,9 @@ 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->turn_initiative = 100; + this->turns_count = 0; + this->ai_turn_timer = 64; this->turn_stage = 1; this->uActorQueueSize = 0; @@ -191,7 +191,7 @@ { //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; + this->pQueue[v40b].actor_initiative = v16; } else { @@ -203,15 +203,15 @@ { v17 = rand() % 99; if ( v17 < 33 ) - this->pQueue[v40b].field_4 = 1; + this->pQueue[v40b].actor_initiative = 1; else - this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3; + this->pQueue[v40b].actor_initiative= (v17 >= 66)? 5 : 3; } else { - this->pQueue[v40b].field_4 = 666; + this->pQueue[v40b].actor_initiative = 666; } - this->pQueue[v40b].field_4 += 16; + this->pQueue[v40b].actor_initiative += 16; } if ( a_players_count > 0 ) @@ -238,7 +238,7 @@ for (i=0; i<a_players_count; ++i) { - this->pQueue[activ_players[i]].field_4 = i+2; + this->pQueue[activ_players[i]].actor_initiative = i+2; } } this->SortTurnQueue(); @@ -274,11 +274,11 @@ objID = PID_ID(pQueue[i].uPackedID); if ( objType == OBJECT_Player ) { - pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333); + pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)pQueue[i].actor_initiative * 2.133333333333333); } else if ( objType == OBJECT_Actor ) { - pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333); + pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)pQueue[i].actor_initiative * 2.133333333333333); } } @@ -294,7 +294,7 @@ // 50C998: using guessed type int dword_50C998_turnbased_icon_1A; //----- (00405E14) -------------------------------------------------------- -void stru262_TurnBased::_405E14() +void stru262_TurnBased::AITurnBasedAction() { AIDirection *v6; // esi@21 int v7; // eax@21 @@ -348,50 +348,51 @@ if ( turn_stage == 1 ) { - if ( field_8 == 64 ) + if ( ai_turn_timer == 64 ) { - _406A63(); + ActorAIDoMainAction(); } - else if ( field_8 > 0 ) + else if ( ai_turn_timer > 0 ) { - _406B9F(); + ActorAIDoAdditionAction(); } else { - _406AFE(); - field_10 = 100; + ActorAISetLastAction(); + turn_initiative = 100; } - field_8 -= pEventTimer->uTimeElapsed; + ai_turn_timer -= pEventTimer->uTimeElapsed; } else if ( turn_stage == 2 ) { - if ( !(field_18 & TE_FLAG_1) ) + if ( field_18 == TE_FLAG_1) { - if ( field_10 == 100 ) + if ( turn_initiative == 100 ) { StartTurn(); - _40652A(); + SetAIRecoveryTimes(); + return; } - if ( field_10 > 0 || pQueue[0].field_4 <= 0 ) + if ( turn_initiative > 0 || pQueue[0].actor_initiative <= 0 ) { _4065B0(); - _40652A(); + SetAIRecoveryTimes(); } } - else NextTurn(); } else if ( turn_stage == 3 ) { - if ( uActionPointsLeft <= 0 || field_18 & TE_FLAG_8 ) + if ( (uActionPointsLeft > 0) && (field_18 == TE_FLAG_8) ) { - field_18 &= ~TE_FLAG_8; - turn_stage = 1; - field_8 = 64; + _406FA8(); } else - { - _406FA8(); + { + field_18 &= ~TE_FLAG_8; + turn_stage = 1; + ai_turn_timer = 64; + } } } @@ -416,7 +417,7 @@ if (j==uActorQueueSize ) { pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num); - pQueue[uActorQueueSize].field_4 = 100; + pQueue[uActorQueueSize].actor_initiative = 100; pQueue[uActorQueueSize].uActionLength = 0; pQueue[uActorQueueSize].field_C = 0; ++uActorQueueSize; @@ -434,29 +435,29 @@ if (j==uActorQueueSize ) { pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]); - pQueue[uActorQueueSize].field_4 = 1; + pQueue[uActorQueueSize].actor_initiative = 1; pQueue[uActorQueueSize].uActionLength = 0; pQueue[uActorQueueSize].field_C = 0; ++uActorQueueSize; } } - ++field_0; - field_10 = 100; + ++turns_count; + turn_initiative = 100; - for(i=0; i<uActorQueueSize; ++i) - { - if (pQueue[i].field_4 == 0 ) - pQueue[i].field_4 = 100; - } + for(i=0; i<uActorQueueSize; ++i) + { + if (pQueue[i].actor_initiative == 0 ) + pQueue[i].actor_initiative = 100; + } - _4063A1(); - for(i=0; i<uActorQueueSize; ++i) - { - if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)||(pQueue[i].field_4 > 0)) - break; - _40680F(i); - } + StepTurnQueue(); + for(i=0; i<uActorQueueSize; ++i) + { + if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)||(pQueue[i].actor_initiative > 0)) + break; + _40680F(i); + } } // 4F75D8: using guessed type int ai_arrays_size; @@ -483,7 +484,7 @@ return; } pTurnEngine->field_18 &= ~TE_FLAG_2; - if ( pQueue[0].field_4 <= 0 ) + if ( pQueue[0].actor_initiative <= 0 ) return; v13 = 0; @@ -552,14 +553,14 @@ } //----- (004063A1) -------------------------------------------------------- - int stru262_TurnBased::_4063A1() + int stru262_TurnBased::StepTurnQueue() { int v9; // dx@12 int j; SortTurnQueue(); viewparams->bRedrawGameUI = 1; - if ( pQueue[0].field_4 ) + if ( pQueue[0].actor_initiative!=0 ) { if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) { @@ -567,33 +568,36 @@ { for (j=0; j<uActorQueueSize; ++j ) { - --pQueue[j].field_4; + --pQueue[j].actor_initiative; } - --field_10; - if (field_10 == 0) + --turn_initiative; + if (turn_initiative == 0) return 1; } - while (pQueue[0].field_4 > 0); + while (pQueue[0].actor_initiative != 0); } else { + if ( pQueue[0].actor_initiative>0 ) + { v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState; if (!(v9 == AIState::Dying || v9 == AIState::Dead || v9 == AIState::Disabled || v9 == AIState::Removed)) { - do + do { for (j=0; j<uActorQueueSize; ++j ) { - --pQueue[j].field_4; - if (pQueue[j].field_4 == 1) + --pQueue[j].actor_initiative; + if (pQueue[j].actor_initiative == 0) pQueue[j].uActionLength = 0; } - --field_10; - if (field_10 == 0) + --turn_initiative; + if (turn_initiative == 0) return 1; } - while (pQueue[0].field_4 > 0); + while (pQueue[0].actor_initiative > 0); + } } } } @@ -613,7 +617,7 @@ int v9; // ecx@14 char v10; // zf@15 int i; - + v6=0; if ( PID_TYPE(pQueue[a2].uPackedID) == OBJECT_Player) { v4 = PID_ID(pQueue[a2].uPackedID); @@ -629,30 +633,30 @@ v6 = pMonsterStats->pInfos[pActors[PID_ID(pQueue[a2].uPackedID)].pMonsterInfo.uID].uRecoveryTime; } - pQueue[a2].field_4 = v6; + pQueue[a2].actor_initiative = v6; SortTurnQueue(); if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; else uActiveCharacter = 0; viewparams->bRedrawGameUI = 1; - if (pQueue[0].field_4 > 0) + if (pQueue[0].actor_initiative > 0) { - while(field_10 > 0) + while(turn_initiative > 0) { for (i=0; i<uActorQueueSize; ++i) { - --pQueue[i].field_4; - if (pQueue[i].field_4==0) + --pQueue[i].actor_initiative; + if (pQueue[i].actor_initiative==0) pQueue[i].uActionLength=0; } - --field_10; + --turn_initiative; } } } //----- (0040652A) -------------------------------------------------------- -void stru262_TurnBased::_40652A() +void stru262_TurnBased::SetAIRecoveryTimes() { int i; int monster_ai_state; @@ -660,7 +664,7 @@ for (i=0; i<uActorQueueSize; ++i ) { - if (pQueue[i].field_4 == 0) + if (pQueue[i].actor_initiative == 0) { if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) break; @@ -670,9 +674,9 @@ monster_ai_state == AIState::Fleeing || monster_ai_state == AIState::Fidgeting) { - pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; + pQueue[i].actor_initiative = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; if (monster->pActorBuffs[7].uExpireTime > 0) - pQueue[i].field_4*=2; + pQueue[i].actor_initiative*=2; } } } @@ -684,11 +688,11 @@ int i; SortTurnQueue(); - if (pQueue[0].field_4 <= 0) + if (pQueue[0].actor_initiative <= 0) { for (i=0; i<uActorQueueSize; ++i ) { - if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)|| (pQueue[i].field_4 > 0) ) + if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)|| (pQueue[i].actor_initiative > 0) ) break; if ((pQueue[i].uActionLength<=0) && (PID_TYPE(pQueue[i].uPackedID)==OBJECT_Actor)) _40680F(i); @@ -696,7 +700,7 @@ } else { - _4063A1(); + StepTurnQueue(); if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; else @@ -705,11 +709,11 @@ } for (i=0; i<uActorQueueSize; ++i ) - AIRangedAttacks(i); + AIAttacks(i); } //----- (00406648) -------------------------------------------------------- -void stru262_TurnBased::AIRangedAttacks( unsigned int queue_index ) +void stru262_TurnBased::AIAttacks( unsigned int queue_index ) { TurnBased_QueueElem *v1; // ecx@1 int v3; // eax@1 @@ -940,7 +944,7 @@ } //----- (00406A63) -------------------------------------------------------- -void stru262_TurnBased::_406A63() +void stru262_TurnBased::ActorAIDoMainAction() { AIDirection a3; // [sp+8h] [bp-44h]@5 @@ -948,7 +952,7 @@ unsigned int target_pid; // [sp+40h] [bp-Ch]@5 int i; - this->field_8 = 64; + this->ai_turn_timer = 64; dword_50C994 = 0; uActiveCharacter = 0; for (i=0; i<uActorQueueSize; ++i ) @@ -965,7 +969,7 @@ // 50C994: using guessed type int dword_50C994; //----- (00406AFE) -------------------------------------------------------- -void stru262_TurnBased::_406AFE() +void stru262_TurnBased::ActorAISetLastAction() { AIDirection a3; // [sp+4h] [bp-48h]@5 AIDirection v7; // [sp+20h] [bp-2Ch]@5 @@ -984,12 +988,12 @@ } } turn_stage = 2; - field_8 = 100; + ai_turn_timer = 100; } //----- (00406B9F) -------------------------------------------------------- -void stru262_TurnBased::_406B9F() +void stru262_TurnBased::ActorAIDoAdditionAction() { Actor *v6; // ebx@5 AIDirection a3; // [sp+0h] [bp-50h]@15 @@ -1045,7 +1049,7 @@ int v8; // eax@7 AIDirection *v9; // esi@10 int v10; // eax@10 - unsigned int v11; // ecx@10 + int v11; // ecx@10 unsigned __int8 pHostileType; // al@12 unsigned __int8 v13; // sf@16 unsigned __int8 v14; // of@16 @@ -1057,7 +1061,7 @@ AIDirection a3; // [sp+Ch] [bp-48h]@10 AIDirection pDir; // [sp+28h] [bp-2Ch]@10 int v27; // [sp+44h] [bp-10h]@33 - unsigned int v28; // [sp+48h] [bp-Ch]@10 + int v28; // [sp+48h] [bp-Ch]@10 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7 unsigned int uActorID; // [sp+50h] [bp-4h]@2 unsigned int a2a; // [sp+5Ch] [bp+8h]@7 @@ -1070,7 +1074,9 @@ //uActorID = v3; actor = &pActors[uActorID]; //v5 = v4->uAIState; - if ( actor->uAIState == 5 || actor->uAIState == 4 || actor->uAIState == 11 || actor->uAIState == 19 || actor->uAIState == 17 ) + if ( actor->uAIState == AIState::Dead || actor->uAIState == AIState::Dying || + actor->uAIState == AIState::Removed|| actor->uAIState == AIState::Disabled || + actor->uAIState == AIState::Summoned ) return 1; v6 = &ai_near_actors_targets_pid[uActorID]; v7 = &pTurnEngine->pQueue[a2]; @@ -1082,116 +1088,96 @@ actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0); v10 = actor->uActorRadius; - memcpy(&a3, v9, sizeof(a3)); - memcpy(&pDir, &a3, sizeof(pDir)); + memcpy(&a3, v9, sizeof(AIDirection)); + memcpy(&pDir, &a3, sizeof(AIDirection)); v11 = a3.uDistance - v10; v28 = a3.uDistance - v10; - if ( ((a3.uDistance - v10) & 0x80000000u) != 0 ) + if ( v28 < 0 ) { v11 = 0; v28 = 0; } pHostileType = actor->pMonsterInfo.uHostilityType; - if ( pHostileType == 1 ) - { - if ( (double)(signed int)v28 >= 307.2 ) - goto LABEL_21; - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - goto LABEL_21; - } - if ( pHostileType == 2 ) - { - v14 = __OFSUB__(v11, 1024); - v13 = ((v11 - 1024) & 0x80000000u) != 0; - } - else + + + switch (pHostileType) { - if ( pHostileType != 3 ) - goto LABEL_21; - v14 = __OFSUB__(v11, 2560); - v13 = ((v11 - 2560) & 0x80000000u) != 0; + case 1: + if ( (double)v28 < 307.2 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 2: + if ( v28 < 1024 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 3: + if ( v28 < 2560 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; } - if ( v13 ^ v14 ) + + if ( actor->pActorBuffs[4].uExpireTime > 0 ) { - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } -LABEL_21: - if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 ) - { - if ( (signed int)v11 < 10240 ) + if (v11 < 10240 ) { Actor::AI_Flee(uActorID, a2a, 0, &pDir); v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; } - Actor::AI_4032B2(uActorID, a2a, 1024, 0); - v29->field_C = 2; + else + { + Actor::AI_4032B2(uActorID, a2a, 1024, 0); + v29->field_C = 2; + } + v29->uActionLength = actor->uCurrentActionLength; return 1; } - if ( actor->pMonsterInfo.uHostilityType != 4 ) - goto LABEL_46; + + if ( actor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long ) + { if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 ) { if ( actor->pMonsterInfo.uAIType == 1 ) { if ( actor->pMonsterInfo.uMovementType == 5 ) - { Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); + else + Actor::AI_Flee(uActorID, a2a, 32, 0); v29->field_C = 4; v29->uActionLength = actor->uCurrentActionLength; return 1; } if ( actor->pMonsterInfo.uAIType == 2 ) { - v27 = actor->sCurrentHP; - v18 = (double)v27; - v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2; - if ( v19 > v18 && (signed int)v11 < 10240 ) + + if (((double)actor->pMonsterInfo.uHP * 0.2) > (double)actor->sCurrentHP && (v11 < 10240 ) ) { if ( actor->pMonsterInfo.uMovementType == 5 ) - { Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); + else + Actor::AI_Flee(uActorID, a2a, 32, 0); v29->field_C = 4; v29->uActionLength = actor->uCurrentActionLength; return 1; } - goto LABEL_39; } if ( actor->pMonsterInfo.uAIType == 3 ) { - v27 = actor->sCurrentHP; - v18 = (double)v27; - v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1; - if ( v19 > v18 && (signed int)v11 < 10240 ) + + if ( ((double)actor->pMonsterInfo.uHP * 0.1) > (double)actor->sCurrentHP && (v11 < 10240 )) { if ( actor->pMonsterInfo.uMovementType == 5 ) - { Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); + else + Actor::AI_Flee(uActorID, a2a, 32, 0); v29->field_C = 4; v29->uActionLength = actor->uCurrentActionLength; return 1; } - goto LABEL_39; + } } -LABEL_39: + if ( (double)(signed int)v28 < 307.2 ) return 0; if ( (signed int)v11 < 5120 ) @@ -1204,42 +1190,29 @@ v29->uActionLength = actor->uCurrentActionLength; return 1; } -LABEL_46: - if ( actor->pMonsterInfo.uMovementType == 0 ) - { - Actor::AI_4032B2(uActorID, a2a, 1024, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; } - if ( actor->pMonsterInfo.uMovementType == 1 ) - { - Actor::AI_4032B2(uActorID, a2a, 2560, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 2 ) + switch(actor->pMonsterInfo.uMovementType) { - Actor::AI_4032B2(uActorID, a2a, 5120, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; + case 0: + Actor::AI_4032B2(uActorID, a2a, 1024, 32); + break; + case 1: + Actor::AI_4032B2(uActorID, a2a, 2560, 32); + break; + case 2: + Actor::AI_4032B2(uActorID, a2a, 5120, 32); + break; + case 4: + Actor::AI_4032B2(uActorID, a2a, 10240, 32); + break; + case 5: + Actor::AI_Stand(uActorID, a2a, 32, 0); + break; + default: + return 1; } - if ( actor->pMonsterInfo.uMovementType == 4 ) - { - Actor::AI_4032B2(uActorID, a2a, 10240, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 5 ) - { - Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; return 1; }
--- a/TurnEngine.h Mon Jul 15 08:20:28 2013 +0400 +++ b/TurnEngine.h Tue Aug 06 00:52:46 2013 +0400 @@ -17,12 +17,12 @@ inline TurnBased_QueueElem() { uPackedID = 0; - field_4 = 0; + actor_initiative = 0; uActionLength = 0; field_C = 0; } int uPackedID; - int field_4; + int actor_initiative; int uActionLength; int field_C; }; @@ -34,41 +34,41 @@ { inline stru262_TurnBased() { - field_0 = 0; + turns_count = 0; turn_stage = 0; - field_8 = 0; + ai_turn_timer = 0; uActorQueueSize = 0; - field_10 = 0; + turn_initiative = 0; uActionPointsLeft = 0; field_18 = 0; field_1C = 0; } void SortTurnQueue(); - void _40471C(); + void ApplyPlayerAction(); void Start(); void End(bool bPlaySound); - void _405E14(); + void AITurnBasedAction(); void StartTurn(); void NextTurn(); - int _4063A1(); + int StepTurnQueue(); void _406457(int a2); - void _40652A(); + void SetAIRecoveryTimes(); void _4065B0(); - void AIRangedAttacks(unsigned int queue_index); + void AIAttacks(unsigned int queue_index); void _40680F(int queue_index); - void _406A63(); - void _406AFE(); - void _406B9F(); + void ActorAIDoMainAction(); + void ActorAISetLastAction(); + void ActorAIDoAdditionAction(); bool ActorTurn(signed int a2); void _406FA8(); - int field_0; + int turns_count; int turn_stage; - int field_8; + int ai_turn_timer; int uActorQueueSize; //c - int field_10; + int turn_initiative; int uActionPointsLeft; //14 int field_18; int field_1C;
--- a/mm7_5.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/mm7_5.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -1039,7 +1039,7 @@ uActiveCharacter = pParty->GetNextActiveCharacter(); some_active_character = 0; if ( pParty->bTurnBasedModeOn ) - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); dword_50C9D0 = 0; dword_50C9D4 = 0; dword_50C9D8 = 0; @@ -2009,7 +2009,7 @@ v60 = sRecoveryTime; pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime; pPlayer9->SetRecoveryTime(v60); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } else {
--- a/mm7_6.cpp Mon Jul 15 08:20:28 2013 +0400 +++ b/mm7_6.cpp Tue Aug 06 00:52:46 2013 +0400 @@ -2202,7 +2202,7 @@ int main_hand_idx = player->pEquipment.uMainHand; if (player->HasItemEquipped(EQUIP_MAIN_HAND)) v34 = pItemsTable->pItems[*(int *)&player->pInventoryItems[main_hand_idx - 1]].uSkillType; - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } switch (v34) @@ -3064,7 +3064,7 @@ if ( !pParty->bTurnBasedModeOn ) pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); pCastSpellInfo.data()->_427D48(uActiveCharacter); - pTurnEngine->_40471C(); + pTurnEngine->ApplyPlayerAction(); } } break;