void start_character_turning (CharacterInfo *chinf, int useloop, int no_diagonal) {
  // work out how far round they have to turn 
  int fromidx = find_looporder_index (chinf->loop);
  int toidx = find_looporder_index (useloop);
  //Display("Curloop: %d, needloop: %d",chinf->loop, useloop);
  int ii, go_anticlock = 0;
  // work out whether anticlockwise is quicker or not
  if ((toidx > fromidx) && ((toidx - fromidx) > 4))
    go_anticlock = 1;
  if ((toidx < fromidx) && ((fromidx - toidx) < 4))
    go_anticlock = 1;
  // strip any current turning_around stages
  chinf->walking = chinf->walking % TURNING_AROUND;
  if (go_anticlock)
    chinf->walking += TURNING_BACKWARDS;
  else
    go_anticlock = -1;

  // Allow the diagonal frames just for turning
  if (no_diagonal == 2)
    no_diagonal = 0;

  for (ii = fromidx; ii != toidx; ii -= go_anticlock) {
    if (ii < 0)
      ii = 7;
    if (ii >= 8)
      ii = 0;
    if (ii == toidx)
      break;
    if ((turnlooporder[ii] >= 4) && (no_diagonal > 0))
      continue;
    if (views[chinf->view].loops[turnlooporder[ii]].numFrames < 1)
      continue;
    if (turnlooporder[ii] < views[chinf->view].numLoops)
      chinf->walking += TURNING_AROUND;
  }
  
}
Beispiel #2
0
int CharacterInfo::update_character_walking(CharacterExtras *chex)
{
    if (walking >= TURNING_AROUND) {
      // Currently rotating to correct direction
      if (walkwait > 0) walkwait--;
      else {
        // Work out which direction is next
        int wantloop = find_looporder_index(loop) + 1;
        // going anti-clockwise, take one before instead
        if (walking >= TURNING_BACKWARDS)
          wantloop -= 2;
        while (1) {
          if (wantloop >= 8)
            wantloop = 0;
          if (wantloop < 0)
            wantloop = 7;
          if ((turnlooporder[wantloop] >= views[view].numLoops) ||
              (views[view].loops[turnlooporder[wantloop]].numFrames < 1) ||
              ((turnlooporder[wantloop] >= 4) && ((flags & CHF_NODIAGONAL)!=0))) {
            if (walking >= TURNING_BACKWARDS)
              wantloop--;
            else
              wantloop++;
          }
          else break;
        }
        loop = turnlooporder[wantloop];
        walking -= TURNING_AROUND;
        // if still turning, wait for next frame
        if (walking % TURNING_BACKWARDS >= TURNING_AROUND)
          walkwait = animspeed;
        else
          walking = walking % TURNING_BACKWARDS;
        chex->animwait = 0;
      }
	  return RETURN_CONTINUE;
      //continue;
    }

	return 0;
}