# HG changeset patch # User Ritor1 # Date 1384428309 -21600 # Node ID beb97b20c3eda0d91a333c23ca7d9a6e9f849e93 # Parent 03d9336e862f99a7ceb8145ec52b4d4af8f7887f ODM_ProcessPartyActions() continued refactoring diff -r 03d9336e862f -r beb97b20c3ed AudioPlayer.h --- a/AudioPlayer.h Wed Nov 13 17:41:12 2013 +0600 +++ b/AudioPlayer.h Thu Nov 14 17:25:09 2013 +0600 @@ -79,7 +79,7 @@ SOUND_8 = 0x8, SOUND_24 = 24, SOUND_error = 27, - SOUND_WalkingOnTo3DModel = 64, + SOUND_RunAlong3DModel = 64, SOUND_Button = 66, SOUND_67 = 67, SOUND_71 = 71, @@ -90,7 +90,7 @@ SOUND_83 = 83, SOUND_84 = 84, SOUND_85 = 85, - SOUND_WalkingBackTo3DModel = 103, + SOUND_WalkAlong3DModel = 103, SOUND_Arcomage_LoseResources = 0x78, SOUND_Arcomage_AddResources = 0x79, SOUND_Arcomage_TowerWallDamage = 0x7A, diff -r 03d9336e862f -r beb97b20c3ed Player.h --- a/Player.h Wed Nov 13 17:41:12 2013 +0600 +++ b/Player.h Thu Nov 14 17:25:09 2013 +0600 @@ -106,7 +106,7 @@ SPEECH_63 = 63, SPEECH_64 = 64, SPEECH_Yell = 65, - SPEECH_66 = 66, + SPEECH_Falling_scream = 66, SPEECH_67 = 67, SPEECH_68 = 68, SPEECH_69 = 69, diff -r 03d9336e862f -r beb97b20c3ed mm7_3.cpp --- a/mm7_3.cpp Wed Nov 13 17:41:12 2013 +0600 +++ b/mm7_3.cpp Thu Nov 14 17:25:09 2013 +0600 @@ -2120,7 +2120,7 @@ int v96; // [sp-4h] [bp-98h]@246 int v97; // [sp+Ch] [bp-88h]@180 Vec3_int_ v98; - bool v101; // [sp+1Ch] [bp-78h]@33 + bool high_fall_flag; // [sp+1Ch] [bp-78h]@33 int v102; // [sp+20h] [bp-74h]@1 int v103; // [sp+24h] [bp-70h]@1 int bFeatherFall; // [sp+28h] [bp-6Ch]@4 @@ -2129,9 +2129,9 @@ int v109; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 - int bJumping; // [sp+48h] [bp-4Ch]@1 + bool hovering; // [sp+48h] [bp-4Ch]@1 int v113; // [sp+4Ch] [bp-48h]@1 - unsigned int v114; // [sp+50h] [bp-44h]@1 + bool party_running_flag; // [sp+50h] [bp-44h]@1 int _walk_speed; // [sp+54h] [bp-40h]@48 int pX; // [sp+58h] [bp-3Ch]@1 int pY; // [sp+5Ch] [bp-38h]@1 @@ -2139,7 +2139,7 @@ int _angle_x; // [sp+68h] [bp-2Ch]@48 unsigned int v122; // [sp+70h] [bp-24h]@180 int pZ; // [sp+74h] [bp-20h]@1 - int v124; // [sp+78h] [bp-1Ch]@1 + bool party_walking_flag; // [sp+78h] [bp-1Ch]@1 int _angle_y; // [sp+7Ch] [bp-18h]@48 int v126; // [sp+80h] [bp-14h]@48 int v128; // [sp+88h] [bp-Ch]@1 @@ -2155,10 +2155,10 @@ pX = pParty->vPosition.x; pY = pParty->vPosition.y; v113 = pParty->field_6F0; - bJumping = 0; + hovering = false; bool partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); - v114 = 0; - v124 = 0; + party_running_flag = false; + party_walking_flag = false; v102 = 0; pModel = 0; bWaterWalk = 0; @@ -2205,15 +2205,12 @@ } else for (int _i = 0; _i < 4; ++_i) // receive falling damage { - Player* player = &pParty->pPlayers[_i]; - - if ( !player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) + if ( !pParty->pPlayers[_i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[_i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) { - player->ReceiveDamage( - (signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(player->GetMaxHealth() / 10)) / 256, - DMGT_PHISYCAL); - v105 = 20 - player->GetParameterBonus(player->GetActualEndurance()); - player->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); + pParty->pPlayers[_i].ReceiveDamage( + (signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(pParty->pPlayers[_i].GetMaxHealth() / 10)) / 256, DMGT_PHISYCAL); + v105 = 20 - pParty->pPlayers[_i].GetParameterBonus(pParty->pPlayers[_i].GetActualEndurance()); + pParty->pPlayers[_i].SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } //} //while ( (signed int)v4 <= (signed int)&pPlayers[4] ); @@ -2230,19 +2227,19 @@ pParty->bFlying = false; } else - { - bJumping = 1; - } - v101 = pZ - v111 <= 32; - if ( bWalkSound && pParty->walk_sound_timer) + hovering = true; + high_fall_flag = pZ - v111 > 32; + + if ( bWalkSound && pParty->walk_sound_timer)//timer update { if (pParty->walk_sound_timer >= pEventTimer->uTimeElapsed) pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } + if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) pParty->bFlying = false; - if (!bJumping) + if (!hovering) { if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) { @@ -2290,11 +2287,11 @@ pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 ) { - if ( pParty->vPosition.z < 4000 || bJumping ) + if ( pParty->vPosition.z < 4000 || hovering ) { pZ += 30; v113 += 30; - pParty->bFlying = 1; + pParty->bFlying = true; if ( pZ > 4000 ) { pZ = 4000; @@ -2326,7 +2323,7 @@ case PARTY_FlyDown: if (pParty->FlyActive() || bUnderwater) { - pParty->bFlying = 0; + pParty->bFlying = false; if ( bUnderwater || pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 10] > 0 ) @@ -2335,11 +2332,11 @@ v113 -= 30; pParty->uFallSpeed = 0; //pParty->uFallSpeed = 0; - pParty->bFlying = 1; + pParty->bFlying = true; pModel = (BSPModel *)1; if ( pZ <= v111 ) { - pParty->bFlying = 0; + pParty->bFlying = false; pPartyActionQueue->uNumActions = 0; } } @@ -2395,7 +2392,7 @@ v1 += 3 * dy / 4; v128 = v1; - v124 = 1; + party_walking_flag = true; } break; @@ -2412,7 +2409,7 @@ v1 -= 3 * dy / 4; v128 = v1; - v124 = 1; + party_walking_flag = true; } break; @@ -2424,13 +2421,13 @@ cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; - v2 += dx * 12; + v2 += dx;// * 12; int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; - v1 += dy * 12; + v1 += dy;// * 12; v128 = v1; - v124 = 1; + party_walking_flag = true; } break; @@ -2457,7 +2454,7 @@ v1 += dy; v128 = v1; - v124 = 1; + party_walking_flag = true; } else { @@ -2465,7 +2462,7 @@ v1 += 2 * dy; v128 = v1; - v114 = 1; + party_running_flag = true; } } break; @@ -2485,7 +2482,7 @@ v1 -= dy; v128 = v1; - v124 = 1; + party_walking_flag = true; } break; @@ -2510,7 +2507,7 @@ v1 -= dy; v128 = v1; - v124 = 1; + party_walking_flag = true; } } break; @@ -2536,10 +2533,10 @@ break; case PARTY_Jump: - if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; - bJumping = 1; + hovering = true; pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); } break; @@ -2594,7 +2591,7 @@ stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; } //LABEL_141: - if (bJumping && !pParty->bFlying) + if (hovering && !pParty->bFlying)//расчёт скорости падения { v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); v34 = pParty->uFallSpeed + 2 * v33; @@ -2604,7 +2601,7 @@ { v34 = pParty->uFallSpeed; } - else if (!bJumping) + else if (!hovering) { if ( !bmodel_standing_on_pid ) { @@ -2626,7 +2623,7 @@ v34 = pParty->uFallSpeed; //LABEL_164: - if(bJumping) + if ( hovering ) { if ( !bUnderwater && v34 <= 0) { @@ -2637,9 +2634,8 @@ { // falling scream for (int i = 0; i < 4; ++i) { - Player* player = &pParty->pPlayers[i]; - if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) && player->CanAct()) - player->PlaySound(SPEECH_66, 0); + if (!pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) && pParty->pPlayers[i].CanAct()) + pParty->pPlayers[i].PlaySound(SPEECH_Falling_scream, 0);//крик падения } } } @@ -2794,7 +2790,7 @@ { if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { - pParty->bFlying = 0; + pParty->bFlying = false; pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; //v127 = v46; pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; @@ -2916,70 +2912,58 @@ pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; } while ( v126 < 100 ); + if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { v122 = abs(pParty->vPosition.x - pX); v126 = abs(pParty->vPosition.y - pY); v62 = abs(pParty->vPosition.z - pZ); - if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) < 8 ) - { - pAudioPlayer->_4AA258(804); - pParty->walk_sound_timer = 64; - } - else - { - if ( v114 && (!bJumping || v101) ) - { - if ( !is_not_on_bmodel - && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) - { - pAudioPlayer->PlaySound(SOUND_WalkingOnTo3DModel, 804, 1, -1, 0, 0, 0, 0);//хождение вперёд на 3D Modelи - } - else - { - //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; - //v64 = WorldPosToGridCellX(pParty->vPosition.x); - v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); - pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//хождение по земле - } - } - else - { - if ( v124 && (!bJumping || v101) ) - { - if ( is_not_on_bmodel - || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) - { - //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; - //v64 = WorldPosToGridCellX(pParty->vPosition.x); - v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0); - pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);// при заднем ходе на земле - } - else - pAudioPlayer->PlaySound(SOUND_WalkingBackTo3DModel, 804, 1, -1, 0, 0, 0, 0);// при заднем ходе на 3D Modelи - } - else - { - pAudioPlayer->_4AA258(804); - pParty->walk_sound_timer = 64; - } - } + if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) >= 8 ) + { + if ( party_running_flag && (!hovering || !high_fall_flag) ) + { + if ( !is_not_on_bmodel + && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) + pAudioPlayer->PlaySound(SOUND_RunAlong3DModel, 804, 1, -1, 0, 0, 0, 0);//бег на 3D Modelи + else + { + v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); + pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//бег по земле + } + } + else if ( party_walking_flag && (!hovering || !high_fall_flag) ) + { + if ( is_not_on_bmodel + || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) + { + v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0); + pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);// хождение по земле + } + else + pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0);// хождение на 3D Modelи + } } - } - if ( !bJumping || v101 ) + else + { + pAudioPlayer->_4AA258(804); + pParty->walk_sound_timer = 64; + } + } + + if ( !hovering || !high_fall_flag ) pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; else pParty->uFlags |= PARTY_FLAGS_1_FALLING; v126 = WorldPosToGridCellX(pParty->vPosition.x); v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; - v114 = WorldPosToGridCellX(pX); + unsigned int v114_a = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, v65) >> 1) & 1; v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); v68 = 0; v69 = (~(unsigned int)v67 >> 1) & 1; - if ( v114 == v126 && v66 == v65 && v122 && v69 ) + if ( v114_a == v126 && v66 == v65 && v122 && v69 ) v68 = 1; if ( !is_not_on_bmodel ) v68 = 1; @@ -3044,12 +3028,12 @@ return; } v76 = pParty->bFlying; - if ( pParty->bFlying || v101 == 0 || bWaterWalk || !pModel ) + if ( pParty->bFlying || !high_fall_flag || bWaterWalk || !pModel ) v77 = 1; else v77 = v122 != 0; - v114 = 0; - if ( !pParty->bFlying && v101 != 0 && !bWaterWalk ) + bool party_drowning_flag = false; + if ( !pParty->bFlying && high_fall_flag && !bWaterWalk ) { if ( pModel ) { @@ -3057,7 +3041,7 @@ } else { - v114 = 1; + party_drowning_flag = true; v78 = 1; } } @@ -3110,7 +3094,7 @@ LOWORD(pParty->uFlags) &= 0xFDFBu; //pParty->uFallSpeed = v121; pParty->field_6F0 = v113; - if ( v114 )//party stand to the water(группа стоит на воде) + if ( party_drowning_flag ) { pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1); if ( pParty->vPosition.z <= pTerrainHeight + 1 )//положение группы всегда +1 diff -r 03d9336e862f -r beb97b20c3ed mm7_4.cpp --- a/mm7_4.cpp Wed Nov 13 17:41:12 2013 +0600 +++ b/mm7_4.cpp Thu Nov 14 17:25:09 2013 +0600 @@ -610,7 +610,7 @@ { // colliding with something in the air - fall down v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; //__debugbreak(); - v6 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 2000]; + v6 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 2000]; v7 = *v6 < v5; *v6 -= v5; if ( v7 ) @@ -631,7 +631,7 @@ if ( !(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) ) { // taking on water //__debugbreak(); - v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; + v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; v7 = *v8 < v4; *v8 -= v4; if ( v7 )