void zone_draw(zone * z) { int i, j; wclear(dispscr); for (i = 0; i < z->width; i++) { for (j = 0; j < z->height; j++) { zone_draw_tile(z, i, j); } } wrefresh(dispscr); }
static void update_vis(void) { int x, y, show; for (x = 0; x < PLYR.z->width; x++) { for (y = 0; y < PLYR.z->height; y++) { show = zone_can_see(PLYR.z, PLYR.x, PLYR.y, x, y, PLYR.sight); if (show != PLYR.z->tiles[x][y].show) { PLYR.z->tiles[x][y].show = show || config.forget_walls ? show : 2; zone_draw_tile(PLYR.z, x, y); } } } wrefresh(dispscr); }
void zone_update(zone * z, int x, int y) { int i; int weight = -1; item * it; chtype ch = z->tiles[x][y].ch; if (z->tiles[x][y].crtr == NULL || z->tiles[x][y].crtr->health <= 0) { for (i = 0; i < z->tiles[x][y].inv->size; i++) { it = z->tiles[x][y].inv->itms[i]; if (it != NULL && it->weight > weight) { weight = it->weight; ch = it->ch; } } } else { ch = z->tiles[x][y].crtr->ch; } z->tiles[x][y].show_ch = ch; zone_draw_tile(z, x, y); }
// // Throws an item from a position along the given direction // (x, y, z) + (dx, dy) is the starting position. // (dx, dy) is the direction the item moves in. // f is the force of the throw, effects duration and damage of the throw // Returns 1 on success and 0 on failure of placing the item // int item_throw(item * it, int x, int y, zone * z, int dx, int dy, int force) { creature * c; int ret, dam; int anim = (z == PLYR.z) && config.throw_anim_delay; int timeout = 100 * force / it->weight; chtype tmp = 0; x += dx; y += dy; while (x >= 0 && y >= 0 && x < z->width && y < z->height && !z->tiles[x][y].impassible && timeout) { if (x < 0 || x >= z->width) break; if (y < 0 || y >= z->height) break; if (z->tiles[x][y].impassible) break; // handle the animation if (anim) { if (tmp) { z->tiles[x-dx][y-dy].ch = tmp; zone_draw_tile(z, x-dx, y-dy); } tmp = z->tiles[x][y].ch; z->tiles[x][y].ch = it->ch; zone_draw_tile(z, x, y); wrefresh(dispscr); usleep(1000 * config.throw_anim_delay); } // creature collision c = z->tiles[x][y].crtr; if (c != NULL) { if (crtr_dodges(c, force / 10)) { memo("The %s artfully dodges the %s!", crtr_name(c), it->name); } else { dam = (it->spikiness + force) / 4 - 4; if (dam < 0) dam = 0; c->health -= dam; if (c->health <= 0) { memo("The %s kills the %s!\n", it->name, crtr_name(c)); crtr_death(c, "projectile impact"); } else { memo("The %s is hit with the %s for %d damage!", crtr_name(c), it->name, dam); } goto cleanup; } } x += dx; y += dy; timeout--; } x -= dx; y -= dy; cleanup: ret = item_tele(it, x, y, z); zone_update(z, x, y); wrefresh(dispscr); return ret; }