Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CBM Artificial Night #1724

Merged
merged 4 commits into from
Jun 27, 2013
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,9 @@ 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 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\
to a flashbang grenade, blinding nearby enemies. Speakers integrated into your\n\
Expand Down
6 changes: 4 additions & 2 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3837,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));
}
Expand All @@ -3852,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;
}
Expand Down
3 changes: 2 additions & 1 deletion itypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 10 additions & 4 deletions lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this into its own loop? This is one of the few performance-sensitive pieces of code in the game, and I'm wary of having an additional branch for each square. Also has_active_bionic does a surprising amount of work.

{
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<item> &items = g->m.i_at(sx, sy);
const field &current_field = g->m.field_at(sx, sy);
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
4 changes: 2 additions & 2 deletions mapitemsdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down