Mercurial > mm7
diff mm7_3.cpp @ 869:715064ae1792
Слияние
author | Ritor1 |
---|---|
date | Mon, 01 Apr 2013 09:05:51 +0600 |
parents | 6759478c2f14 7bd9beae3b8d |
children | a0ae8d36c2d6 |
line wrap: on
line diff
--- a/mm7_3.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_3.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -862,15 +862,15 @@ void __cdecl UpdateActors_ODM() { Actor *v0; // esi@2 - unsigned __int16 v1; // ax@2 - unsigned int v2; // ecx@6 + AIState uAIState; // ax@2 + //unsigned int v2; // ecx@6 int v3; // ebx@6 - int v4; // eax@8 + //int v4; // eax@8 int v5; // eax@10 int v6; // ecx@10 - signed int v7; // ebx@10 + //signed int v7; // ebx@10 signed int v8; // ebx@17 - unsigned __int8 v9; // zf@17 + //unsigned __int8 v9; // zf@17 unsigned __int8 v10; // sf@17 unsigned __int16 v11; // ax@21 int v12; // eax@29 @@ -878,7 +878,7 @@ int v14; // eax@30 unsigned __int64 v15; // qax@30 int v16; // eax@33 - int v17; // edi@34 + //int v17; // edi@34 int v18; // edx@42 int v19; // ecx@42 __int16 v20; // ax@42 @@ -895,12 +895,12 @@ int v31; // edi@57 signed int i; // ebx@57 unsigned int v33; // ecx@58 - int v34; // ebx@64 + //int v34; // ebx@64 int v35; // edi@64 int v36; // eax@64 - unsigned __int16 v37; // cx@66 + //unsigned __int16 v37; // cx@66 signed int v38; // edx@71 - signed int v39; // edi@71 + unsigned int v39; // edi@71 BSPModel *v40; // eax@75 ODMFace *v41; // edi@75 int v42; // ebx@76 @@ -913,9 +913,9 @@ int v49; // edi@85 int v50; // eax@85 unsigned __int64 v51; // qax@85 - unsigned __int8 v52; // zf@87 - unsigned __int8 v53; // sf@87 - unsigned __int8 v54; // of@104 + //unsigned __int8 v52; // zf@87 + //unsigned __int8 v53; // sf@87 + // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 int v57; // ST10_4@107 @@ -929,71 +929,64 @@ int v65; // [sp+20h] [bp-30h]@2 int v66; // [sp+24h] [bp-2Ch]@2 bool v67; // [sp+28h] [bp-28h]@10 - unsigned int v68; // [sp+2Ch] [bp-24h]@10 + //unsigned int v68; // [sp+2Ch] [bp-24h]@10 unsigned int v69; // [sp+30h] [bp-20h]@6 unsigned int v70; // [sp+34h] [bp-1Ch]@10 int v71; // [sp+38h] [bp-18h]@62 - int v72; // [sp+3Ch] [bp-14h]@10 + int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 + int v72b; int v73; // [sp+40h] [bp-10h]@17 - int v74; // [sp+44h] [bp-Ch]@8 + int uIsFlying; // [sp+44h] [bp-Ch]@8 unsigned int v75; // [sp+48h] [bp-8h]@1 - int v76; // [sp+4Ch] [bp-4h]@10 - - v75 = 0; - if ( (signed int)uNumActors <= 0 ) - return; - do + int uIsOnWater; // [sp+4Ch] [bp-4h]@10 + + for(v75=0;(signed int)v75 < (signed int)uNumActors;++v75) { v0 = &pActors[v75]; v66 = v0->vPosition.x; v65 = v0->vPosition.y; - v1 = v0->uAIState; - if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) - goto LABEL_121; - v2 = v0->pMonsterInfo.uID; + uAIState = v0->uAIState; + if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed ) + { + continue; + } v3 = 0; v69 = 0; - if ( MonsterStats::BelongsToSupertype(v2, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) + if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) v3 = 1; - v4 = v0->pMonsterInfo.uFlying; v0->uSectorID = 0; - v74 = v4; + uIsFlying = v0->pMonsterInfo.uFlying; if ( !v0->CanAct() ) - v74 = 0; + uIsFlying = 0; v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); v5 = ODM_GetFloorLevel( v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v0->uActorHeight, - &v76, + &uIsOnWater, (int *)&v69, v3); v6 = v0->vPosition.z; - v7 = v5; - v68 = v5; - v72 = 0; + uIsAboveFloor = 0; v67 = v69 == 0; if ( v6 > v5 + 1 ) - v72 = 1; - if ( v0->uAIState == 5 && v76 && !v72 ) + uIsAboveFloor = 1; + if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) { v0->uAIState = Removed; - goto LABEL_121; + continue; } if ( v0->uCurrentActionAnimation == ANIM_Walking ) { v8 = v0->uMovementSpeed; - v9 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; - v10 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; v73 = v0->uMovementSpeed; - if ( !v10 && (!(v10 | v9) || LODWORD(v0->pActorBuffs[7].uExpireTime) > 0) ) + if ( (signed __int64)v0->pActorBuffs[7].uExpireTime > 0 ) { v8 = (signed __int64)((double)v73 * 0.5); v73 = (signed __int64)((double)v73 * 0.5); } - v11 = v0->uAIState; - if ( v11 == 7 || v11 == 6 ) + if ( uAIState == Fleeing || uAIState == Pursuing ) { v8 *= 2; v73 = v8; @@ -1003,15 +996,13 @@ if ( v8 > 1000 ) v8 = 1000; v12 = stru_5C6E00->Cos(v0->uYawAngle); - v69 = v12; v13 = v12 * (signed __int64)v8; v73 = v13 >> 16; v0->vVelocity.x = WORD1(v13); v69 = stru_5C6E00->Sin(v0->uYawAngle); v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v69 * v8 >> 16; - if ( !v9 ) + if ( uIsFlying ) { v14 = stru_5C6E00->Sin(v0->uPitchAngle); v69 = v14; @@ -1019,7 +1010,7 @@ v73 = v15 >> 16; v0->vVelocity.z = WORD1(v15); } - v7 = v68; + //v7 = v68; } else { @@ -1029,9 +1020,8 @@ v0->vVelocity.x = v73; v73 = v0->vVelocity.y; v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v73; - if ( !v9 ) + if ( uIsFlying ) { v69 = 55000; v73 = v0->vVelocity.z; @@ -1039,20 +1029,20 @@ v0->vVelocity.z = v73; } } - if ( v0->vPosition.z < v7 ) - { - v16 = v74; - v0->vPosition.z = v7; + if ( v0->vPosition.z < v5 ) + { + v16 = uIsFlying; + v0->vPosition.z = v5; v0->vVelocity.z = v16 != 0 ? 0x14 : 0; } - v17 = 0; - if ( !v72 || v74 ) - { - if ( v70 && !v72 && v67 ) + //v17 = 0; + if ( !uIsAboveFloor || uIsFlying ) + { + if ( v70 && !uIsAboveFloor && v67 ) { v18 = v0->vPosition.y; v19 = v0->vPosition.x; - v0->vPosition.z = v7; + v0->vPosition.z = v5; ODM_GetTerrainNormalAt(v19, v18, &v62); v20 = GetGravityStrength(); v21 = v62.y; @@ -1060,22 +1050,22 @@ v23 = v62.y * v0->vVelocity.y; v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16; - v72 = v21; + v72b = v21; v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v24 = v72; - v72 = v22; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v24 = v72b; + v72b = v22; v0->vVelocity.y += v24; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v0->vVelocity.z += v72; - v17 = 0; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v0->vVelocity.z += v72b; + //v17 = 0; } } else { v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); } - if ( pParty->armageddon_timer != v17 && v0->CanAct() ) + if ( pParty->armageddon_timer != 0 && v0->CanAct() ) { v0->vVelocity.x += rand() % 100 - 50; v0->vVelocity.y += rand() % 100 - 50; @@ -1085,14 +1075,13 @@ v0->uYawAngle += v25 % 32 - 16; v0->UpdateAnimation(); } - if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == v17 ) - { - v0->vVelocity.y = v17; - v0->vVelocity.x = v17; - } - v9 = v0->pMonsterInfo.uFlying == 0; + if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 ) + { + v0->vVelocity.y = 0; + v0->vVelocity.x = 0; + } stru_721530.field_0 = 1; - if ( v9 ) + if ( !uIsFlying ) v26 = 40; else v26 = v0->uActorRadius; @@ -1101,8 +1090,8 @@ stru_721530.field_8 = v26; stru_721530.prolly_normal_d = v26; stru_721530.field_C = v27; - stru_721530.field_70 = v17; - v69 = v17; + stru_721530.field_70 = 0; + v69 = 0; while ( 1 ) { stru_721530.field_34.x = v0->vPosition.x; @@ -1125,7 +1114,7 @@ v30 = WorldPosToGridCellX(v0->vPosition.x); _46E26D_collide_against_sprites(v30, v29); _46EF01_collision_chech_player(0); - _46ED8A_collide_against_sprite_objects(8 * v75 | OBJECT_Actor); + _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); v31 = 0; for ( i = 0; v31 < ai_arrays_size; ++v31 ) { @@ -1136,7 +1125,7 @@ v71 = i > 1; if ( stru_721530.field_7C < stru_721530.field_6C ) v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v34 = 0; + //v34 = 0; v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; v36 = ODM_GetFloorLevel( stru_721530.normal2.x, @@ -1146,17 +1135,16 @@ (int *)&v63, &v64, 0); - if ( v76 ) + if ( uIsOnWater ) { if ( v35 < v36 + 60 ) { - v37 = v0->uAIState; - if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 ) + if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) { if ( v64 ) v61 = v36 + 30; else - v61 = v68 + 60; + v61 = v5 + 60; sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61); v0->uAIState = Removed; return; @@ -1170,60 +1158,64 @@ v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; break; } - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; v38 = stru_721530.uFaceID; v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; stru_721530.field_70 += stru_721530.field_7C; - v39 = v38 >> 3; - switch ( v38 & 7 ) - { - case 3: - if ( pParty->bTurnBasedModeOn != 1 ) - goto LABEL_97; - if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 ) - { - v34 = 0; -LABEL_97: + v39 = PID_ID(v38); + switch ( PID_TYPE(v38) ) + { + case OBJECT_Actor: + if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 || pParty->bTurnBasedModeOn != 1 ) + { + //if(pParty->bTurnBasedModeOn == 1) + //v34 = 0; if ( v0->pMonsterInfo.uHostilityType ) { - if ( v71 == v34 ) - goto LABEL_99; -LABEL_101: - Actor::AI_StandOrBored(v75, 4, v34, (AIDirection *)v34); - break; + if ( v71 == 0 ) + { + Actor::Flee(v75, v38, 0, (AIDirection *)0); + } + else + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } } - if ( v71 != v34 ) - goto LABEL_101; - if ( pActors[v39].pMonsterInfo.uHostilityType ) + else if ( v71 != 0 ) + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } + else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) { -LABEL_99: - Actor::_402968(v75, v38, v34, (AIDirection *)v34); - break; + Actor::Flee(v75, v38, 0, (AIDirection *)0); } -LABEL_103: - Actor::FaceObject(v75, v38, v34, (AIDirection *)v34); - break; + else + { + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + } } break; - case 4: + case OBJECT_Player: if ( !v0->GetActorsRelation(0) ) { v38 = stru_721530.uFaceID; - goto LABEL_103; - } - v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; - v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + break; + } + //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; + //v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; v0->vVelocity.y = 0; v0->vVelocity.x = 0; - if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime < 0) pParty->pPartyBuffs[11].Reset(); viewparams->bRedrawGameUI = 1; break; - case 5: + case OBJECT_Decoration: v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v48 = stru_5C6E00->Atan2( v0->vPosition.x - pLevelDecorations[v39].vPosition.x, @@ -1238,7 +1230,7 @@ v70 = v51 >> 16; v0->vVelocity.y = WORD1(v51); break; - case 6: + case OBJECT_BModel: v40 = &pOutdoor->pBModels[v38 >> 9]; v41 = &v40->pFaces[v39 & 0x3F]; if ( !(BYTE3(v41->uAttributes) & 0x20) ) @@ -1258,16 +1250,16 @@ } else { - v72 = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; - if ( stru_721530.field_64 >> 3 > v72 ) - v72 = stru_721530.field_64 >> 3; + if ( stru_721530.field_64 >> 3 > v72b ) + v72b = stru_721530.field_64 >> 3; v73 = v41->pFacePlane.vNormal.x; - v73 = (unsigned __int64)(v72 * (signed __int64)v73) >> 16; + v73 = (unsigned __int64)(v72b * (signed __int64)v73) >> 16; v71 = v41->pFacePlane.vNormal.y; - v71 = (unsigned __int64)(v72 * (signed __int64)v71) >> 16; + v71 = (unsigned __int64)(v72b * (signed __int64)v71) >> 16; v70 = v41->pFacePlane.vNormal.z; - v70 = (unsigned __int64)(v72 * (signed __int64)(signed int)v70) >> 16; + v70 = (unsigned __int64)(v72b * (signed __int64)(signed int)v70) >> 16; v0->vVelocity.x += v73; v0->vVelocity.y += v71; v0->vVelocity.z += v70; @@ -1302,35 +1294,26 @@ v70 = v0->vVelocity.z; v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; ++v69; - v54 = v69 < 100; - v10 = (v69 - 100) < 0; + //v54 = v69 < 100; + //v10 = (v69 - 100) < 0; v0->vVelocity.z = v70; - if ( !(v10 ^ v54) ) + if ( v69 >= 100 ) break; v26 = stru_721530.prolly_normal_d; } - v69 = WorldPosToGridCellX(v66); - v55 = WorldPosToGridCellZ(v65); - v56 = v55 - 1; - v57 = v0->vPosition.x; - v71 = v55 - 1; - v68 = WorldPosToGridCellX(v57); - v70 = WorldPosToGridCellZ(v0->vPosition.y) - 1; - v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v69, v56) >> 1) & 1; - v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v68, v70) >> 1) & 1; - v60 = 0; - if ( v69 == v68 && v71 == v70 && v58 ) - v60 = 1; - if ( !v67 ) - v60 = 1; - if ( !v60 ) + v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1; + v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1; + if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) + && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) + && v58 + || v67 != 0 ) { if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) { v58 = v58 == 0; v59 = v59 == 0; } - if ( !v74 && v58 && !v59 ) + if ( !uIsFlying && v58 && !v59 ) { v0->vPosition.x = v66; v0->vPosition.y = v65; @@ -1343,10 +1326,7 @@ } } } -LABEL_121: - ++v75; - } - while ( (signed int)v75 < (signed int)uNumActors ); + } } //----- (0047253E) -------------------------------------------------------- @@ -1391,7 +1371,7 @@ v4 = &pObjectList->pObjects[item->uObjectDescID]; if (item->AttachedToActor()) { - v5 = item->spell_target_pid >> 3; + v5 = PID_ID(item->spell_target_pid); *(int *)(v2 - 26) = pActors[v5].vPosition.x; *(int *)(v2 - 22) = pActors[v5].vPosition.y; *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight; @@ -1467,7 +1447,7 @@ v10 = i; if ( !(v9 & 0x40) ) goto LABEL_35; - _46BFFA_check_object_intercept(i, 8 * i | OBJECT_Item); + _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); } } LABEL_36: @@ -1934,7 +1914,7 @@ uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) @@ -1942,7 +1922,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_152; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1954,7 +1934,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; v45 = v44->uPolygonType; @@ -2363,7 +2343,7 @@ v6 = v108 & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { - pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; + pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292); }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) @@ -2858,7 +2838,7 @@ pY = _angle_y; v45 = stru_721530.uFaceID; pZ = v40; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -2866,7 +2846,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_234; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; @@ -2887,7 +2867,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { pParty->bFlying = 0; v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; @@ -4788,7 +4768,7 @@ if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0); - static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, (BSPVertexBuffer *)v56 - 1); + static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); if ( pDecalBuilder->uNumDecals > 0 ) { v40 = -1; @@ -5988,7 +5968,7 @@ float v28; // [sp+12Ch] [bp-38h]@2 int v29; // [sp+130h] [bp-34h]@4 int v30; // [sp+134h] [bp-30h]@1 - float v31; // [sp+138h] [bp-2Ch]@2 + //int v31; // [sp+138h] [bp-2Ch]@2 int v32; // [sp+13Ch] [bp-28h]@6 int v33; // [sp+140h] [bp-24h]@2 int v34; // [sp+144h] [bp-20h]@1 @@ -5998,7 +5978,6 @@ int v38; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 int v40; // [sp+160h] [bp-4h]@7 - float v41; extern bool new_sky; if (new_sky) @@ -6042,9 +6021,7 @@ array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y; v36 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5; - v31 = (signed int)(v36 / tan(0.6457717418670654) + 0.5); - //v41 = v31 + 6.7553994e15; - v33 = 65536 / v31; + v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5); for (int i = 0; i < _this.uNumVertices; ++i) { @@ -6109,28 +6086,29 @@ v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16); v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, v18) / 8; - v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, v18) / 8; + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8; + v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8; //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; //array_50AC10[i].vWorldPosition.x = v36 / (_this.pTexture->uTextureHeight * 65536.0); //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16); //array_50AC10[i].vWorldPosition.z = v35 / (_this.pTexture->uTextureWidth * 65536.0); - array_50AC10[i]._rhw = 1; - array_50AC10[i].u += 1.0 / 224 * pMiscTimer->uTotalGameTimeElapsed; - array_50AC10[i].v += 1.0 / 224 * pMiscTimer->uTotalGameTimeElapsed; - //float t = (GetTickCount() % 96000) / 96000.0f; - //array_50AC10[i].u += t; + array_50AC10[i]._rhw = 1.0;// / (pOutdoorCamera->shading_dist_mist >> 16); + //array_50AC10[i].u = (double)v35 / (65536.0 * _this.pTexture->uTextureWidth); + //array_50AC10[i].v = (double)v36 / (65536.0 * _this.pTexture->uTextureHeight); + float t = (GetTickCount() % 96000) / 96000.0f; + array_50AC10[i].u += t; + array_50AC10[i].v += t; if ( i == _this.uNumVertices - 1 ) { - pRenderer->DrawFan(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); - - //array_50AC10[0].vWorldViewProjY = v38; - //array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; - //array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; - //array_50AC10[3].vWorldViewProjY = v38; - - pRenderer->DrawFan(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); + pRenderer->DrawSkyPolygon(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); + + array_50AC10[0].vWorldViewProjY = v38; + array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; + array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; + array_50AC10[3].vWorldViewProjY = v38; + + pRenderer->DrawSkyPolygon(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); return; } } @@ -6247,7 +6225,7 @@ uFaceID = v65; } v56 = 8 * uFaceID; - LOBYTE(v56) = 8 * uFaceID | 6; + LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); v57 = v56; v58 = pFace->GetTexture(); pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); @@ -11174,11 +11152,11 @@ v15->uScreenSpaceX = a5; v15->uScreenSpaceY = a6; //v23 = 8 * uDecorationID; - //LOBYTE(v23) = 8 * uDecorationID | OBJECT_Decoration; + //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID); //v15->sZValue = v22 + v23; v15->actual_z = HIWORD(x); - v15->object_pid = 8 * uDecorationID | OBJECT_Decoration; + v15->object_pid = PID(OBJECT_Decoration,uDecorationID); v15->uTintColor = 0; v15->pSpriteFrame = v12; @@ -11331,12 +11309,12 @@ v3->uTintColor = 0; v3->uScreenSpaceY = v22; //v23 = 8 * i; - //LOBYTE(v23) = 8 * i | OBJECT_Item; + //LOBYTE(v23) = PID(OBJECT_Item,i); v3->pSpriteFrame = v24; //v12 = (p->uAttributes & 0x20) == 0; //v3->sZValue = v21 + v23; v3->actual_z = HIWORD(x); - v3->object_pid = 8 * i | OBJECT_Item; + v3->object_pid = PID(OBJECT_Item,i); if (p->uAttributes & 0x20) { if ( !pRenderer->pRenderD3D ) @@ -12810,7 +12788,7 @@ ++num_dead_actors; else { - int sumonner_type = pActors[i].uSummonerID & 7;; + int sumonner_type = PID_TYPE(pActors[i].uSummonerID); if (sumonner_type == OBJECT_Player) ++num_dead_actors; } @@ -14993,7 +14971,7 @@ { v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_near_actors_ids[v18] | 3, 4u), v18 = i, v21) ) + || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) { v22 = ai_near_actors_ids[v18]; v20->uAttributes |= 0x8000u; @@ -15114,72 +15092,74 @@ unsigned __int16 v22; // ax@86 //signed int v23; // eax@94 //unsigned int v24; // eax@102 - signed int v25; // edi@102 - SpellBuff *v26; // esi@102 + //signed int v25; // edi@102 + //SpellBuff *v26; // esi@102 unsigned int v27; // ecx@123 unsigned int v28; // eax@123 - unsigned int v29; // eax@127 + //unsigned int v29; // eax@127 AIDirection *v30; // eax@129 unsigned __int16 v31; // ax@132 - unsigned int v32; // esi@142 + //unsigned int v32; // esi@142 int v33; // eax@144 int v34; // eax@147 char v35; // al@150 unsigned int v36; // edi@152 signed int v37; // eax@154 - unsigned __int8 v38; // sf@158 - unsigned __int8 v39; // of@158 - signed int v40; // edx@166 - unsigned int v41; // ecx@166 + //unsigned __int8 v38; // sf@158 + //unsigned __int8 v39; // of@158 + //signed int v40; // edx@166 + //unsigned int v41; // ecx@166 double v42; // st7@176 double v43; // st6@176 - bool v44; // eax@189 + //bool v44; // eax@189 bool v45; // eax@192 unsigned __int8 v46; // cl@197 double v47; // st7@206 double v48; // st7@207 - char v49; // zf@208 - char v50; // zf@214 - signed int v51; // edx@219 - unsigned int v52; // ecx@219 + //char v49; // zf@208 + //char v50; // zf@214 + //signed int v51; // edx@219 + //unsigned int v52; // ecx@219 __int16 v53; // fps@224 - unsigned __int8 v54; // c0@224 - unsigned __int8 v55; // c3@224 + //unsigned __int8 v54; // c0@224 + //unsigned __int8 v55; // c3@224 double v56; // st7@226 AIDirection *v57; // eax@246 double v58; // st7@246 - signed int v59; // [sp-18h] [bp-C8h]@213 - int v60; // [sp-14h] [bp-C4h]@144 - int v61; // [sp-14h] [bp-C4h]@168 - AIDirection *v62; // [sp-14h] [bp-C4h]@213 - signed int v63; // [sp-14h] [bp-C4h]@216 + //signed int v59; // [sp-18h] [bp-C8h]@213 + //int v60; // [sp-14h] [bp-C4h]@144 + //int v61; // [sp-14h] [bp-C4h]@168 + //AIDirection *v62; // [sp-14h] [bp-C4h]@213 + //signed int v63; // [sp-14h] [bp-C4h]@216 unsigned int v64; // [sp-14h] [bp-C4h]@219 unsigned int v65; // [sp-10h] [bp-C0h]@144 char v66; // [sp-10h] [bp-C0h]@147 - AIDirection *v67; // [sp-10h] [bp-C0h]@167 - int v68; // [sp-10h] [bp-C0h]@168 - AIDirection *v69; // [sp-10h] [bp-C0h]@206 + //AIDirection *v67; // [sp-10h] [bp-C0h]@167 + //int v68; // [sp-10h] [bp-C0h]@168 + //AIDirection *v69; // [sp-10h] [bp-C0h]@206 int v70; // [sp-10h] [bp-C0h]@213 - AIDirection *v71; // [sp-10h] [bp-C0h]@216 + //AIDirection *v71; // [sp-10h] [bp-C0h]@216 AIDirection v72; // [sp+0h] [bp-B0h]@246 AIDirection a3; // [sp+1Ch] [bp-94h]@129 AIDirection v74; // [sp+38h] [bp-78h]@246 AIDirection v75; // [sp+54h] [bp-5Ch]@129 - int v76; // [sp+70h] [bp-40h]@83 + int target_pid_type; // [sp+70h] [bp-40h]@83 signed int a1; // [sp+74h] [bp-3Ch]@129 int v78; // [sp+78h] [bp-38h]@79 AIDirection pDir; // [sp+7Ch] [bp-34h]@129 float v80; // [sp+98h] [bp-18h]@33 int v81; // [sp+9Ch] [bp-14h]@100 - int v82; // [sp+A0h] [bp-10h]@45 + //int v82; // [sp+A0h] [bp-10h]@45 //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 unsigned int v84; // [sp+A8h] [bp-8h]@11 - signed int a2; // [sp+ACh] [bp-4h]@83 + signed int target_pid; // [sp+ACh] [bp-4h]@83 + AIState uAIState; + int v38; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - MakeActorAIList_ODM(); + MakeActorAIList_ODM(); else - MakeActorAIList_BLV(); + MakeActorAIList_BLV(); //v0 = 0; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) @@ -15196,7 +15176,7 @@ v3 = pParty->sRotationX + v1 % 16 - 8; pParty->sRotationX = v3; if ( v3 > 128 || (v2 = -128, v3 < -128) ) - pParty->sRotationX = v2; + pParty->sRotationX = v2; pParty->uFlags |= 2u; pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; v4 = pParty->field_16140 + 50; @@ -15218,13 +15198,13 @@ { if ( v7 >= 0 ) { - Actor::_4030AD(v84, 4, 0); + Actor::Stun(v84, 4, 0); } else { Actor::Die(v84); if ( v5->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); + GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); } } } @@ -15238,14 +15218,14 @@ { pPlayer = *v8; if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) - pPlayer->ReceiveDamage(v4, 5); + pPlayer->ReceiveDamage(v4, 5); ++v8; } while ( (signed int)v8 <= (signed int)&pPlayers[4] ); //v0 = 0; } if (pTurnEngine->field_1C) - --pTurnEngine->field_1C; + --pTurnEngine->field_1C; } } @@ -15268,10 +15248,10 @@ //v49 = *(unsigned int *)LODWORD(v80) == 5; ai_near_actors_targets_pid[i] = OBJECT_Player; if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) - continue; + continue; if (!actor->sCurrentHP && actor->uAIState != Dying) - Actor::Die(i); + Actor::Die(i); //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; @@ -15294,18 +15274,19 @@ ++v14; } while ( v13 < 22 );*/ - if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime) + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) - actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; - if (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime) - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - else - actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; + actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + // not sure + else if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; - if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || - actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) - continue; + if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 + || (signed __int64)actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) + continue; //v15 = pMiscTimer->uTimeElapsed; //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; @@ -15314,17 +15295,18 @@ if (actor->pMonsterInfo.uRecoveryTime) { if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) - actor->pMonsterInfo.uRecoveryTime = 0; - else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; + actor->pMonsterInfo.uRecoveryTime = 0; + else + actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; } actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; if (actor->uCurrentActionTime < actor->uCurrentActionLength) - continue; + continue; //v19 = actor->uAIState; if (actor->uAIState == Dying) - actor->uAIState = Dead; + actor->uAIState = Dead; else { if (actor->uAIState != Summoned) @@ -15360,559 +15342,445 @@ v21 = &pActors[actor_id]; Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - a2 = ai_near_actors_targets_pid[actor_id]; - v76 = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - v80 = 0.5; + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + target_pid = ai_near_actors_targets_pid[actor_id]; + target_pid_type = PID_TYPE(target_pid); + if ( target_pid_type == OBJECT_Actor) + v80 = 0.5; else - v80 = 1.0; + v80 = 1.0; v22 = v21->uAIState; if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) { continue; } - else - { - if ( !v21->sCurrentHP ) + if ( !v21->sCurrentHP ) Actor::Die(actor_id); - v25 = 0; - v26 = v21->pActorBuffs; - do + for(int i=0;i<22;i++) + { + if ( i != 10 ) { - if ( v25 != 10 ) - { - v26->_4585CA(pParty->uTimePlayed); - //v24 = 0; - } - ++v25; - ++v26; + v21->pActorBuffs[i]._4585CA(pParty->uTimePlayed); } - while ( v25 < 22 ); - if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) ) + } + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight; - if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 ) - { - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - { - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; - } - } - if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) ) - { - v21->uAIState = Removed; - continue; - } - else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime ) + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + // not sure + else if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; + if ( (signed __int64)v21->pActorBuffs[2].uExpireTime < 0 ) + { + v21->uAIState = Removed; + continue; + } + if ( (signed __int64)v21->pActorBuffs[5].uExpireTime > 0 + || (signed __int64)v21->pActorBuffs[6].uExpireTime > 0) + { + continue; + } + v27 = pMiscTimer->uTimeElapsed; + v28 = v21->pMonsterInfo.uRecoveryTime; + v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if ( (signed int)v28 > 0 ) + v21->pMonsterInfo.uRecoveryTime = v28 - v27; + if ( v21->pMonsterInfo.uRecoveryTime < 0 ) + v21->pMonsterInfo.uRecoveryTime = 0; + if ( !(v21->uAttributes & 0x8000) ) + v21->uAttributes |= 0x8000; + a1 = PID(OBJECT_Actor,actor_id); + v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); + memcpy(&v75, v30, sizeof(v75)); + memcpy(&pDir, &v75, sizeof(pDir)); + uAIState = v21->uAIState; + /*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly + && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 + && v80 * 307.2 >= (double)(signed int)v75.uDistance + && (uAIState == Pursuing || uAIState == Standing || uAIState == Tethered || uAIState == Fidgeting) + || ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) ) + { + v32 = actor_id; + } + else + */ + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly + || (signed int)v21->pMonsterInfo.uRecoveryTime > 0 + || v80 * 307.2 < (double)(signed int)v75.uDistance + || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting + && !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) + { + if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) { continue; } - else + else if ( v21->uAIState == AttackingMelee ) + { + v35 = stru_50C198.special_ability_use_check(v21, actor_id); + stru_50FE08.Add( + a1, + 5120, + v21->vPosition.x, + v21->vPosition.y, + v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), + v35, + 1 + ); + } + else if ( v21->uAIState == AttackingRanged1 ) { - v27 = pMiscTimer->uTimeElapsed; - v28 = v21->pMonsterInfo.uRecoveryTime; - v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v28 > 0 ) - v21->pMonsterInfo.uRecoveryTime = v28 - v27; - if ( v21->pMonsterInfo.uRecoveryTime< 0 ) - v21->pMonsterInfo.uRecoveryTime = 0; - v29 = v21->uAttributes; - if ( !(v29 & 0x8000) ) - v21->uAttributes = v29 | 0x8000; - a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0); - v49 = v21->pMonsterInfo.uHostilityType == 0; - memcpy(&v75, v30, sizeof(v75)); - memcpy(&pDir, &v75, sizeof(pDir)); - if ( !v49 - && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 - && v80 * 307.2 >= (double)(signed int)v75.uDistance - && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9) - || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 ) - { - v32 = actor_id; - } - else - { - if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) - { - continue; - } - else if ( v21->uAIState == 2 ) - { - v32 = actor_id; - v35 = stru_50C198.special_ability_use_check(v21, actor_id); - stru_50FE08.Add( - a1, - 5120, - v21->vPosition.x, - v21->vPosition.y, - v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), - v35, - 1 - ); - } - else if ( v21->uAIState == 3 ) - { - v34 = v21->pMonsterInfo.uMissleAttack1Type; - v66 = 0; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else if ( v21->uAIState == 12 ) - { - v34 = v21->pMonsterInfo.uMissleAttack2Type; - v66 = 1; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else - { - v32 = actor_id; - if ( v21->uAIState == 13 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; - v60 = 2; - v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - else if ( v21->uAIState == 18 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; - v60 = 3; - v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - } - } + v34 = v21->pMonsterInfo.uMissleAttack1Type; + Actor::RangedAttack(actor_id, &pDir, v34, 0); + } + else if ( v21->uAIState == AttackingRanged2 ) + { + v34 = v21->pMonsterInfo.uMissleAttack2Type; + Actor::RangedAttack(actor_id, &pDir, v34, 1); + } + else if ( v21->uAIState == AttackingRanged3 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; + v33 = v21->pMonsterInfo.uSpell1ID; + Actor::SpellAttack(actor_id, &pDir, v33, 2, v65); + } + else if ( v21->uAIState == AttackingRanged4 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; + v33 = v21->pMonsterInfo.uSpell2ID; + Actor::SpellAttack(actor_id, &pDir, v33, 3, v65); } } + v36 = v75.uDistance; - if ( !v21->pMonsterInfo.uHostilityType ) + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) { - if ( v76 == 3 ) + if ( target_pid_type == OBJECT_Actor ) { v36 = v75.uDistance; v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] - + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3); + + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); } else { v37 = 4; } + v38=0; if ( v37 == 2 ) { - v39 = __OFSUB__(v36, 1024); - v38 = ((v36 - 1024) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 1024); + //v38 = ((v36 - 1024) & 0x80000000u) != 0; + v38 = 1024; } else if ( v37 == 3 ) { - v39 = __OFSUB__(v36, 2560); - v38 = ((v36 - 2560) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 2560); + //v38 = ((v36 - 2560) & 0x80000000u) != 0; + v38 = 2560; } else if ( v37 == 4 ) { - v39 = __OFSUB__(v36, 5120); - v38 = ((v36 - 5120) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 5120); + //v38 = ((v36 - 5120) & 0x80000000u) != 0; + v38 = 5120; } - if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 ) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } + if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 ) { - v40 = a2; - v41 = v32; if ( (signed int)v36 >= 10240 ) { - v68 = 0; - v61 = 1024; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, target_pid, 1024, 0); } - v67 = &pDir; - Actor::_402968(v41, v40, 0, v67); + else + { + //peasents after attacked + //guard after attacked + Actor::Flee(actor_id, target_pid, 0, &pDir); + } continue; } - if ( v21->pMonsterInfo.uHostilityType == 4 && a2 ) + + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) { - if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 ) + + if ( v21->pMonsterInfo.uAIType == 1 ) { - if ( v21->pMonsterInfo.uAIType == 1 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v67 = &pDir; - if ( v21->pMonsterInfo.uMovementType != 5 ) - { - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); - continue; - } - Actor::AI_Stand( - v32, - a2, - (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), - &pDir); + Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); } else { + Actor::Flee(actor_id, target_pid, 0, &pDir); + continue; + } + + } + if ( !(v21->uAttributes & 0x020000) ) + { + if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3) + { if ( v21->pMonsterInfo.uAIType == 2 ) - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2; - } - else - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; + if ( v21->pMonsterInfo.uAIType == 3 ) v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1; - } - if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 ) + v84 = v21->sCurrentHP; + v42 = (double)(signed int)v84; if ( v43 > v42 && (signed int)v36 < 10240 ) { - v67 = &pDir; - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); + Actor::Flee(actor_id, target_pid, 0, &pDir); continue; } } } + v81 = v36 - v21->uActorRadius; - if ( v76 == 3 ) - v81 -= pActors[a2 >> 3].uActorRadius; + if ( target_pid_type == OBJECT_Actor ) + v81 -= pActors[PID_ID(target_pid)].uActorRadius; if ( v81 < 0 ) - v81 = 0; + v81 = 0; rand(); - v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0; v21->uAttributes &= 0xFBFFFF; - v82 = 0; - v49 = v21->pMonsterInfo.uMovementType == 5; - v84 = v44; - if ( v49 ) - v82 = 1; if ( v81 < 5120 ) { - v45 = stru_50C198.special_ability_use_check(v21, v32); - if ( !v45 ) + v45 = stru_50C198.special_ability_use_check(v21, actor_id); + if ( v45 == 0 ) { if ( v21->pMonsterInfo.uMissleAttack1Type ) { - if ( v84 ) + if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - Actor::_403476(v32, a2, &pDir); - continue; - + Actor::MissileAttack1(actor_id, target_pid, &pDir); } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + if ( v80 * 307.2 > (double)v81 ) + { + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + } } - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) + } + else + { + v56 = v80 * 307.2; + if ( (double)v81 >= v56 ) { - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; - } - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) - { - if ( v81 >= 1024 ) - { - if ( v82 ) + if ( v81 >= 1024 ) { - v69 = &pDir; + if ( v21->pMonsterInfo.uMovementType == 5 ) + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + //monsters + Actor::Pursue3(actor_id, target_pid, 0, &pDir); + } + } + else if ( v21->pMonsterInfo.uMovementType == 5 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 0; - - Actor::_402686(v32, a2, v63, v71); - continue; + else + { + v70 = (signed __int64)v56; + //monsters + //guard after player runs away + // follow player + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - if ( v82 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; + else + { + //monsters + Actor::MeleeAttack(actor_id, target_pid, &pDir); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) - { - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); continue; } - if ( v45 != 1 ) + else if ( v45 == 2 || v45 == 3 ) { - if ( v45 > 1 && v45 <= 3 ) + if ( v45 == 2 ) + v46 = v21->pMonsterInfo.uSpell1ID; + else + v46 = v21->pMonsterInfo.uSpell2ID; + if ( v46 ) { - if ( v45 == 2 ) - v46 = v21->pMonsterInfo.uSpell1ID; - else - v46 = v21->pMonsterInfo.uSpell2ID; - if ( v46 ) + if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - if ( v84 ) - { - if ( v45 == 2 ) - Actor::_403854(v32, a2, &pDir); - else - Actor::_403A60(v32, a2, &pDir); - continue; - } - if ( v80 * 307.2 > (double)v81 || v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - - } - v69 = &pDir; + if ( v45 == 2 ) + Actor::SpellAttack1(actor_id, target_pid, &pDir); + else + Actor::SpellAttack2(actor_id, target_pid, &pDir); + } + else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } + else + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + } + } + else + { v48 = v80 * 307.2; if ( (double)v81 >= v48 ) { if ( v81 >= 1024 ) { - v50 = v82 == 0; - if ( !v50 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; - + else + { + Actor::Pursue3(actor_id, target_pid, 256, &pDir); + } } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v48; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; + else + { + v70 = (signed __int64)v48; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - Actor::_403C6C(v32, a2, &pDir); - continue; + else + { + Actor::MeleeAttack(actor_id, target_pid, &pDir); + } } + continue; } } } - if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 ) + + if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) { if ( !v21->pMonsterInfo.uMovementType ) { - v68 = 0; - v61 = 1024; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - + Actor::_4032B2(actor_id, 4, 1024, 0); } - if ( v21->pMonsterInfo.uMovementType == 1 ) + else if ( v21->pMonsterInfo.uMovementType == 1 ) { - v68 = 0; - v61 = 2560; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 2560, 0); } - if ( v21->pMonsterInfo.uMovementType == 2 ) + else if ( v21->pMonsterInfo.uMovementType == 2 ) { - v68 = 0; - v61 = 5120; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 5120, 0); } - if ( v21->pMonsterInfo.uMovementType == 4 ) + else if ( v21->pMonsterInfo.uMovementType == 4 ) { - v68 = 0; - v61 = 10240; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 10240, 0); } - if ( v21->pMonsterInfo.uMovementType == 5 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; memcpy(&v74, v57, sizeof(v74)); memcpy(&pDir, &v74, sizeof(pDir)); - v69 = &pDir; - v52 = actor_id; v64 = (signed __int64)v58; - v51 = 4; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - continue; - + Actor::AI_Stand(actor_id, 4, v64, &pDir); + } } - if ( !v21->pMonsterInfo.uMissleAttack2Type ) + else if ( !v21->pMonsterInfo.uMissleAttack2Type ) { v56 = v80 * 307.2; if ( (double)v81 >= v56 ) { if ( v81 >= 1024 ) { - v50 = v82 == 0; - if ( !v50 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; + else + { + Actor::Pursue3(actor_id, target_pid, 256, &pDir); + } } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; - + else + { + v70 = (signed __int64)v56; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); - continue; - } - if ( !v84 ) - { - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::MeleeAttack(actor_id, target_pid, &pDir); } + } + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) + if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) { - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; } - Actor::_40368B(v32, a2, &pDir); + else + { + Actor::MissileAttack2(actor_id, target_pid, &pDir); + } } } } @@ -15989,10 +15857,10 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == OBJECT_Actor ) - { - v3 = &pActors[v2->uPackedID >> 3]; - v4 = &pActors[v2->uPackedID >> 3]; + if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) + { + v3 = &pActors[PID_ID(v2->uPackedID)]; + v4 = &pActors[PID_ID(v2->uPackedID)]; LOBYTE(v4->uAttributes) |= 0x80u; if ( !v4->CanAct() ) { @@ -16001,7 +15869,7 @@ LOBYTE(v3->uAttributes) &= 0x7Fu; } } - if ( (v2->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) { v5 = &pParty->pPlayers[v2->uPackedID >> 3]; if ( v5->pConditions[14] @@ -16037,8 +15905,8 @@ v10 = v7->field_4; if ( v9 < v10 || v9 == v10 - && ((v11 = v8->uPackedID & 7, v11 == OBJECT_Player) && (v7->uPackedID & 7) == OBJECT_Actor - || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) + && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor + || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) { v12 = v7->uPackedID; v13 = v7->field_4; @@ -16066,9 +15934,9 @@ } v1->uActorQueueSize = v19; result = v1->pQueue[0].uPackedID; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) - { - result = (result >> 3) + 1; + if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + { + result = PID_ID(result) + 1; uActiveCharacter = result; v1->field_18 |= 4u; } @@ -16083,8 +15951,8 @@ v17 = v1->pQueue; do { - if ( (v17->uPackedID & 7) == OBJECT_Player) - pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); + if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) + pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17; result = v22; @@ -16164,7 +16032,7 @@ { if ( v40->CanAct() ) { - *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = 8 * v3 | OBJECT_Player; + *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = PID(OBJECT_Player,v3); v1->pQueue[v1->uActorQueueSize].field_C = 2; v1->pQueue[v1->uActorQueueSize].uActionLength = 0; pParty->pTurnBasedPlayerRecoveryTimes[v1->uActorQueueSize++] = 0; @@ -16194,8 +16062,8 @@ v8 = ai_near_actors_targets_pid[v5]; LOBYTE(v7) = v7 | 0x80; v6->uAttributes = v7; - v33 = 8 * v5 | OBJECT_Actor; - memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31)); + v33 = PID(OBJECT_Actor,v5); + memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,v5), v8, &a3, 0), sizeof(v31)); memcpy(&v30, &v31, sizeof(v30)); Actor::AI_StandOrBored(v37, 4, 32, &v30); *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33; @@ -16221,7 +16089,7 @@ v12 = (char *)&v1->pQueue[0].field_4; while ( 1 ) { - v13 = *((int *)v12 - 1) & 7; + v13 = PID_TYPE(*((int *)v12 - 1)); if ( v13 != OBJECT_Player ) break; v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery;