1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
//If direction is not 0, then we already chose
if (direction == 0)
{
/* The decision on the direction really depends what this object does... */
switch (moveState)
{
case MOVE_TO_GROUP_ALWAYS:
case MOVE_TO_GROUP_SOMETIMES:
//Either we move to group always or we check the percentage
if (moveState == MOVE_TO_GROUP_ALWAYS || (rand () % 100 < percentageMoveToGroup))
{
int groupI, groupJ;
if (canSenseGroup (group, groupI, groupJ))
{
direction = PathFinder::findPath (map, maxI, maxJ, i, j, groupI, groupJ);
//If not random, then break, otherwise FALL THROUGH
if (direction != HANDLE_RANDOM)
break;
}
//Did not find group, move randomly
}
//FALL THROUGH !
case MOVE_RANDOMLY:
direction = rand () % 10;
break;
default:
/* Takes care of case DONT_MOVE too */
return HANDLE_PASS;
}
} |