Example #1
0
static Boolean teleok(Short x, Short y)
{	/* might throw him into a POOL */
  return( !OUT_OF_BOUNDS(x,y) &&
	  !IS_ROCK(get_cell_type(floor_info[x][y])) &&
	  !mon_at(x,y) &&
	  !sobj_at(ENORMOUS_ROCK,x,y) &&
	  !trap_at(x,y)
	  );
  /* Note: gold is permitted (because of vaults) */
}
Example #2
0
static int proto_server_mt_cinfo_handler(Proto_Session *s)
{
    int in_x, in_y, rc;
    char cell, team, occupied;
    Proto_Msg_Hdr h;

    if (proto_debug()) {
        fprintf(stderr, "proto_server_mt_cinfo_handler: invoked for session:\n");
        //proto_session_dump(s);
    }

    // read msg here
    proto_session_body_unmarshall_int(s, 0, &in_x);
    proto_session_body_unmarshall_int(s, sizeof(int), &in_y);

    if (proto_debug()) 
        fprintf(stderr, "proto_server_mt_numjail_handler: requested cellinfo( %d, %d )\n", in_x, in_y);
    
    //cell = '#';//cell = (char)0xCC; // call mze.c numjail(teamNo) func
    //team = '1';//team = (char)0xDD;
    //occupied = 'Y';//occupied = (char)0xEE;

    cell = get_cell_type( in_x, in_y );
    team = get_cell_team( in_x, in_y );
    occupied = is_cell_occupied( in_x, in_y );
    //findCInfo(in_x, in_y);

    if (proto_debug())
        fprintf(stderr, "proto_server_mt_numjail_handler: maze.c::func returned\n"
                "     cell='%c', team='%c', occupied='%c'\n", cell, team, occupied);

    // create replay message
    bzero(&h, sizeof(h));
    h.type = proto_session_hdr_unmarshall_type(s);
    h.type += PROTO_MT_REP_BASE_RESERVED_FIRST;
    proto_session_hdr_marshall(s, &h);

    if (proto_session_body_marshall_char(s, cell) < 0 )
        fprintf(stderr, "proto_server_mt_cinfo_handler: "
                "proto_session_body_marshall_bytes failed\n");

    if (proto_session_body_marshall_char(s, team) < 0 )
        fprintf(stderr, "proto_server_mt_cinfo_handler: "
                "proto_session_body_marshall_bytes failed\n");

    if (proto_session_body_marshall_char(s, occupied) < 0 )
        fprintf(stderr, "proto_server_mt_cinfo_handler: "
                "proto_session_body_marshall_bytes failed\n");

    rc = proto_session_send_msg(s, 1);
    // TODO: return failed if an error occours
    return rc;
}
Example #3
0
// ok, the SDOOR/SCORR part works.  however, none of the rest is tested
// (traps, mimics, swallowed, etc)
void do_search() // was dosearch
{
  Int8 x,y;
  trap_t *trap;
  monst_t *mtmp;
  UChar floor_type, tmp_type;

  if (you.uswallow) {
    message("What are you looking for? The exit?");
    return;
  }
  for (x = you.ux - 1 ; x <= you.ux + 1 ; x++)
    for (y = you.uy - 1 ; y <= you.uy + 1 ; y++) {
      if (x == you.ux && y == you.uy) continue;
      floor_type = get_cell_type(floor_info[x][y]);
      if (floor_type == SDOOR || floor_type == SCORR) {
	if (rund(7)) continue;
	tmp_type = (floor_type == SDOOR) ? DOOR : CORR;
	set_cell_type(floor_info[x][y], tmp_type);
	floor_info[x][y] &= ~SEEN_CELL;	/* force prl */
	prl(x,y);
	nomul(0);
      } else {
	/* Be careful not to find anything in an SCORR or SDOOR */
	mtmp = mon_at(x,y);
	if (mtmp && (mtmp->bitflags & M_IS_MIMIC)) {
	  see_mimic(mtmp);
	  message("You find a mimic.");
	  return;
	}
	for (trap = ftrap ; trap ; trap = trap->ntrap)
	  if (trap->tx == x && trap->ty == y &&
	      !(get_trap_seen(trap->trap_info)) && !rund(8)) {
	    nomul(0);
	    tmp_type = get_trap_type(trap->trap_info);
	    StrPrintF(ScratchBuffer, "You find a%s.", traps[tmp_type]);
	    message(ScratchBuffer);
	    if (tmp_type == PIERC) {
	      deltrap(trap);
	      makemon(PM_PIERCER, x, y);
	      return;
	    }
	    trap->trap_info |= SEEN_TRAP;
	    if (!vism_at(x,y))
	      print(x, y, '^');
	  }
      }
    }
}
Example #4
0
Char loc_symbol(Short x, Short y) // Equivalent of "news0"
{
  obj_t *otmp;
  trap_t *ttmp;
  UChar cell_type;
  Char c;
  Boolean blind = Blind;

  if (OUT_OF_BOUNDS(x,y)) return ' ';
  cell_type = get_cell_type(floor_info[x][y]);
  if (!get_cell_seen(floor_info[x][y]))
    c = ' ';
  else if (cell_type == POOL)
    c = POOL_SYM;
  else if (!blind && (otmp = obj_at(x,y)))
    c = otmp->olet;
  else if (!blind && gold_at(x,y))
    c = GOLD_SYM;
  else if (x == xupstair && y == yupstair)
    c = UPSTAIR_SYM;
  else if (x == xdnstair && y == ydnstair)
    c = DOWNSTAIR_SYM;
  else if ((ttmp = trap_at(x,y)) && get_trap_seen(ttmp->trap_info))
    c = TRAP_SYM;
  else switch(cell_type) {
  case HWALL: c = HWALL_SYM;  break;
  case VWALL: c = VWALL_SYM;  break;
  case CORR:  c = CORR_SYM;   break;
  case SCORR: case SDOOR:
    c = floor_symbol[x][y];	/* %% wrong after killing mimic ! */
    break;
  case LDOOR: case DOOR:
    c = DOOR_SYM;
    break;
  case ROOM:
    // the 'blind' here seems strange to me:
    if (get_cell_lit(floor_info[x][y]) || cansee(x,y) || blind) c = ROOM_SYM;
    else c = ' ';
    break;
  default:
    c = ERRCHAR;
  }
  return c;
}
Example #5
0
void tele_finish(Short x, Short y, Boolean controlled)
{
  Short nux,nuy;
  Boolean done = false;

  if (controlled) {
    if (teleok(x, y)) {
      teleds(x, y);
      done = true; //return;
    }
    message("Sorry ...");
  }
  if (!done) {
    do {
      nux = rnd(DCOLS-1);
      nuy = rund(DROWS);
    } while (!teleok(nux, nuy));
    teleds(nux, nuy);
  }
  // clean up after drowning victims
  if (map_mode_teleport == TELE_DROWN) {
    if (get_cell_type(floor_info[(Short) you.ux][(Short) you.uy]) == POOL)
      drown_finish();
    // else, after surviving, do we tick or not?  XXXX think about this.
  }
  // else, if scroll or command, tick; if random timer, don't tick.
  // wait hm.
  // random timer - never tick.
  // command - tick iff controlled
  // scroll - tick iff controlled
  // drown - ???
  // trap - ???
  else if (controlled && map_mode_teleport != TELE_RNDTIMER) {
    extern Boolean took_time;
    void end_turn_start_turn(); // in main.c
    took_time = true;
    end_turn_start_turn(); // XXXX
  }
  // finally, reset.
  map_mode_teleport = TELE_MAP;
}
Example #6
0
Short findit()   /* returns number of things found */
{
  Short num;
  UChar zx,zy;
  trap_t *ttmp;
  monst_t *mtmp;
  UChar lx,hx,ly,hy;

  if (you.uswallow) return false;
  for (lx = you.ux;
       (num = get_cell_type(floor_info[lx-1][you.uy])) && num != CORR; lx--) ;
  for (hx = you.ux;
       (num = get_cell_type(floor_info[hx+1][you.uy])) && num != CORR; hx++) ;
  for (ly = you.uy;
       (num = get_cell_type(floor_info[you.ux][ly-1])) && num != CORR; ly--) ;
  for (hy = you.uy;
       (num = get_cell_type(floor_info[you.ux][hy+1])) && num != CORR; hy++) ;
  num = 0;
  for (zy = ly; zy <= hy; zy++) {
    for (zx = lx; zx <= hx; zx++) {
      if (get_cell_type(floor_info[zx][zy]) == SDOOR) {
	set_cell_type(floor_info[zx][zy], DOOR);
	print(zx, zy, DOOR_SYM);
	num++;
      } else if (get_cell_type(floor_info[zx][zy]) == SCORR) {
	set_cell_type(floor_info[zx][zy], CORR);
	print(zx, zy, CORR_SYM);
	num++;
      } else if ((ttmp = trap_at(zx, zy))) {
	if (get_trap_type(ttmp->trap_info) == PIERC) {
	  makemon(PM_PIERCER, zx, zy);
	  num++;
	  deltrap(ttmp);
	} else if (!get_trap_seen(ttmp->trap_info)) {
	  ttmp->trap_info |= SEEN_TRAP;
	  if (!vism_at(zx, zy))
	    print(zx,zy,'^');
	  num++;
	}
      } else if ((mtmp = mon_at(zx,zy)) && (mtmp->bitflags & M_IS_MIMIC)) {
	see_mimic(mtmp);
	num++;
      }
    }
  }
  return num;
}
Example #7
0
static void teleds(Short nux, Short nuy)
{
  if (Punished) unplacebc();
  unsee();
  you.utrap = 0;
  you.ustuck = 0;
  you.ux = nux;
  you.uy = nuy;
  setsee();
  if (Punished) placebc(true);
  if (you.uswallow) {
    you.uswallowedtime = you.uswallow = 0;
    //    refresh(); //docrt();
  }
  move_visible_window(you.ux, you.uy, true);
  refresh();
  nomul(0);
  if (get_cell_type(floor_info[nux][nuy]) == POOL && !Levitation)
    drown();
  inshop();
  pickup(true);
  if (!Blind) read_engr_at(you.ux,you.uy);
}
Example #8
0
void drown() // not tested AT ALL yet
{
  tri_val_t result;
  message("You fall into a pool!");
  message("You can't swim!");
  if (rund(3) < you.uluck+2) {
    /* most scrolls become unreadable */
    obj_t *obj;
    for (obj = invent ; obj ; obj = obj->nobj)
      if (obj->olet == SCROLL_SYM && rund(12) > you.uluck)
	obj->otype = SCR_BLANK_PAPER;
    /* we should perhaps merge these scrolls ?  */ // if you say so.
    message("You attempt a teleport spell.");	// utcsri!carroll

    map_mode_teleport = TELE_DROWN;
    result = dotele(); // XXX Does not work right if you have Teleport_control!
    if (result != GO_ON)
      if (get_cell_type(floor_info[(Short) you.ux][(Short) you.uy]) != POOL)
	return; // else keep going to drown_finish.
    // for the case of GO_ON, we will check cell type in tele_finish,
    // which will call drown_finish if necessary.
  }
  drown_finish();
}
Example #9
0
/*
 * shk_move: return 1: he moved  0: he didnt  -1: let m_move do it
 * (what about "return 2" ???
 */
