Skip to content

Commit

Permalink
Unhardcode more bionics, add weapon dispersion enchantment (#47288)
Browse files Browse the repository at this point in the history
* Unhardcode more bionics

* Update src/bionics.h

Co-authored-by: anothersimulacrum <[email protected]>

* Change dipersion to use enchantment

* Update ranged.cpp

* Clean up

Co-authored-by: anothersimulacrum <[email protected]>
  • Loading branch information
Ramza13 and anothersimulacrum authored Jul 8, 2021
1 parent 39248f5 commit b09bbfe
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@
"name": { "str": "Weather Reader" },
"description": "A multitude of scientific instruments and sensors collect environmental data. The data is compiled and presented as a simple readout of the current weather. It also passively tells you the local air temperature.",
"occupied_bodyparts": [ [ "torso", 1 ], [ "head", 1 ] ],
"act_cost": "10 J"
"act_cost": "10 J",
"flags": [ "THERMOMETER" ]
},
{
"id": "bio_nanobots",
Expand Down Expand Up @@ -1372,7 +1373,8 @@
"name": { "str": "Targeting System" },
"description": "Your eyes are surgically equipped with range finders, and their movement is synced with that of your arms, to a degree. Shots you fire will be much more accurate, particularly at long range.",
"occupied_bodyparts": [ [ "eyes", 1 ], [ "arm_l", 3 ], [ "arm_r", 3 ], [ "hand_l", 1 ], [ "hand_r", 1 ] ],
"flags": [ "BIONIC_NPC_USABLE" ]
"flags": [ "BIONIC_NPC_USABLE" ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "WEAPON_DISPERSION", "multiply": -0.25 } ] } ]
},
{
"id": "bio_teleport",
Expand Down
2 changes: 2 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1529,3 +1529,5 @@ Gun fault flags:
- ```DIMENSIONAL_ANCHOR``` You can't be teleported.
- ```CLIMATE_CONTROL``` You are resistant to extreme temperatures.
- ```HEATSINK``` You are resistant to extreme heat.
- ```THERMOMETER``` You always know what temperature it is.
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ For information about tools with option to export ASCII art in format ready to b
| dupes_allowed | (_optional_) Boolean to determine if multiple copies of this bionic can be installed. Defaults to false.
| cant_remove_reason | (_optional_) String message to be displayed as the reason it can't be uninstalled. Having any value other than `""` as this will prevent unistalling the bionic. Formatting includes two `%s` for example: `The Telescopic Lenses are part of %1$s eyes now. Removing them would leave %2$s blind.` (default: `""`)
| social_modifiers | (_optional_) Json object with optional members: persuade, lie, and intimidate which add or subtract that amount from those types of social checks
| dispersion_mod | (_optional_) Modifier to change firearm disperation.

```C++
{
Expand Down
1 change: 1 addition & 0 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ Effects for the character that has the enchantment:
* SIGHT_RANGE
* CARRY_WEIGHT
* CARRY_VOLUME
* WEAPON_DISPERSION
* SOCIAL_LIE
* SOCIAL_PERSUADE
* SOCIAL_INTIMIDATE
Expand Down
1 change: 1 addition & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void bionic_data::load( const JsonObject &jsobj, const std::string & )
optional( jsobj, was_loaded, "vitamin_absorb_mod", vitamin_absorb_mod, 1.0f );

optional( jsobj, was_loaded, "dupes_allowed", dupes_allowed, false );

int enchant_num = 0;
for( JsonValue jv : jsobj.get_array( "enchantments" ) ) {
std::string enchant_name = "INLINE_ENCH_" + name + "_" + std::to_string( enchant_num++ );
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace io
case enchant_vals::mod::FOOTSTEP_NOISE: return "FOOTSTEP_NOISE";
case enchant_vals::mod::SIGHT_RANGE: return "SIGHT_RANGE";
case enchant_vals::mod::CARRY_WEIGHT: return "CARRY_WEIGHT";
case enchant_vals::mod::WEAPON_DISPERSION: return "WEAPON_DISPERSION";
case enchant_vals::mod::SOCIAL_LIE: return "SOCIAL_LIE";
case enchant_vals::mod::SOCIAL_PERSUADE: return "SOCIAL_PERSUADE";
case enchant_vals::mod::SOCIAL_INTIMIDATE: return "SOCIAL_INTIMIDATE";
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum class mod : int {
FOOTSTEP_NOISE,
SIGHT_RANGE,
CARRY_WEIGHT,
WEAPON_DISPERSION,
SOCIAL_LIE,
SOCIAL_PERSUADE,
SOCIAL_INTIMIDATE,
Expand Down
7 changes: 4 additions & 3 deletions src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "input.h"
#include "item.h"
#include "json.h"
#include "make_static.h"
#include "magic.h"
#include "map.h"
#include "messages.h"
Expand Down Expand Up @@ -470,7 +471,7 @@ static std::string get_temp( const avatar &u )
{
std::string temp;
if( u.has_item_with_flag( json_flag_THERMOMETER ) ||
u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
u.has_flag( STATIC( json_character_flag( "THERMOMETER" ) ) ) ) {
temp = print_temperature( get_weather().get_temperature( u.pos() ) );
}
if( temp.empty() ) {
Expand Down Expand Up @@ -1676,7 +1677,7 @@ static void draw_env_compact( avatar &u, const catacurses::window &w )
get_wind_desc( windpower ) + " " + get_wind_arrow( g->weather.winddirection ) );

if( u.has_item_with_flag( json_flag_THERMOMETER ) ||
u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
u.has_flag( STATIC( json_character_flag( "THERMOMETER" ) ) ) ) {
std::string temp = print_temperature( g->weather.get_temperature( u.pos() ) );
mvwprintz( w, point( 31 - utf8_width( temp ), 5 ), c_light_gray, temp );
}
Expand Down Expand Up @@ -2058,7 +2059,7 @@ static void draw_time_classic( const avatar &u, const catacurses::window &w )
}

if( u.has_item_with_flag( json_flag_THERMOMETER ) ||
u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
u.has_flag( STATIC( json_character_flag( "THERMOMETER" ) ) ) ) {
std::string temp = print_temperature( get_weather().get_temperature( u.pos() ) );
mvwprintz( w, point( 31, 0 ), c_light_gray, _( "Temp : " ) + temp );
}
Expand Down
7 changes: 4 additions & 3 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ static const skill_id skill_launcher( "launcher" );
static const skill_id skill_throw( "throw" );

static const bionic_id bio_railgun( "bio_railgun" );
static const bionic_id bio_targeting( "bio_targeting" );
static const bionic_id bio_ups( "bio_ups" );

static const std::string flag_MOUNTABLE( "MOUNTABLE" );
Expand Down Expand Up @@ -1833,8 +1832,10 @@ dispersion_sources Character::get_weapon_dispersion( const item &obj ) const

dispersion.add_range( dispersion_from_skill( avgSkill, weapon_dispersion ) );

if( has_bionic( bio_targeting ) ) {
dispersion.add_multiplier( 0.75 );
float disperation_mod = enchantment_cache->modify_value( enchant_vals::mod::WEAPON_DISPERSION,
1.0f );
if( disperation_mod != 1.0f ) {
dispersion.add_multiplier( disperation_mod );
}

// Range is effectively four times longer when shooting unflagged/flagged guns underwater/out of water.
Expand Down

0 comments on commit b09bbfe

Please sign in to comment.