diff --git a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp index 520b072..aaa321f 100644 --- a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp @@ -2290,6 +2290,9 @@ int CScriptObjectPlayer::UseLadder(IFunctionHandler *pH) if(onLadder!=0 && !m_pPlayer->m_stats.onLadder) { m_pPlayer->m_insideLadderVolume = true; + m_pPlayer->m_activeHandGrabbingLadder = false; + m_pPlayer->m_wasGrabbingLadder[0] = false; + m_pPlayer->m_wasGrabbingLadder[1] = false; m_pPlayer->m_PrevWeaponID=m_pPlayer->GetSelectedWeaponId(); m_pPlayer->SelectWeapon(-1); m_pPlayer->m_stats.onLadder = true; diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp index b3eb6c3..5fd63c4 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp @@ -1919,15 +1919,18 @@ void CPlayer::ProcessMovements(CXEntityProcessingCmd &cmd, bool bScheduled) if (speedxyz[2] > 0) { // add a bit of forward movement for dismounts at the top - speedxyz[0] = -m_psin * 0.50f; - speedxyz[1] = m_pcos * 0.50f; + //speedxyz[0] = -m_psin * 0.50f; + //speedxyz[1] = m_pcos * 0.50f; } m_prevLadderGrabPos = curGrabPos; } m_wasGrabbingLadder[i] = grabbing[i]; } - if (!grabbing[0] && !grabbing[1]) + if (m_activeHandGrabbingLadder != -1 && !grabbing[m_activeHandGrabbingLadder]) + { m_activeHandGrabbingLadder = -1; + CheckLadderDismount(); + } if (m_activeHandGrabbingLadder == -1 && !m_insideLadderVolume) { @@ -7095,6 +7098,30 @@ void CPlayer::CheckMeleeWeaponSwing() m_prevHandPos = handPos; } +void CPlayer::CheckLadderDismount() +{ + Matrix34 cameraTransform = Matrix34::CreateRotationXYZ(Deg2Rad(m_pEntity->GetCamera()->GetAngles()), m_pEntity->GetCamera()->GetPos()); + Vec3 fwd = cameraTransform.GetForward(); + fwd.z = 0; + fwd.Normalize(); + Vec3 testPos = cameraTransform.GetTranslation() + fwd * 1.0f + Vec3(0, 0, 0.5f); + + // find floor + IPhysicalWorld* world = m_pGame->GetSystem()->GetIPhysicalWorld(); + int objTypes = ent_terrain|ent_static; + int flags = rwi_stop_at_pierceable|rwi_ignore_terrain_holes; + ray_hit hit; + int col = world->RayWorldIntersection(testPos, Vec3(0, 0, -2), objTypes, flags, &hit, 1, m_pEntity->GetPhysics()); + if (col) + { + Vec3 dismountCandidate = hit.pt; + if (CanStand(dismountCandidate)) + { + m_pEntity->SetPos(dismountCandidate); + } + } +} + ////////////////////////////////////////////////////////////////////// void CPlayer::OnEntityNetworkUpdate( const EntityId &idViewerEntity, const Vec3d &v3dViewer, uint32 &inoutPriority, EntityCloneState &inoutCloneState) const diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.h b/Sources/CryGame C++/Solution1/CryGame/XPlayer.h index 19b66f2..fbbe9a4 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.h +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.h @@ -1179,6 +1179,8 @@ enum eInVehiclestate int m_activeHandGrabbingLadder = -1; Vec3 m_prevLadderGrabPos; bool m_insideLadderVolume = false; + + void CheckLadderDismount(); }; #endif // __GAME_PLAYER_H__