From c6620bb3587c29a282588d59b967540f09ba1925 Mon Sep 17 00:00:00 2001 From: pyrolink Date: Sun, 22 Jan 2006 08:53:35 +0000 Subject: [PATCH] Range and melee attack split up. This was SVN commit r3396. --- source/simulation/EntityStateProcessing.cpp | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index c0e88ec493..e4f37ccfa6 100755 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -332,6 +332,20 @@ bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timeste current->m_data[0].location = current->m_data[0].entity->m_position; float Distance = (current->m_data[0].location - m_position).length(); + //TODO: find a better way than assuming constant action indicators. + + if ( current->m_data[1].data == 1 ) + { + //Are we closer using ranged attack? + if ( fabs(Distance - m_actions[4].m_MaxRange) < fabs(Distance - action->m_MaxRange) && + Distance > m_actions[4].m_MinRange && !m_shouldRun && m_actions.find( 4 ) != m_actions.end()) + { + action = &m_actions[4]; + current->m_data[1].data = 4; + } + else + action = &m_actions[1]; + } if( Distance < action->m_MaxRange ) { (int&)current->m_type = transition; @@ -440,6 +454,21 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times } CVector2D delta = current->m_data[0].entity->m_position - m_position; + float deltaLength = delta.length(); + + //TODO: find a better way than assuming constant action indicators. + if ( current->m_data[1].data == 1 ) + { + //Are we closer using ranged attack? + if ( fabs(deltaLength - m_actions[4].m_MaxRange) < fabs(deltaLength - action->m_MaxRange) && + deltaLength > m_actions[4].m_MinRange && !m_shouldRun && m_actions.find( 4 ) != m_actions.end()) + { + action = &m_actions[4]; + current->m_data[1].data = 4; + } + else + action = &m_actions[1]; + } float adjRange = action->m_MaxRange + m_bounds->m_radius + current->m_data[0].entity->m_bounds->m_radius; @@ -461,7 +490,6 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times // We're aiming to end up at a location just inside our maximum range // (is this good enough?) delta = delta.normalize() * ( adjRange - m_bounds->m_radius ); - float deltaLength = delta.length(); if ( m_actor ) {