Mercurial > mm7
diff mm7_3.cpp @ 848:ceef50611567
* AI fixed (temporary)
* PID_ID, PID_TYPE replaces
* >> 7 error in AudioPlayer
author | zipi |
---|---|
date | Sun, 31 Mar 2013 10:44:43 +0100 |
parents | 39503542470c |
children | 8fafe3645f36 cb0b3badc7f7 |
line wrap: on
line diff
--- a/mm7_3.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_3.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -898,9 +898,9 @@ //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,8 +913,8 @@ 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 v52; // zf@87 + //unsigned __int8 v53; // sf@87 // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 @@ -1139,8 +1139,7 @@ { 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; @@ -1167,7 +1166,7 @@ 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; + v39 = PID_ID(v38); switch ( PID_TYPE(v38) ) { case OBJECT_Actor: @@ -1207,8 +1206,8 @@ Actor::FaceObject(v75, v38, 0, (AIDirection *)0); break; } - v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; - v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; + //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) ) @@ -1372,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; @@ -1915,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)) ) @@ -1923,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; @@ -1935,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; @@ -2839,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(); @@ -2847,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; @@ -2868,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]; @@ -12788,7 +12787,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; } @@ -15143,7 +15142,7 @@ AIDirection a3; // [sp+1Ch] [bp-94h]@129 AIDirection v74; // [sp+38h] [bp-78h]@246 AIDirection v75; // [sp+54h] [bp-5Ch]@129 - int actor_pid_type; // [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 @@ -15152,7 +15151,7 @@ //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 actor_pid; // [sp+ACh] [bp-4h]@83 + signed int target_pid; // [sp+ACh] [bp-4h]@83 AIState uAIState; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) @@ -15342,9 +15341,9 @@ 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; - actor_pid = ai_near_actors_targets_pid[actor_id]; - actor_pid_type = PID_TYPE(actor_pid); - if ( actor_pid_type == OBJECT_Actor) + 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; @@ -15389,7 +15388,7 @@ if ( !(v21->uAttributes & 0x8000) ) v21->uAttributes |= 0x8000; a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, actor_pid, &a3, 0); + v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, target_pid, &a3, 0); memcpy(&v75, v30, sizeof(v75)); memcpy(&pDir, &v75, sizeof(pDir)); uAIState = v21->uAIState; @@ -15400,13 +15399,14 @@ || ( 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 ) - //else { if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) { @@ -15435,31 +15435,28 @@ v34 = v21->pMonsterInfo.uMissleAttack2Type; Actor::_404874(actor_id, &pDir, v34, 1); } - else + else if ( v21->uAIState == AttackingRanged3 ) { - if ( v21->uAIState == AttackingRanged3 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; - v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, 2, v65); - } - else if ( v21->uAIState == AttackingRanged4 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; - v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, 3, v65); - } + v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; + v33 = v21->pMonsterInfo.uSpell1ID; + Actor::_404AC7(actor_id, &pDir, v33, 2, v65); + } + else if ( v21->uAIState == AttackingRanged4 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; + v33 = v21->pMonsterInfo.uSpell2ID; + Actor::_404AC7(actor_id, &pDir, v33, 3, v65); } } v36 = v75.uDistance; if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) { - if ( actor_pid_type == OBJECT_Actor ) + if ( target_pid_type == OBJECT_Actor ) { v36 = v75.uDistance; v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] - + (pActors[actor_pid >> 3].pMonsterInfo.uID - 1) / 3); + + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); } else { @@ -15488,29 +15485,29 @@ { if ( (signed int)v36 >= 10240 ) { - Actor::_4032B2(actor_id, actor_pid, 1024, 0); + Actor::_4032B2(actor_id, target_pid, 1024, 0); } else { //peasents after attacked //guard after attacked - Actor::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); } continue; } - if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && actor_pid ) + if ( /*v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long &&*/ target_pid ) // temporary { if ( v21->pMonsterInfo.uAIType == 1 ) { if ( v21->pMonsterInfo.uMovementType == 5 ) { - Actor::AI_Stand(actor_id, actor_pid, (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::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); continue; } @@ -15527,15 +15524,15 @@ v42 = (double)(signed int)v84; if ( v43 > v42 && (signed int)v36 < 10240 ) { - Actor::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); continue; } } } v81 = v36 - v21->uActorRadius; - if ( actor_pid_type == OBJECT_Actor ) - v81 -= pActors[actor_pid >> 3].uActorRadius; + if ( target_pid_type == OBJECT_Actor ) + v81 -= pActors[PID_ID(target_pid)].uActorRadius; if ( v81 < 0 ) v81 = 0; rand(); @@ -15549,13 +15546,13 @@ { if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - Actor::_403476(actor_id, actor_pid, &pDir); + Actor::_403476(actor_id, target_pid, &pDir); } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { @@ -15563,10 +15560,10 @@ if ( !(v54 | v55) ) { v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); continue; } - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else @@ -15580,19 +15577,19 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { //monsters - Actor::_402686(actor_id, actor_pid, 0, &pDir); + Actor::_402686(actor_id, target_pid, 0, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { @@ -15600,19 +15597,19 @@ //monsters //guard after player runs away // follow player - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { //monsters - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } continue; @@ -15628,20 +15625,20 @@ if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { if ( v45 == 2 ) - Actor::_403854(actor_id, actor_pid, &pDir); + Actor::_403854(actor_id, target_pid, &pDir); else - Actor::_403A60(actor_id, actor_pid, &pDir); + Actor::_403A60(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; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else @@ -15655,34 +15652,34 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402686(actor_id, actor_pid, 256, &pDir); + Actor::_402686(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v70 = (signed __int64)v48; - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } continue; @@ -15690,7 +15687,7 @@ } } - if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !actor_pid || v81 >= 5120 || v45 != 1 ) + if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) { if ( !v21->pMonsterInfo.uMovementType ) { @@ -15729,34 +15726,34 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402686(actor_id, actor_pid, 256, &pDir); + Actor::_402686(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v70 = (signed __int64)v56; - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) @@ -15765,16 +15762,16 @@ if ( !(v54 | v55) || v21->pMonsterInfo.uMovementType == 5 ) { v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else { - Actor::_40368B(actor_id, actor_pid, &pDir); + Actor::_40368B(actor_id, target_pid, &pDir); } } } @@ -15852,10 +15849,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() ) { @@ -15864,7 +15861,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] @@ -15900,8 +15897,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; @@ -15929,7 +15926,7 @@ } v1->uActorQueueSize = v19; result = v1->pQueue[0].uPackedID; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) { result = (result >> 3) + 1; uActiveCharacter = result; @@ -15946,7 +15943,7 @@ v17 = v1->pQueue; do { - if ( (v17->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17; @@ -16084,7 +16081,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;