Mercurial > mm7
comparison mm7_3.cpp @ 138:a8ec7e1e18b6
Sliding downhill & relative subs.
how it's done: each time you get a little bit pushed in the air along terrain normal,
and then falling to the gravity, gradually sliding downwards. nice trick
author | Nomad |
---|---|
date | Tue, 12 Feb 2013 00:22:30 +0200 |
parents | 1c471f3629fb |
children | 7eeea515f5ff |
comparison
equal
deleted
inserted
replaced
137:a2ddaf0e4d8a | 138:a8ec7e1e18b6 |
---|---|
993 v4 = v0->pMonsterInfo.uFlying; | 993 v4 = v0->pMonsterInfo.uFlying; |
994 v0->uSectorID = 0; | 994 v0->uSectorID = 0; |
995 v74 = v4; | 995 v74 = v4; |
996 if ( !v0->CanAct() ) | 996 if ( !v0->CanAct() ) |
997 v74 = 0; | 997 v74 = 0; |
998 v70 = GetTerrainHeightsAroundParty(v0->vPosition.x, v0->vPosition.y); | 998 v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); |
999 v5 = sub_46D49E_prolly_get_world_y_under_party( | 999 v5 = sub_46D49E_prolly_get_world_y_under_party( |
1000 v0->vPosition.x, | 1000 v0->vPosition.x, |
1001 v0->vPosition.y, | 1001 v0->vPosition.y, |
1002 v0->vPosition.z, | 1002 v0->vPosition.z, |
1003 v0->uActorHeight, | 1003 v0->uActorHeight, |
1086 if ( v70 && !v72 && v67 ) | 1086 if ( v70 && !v72 && v67 ) |
1087 { | 1087 { |
1088 v18 = v0->vPosition.y; | 1088 v18 = v0->vPosition.y; |
1089 v19 = v0->vPosition.x; | 1089 v19 = v0->vPosition.x; |
1090 v0->vPosition.z = v7; | 1090 v0->vPosition.z = v7; |
1091 _46DCC8_get_gravity_direction_outdoor(v19, v18, &v62); | 1091 ODM_GetTerrainNormalAt(v19, v18, &v62); |
1092 v20 = GetGravityStrength(); | 1092 v20 = GetGravityStrength(); |
1093 v21 = v62.y; | 1093 v21 = v62.y; |
1094 v22 = v62.z; | 1094 v22 = v62.z; |
1095 v23 = v62.y * v0->vVelocity.y; | 1095 v23 = v62.y * v0->vVelocity.y; |
1096 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; | 1096 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; |
1824 | 1824 |
1825 uLayingItemID_ = uLayingItemID; | 1825 uLayingItemID_ = uLayingItemID; |
1826 v1 = &pLayingItems[uLayingItemID]; | 1826 v1 = &pLayingItems[uLayingItemID]; |
1827 v58 = 0; | 1827 v58 = 0; |
1828 v2 = &pObjectList->pObjects[v1->uObjectDescID]; | 1828 v2 = &pObjectList->pObjects[v1->uObjectDescID]; |
1829 v57 = GetTerrainHeightsAroundParty(v1->vPosition.x, v1->vPosition.y); | 1829 v57 = IsTerrainSlopeTooHigh(v1->vPosition.x, v1->vPosition.y); |
1830 v3 = v1->vPosition.y; | 1830 v3 = v1->vPosition.y; |
1831 v4 = v1->vPosition.x; | 1831 v4 = v1->vPosition.x; |
1832 v5 = v2->uHeight; | 1832 v5 = v2->uHeight; |
1833 v55 = 0; | 1833 v55 = 0; |
1834 v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0); | 1834 v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0); |
1862 if ( v57 ) | 1862 if ( v57 ) |
1863 { | 1863 { |
1864 v11 = v1->vPosition.y; | 1864 v11 = v1->vPosition.y; |
1865 v12 = v1->vPosition.x; | 1865 v12 = v1->vPosition.x; |
1866 v1->vPosition.z = v8; | 1866 v1->vPosition.z = v8; |
1867 _46DCC8_get_gravity_direction_outdoor(v12, v11, &v51); | 1867 ODM_GetTerrainNormalAt(v12, v11, &v51); |
1868 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | 1868 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); |
1869 v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; | 1869 v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; |
1870 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); | 1870 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); |
1871 v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16; | 1871 v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16; |
1872 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); | 1872 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); |
2992 | 2992 |
2993 | 2993 |
2994 //----- (00473893) -------------------------------------------------------- | 2994 //----- (00473893) -------------------------------------------------------- |
2995 void __cdecl ODM_ProcessPartyActions() | 2995 void __cdecl ODM_ProcessPartyActions() |
2996 { | 2996 { |
2997 int _zero; // esi@1 | 2997 //int _zero; // esi@1 |
2998 int v1; // edi@1 | 2998 int v1; // edi@1 |
2999 int v2; // ebx@1 | 2999 int v2; // ebx@1 |
3000 int v3; // eax@14 | 3000 int v3; // eax@14 |
3001 Player **v4; // esi@21 | 3001 Player **v4; // esi@21 |
3002 int v5; // eax@24 | 3002 int v5; // eax@24 |
3090 int v93; // [sp-8h] [bp-9Ch]@104 | 3090 int v93; // [sp-8h] [bp-9Ch]@104 |
3091 unsigned int v94; // [sp-8h] [bp-9Ch]@246 | 3091 unsigned int v94; // [sp-8h] [bp-9Ch]@246 |
3092 int v95; // [sp-4h] [bp-98h]@104 | 3092 int v95; // [sp-4h] [bp-98h]@104 |
3093 int v96; // [sp-4h] [bp-98h]@246 | 3093 int v96; // [sp-4h] [bp-98h]@246 |
3094 int v97; // [sp+Ch] [bp-88h]@180 | 3094 int v97; // [sp+Ch] [bp-88h]@180 |
3095 int v98; // [sp+10h] [bp-84h]@147 | 3095 Vec3_int_ v98; |
3096 int v99; // [sp+14h] [bp-80h]@147 | 3096 //int v98; // [sp+10h] [bp-84h]@147 |
3097 int v100; // [sp+18h] [bp-7Ch]@147 | 3097 //int v99; // [sp+14h] [bp-80h]@147 |
3098 //int v100; // [sp+18h] [bp-7Ch]@147 | |
3098 bool v101; // [sp+1Ch] [bp-78h]@33 | 3099 bool v101; // [sp+1Ch] [bp-78h]@33 |
3099 int v102; // [sp+20h] [bp-74h]@1 | 3100 int v102; // [sp+20h] [bp-74h]@1 |
3100 int v103; // [sp+24h] [bp-70h]@1 | 3101 int v103; // [sp+24h] [bp-70h]@1 |
3101 int bFeatherFall; // [sp+28h] [bp-6Ch]@4 | 3102 int bFeatherFall; // [sp+28h] [bp-6Ch]@4 |
3102 int v105; // [sp+2Ch] [bp-68h]@24 | 3103 int v105; // [sp+2Ch] [bp-68h]@24 |
3126 int v129; // [sp+8Ch] [bp-8h]@92 | 3127 int v129; // [sp+8Ch] [bp-8h]@92 |
3127 int v130; // [sp+90h] [bp-4h]@14 | 3128 int v130; // [sp+90h] [bp-4h]@14 |
3128 | 3129 |
3129 v121 = pParty->uFallSpeed; | 3130 v121 = pParty->uFallSpeed; |
3130 v123 = pParty->vPosition.z; | 3131 v123 = pParty->vPosition.z; |
3131 _zero = 0; | |
3132 v1 = 0; | 3132 v1 = 0; |
3133 v103 = 0; | 3133 v103 = 0; |
3134 v2 = 0; | 3134 v2 = 0; |
3135 *(float *)&v128 = 0.0; | 3135 *(float *)&v128 = 0.0; |
3136 v116 = pParty->vPosition.x; | 3136 v116 = pParty->vPosition.x; |
3137 v117 = pParty->vPosition.y; | 3137 v117 = pParty->vPosition.y; |
3138 v113 = pParty->field_6F0; | 3138 v113 = pParty->field_6F0; |
3139 bJumping = 0; | 3139 bJumping = 0; |
3140 v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.y); | 3140 auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); |
3141 v114 = 0; | 3141 v114 = 0; |
3142 v124 = 0; | 3142 v124 = 0; |
3143 v108 = 0; | 3143 v108 = 0; |
3144 v102 = 0; | 3144 v102 = 0; |
3145 v127 = 0; | 3145 v127 = 0; |
3203 (*v4)->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | 3203 (*v4)->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); |
3204 } | 3204 } |
3205 ++v4; | 3205 ++v4; |
3206 } | 3206 } |
3207 while ( (signed int)v4 <= (signed int)&pPlayers[4] ); | 3207 while ( (signed int)v4 <= (signed int)&pPlayers[4] ); |
3208 _zero = 0; | |
3209 } | 3208 } |
3210 } | 3209 } |
3211 v109 = -1; | 3210 v109 = -1; |
3212 if ( pParty->bFlying != _zero ) | 3211 if ( pParty->bFlying ) |
3213 v109 = sub_46D8E3(v116, v117, v123 + pParty->uPartyHeight, (int)&v102); | 3212 v109 = sub_46D8E3(v116, v117, v123 + pParty->uPartyHeight, (int)&v102); |
3214 v107 = v108 == _zero; | 3213 v107 = v108 == 0; |
3215 v105 = v111 + 1; | 3214 v105 = v111 + 1; |
3216 if ( v123 <= v111 + 1 ) | 3215 if ( v123 <= v111 + 1 ) |
3217 { | 3216 { |
3218 v109 = -1; | 3217 v109 = -1; |
3219 pParty->bFlying = _zero; | 3218 pParty->bFlying = false; |
3220 } | 3219 } |
3221 else | 3220 else |
3222 { | 3221 { |
3223 bJumping = 1; | 3222 bJumping = 1; |
3224 } | 3223 } |
3225 v101 = v123 - v111 <= 32; | 3224 v101 = v123 - v111 <= 32; |
3226 if ( bWalkSound != _zero && pParty->field_6F8 > _zero ) | 3225 if ( bWalkSound && pParty->field_6F8 > 0 ) |
3227 pParty->field_6F8 -= pEventTimer->uTimeElapsed; | 3226 pParty->field_6F8 -= pEventTimer->uTimeElapsed; |
3228 if ( !bUnderwater | 3227 if ( !bUnderwater |
3229 && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero | 3228 && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0 |
3230 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < _zero || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero) ) | 3229 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0) ) |
3231 pParty->bFlying = _zero; | 3230 pParty->bFlying = false; |
3232 if ( bJumping == _zero ) | 3231 if (!bJumping) |
3233 { | 3232 { |
3234 if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) ) | 3233 if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) ) |
3235 { | 3234 { |
3236 if ( v108 != _zero ) | 3235 if (v108) |
3237 { | 3236 { |
3238 if ( v108 >> 6 < pOutdoor->uNumBModels ) | 3237 if ( v108 >> 6 < pOutdoor->uNumBModels ) |
3239 { | 3238 { |
3240 v7 = pOutdoor->pBModels[v108 >> 6].pFaces; | 3239 v7 = pOutdoor->pBModels[v108 >> 6].pFaces; |
3241 v6 = v108 & 0x3F; | 3240 v6 = v108 & 0x3F; |
3267 while ( pPartyActionQueue->uNumActions ) | 3266 while ( pPartyActionQueue->uNumActions ) |
3268 { | 3267 { |
3269 switch ( pPartyActionQueue->Next() ) | 3268 switch ( pPartyActionQueue->Next() ) |
3270 { | 3269 { |
3271 case PARTY_FlyUp: | 3270 case PARTY_FlyUp: |
3272 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) | 3271 { |
3273 { | 3272 if (!pParty->FlyActive() && !bUnderwater) |
3274 pParty->bFlying = 0; | 3273 break; |
3275 if ( bUnderwater | 3274 |
3276 || pParty->pPartyBuffs[7].uFlags & 1 | 3275 pParty->bFlying = false; |
3277 || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 ) | 3276 if (bUnderwater || |
3277 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || | |
3278 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana <= 0 ) | |
3278 { | 3279 { |
3279 if ( pParty->vPosition.z < 4000 || bJumping ) | 3280 if ( pParty->vPosition.z < 4000 || bJumping ) |
3280 { | 3281 { |
3281 v123 += 30; | 3282 v123 += 30; |
3282 v113 += 30; | 3283 v113 += 30; |
3304 } | 3305 } |
3305 pParty->uFallSpeed = 0; | 3306 pParty->uFallSpeed = 0; |
3306 v127 = (BSPModel *)1; | 3307 v127 = (BSPModel *)1; |
3307 } | 3308 } |
3308 } | 3309 } |
3309 } | 3310 } |
3310 goto LABEL_118; | 3311 break; |
3312 | |
3311 case PARTY_FlyDown: | 3313 case PARTY_FlyDown: |
3312 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) | 3314 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) |
3313 { | 3315 { |
3314 pParty->bFlying = 0; | 3316 pParty->bFlying = 0; |
3315 if ( bUnderwater | 3317 if ( bUnderwater |
3454 * (unsigned __int64)(signed __int64)(*(float *)&v128 | 3456 * (unsigned __int64)(signed __int64)(*(float *)&v128 |
3455 * fWalkSpeedMultiplier))) >> 16; | 3457 * fWalkSpeedMultiplier))) >> 16; |
3456 v1 += v129; | 3458 v1 += v129; |
3457 goto LABEL_93; | 3459 goto LABEL_93; |
3458 } | 3460 } |
3459 if ( v118 && !v108 ) | 3461 if ( partyAtHighSlope && !v108 ) |
3460 { | 3462 { |
3461 v23 = stru_5C6E00->SinCos(_angle_y); | 3463 v23 = stru_5C6E00->SinCos(_angle_y); |
3462 v24 = (double)_walk_speed; | 3464 v24 = (double)_walk_speed; |
3463 v126 = v23; | 3465 v126 = v23; |
3464 *(float *)&v128 = v24; | 3466 *(float *)&v128 = v24; |
3546 goto LABEL_118; | 3548 goto LABEL_118; |
3547 case PARTY_CenterView: | 3549 case PARTY_CenterView: |
3548 _angle_x = 0; | 3550 _angle_x = 0; |
3549 goto LABEL_118; | 3551 goto LABEL_118; |
3550 case PARTY_Jump: | 3552 case PARTY_Jump: |
3551 if ( (!v118 || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) | 3553 if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) |
3552 { | 3554 { |
3553 v126 = pParty->field_24 << 6; | 3555 v126 = pParty->field_24 << 6; |
3554 bJumping = 1; | 3556 bJumping = 1; |
3555 v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121); | 3557 v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121); |
3556 } | 3558 } |
3607 v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); | 3609 v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); |
3608 v34 = v121 + 2 * v33; | 3610 v34 = v121 + 2 * v33; |
3609 v121 += 2 * v33; | 3611 v121 += 2 * v33; |
3610 goto LABEL_149; | 3612 goto LABEL_149; |
3611 } | 3613 } |
3612 if ( !v118 ) | 3614 if ( !partyAtHighSlope ) |
3613 { | 3615 { |
3614 v34 = v121; | 3616 v34 = v121; |
3615 LABEL_149: | 3617 LABEL_149: |
3616 if ( bJumping == v32 ) | 3618 if ( bJumping == v32 ) |
3617 goto LABEL_150; | 3619 goto LABEL_150; |
3619 } | 3621 } |
3620 if ( !bJumping ) | 3622 if ( !bJumping ) |
3621 { | 3623 { |
3622 if ( v108 ) | 3624 if ( v108 ) |
3623 goto LABEL_150; | 3625 goto LABEL_150; |
3626 | |
3627 // rolling down the hill | |
3628 // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air | |
3629 // and falling to the gravity, gradually sliding downwards. nice trick | |
3624 v123 = v111; | 3630 v123 = v111; |
3625 _46DCC8_get_gravity_direction_outdoor(v116, v117, (Vec3_int_ *)&v98); | 3631 ODM_GetTerrainNormalAt(v116, v117, &v98); |
3626 v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); | 3632 v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); |
3627 v129 = abs((signed __int64)v2 * (signed __int64)v98 + (signed __int64)v1 * (signed __int64)v99 + (signed __int64)v35 * (signed __int64)v100) >> 16; | 3633 v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16; |
3628 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98) >> 16); | 3634 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98.x) >> 16); |
3629 v2 += (int)v127; | 3635 v2 += (int)v127; |
3630 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v99) >> 16); | 3636 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98.y) >> 16); |
3631 v1 += (int)v127; | 3637 v1 += (int)v127; |
3632 v128 = v1; | 3638 v128 = v1; |
3633 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v100) >> 16); | 3639 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16); |
3634 v34 = (int)((char *)v127 + v35); | 3640 v34 = (int)((char *)v127 + v35); |
3635 v32 = 0; | 3641 v32 = 0; |
3636 v121 = v34; | 3642 v121 = v34; |
3637 goto LABEL_149; | 3643 goto LABEL_149; |
3638 } | 3644 } |
3658 goto LABEL_151; | 3664 goto LABEL_151; |
3659 } | 3665 } |
3660 LABEL_150: | 3666 LABEL_150: |
3661 pParty->uFallStartY = v123; | 3667 pParty->uFallStartY = v123; |
3662 LABEL_151: | 3668 LABEL_151: |
3663 if ( v2 * v2 + v1 * v1 < 400 && !v118 ) | 3669 if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope ) |
3664 { | 3670 { |
3665 *(float *)&v128 = 0.0; | 3671 *(float *)&v128 = 0.0; |
3666 v2 = 0; | 3672 v2 = 0; |
3667 } | 3673 } |
3668 stru_721530.field_84 = -1; | 3674 stru_721530.field_84 = -1; |
3718 v40, | 3724 v40, |
3719 pParty->uPartyHeight, | 3725 pParty->uPartyHeight, |
3720 &v130, | 3726 &v130, |
3721 &v110, | 3727 &v110, |
3722 0); | 3728 0); |
3723 v127 = (BSPModel *)GetTerrainHeightsAroundParty(_angle_x, v117); | 3729 v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, v117); |
3724 v42 = GetTerrainHeightsAroundParty(v116, _angle_y); | 3730 v42 = IsTerrainSlopeTooHigh(v116, _angle_y); |
3725 v107 = 0; | 3731 v107 = 0; |
3726 v118 = v42; | 3732 v118 = v42; |
3727 if ( !v97 && !v110 && !v108 ) | 3733 if ( !v97 && !v110 && !v108 ) |
3728 v107 = 1; | 3734 v107 = 1; |
3729 v43 = 1; | 3735 v43 = 1; |
3744 v40, | 3750 v40, |
3745 pParty->uPartyHeight, | 3751 pParty->uPartyHeight, |
3746 &v130, | 3752 &v130, |
3747 &v108, | 3753 &v108, |
3748 0); | 3754 0); |
3749 if ( GetTerrainHeightsAroundParty(_angle_x, _angle_y) && (signed int)v127 <= v123 ) | 3755 if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= v123 ) |
3750 { | 3756 { |
3751 v43 = 1; | 3757 v43 = 1; |
3752 LABEL_197: | 3758 LABEL_197: |
3753 v116 = _angle_x; | 3759 v116 = _angle_x; |
3754 if ( !v43 ) | 3760 if ( !v43 ) |
9432 } | 9438 } |
9433 | 9439 |
9434 | 9440 |
9435 | 9441 |
9436 //----- (004823F4) -------------------------------------------------------- | 9442 //----- (004823F4) -------------------------------------------------------- |
9437 bool __fastcall GetTerrainHeightsAroundParty(int a1, int a2) | 9443 bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) |
9438 { | 9444 { |
9439 unsigned int v2; // ebx@1 | 9445 //unsigned int v2; // ebx@1 |
9440 unsigned int v3; // edi@1 | 9446 //unsigned int v3; // edi@1 |
9441 int v4; // eax@1 | 9447 //int v4; // eax@1 |
9442 int v6; // esi@5 | 9448 //int v6; // esi@5 |
9443 int v7; // ecx@6 | 9449 //int v7; // ecx@6 |
9444 int v8; // edx@6 | 9450 //int v8; // edx@6 |
9445 int v9; // eax@6 | 9451 //int v9; // eax@6 |
9446 int v10; // esi@10 | 9452 //int v10; // esi@10 |
9447 int v11; // [sp+14h] [bp-8h]@1 | 9453 //int v11; // [sp+14h] [bp-8h]@1 |
9448 int v12; // [sp+18h] [bp-4h]@1 | 9454 //int v12; // [sp+18h] [bp-4h]@1 |
9449 | 9455 |
9450 v12 = a1; | 9456 //v12 = a1; |
9451 v11 = a2; | 9457 //v11 = a2; |
9452 v2 = WorldPosToGridCellX(a1); | 9458 auto grid_x = WorldPosToGridCellX(pos_x); |
9453 v3 = WorldPosToGridCellZ(v11) - 1; | 9459 auto grid_z = WorldPosToGridCellZ(pos_z) - 1; |
9454 dword_76D568_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2); | 9460 |
9455 dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1); | 9461 auto party_grid_x1 = GridCellToWorldPosX(grid_x); |
9456 dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1); | 9462 //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); |
9457 dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2); | 9463 //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); |
9458 dword_76D558_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3); | 9464 //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x); |
9459 dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3); | 9465 auto party_grid_z1 = GridCellToWorldPosZ(grid_z); |
9460 dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1); | 9466 //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z); |
9461 dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1); | 9467 //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); |
9462 dword_76D548_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2, v3); | 9468 //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); |
9463 dword_76D54C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3); | 9469 auto party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); |
9464 dword_76D550_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3 + 1); | 9470 auto party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); |
9465 v4 = pOutdoor->DoGetHeightOnTerrain(v2, v3 + 1); | 9471 auto party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); |
9466 dword_76D554_terrain_cell_world_pos_around_party_y = v4; | 9472 auto party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); |
9467 if ( dword_76D548_terrain_cell_world_pos_around_party_y == dword_76D54C_terrain_cell_world_pos_around_party_y | 9473 //dword_76D554_terrain_cell_world_pos_around_party_y = v4; |
9468 && dword_76D54C_terrain_cell_world_pos_around_party_y == dword_76D550_terrain_cell_world_pos_around_party_y | 9474 if (party_x1z1_y == party_x2z1_y && |
9469 && dword_76D550_terrain_cell_world_pos_around_party_y == v4 ) | 9475 party_x2z1_y == party_x2z2_y && |
9470 return 0; | 9476 party_x2z2_y == party_x1z2_y ) |
9471 v6 = abs(v12 - dword_76D568_terrain_cell_world_pos_around_party_x); | 9477 return false; |
9472 if ( abs(dword_76D558_terrain_cell_world_pos_around_party_z - v11) >= v6 ) | 9478 |
9473 { | 9479 auto dx = abs(pos_x - party_grid_x1), |
9474 v7 = dword_76D554_terrain_cell_world_pos_around_party_y; | 9480 dz = abs(party_grid_z1 - pos_z); |
9475 v8 = dword_76D550_terrain_cell_world_pos_around_party_y; | 9481 |
9476 v9 = dword_76D548_terrain_cell_world_pos_around_party_y; | 9482 int y1, y2, y3; |
9483 if (dz >= dx) | |
9484 { | |
9485 y1 = party_x1z2_y; // lower-left triangle | |
9486 y2 = party_x2z2_y; // y3 | \ | |
9487 y3 = party_x1z1_y; // | \ | |
9488 /* | \ | |
9489 |______ \ | |
9490 y1 y2 */ | |
9477 } | 9491 } |
9478 else | 9492 else |
9479 { | 9493 { |
9480 v7 = dword_76D54C_terrain_cell_world_pos_around_party_y; | 9494 y1 = party_x2z1_y; // upper-right |
9481 v8 = dword_76D548_terrain_cell_world_pos_around_party_y; | 9495 y2 = party_x1z1_y; // y2_______ y1 |
9482 v9 = dword_76D550_terrain_cell_world_pos_around_party_y; | 9496 y3 = party_x2z2_y; // \ | |
9483 } | 9497 /* \ | |
9484 if ( v7 >= v8 ) | 9498 \ | |
9485 { | 9499 y3 */ |
9486 v10 = v8; | 9500 } |
9487 if ( v8 < v9 ) | 9501 |
9502 int y_min = min(y1, min(y2, y3)), | |
9503 y_max = max(y1, max(y2, y3)); | |
9504 return y_max - y_min > 512; | |
9505 | |
9506 /*if ( y1 >= y2 ) | |
9507 { | |
9508 y_min = y2; | |
9509 if ( y2 < y3 ) | |
9488 goto LABEL_13; | 9510 goto LABEL_13; |
9489 LABEL_12: | 9511 LABEL_12: |
9490 v10 = v9; | 9512 y_min = y3; |
9491 goto LABEL_13; | 9513 goto LABEL_13; |
9492 } | 9514 } |
9493 if ( v7 >= v9 ) | 9515 else if ( y1 >= y3 ) |
9494 goto LABEL_12; | 9516 goto LABEL_12; |
9495 v10 = v7; | 9517 else |
9518 y_min = y1; | |
9519 | |
9496 LABEL_13: | 9520 LABEL_13: |
9497 if ( v7 <= v8 ) | 9521 if ( y1 <= y2 ) |
9498 { | 9522 { |
9499 if ( v8 > v9 ) | 9523 if ( y2 > y3 ) |
9500 v9 = v8; | 9524 y3 = y2; |
9501 } | 9525 } |
9502 else | 9526 else |
9503 { | 9527 { |
9504 if ( v7 > v9 ) | 9528 if ( y1 > y3 ) |
9505 v9 = v7; | 9529 y3 = y1; |
9506 } | 9530 } |
9507 return v9 - v10 > 512; | 9531 return y3 - v10 > 512;*/ |
9508 } | 9532 } |
9509 | 9533 |
9510 | 9534 |
9511 //----- (0048257A) -------------------------------------------------------- | 9535 //----- (0048257A) -------------------------------------------------------- |
9512 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4) | 9536 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4) |