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

Port fix for Artificial Night Generator bionic #824

Merged
merged 2 commits into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@
"description": "When active, this bionic eliminates all light within a 2 tile radius through destructive interference.",
"occupied_bodyparts": [ [ "torso", 16 ] ],
"flags": [ "BIONIC_TOGGLED" ],
"enchantments": [ "ENCH_INVISIBILITY" ],
"enchantments": [ "ENCH_SHADOW_CLOUD" ],
"act_cost": "9 kJ",
"react_cost": "9 kJ",
"time": 1
Expand Down
8 changes: 8 additions & 0 deletions data/json/emit.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
"intensity": 3,
"chance": 50
},
{
"id": "emit_shadow_field",
"type": "emit",
"field": "fd_shadow",
"intensity": 1,
"qty": 10,
"chance": 100
},
{
"id": "emit_shock_burst",
"type": "emit",
Expand Down
7 changes: 7 additions & 0 deletions data/json/enchantments.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"id": "ENCH_INVISIBILITY",
"condition": "ACTIVE",
"ench_effects": [ { "effect": "invisibility", "intensity": 1 } ]
},
{
"type": "enchantment",
"id": "ENCH_SHADOW_CLOUD",
"condition": "ACTIVE",
"ench_effects": [ { "effect": "invisibility", "intensity": 1 } ],
"emitter": "emit_shadow_field"
}
]
7 changes: 7 additions & 0 deletions data/json/field_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,13 @@
"display_field": true,
"looks_like": "fd_fire"
},
{
"id": "fd_shadow",
"type": "field_type",
"intensity_levels": [ { "name": "shadow", "light_override": 3.7 } ],
"half_life": "10 seconds",
"percent_spread": 50
},
{
"id": "fd_flame_burst",
"type": "field_type",
Expand Down
4 changes: 4 additions & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3275,6 +3275,10 @@ Setting of sprite sheets. Same as `tiles-new` field in `tile_config`. Sprite fil
"type": "field_type", // this is a field type
"id": "fd_gum_web", // id of the field
"immune_mtypes": [ "mon_spider_gum" ], // list of monster immune to this field
"intensity_levels": [
{ "name": "shadow", // name of this level of intensity
"light_override": 3.7 } //light level on the tile occupied by this field will be set at 3.7 not matter the ambient light.
],
"bash": {
"str_min": 1, // lower bracket of bashing damage required to bash
"str_max": 3, // higher bracket
Expand Down
9 changes: 3 additions & 6 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ static const bionic_id bio_lockpick( "bio_lockpick" );
static const bionic_id bio_magnet( "bio_magnet" );
static const bionic_id bio_meteorologist( "bio_meteorologist" );
static const bionic_id bio_nanobots( "bio_nanobots" );
static const bionic_id bio_night( "bio_night" );
static const bionic_id bio_painkiller( "bio_painkiller" );
static const bionic_id bio_plutdump( "bio_plutdump" );
static const bionic_id bio_power_storage( "bio_power_storage" );
Expand Down Expand Up @@ -244,6 +243,8 @@ bionic_data::bionic_data() : name( no_translation( "bad bionic" ) ),
{
}

bionic_data::~bionic_data() = default;

static void force_comedown( effect &eff )
{
if( eff.is_null() || eff.get_effect_type() == nullptr || eff.get_duration() <= 1_turns ) {
Expand Down Expand Up @@ -1472,11 +1473,7 @@ void Character::process_bionic( int b )
}

// Bionic effects on every turn they are active go here.
if( bio.id == bio_night ) {
if( calendar::once_every( 5_turns ) ) {
add_msg_if_player( m_neutral, _( "Artificial night generator active!" ) );
}
} else if( bio.id == bio_remote ) {
if( bio.id == bio_remote ) {
if( g->remoteveh() == nullptr && get_value( "remote_controlling" ).empty() ) {
bio.powered = false;
add_msg_if_player( m_warning, _( "Your %s has lost connection and is turning off." ),
Expand Down
1 change: 1 addition & 0 deletions src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using itype_id = std::string;

struct bionic_data {
bionic_data();
~bionic_data();

translation name;
translation description;
Expand Down
8 changes: 2 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static const bionic_id bio_synaptic_regen( "bio_synaptic_regen" );
static const bionic_id bio_tattoo_led( "bio_tattoo_led" );
static const bionic_id bio_tools( "bio_tools" );
static const bionic_id bio_ups( "bio_ups" );
static const bionic_id str_bio_night( "bio_night" );

// Aftershock stuff!
static const bionic_id afs_bio_linguistic_coprocessor( "afs_bio_linguistic_coprocessor" );

Expand Down Expand Up @@ -9975,11 +9975,7 @@ bool Character::sees( const tripoint &t, bool, int ) const
if( wanted_range < MAX_CLAIRVOYANCE && wanted_range < clairvoyance() ) {
return true;
}
// Only check if we need to override if we already came to the opposite conclusion.
if( can_see && wanted_range < 15 && wanted_range > sight_range( 1 ) &&
has_active_bionic( str_bio_night ) ) {
can_see = false;
}

if( can_see && wanted_range > unimpaired_range() ) {
can_see = false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ float field_entry::light_emitted() const
return type.obj().get_light_emitted( intensity - 1 );
}

float field_entry::local_light_override() const
{
return type.obj().get_local_light_override( intensity - 1 );
}

float field_entry::translucency() const
{
return type.obj().get_translucency( intensity - 1 );
Expand Down
1 change: 1 addition & 0 deletions src/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class field_entry
mongroup_id monster_spawn_group() const;

float light_emitted() const;
float local_light_override() const;
float translucency() const;
bool is_transparent() const;
int convection_temperature_mod() const;
Expand Down
2 changes: 2 additions & 0 deletions src/field_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void field_type::load( const JsonObject &jo, const std::string & )
fallback_intensity_level.monster_spawn_group );
optional( jao, was_loaded, "light_emitted", intensity_level.light_emitted,
fallback_intensity_level.light_emitted );
optional( jao, was_loaded, "light_override", intensity_level.local_light_override,
fallback_intensity_level.local_light_override );
optional( jao, was_loaded, "translucency", intensity_level.translucency,
fallback_intensity_level.translucency );
optional( jao, was_loaded, "convection_temperature_mod", intensity_level.convection_temperature_mod,
Expand Down
4 changes: 4 additions & 0 deletions src/field_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct field_intensity_level {
int monster_spawn_radius = 0;
mongroup_id monster_spawn_group;
float light_emitted = 0.0f;
float local_light_override = -1.0f;
float translucency = 0.0f;
int convection_temperature_mod = 0;
int scent_neutralization = 0;
Expand Down Expand Up @@ -224,6 +225,9 @@ struct field_type {
float get_light_emitted( int level = 0 ) const {
return get_intensity_level( level ).light_emitted;
}
float get_local_light_override( int level = 0 )const {
return get_intensity_level( level ).local_light_override;
}
float get_translucency( int level = 0 ) const {
return get_intensity_level( level ).translucency;
}
Expand Down
16 changes: 7 additions & 9 deletions src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include "vpart_range.h"
#include "weather.h"

static const bionic_id bio_night( "bio_night" );

static const efftype_id effect_haslight( "haslight" );
static const efftype_id effect_onfire( "onfire" );

Expand Down Expand Up @@ -407,6 +405,7 @@ void map::generate_lightmap( const int zlev )
apply_character_light( guy );
}

std::vector<std::pair<tripoint, float>> lm_override;
// Traverse the submaps in order
for( int smx = 0; smx < my_MAPSIZE; ++smx ) {
for( int smy = 0; smy < my_MAPSIZE; ++smy ) {
Expand Down Expand Up @@ -459,6 +458,10 @@ void map::generate_lightmap( const int zlev )
if( light_emitted > 0 ) {
add_light_source( p, light_emitted );
}
const float light_override = cur->local_light_override();
if( light_override >= 0.0 ) {
lm_override.push_back( std::pair<tripoint, float>( p, light_override ) );
}
}
}
}
Expand Down Expand Up @@ -565,13 +568,8 @@ void map::generate_lightmap( const int zlev )
apply_light_source( p, light_source_buffer[p.x][p.y] );
}
}

if( g->u.has_active_bionic( bio_night ) ) {
for( const tripoint &p : points_in_rectangle( cache_start, cache_end ) ) {
if( rl_dist( p, g->u.pos() ) < 2 ) {
lm[p.x][p.y].fill( LIGHT_AMBIENT_MINIMAL );
}
}
for( const std::pair<tripoint, float> &elem : lm_override ) {
lm[elem.first.x][elem.first.y].fill( elem.second );
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/modify_morale_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ TEST_CASE( "ursine honey", "[food][modify_morale][ursine][honey]" )
CHECK( dummy.get_morale( MORALE_HONEY ) > 0 );

AND_THEN( "they enjoy it" ) {
CHECK( dummy.has_morale( MORALE_FOOD_GOOD ) > 0 );
CHECK( dummy.get_morale( MORALE_FOOD_GOOD ) > 0 );
}
}
}
Expand Down