/* Monster hit animation */ void game::draw_hit_mon(int x, int y, monster m, bool dead) { if (use_tiles) { //int iTimeout = 0; tilecontext->init_draw_hit(x, y, m.type->id); wrefresh(w_terrain); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = BULLET_SPEED; nanosleep(&tspec, NULL); mvwputch(w_terrain, POSX + (x - (u.posx + u.view_offset_x)), POSY + (y - (u.posy + u.view_offset_y)), c_white, ' '); wrefresh(w_terrain); } else { nc_color cMonColor = m.type->color; char sMonSym = m.symbol(); hit_animation(POSX + (x - (u.posx + u.view_offset_x)), POSY + (y - (u.posy + u.view_offset_y)), red_background(cMonColor), dead ? '%' : sMonSym); } }
/* Player hit animation */ void game::draw_hit_player(player *p, bool dead) { if (use_tiles) { // get base name of player id std::string pname = (p->is_npc()?"npc_":"player_"); // get sex of player pname += (p->male?"male":"female"); tilecontext->init_draw_hit(p->posx, p->posy, pname); wrefresh(w_terrain); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = BULLET_SPEED; nanosleep(&tspec, NULL); mvwputch(w_terrain, POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), c_white, ' '); wrefresh(w_terrain); } else { hit_animation(POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), red_background(p->color()), '@'); } }
/* Player hit animation */ void game::draw_hit_player(player *p, const int iDam, bool dead) { (void)dead; //unused hit_animation(POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), (iDam == 0) ? yellow_background(p->color()) : red_background(p->color()), '@'); }
/* Player hit animation */ void game::draw_hit_player(player *p, const int iDam, bool dead) { (void)dead; //unused if (use_tiles) { // get base name of player id std::string pname = (p->is_npc() ? "npc_" : "player_"); // get sex of player pname += (p->male ? "male" : "female"); tilecontext->init_draw_hit(p->posx, p->posy, pname); wrefresh(w_terrain); try_update(); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = 1000000 * OPTIONS["ANIMATION_DELAY"]; if( tspec.tv_nsec != 0 ) { nanosleep(&tspec, NULL); } } else { hit_animation(POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), (iDam == 0) ? yellow_background(p->symbol_color()) : red_background(p->symbol_color()), "@"); } }
/* Player hit animation */ void game::draw_hit_player(player *p, const int iDam, bool dead) { (void)dead; //unused const std::string &sMonSym = p->symbol(); hit_animation(POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), (iDam == 0) ? yellow_background(p->symbol_color()) : red_background(p->symbol_color()), sMonSym); }
nc_color monster::color_with_effects() { nc_color ret = type->color; if (has_effect("beartrap") || has_effect("stunned") || has_effect("downed")) ret = hilite(ret); if (has_effect("onfire")) ret = red_background(ret); return ret; }
/* Monster hit animation */ void game::draw_hit_mon(int x, int y, monster m, bool dead) { nc_color cMonColor = m.type->color; const std::string &sMonSym = m.symbol(); hit_animation(POSX + (x - (u.posx + u.view_offset_x)), POSY + (y - (u.posy + u.view_offset_y)), red_background(cMonColor), dead ? "%" : sMonSym); }
nc_color monster::color_with_effects() { nc_color ret = type->color; if (has_effect(ME_BEARTRAP) || has_effect(ME_STUNNED)) ret = hilite(ret); if (has_effect(ME_ONFIRE)) ret = red_background(ret); return ret; }
void veh_interact::move_cursor (int dx, int dy) { mvwputch (w_disp, cy+6, cx+6, cpart >= 0? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0? veh->part_sym (cpart) : ' ')); cx += dx; cy += dy; cpart = part_at (cx, cy); int vdx = -ddx - cy; int vdy = cx - ddy; int vx, vy; veh->coord_translate (vdx, vdy, vx, vy); int vehx = veh->global_x() + vx; int vehy = veh->global_y() + vy; bool obstruct = g->m.move_cost_ter_only (vehx, vehy) == 0; vehicle *oveh = g->m.veh_at (vehx, vehy); if (oveh && oveh != veh) obstruct = true; nc_color col = cpart >= 0? veh->part_color (cpart) : c_black; mvwputch (w_disp, cy+6, cx+6, obstruct? red_background(col) : hilite(col), special_symbol(cpart >= 0? veh->part_sym (cpart) : ' ')); wrefresh (w_disp); werase (w_parts); veh->print_part_desc (w_parts, 0, winw2, cpart, -1); wrefresh (w_parts); can_mount.clear(); has_mats.clear(); if (!obstruct) for (int i = 1; i < num_vparts; i++) { if (veh->can_mount (vdx, vdy, (vpart_id) i)) can_mount.push_back (i); } need_repair.clear(); parts_here.clear(); ptank = -1; if (cpart >= 0) { parts_here = veh->internal_parts(cpart); parts_here.insert (parts_here.begin(), cpart); for (int i = 0; i < parts_here.size(); i++) { int p = parts_here[i]; if (veh->parts[p].hp < veh->part_info(p).durability) need_repair.push_back (i); if (veh->part_flag(p, vpf_fuel_tank) && veh->parts[p].amount < veh->part_info(p).size) ptank = p; } } has_fuel = ptank >= 0? g->pl_refill_vehicle(*veh, ptank, true) : false; werase (w_msg); wrefresh (w_msg); display_mode (' '); }
nc_color monster::color_with_effects() const { nc_color ret = type->color; if (has_effect("beartrap") || has_effect("stunned") || has_effect("downed") || has_effect("tied")) { ret = hilite(ret); } if (has_effect("pacified")) { ret = invert_color(ret); } if (has_effect("onfire")) { ret = red_background(ret); } return ret; }
/* Player hit animation */ void game::draw_hit_player(player *p, bool dead) { if (use_tiles) { // get base name of player id std::string pname = (p->is_npc()?"npc_":"player_"); // get sex of player pname += (p->male?"male":"female"); tilecontext->init_draw_hit(p->posx, p->posy, pname); wrefresh(w_terrain); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = BULLET_SPEED; nanosleep(&tspec, NULL); /* hit_animation(p->posx - g->u.posx + VIEWX - g->u.view_offset_x, p->posy - g->u.posy + VIEWY - g->u.view_offset_y, red_background(p->color()), '@'); */ /* if (iTimeout <= 0 || iTimeout > 999) { iTimeout = 70; } timeout(iTimeout); getch(); //useing this, because holding down a key with nanosleep can get yourself killed timeout(-1); */ mvwputch(w_terrain, p->posx + VIEWX - u.posx - u.view_offset_x, p->posy + VIEWY - u.posy - u.view_offset_y, c_white, ' '); wrefresh(w_terrain); } else { hit_animation(p->posx + VIEWX - u.posx - u.view_offset_x, p->posy + VIEWY - u.posy - u.view_offset_y, red_background(p->color()), '@'); } }
/* Monster hit animation */ void game::draw_hit_mon(int x, int y, monster m, bool dead) { if (use_tiles) { //int iTimeout = 0; tilecontext->init_draw_hit(x, y, monster_names[m.type->id]); wrefresh(w_terrain); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = BULLET_SPEED; nanosleep(&tspec, NULL); /* nc_color cMonColor = m.type->color; char sMonSym = m.symbol(); hit_animation(x, y, red_background(cMonColor), dead?'%':sMonSym); */ /* x + VIEWX - u.posx - u.view_offset_x, y + VIEWY - u.posy - u.view_offset_y, */ mvwputch(w_terrain, x + VIEWX - u.posx - u.view_offset_x, y + VIEWY - u.posy - u.view_offset_y, c_white, ' '); wrefresh(w_terrain); } else { nc_color cMonColor = m.type->color; char sMonSym = m.symbol(); hit_animation(x + VIEWX - u.posx - u.view_offset_x, y + VIEWY - u.posy - u.view_offset_y, red_background(cMonColor), dead?'%':sMonSym); } }
void sokoban_game::draw_level(WINDOW *w_sokoban) { const int iOffsetX = (FULL_SCREEN_WIDTH - 2 - mLevelInfo[iCurrentLevel]["MaxLevelX"]) / 2; const int iOffsetY = (FULL_SCREEN_HEIGHT - 2 - mLevelInfo[iCurrentLevel]["MaxLevelY"]) / 2; for (std::map<int, std::map<int, std::string> >::iterator iterY = mLevel.begin(); iterY != mLevel.end(); ++iterY) { for (std::map<int, std::string>::iterator iterX = (iterY->second).begin(); iterX != (iterY->second).end(); ++iterX) { std::string sTile = iterX->second; if (sTile == "#") { mvwputch(w_sokoban, iOffsetY + (iterY->first), iOffsetX + (iterX->first), c_white, get_wall_connection(iterY->first, iterX->first)); } else { nc_color cCol = c_white; if (sTile == "." || sTile == "*" || sTile == "+") { cCol = red_background(c_white); } if (sTile == ".") { sTile = " "; } if (sTile == "*") { sTile = "$"; } if (sTile == "+") { sTile = "@"; } mvwprintz(w_sokoban, iOffsetY + (iterY->first), iOffsetX + (iterX->first), cCol, sTile.c_str()); } } } }
/* Monster hit animation */ void game::draw_hit_mon(int x, int y, monster m, bool dead) { if (use_tiles) { //int iTimeout = 0; tilecontext->init_draw_hit(x, y, m.type->id); wrefresh(w_terrain); try_update(); timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = 1000000 * OPTIONS["ANIMATION_DELAY"]; if( tspec.tv_nsec != 0 ) { nanosleep(&tspec, NULL); } } else { nc_color cMonColor = m.type->color; const std::string &sMonSym = m.symbol(); hit_animation(POSX + (x - (u.posx + u.view_offset_x)), POSY + (y - (u.posy + u.view_offset_y)), red_background(cMonColor), dead ? "%" : sMonSym); } }
void test_pattern(int iCurrentPage, int iCurrentLine) { std::vector<std::string> vMatchingItems; std::string sItemName = ""; if (vAutoPickupRules[iCurrentPage][iCurrentLine].sRule == "") { return; } //Loop through all itemfactory items //TODO: somehow generate damaged, fitting or container items for (int i = 0; i < standard_itype_ids.size(); i++) { sItemName = item_controller->find_template(standard_itype_ids[i])->name; if (vAutoPickupRules[iCurrentPage][iCurrentLine].bActive && auto_pickup_match(sItemName, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule)) { vMatchingItems.push_back(sItemName); } } const int iOffsetX = 15 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0); const int iOffsetY = 5 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0); int iStartPos = 0; const int iContentHeight = FULL_SCREEN_HEIGHT - 8; const int iContentWidth = FULL_SCREEN_WIDTH - 30; char ch; std::stringstream sTemp; WINDOW* w_test_rule_border = newwin(iContentHeight + 2, iContentWidth, iOffsetY, iOffsetX); WINDOW* w_test_rule_content = newwin(iContentHeight, iContentWidth - 2, 1 + iOffsetY, 1 + iOffsetX); wborder(w_test_rule_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX); int nmatch = vMatchingItems.size(); std::string buf = string_format(ngettext("%1$d item matches: %2$s", "%1$d items match: %2$s", nmatch), nmatch, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule.c_str()); mvwprintz(w_test_rule_border, 0, iContentWidth/2 - utf8_width(buf.c_str())/2, hilite(c_white), buf.c_str()); mvwprintz(w_test_rule_border, iContentHeight + 1, 1, red_background(c_white), _("Won't display damaged, fits and can/bottle items")); wrefresh(w_test_rule_border); iCurrentLine = 0; do { // Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { mvwputch(w_test_rule_content, i, j, c_black, ' '); } } calcStartPos(iStartPos, iCurrentLine, iContentHeight, vMatchingItems.size()); // display auto pickup for (int i = iStartPos; i < vMatchingItems.size(); i++) { if (i >= iStartPos && i < iStartPos + ((iContentHeight > vMatchingItems.size()) ? vMatchingItems.size() : iContentHeight)) { nc_color cLineColor = c_white; sTemp.str(""); sTemp << i + 1; mvwprintz(w_test_rule_content, i - iStartPos, 0, cLineColor, sTemp.str().c_str()); mvwprintz(w_test_rule_content, i - iStartPos, 4, cLineColor, ""); if (iCurrentLine == i) { wprintz(w_test_rule_content, c_yellow, ">> "); } else { wprintz(w_test_rule_content, c_yellow, " "); } wprintz(w_test_rule_content, (iCurrentLine == i) ? hilite(cLineColor) : cLineColor, vMatchingItems[i].c_str()); } } wrefresh(w_test_rule_content); ch = (char)input(); switch(ch) { case 'j': //move down iCurrentLine++; if (iCurrentLine >= vMatchingItems.size()) { iCurrentLine = 0; } break; case 'k': //move up iCurrentLine--; if (iCurrentLine < 0) { iCurrentLine = vMatchingItems.size()-1; } break; } } while(ch == 'j' || ch == 'k'); werase(w_test_rule_border); werase(w_test_rule_content); }
void test_pattern(int iCurrentPage, int iCurrentLine) { std::vector<std::string> vMatchingItems; std::string sItemName = ""; if (vAutoPickupRules[iCurrentPage][iCurrentLine].sRule == "") { return; } //Loop through all itemfactory items //APU now ignores prefixes, bottled items and suffix combinations still not generated for( auto &p : item_controller->get_all_itypes() ) { sItemName = p.second->nname(1); if (vAutoPickupRules[iCurrentPage][iCurrentLine].bActive && auto_pickup_match(sItemName, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule)) { vMatchingItems.push_back(sItemName); } } const int iOffsetX = 15 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0); const int iOffsetY = 5 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0); int iStartPos = 0; const int iContentHeight = FULL_SCREEN_HEIGHT - 8; const int iContentWidth = FULL_SCREEN_WIDTH - 30; std::stringstream sTemp; WINDOW *w_test_rule_border = newwin(iContentHeight + 2, iContentWidth, iOffsetY, iOffsetX); WINDOW_PTR w_test_rule_borderptr( w_test_rule_border ); WINDOW *w_test_rule_content = newwin(iContentHeight, iContentWidth - 2, 1 + iOffsetY, 1 + iOffsetX); WINDOW_PTR w_test_rule_contentptr( w_test_rule_content ); draw_border(w_test_rule_border); int nmatch = vMatchingItems.size(); std::string buf = string_format(ngettext("%1$d item matches: %2$s", "%1$d items match: %2$s", nmatch), nmatch, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule.c_str()); mvwprintz(w_test_rule_border, 0, iContentWidth / 2 - utf8_width(buf.c_str()) / 2, hilite(c_white), "%s", buf.c_str()); mvwprintz(w_test_rule_border, iContentHeight + 1, 1, red_background(c_white), _("Won't display bottled and suffixes=(fits)")); wrefresh(w_test_rule_border); iCurrentLine = 0; input_context ctxt("AUTO_PICKUP_TEST"); ctxt.register_updown(); ctxt.register_action("QUIT"); while(true) { // Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { mvwputch(w_test_rule_content, i, j, c_black, ' '); } } calcStartPos(iStartPos, iCurrentLine, iContentHeight, vMatchingItems.size()); // display auto pickup for (int i = iStartPos; i < (int)vMatchingItems.size(); i++) { if (i >= iStartPos && i < iStartPos + ((iContentHeight > (int)vMatchingItems.size()) ? (int)vMatchingItems.size() : iContentHeight)) { nc_color cLineColor = c_white; sTemp.str(""); sTemp << i + 1; mvwprintz(w_test_rule_content, i - iStartPos, 0, cLineColor, "%s", sTemp.str().c_str()); mvwprintz(w_test_rule_content, i - iStartPos, 4, cLineColor, ""); if (iCurrentLine == i) { wprintz(w_test_rule_content, c_yellow, ">> "); } else { wprintz(w_test_rule_content, c_yellow, " "); } wprintz(w_test_rule_content, (iCurrentLine == i) ? hilite(cLineColor) : cLineColor, vMatchingItems[i].c_str()); } } wrefresh(w_test_rule_content); const std::string action = ctxt.handle_input(); if (action == "DOWN") { iCurrentLine++; if (iCurrentLine >= (int)vMatchingItems.size()) { iCurrentLine = 0; } } else if (action == "UP") { iCurrentLine--; if (iCurrentLine < 0) { iCurrentLine = vMatchingItems.size() - 1; } } else { break; } } }
/* Player hit animation */ void game::draw_hit_player(player *p, bool dead) { hit_animation(POSX + (p->posx - (u.posx + u.view_offset_x)), POSY + (p->posy - (u.posy + u.view_offset_y)), red_background(p->color()), '@'); }
void shoot_monster(game *g, player &p, monster &mon, int &dam, double goodhit, item* weapon) { // Gunmods don't have a type, so use the player weapon type. it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type); std::string message; bool u_see_mon = g->u_see(&(mon)); if (mon.has_flag(MF_HARDTOSHOOT) && !one_in(4) && weapon->curammo->phase != LIQUID && weapon->curammo->accuracy >= 4) { // Buckshot hits anyway if (u_see_mon) g->add_msg("The shot passes through the %s without hitting.", mon.name().c_str()); goodhit = 1; } else { // Not HARDTOSHOOT // Armor blocks BEFORE any critical effects. int zarm = mon.armor_cut(); zarm -= weapon->curammo->pierce; if (weapon->curammo->phase == LIQUID) zarm = 0; else if (weapon->curammo->accuracy < 4) // Shot doesn't penetrate armor well zarm *= rng(2, 4); if (zarm > 0) dam -= zarm; if (dam <= 0) { if (u_see_mon) g->add_msg("The shot reflects off the %s!", mon.name_with_armor().c_str()); dam = 0; goodhit = 1; } if (goodhit < .1 && !mon.has_flag(MF_NOHEAD)) { message = "Headshot!"; dam = rng(5 * dam, 8 * dam); p.practice(g->turn, firing->skill_used, 5); } else if (goodhit < .2) { message = "Critical!"; dam = rng(dam * 2, dam * 3); p.practice(g->turn, firing->skill_used, 2); } else if (goodhit < .4) { dam = rng(int(dam * .9), int(dam * 1.5)); p.practice(g->turn, firing->skill_used, rng(0, 2)); } else if (goodhit <= .7) { message = "Grazing hit."; dam = rng(0, dam); } else dam = 0; // Find the zombie at (x, y) and hurt them, MAYBE kill them! if (dam > 0) { mon.moves -= dam * 5; if (&p == &(g->u) && u_see_mon) g->add_msg("%s You hit the %s for %d damage.", message.c_str(), mon.name().c_str(), dam); else if (u_see_mon) g->add_msg("%s %s shoots the %s.", message.c_str(), p.name.c_str(), mon.name().c_str()); bool bMonDead = mon.hurt(dam); hit_animation(mon.posx - g->u.posx + VIEWX - g->u.view_offset_x, mon.posy - g->u.posy + VIEWY - g->u.view_offset_y, red_background(mon.type->color), (bMonDead) ? '%' : mon.symbol()); if (bMonDead) g->kill_mon(g->mon_at(mon.posx, mon.posy), (&p == &(g->u))); else if (weapon->curammo->ammo_effects != 0) g->hit_monster_with_flags(mon, weapon->curammo->ammo_effects); dam = 0; } } }
/** * Moves the cursor on the vehicle editing window. * @param dx How far to move the cursor on the x-axis. * @param dy How far to move the cursor on the y-axis. */ void veh_interact::move_cursor (int dx, int dy) { mvwputch (w_disp, cursor_y + 6, cursor_x + 6, cpart >= 0 ? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' ')); cursor_x += dx; cursor_y += dy; cpart = part_at (cursor_x, cursor_y); int vdx = -ddx - cursor_y; int vdy = cursor_x - ddy; int vx, vy; veh->coord_translate (vdx, vdy, vx, vy); int vehx = veh->global_x() + vx; int vehy = veh->global_y() + vy; bool obstruct = g->m.move_cost_ter_furn (vehx, vehy) == 0; vehicle *oveh = g->m.veh_at (vehx, vehy); if (oveh && oveh != veh) { obstruct = true; } nc_color col = cpart >= 0 ? veh->part_color (cpart) : c_black; mvwputch (w_disp, cursor_y + 6, cursor_x + 6, obstruct ? red_background(col) : hilite(col), special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' ')); wrefresh (w_disp); werase (w_parts); veh->print_part_desc (w_parts, 0, winw2, cpart, -1); wrefresh (w_parts); can_mount.clear(); if (!obstruct) { for (std::map<std::string, vpart_info>::iterator part_type_iterator = vehicle_part_types.begin(); part_type_iterator != vehicle_part_types.end(); ++part_type_iterator) { if (veh->can_mount (vdx, vdy, part_type_iterator->first)) { can_mount.push_back (part_type_iterator->second); } } } need_repair.clear(); parts_here.clear(); ptank = NULL; wheel = NULL; if (cpart >= 0) { //Misleading, internal_parts actually returns all parts at that square parts_here = veh->internal_parts(cpart); parts_here.insert (parts_here.begin(), cpart); for (int i = 0; i < parts_here.size(); i++) { int p = parts_here[i]; if (veh->parts[p].hp < veh->part_info(p).durability) { need_repair.push_back (i); } if (veh->part_flag(p, "FUEL_TANK") && veh->parts[p].amount < veh->part_info(p).size) { ptank = &veh->parts[p]; } if (veh->part_flag(p, "WHEEL") && veh->parts[p].amount < veh->part_info(p).size) { wheel = &veh->parts[p]; } } } has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false; werase (w_msg); wrefresh (w_msg); display_mode (' '); }
void safemode::test_pattern( const int tab_in, const int row_in ) { std::vector<std::string> creature_list; std::string creature_name; auto &temp_rules = ( tab_in == GLOBAL_TAB ) ? global_rules : character_rules; if( temp_rules[row_in].rule.empty() ) { return; } if( g->u.name.empty() ) { popup( _( "No monsters loaded. Please start a game first." ) ); return; } //Loop through all monster mtypes for( const auto &mtype : MonsterGenerator::generator().get_all_mtypes() ) { creature_name = mtype.nname(); if( wildcard_match( creature_name, temp_rules[row_in].rule ) ) { creature_list.push_back( creature_name ); } } const int offset_x = 15 + ( ( TERMX > FULL_SCREEN_WIDTH ) ? ( TERMX - FULL_SCREEN_WIDTH ) / 2 : 0 ); const int offset_y = 5 + ( ( TERMY > FULL_SCREEN_HEIGHT ) ? ( TERMY - FULL_SCREEN_HEIGHT ) / 2 : 0 ); int start_pos = 0; const int content_height = FULL_SCREEN_HEIGHT - 8; const int content_width = FULL_SCREEN_WIDTH - 30; WINDOW *w_test_rule_border = newwin( content_height + 2, content_width, offset_y, offset_x ); WINDOW_PTR w_test_rule_borderptr( w_test_rule_border ); WINDOW *w_test_rule_content = newwin( content_height, content_width - 2, 1 + offset_y, 1 + offset_x ); WINDOW_PTR w_test_rule_contentptr( w_test_rule_content ); draw_border( w_test_rule_border ); int nmatch = creature_list.size(); std::string buf = string_format( ngettext( "%1$d monster matches: %2$s", "%1$d monsters match: %2$s", nmatch ), nmatch, temp_rules[row_in].rule.c_str() ); mvwprintz( w_test_rule_border, 0, content_width / 2 - utf8_width( buf ) / 2, hilite( c_white ), "%s", buf.c_str() ); mvwprintz( w_test_rule_border, content_height + 1, 1, red_background( c_white ), _( "Lists monsters regardless of their attitude." ) ); wrefresh( w_test_rule_border ); int line = 0; input_context ctxt( "SAFEMODE_TEST" ); ctxt.register_updown(); ctxt.register_action( "QUIT" ); while( true ) { // Clear the lines for( int i = 0; i < content_height; i++ ) { for( int j = 0; j < 79; j++ ) { mvwputch( w_test_rule_content, i, j, c_black, ' ' ); } } calcStartPos( start_pos, line, content_height, creature_list.size() ); // display safe mode for( int i = start_pos; i < ( int )creature_list.size(); i++ ) { if( i >= start_pos && i < start_pos + std::min( content_height, static_cast<int>( creature_list.size() ) ) ) { nc_color line_color = c_white; mvwprintz( w_test_rule_content, i - start_pos, 0, line_color, "%d", i + 1 ); mvwprintz( w_test_rule_content, i - start_pos, 4, line_color, "" ); wprintz( w_test_rule_content, c_yellow, ( line == i ) ? ">> " : " " ); wprintz( w_test_rule_content, ( line == i ) ? hilite( line_color ) : line_color, "%s", creature_list[i].c_str() ); } } wrefresh( w_test_rule_content ); const std::string action = ctxt.handle_input(); if( action == "DOWN" ) { line++; if( line >= ( int )creature_list.size() ) { line = 0; } } else if( action == "UP" ) { line--; if( line < 0 ) { line = creature_list.size() - 1; } } else { break; } } }
void shoot_monster(game *g, player &p, monster &mon, int &dam, double goodhit, item* weapon) { // Gunmods don't have a type, so use the player weapon type. it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type); std::string message; bool u_see_mon = g->u_see(&(mon)); int adjusted_damage = dam; if (mon.has_flag(MF_HARDTOSHOOT) && !one_in(10 - 10 * (.8 - goodhit)) && // Maxes out at 50% chance with perfect hit weapon->curammo->phase != LIQUID && !weapon->curammo->ammo_effects.count("SHOT") && !weapon->curammo->ammo_effects.count("BOUNCE")) { if (u_see_mon) g->add_msg(_("The shot passes through the %s without hitting."), mon.name().c_str()); goodhit = 1; } else { // Not HARDTOSHOOT // Armor blocks BEFORE any critical effects. int zarm = mon.armor_cut(); zarm -= weapon->curammo->pierce; if (weapon->curammo->phase == LIQUID) zarm = 0; else if (weapon->curammo->ammo_effects.count("SHOT")) // Shot doesn't penetrate armor well zarm *= rng(2, 3); if (zarm > 0) adjusted_damage -= zarm; if (adjusted_damage <= 0) { if (u_see_mon) g->add_msg(_("The shot reflects off the %s!"), mon.name_with_armor().c_str()); adjusted_damage = 0; goodhit = 1; } if (goodhit <= .1 && !mon.has_flag(MF_NOHEAD)) { message = _("Headshot!"); adjusted_damage = rng(5 * adjusted_damage, 8 * adjusted_damage); p.practice(g->turn, firing->skill_used, 5); } else if (goodhit <= .2) { message = _("Critical!"); adjusted_damage = rng(adjusted_damage * 2, adjusted_damage * 3); p.practice(g->turn, firing->skill_used, 3); } else if (goodhit <= .4) { message = _("Good hit!"); adjusted_damage = rng(adjusted_damage , adjusted_damage * 2); p.practice(g->turn, firing->skill_used, 2); } else if (goodhit <= .6) { adjusted_damage = rng(adjusted_damage / 2, adjusted_damage); p.practice(g->turn, firing->skill_used, 1); } else if (goodhit <= .8) { message = _("Grazing hit."); adjusted_damage = rng(0, adjusted_damage); } else { adjusted_damage = 0; } if(item(weapon->curammo, 0).has_flag("NOGIB")) { adjusted_damage = std::min(adjusted_damage, mon.hp+10); } // Find the zombie at (x, y) and hurt them, MAYBE kill them! if (adjusted_damage > 0) { switch (mon.type->size) { case MS_TINY: mon.moves -= rng(0, adjusted_damage * 5); break; case MS_SMALL: mon.moves -= rng(0, adjusted_damage * 3); break; case MS_MEDIUM: mon.moves -= rng(0, adjusted_damage); break; case MS_LARGE: mon.moves -= rng(0, adjusted_damage / 3); break; case MS_HUGE: mon.moves -= rng(0, adjusted_damage / 5); break; } if (&p == &(g->u) && u_see_mon) { g->add_msg(_("%s You hit the %s for %d damage."), message.c_str(), mon.name().c_str(), adjusted_damage); } else if (u_see_mon) { g->add_msg(_("%s %s shoots the %s."), message.c_str(), p.name.c_str(), mon.name().c_str()); } bool bMonDead = mon.hurt(adjusted_damage, dam); if( u_see_mon ) { hit_animation(mon.posx - g->u.posx + VIEWX - g->u.view_offset_x, mon.posy - g->u.posy + VIEWY - g->u.view_offset_y, red_background(mon.type->color), (bMonDead) ? '%' : mon.symbol()); } if (bMonDead) { g->kill_mon(g->mon_at(mon.posx, mon.posy), (&p == &(g->u))); } else if (!weapon->curammo->ammo_effects.empty()) { g->hit_monster_with_flags(mon, weapon->curammo->ammo_effects); } adjusted_damage = 0; } } dam = adjusted_damage; }
/** * Moves the cursor on the vehicle editing window. * @param dx How far to move the cursor on the x-axis. * @param dy How far to move the cursor on the y-axis. */ void veh_interact::move_cursor (int dx, int dy) { mvwputch (w_disp, 6, 6, cpart >= 0 ? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' ')); ddx += dy; ddy -= dx; display_veh(); cpart = part_at (0, 0); int vdx = -ddx; int vdy = -ddy; int vx, vy; veh->coord_translate (vdx, vdy, vx, vy); int vehx = veh->global_x() + vx; int vehy = veh->global_y() + vy; bool obstruct = g->m.move_cost_ter_furn (vehx, vehy) == 0; vehicle *oveh = g->m.veh_at (vehx, vehy); if (oveh && oveh != veh) { obstruct = true; } nc_color col = cpart >= 0 ? veh->part_color (cpart) : c_black; mvwputch (w_disp, 6, 6, obstruct ? red_background(col) : hilite(col), special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' ')); wrefresh (w_disp); werase (w_parts); veh->print_part_desc (w_parts, 0, parts_w, cpart, -1); wrefresh (w_parts); can_mount.clear(); if (!obstruct) { for (std::map<std::string, vpart_info>::iterator part_type_iterator = vehicle_part_types.begin(); part_type_iterator != vehicle_part_types.end(); ++part_type_iterator) { if (veh->can_mount (vdx, vdy, part_type_iterator->first)) { can_mount.push_back (part_type_iterator->second); } } } //Only build the wheel list once if(wheel_types.empty()) { for (std::map<std::string, vpart_info>::iterator part_type_iterator = vehicle_part_types.begin(); part_type_iterator != vehicle_part_types.end(); ++part_type_iterator) { if (part_type_iterator->second.has_flag("WHEEL")) { wheel_types.push_back (part_type_iterator->second); } } } need_repair.clear(); parts_here.clear(); ptank = NULL; wheel = NULL; if (cpart >= 0) { parts_here = veh->parts_at_relative(veh->parts[cpart].mount_dx, veh->parts[cpart].mount_dy); for (int i = 0; i < parts_here.size(); i++) { int p = parts_here[i]; if (veh->parts[p].hp < veh->part_info(p).durability) { need_repair.push_back (i); } if (veh->part_flag(p, "FUEL_TANK") && veh->parts[p].amount < veh->part_info(p).size) { ptank = &veh->parts[p]; } if (veh->part_flag(p, "WHEEL")) { wheel = &veh->parts[p]; } } } has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false; werase (w_msg); wrefresh (w_msg); display_mode (' '); }