comparison TurnEngine.cpp @ 1342:bdf0cc8620ad

TE continue
author Gloval
date Mon, 08 Jul 2013 01:04:42 +0400
parents 67e47fc3133d
children f0b95fb02b83
comparison
equal deleted inserted replaced
1341:67e47fc3133d 1342:bdf0cc8620ad
58 } 58 }
59 } 59 }
60 //sort 60 //sort
61 if (uActorQueueSize>0) 61 if (uActorQueueSize>0)
62 { 62 {
63
64 for( i=0; i<uActorQueueSize-1; ++i) 63 for( i=0; i<uActorQueueSize-1; ++i)
65 { 64 {
66 v7=&pQueue[i]; 65 v7=&pQueue[i];
67 for(j=i+1; j<uActorQueueSize;++j ) 66 for(j=i+1; j<uActorQueueSize;++j )
68 { 67 {
81 memcpy(v8, &temp_elem, sizeof(TurnBased_QueueElem)); 80 memcpy(v8, &temp_elem, sizeof(TurnBased_QueueElem));
82 } 81 }
83 } 82 }
84 } 83 }
85 } 84 }
86
87 uActorQueueSize = active_actors; 85 uActorQueueSize = active_actors;
88
89 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) 86 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
90 { 87 {
91 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; 88 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1;
92 field_18 |= TE_PLAYER_TURN; 89 field_18 |= TE_PLAYER_TURN;
93 } 90 }
94 else 91 else
95 { 92 {
96 uActiveCharacter = 0; 93 uActiveCharacter = 0;
97 field_18 &= ~TE_PLAYER_TURN; 94 field_18 &= ~TE_PLAYER_TURN;
98 } 95 }
99
100 for(i=0; i<uActorQueueSize; ++i) 96 for(i=0; i<uActorQueueSize; ++i)
101 { 97 {
102 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) 98 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
103 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); 99 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875);
104 } 100 }
117 } 113 }
118 114
119 //----- (004059DB) -------------------------------------------------------- 115 //----- (004059DB) --------------------------------------------------------
120 void stru262_TurnBased::Start() 116 void stru262_TurnBased::Start()
121 { 117 {
122 //stru262_TurnBased *v1; // ebx@1 118
123 int v3; // esi@1 119 int v3; // esi@1
124 int v4; // eax@5
125 unsigned int actor_id; // esi@7 120 unsigned int actor_id; // esi@7
126 Actor *pActor; // edi@7 121 Actor *pActor; // edi@7
127 unsigned int v7; // eax@9
128 unsigned int v8; // edx@10 122 unsigned int v8; // edx@10
129 //unsigned __int8 v9; // zf@14 123 signed int v16; // qax@19
130 //unsigned __int8 v10; // sf@14
131 //unsigned __int8 v11; // of@14
132 //char *v12; // esi@15
133 //int v13; // ecx@16
134 //unsigned __int16 v14; // ax@17
135 int v15; // ecx@18
136 signed __int64 v16; // qax@19
137 int v17; // edx@22 124 int v17; // edx@22
138 unsigned int v18; // esi@27
139 char *v19; // esi@32
140 int v20; // edx@33
141 char *v21; // eax@33
142 int v22; // ecx@33
143 int v23; // eax@34
144 char *v24; // eax@34
145 char *v25; // ecx@34
146 int v26; // edx@34
147 int v27; // eax@38
148 int v28; // ecx@38
149 AIDirection v30; // [sp+Ch] [bp-68h]@10 125 AIDirection v30; // [sp+Ch] [bp-68h]@10
150 AIDirection v31; // [sp+28h] [bp-4Ch]@10 126 AIDirection v31; // [sp+28h] [bp-4Ch]@10
151 AIDirection a3; // [sp+44h] [bp-30h]@10 127 AIDirection a3; // [sp+44h] [bp-30h]@10
152 //int v33; // [sp+60h] [bp-14h]@10
153 int *v34; // [sp+64h] [bp-10h]@6
154 int v35; // [sp+68h] [bp-Ch]@5
155 Player *pPlayer; // [sp+6Ch] [bp-8h]@1 128 Player *pPlayer; // [sp+6Ch] [bp-8h]@1
156 int v40b; 129 int v40b;
157 unsigned int v37; // [sp+70h] [bp-4h]@7
158 int activ_players[4]; 130 int activ_players[4];
159 int players_recovery_time[4]; 131 int players_recovery_time[4];
160 int a_players_count; 132 int a_players_count;
161 int i,j; 133 int i,j;
162 int temp; 134 int temp;
163 135
164
165 pTurnEngine->field_18 &= ~TE_FLAG_2; 136 pTurnEngine->field_18 &= ~TE_FLAG_2;
166 //v1 = this;
167 pEventTimer->TrackGameTime(); 137 pEventTimer->TrackGameTime();
168 pAudioPlayer->StopChannels(-1, -1); 138 pAudioPlayer->StopChannels(-1, -1);
169 pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); 139 pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0);
170 pPlayer = pParty->pPlayers; 140 pPlayer = pParty->pPlayers;
171 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; 141 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
242 this->pQueue[v40b].field_4 = 666; 212 this->pQueue[v40b].field_4 = 666;
243 } 213 }
244 this->pQueue[v40b].field_4 += 16; 214 this->pQueue[v40b].field_4 += 16;
245 } 215 }
246 216
247
248 if ( a_players_count > 0 ) 217 if ( a_players_count > 0 )
249 { 218 {
250 for (i=0; i<a_players_count; ++i) 219 for (i=0; i<a_players_count; ++i)
251 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); 220 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0);
252 //sort players by recovery time 221 //sort players by recovery time
360 target_pid = ai_near_actors_targets_pid[i]; 329 target_pid = ai_near_actors_targets_pid[i];
361 v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &a3, 0); 330 v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &a3, 0);
362 memcpy(&v15, v6, sizeof(AIDirection)); 331 memcpy(&v15, v6, sizeof(AIDirection));
363 memcpy(&v14, &v15, sizeof(AIDirection)); 332 memcpy(&v14, &v15, sizeof(AIDirection));
364 v7 = curr_actor->uAIState; 333 v7 = curr_actor->uAIState;
365 if(v7==Dying) 334 if(v7==AIState::Dying)
366 { 335 {
367 curr_actor->uCurrentActionTime = 0; 336 curr_actor->uCurrentActionTime = 0;
368 curr_actor->uCurrentActionLength = 0; 337 curr_actor->uCurrentActionLength = 0;
369 curr_actor->uAIState = Dead; 338 curr_actor->uAIState = Dead;
370 curr_actor->UpdateAnimation(); 339 curr_actor->UpdateAnimation();
371 } 340 }
372 else if ( (v7 > Removed)&&(v7 < Disabled)) 341 else if ( (v7 > AIState::Removed)&&(v7 < AIState::Disabled))
373 { 342 {
374 Actor::AI_StandOrBored(i, target_pid, 32, &v14); 343 Actor::AI_StandOrBored(i, target_pid, 32, &v14);
375 } 344 }
376 } 345 }
377 } 346 }
391 { 360 {
392 _406AFE(); 361 _406AFE();
393 field_10 = 100; 362 field_10 = 100;
394 } 363 }
395 field_8 -= pEventTimer->uTimeElapsed; 364 field_8 -= pEventTimer->uTimeElapsed;
396
397 } 365 }
398 else if ( turn_stage == 2 ) 366 else if ( turn_stage == 2 )
399 { 367 {
400 if ( !(field_18 & TE_FLAG_1) ) 368 if ( !(field_18 & TE_FLAG_1) )
401 { 369 {
410 _40652A(); 378 _40652A();
411 } 379 }
412 } 380 }
413 else 381 else
414 NextTurn(); 382 NextTurn();
415
416 } 383 }
417 else if ( turn_stage == 3 ) 384 else if ( turn_stage == 3 )
418 { 385 {
419 if ( uActionPointsLeft <= 0 || field_18 & TE_FLAG_8 ) 386 if ( uActionPointsLeft <= 0 || field_18 & TE_FLAG_8 )
420 { 387 {
527 { 494 {
528 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) 495 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
529 { 496 {
530 curr_actor = &pActors[PID_ID(pQueue[i].uPackedID)]; 497 curr_actor = &pActors[PID_ID(pQueue[i].uPackedID)];
531 ai_state = curr_actor->uAIState; 498 ai_state = curr_actor->uAIState;
532 if ( (ai_state == Dying) || (ai_state == Stunned) || (ai_state == AttackingMelee) || 499 if ( (ai_state == AIState::Dying) || (ai_state == AIState::Stunned) || (ai_state == AIState::AttackingMelee) ||
533 (ai_state == AttackingRanged1) || (ai_state == AttackingRanged2) || 500 (ai_state == AIState::AttackingRanged1) || (ai_state == AIState::AttackingRanged2) ||
534 (ai_state == AttackingRanged3) || (ai_state == AttackingRanged4) || (ai_state ==Summoned)) 501 (ai_state == AIState::AttackingRanged3) || (ai_state == AIState::AttackingRanged4) || (ai_state ==AIState::Summoned))
535 { 502 {
536 curr_actor->uCurrentActionTime += pEventTimer->uTimeElapsed; 503 curr_actor->uCurrentActionTime += pEventTimer->uTimeElapsed;
537 if ( curr_actor->uCurrentActionTime < curr_actor->uCurrentActionLength ) 504 if ( curr_actor->uCurrentActionTime < curr_actor->uCurrentActionLength )
538 { 505 {
539 v13 = 1; 506 v13 = 1;
540 } 507 }
541 else if ( ai_state == 4 )// Dying 508 else if ( ai_state == 4 )// Dying
542 { 509 {
543 curr_actor->uAIState = Dead; 510 curr_actor->uAIState = AIState::Dead;
544 curr_actor->uCurrentActionTime = 0; 511 curr_actor->uCurrentActionTime = 0;
545 curr_actor->uCurrentActionLength = 0; 512 curr_actor->uCurrentActionLength = 0;
546 curr_actor->UpdateAnimation(); 513 curr_actor->UpdateAnimation();
547 } 514 }
548 else 515 else
565 { 532 {
566 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) 533 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
567 { 534 {
568 monster=PID_ID(pQueue[i].uPackedID); 535 monster=PID_ID(pQueue[i].uPackedID);
569 monster_ai_state=pActors[monster].uAIState; 536 monster_ai_state=pActors[monster].uAIState;
570 if ((monster_ai_state != Dead) && 537 if ((monster_ai_state != AIState::Dead) &&
571 (monster_ai_state != Dying) && 538 (monster_ai_state != AIState::Dying) &&
572 (monster_ai_state != Removed) && 539 (monster_ai_state != AIState::Removed) &&
573 (monster_ai_state != Summoned) && 540 (monster_ai_state != AIState::Summoned) &&
574 (monster_ai_state != Disabled)) 541 (monster_ai_state != AIState::Disabled))
575 { 542 {
576 pQueue[i].uActionLength = 0; 543 pQueue[i].uActionLength = 0;
577 Actor::AI_StandOrBored(monster, ai_near_actors_targets_pid[monster], 32, nullptr); 544 Actor::AI_StandOrBored(monster, ai_near_actors_targets_pid[monster], 32, nullptr);
578 } 545 }
579 } 546 }
582 pParty->uTimePlayed += 213i64; 549 pParty->uTimePlayed += 213i64;
583 _494035_timed_effects__water_walking_damage__etc(); 550 _494035_timed_effects__water_walking_damage__etc();
584 uActionPointsLeft = 130; 551 uActionPointsLeft = 130;
585 } 552 }
586 553
587 //----- (004063A1) -------------------------------------------------------- 554 //----- (004063A1) --------------------------------------------------------
588 int stru262_TurnBased::_4063A1() 555 int stru262_TurnBased::_4063A1()
589 { 556 {
590 stru262_TurnBased *v1; // esi@1 557 int v9; // dx@12
591 int v2; // ebp@1 558 int j;
592 signed int result; // eax@1 559
593 int v4; // edx@1 560 SortTurnQueue();
594 int v5; // edx@3 561 viewparams->bRedrawGameUI = 1;
595 int v6; // edi@4 562 if ( pQueue[0].field_4 )
596 int v7; // ecx@5 563 {
597 Actor *v8; // ecx@11 564 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
598 unsigned __int16 v9; // dx@12 565 {
599 int v10; // edi@16 566 do
600 int v11; // edx@17 567 {
601 char v12; // zf@18 568 for (j=0; j<uActorQueueSize; ++j )
602 569 {
603 v1 = this; 570 --pQueue[j].field_4;
604 SortTurnQueue(); 571 }
605 v2 = (int)&v1->pQueue[0].field_4; 572 --field_10;
606 result = 1; 573 if (field_10 == 0)
607 viewparams->bRedrawGameUI = 1; 574 return 1;
608 v4 = v1->pQueue[0].field_4; 575 }
609 if ( v4 ) 576 while (pQueue[0].field_4 > 0);
610 { 577 }
611 if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) 578 else
612 { 579 {
613 v5 = v1->uActorQueueSize; 580 v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState;
614 while ( 1 ) 581 if (!(v9 == AIState::Dying || v9 == AIState::Dead ||
615 { 582 v9 == AIState::Disabled || v9 == AIState::Removed))
616 v6 = 0; 583 {
617 if ( v5 > 0 ) 584 do
618 { 585 {
619 v7 = (int)&v1->pQueue[0].field_4; 586 for (j=0; j<uActorQueueSize; ++j )
620 do 587 {
621 { 588 --pQueue[j].field_4;
622 --*(int *)v7; 589 if (pQueue[j].field_4 == 1)
623 v5 = v1->uActorQueueSize; 590 pQueue[j].uActionLength = 0;
624 ++v6; 591 }
625 v7 += 16; 592 --field_10;
626 } 593 if (field_10 == 0)
627 while ( v6 < v5 ); 594 return 1;
628 } 595 }
629 --v1->field_10; 596 while (pQueue[0].field_4 > 0);
630 if ( v1->field_10 <= 0 ) 597 }
631 break; 598 }
632 if ( !*(int *)v2 ) 599 }
633 goto LABEL_9; 600 return 0;
634 } 601 }
635 LABEL_24:
636 result = 1;
637 }
638 else
639 {
640 v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)];
641 if ( v4 > 0 )
642 {
643 do
644 {
645 v9 = v8->uAIState;
646 if (( v9 == 5 )|| ( v9 == 4 || v9 == 19 || v9 == 11 ))
647 break;
648 v10 = 0;
649 if ( v1->uActorQueueSize > 0 )
650 {
651 v11 = (int)&v1->pQueue[0].field_4;
652 do
653 {
654 v12 = (*(int *)v11)-- == 1;
655 if ( v12 )
656 *(int *)(v11 + 4) = 0;
657 ++v10;
658 v11 += 16;
659 }
660 while ( v10 < v1->uActorQueueSize );
661 }
662 --v1->field_10;
663 if ( v1->field_10 <= 0 )
664 goto LABEL_24;
665 }
666 while ( *(int *)v2 > 0 );
667 }
668 LABEL_9:
669 result = 0;
670 }
671 }
672 return result;
673 }
674 602
675 //----- (00406457) -------------------------------------------------------- 603 //----- (00406457) --------------------------------------------------------
676 void stru262_TurnBased::_406457( int a2 ) 604 void stru262_TurnBased::_406457( int a2 )
677 { 605 {
678 stru262_TurnBased *v2; // esi@1 606 stru262_TurnBased *v2; // esi@1
736 { 664 {
737 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) 665 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
738 break; 666 break;
739 monster=&pActors[PID_ID(pQueue[i].uPackedID)]; 667 monster=&pActors[PID_ID(pQueue[i].uPackedID)];
740 monster_ai_state=monster->uAIState; 668 monster_ai_state=monster->uAIState;
741 if (monster_ai_state == Standing || 669 if (monster_ai_state == AIState::Standing ||
742 monster_ai_state == Fleeing || 670 monster_ai_state == AIState::Fleeing ||
743 monster_ai_state == Fidgeting) 671 monster_ai_state == AIState::Fidgeting)
744 { 672 {
745 pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; 673 pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime;
746 if (monster->pActorBuffs[7].uExpireTime > 0) 674 if (monster->pActorBuffs[7].uExpireTime > 0)
747 pQueue[i].field_4*=2; 675 pQueue[i].field_4*=2;
748 } 676 }
775 uActiveCharacter = 0; 703 uActiveCharacter = 0;
776 viewparams->bRedrawGameUI = 1; 704 viewparams->bRedrawGameUI = 1;
777 } 705 }
778 706
779 for (i=0; i<uActorQueueSize; ++i ) 707 for (i=0; i<uActorQueueSize; ++i )
780 _406648(i); 708 AIRangedAttacks(i);
781 } 709 }
782 710
783 //----- (00406648) -------------------------------------------------------- 711 //----- (00406648) --------------------------------------------------------
784 void stru262_TurnBased::_406648(unsigned int a2) 712 void stru262_TurnBased::AIRangedAttacks( unsigned int queue_index )
785 { 713 {
786 TurnBased_QueueElem *v1; // ecx@1 714 TurnBased_QueueElem *v1; // ecx@1
787 int v3; // eax@1 715 int v3; // eax@1
788 unsigned int v4; // ebx@2 716 unsigned int v4; // ebx@2
789 Actor *v5; // esi@2 717 Actor *v5; // esi@2
809 AIDirection a3; // [sp+Ch] [bp-3Ch]@2 737 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
810 AIDirection a4; // [sp+28h] [bp-20h]@2 738 AIDirection a4; // [sp+28h] [bp-20h]@2
811 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 739 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
812 unsigned int a2a; // [sp+50h] [bp+8h]@2 740 unsigned int a2a; // [sp+50h] [bp+8h]@2
813 741
814 v1 = &pQueue[a2]; 742 v1 = &pQueue[queue_index];
815 v28 = v1; 743 v28 = v1;
816 v3 = v1->uPackedID; 744 v3 = v1->uPackedID;
817 if (PID_TYPE(v1->uPackedID) != OBJECT_Player) 745 if (PID_TYPE(v1->uPackedID) != OBJECT_Player)
818 { 746 {
819 v4 = PID_ID(v3); 747 v4 = PID_ID(v3);
820 a2a = ai_near_actors_targets_pid[PID_ID(v3)]; 748 a2a = ai_near_actors_targets_pid[PID_ID(v3)];
821 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); 749 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3));
822 memcpy(&a4, &a3, sizeof(a4)); 750 memcpy(&a4, &a3, sizeof(a4));
823 v5 = &pActors[PID_ID(v3)]; 751 v5 = &pActors[PID_ID(v3)];
824 LOWORD(v3) = v5->uAIState; 752 LOWORD(v3) = v5->uAIState;
825 if ( (short)v3 != Dead ) 753 if (( (short)v3 != AIState::Dead )&& ( (short)v3 != AIState::Disabled )&&( (short)v3 != AIState::Removed ))
826 { 754 {
827 if ( (short)v3 != Disabled )
828 {
829 if ( (short)v3 != Removed )
830 {
831 v6 = v5->uCurrentActionLength;
832 v5->uCurrentActionTime += pEventTimer->uTimeElapsed; 755 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
833 if ( (signed int)v5->uCurrentActionTime >= v6 ) 756 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
834 { 757 {
835 v7 = (signed __int16)v3; 758 v7 = (signed __int16)v3;
836 v8 = (signed __int16)v3 - 2; 759 v8 = (signed __int16)v3 - 2;
837 if ( !v8 ) 760 if ( !v8 )
838 { 761 {
839 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); 762 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
840 stru_50FE08.Add( 763 stru_50FE08.Add( v28->uPackedID, 5120,
841 v28->uPackedID, 764 v5->vPosition.x, v5->vPosition.y,
842 5120,
843 v5->vPosition.x,
844 v5->vPosition.y,
845 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), 765 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
846 v19, 766 v19, 1);
847 1); 767 Actor::AI_Stand(v4, a2a, 0,&a4);
848 goto LABEL_25; 768 return;
849 } 769 }
850 v9 = v8 - 1; 770 v9 = v8 - 1;
851 if ( v9 ) 771 if ( v9 )
852 { 772 {
853 v10 = v9 - 1; 773 v10 = v9 - 1;
854 if ( !v10 ) 774 if ( !v10 )
855 goto LABEL_21; 775 {
776 v5->uCurrentActionTime = 0;
777 v5->uCurrentActionLength = 0;
778 v5->uAIState = Dead;
779 pActors[v4].UpdateAnimation();
780 return;
781 }
856 v11 = v10 - 4; 782 v11 = v10 - 4;
857 if ( !v11 ) 783 if ( !v11 )
858 goto LABEL_25; 784 {
785 Actor::AI_Stand(v4, a2a, 0,&a4);
786 return;
787 }
859 v12 = v11 - 4; 788 v12 = v11 - 4;
860 if ( v12 ) 789 if ( v12 )
861 { 790 {
862 v13 = v12 - 1; 791 v13 = v12 - 1;
863 if ( v13 ) 792 if ( v13 )
864 { 793 {
865 if ( v13 != Dead ) 794 if ( v13 != 5 )
866 { 795 {
867 if ( v7 != 4 ) 796 if ( v7 != 4 )
868 { 797 {
869 v14 = rand(); 798 v14 = rand();
870 v15 = v4;
871 v23 = &a4;
872 v16 = a2a;
873 if ( !(v14 % 2) ) 799 if ( !(v14 % 2) )
874 { 800 {
875 Actor::AI_Bored(v4, a2a, &a4); 801 Actor::AI_Bored(v4, a2a, &a4);
876 return; 802 return;
877 } 803 }
878 v21 = 64; 804 Actor::AI_Stand(v4, a2a, 64,&a4);
879 LABEL_26:
880 Actor::AI_Stand(v15, v16, v21, v23);
881 return; 805 return;
882 } 806 }
883 LABEL_21:
884 v5->uCurrentActionTime = 0; 807 v5->uCurrentActionTime = 0;
885 v5->uCurrentActionLength = 0; 808 v5->uCurrentActionLength = 0;
886 v5->uAIState = Dead; 809 v5->uAIState = Dead;
887 pActors[v4].UpdateAnimation(); 810 pActors[v4].UpdateAnimation();
888 return; 811 return;
896 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1; 819 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
897 v22 = 2; 820 v22 = 2;
898 v17 = v5->pMonsterInfo.uSpell1ID; 821 v17 = v5->pMonsterInfo.uSpell1ID;
899 } 822 }
900 Actor::AI_SpellAttack(v4, &a4, v17, v22, v24); 823 Actor::AI_SpellAttack(v4, &a4, v17, v22, v24);
901 LABEL_25: 824 Actor::AI_Stand(v4, a2a, 0, &a4);
902 v16 = a2a; 825 return;
903 v23 = &a4;
904 v21 = 0;
905 v15 = v4;
906 goto LABEL_26;
907 } 826 }
908 v18 = v5->pMonsterInfo.uMissleAttack2Type; 827 v18 = v5->pMonsterInfo.uMissleAttack2Type;
909 v25 = 1; 828 v25 = 1;
910 } 829 }
911 else 830 else
912 { 831 {
913 v18 = v5->pMonsterInfo.uMissleAttack1Type; 832 v18 = v5->pMonsterInfo.uMissleAttack1Type;
914 v25 = 0; 833 v25 = 0;
915 } 834 }
916 Actor::AI_RangedAttack(v4, &a4, v18, v25); 835 Actor::AI_RangedAttack(v4, &a4, v18, v25);
917 goto LABEL_25; 836 Actor::AI_Stand(v4, a2a, 0,&a4);
837 return;
918 } 838 }
919 } 839 }
920 } 840
921 } 841 }
922 } 842
923 } 843 }
924 // 50FE08: using guessed type stru298 stru_50FE08; 844 // 50FE08: using guessed type stru298 stru_50FE08;
925 845
926 //----- (0040680F) -------------------------------------------------------- 846 //----- (0040680F) --------------------------------------------------------
927 __int16 stru262_TurnBased::_40680F(int a2) 847 void stru262_TurnBased::_40680F( int a2 )
928 { 848 {
929 TurnBased_QueueElem *v2; // eax@1 849 TurnBased_QueueElem *v2; // eax@1
930 unsigned int v3; // eax@1 850 unsigned int v3; // eax@1
931 unsigned int v4; // edi@2 851 unsigned int v4; // edi@2
932 Actor *v5; // ebx@2 852 Actor *v5; // ebx@2
933 unsigned int *v6; // esi@7 853 unsigned int *v6; // esi@7
1058 //v3 = v21; 978 //v3 = v21;
1059 v21->field_C = 1; 979 v21->field_C = 1;
1060 LABEL_48: 980 LABEL_48:
1061 v21->uActionLength = v5->uCurrentActionLength; 981 v21->uActionLength = v5->uCurrentActionLength;
1062 //return (signed __int16)v3; 982 //return (signed __int16)v3;
1063 return (signed __int16)&v21; 983 return;
1064 } 984 }
1065 } 985 }
1066 LABEL_44: 986 LABEL_44:
1067 if ( (double)(signed int)v20 < 307.2 ) 987 if ( (double)(signed int)v20 < 307.2 )
1068 { 988 {
1077 v21->field_C = 0; 997 v21->field_C = 0;
1078 goto LABEL_48; 998 goto LABEL_48;
1079 } 999 }
1080 } 1000 }
1081 } 1001 }
1082 return (signed __int16)v3;
1083 } 1002 }
1084 1003
1085 //----- (00406A63) -------------------------------------------------------- 1004 //----- (00406A63) --------------------------------------------------------
1086 void stru262_TurnBased::_406A63() 1005 void stru262_TurnBased::_406A63()
1087 { 1006 {
1130 field_8 = 100; 1049 field_8 = 100;
1131 1050
1132 } 1051 }
1133 1052
1134 //----- (00406B9F) -------------------------------------------------------- 1053 //----- (00406B9F) --------------------------------------------------------
1135 int stru262_TurnBased::_406B9F() 1054 void stru262_TurnBased::_406B9F()
1136 { 1055 {
1137 signed int result; // eax@1
1138 unsigned __int8 v2; // zf@1
1139 unsigned __int8 v3; // sf@1
1140 int v4; // esi@4
1141 unsigned int v5; // esi@5 1056 unsigned int v5; // esi@5
1142 Actor *v6; // ebx@5 1057 Actor *v6; // ebx@5
1143 unsigned __int16 v7; // cx@15
1144 AIDirection a3; // [sp+0h] [bp-50h]@15 1058 AIDirection a3; // [sp+0h] [bp-50h]@15
1145 AIDirection v9; // [sp+1Ch] [bp-34h]@15 1059 AIDirection v9; // [sp+1Ch] [bp-34h]@15
1146 signed int a1; // [sp+38h] [bp-18h]@4
1147 stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
1148 unsigned int v12; // [sp+40h] [bp-10h]@5 1060 unsigned int v12; // [sp+40h] [bp-10h]@5
1149 unsigned int v13; // [sp+44h] [bp-Ch]@8 1061 unsigned int v13; // [sp+44h] [bp-Ch]@8
1150 TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 1062 int i;
1151 signed int a2; // [sp+4Ch] [bp-4h]@1 1063
1152 1064 for (i=0; i<uActorQueueSize; ++i )
1153 result = 0; 1065 {
1154 thisa = this; 1066 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
1155 v2 = this->uActorQueueSize == 0; 1067 {
1156 v3 = this->uActorQueueSize < 0; 1068 v6 = &pActors[PID_ID(pQueue[i].uPackedID)];
1157 a2 = 0; 1069 if ( !(v6->pActorBuffs[5].uExpireTime > 0|| (v6->pActorBuffs[6].uExpireTime > 0) ||
1158 if ( !(v3 | v2) ) 1070 v6->uAIState == AIState::Dead || v6->uAIState == AIState::Removed || v6->uAIState == AIState::Disabled) )
1159 { 1071 {
1160 v14 = this->pQueue; 1072 v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
1161 while ( 1 ) 1073 memcpy(&v9, Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &a3, 0), sizeof(AIDirection));
1162 { 1074 if ( v6->uAIState == AIState::Pursuing || v6->uAIState == AIState::Tethered )
1163 v4 = v14->uPackedID; 1075 {
1164 a1 = v14->uPackedID; 1076 if ( (double)(signed int)v9.uDistance < 307.2 )
1165 if (PID_TYPE(a1) != OBJECT_Player) 1077 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
1166 { 1078 }
1167 v5 = PID_ID(v4);
1168 v12 = v5;
1169 v6 = &pActors[v5];
1170 if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
1171 || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
1172 v13 = result;
1173 else 1079 else
1174 v13 = 1; 1080 {
1175 if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result 1081 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
1176 && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) 1082 if ( v6->uCurrentActionTime > v6->uCurrentActionLength )
1177 result = 1;
1178 if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) )
1179 {
1180 v13 = ai_near_actors_targets_pid[v5];
1181 memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
1182 v7 = v6->uAIState;
1183 if ( v7 == 6 || v7 == 1 )
1184 { 1083 {
1185 if ( (double)(signed int)v9.uDistance < 307.2 ) 1084 if ( v6->uAIState == AIState::Dying )
1186 goto LABEL_26;
1187 }
1188 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
1189 if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
1190 {
1191 if ( v7 == 4 )
1192 { 1085 {
1193 v6->uCurrentActionTime = 0; 1086 v6->uCurrentActionTime = 0;
1194 v6->uCurrentActionLength = 0; 1087 v6->uCurrentActionLength = 0;
1195 v6->uAIState = Dead; 1088 v6->uAIState = AIState::Dead;
1196 v6->UpdateAnimation(); 1089 v6->UpdateAnimation();
1197 } 1090 }
1198 if ( !thisa->ActorTurn(a2) ) 1091 if ( !ActorTurn(i) )
1199 LABEL_26: 1092 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
1200 Actor::AI_Stand(v12, v13, 32, &v9);
1201 } 1093 }
1202 } 1094 }
1203 } 1095 }
1204 ++a2; 1096 }
1205 result = (signed int)thisa; 1097 }
1206 ++v14;
1207 if ( a2 >= thisa->uActorQueueSize )
1208 break;
1209 result = 0;
1210 }
1211 }
1212 return result;
1213 } 1098 }
1214 1099
1215 //----- (00406D10) -------------------------------------------------------- 1100 //----- (00406D10) --------------------------------------------------------
1216 bool stru262_TurnBased::ActorTurn(signed int a2) 1101 bool stru262_TurnBased::ActorTurn(signed int a2)
1217 { 1102 {