Beispiel #1
0
void MoveCharacterToHotspot(int chaa,int hotsp) {
    if ((hotsp<0) || (hotsp>=MAX_HOTSPOTS))
        quit("!MovecharacterToHotspot: invalid hotspot");
    if (thisroom.hswalkto[hotsp].x<1) return;
    walk_character(chaa,thisroom.hswalkto[hotsp].x,thisroom.hswalkto[hotsp].y,0, true);
    GameLoopUntilEvent(UNTIL_MOVEEND,(long)&game.chars[chaa].walking);
}
Beispiel #2
0
void CharacterInfo::update_character_follower(int &aa, int &numSheep, int *followingAsSheep, int &doing_nothing)
{
	if ((following >= 0) && (followinfo == FOLLOW_ALWAYSONTOP)) {
      // an always-on-top follow
      if (numSheep >= MAX_SHEEP)
        quit("too many sheep");
      followingAsSheep[numSheep] = aa;
      numSheep++;
    }
    // not moving, but should be following another character
    else if ((following >= 0) && (doing_nothing == 1)) {
      short distaway=(followinfo >> 8) & 0x00ff;
      // no character in this room
      if ((game.chars[following].on == 0) || (on == 0)) ;
      else if (room < 0) {
        room ++;
        if (room == 0) {
          // appear in the new room
          room = game.chars[following].room;
          x = play.entered_at_x;
          y = play.entered_at_y;
        }
      }
      // wait a bit, so we're not constantly walking
      else if (Random(100) < (followinfo & 0x00ff)) ;
      // the followed character has changed room
      else if ((room != game.chars[following].room)
            && (game.chars[following].on == 0))
        ;  // do nothing if the player isn't visible
      else if (room != game.chars[following].room) {
        prevroom = room;
        room = game.chars[following].room;

        if (room == displayed_room) {
          // only move to the room-entered position if coming into
          // the current room
          if (play.entered_at_x > (thisroom.width - 8)) {
            x = thisroom.width+8;
            y = play.entered_at_y;
            }
          else if (play.entered_at_x < 8) {
            x = -8;
            y = play.entered_at_y;
            }
          else if (play.entered_at_y > (thisroom.height - 8)) {
            y = thisroom.height+8;
            x = play.entered_at_x;
            }
          else if (play.entered_at_y < thisroom.top+8) {
            y = thisroom.top+1;
            x = play.entered_at_x;
            }
          else {
            // not at one of the edges
            // delay for a few seconds to let the player move
            room = -play.follow_change_room_timer;
          }
          if (room >= 0) {
            walk_character(aa,play.entered_at_x,play.entered_at_y,1, true);
            doing_nothing = 0;
          }
        }
      }
      else if (room != displayed_room) {
        // if the characetr is following another character and
        // neither is in the current room, don't try to move
      }
      else if ((abs(game.chars[following].x - x) > distaway+30) |
        (abs(game.chars[following].y - y) > distaway+30) |
        ((followinfo & 0x00ff) == 0)) {
        // in same room
        int goxoffs=(Random(50)-25);
        // make sure he's not standing on top of the other man
        if (goxoffs < 0) goxoffs-=distaway;
        else goxoffs+=distaway;
        walk_character(aa,game.chars[following].x + goxoffs,
          game.chars[following].y + (Random(50)-25),0, true);
        doing_nothing = 0;
      }
    }