comparison Actor.cpp @ 2492:85a12b497698

BelongsToSupertype() clear
author Ritor1
date Mon, 15 Sep 2014 17:30:19 +0600
parents 0a0c6d75aabe
children de8c5c223e9c
comparison
equal deleted inserted replaced
2490:0a0c6d75aabe 2492:85a12b497698
1858 } 1858 }
1859 1859
1860 //----- (004030AD) -------------------------------------------------------- 1860 //----- (004030AD) --------------------------------------------------------
1861 void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState) 1861 void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState)
1862 { 1862 {
1863 Actor *v4; // ebx@1
1864 __int16 v7; // ax@16 1863 __int16 v7; // ax@16
1865 AIDirection a3; // [sp+Ch] [bp-40h]@16 1864 AIDirection a3; // [sp+Ch] [bp-40h]@16
1866 AIDirection* v10; // [sp+28h] [bp-24h]@16 1865
1867 1866 if ( pActors[uActorID].uAIState == Fleeing )
1868 v4 = &pActors[uActorID]; 1867 pActors[uActorID].uAttributes |= 0x20000;
1869 if ( v4->uAIState == Fleeing ) 1868 if ( pActors[uActorID].pMonsterInfo.uHostilityType != 4 )
1870 BYTE2(v4->uAttributes) |= 2u; 1869 {
1871 if ( v4->pMonsterInfo.uHostilityType != 4 ) 1870 pActors[uActorID].uAttributes &= 0xFFFFFFFB;
1872 { 1871 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
1873 v4->uAttributes &= 0xFFFFFFFBu; 1872 }
1874 v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; 1873 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
1875 } 1874 pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].Reset();
1876 if ( v4->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) 1875 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 )
1877 v4->pActorBuffs[ACTOR_BUFF_CHARM].Reset(); 1876 pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].Reset();
1878 if ( v4->pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 ) 1877 if ( stunRegardlessOfState || (pActors[uActorID].uAIState != Stunned
1879 v4->pActorBuffs[ACTOR_BUFF_AFRAID].Reset(); 1878 && pActors[uActorID].uAIState != AttackingRanged1
1880 if ( stunRegardlessOfState 1879 && pActors[uActorID].uAIState != AttackingRanged2
1881 || (v4->uAIState != Stunned 1880 && pActors[uActorID].uAIState != AttackingRanged3
1882 && v4->uAIState != AttackingRanged1 1881 && pActors[uActorID].uAIState != AttackingRanged4
1883 && v4->uAIState != AttackingRanged2 1882 && pActors[uActorID].uAIState != AttackingMelee))
1884 && v4->uAIState != AttackingRanged3
1885 && v4->uAIState != AttackingRanged4
1886 && v4->uAIState != AttackingMelee))
1887 { 1883 {
1888 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0); 1884 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0);
1889 v10 = &a3; 1885 //v10 = &a3;
1890 v4->uYawAngle = LOWORD(v10->uYawAngle); 1886 pActors[uActorID].uYawAngle = LOWORD(a3.uYawAngle);
1891 v7 = pSpriteFrameTable->pSpriteSFrames[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength; 1887 v7 = pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[ANIM_GotHit]].uAnimLength;
1892 v4->uCurrentActionTime = 0; 1888 pActors[uActorID].uCurrentActionTime = 0;
1893 v4->uAIState = Stunned; 1889 pActors[uActorID].uAIState = Stunned;
1894 v4->uCurrentActionLength = 8 * v7; 1890 pActors[uActorID].uCurrentActionLength = 8 * v7;
1895 Actor::PlaySound(uActorID, 2u); 1891 Actor::PlaySound(uActorID, 2);
1896 v4->UpdateAnimation(); 1892 pActors[uActorID].UpdateAnimation();
1897 } 1893 }
1898 } 1894 }
1899 1895
1900 //----- (00402F87) -------------------------------------------------------- 1896 //----- (00402F87) --------------------------------------------------------
1901 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) 1897 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
2458 uCurrentActionAnimation = ANIM_Walking; 2454 uCurrentActionAnimation = ANIM_Walking;
2459 break; 2455 break;
2460 2456
2461 case AttackingMelee: 2457 case AttackingMelee:
2462 uCurrentActionAnimation = ANIM_AtkMelee; 2458 uCurrentActionAnimation = ANIM_AtkMelee;
2463 uAttributes |= 0x200000u; 2459 uAttributes |= 0x200000;
2464 break; 2460 break;
2465 2461
2466 case AttackingRanged1: 2462 case AttackingRanged1:
2467 case AttackingRanged2: 2463 case AttackingRanged2:
2468 case AttackingRanged3: 2464 case AttackingRanged3:
2469 case AttackingRanged4: 2465 case AttackingRanged4:
2470 uCurrentActionAnimation = ANIM_AtkRanged; 2466 uCurrentActionAnimation = ANIM_AtkRanged;
2471 uAttributes |= 0x200000u; 2467 uAttributes |= 0x200000;
2472 break; 2468 break;
2473 2469
2474 case Dying: 2470 case Dying:
2475 case Resurrected: 2471 case Resurrected:
2476 uCurrentActionAnimation = ANIM_Dying; 2472 uCurrentActionAnimation = ANIM_Dying;
2477 uAttributes |= 0x200000u; 2473 uAttributes |= 0x200000;
2478 break; 2474 break;
2479 2475
2480 case Pursuing: 2476 case Pursuing:
2481 case Fleeing: 2477 case Fleeing:
2482 uCurrentActionAnimation = ANIM_Walking; 2478 uCurrentActionAnimation = ANIM_Walking;
2483 uAttributes |= 0x200000u; 2479 uAttributes |= 0x200000;
2484 break; 2480 break;
2485 2481
2486 case Stunned: 2482 case Stunned:
2487 uCurrentActionAnimation = ANIM_GotHit; 2483 uCurrentActionAnimation = ANIM_GotHit;
2488 uAttributes |= 0x200000u; 2484 uAttributes |= 0x200000;
2489 break; 2485 break;
2490 2486
2491 case Fidgeting: 2487 case Fidgeting:
2492 uCurrentActionAnimation = ANIM_Bored; 2488 uCurrentActionAnimation = ANIM_Bored;
2493 uAttributes |= 0x200000u; 2489 uAttributes |= 0x200000;
2494 break; 2490 break;
2495 2491
2496 case Standing: 2492 case Standing:
2497 case Interacting: 2493 case Interacting:
2498 case Summoned: 2494 case Summoned:
2499 uCurrentActionAnimation = ANIM_Standing; 2495 uCurrentActionAnimation = ANIM_Standing;
2500 uAttributes |= 0x200000u; 2496 uAttributes |= 0x200000;
2501 break; 2497 break;
2502 2498
2503 case Dead: 2499 case Dead:
2504 if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0) 2500 if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0)
2505 uAIState = Removed; 2501 uAIState = Removed;
2674 { 2670 {
2675 unsigned __int8 extraSummonLevel; // al@1 2671 unsigned __int8 extraSummonLevel; // al@1
2676 int summonMonsterBaseType; // esi@1 2672 int summonMonsterBaseType; // esi@1
2677 int v5; // edx@2 2673 int v5; // edx@2
2678 int v7; // edi@10 2674 int v7; // edi@10
2679 Actor *v8; // esi@10 2675 Actor *actor; // esi@10
2680 MonsterInfo *v9; // ebx@10 2676 MonsterInfo *v9; // ebx@10
2681 MonsterDesc *v10; // edi@10 2677 //MonsterDesc *v10; // edi@10
2682 int v13; // ebx@10 2678 int v13; // ebx@10
2683 int v15; // edi@10 2679 int v15; // edi@10
2684 int v17; // ebx@10 2680 int v17; // ebx@10
2685 unsigned int v19; // qax@10 2681 unsigned int v19; // qax@10
2686 int result; // eax@13 2682 int result; // eax@13
2692 actorSector = 0; 2688 actorSector = 0;
2693 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 2689 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
2694 actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z); 2690 actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z);
2695 2691
2696 v19 = this->uAlly; 2692 v19 = this->uAlly;
2697 if ( !v19 ) 2693 if ( !this->uAlly )
2698 { 2694 {
2699 monsterId = this->pMonsterInfo.uID - 1; 2695 monsterId = this->pMonsterInfo.uID - 1;
2700 v19 = (uint)(monsterId * 0.33333334); 2696 v19 = (uint)(monsterId * 0.33333334);
2701 } 2697 }
2702 v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64; 2698 v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64;
2703 v13 = rand() % 2048; 2699 v13 = rand() % 2048;
2704 v15 = fixpoint_mul(stru_5C6E00->Cos(v13), v27) + this->vPosition.x; 2700 v15 = fixpoint_mul(stru_5C6E00->Cos(v13), v27) + this->vPosition.x;
2705 v17 = fixpoint_mul(stru_5C6E00->Sin(v13), v27) + this->vPosition.y; 2701 v17 = fixpoint_mul(stru_5C6E00->Sin(v13), v27) + this->vPosition.y;
2706 2702
2707 if (uCurrentlyLoadedLevelType != LEVEL_Outdoor) 2703 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
2708 { 2704 {
2709 result = pIndoor->GetSector(v15, v17, this->vPosition.z); 2705 result = pIndoor->GetSector(v15, v17, this->vPosition.z);
2710 if (result != actorSector) 2706 if (result != actorSector)
2711 return; 2707 return;
2712 result = BLV_GetFloorLevel(v15, v17, v27, result, &monsterId); 2708 result = BLV_GetFloorLevel(v15, v17, v27, result, &monsterId);
2718 2714
2719 extraSummonLevel = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; 2715 extraSummonLevel = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
2720 summonMonsterBaseType = this->pMonsterInfo.field_3C_some_special_attack; 2716 summonMonsterBaseType = this->pMonsterInfo.field_3C_some_special_attack;
2721 if ( extraSummonLevel ) 2717 if ( extraSummonLevel )
2722 { 2718 {
2723 if ( extraSummonLevel >= 1u && extraSummonLevel <= 3u ) 2719 if ( extraSummonLevel >= 1 && extraSummonLevel <= 3 )
2724 summonMonsterBaseType = summonMonsterBaseType + extraSummonLevel - 1; 2720 summonMonsterBaseType = summonMonsterBaseType + extraSummonLevel - 1;
2725 } 2721 }
2726 else 2722 else
2727 { 2723 {
2728 v5 = rand() % 100; 2724 v5 = rand() % 100;
2730 summonMonsterBaseType += 2; 2726 summonMonsterBaseType += 2;
2731 else if ( v5 >= 60 ) 2727 else if ( v5 >= 60 )
2732 summonMonsterBaseType += 1; 2728 summonMonsterBaseType += 1;
2733 } 2729 }
2734 v7 = summonMonsterBaseType - 1; 2730 v7 = summonMonsterBaseType - 1;
2735 v8 = &pActors[uNumActors]; 2731 actor = &pActors[uNumActors];
2736 v9 = &pMonsterStats->pInfos[v7 + 1]; 2732 v9 = &pMonsterStats->pInfos[v7 + 1];
2737 pActors[uNumActors].Reset(); 2733 pActors[uNumActors].Reset();
2738 v10 = &pMonsterList->pMonsters[v7]; 2734 strcpy(actor->pActorName, v9->pName);
2739 strcpy(v8->pActorName, v9->pName); 2735 actor->sCurrentHP = LOWORD(v9->uHP);
2740 v8->sCurrentHP = LOWORD(v9->uHP); 2736 memcpy(&actor->pMonsterInfo, v9, sizeof(actor->pMonsterInfo));
2741 memcpy(&v8->pMonsterInfo, v9, sizeof(v8->pMonsterInfo)); 2737 actor->word_000086_some_monster_id = summonMonsterBaseType;
2742 v8->word_000086_some_monster_id = summonMonsterBaseType; 2738 actor->uActorRadius = pMonsterList->pMonsters[v7].uMonsterRadius;
2743 v8->uActorRadius = v10->uMonsterRadius; 2739 actor->uActorHeight = pMonsterList->pMonsters[v7].uMonsterHeight;
2744 v8->uActorHeight = v10->uMonsterHeight; 2740 actor->pMonsterInfo.uTreasureDiceRolls = 0;
2745 v8->pMonsterInfo.uTreasureDiceRolls = 0; 2741 actor->pMonsterInfo.uTreasureType = 0;
2746 v8->pMonsterInfo.uTreasureType = 0; 2742 actor->pMonsterInfo.uExp = 0;
2747 v8->pMonsterInfo.uExp = 0; 2743 actor->uMovementSpeed = pMonsterList->pMonsters[v7].uMovementSpeed;
2748 v8->uMovementSpeed = v10->uMovementSpeed; 2744
2749 v8->vInitialPosition.z = this->vPosition.z; 2745 actor->vInitialPosition.x = v15;
2750 v8->vPosition.z = this->vPosition.z; 2746 actor->vInitialPosition.y = v17;
2751 v8->vInitialPosition.x = v15; 2747 actor->vInitialPosition.z = this->vPosition.z;
2752 v8->vPosition.x = v15; 2748 actor->vPosition.x = v15;
2753 v8->vInitialPosition.y = v17; 2749 actor->vPosition.y = v17;
2754 v8->vPosition.y = v17; 2750 actor->vPosition.z = this->vPosition.z;
2755 v8->uTetherDistance = 256; 2751
2756 v8->uSectorID = actorSector; 2752 actor->uTetherDistance = 256;
2757 v8->PrepareSprites(0); 2753 actor->uSectorID = actorSector;
2758 v8->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; 2754 actor->PrepareSprites(0);
2759 v8->uAlly = v19; 2755 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
2760 v8->uCurrentActionTime = 0; 2756 actor->uAlly = v19;
2761 v8->uGroup = this->uGroup; 2757 actor->uCurrentActionTime = 0;
2762 v8->uAIState = Summoned; 2758 actor->uGroup = this->uGroup;
2763 v8->uCurrentActionLength = 256; 2759 actor->uAIState = Summoned;
2764 v8->UpdateAnimation(); 2760 actor->uCurrentActionLength = 256;
2761 actor->UpdateAnimation();
2765 2762
2766 ++uNumActors; 2763 ++uNumActors;
2767 ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus; 2764 ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
2768 if ( this->uAttributes & 0x80000 ) 2765 if ( this->uAttributes & 0x80000 )
2769 v8->uAttributes |= 0x80000; 2766 actor->uAttributes |= 0x80000;
2770 v8->uSummonerID = PID(OBJECT_Actor,summonerId); 2767 actor->uSummonerID = PID(OBJECT_Actor,summonerId);
2771 2768
2772 } 2769 }
2773 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); 2770 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
2774 //----- (0046DF1A) -------------------------------------------------------- 2771 //----- (0046DF1A) --------------------------------------------------------
2775 bool Actor::_46DF1A_collide_against_actor( int a1, int a2 ) 2772 bool Actor::_46DF1A_collide_against_actor( int a1, int a2 )
3111 3108
3112 //If actor afraid: flee or if out of range random move 3109 //If actor afraid: flee or if out of range random move
3113 if (pActor->pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0) 3110 if (pActor->pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0)
3114 { 3111 {
3115 if ( (signed int)v36 >= 10240 ) 3112 if ( (signed int)v36 >= 10240 )
3116 Actor::AI_RandomMove(actor_id, target_pid, 1024, 0); 3113 Actor::AI_RandomMove(actor_id, target_pid, 1024, 0);
3117 else 3114 else
3118 { 3115 Actor::AI_Flee(actor_id, target_pid, 0, pDir);
3119 Actor::AI_Flee(actor_id, target_pid, 0, pDir);
3120 }
3121 continue; 3116 continue;
3122 } 3117 }
3123 3118
3124 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) 3119 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
3125 { 3120 {
3338 return uTotalActors == uAliveActors; 3333 return uTotalActors == uAliveActors;
3339 } 3334 }
3340 //----- (00408B54) -------------------------------------------------------- 3335 //----- (00408B54) --------------------------------------------------------
3341 unsigned int Actor::SearchActorByID(unsigned int *pTotalActors, unsigned int a2) 3336 unsigned int Actor::SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
3342 { 3337 {
3343 int v4; // eax@1 3338 //int v4; // eax@1
3344 unsigned int v5; // ebx@1 3339 unsigned int result; // ebx@1
3345 3340
3346 v4 = GetAlertStatus(); 3341 //v4 = GetAlertStatus();
3347 *pTotalActors = 0; 3342 *pTotalActors = 0;
3343 result = 0;
3348 if ( (pActors[a2].uAttributes & 0x100000) == GetAlertStatus() ) 3344 if ( (pActors[a2].uAttributes & 0x100000) == GetAlertStatus() )
3349 { 3345 {
3350 *pTotalActors = 1; 3346 *pTotalActors = 1;
3351 if ( pActors[a2].IsNotAlive() == 1 ) 3347 if ( pActors[a2].IsNotAlive() == 1 )
3352 v5 = 1; 3348 result = 1;
3353 } 3349 }
3354 return v5; 3350 return result;
3355 } 3351 }
3356 //----- (00408AE7) -------------------------------------------------------- 3352 //----- (00408AE7) --------------------------------------------------------
3357 unsigned int Actor::SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) 3353 unsigned int Actor::SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup)
3358 { 3354 {
3355 unsigned int result; // [sp+10h] [bp-4h]@1
3356
3357 int v8 = GetAlertStatus();
3358 *pTotalActors = 0;
3359 result = 0;
3360 for ( uint i = 0; i < uNumActors; i++)
3361 {
3362 if ( (pActors[i].uAttributes & 0x100000) == v8 && pActors[i].uGroup == uGroup)
3363 {
3364 ++*pTotalActors;
3365 if ( pActors[i].IsNotAlive() == 1 )
3366 ++result;
3367 }
3368 }
3369 return result;
3370 }
3371 //----- (00408A7E) --------------------------------------------------------
3372 unsigned int Actor::SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
3373 {
3359 int v8; // [sp+Ch] [bp-8h]@1 3374 int v8; // [sp+Ch] [bp-8h]@1
3360 unsigned int v9; // [sp+10h] [bp-4h]@1 3375 unsigned int result; // [sp+10h] [bp-4h]@1
3361 Actor* v4;
3362 3376
3363 v8 = GetAlertStatus(); 3377 v8 = GetAlertStatus();
3364 *pTotalActors = 0; 3378 *pTotalActors = 0;
3365 v9 = 0; 3379 result = 0;
3366 for ( uint i = 0; i < uNumActors; i++) 3380 for ( uint i = 0; i < uNumActors; i++)
3367 { 3381 {
3368 v4 = &pActors[i]; 3382 if ( (pActors[i].uAttributes & 0x100000) == v8 && pActors[i].pMonsterInfo.field_33 == uMonsterID)
3369 if ( (v4->uAttributes & 0x100000) == v8 && v4->uGroup == uGroup)
3370 { 3383 {
3371 ++*pTotalActors; 3384 ++*pTotalActors;
3372 if ( v4->IsNotAlive() == 1 ) 3385 if ( pActors[i].IsNotAlive() == 1 )
3373 ++v9; 3386 ++result;
3374 } 3387 }
3375 } 3388 }
3376 return v9; 3389 return result;
3377 }
3378 //----- (00408A7E) --------------------------------------------------------
3379 unsigned int Actor::SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
3380 {
3381 Actor *v4; // edi@2
3382 int v8; // [sp+Ch] [bp-8h]@1
3383 unsigned int v9; // [sp+10h] [bp-4h]@1
3384
3385 v8 = GetAlertStatus();
3386 *pTotalActors = 0;
3387 v9 = 0;
3388 for ( uint i = 0; i < uNumActors; i++)
3389 {
3390 v4 = &pActors[i];
3391 if ( (v4->uAttributes & 0x100000) == v8 && v4->pMonsterInfo.field_33 == uMonsterID)
3392 {
3393 ++*pTotalActors;
3394 if ( v4->IsNotAlive() == 1 )
3395 ++v9;
3396 }
3397 }
3398 return v9;
3399 } 3390 }
3400 //----- (00408A27) -------------------------------------------------------- 3391 //----- (00408A27) --------------------------------------------------------
3401 unsigned int Actor::SearchAliveActors(unsigned int *pTotalActors) 3392 unsigned int Actor::SearchAliveActors(unsigned int *pTotalActors)
3402 { 3393 {
3403 int v2; // eax@1 3394 int v2; // eax@1
3404 unsigned int v3; // ebp@1 3395 unsigned int result; // ebp@1
3405 Actor *v5; // edi@2
3406 3396
3407 v2 = GetAlertStatus(); 3397 v2 = GetAlertStatus();
3408 v3 = 0; 3398 result = 0;
3409 *pTotalActors = 0; 3399 *pTotalActors = 0;
3410 for ( uint i = 0; i < uNumActors; i++) 3400 for ( uint i = 0; i < uNumActors; i++)
3411 { 3401 {
3412 v5 = &pActors[i]; 3402 if ( (pActors[i].uAttributes & 0x100000) == v2 )
3413 if ( (v5->uAttributes & 0x100000) == v2 )
3414 { 3403 {
3415 ++*pTotalActors; 3404 ++*pTotalActors;
3416 if ( v5->IsNotAlive() == 1 ) 3405 if ( pActors[i].IsNotAlive() == 1 )
3417 ++v3; 3406 ++result;
3418 } 3407 }
3419 } 3408 }
3420 return v3; 3409 return result;
3421 } 3410 }
3422 //----- (00408768) -------------------------------------------------------- 3411 //----- (00408768) --------------------------------------------------------
3423 void Actor::InitializeActors() 3412 void Actor::InitializeActors()
3424 { 3413 {
3425 signed int v5; // [sp+Ch] [bp-10h]@1 3414 bool evil; // [sp+Ch] [bp-10h]@1
3426 signed int v6; // [sp+10h] [bp-Ch]@1 3415 bool bPit; // [sp+10h] [bp-Ch]@1
3427 signed int v7; // [sp+14h] [bp-8h]@1 3416 bool good; // [sp+14h] [bp-8h]@1
3428 signed int v8; // [sp+18h] [bp-4h]@1 3417 bool bCelestia; // [sp+18h] [bp-4h]@1
3429 3418
3430 v8 = 0; 3419 bCelestia = false;
3431 v6 = 0; 3420 bPit = false;
3432 v7 = 0; 3421 good = false;
3433 v5 = 0; 3422 evil = false;
3434 if ( !_stricmp(pCurrentMapName, "d25.blv") ) 3423 if ( !_stricmp(pCurrentMapName, "d25.blv") )//the Celestia
3435 v8 = 1; 3424 bCelestia = true;
3436 if ( !_stricmp(pCurrentMapName, "d26.blv") ) 3425 if ( !_stricmp(pCurrentMapName, "d26.blv") )//the Pit
3437 v6 = 1; 3426 bPit = true;
3438 if (pParty->IsPartyGood()) 3427 if (pParty->IsPartyGood())
3439 v7 = 1; 3428 good = true;
3440 if (pParty->IsPartyEvil()) 3429 if (pParty->IsPartyEvil())
3441 v5 = 1; 3430 evil = true;
3442 3431
3443 Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical 3432 Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical
3444 for (uint i = 0; i < uNumActors; ++i) 3433 for (uint i = 0; i < uNumActors; ++i)
3445 { 3434 {
3446 Actor* actor = &pActors[i]; 3435 Actor* actor = &pActors[i];
3457 } 3446 }
3458 } 3447 }
3459 3448
3460 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; 3449 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
3461 3450
3462 if (!v8 || v7) 3451 if (!bCelestia || good)
3463 if (!v6 || v5) 3452 if (!bPit || evil)
3464 if (actor->IsPeasant()) 3453 if (actor->IsPeasant())
3465 actor->uAttributes &= 0xF70000; 3454 actor->uAttributes &= 0xF70000;
3466 3455
3467 actor->uAttributes &= 0x7F0000; 3456 actor->uAttributes &= 0x7F0000;
3468 if (actor->uAttributes & 0x400000) 3457 if (actor->uAttributes & 0x400000)
3511 if (pMonster->IsNotAlive()) 3500 if (pMonster->IsNotAlive())
3512 return; 3501 return;
3513 3502
3514 pMonster->uAttributes |= 0xC000; 3503 pMonster->uAttributes |= 0xC000;
3515 if ( pMonster->uAIState == Fleeing ) 3504 if ( pMonster->uAIState == Fleeing )
3516 pMonster->uAttributes |= 0x20000u; 3505 pMonster->uAttributes |= 0x20000;
3517 bool hit_will_stun = false, 3506 bool hit_will_stun = false,
3518 hit_will_paralyze = false; 3507 hit_will_paralyze = false;
3519 if ( !projectileSprite ) 3508 if ( !projectileSprite )
3520 { 3509 {
3521 int main_hand_idx = player->pEquipment.uMainHand; 3510 int main_hand_idx = player->pEquipment.uMainHand;
4110 { 4099 {
4111 signed int distance; // edi@1 4100 signed int distance; // edi@1
4112 int for_x; // ebx@5 4101 int for_x; // ebx@5
4113 int for_y; // [sp+Ch] [bp-10h]@5 4102 int for_y; // [sp+Ch] [bp-10h]@5
4114 int for_z; // [sp+10h] [bp-Ch]@5 4103 int for_z; // [sp+10h] [bp-Ch]@5
4115 // int v3; // eax@5
4116 // int v4; // ebx@5
4117 // unsigned int v5; // ecx@5
4118 // int v6; // edx@6
4119 // unsigned int v7; // edx@8
4120 // unsigned int v8; // edx@10
4121 4104
4122 4105
4123 distance = 5120; 4106 distance = 5120;
4124 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) 4107 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
4125 distance = 2560; 4108 distance = 2560;
4165 v14 = 0; 4148 v14 = 0;
4166 if ( !( this->uAttributes & 0x800000 ) ) 4149 if ( !( this->uAttributes & 0x800000 ) )
4167 { 4150 {
4168 for (uchar i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++ ) 4151 for (uchar i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++ )
4169 v14 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; 4152 v14 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1;
4170 if ( v14 != 0 ) 4153 if ( v14 )
4171 { 4154 {
4172 pParty->PartyFindsGold(v14, 0); 4155 pParty->PartyFindsGold(v14, 0);
4173 viewparams->bRedrawGameUI = 1; 4156 viewparams->bRedrawGameUI = 1;
4174 } 4157 }
4175 } 4158 }
4237 v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; 4220 v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
4238 if ( v14 ) 4221 if ( v14 )
4239 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v11); 4222 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v11);
4240 else 4223 else
4241 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11); 4224 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11);
4242 ShowStatusBarString(pTmpBuf2.data(), 2u); 4225 ShowStatusBarString(pTmpBuf2.data(), 2);
4243 if ( !pParty->AddItemToParty(&Dst) ) 4226 if ( !pParty->AddItemToParty(&Dst) )
4244 pParty->SetHoldingItem(&Dst); 4227 pParty->SetHoldingItem(&Dst);
4245 itemFound = true; 4228 itemFound = true;
4246 } 4229 }
4247 } 4230 }
4279 pParty->SetHoldingItem(&this->ActorHasItems[1]); 4262 pParty->SetHoldingItem(&this->ActorHasItems[1]);
4280 itemFound = true; 4263 itemFound = true;
4281 } 4264 }
4282 this->ActorHasItems[1].Reset(); 4265 this->ActorHasItems[1].Reset();
4283 } 4266 }
4284 if ( !itemFound || rand() % 100 < 90 ) 4267 if ( !itemFound || rand() % 100 < 90 )//for repeatedly get gold and item
4285 this->Remove(); 4268 this->Remove();
4286 } 4269 }
4287 4270
4288 4271
4289 //----- (00427102) -------------------------------------------------------- 4272 //----- (00427102) --------------------------------------------------------
4607 4590
4608 //----- (004014E6) -------------------------------------------------------- 4591 //----- (004014E6) --------------------------------------------------------
4609 void Actor::MakeActorAIList_ODM() 4592 void Actor::MakeActorAIList_ODM()
4610 { 4593 {
4611 int v1; // eax@4 4594 int v1; // eax@4
4612 // int v2; // ebx@4
4613 // unsigned int v3; // ecx@4
4614 // int v4; // edx@5
4615 // int v5; // edx@7
4616 // unsigned int v6; // edx@9
4617 unsigned int v7; // ST20_4@10 4595 unsigned int v7; // ST20_4@10
4618 int v9; // edi@10 4596 int distance; // edi@10
4619 int v10; // ebx@14 4597 int v10; // ebx@14
4620 int v21; // [sp+Ch] [bp-14h]@4 4598 int v21; // [sp+Ch] [bp-14h]@4
4621 int v22; // [sp+10h] [bp-10h]@4 4599 int v22; // [sp+10h] [bp-10h]@4
4622 4600
4623 pParty->uFlags &= 0xFFFFFFCFu; 4601 pParty->uFlags &= 0xFFFFFFCF;
4624 4602
4625 ai_arrays_size = 0; 4603 ai_arrays_size = 0;
4626 for (uint i = 0; i < uNumActors; ++i) 4604 for (uint i = 0; i < uNumActors; ++i)
4627 { 4605 {
4628 Actor* actor = &pActors[i]; 4606 Actor* actor = &pActors[i];
4635 } 4613 }
4636 4614
4637 v22 = abs(pParty->vPosition.z - actor->vPosition.z); 4615 v22 = abs(pParty->vPosition.z - actor->vPosition.z);
4638 v21 = abs(pParty->vPosition.y - actor->vPosition.y); 4616 v21 = abs(pParty->vPosition.y - actor->vPosition.y);
4639 v1 = abs(pParty->vPosition.x - actor->vPosition.x); 4617 v1 = abs(pParty->vPosition.x - actor->vPosition.x);
4640 v7 = int_get_vector_length(v22, v21, v1); 4618 v7 = int_get_vector_length(v22, v21, v1);
4641 //v8 = actor->uActorRadius; 4619 distance = v7 - actor->uActorRadius;
4642 v9 = v7 - actor->uActorRadius; 4620 if ( distance < 0 )
4643 //v23 = v7 - v8; 4621 distance = 0;
4644 if ( v9 < 0 ) 4622
4623 if (distance < 5632)
4624 {
4625 v10 = actor->uAttributes & 0xFEFFFFFF;
4626 actor->uAttributes = v10;
4627 if ( v10 & 0x80000 || actor->GetActorsRelation(0) )
4645 { 4628 {
4646 v9 = 0; 4629 //v11 = (pParty->uFlags & 0x10) == 0;
4647 //v23 = 0; 4630 actor->uAttributes = v10 | ACTOR_HOSTILE;
4631 if (distance < 5120 )
4632 pParty->SetYellowAlert();
4633 if (distance < 307)
4634 pParty->SetRedAlert();
4648 } 4635 }
4649 4636 actor->uAttributes |= 0x4000;
4650 if (v9 < 5632) 4637 ai_near_actors_distances[ai_arrays_size] = distance;
4651 { 4638 ai_near_actors_ids[ai_arrays_size++] = i;
4652 v10 = actor->uAttributes & 0xFEFFFFFF; 4639 }
4653 actor->uAttributes = v10; 4640 else
4654 if ( v10 & 0x80000 || actor->GetActorsRelation(0) ) 4641 actor->uAttributes &= 0xFFFFBFFF;
4655 {
4656 //v11 = (pParty->uFlags & 0x10) == 0;
4657 actor->uAttributes = v10 | 0x1000000;
4658 if (v9 < 5120 )
4659 pParty->SetYellowAlert();
4660 if (v9 < 307)
4661 pParty->SetRedAlert();
4662 }
4663 actor->uAttributes |= 0x00004000;
4664 ai_near_actors_distances[ai_arrays_size] = v9;
4665 ai_near_actors_ids[ai_arrays_size++] = i;
4666 }
4667 else
4668 actor->uAttributes &= 0xFFFFBFFF;
4669 } 4642 }
4670 4643
4671 /* 4644 /*
4672 result = v27; 4645 result = v27;
4673 if ( v27 > 0 ) 4646 if ( v27 > 0 )
4726 4699
4727 //----- (004016FA) -------------------------------------------------------- 4700 //----- (004016FA) --------------------------------------------------------
4728 int Actor::MakeActorAIList_BLV() 4701 int Actor::MakeActorAIList_BLV()
4729 { 4702 {
4730 int v1; // eax@4 4703 int v1; // eax@4
4731 int v9; // edi@10 4704 int distance; // edi@10
4732 int v13; // edx@24 4705 int v13; // edx@24
4733 int v15; // ebx@26 4706 int v15; // ebx@26
4734 unsigned int v17; // esi@27 4707 unsigned int v17; // esi@27
4735 int v18; // ecx@31 4708 int v18; // ecx@31
4736 signed int v19; // edi@31 4709 signed int v19; // edi@31
4742 int v39; // [sp+14h] [bp-10h]@4 4715 int v39; // [sp+14h] [bp-10h]@4
4743 int i; // [sp+18h] [bp-Ch]@31 4716 int i; // [sp+18h] [bp-Ch]@31
4744 uint v45; // [sp+20h] [bp-4h]@1 4717 uint v45; // [sp+20h] [bp-4h]@1
4745 4718
4746 // __debugbreak(); // refactor for blv ai 4719 // __debugbreak(); // refactor for blv ai
4747 pParty->uFlags &= 0xFFFFFFCFu; 4720 pParty->uFlags &= 0xFFFFFFCF;
4748 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); 4721 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
4749 v45 = 0; 4722 v45 = 0;
4750 for ( uint i = 0; i < (signed int)uNumActors; ++i ) 4723 for ( uint i = 0; i < (signed int)uNumActors; ++i )
4751 { 4724 {
4752 pActors[i].uAttributes &= 0xFB00; 4725 pActors[i].uAttributes &= 0xFB00;
4757 } 4730 }
4758 v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x); 4731 v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x);
4759 v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y); 4732 v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y);
4760 v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z); 4733 v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z);
4761 4734
4762 v9 = int_get_vector_length(v39, v38, v1) - pActors[i].uActorRadius; 4735 distance = int_get_vector_length(v39, v38, v1) - pActors[i].uActorRadius;
4763 if ( v9 < 0 ) 4736 if ( distance < 0 )
4764 v9 = 0; 4737 distance = 0;
4765 if ( v9 < 10240 ) 4738 if ( distance < 10240 )
4766 { 4739 {
4767 pActors[i].uAttributes &= 0xFEFFFFFF; 4740 pActors[i].uAttributes &= 0xFEFFFFFF;
4768 if ( pActors[i].uAttributes & 0x80000 || pActors[i].GetActorsRelation(0) ) 4741 if ( pActors[i].uAttributes & 0x80000 || pActors[i].GetActorsRelation(0) )
4769 { 4742 {
4770 pActors[i].uAttributes |= 0x1000000; 4743 pActors[i].uAttributes |= ACTOR_HOSTILE;
4771 if ( !(pParty->uFlags & 0x10) && (double)v9 < 307.2 ) 4744 if ( !(pParty->uFlags & 0x10) && (double)distance < 307.2 )
4772 pParty->uFlags |= 0x10; 4745 pParty->SetRedAlert();
4773 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) 4746 if ( !(pParty->uFlags & 0x20) && distance < 5120 )
4774 pParty->uFlags |= 0x20; 4747 pParty->SetYellowAlert();
4775 } 4748 }
4776 ai_near_actors_distances[v45] = v9; 4749 ai_near_actors_distances[v45] = distance;
4777 ai_near_actors_ids[v45] = i; 4750 ai_near_actors_ids[v45] = i;
4778 v45++; 4751 v45++;
4779 } 4752 }
4780 else 4753 else
4781 pActors[i].uAttributes &= 0xBF00; 4754 pActors[i].uAttributes &= 0xBF00;