Short shk_move(monst_t *shkp)
{
  monst_t *mtmp;
  permonst_t *mdat = shkp->data;
  UChar gx,gy,omx,omy,nx,ny,nix,niy;
  Int8 appr,i;
  Short udist;
  Short z;
  Int8 shkroom,chi,chcnt,cnt;
  Boolean uondoor=false, satdoor, avoid=false, badinv;
  coord poss[9];
  Short info[9];
  obj_t *ib = NULL;

  omx = shkp->mx;
  omy = shkp->my;

  if ((udist = dist(omx,omy)) < 3) {
    if (ANGRY(shkp)) {
      hit_you(shkp, dice(mdat->damn, mdat->damd)+1);
      return 0;
    }
    if (ESHK(shkp)->following) {
      if (StrNCompare(ESHK(shkp)->customer, plname, PL_NSIZ)) {
	StrPrintF(ScratchBuffer, "Hello %s! I was looking for %s.",
		  plname, ESHK(shkp)->customer);
	message(ScratchBuffer);
	ESHK(shkp)->following = false;
	return 0;
      }
      if (!ESHK(shkp)->robbed) {	/* impossible? */
	ESHK(shkp)->following = false;
	return 0;
      }
      if (moves > followmsg+4) {
	StrPrintF(ScratchBuffer, "Hello %s! Didn't you forget to pay?",
		  plname);
	message(ScratchBuffer);
	followmsg = moves;
      }
      if (udist < 2)
	return 0;
    }
  }

  shkroom = inroom(omx,omy);
  appr = 1;
  gx = ESHK(shkp)->shk.x;
  gy = ESHK(shkp)->shk.y;
  satdoor = (gx == omx && gy == omy);
  if (ESHK(shkp)->following || ((z = holetime()) >= 0 && z*z <= udist)){
    gx = you.ux;
    gy = you.uy;
    if (shkroom < 0 || shkroom != inroom(you.ux,you.uy))
      if (udist > 4)
	return -1;	/* leave it to m_move */
  } else if (ANGRY(shkp)) {
    Long saveBlind = Blind;
    Blind = 0;
    if ((shkp->mcansee_and_blinded & M_CAN_SEE) && !Invis && cansee(omx,omy)) {
      gx = you.ux;
      gy = you.uy;
    }
    Blind = saveBlind;
    avoid = false;
  } else {
#define	GDIST(x,y)	((x-gx)*(x-gx)+(y-gy)*(y-gy))
    if (Invis)
      avoid = false;
    else {
      uondoor = (you.ux == ESHK(shkp)->shd.x &&
		 you.uy == ESHK(shkp)->shd.y);
      if (uondoor) {
	if (ESHK(shkp)->billct) {
	  StrPrintF(ScratchBuffer,
		    "Hello %s! Will you please pay before leaving?", plname);
	  message(ScratchBuffer);
	}
	badinv = (carrying(PICK_AXE) || carrying(ICE_BOX));
	if (satdoor && badinv)
	  return 0;
	avoid = !badinv;
      } else {
	avoid = (you.uinshop && dist(gx,gy) > 8);
	badinv = false;
      }

      if (((!ESHK(shkp)->robbed && !ESHK(shkp)->billct) || avoid)
	  && GDIST(omx,omy) < 3) {
	if (!badinv && !online(omx,omy))
	  return 0;
	if (satdoor)
	  appr = gx = gy = 0;
      }
    }
  }
  if (omx == gx && omy == gy)
    return 0;
  if (shkp->bitflags & M_IS_CONFUSED) {
    avoid = false;
    appr = 0;
  }
  nix = omx;
  niy = omy;
  cnt = mfindpos(shkp,poss,info,ALLOW_SSM);
  if (avoid && uondoor) {		/* perhaps we cannot avoid him */
    for (i=0; i<cnt; i++)
      if (!(info[i] & NOTONL)) goto notonl_ok;
    avoid = false;
  notonl_ok:
    ;
  }
  chi = -1;
  chcnt = 0;
  for (i = 0 ; i < cnt ; i++) {
    nx = poss[i].x;
    ny = poss[i].y;
    if (get_cell_type(floor_info[nx][ny]) == ROOM
	|| shkroom != ESHK(shkp)->shoproom
	|| ESHK(shkp)->following) {
#ifdef STUPID
      /* cater for stupid compilers */
      Short zz;
#endif STUPID
      if (uondoor && (ib = sobj_at(ICE_BOX, nx, ny))) {
	nix = nx; niy = ny; chi = i; break;
      }
      if (avoid && (info[i] & NOTONL))
	continue;
      if ((!appr && !rund(++chcnt)) ||
#ifdef STUPID
	  (appr && (zz = GDIST(nix,niy)) && zz > GDIST(nx,ny))
#else
	  (appr && GDIST(nx,ny) < GDIST(nix,niy))
#endif STUPID
	  ) {
	nix = nx;
	niy = ny;
	chi = i;
      }
    }
  }
  if (nix != omx || niy != omy) {
    if (info[chi] & ALLOW_M){
      mtmp = mon_at(nix,niy);
      if (hitmm(shkp,mtmp) == 1 && rund(3) &&
	  hitmm(mtmp,shkp) == 2) return 2;
      return 0;
    } else if (info[chi] & ALLOW_U){
      hit_you(shkp, dice(mdat->damn, mdat->damd)+1);
      return 0;
    }
    shkp->mx = nix;
    shkp->my = niy;
    pmon(shkp);
    if (ib) {
      unlink_obj(ib);//freeobj
      mpickobj(shkp, ib);
    }
    return 1;
  }
  return 0;
}