# HG changeset patch # User Gloval # Date 1373231082 -14400 # Node ID bdf0cc8620ad670511ee19ca2cd14402c8ebfa08 # Parent 67e47fc3133dc158c63a8b4fbf32be1ad9e9449e TE continue diff -r 67e47fc3133d -r bdf0cc8620ad TurnEngine.cpp --- a/TurnEngine.cpp Sat Jul 06 23:00:24 2013 +0400 +++ b/TurnEngine.cpp Mon Jul 08 01:04:42 2013 +0400 @@ -60,7 +60,6 @@ //sort if (uActorQueueSize>0) { - for( i=0; ifield_18 &= ~TE_FLAG_2; - //v1 = this; pEventTimer->TrackGameTime(); pAudioPlayer->StopChannels(-1, -1); pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); @@ -244,7 +214,6 @@ this->pQueue[v40b].field_4 += 16; } - if ( a_players_count > 0 ) { for (i=0; iuAIState; - if(v7==Dying) + if(v7==AIState::Dying) { curr_actor->uCurrentActionTime = 0; curr_actor->uCurrentActionLength = 0; curr_actor->uAIState = Dead; curr_actor->UpdateAnimation(); } - else if ( (v7 > Removed)&&(v7 < Disabled)) + else if ( (v7 > AIState::Removed)&&(v7 < AIState::Disabled)) { Actor::AI_StandOrBored(i, target_pid, 32, &v14); } @@ -393,7 +362,6 @@ field_10 = 100; } field_8 -= pEventTimer->uTimeElapsed; - } else if ( turn_stage == 2 ) { @@ -412,7 +380,6 @@ } else NextTurn(); - } else if ( turn_stage == 3 ) { @@ -529,9 +496,9 @@ { curr_actor = &pActors[PID_ID(pQueue[i].uPackedID)]; ai_state = curr_actor->uAIState; - if ( (ai_state == Dying) || (ai_state == Stunned) || (ai_state == AttackingMelee) || - (ai_state == AttackingRanged1) || (ai_state == AttackingRanged2) || - (ai_state == AttackingRanged3) || (ai_state == AttackingRanged4) || (ai_state ==Summoned)) + if ( (ai_state == AIState::Dying) || (ai_state == AIState::Stunned) || (ai_state == AIState::AttackingMelee) || + (ai_state == AIState::AttackingRanged1) || (ai_state == AIState::AttackingRanged2) || + (ai_state == AIState::AttackingRanged3) || (ai_state == AIState::AttackingRanged4) || (ai_state ==AIState::Summoned)) { curr_actor->uCurrentActionTime += pEventTimer->uTimeElapsed; if ( curr_actor->uCurrentActionTime < curr_actor->uCurrentActionLength ) @@ -540,7 +507,7 @@ } else if ( ai_state == 4 )// Dying { - curr_actor->uAIState = Dead; + curr_actor->uAIState = AIState::Dead; curr_actor->uCurrentActionTime = 0; curr_actor->uCurrentActionLength = 0; curr_actor->UpdateAnimation(); @@ -567,11 +534,11 @@ { monster=PID_ID(pQueue[i].uPackedID); monster_ai_state=pActors[monster].uAIState; - if ((monster_ai_state != Dead) && - (monster_ai_state != Dying) && - (monster_ai_state != Removed) && - (monster_ai_state != Summoned) && - (monster_ai_state != Disabled)) + if ((monster_ai_state != AIState::Dead) && + (monster_ai_state != AIState::Dying) && + (monster_ai_state != AIState::Removed) && + (monster_ai_state != AIState::Summoned) && + (monster_ai_state != AIState::Disabled)) { pQueue[i].uActionLength = 0; Actor::AI_StandOrBored(monster, ai_near_actors_targets_pid[monster], 32, nullptr); @@ -584,93 +551,54 @@ uActionPointsLeft = 130; } -//----- (004063A1) -------------------------------------------------------- -int stru262_TurnBased::_4063A1() - { - stru262_TurnBased *v1; // esi@1 - int v2; // ebp@1 - signed int result; // eax@1 - int v4; // edx@1 - int v5; // edx@3 - int v6; // edi@4 - int v7; // ecx@5 - Actor *v8; // ecx@11 - unsigned __int16 v9; // dx@12 - int v10; // edi@16 - int v11; // edx@17 - char v12; // zf@18 + //----- (004063A1) -------------------------------------------------------- + int stru262_TurnBased::_4063A1() + { + int v9; // dx@12 + int j; - v1 = this; - SortTurnQueue(); - v2 = (int)&v1->pQueue[0].field_4; - result = 1; - viewparams->bRedrawGameUI = 1; - v4 = v1->pQueue[0].field_4; - if ( v4 ) - { - if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - { - v5 = v1->uActorQueueSize; - while ( 1 ) - { - v6 = 0; - if ( v5 > 0 ) - { - v7 = (int)&v1->pQueue[0].field_4; - do - { - --*(int *)v7; - v5 = v1->uActorQueueSize; - ++v6; - v7 += 16; - } - while ( v6 < v5 ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - break; - if ( !*(int *)v2 ) - goto LABEL_9; - } -LABEL_24: - result = 1; - } - else - { - v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; - if ( v4 > 0 ) - { - do - { - v9 = v8->uAIState; - if (( v9 == 5 )|| ( v9 == 4 || v9 == 19 || v9 == 11 )) - break; - v10 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v11 = (int)&v1->pQueue[0].field_4; - do - { - v12 = (*(int *)v11)-- == 1; - if ( v12 ) - *(int *)(v11 + 4) = 0; - ++v10; - v11 += 16; - } - while ( v10 < v1->uActorQueueSize ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - goto LABEL_24; - } - while ( *(int *)v2 > 0 ); - } -LABEL_9: - result = 0; - } - } - return result; - } + SortTurnQueue(); + viewparams->bRedrawGameUI = 1; + if ( pQueue[0].field_4 ) + { + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + { + do + { + for (j=0; j 0); + } + else + { + v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState; + if (!(v9 == AIState::Dying || v9 == AIState::Dead || + v9 == AIState::Disabled || v9 == AIState::Removed)) + { + do + { + for (j=0; j 0); + } + } + } + return 0; + } //----- (00406457) -------------------------------------------------------- void stru262_TurnBased::_406457( int a2 ) @@ -738,9 +666,9 @@ break; monster=&pActors[PID_ID(pQueue[i].uPackedID)]; monster_ai_state=monster->uAIState; - if (monster_ai_state == Standing || - monster_ai_state == Fleeing || - monster_ai_state == Fidgeting) + if (monster_ai_state == AIState::Standing || + monster_ai_state == AIState::Fleeing || + monster_ai_state == AIState::Fidgeting) { pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; if (monster->pActorBuffs[7].uExpireTime > 0) @@ -777,11 +705,11 @@ } for (i=0; iuPackedID; if (PID_TYPE(v1->uPackedID) != OBJECT_Player) @@ -822,65 +750,60 @@ memcpy(&a4, &a3, sizeof(a4)); v5 = &pActors[PID_ID(v3)]; LOWORD(v3) = v5->uAIState; - if ( (short)v3 != Dead ) - { - if ( (short)v3 != Disabled ) - { - if ( (short)v3 != Removed ) + if (( (short)v3 != AIState::Dead )&& ( (short)v3 != AIState::Disabled )&&( (short)v3 != AIState::Removed )) { - v6 = v5->uCurrentActionLength; v5->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime >= v6 ) + if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength ) { v7 = (signed __int16)v3; v8 = (signed __int16)v3 - 2; if ( !v8 ) { v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); - stru_50FE08.Add( - v28->uPackedID, - 5120, - v5->vPosition.x, - v5->vPosition.y, + stru_50FE08.Add( v28->uPackedID, 5120, + v5->vPosition.x, v5->vPosition.y, v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), - v19, - 1); - goto LABEL_25; + v19, 1); + Actor::AI_Stand(v4, a2a, 0,&a4); + return; } v9 = v8 - 1; if ( v9 ) { v10 = v9 - 1; if ( !v10 ) - goto LABEL_21; + { + v5->uCurrentActionTime = 0; + v5->uCurrentActionLength = 0; + v5->uAIState = Dead; + pActors[v4].UpdateAnimation(); + return; + } v11 = v10 - 4; if ( !v11 ) - goto LABEL_25; + { + Actor::AI_Stand(v4, a2a, 0,&a4); + return; + } v12 = v11 - 4; if ( v12 ) { v13 = v12 - 1; if ( v13 ) { - if ( v13 != Dead ) + if ( v13 != 5 ) { if ( v7 != 4 ) { v14 = rand(); - v15 = v4; - v23 = &a4; - v16 = a2a; if ( !(v14 % 2) ) { Actor::AI_Bored(v4, a2a, &a4); return; } - v21 = 64; -LABEL_26: - Actor::AI_Stand(v15, v16, v21, v23); + Actor::AI_Stand(v4, a2a, 64,&a4); return; } -LABEL_21: v5->uCurrentActionTime = 0; v5->uCurrentActionLength = 0; v5->uAIState = Dead; @@ -898,12 +821,8 @@ v17 = v5->pMonsterInfo.uSpell1ID; } Actor::AI_SpellAttack(v4, &a4, v17, v22, v24); -LABEL_25: - v16 = a2a; - v23 = &a4; - v21 = 0; - v15 = v4; - goto LABEL_26; + Actor::AI_Stand(v4, a2a, 0, &a4); + return; } v18 = v5->pMonsterInfo.uMissleAttack2Type; v25 = 1; @@ -914,18 +833,19 @@ v25 = 0; } Actor::AI_RangedAttack(v4, &a4, v18, v25); - goto LABEL_25; + Actor::AI_Stand(v4, a2a, 0,&a4); + return; } } - } - } + } + } // 50FE08: using guessed type stru298 stru_50FE08; //----- (0040680F) -------------------------------------------------------- -__int16 stru262_TurnBased::_40680F(int a2) - { +void stru262_TurnBased::_40680F( int a2 ) + { TurnBased_QueueElem *v2; // eax@1 unsigned int v3; // eax@1 unsigned int v4; // edi@2 @@ -1060,7 +980,7 @@ LABEL_48: v21->uActionLength = v5->uCurrentActionLength; //return (signed __int16)v3; - return (signed __int16)&v21; + return; } } LABEL_44: @@ -1079,7 +999,6 @@ } } } - return (signed __int16)v3; } //----- (00406A63) -------------------------------------------------------- @@ -1132,84 +1051,50 @@ } //----- (00406B9F) -------------------------------------------------------- -int stru262_TurnBased::_406B9F() +void stru262_TurnBased::_406B9F() { - signed int result; // eax@1 - unsigned __int8 v2; // zf@1 - unsigned __int8 v3; // sf@1 - int v4; // esi@4 unsigned int v5; // esi@5 Actor *v6; // ebx@5 - unsigned __int16 v7; // cx@15 AIDirection a3; // [sp+0h] [bp-50h]@15 AIDirection v9; // [sp+1Ch] [bp-34h]@15 - signed int a1; // [sp+38h] [bp-18h]@4 - stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1 unsigned int v12; // [sp+40h] [bp-10h]@5 unsigned int v13; // [sp+44h] [bp-Ch]@8 - TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 - signed int a2; // [sp+4Ch] [bp-4h]@1 + int i; - result = 0; - thisa = this; - v2 = this->uActorQueueSize == 0; - v3 = this->uActorQueueSize < 0; - a2 = 0; - if ( !(v3 | v2) ) + for (i=0; ipQueue; - while ( 1 ) + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) { - v4 = v14->uPackedID; - a1 = v14->uPackedID; - if (PID_TYPE(a1) != OBJECT_Player) + v6 = &pActors[PID_ID(pQueue[i].uPackedID)]; + if ( !(v6->pActorBuffs[5].uExpireTime > 0|| (v6->pActorBuffs[6].uExpireTime > 0) || + v6->uAIState == AIState::Dead || v6->uAIState == AIState::Removed || v6->uAIState == AIState::Disabled) ) { - v5 = PID_ID(v4); - v12 = v5; - v6 = &pActors[v5]; - if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result - || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result ) - v13 = result; - else - v13 = 1; - if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result - && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) - result = 1; - if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) ) + v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; + memcpy(&v9, Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &a3, 0), sizeof(AIDirection)); + if ( v6->uAIState == AIState::Pursuing || v6->uAIState == AIState::Tethered ) { - v13 = ai_near_actors_targets_pid[v5]; - memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); - v7 = v6->uAIState; - if ( v7 == 6 || v7 == 1 ) + if ( (double)(signed int)v9.uDistance < 307.2 ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); + } + else + { + v6->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( v6->uCurrentActionTime > v6->uCurrentActionLength ) { - if ( (double)(signed int)v9.uDistance < 307.2 ) - goto LABEL_26; - } - v6->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength ) - { - if ( v7 == 4 ) + if ( v6->uAIState == AIState::Dying ) { v6->uCurrentActionTime = 0; v6->uCurrentActionLength = 0; - v6->uAIState = Dead; + v6->uAIState = AIState::Dead; v6->UpdateAnimation(); } - if ( !thisa->ActorTurn(a2) ) -LABEL_26: - Actor::AI_Stand(v12, v13, 32, &v9); + if ( !ActorTurn(i) ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); } } } - ++a2; - result = (signed int)thisa; - ++v14; - if ( a2 >= thisa->uActorQueueSize ) - break; - result = 0; } } - return result; } //----- (00406D10) -------------------------------------------------------- diff -r 67e47fc3133d -r bdf0cc8620ad TurnEngine.h --- a/TurnEngine.h Sat Jul 06 23:00:24 2013 +0400 +++ b/TurnEngine.h Mon Jul 08 01:04:42 2013 +0400 @@ -55,11 +55,11 @@ void _406457(int a2); void _40652A(); void _4065B0(); - void _406648(unsigned int a2); - __int16 _40680F(int a2); + void AIRangedAttacks(unsigned int queue_index); + void _40680F(int a2); void _406A63(); void _406AFE(); - int _406B9F(); + void _406B9F(); bool ActorTurn(signed int a2); void _406FA8();