void curses_putch(winid wid, int x, int y, int ch, int color, int attr) { WINDOW *win; boolean border = curses_window_has_border(wid); if (border && (wid != MAP_WIN)) { x++; y++; } win = curses_get_nhwin(wid); curses_toggle_color_attr(win, color, attr, ON); #ifdef PDCURSES mvwaddrawch(win, y, x, ch); #else mvwaddch(win, y, x, ch); #endif if (wid == MAP_WIN) { refresh_map_window(); } else { wrefresh(win); } curses_toggle_color_attr(win, color, attr, OFF); }
void fall(struct linked_list *item, int pr) { struct object *obj; struct room *rp; static coord fpos; obj = (struct object *) ldata(item); if (fallpos(&obj->o_pos, &fpos, TRUE)) { mvaddrawch(fpos.y, fpos.x, obj->o_type); obj->o_pos = fpos; if ((rp = roomin(&hero)) != NULL && !(rp->r_flags & ISDARK)) { light(&hero); mvwaddrawch(cw, hero.y, hero.x, PLAYER); } attach(lvl_obj, item); return; } if (pr) if (obj->o_type == WEAPON) /* BUGFUX: Identification trick */ msg("Your %s vanishes as it hits the ground.", w_names[obj->o_which]); else msg("%s vanishes as it hits the ground.", inv_name(obj,TRUE)); discard(item); }
static void write_char(WINDOW *win, int x, int y, nethack_char nch) { curses_toggle_color_attr(win, nch.color, nch.attr, ON); #ifdef PDCURSES mvwaddrawch(win, y, x, nch.ch); #else mvwaddch(win, y, x, nch.ch); #endif curses_toggle_color_attr(win, nch.color, nch.attr, OFF); }
/* * do the actual motion on the screen done by an object traveling * across the room */ void do_motion(struct object *obj, int ydelta, int xdelta) { /* * Come fly with us ... */ obj->o_pos = hero; for (;;) { int ch; /* * Erase the old one */ if (!ce(obj->o_pos, hero) && cansee(unc(obj->o_pos)) && CMVWINCH(cw, obj->o_pos.y, obj->o_pos.x) != ' ') mvwaddrawch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)); /* * Get the new position */ obj->o_pos.y += ydelta; obj->o_pos.x += xdelta; if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR) { /* * It hasn't hit anything yet, so display it * If it alright. */ if (cansee(unc(obj->o_pos)) && CMVWINCH(cw, obj->o_pos.y, obj->o_pos.x) != ' ') { mvwaddrawch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type); draw(cw); } continue; } break; } }
void missile(int ydelta, int xdelta) { struct object *obj; struct linked_list *item, *nitem; /* * Get which thing we are hurling */ if ((item = get_item("throw", WEAPON)) == NULL) return; obj = (struct object *) ldata(item); if (!dropcheck(obj) || is_current(obj)) return; /* * Get rid of the thing. If it is a non-multiple item object, or * if it is the last thing, just drop it. Otherwise, create a new * item with a count of one. */ if (obj->o_count < 2) { detach(pack, item); inpack--; } else { obj->o_count--; if (obj->o_group == 0) inpack--; nitem = (struct linked_list *) new_item(sizeof *obj); obj = (struct object *) ldata(nitem); *obj = *((struct object *) ldata(item)); obj->o_count = 1; item = nitem; } do_motion(obj, ydelta, xdelta); /* * AHA! Here it has hit something. If it is a wall or a door, * or if it misses (combat) the mosnter, put it on the floor */ if (!ismons(CMVWINCH(mw, obj->o_pos.y, obj->o_pos.x)) || !hit_monster(unc(obj->o_pos), obj)) fall(item, TRUE); mvwaddrawch(cw, hero.y, hero.x, PLAYER); }
void drawMap() { int XIndex, YIndex; for (YIndex = 0; YIndex < MAP_DISPLAY_HEIGHT; YIndex++) { for (XIndex = 0; XIndex < MAP_DISPLAY_WIDTH; XIndex++) { switch(grid[YIndex+mapTopY][XIndex+mapTopX]) { case WALL: wattrset(win,COLOR_PAIR(4)); mvwaddrawch(win,YIndex+1,XIndex+1,ACS_BOARD); wattroff(win,COLOR_PAIR(4)); break; case GRAVEL: wattrset(win,COLOR_PAIR(11) | A_NORMAL); mvwprintw(win,YIndex+1,XIndex+1,"."); wattroff(win,COLOR_PAIR(11) | A_NORMAL); break; } } } }
int do_chase(struct thing *th) { struct room *rer, *ree; /* room of chaser, room of chasee */ int mindist = 32767, i, dist; int stoprun = FALSE; /* TRUE means we are there */ int sch; coord this; /* Temporary destination for chaser */ rer = roomin(&th->t_pos); /* Find room of chaser */ ree = roomin(th->t_dest); /* Find room of chasee */ /* * We don't count doors as inside rooms for this routine */ if (CMVWINCH(stdscr, th->t_pos.y, th->t_pos.x) == DOOR) rer = NULL; this = *th->t_dest; /* * If the object of our desire is in a different room, * than we are and we ar not in a corridor, run to the * door nearest to our goal. */ if (rer != NULL && rer != ree) for (i = 0; i < rer->r_nexits; i++) /* loop through doors */ { dist = DISTANCE(th->t_dest->y, th->t_dest->x, rer->r_exit[i].y, rer->r_exit[i].x); if (dist < mindist) /* minimize distance */ { this = rer->r_exit[i]; mindist = dist; } } /* * this now contains what we want to run to this time * so we run to it. If we hit it we either want to fight it * or stop running */ if (!chase(th, &this)) { if (ce(this, hero)) { return( attack(th) ); } else if (th->t_type != 'F') stoprun = TRUE; } else if (th->t_type == 'F') return(0); mvwaddrawch(cw, th->t_pos.y, th->t_pos.x, th->t_oldch); sch = CMVWINCH(cw, ch_ret.y, ch_ret.x); if (rer != NULL && (rer->r_flags & ISDARK) && sch == FLOOR && DISTANCE(ch_ret.y, ch_ret.x, th->t_pos.y, th->t_pos.x) < 3 && off(player, ISBLIND)) th->t_oldch = ' '; else th->t_oldch = sch; if (cansee(unc(ch_ret)) && !on(*th, ISINVIS)) mvwaddrawch(cw, ch_ret.y, ch_ret.x, th->t_type); mvwaddrawch(mw, th->t_pos.y, th->t_pos.x, ' '); mvwaddrawch(mw, ch_ret.y, ch_ret.x, th->t_type); th->t_pos = ch_ret; /* * And stop running if need be */ if (stoprun && ce(th->t_pos, *(th->t_dest))) th->t_flags &= ~ISRUN; return(0); }