Skip to content
Open
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
28 changes: 28 additions & 0 deletions data/core/external_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@
"stype": "int",
"value": 3500
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_STR_VALUE",
"//": "Sets a cap on maximum effective strength for characters.",
"stype": "int",
"value": 20
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_DEX_VALUE",
"//": "Sets a cap on maximum effective dexterity for characters.",
"stype": "int",
"value": 20
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_PER_VALUE",
"//": "Sets a cap on maximum effective perception for characters.",
"stype": "int",
"value": 20
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_INT_VALUE",
"//": "Sets a cap on maximum effective intelligence for characters.",
"stype": "int",
"value": 20
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_CARDIOFIT_STAMINA_SCALING",
Expand Down
28 changes: 28 additions & 0 deletions data/mods/Magiclysm/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,33 @@
"display_category": "display_ranged",
"sort_rank": 14500,
"description": "Your skill in the arcane. Represents magic theory and all that entails. A higher skill increases how quickly you can learn spells, and decreases their spell failure chance. You learn this skill by studying books or spells."
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_STR_VALUE",
"//": "Sets a cap on maximum effective strength for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_DEX_VALUE",
"//": "Sets a cap on maximum effective dexterity for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_PER_VALUE",
"//": "Sets a cap on maximum effective perception for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_INT_VALUE",
"//": "Sets a cap on maximum effective inteligence for characters.",
"stype": "int",
"value": 35
}
]
21 changes: 21 additions & 0 deletions data/mods/MindOverMatter/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,26 @@
"category": "content",
"dependencies": [ "dda" ],
"conflicts": [ "aftershock_exoplanet" ]
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_STR_VALUE",
"//": "Sets a cap on maximum effective strength for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_DEX_VALUE",
"//": "Sets a cap on maximum effective dexterity for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_PER_VALUE",
"//": "Sets a cap on maximum effective perception for characters.",
"stype": "int",
"value": 35
}
]
2 changes: 1 addition & 1 deletion data/mods/TEST_DATA/enchantments.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"condition": "ALWAYS",
"emitter": "emit_shadow_field",
"values": [
{ "value": "DEXTERITY", "multiply": 2, "add": 25 },
{ "value": "DEXTERITY", "multiply": 1, "add": 1 },
{ "value": "SOCIAL_LIE", "multiply": 0.5, "add": 15 },
{ "value": "SOCIAL_PERSUADE", "multiply": 0.5, "add": 15 },
{ "value": "SOCIAL_INTIMIDATE", "multiply": 0.5, "add": 1 }
Expand Down
2 changes: 1 addition & 1 deletion data/mods/TEST_DATA/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -5245,7 +5245,7 @@
"passive_effects": [
{
"values": [
{ "value": "STRENGTH", "add": 3, "multiply": 1 },
{ "value": "STRENGTH", "add": 2, "multiply": 0.25 },
{ "value": "DEXTERITY", "add": -2 },
{ "value": "INTELLIGENCE", "add": 1, "multiply": -0.5 },
{ "value": "PERCEPTION", "add": -7 }
Expand Down
28 changes: 28 additions & 0 deletions data/mods/Xedra_Evolved/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,33 @@
"category": "content",
"dependencies": [ "dda" ],
"loading_images": [ "xedra1.png", "xedra2.png", "xedra3.png", "xedra4.png", "xedra5.png" ]
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_STR_VALUE",
"//": "Sets a cap on maximum effective strength for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_DEX_VALUE",
"//": "Sets a cap on maximum effective dexterity for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_PER_VALUE",
"//": "Sets a cap on maximum effective perception for characters.",
"stype": "int",
"value": 35
},
{
"type": "EXTERNAL_OPTION",
"name": "PLAYER_MAX_INT_VALUE",
"//": "Sets a cap on maximum effective inteligence for characters.",
"stype": "int",
"value": 35
}
]
21 changes: 13 additions & 8 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ static const std::string type_skin_tone( "skin_tone" );
static const std::string type_facial_hair( "facial_hair" );
static const std::string type_eye_color( "eye_color" );

int character_max_str = 20;
int character_max_dex = 20;
int character_max_per = 20;
int character_max_int = 20;

namespace io
{

Expand Down Expand Up @@ -4330,36 +4335,36 @@ body_part_set Character::exclusive_flag_coverage( const flag_id &flag ) const
// get_stat_bonus() is always just the bonus amount
int Character::get_str() const
{
return std::max( 0, get_str_base() + str_bonus );
return std::min( character_max_str, std::max( 0, get_str_base() + str_bonus ) );
}
int Character::get_dex() const
{
return std::max( 0, get_dex_base() + dex_bonus );
return std::min( character_max_dex, std::max( 0, get_dex_base() + dex_bonus ) );
}
int Character::get_per() const
{
return std::max( 0, get_per_base() + per_bonus );
return std::min( character_max_per, std::max( 0, get_per_base() + per_bonus ) );
}
int Character::get_int() const
{
return std::max( 0, get_int_base() + int_bonus );
return std::min( character_max_int, std::max( 0, get_int_base() + int_bonus ) );
}

int Character::get_str_base() const
{
return str_max;
return std::min( character_max_str, str_max );
}
int Character::get_dex_base() const
{
return dex_max;
return std::min( character_max_dex, dex_max );
}
int Character::get_per_base() const
{
return per_max;
return std::min( character_max_per, per_max );
}
int Character::get_int_base() const
{
return int_max;
return std::min( character_max_int, int_max );
}

int Character::get_str_bonus() const
Expand Down
5 changes: 5 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ template <typename E> struct enum_traits;

using bionic_uid = unsigned int;

extern int character_max_str;
extern int character_max_dex;
extern int character_max_per;
extern int character_max_int;

constexpr int MAX_CLAIRVOYANCE = 40;
// kcal in a kilogram of fat, used to convert stored kcal into body weight. 3500kcal/lb * 2.20462lb/kg = 7716.17
constexpr float KCAL_PER_KG = 3500 * 2.20462;
Expand Down
15 changes: 15 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4033,6 +4033,21 @@ void options_manager::update_options_cache()
trigdist = ::get_option<bool>( "CIRCLEDIST" );
use_tiles = ::get_option<bool>( "USE_TILES" );

// Since these are external options they aren't loaded before the first time
// update_options_cache is called, so they're conditionally loaded.
if( ::has_option( "PLAYER_MAX_STR_VALUE" ) ) {
character_max_str = ::get_option<int>( "PLAYER_MAX_STR_VALUE" );
}
if( ::has_option( "PLAYER_MAX_DEX_VALUE" ) ) {
character_max_dex = ::get_option<int>( "PLAYER_MAX_DEX_VALUE" );
}
if( ::has_option( "PLAYER_MAX_PER_VALUE" ) ) {
character_max_per = ::get_option<int>( "PLAYER_MAX_PER_VALUE" );
}
if( ::has_option( "PLAYER_MAX_INT_VALUE" ) ) {
character_max_int = ::get_option<int>( "PLAYER_MAX_INT_VALUE" );
}

prevent_occlusion = ::get_option<int>( "PREVENT_OCCLUSION" );
prevent_occlusion_retract = ::get_option<bool>( "PREVENT_OCCLUSION_RETRACT" );
prevent_occlusion_transp = ::get_option<bool>( "PREVENT_OCCLUSION_TRANSP" );
Expand Down
6 changes: 3 additions & 3 deletions tests/enchantments_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void test_generic_ench( avatar &p, enchant_test enc_test )
// wait a turn for the effect to kick in
p.process_turn();

CHECK( p.get_dex() == ( enc_test.dex_before + 25 ) * 3 );
CHECK( p.get_dex() == ( enc_test.dex_before + 1 ) * 2 );
CHECK( get_talker_for( p )->trial_chance_mod( "lie" ) == static_cast<int>( round( (
enc_test.lie_before + 15 ) * 1.5 ) ) );
CHECK( get_talker_for( p )->trial_chance_mod( "persuade" ) == static_cast<int>( round( (
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" )
guy.recalculate_enchantment_cache();
advance_turn( guy );
INFO( "Stats change accordingly" );
REQUIRE( guy.get_str() == 22 );
REQUIRE( guy.get_str() == 12 );
REQUIRE( guy.get_dex() == 6 );
REQUIRE( guy.get_int() == 5 );
REQUIRE( guy.get_per() == 1 );
Expand All @@ -191,7 +191,7 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" )
guy.recalculate_enchantment_cache();
advance_turn( guy );
INFO( "Stats change accordingly" );
REQUIRE( guy.get_str() == 42 );
REQUIRE( guy.get_str() == 18 );
REQUIRE( guy.get_dex() == 4 );
REQUIRE( guy.get_int() == 0 );
REQUIRE( guy.get_per() == 0 );
Expand Down
Loading