Mercurial > mm7
comparison Actor.cpp @ 417:55684f4eda73
Actor::SelectTarget & ai_near_actors_targets_pid
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 19:31:56 +0200 |
parents | d8b3056df4e2 |
children | e5cf03a3d98e |
comparison
equal
deleted
inserted
replaced
414:d8b3056df4e2 | 417:55684f4eda73 |
---|---|
3053 } | 3053 } |
3054 | 3054 |
3055 //----- (00402F87) -------------------------------------------------------- | 3055 //----- (00402F87) -------------------------------------------------------- |
3056 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) | 3056 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) |
3057 { | 3057 { |
3058 //int v3; // edi@1 | |
3059 //AIDirection *v4; // esi@1 | |
3060 //Actor *v5; // ebx@1 | |
3061 //SpriteFrame *v6; // ecx@3 | |
3062 unsigned int v7; // eax@3 | 3058 unsigned int v7; // eax@3 |
3063 //int v8; // edx@3 | |
3064 unsigned int v9; // eax@3 | 3059 unsigned int v9; // eax@3 |
3065 //int result; // eax@4 | |
3066 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 | |
3067 //AIDirection v12; // [sp+28h] [bp-40h]@2 | |
3068 //AIDirection v13; // [sp+44h] [bp-24h]@2 | |
3069 //unsigned int v14; // [sp+60h] [bp-8h]@1 | |
3070 //unsigned int v15; // [sp+64h] [bp-4h]@1 | |
3071 | 3060 |
3072 assert(uActorID < uNumActors); | 3061 assert(uActorID < uNumActors); |
3073 auto actor = pActors + uActorID; | 3062 auto actor = pActors + uActorID; |
3074 | 3063 |
3075 //v3 = uActorID; | 3064 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 |
3076 //v4 = a4; | |
3077 //v5 = &pActors[uActorID]; | |
3078 //v14 = uObjID; | |
3079 //v15 = uActorID; | |
3080 if (!a4) | 3065 if (!a4) |
3081 a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); | 3066 a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); |
3082 /*{ | 3067 |
3083 memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); | |
3084 memcpy(&v12, &v13, sizeof(v12)); | |
3085 v3 = v15; | |
3086 v4 = &v12; | |
3087 }*/ | |
3088 | |
3089 //v6 = pSpriteFrameTable->pSpriteSFrames; | |
3090 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; | 3068 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; |
3091 | 3069 |
3092 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); | 3070 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); |
3093 //LOWORD(v8) = actor->uYawAngle; | |
3094 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; | 3071 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; |
3095 | 3072 |
3096 if ( BYTE1(v9) & 7 ) // turned away - just stand | 3073 if ( BYTE1(v9) & 7 ) // turned away - just stand |
3097 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); | 3074 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); |
3098 else // facing player - play bored anim | 3075 else // facing player - play bored anim |
3570 if ( rand() % 100 < 2 ) | 3547 if ( rand() % 100 < 2 ) |
3571 Actor::PlaySound(v4, 2u); | 3548 Actor::PlaySound(v4, 2u); |
3572 v6->UpdateAnimation(); | 3549 v6->UpdateAnimation(); |
3573 } | 3550 } |
3574 | 3551 |
3575 //----- (00401221) -------------------------------------------------------- | 3552 //----- (00SelectTarget) -------------------------------------------------------- |
3576 void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) | 3553 void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) |
3577 { | 3554 { |
3578 Actor *v3; // esi@1 | 3555 //Actor *v3; // esi@1 |
3579 unsigned int v4; // ebx@1 | 3556 //unsigned int v4; // ebx@1 |
3580 int v5; // ecx@1 | 3557 int v5; // ecx@1 |
3581 unsigned int v6; // eax@1 | 3558 //unsigned int v6; // eax@1 |
3582 Actor *v7; // edi@2 | 3559 //Actor *v7; // edi@2 |
3583 __int16 v8; // ax@3 | 3560 //__int16 v8; // ax@3 |
3584 int v9; // eax@10 | 3561 int v9; // eax@10 |
3585 signed int v10; // eax@13 | 3562 signed int v10; // eax@13 |
3586 int v11; // ebx@16 | 3563 int v11; // ebx@16 |
3587 int v12; // eax@16 | 3564 int v12; // eax@16 |
3588 int v13; // eax@25 | 3565 //int v13; // eax@25 |
3589 signed int v14; // eax@31 | 3566 signed int v14; // eax@31 |
3590 int v15; // edi@43 | 3567 int v15; // edi@43 |
3591 int v16; // ebx@45 | 3568 int v16; // ebx@45 |
3592 int v17; // eax@45 | 3569 int v17; // eax@45 |
3593 int v18; // eax@51 | 3570 //int v18; // eax@51 |
3594 int v19; // [sp+Ch] [bp-24h]@16 | 3571 int v19; // [sp+Ch] [bp-24h]@16 |
3595 int *v20; // [sp+10h] [bp-20h]@1 | 3572 //int *v20; // [sp+10h] [bp-20h]@1 |
3596 signed int v21; // [sp+14h] [bp-1Ch]@1 | 3573 signed int v21; // [sp+14h] [bp-1Ch]@1 |
3597 unsigned int v22; // [sp+18h] [bp-18h]@1 | 3574 //unsigned int v22; // [sp+18h] [bp-18h]@1 |
3598 int v23; // [sp+1Ch] [bp-14h]@16 | 3575 int v23; // [sp+1Ch] [bp-14h]@16 |
3599 unsigned int v24; // [sp+20h] [bp-10h]@1 | 3576 //unsigned int v24; // [sp+20h] [bp-10h]@1 |
3600 int v25; // [sp+24h] [bp-Ch]@1 | 3577 int v25; // [sp+24h] [bp-Ch]@1 |
3601 signed int v26; // [sp+28h] [bp-8h]@1 | 3578 //signed int v26; // [sp+28h] [bp-8h]@1 |
3602 int v27; // [sp+2Ch] [bp-4h]@16 | 3579 int v27; // [sp+2Ch] [bp-4h]@16 |
3603 int v28; // [sp+2Ch] [bp-4h]@45 | 3580 int v28; // [sp+2Ch] [bp-4h]@45 |
3604 | 3581 |
3605 v25 = -1; | 3582 v25 = -1; |
3606 v22 = uActorID; | 3583 //v22 = uActorID; |
3607 v3 = &pActors[uActorID]; | 3584 //v3 = &pActors[uActorID]; |
3608 v4 = 0; | 3585 //v4 = 0; |
3609 v5 = 0; | 3586 v5 = 0; |
3610 v6 = v3->uLastCharacterIDToHit; | 3587 //v6 = v3->uLastCharacterIDToHit; |
3611 *a2 = 0; | 3588 *a2 = 0; |
3612 v20 = a2; | 3589 //v20 = a2; |
3613 v21 = 0; | 3590 v21 = 0; |
3614 v24 = v6; | 3591 //v24 = v3->uLastCharacterIDToHit; |
3615 v26 = 0; | 3592 //v26 = 0; |
3616 if ( (signed int)uNumActors > 0 ) | 3593 assert(uActorID < uNumActors); |
3617 { | 3594 auto _this = pActors + uActorID; |
3618 v7 = pActors; | 3595 |
3619 do | 3596 for (uint i = 0; i < uNumActors; ++i) |
3620 { | 3597 { |
3621 v8 = v7->uAIState; | 3598 auto actor = pActors + i; |
3622 if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) | 3599 //v7 = pActors; |
3600 //do | |
3601 //{ | |
3602 //v8 = v7->uAIState; | |
3603 if (actor->uAIState == Dead || actor->uAIState == Dying || | |
3604 actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) | |
3605 continue; | |
3606 | |
3607 if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, _this->uLastCharacterIDToHit != v9) ) | |
3623 { | 3608 { |
3624 ++v7; | 3609 v10 = _this->GetActorsRelation(actor); |
3625 v5 = v26++ + 1; | 3610 if ( v10 == 0 ) |
3626 continue; | 3611 continue; |
3627 } | 3612 } |
3628 if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) | 3613 else if (_this->IsNotAlive()) |
3629 { | 3614 { |
3630 v10 = v3->GetActorsRelation(v7); | 3615 _this->uLastCharacterIDToHit = 0; |
3631 if ( v10 == v4 ) | 3616 v10 = _this->GetActorsRelation(actor); |
3632 { | 3617 if ( v10 == 0 ) |
3633 ++v7; | |
3634 v5 = v26++ + 1; | |
3635 continue; | 3618 continue; |
3636 } | |
3637 } | |
3638 else if (v7->IsNotAlive()) | |
3639 { | |
3640 v24 = v4; | |
3641 v3->uLastCharacterIDToHit = v4; | |
3642 v10 = v3->GetActorsRelation(v7); | |
3643 if ( v10 == v4 ) | |
3644 { | |
3645 ++v7; | |
3646 v5 = v26++ + 1; | |
3647 continue; | |
3648 } | |
3649 } | 3619 } |
3650 else | 3620 else |
3651 { | 3621 { |
3652 v18 = v7->uGroup; | 3622 //v18 = actor->uGroup; |
3653 if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) | 3623 if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup ) |
3654 { | |
3655 ++v7; | |
3656 v5 = v26++ + 1; | |
3657 continue; | 3624 continue; |
3658 } | |
3659 v10 = 4; | 3625 v10 = 4; |
3660 } | 3626 } |
3661 if ( v3->pMonsterInfo.uHostilityType ) | 3627 if ( _this->pMonsterInfo.uHostilityType ) |
3662 v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; | 3628 v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType; |
3663 v11 = dword_4DF380[v10]; | 3629 v11 = dword_4DF380[v10]; |
3664 v23 = abs(v3->vPosition.x - v7->vPosition.x); | 3630 v23 = abs(_this->vPosition.x - actor->vPosition.x); |
3665 v27 = abs(v3->vPosition.y - v7->vPosition.y); | 3631 v27 = abs(_this->vPosition.y - actor->vPosition.y); |
3666 v12 = abs(v3->vPosition.z - v7->vPosition.z); | 3632 v12 = abs(_this->vPosition.z - actor->vPosition.z); |
3667 v19 = v12; | 3633 v19 = v12; |
3668 if ( v23 <= v11 | 3634 if ( v23 <= v11 |
3669 && v27 <= v11 | 3635 && v27 <= v11 |
3670 && v12 <= v11 | 3636 && v12 <= v11 |
3671 && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) | 3637 && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) |
3672 && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) | 3638 && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) |
3673 { | 3639 { |
3674 v25 = v23 * v23 + v27 * v27 + v19 * v19; | 3640 v25 = v23 * v23 + v27 * v27 + v19 * v19; |
3675 v21 = v26; | 3641 v21 = i; |
3676 } | 3642 } |
3677 v4 = 0; | 3643 //v4 = 0; |
3678 ++v7; | 3644 //++v7; |
3679 v5 = v26++ + 1; | 3645 //v5 = v26++ + 1; |
3646 //} | |
3647 //while ( v26 < (signed int)uNumActors ); | |
3648 | |
3649 } | |
3650 if ( v25 != -1 ) | |
3651 { | |
3652 //v13 = 8 * v21; | |
3653 //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; | |
3654 *a2 = 8 * v21 | OBJECT_Actor; | |
3680 } | 3655 } |
3681 while ( v26 < (signed int)uNumActors ); | 3656 |
3682 if ( v25 != -1 ) | 3657 if (pParty->Invisible()) |
3683 { | 3658 can_target_party = false; |
3684 v13 = 8 * v21; | 3659 |
3685 LOBYTE(v13) = 8 * v21 | 3; | 3660 if (can_target_party) |
3686 *v20 = v13; | 3661 { |
3687 } | 3662 v14 = _this->GetActorsRelation(0); |
3688 } | 3663 if ( BYTE2(_this->uAttributes) & 8 |
3689 if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4 | 3664 && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0 |
3690 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) ) | 3665 && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0) |
3691 a3 = v4; | 3666 && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0 |
3692 if ( a3 != v4 ) | 3667 && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0) |
3693 { | 3668 && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0 |
3694 v14 = v3->GetActorsRelation(0); | 3669 && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) ) |
3695 if ( BYTE2(v3->uAttributes) & 8 | |
3696 && SHIDWORD(v3->pActorBuffs[12].uExpireTime) <= (signed int)v4 | |
3697 && (SHIDWORD(v3->pActorBuffs[12].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[12].uExpireTime) <= v4) | |
3698 && SHIDWORD(v3->pActorBuffs[1].uExpireTime) <= (signed int)v4 | |
3699 && (SHIDWORD(v3->pActorBuffs[1].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[1].uExpireTime) <= v4) | |
3700 && SHIDWORD(v3->pActorBuffs[2].uExpireTime) <= (signed int)v4 | |
3701 && (SHIDWORD(v3->pActorBuffs[2].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[2].uExpireTime) <= v4) ) | |
3702 v14 = 4; | 3670 v14 = 4; |
3703 if ( v14 != v4 ) | 3671 if ( v14 != 0 ) |
3704 { | 3672 { |
3705 v15 = dword_4DF390; | 3673 v15 = dword_4DF390; |
3706 if ( !v3->pMonsterInfo.uHostilityType ) | 3674 if ( !_this->pMonsterInfo.uHostilityType ) |
3707 v15 = dword_4DF380[v14]; | 3675 v15 = dword_4DF380[v14]; |
3708 v16 = abs(v3->vPosition.x - pParty->vPosition.x); | 3676 v16 = abs(_this->vPosition.x - pParty->vPosition.x); |
3709 v28 = abs(v3->vPosition.y - pParty->vPosition.y); | 3677 v28 = abs(_this->vPosition.y - pParty->vPosition.y); |
3710 v17 = abs(v3->vPosition.z - pParty->vPosition.z); | 3678 v17 = abs(_this->vPosition.z - pParty->vPosition.z); |
3711 if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) | 3679 if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) |
3712 { | 3680 { |
3713 if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 ) | 3681 if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 ) |
3714 *v20 = 4; | 3682 *a2 = OBJECT_Player; |
3715 } | 3683 } |
3716 } | 3684 } |
3717 } | 3685 } |
3718 } | 3686 } |
3719 // 4DF380: using guessed type int dword_4DF380[]; | 3687 // 4DF380: using guessed type int dword_4DF380[]; |