Update of /cvsroot/wpdev/wolfpack/ai
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17868/ai
Modified Files:
ai.cpp ai.h ai_monsters.cpp
Log Message:
fixes
Index: ai.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ai.h 17 Sep 2004 23:28:17 -0000 1.14
--- ai.h 18 Sep 2004 21:10:40 -0000 1.15
***************
*** 191,196 ****
protected:
! void moveTo( const Coord_cl& pos );
! void movePath( const Coord_cl& pos );
int waitForPathCalculation;
};
--- 191,196 ----
protected:
! bool moveTo( const Coord_cl& pos );
! bool movePath( const Coord_cl& pos );
int waitForPathCalculation;
};
***************
*** 277,286 ****
--- 277,290 ----
{
protected:
+ unsigned int nextTry;
+
Monster_Aggr_MoveToTarget() : Action_Wander()
{
+ nextTry = 0;
}
public:
Monster_Aggr_MoveToTarget( P_NPC npc, AbstractAI* ai ) : Action_Wander( npc, ai )
{
+ nextTry = 0;
}
virtual void execute();
Index: ai.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** ai.cpp 17 Sep 2004 23:28:16 -0000 1.29
--- ai.cpp 18 Sep 2004 21:10:40 -0000 1.30
***************
*** 41,44 ****
--- 41,45 ----
#include "../network/uosocket.h"
#include "../targetrequests.h"
+ #include "../profile.h"
// library includes
***************
*** 130,133 ****
--- 131,135 ----
#endif
+ startProfiling(PF_AICHECKFINDACTION);
// If we have no current action or our action cant be executed, we must get a new one
if ( !m_currentAction || ( m_currentAction && m_currentAction->preCondition() <= 0.0f ) )
***************
*** 151,154 ****
--- 153,157 ----
}
}
+ stopProfiling(PF_AICHECKFINDACTION);
// Action is changing
***************
*** 162,165 ****
--- 165,169 ----
// Now we should have a current action set, else do nothing!
+ startProfiling(PF_AICHECKEXECUTEACTION);
if ( m_currentAction )
{
***************
*** 180,183 ****
--- 184,188 ----
}
}
+ stopProfiling(PF_AICHECKEXECUTEACTION);
}
***************
*** 587,596 ****
{
P_CHAR pTarget = m_npc->wanderFollowTarget();
! if ( pTarget )
! {
! movePath( pTarget->pos() );
}
- if ( pTarget->dist( m_npc ) > 3 )
- m_npc->setAICheckTime( ( uint )( Server::instance()->time() + ( float ) m_npc->aiCheckInterval() * 0.0005f * MY_CLOCKS_PER_SEC ) );
}
else
--- 592,605 ----
{
P_CHAR pTarget = m_npc->wanderFollowTarget();
! if (pTarget) {
! if ( m_npc->dist(pTarget) < 4 ) {
! movePath( pTarget->pos() );
! } else {
! moveTo( pTarget->pos());
! }
!
! if ( pTarget->dist( m_npc ) > 3 )
! m_npc->setAICheckTime( ( uint )( Server::instance()->time() + ( float ) m_npc->aiCheckInterval() * 0.0005f * MY_CLOCKS_PER_SEC ) );
}
}
else
***************
*** 606,610 ****
case enDestination:
{
! movePath( m_npc->wanderDestination() );
break;
}
--- 615,623 ----
case enDestination:
{
! if (m_npc->pos().distance( m_npc->wanderDestination() ) < 6 ) {
! movePath( m_npc->wanderDestination() );
! } else {
! moveTo( m_npc->wanderDestination() );
! }
break;
}
***************
*** 612,616 ****
}
! void Action_Wander::moveTo( const Coord_cl& pos )
{
// simply move towards the target
--- 625,629 ----
}
! bool Action_Wander::moveTo( const Coord_cl& pos )
{
// simply move towards the target
***************
*** 637,651 ****
if ( !mayWalk( m_npc, newPos ) )
{
! return;
}
}
}
! Movement::instance()->Walking( m_npc, dir, 0xFF );
}
! void Action_Wander::movePath( const Coord_cl& pos )
{
! if ( ( waitForPathCalculation <= 0 && !m_npc->hasPath() ) || pos != m_npc->pathDestination() )
{
Q_UINT8 range = 1;
--- 650,664 ----
if ( !mayWalk( m_npc, newPos ) )
{
! return false;
}
}
}
! return Movement::instance()->Walking( m_npc, dir, 0xFF );
}
! bool Action_Wander::movePath( const Coord_cl& pos )
{
! if ( waitForPathCalculation <= 0 && !m_npc->hasPath() )
{
Q_UINT8 range = 1;
***************
*** 661,664 ****
--- 674,678 ----
m_npc->findPath( pos, range == 1 ? 1.5f : ( float ) range );
+
// dont return here!
}
***************
*** 666,671 ****
{
waitForPathCalculation--;
! moveTo( pos );
! return;
}
--- 680,684 ----
{
waitForPathCalculation--;
! return moveTo( pos );
}
***************
*** 675,687 ****
Coord_cl nextmove = m_npc->nextMove();
Q_UINT8 dir = m_npc->pos().direction( nextmove );
! Movement::instance()->Walking( m_npc, dir, 0xFF );
m_npc->popMove();
! return;
}
else
{
waitForPathCalculation = 3;
! moveTo( pos );
! return;
}
}
--- 688,699 ----
Coord_cl nextmove = m_npc->nextMove();
Q_UINT8 dir = m_npc->pos().direction( nextmove );
! bool result = Movement::instance()->Walking( m_npc, dir, 0xFF );
m_npc->popMove();
! return result;
}
else
{
waitForPathCalculation = 3;
! return moveTo( pos );
}
}
Index: ai_monsters.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai_monsters.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** ai_monsters.cpp 17 Sep 2004 20:40:23 -0000 1.22
--- ai_monsters.cpp 18 Sep 2004 21:10:40 -0000 1.23
***************
*** 296,314 ****
void Monster_Aggr_MoveToTarget::execute()
{
Monster_Aggressive* pAI = dynamic_cast<Monster_Aggressive*>( m_ai );
! if ( !pAI || !pAI->currentVictim() )
return;
// Even if the victim is zero, thats correct.
! if ( pAI && !m_npc->attackTarget() )
! {
! m_npc->fight( pAI->currentVictim() );
}
! if ( Config::instance()->pathfind4Combat() )
! movePath( pAI->currentVictim()->pos() );
else
! moveTo( pAI->currentVictim()->pos() );
}
--- 296,329 ----
void Monster_Aggr_MoveToTarget::execute()
{
+ // We failed several times to reach the target so we wait
+ if (nextTry > Server::instance()->time()) {
+ return;
+ }
+
Monster_Aggressive* pAI = dynamic_cast<Monster_Aggressive*>( m_ai );
+ if ( !pAI )
+ return;
! P_CHAR currentVictim = pAI->currentVictim();
!
! if ( !currentVictim ) {
return;
+ }
// Even if the victim is zero, thats correct.
! if ( !m_npc->attackTarget() ) {
! m_npc->fight( currentVictim );
}
! if ( Config::instance()->pathfind4Combat() && m_npc->dist(currentVictim) < 5 )
! {
! if (!movePath( currentVictim->pos() )) {
! nextTry = Server::instance()->time() + RandomNum(1250, 2250);
! }
! }
else
! {
! moveTo( currentVictim->pos() );
! }
}
|