Mercurial > mm7
diff mm7_6.cpp @ 295:640a176c030f
sub_42ECB5
author | Nomad |
---|---|
date | Tue, 19 Feb 2013 13:29:02 +0200 |
parents | 1f0af5cac2dd |
children | 3dcc9d945eeb |
line wrap: on
line diff
--- a/mm7_6.cpp Mon Feb 18 16:39:49 2013 +0600 +++ b/mm7_6.cpp Tue Feb 19 13:29:02 2013 +0200 @@ -7837,39 +7837,39 @@ //unsigned int v0; // ebx@1 //Player *v1; // esi@1 //bool result; // eax@1 - int v3; // edi@2 + //int v3; // edi@2 //unsigned int v4; // eax@7 char *v5; // eax@8 //int v6; // ecx@9 //signed int v7; // eax@16 - Actor *v8; // edi@20 + //Actor *v8; // edi@20 unsigned int v9; // ecx@21 - char *v10; // eax@26 + //char *v10; // eax@26 char *v11; // eax@26 unsigned int v12; // eax@47 - char *v13; // eax@47 - char *v14; // eax@47 - unsigned int v15; // ebx@54 - int v16; // [sp-10h] [bp-4Ch]@24 - int v17; // [sp-10h] [bp-4Ch]@44 - unsigned int v18; // [sp-Ch] [bp-48h]@24 - unsigned int v19; // [sp-Ch] [bp-48h]@44 - __int16 v20; // [sp-8h] [bp-44h]@24 - __int16 v21; // [sp-8h] [bp-44h]@44 - int v22; // [sp-4h] [bp-40h]@24 - int v23; // [sp-4h] [bp-40h]@44 + //char *v13; // eax@47 + //char *v14; // eax@47 + //unsigned int v15; // ebx@54 + //int v16; // [sp-10h] [bp-4Ch]@24 + //int v17; // [sp-10h] [bp-4Ch]@44 + //unsigned int v18; // [sp-Ch] [bp-48h]@24 + //unsigned int v19; // [sp-Ch] [bp-48h]@44 + //__int16 v20; // [sp-8h] [bp-44h]@24 + //__int16 v21; // [sp-8h] [bp-44h]@44 + //int v22; // [sp-4h] [bp-40h]@24 + //int v23; // [sp-4h] [bp-40h]@44 SoundID v24; // [sp-4h] [bp-40h]@58 - Vec3_int_ a3; // [sp+Ch] [bp-30h]@19 + //Vec3_int_ a3; // [sp+Ch] [bp-30h]@19 //unsigned int a2; // [sp+18h] [bp-24h]@20 //unsigned int v27; // [sp+1Ch] [bp-20h]@1 - int v28; // [sp+20h] [bp-1Ch]@9 + //int v28; // [sp+20h] [bp-1Ch]@9 //unsigned int *v28b; - int v29; // [sp+24h] [bp-18h]@16 - int v30; // [sp+28h] [bp-14h]@16 + //int v29; // [sp+24h] [bp-18h]@16 + //int v30; // [sp+28h] [bp-14h]@16 //int v31; // [sp+2Ch] [bp-10h]@4 - int v32; // [sp+30h] [bp-Ch]@7 + //int v32; // [sp+30h] [bp-Ch]@7 //int v33; // [sp+34h] [bp-8h]@7 - int v34; // [sp+38h] [bp-4h]@17 + //int v34; // [sp+38h] [bp-4h]@17 //v0 = uActiveCharacter; //v27 = 6972 * uActiveCharacter; @@ -7880,7 +7880,7 @@ return; pStru277->_427D48(uActiveCharacter); - v3 = 0; + //v3 = 0; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -7889,7 +7889,8 @@ if (bow_idx && player->pInventoryItems[bow_idx - 1].Broken()) bow_idx = 0; - v32 = 0; + //v32 = 0; + int wand_item_id = 0; //v33 = 0; //v4 = v1->pEquipment.uMainHand; int laser_weapon_item_id = 0; @@ -7903,21 +7904,21 @@ { //v28b = &v1->pInventoryItems[v4].uItemID; //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); - if (pItemsTable->pItems[item->uItemID].uEquipType == EQUIP_C) + if (pItemsTable->pItems[item->uItemID].uEquipType == EQUIP_WAND) { - if (item->_bonus_type <= 0) - player->pEquipment.uMainHand = 0; + if (item->uNumCharges <= 0) + player->pEquipment.uMainHand = 0; // wand discharged - unequip else - v32 = item->uItemID;//*((int *)v5 + 124); + wand_item_id = item->uItemID;//*((int *)v5 + 124); } else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE) laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124); } } - v30 = 0; - v29 = 0; - v28 = 0; + //v30 = 0; + //v29 = 0; + //v28 = 0; //v7 = pMouse->uPointingObjectID; int target_pid = pMouse->uPointingObjectID; @@ -7929,199 +7930,122 @@ target_type = target_pid & 7; target_id = target_pid >> 3; } - - - a3.z = 0; - a3.y = 0; - a3.x = 0; + + auto actor = &pActors[target_id]; + int actor_distance = 0; if (target_type == OBJECT_Actor) { - //a2 = target_id; - v8 = &pActors[target_id]; - int distance_x = v8->vPosition.x - pParty->vPosition.x, - distance_y = v8->vPosition.y - pParty->vPosition.y, - distance_z = v8->vPosition.z - pParty->vPosition.z; - v34 = sub_452A9E(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - v8->uActorRadius; - if ( v34 >= 0 ) - { - v9 = 0; - } - else - { - v9 = 0; - v34 = 0; - } - if ( laser_weapon_item_id != v9 ) - { - v28 = 1; - v22 = uActiveCharacter + 8; - v20 = v9; - v18 = v9; - v16 = 102; -LABEL_34: - _42777D_CastSpell_UseWand_ShootArrow(v16, uActiveCharacter - 1, v18, v20, v22); -LABEL_28: - v3 = 0; - goto LABEL_29; - } - if ( v32 != v9 ) + int distance_x = actor->vPosition.x - pParty->vPosition.x, + distance_y = actor->vPosition.y - pParty->vPosition.y, + distance_z = actor->vPosition.z - pParty->vPosition.z; + actor_distance = integer_sqrt(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - actor->uActorRadius; + if (actor_distance < 0) + actor_distance = 0; + } + + bool shooting_bow = false, + shotting_laser = false, + shooting_wand = false; + if (laser_weapon_item_id) + { + shotting_laser = true; + _42777D_CastSpell_UseWand_ShootArrow(102, uActiveCharacter - 1, 0, 0, uActiveCharacter + 8); + } + else if (wand_item_id) + { + shooting_wand = true; + + int main_hand_idx = player->pEquipment.uMainHand; + _42777D_CastSpell_UseWand_ShootArrow(*((int *)&pSpellDatas[66].field_8 + player->pInventoryItems[main_hand_idx - 1].uItemID), uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); + + if (!--player->pInventoryItems[main_hand_idx - 1].uNumCharges) + player->pEquipment.uMainHand = 0; + } + else if (target_type == OBJECT_Actor) + { + if (actor_distance <= 407.2) + { + Vec3_int_ a3; + a3.x = actor->vPosition.x - pParty->vPosition.x; + a3.y = actor->vPosition.y - pParty->vPosition.y; + a3.z = actor->vPosition.z - pParty->vPosition.z; + Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); + + DamageMonsterFromParty((8 * uActiveCharacter - 8) | OBJECT_Player, target_id, &a3); + if (player->WearsItem(506, 1) || player->WearsItem(506, 0)) + _42FA66_do_explosive_impact( + actor->vPosition.x, + actor->vPosition.y, + actor->vPosition.z + actor->uActorHeight / 2, + 0, 512, uActiveCharacter); + } + else if (bow_idx) + { + shooting_bow = true; + + _42777D_CastSpell_UseWand_ShootArrow(100, uActiveCharacter - 1, 0, 0, 0); + if (!pParty->bTurnBasedModeOn) { - v29 = 1; - _42777D_CastSpell_UseWand_ShootArrow( - *((int *)&pSpellDatas[66].field_8 - + *(int *)(&stru_AA1058[3].pSounds[36 * *(int *)&pParty->pArtifactsFound[6972 * uActiveCharacter + 22] + 41048] + 6972 * uActiveCharacter)), - uActiveCharacter - 1, - 8u, - v9, - uActiveCharacter + 8); - v10 = &player->field_1F5[36 * player->pEquipment.uMainHand + 11]; - --*(int *)v10; - v11 = (char *)player + 36 * player->pEquipment.uMainHand; - if ( *((int *)v11 + 128) <= 0 ) - { - *((int *)v11 + 124) = 0; - player->pEquipment.uMainHand = 0; - } - goto LABEL_28; + int recovery = player->GetAttackRecoveryTime(0); + if (recovery < 30) + recovery = 30; + player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333); } - if ( (double)v34 <= 407.2 ) - { - a3.x = v8->vPosition.x - pParty->vPosition.x; - a3.y = v8->vPosition.y - pParty->vPosition.y; - a3.z = v8->vPosition.z - pParty->vPosition.z; - Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); - DamageMonsterFromParty((8 * uActiveCharacter - 8) | OBJECT_Player, target_id, &a3); - if ( player->WearsItem(506, 1) || player->WearsItem(506, 0) ) - _42FA66_do_explosive_impact( - v8->vPosition.x, - v8->vPosition.y, - v8->vPosition.z + v8->uActorHeight / 2, - 0, - 512, - uActiveCharacter); - } - else - { - if ( bow_idx != v9 ) - { - v30 = 1; - v22 = 0; - v20 = 0; - v18 = 0; - v16 = 100; - goto LABEL_34; - } - } - v3 = 0; - goto LABEL_39; } - - if ( laser_weapon_item_id ) + } + else + { + if (bow_idx) { - v28 = 1; - v23 = uActiveCharacter + 8; - v21 = 0; - v19 = 0; - v17 = 102; + shooting_bow = true; + _42777D_CastSpell_UseWand_ShootArrow(100, uActiveCharacter - 1, 0, 0, 0); } else { - if ( v32 ) + if (!pParty->bTurnBasedModeOn) { - v12 = player->pEquipment.uMainHand; - v29 = 1; - _42777D_CastSpell_UseWand_ShootArrow( - *((int *)&pSpellDatas[66].field_8 + *(int *)&player->pInventoryItems[v12-1]), - uActiveCharacter - 1, - 8u, - 0, - uActiveCharacter + 8); - v13 = &player->field_1F5[36 * player->pEquipment.uMainHand + 11]; - --*(int *)v13; - v14 = (char *)player + 36 * player->pEquipment.uMainHand; - if ( *((int *)v14 + 128) <= 0 ) - { - *((int *)v14 + 124) = 0; - player->pEquipment.uMainHand = 0; - } -LABEL_29: - v34 = v3; - if ( v30 == v3 ) - { - if ( v29 != v3 ) - return; - if ( v28 == v3 ) - { - v15 = player->pEquipment.uMainHand; - if ( player->HasItemEquipped(EQUIP_TWO_HANDED) ) - v34 = pItemsTable->pItems[*(int *)&player->pInventoryItems[v15-1]].uSkillType; - pTurnEngine->_40471C(); - } - else - { - v34 = 7; - } - } - else - { - v34 = 5; - player->PlaySound(SPEECH_50, v3); - } - switch ( v34 ) - { - case 0: - v24 = (SoundID)81; - goto LABEL_66; - case 1: - v24 = (SoundID)84; - goto LABEL_66; - case 2: - v24 = (SoundID)85; - goto LABEL_66; - case 3: - v24 = (SoundID)78; - goto LABEL_66; - case 4: - v24 = (SoundID)80; - goto LABEL_66; - case 5: - v24 = (SoundID)71; - goto LABEL_66; - case 6: - v24 = (SoundID)83; - goto LABEL_66; - case 7: - v24 = (SoundID)67; -LABEL_66: - pAudioPlayer->PlaySound(v24, v3, v3, -1, v3, v3, v3, v3); - break; - default: - return; - } - return; + int recovery = player->GetAttackRecoveryTime(0); + if (recovery < 30 ) + recovery = 30; + player->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333)); } - if ( !bow_idx ) - { -LABEL_39: - int v31 = player->GetAttackRecoveryTime(v3); - if ( v31 < 30 ) - v31 = 30; - if ( pParty->bTurnBasedModeOn == v3 ) - player->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v31 * 2.133333333333333)); - goto LABEL_29; - } - v23 = 0; - v21 = 0; - v19 = 0; - v30 = 1; - v17 = 100; } - _42777D_CastSpell_UseWand_ShootArrow(v17, uActiveCharacter - 1, v19, v21, v23); - goto LABEL_29; + } + + + int v34 = 0; + if (shooting_wand) + return; + else if (shooting_bow) + { + v34 = 5; + player->PlaySound(SPEECH_50, 0); + } + if (shotting_laser) + v34 = 7; + else + { + int main_hand_idx = player->pEquipment.uMainHand; + if (player->HasItemEquipped(EQUIP_TWO_HANDED)) + v34 = pItemsTable->pItems[*(int *)&player->pInventoryItems[main_hand_idx - 1]].uSkillType; + pTurnEngine->_40471C(); + } + + switch (v34) + { + case 0: pAudioPlayer->PlaySound(SOUND_81, 0, 0, -1, 0, 0, 0, 0); break; + case 1: pAudioPlayer->PlaySound(SOUND_84, 0, 0, -1, 0, 0, 0, 0); break; + case 2: pAudioPlayer->PlaySound(SOUND_85, 0, 0, -1, 0, 0, 0, 0); break; + case 3: pAudioPlayer->PlaySound(SOUND_78, 0, 0, -1, 0, 0, 0, 0); break; + case 4: pAudioPlayer->PlaySound(SOUND_80, 0, 0, -1, 0, 0, 0, 0); break; + case 5: pAudioPlayer->PlaySound(SOUND_71, 0, 0, -1, 0, 0, 0, 0); break; + case 6: pAudioPlayer->PlaySound(SOUND_83, 0, 0, -1, 0, 0, 0, 0); break; + case 7: pAudioPlayer->PlaySound(SOUND_67, 0, 0, -1, 0, 0, 0, 0); break; + } } //----- (0042F184) -------------------------------------------------------- -int stru319::FindClosestActor(int a2, int a3, int a4) +int stru319::FindClosestActor(int pick_depth, int a3, int a4) { int v4; // edi@1 stru319 *v5; // esi@1 @@ -8161,9 +8085,10 @@ v6 = a3 != 0; if ( a4 ) LOBYTE(v6) = v6 | 8; - v7 = pGame->pVisInstance->_4C1944(OBJECT_Actor, a2, v6, 657456, -1); + v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); if ( v7 != -1 ) return (unsigned __int16)v7; + else return 0; } else { @@ -8201,7 +8126,7 @@ && (!a3 || pActors[(unsigned int)v11 >> 3].GetActorsRelation(0)) ) { if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) - && v22 <= a2 << 16 ) + && v22 <= pick_depth << 16 ) { v14 = 0; if ( v10 > 0 )