From e9f030e164ad8c4b53123b1f8e5cb9ecb33f668c Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 24 Jun 2013 12:11:31 -0700 Subject: [PATCH 1/4] Add CBM Artificial Night --- bionics.cpp | 4 ++++ game.cpp | 6 +++++- itypedef.cpp | 3 ++- mapitemsdef.cpp | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bionics.cpp b/bionics.cpp index 8403a025e982a..908c2f0be00a8 100644 --- a/bionics.cpp +++ b/bionics.cpp @@ -1045,6 +1045,10 @@ Interfaces your power system with the internal charging port on suits of power a The Mk. II was designed by DoubleTech Inc., to meet the popularity of the Mk. II\n\ power armor series."); + bionics["bio_night"] = new bionic_data("Artificial Night Satellite Uplink", false, true, 1, 2, "\ +Commands an orbiting geosynchronous satellite to deploy a large opaque surface,\n\ +blotting out the sun and casting all in your vicinity into darkness."); + bionics["bio_flashbang"] = new bionic_data("Flashbang Generator", false, true, 5, 0, "\ Light emitting diodes integrated into your skin can release a flash comparable\n\ to a flashbang grenade, blinding nearby enemies. Speakers integrated into your\n\ diff --git a/game.cpp b/game.cpp index 4be27c5f36a21..33b24fdb6774a 100644 --- a/game.cpp +++ b/game.cpp @@ -3699,7 +3699,9 @@ float game::natural_light_level() const if (levz >= 0) { ret = turn.sunlight(); ret += weather_data[weather].light_modifier; - } + } + if (u.has_active_bionic("bio_night")) + ret = 0; return std::max(0.0f, ret); } @@ -3712,6 +3714,8 @@ unsigned char game::light_level() int ret; if (levz < 0) // Underground! + ret = 1; + else if (u.has_active_bionic("bio_night")) ret = 1; else { ret = turn.sunlight(); diff --git a/itypedef.cpp b/itypedef.cpp index aef1f97b1be00..dc50113e7f809 100644 --- a/itypedef.cpp +++ b/itypedef.cpp @@ -349,7 +349,8 @@ BIO_SINGLE("bio_armor_legs", 3, 3500, c_cyan, 3); BIO_SINGLE("bio_face_mask", 1, 8500, c_magenta, 5); BIO_SINGLE("bio_scent_mask", 1, 8500, c_magenta, 5); BIO_SINGLE("bio_cloak", 1, 8500, c_magenta, 5); -BIO_SINGLE("bio_fingerhack", 1, 3500, c_magenta, 2); +BIO_SINGLE("bio_fingerhack", 1, 3500, c_magenta, 2); +BIO_SINGLE("bio_night", 1, 8500, c_magenta, 5); // defensive BIO_SINGLE("bio_ads", 1, 9500, c_ltblue, 7); BIO_SINGLE("bio_ods", 1, 9500, c_ltblue, 7); diff --git a/mapitemsdef.cpp b/mapitemsdef.cpp index f1d866d1ed1de..f8295f7868db0 100644 --- a/mapitemsdef.cpp +++ b/mapitemsdef.cpp @@ -628,7 +628,7 @@ void game::init_mapitems() "bio_membrane", "bio_gills", "bio_purifier", "bio_climate", "bio_heatsink", "bio_blood_filter", "bio_recycler", "bio_digestion", "bio_evap", "bio_water_extractor", - "bio_face_mask", "bio_scent_mask", "bio_cloak", "bio_fingerhack", + "bio_face_mask", "bio_scent_mask", "bio_cloak", "bio_fingerhack", "bio_night", "bio_carbon", "bio_armor_head", "bio_armor_torso", "bio_armor_arms", "bio_armor_legs", "bio_shock", "bio_heat_absorb", "bio_claws", "bio_shockwave", @@ -717,7 +717,7 @@ void game::init_mapitems() "bio_carbon", "bio_armor_head", "bio_armor_torso", "bio_armor_arms", "bio_armor_legs", "bio_targeting", "bio_ground_sonar", - "bio_face_mask", "bio_scent_mask", "bio_cloak", "bio_fingerhack", + "bio_face_mask", "bio_scent_mask", "bio_cloak", "bio_fingerhack", "bio_night", "bio_nanobots", "bio_blood_anal", "bio_ads", "bio_ods", "bio_blaster", "bio_laser", "bio_emp", "bio_railgun", "bio_flashbang", From eb4cdbe9042201bd8f1235bbe08b3717ac1aeb73 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 25 Jun 2013 03:56:36 -0700 Subject: [PATCH 2/4] Bio Night v2 --- bionics.cpp | 5 ++--- game.cpp | 12 +++++------- lightmap.cpp | 14 ++++++++++---- map.cpp | 3 ++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/bionics.cpp b/bionics.cpp index 908c2f0be00a8..83c71ed97368c 100644 --- a/bionics.cpp +++ b/bionics.cpp @@ -1045,9 +1045,8 @@ Interfaces your power system with the internal charging port on suits of power a The Mk. II was designed by DoubleTech Inc., to meet the popularity of the Mk. II\n\ power armor series."); - bionics["bio_night"] = new bionic_data("Artificial Night Satellite Uplink", false, true, 1, 2, "\ -Commands an orbiting geosynchronous satellite to deploy a large opaque surface,\n\ -blotting out the sun and casting all in your vicinity into darkness."); + bionics["bio_night"] = new bionic_data("Artificial Night Generator", false, true, 1, 2, "\ +Destructive interference eliminates all light within a 15 tile radius."); bionics["bio_flashbang"] = new bionic_data("Flashbang Generator", false, true, 5, 0, "\ Light emitting diodes integrated into your skin can release a flash comparable\n\ diff --git a/game.cpp b/game.cpp index 33b24fdb6774a..19daa84e71c2d 100644 --- a/game.cpp +++ b/game.cpp @@ -3699,9 +3699,7 @@ float game::natural_light_level() const if (levz >= 0) { ret = turn.sunlight(); ret += weather_data[weather].light_modifier; - } - if (u.has_active_bionic("bio_night")) - ret = 0; + } return std::max(0.0f, ret); } @@ -3714,8 +3712,6 @@ unsigned char game::light_level() int ret; if (levz < 0) // Underground! - ret = 1; - else if (u.has_active_bionic("bio_night")) ret = 1; else { ret = turn.sunlight(); @@ -3841,7 +3837,7 @@ bool game::sees_u(int x, int y, int &t) if( range <= 0) range = 1; - return (!u.has_active_bionic("bio_cloak") && + return ((!u.has_active_bionic("bio_cloak") || !u.has_active_bionic("bio_night")) && !u.has_artifact_with(AEP_INVISIBLE) && m.sees(x, y, u.posx, u.posy, range, t)); } @@ -3856,7 +3852,9 @@ bool game::u_see(int x, int y) else if (wanted_range <= u.sight_range(light_level()) || (wanted_range <= u.sight_range(DAYLIGHT_LEVEL) && m.light_at(x, y) >= LL_LOW)) - can_see = m.pl_sees(u.posx, u.posy, x, y, wanted_range); + can_see = m.pl_sees(u.posx, u.posy, x, y, wanted_range); + if (u.has_active_bionic("bio_night") && wanted_range < 15 && wanted_range > u.sight_range(1)) + return false; return can_see; } diff --git a/lightmap.cpp b/lightmap.cpp index 35d55f36b055f..33def889a8ad2 100644 --- a/lightmap.cpp +++ b/lightmap.cpp @@ -39,16 +39,21 @@ void map::generate_lightmap(game* g) // the lightmap when in less than total sunlight. lm[sx][sy] = natural_light; } + if (g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15) + { + lm[sx][sy] = 0; + } } } } // Apply player light sources - if (held_luminance > LIGHT_AMBIENT_LOW) + if (held_luminance > LIGHT_AMBIENT_LOW && !(g->u.has_active_bionic("bio_night"))) apply_light_source(g->u.posx, g->u.posy, held_luminance, trigdist); int flood_basalt_check = 0; // does excessive lava need high quality lighting? Nope nope nope nope for(int sx = 0; sx < LIGHTMAP_CACHE_X; ++sx) { for(int sy = 0; sy < LIGHTMAP_CACHE_Y; ++sy) { + if (!(g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15)) { const ter_id terrain = g->m.ter(sx, sy); const std::vector &items = g->m.i_at(sx, sy); const field ¤t_field = g->m.field_at(sx, sy); @@ -59,7 +64,7 @@ void map::generate_lightmap(game* g) for(int i = 0; i < 4; ++i) { if (INBOUNDS(sx + dir_x[i], sy + dir_y[i]) && g->m.is_outside(sx + dir_x[i], sy + dir_y[i])) { - if (INBOUNDS(sx, sy) && g->m.is_outside(0, 0)) + if (INBOUNDS(sx, sy) && g->m.is_outside(0, 0) && !(g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15)) lm[sx][sy] = natural_light; if (g->m.light_transparency(sx, sy) > LIGHT_TRANSPARENCY_SOLID) @@ -112,12 +117,13 @@ void map::generate_lightmap(game* g) break; } } + } } for (int i = 0; i < g->z.size(); ++i) { int mx = g->z[i].posx; int my = g->z[i].posy; - if (INBOUNDS(mx, my)) { + if (INBOUNDS(mx, my) && !(g->u.has_active_bionic("bio_night") && rl_dist(mx, my, g->u.posx, g->u.posy) < 15)) { if (g->z[i].has_effect(ME_ONFIRE)) { apply_light_source(mx, my, 3, trigdist); } @@ -161,7 +167,7 @@ void map::generate_lightmap(game* g) part != vehs[v].v->external_parts.end(); ++part) { int px = vehs[v].x + vehs[v].v->parts[*part].precalc_dx[0]; int py = vehs[v].y + vehs[v].v->parts[*part].precalc_dy[0]; - if(INBOUNDS(px, py)) { + if(INBOUNDS(px, py) && !(g->u.has_active_bionic("bio_night") && rl_dist(px, py, g->u.posx, g->u.posy) < 15)) { int dpart = vehs[v].v->part_with_feature(*part , vpf_light); if (dpart >= 0) { diff --git a/map.cpp b/map.cpp index 3cb858a29d0e7..993700f5db141 100644 --- a/map.cpp +++ b/map.cpp @@ -3082,7 +3082,8 @@ void map::draw(game *g, WINDOW* w, const point center) } } - if (dist > real_max_sight_range || + if ((g->u.has_active_bionic("bio_night") && dist < 15 && dist > natural_sight_range) || // if bio_night active, blackout 15 tile radius around player + dist > real_max_sight_range || (dist > light_sight_range && (lit == LL_DARK || (u_sight_impaired && lit != LL_BRIGHT) || From 682542ec45f2ee1497d0e631701ff1df64c544a1 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 25 Jun 2013 16:47:20 -0700 Subject: [PATCH 3/4] Add active message to CBM artificial night --- bionics.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bionics.cpp b/bionics.cpp index 83c71ed97368c..6b6287ca2282d 100644 --- a/bionics.cpp +++ b/bionics.cpp @@ -220,6 +220,9 @@ void player::activate_bionic(int b, game *g) pkill = pain; } else if (bio.id == "bio_nanobots"){ healall(4); + } else if (bio.id == "bio_night"){ + if (g->turn % 5) + g->add_msg("Artificial night generator active!"); } else if (bio.id == "bio_resonator"){ g->sound(posx, posy, 30, "VRRRRMP!"); for (int i = posx - 1; i <= posx + 1; i++) { From c63088f28891125a17ed57ce4d259515bbbdd430 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 25 Jun 2013 17:00:40 -0700 Subject: [PATCH 4/4] Moved lightmap changes into one loop at end --- lightmap.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lightmap.cpp b/lightmap.cpp index 33def889a8ad2..abc9d62fb54fd 100644 --- a/lightmap.cpp +++ b/lightmap.cpp @@ -39,21 +39,16 @@ void map::generate_lightmap(game* g) // the lightmap when in less than total sunlight. lm[sx][sy] = natural_light; } - if (g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15) - { - lm[sx][sy] = 0; - } } } } // Apply player light sources - if (held_luminance > LIGHT_AMBIENT_LOW && !(g->u.has_active_bionic("bio_night"))) + if (held_luminance > LIGHT_AMBIENT_LOW) apply_light_source(g->u.posx, g->u.posy, held_luminance, trigdist); int flood_basalt_check = 0; // does excessive lava need high quality lighting? Nope nope nope nope for(int sx = 0; sx < LIGHTMAP_CACHE_X; ++sx) { for(int sy = 0; sy < LIGHTMAP_CACHE_Y; ++sy) { - if (!(g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15)) { const ter_id terrain = g->m.ter(sx, sy); const std::vector &items = g->m.i_at(sx, sy); const field ¤t_field = g->m.field_at(sx, sy); @@ -64,7 +59,7 @@ void map::generate_lightmap(game* g) for(int i = 0; i < 4; ++i) { if (INBOUNDS(sx + dir_x[i], sy + dir_y[i]) && g->m.is_outside(sx + dir_x[i], sy + dir_y[i])) { - if (INBOUNDS(sx, sy) && g->m.is_outside(0, 0) && !(g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15)) + if (INBOUNDS(sx, sy) && g->m.is_outside(0, 0)) lm[sx][sy] = natural_light; if (g->m.light_transparency(sx, sy) > LIGHT_TRANSPARENCY_SOLID) @@ -117,13 +112,12 @@ void map::generate_lightmap(game* g) break; } } - } } for (int i = 0; i < g->z.size(); ++i) { int mx = g->z[i].posx; int my = g->z[i].posy; - if (INBOUNDS(mx, my) && !(g->u.has_active_bionic("bio_night") && rl_dist(mx, my, g->u.posx, g->u.posy) < 15)) { + if (INBOUNDS(mx, my)) { if (g->z[i].has_effect(ME_ONFIRE)) { apply_light_source(mx, my, 3, trigdist); } @@ -167,7 +161,7 @@ void map::generate_lightmap(game* g) part != vehs[v].v->external_parts.end(); ++part) { int px = vehs[v].x + vehs[v].v->parts[*part].precalc_dx[0]; int py = vehs[v].y + vehs[v].v->parts[*part].precalc_dy[0]; - if(INBOUNDS(px, py) && !(g->u.has_active_bionic("bio_night") && rl_dist(px, py, g->u.posx, g->u.posy) < 15)) { + if(INBOUNDS(px, py)) { int dpart = vehs[v].v->part_with_feature(*part , vpf_light); if (dpart >= 0) { @@ -178,6 +172,16 @@ void map::generate_lightmap(game* g) } } } + for(int sx = 0; sx < LIGHTMAP_CACHE_X; ++sx) + { + for(int sy = 0; sy < LIGHTMAP_CACHE_Y; ++sy) + { + if (g->u.has_active_bionic("bio_night") && rl_dist(sx, sy, g->u.posx, g->u.posy) < 15) + { + lm[sx][sy] = 0; + } + } + } } lit_level map::light_at(int dx, int dy)