Esempio n. 1
0
static int	case_check_eastwest(t_client *client, t_srv *srv,
				    t_tmpview *tmpview)
{
  if (client->position.direction == EAST)
    {
      if (object_at(tmpview->begin->x,
		    (tmpview->begin->y + tmpview->i - 1) % srv->args.map_y,
		    tmpview->answer, srv) == FAILURE)
	return (FAILURE);
    }
  if (client->position.direction == WEST)
    {
      if ((tmpview->begin->y - tmpview->i + 1) < 0)
	{
	  if (object_at(tmpview->begin->x,
			srv->args.map_y + tmpview->begin->y - tmpview->i + 1,
			tmpview->answer, srv) == FAILURE)
	    return (FAILURE);
	}
      else if (object_at(tmpview->begin->x, tmpview->begin->y - tmpview->i + 1,
			 tmpview->answer, srv) == FAILURE)
  	return (FAILURE);
    }
  return (SUCCESS);
}
Esempio n. 2
0
// typetag: "ss" (inlet, outlet)
const Value Planet::link(const Value &val) {
  // std::cout << "link: " << val << std::endl;
  if (val.is_nil()) {
    return create_pending_links();
  }

  Value error;
  Object *source = object_at(Url(val[0].str()), &error);
  if (error.is_error() || !object_at(Url(val[2].str()), &error)) {
    // not found
    if (val[1].str() == "=>") {
      return add_pending_link(val);
    } else if (val[1].str() == "||") {
      // remove from pending links
      return remove_pending_link(val);
    }
    return val;
  }

  Slot   *slot = TYPE_CAST(Slot, source);
  Object *object;
  if (slot != NULL) {
    return val[1].str() == "||" ? slot->unlink(val[2]) : slot->link(val[2]);
  } else if ( (object = source->child("out")) && (object = object->first_child()) ) {
    // was a link default slots: /met/out --> /counter/in
    if ( (slot = TYPE_CAST(Slot, object)) ) {
      return val[1].str() == "||" ? slot->unlink(val[2]) : slot->link(val[2]);
    } else {
      return Value(BAD_REQUEST_ERROR, std::string("Object at '").append(slot->url()).append("' does not support links (using first child of '").append(source->url()).append("')."));
    }
  } else {
    return Value(BAD_REQUEST_ERROR, std::string("Object at '").append(source->url()).append("' does not support links (not an Outlet, Inlet or Node)."));
  }
}
Esempio n. 3
0
void
fight(boolean to_the_death)
{
	short ch, c, d;
	short row, col;
	boolean first_miss = 1;
	short possible_damage;
	object *monster;

	while (!is_direction(ch = rgetchar(), &d)) {
		sound_bell();
		if (first_miss) {
			message("direction?", 0);
			first_miss = 0;
		}
	}
	check_message();
	if (ch == CANCEL) {
		return;
	}
	row = rogue.row; col = rogue.col;
	get_dir_rc(d, &row, &col, 0);

	c = mvinch(row, col);
	if (((c < 'A') || (c > 'Z')) ||
		(!can_move(rogue.row, rogue.col, row, col))) {
		message("I see no monster there", 0);
		return;
	}
	if (!(fight_monster = object_at(&level_monsters, row, col))) {
		return;
	}
	if (!(fight_monster->m_flags & STATIONARY)) {
		possible_damage = ((get_damage(fight_monster->m_damage, 0) * 2) / 3);
	} else {
		possible_damage = fight_monster->stationary_damage - 1;
	}
	while (fight_monster) {
		one_move_rogue(ch, 0);
		if (((!to_the_death) && (rogue.hp_current <= possible_damage)) ||
			interrupted || (!(dungeon[row][col] & MONSTER))) {
			fight_monster = NULL;
		} else {
			monster = object_at(&level_monsters, row, col);
			if (monster != fight_monster) {
				fight_monster = NULL;
			}
		}
	}
}
Esempio n. 4
0
// Attempts to open a door if present, return 1 on succesful open
int attempt_open_door(player_t* p, room_t* r)
{
    object_t* door = NULL;
    
    if(is_of_type(object_at(p->pos.x - 1, p->pos.y, r), DOOR_ID))
        door = object_at(p->pos.x - 1, p->pos.y, r);

    else if(is_of_type(object_at(p->pos.x + 1, p->pos.y, r), DOOR_ID))
        door = object_at(p->pos.x + 1, p->pos.y, r);

    else if(is_of_type(object_at(p->pos.x, p->pos.y - 1, r), DOOR_ID))
        door = object_at(p->pos.x, p->pos.y - 1, r);

    else if(is_of_type(object_at(p->pos.x, p->pos.y + 1, r), DOOR_ID))
        door = object_at(p->pos.x, p->pos.y + 1, r);

    if(door != NULL)
	{
        open_door(door);
		return 1;
	}
	else
	{
		return 0;
	}
}
Esempio n. 5
0
static void
hold_monster(void)
{
	short i, j;
	short mcount = 0;
	object *monster;
	short row, col;

	for (i = -2; i <= 2; i++) {
		for (j = -2; j <= 2; j++) {
			row = rogue.row + i;
			col = rogue.col + j;
			if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
				 (col > (DCOLS-1))) {
				continue;
			}
			if (dungeon[row][col] & MONSTER) {
				monster = object_at(&level_monsters, row, col);
				monster->m_flags |= ASLEEP;
				monster->m_flags &= (~WAKENS);
				mcount++;
			}
		}
	}
	if (mcount == 0) {
		message("you feel a strange sense of loss", 0);
	} else if (mcount == 1) {
		message("the monster freezes", 0);
	} else {
		message("the monsters around you freeze", 0);
	}
}
Esempio n. 6
0
void
hold_monster(void)
{
    short i, j;
    short mcount = 0;
    object *monster;
    short row, col;

    for (i = -2; i <= 2; i++) {
	for (j = -2; j <= 2; j++) {
	    row = rogue.row + i;
	    col = rogue.col + j;
	    if ((row < MIN_ROW) || (row > (ROGUE_LINES - 2)) || (col < 0) ||
		(col > (ROGUE_COLUMNS - 1))) {
		continue;
	    }
	    if (dungeon[row][col] & MONSTER) {
		monster = object_at(&level_monsters, row, col);
		monster->m_flags |= ASLEEP;
		monster->m_flags &= (~WAKENS);
		mcount++;
	    }
	}
    }
    if (mcount == 0) {
	message(mesg[269], 0);
    } else if (mcount == 1) {
	message(mesg[270], 0);
    } else {
	message(mesg[271], 0);
    }
}
Esempio n. 7
0
int
gold_at(short row, short col)
{
    if (dungeon[row][col] & OBJECT) {
	object *obj;

	if ((obj = object_at(&level_objects, row, col)) &&
	    (obj->what_is == GOLD)) {
	    return 1;
	}
    }
    return 0;
}
Esempio n. 8
0
int
imitating(short row, short col)
{
    if (dungeon[row][col] & MONSTER) {
	object *monster;

	if ((monster = object_at(&level_monsters, row, col))) {
	    if (monster->m_flags & IMITATES) {
		return 1;
	    }
	}
    }
    return 0;
}
Esempio n. 9
0
int		view_get_line(t_client *client, char **answer, int range,
			      t_srv *srv)
{
  if (range == 1)
    {
      if (object_at(client->position.x, client->position.y, answer, srv)
	  == FAILURE)
	return (FAILURE);
    }
  else
    if (case_by_case(client, answer, range, srv) == FAILURE)
      return (FAILURE);
  return (SUCCESS);
}
Esempio n. 10
0
static int	case_check_northsouth(t_client *client, t_srv *srv,
				      t_tmpview *tmpview)
{
  if (client->position.direction == NORTH)
    {
      if (object_at((tmpview->begin->x + tmpview->i - 1) % srv->args.map_x,
		    tmpview->begin->y, tmpview->answer, srv) == FAILURE)
	return (FAILURE);
    }
  if (client->position.direction == SOUTH)
    {
      if ((tmpview->begin->x - tmpview->i + 1) < 0)
	{
	  if (object_at(srv->args.map_x + tmpview->begin->x - tmpview->i + 1,
			tmpview->begin->y, tmpview->answer, srv) == FAILURE)
	    return (FAILURE);
	}
      else if (object_at(tmpview->begin->x - tmpview->i + 1,
			 tmpview->begin->y, tmpview->answer, srv) == FAILURE)
	return (FAILURE);
    }
  return (SUCCESS);
}
Esempio n. 11
0
int mon_can_go(object *monster, short row, short col)
{
    object *obj;
    short dr, dc;

    dr = monster->row - row;	/* check if move distance > 1 */
    if ((dr >= 2) || (dr <= -2))
    {
        return(0);
    }
    dc = monster->col - col;
    if ((dc >= 2) || (dc <= -2))
    {
        return(0);
    }
    if ((!dungeon[monster->row][col]) || (!dungeon[row][monster->col]))
    {
        return(0);
    }
    if ((!is_passable(row, col)) || (dungeon[row][col] & MONSTER))
    {
        return(0);
    }
    if ((monster->row!=row) && (monster->col!=col)
            && ((dungeon[row][col]&DOOR)
                || (dungeon[monster->row][monster->col]&DOOR)))
    {
        return(0);
    }
    if (!(monster->m_flags & (FLITS | CONFUSED | CAN_FLIT)) &&
            (monster->trow == NO_ROOM))
    {
        if ((monster->row < rogue.row) && (row < monster->row)) return(0);
        if ((monster->row > rogue.row) && (row > monster->row)) return(0);
        if ((monster->col < rogue.col) && (col < monster->col)) return(0);
        if ((monster->col > rogue.col) && (col > monster->col)) return(0);
    }
    if (dungeon[row][col] & OBJECT)
    {
        obj = object_at(&level_objects, row, col);
        if ((obj->what_is == SCROLL) && (obj->which_kind == SCARE_MONSTER))
        {
            return(0);
        }
    }
    return(1);
}
char
gmc_row_col(int row, int col)
{
	object *monster;

	if ((monster = object_at(&level_monsters, row, col)) != NULL) {
		if ((!(detect_monster || see_invisible || r_see_invisible) &&
			(monster->m_flags & INVISIBLE)) || blind) {
			return(monster->trail_char);
		}
		if (monster->m_flags & IMITATES) {
			return(monster->disguise);
		}
		return(monster->m_char);
	} else {
		return('&');	/* BUG if this ever happens */
	}
}
Esempio n. 13
0
void sleepify( object *scroll )
{
	/* (zerogue 0.4.0) Added mechanic where a scroll of sleep can be used to
	 * put nearby monsters to sleep.  Modelled after hold_monster().
	 */
	short mcount = 0 ;
	short row, col ;

	if( scroll->identified || id_scrolls[scroll->which_kind].id_status == IDENTIFIED )
	{
		for( row = (rogue.row - 2) ; row <= (rogue.row + 2) ; row++ )
		{
			for( col = (rogue.col - 2) ; col <= (rogue.col + 2) ; col++ )
			{
				if( (row<MIN_ROW) || (row>(DROWS-2)) || (col<0) || (col>(DCOLS-1)) )
					continue ;

				if( dungeon[row][col] & MONSTER )
				{
					object *monster = object_at( &level_monsters, row, col ) ;
					monster->m_flags |= ( ASLEEP | NAPPING ) ;
					monster->nap_length += get_rand( 3, ( get_rogue_level(1) + 2 ) ) ; // (zerogue 0.4.1)
					++mcount ;
				}
			}
		}
	}

	if( mcount == 0 )
	{
		message( "You fall asleep.", 0 ) ;
		take_a_nap() ;
	}
	else if( mcount == 1 )
		message( "The monster falls asleep!", 0 ) ;
	else
		message( "The monsters around you fall asleep!", 0 ) ;

	return ;
}