[wpdev-commits] wolfpack/ai ai.cpp,1.21,1.22
Brought to you by:
rip,
thiagocorrea
From: Correa <thi...@us...> - 2004-08-10 03:19:36
|
Update of /cvsroot/wpdev/wolfpack/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18584 Modified Files: ai.cpp Log Message: applied coding standard rules. Index: ai.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/ai/ai.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ai.cpp 4 Aug 2004 23:17:37 -0000 1.21 --- ai.cpp 10 Aug 2004 03:19:27 -0000 1.22 *************** *** 492,516 **** // Only try to walk if we're not already out of the spawnregion // Otherwise fall trough to enFreely ! cSpawnRegion *region = m_npc->spawnregion(); ! if (region && region->contains(m_npc->pos().x, m_npc->pos().y, m_npc->pos().map)) { // Calculate the field we're facing. unsigned char dir = m_npc->direction(); ! Coord_cl newpos = Movement::instance()->calcCoordFromDir(dir, m_npc->pos()); // Calculate a new direction. ! if (!region->contains(newpos.x, newpos.y, newpos.map)) { ! unsigned char newdir = RandomNum(0, 7); // Make sure we're not trying to walk in the same // direction or the directions directly beneath if we met the border of a // spawnregion. But we don't want to turn around exactly either. (Looks // to mechanically) ! while (newdir == dir ! || newdir == ((dir == 0) ? 7 : dir - 1) ! || newdir == ((dir == 7) ? 0 : dir + 1) ) { ! newdir += RandomNum(0, 1) ? -1 : 1; } dir = newdir; --- 492,514 ---- // Only try to walk if we're not already out of the spawnregion // Otherwise fall trough to enFreely ! cSpawnRegion* region = m_npc->spawnregion(); ! if ( region && region->contains( m_npc->pos().x, m_npc->pos().y, m_npc->pos().map ) ) { // Calculate the field we're facing. unsigned char dir = m_npc->direction(); ! Coord_cl newpos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() ); // Calculate a new direction. ! if ( !region->contains( newpos.x, newpos.y, newpos.map ) ) { ! unsigned char newdir = RandomNum( 0, 7 ); // Make sure we're not trying to walk in the same // direction or the directions directly beneath if we met the border of a // spawnregion. But we don't want to turn around exactly either. (Looks // to mechanically) ! while ( newdir == dir || newdir == ( ( dir == 0 ) ? 7 : dir - 1 ) || newdir == ( ( dir == 7 ) ? 0 : dir + 1 ) ) { ! newdir += RandomNum( 0, 1 ) ? -1 : 1; } dir = newdir; *************** *** 520,536 **** // If there's a obstacle, change the direction slightly to see if we can get // around it. ! if (!Movement::instance()->Walking(m_npc, dir, 0xFF)) { signed char newdir = dir; ! newdir += RandomNum(0, 1) ? -1 : 1; ! if (newdir < 0) { newdir = 7; ! } else if (newdir > 7) { newdir = 0; } ! m_npc->setDirection(newdir); m_npc->update(); } --- 518,535 ---- // If there's a obstacle, change the direction slightly to see if we can get // around it. ! if ( !Movement::instance()->Walking( m_npc, dir, 0xFF ) ) { signed char newdir = dir; ! newdir += RandomNum( 0, 1 ) ? -1 : 1; ! if ( newdir < 0 ) { newdir = 7; ! } ! else if ( newdir > 7 ) { newdir = 0; } ! m_npc->setDirection( newdir ); m_npc->update(); } *************** *** 544,551 **** UINT8 dir = m_npc->direction(); if ( RandomNum( 0, 100 ) < 20 ) ! dir = RandomNum(0, 7); ! m_npc->setDirection(dir); ! Movement::instance()->Walking(m_npc, dir, 0xFF); break; } --- 543,550 ---- UINT8 dir = m_npc->direction(); if ( RandomNum( 0, 100 ) < 20 ) ! dir = RandomNum( 0, 7 ); ! m_npc->setDirection( dir ); ! Movement::instance()->Walking( m_npc, dir, 0xFF ); break; } |