Skip to content

Commit 8fd7286

Browse files
committed
Add an external option to enforce stat caps and set it for core game
Also for MoM
1 parent 4688691 commit 8fd7286

File tree

10 files changed

+143
-13
lines changed

10 files changed

+143
-13
lines changed

data/core/external_options.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@
2020
"stype": "int",
2121
"value": 3500
2222
},
23+
{
24+
"type": "EXTERNAL_OPTION",
25+
"name": "PLAYER_MAX_STR_VALUE",
26+
"//": "Sets a cap on maximum effective strength for characters.",
27+
"stype": "int",
28+
"value": 20
29+
},
30+
{
31+
"type": "EXTERNAL_OPTION",
32+
"name": "PLAYER_MAX_DEX_VALUE",
33+
"//": "Sets a cap on maximum effective dexterity for characters.",
34+
"stype": "int",
35+
"value": 20
36+
},
37+
{
38+
"type": "EXTERNAL_OPTION",
39+
"name": "PLAYER_MAX_PER_VALUE",
40+
"//": "Sets a cap on maximum effective perception for characters.",
41+
"stype": "int",
42+
"value": 20
43+
},
44+
{
45+
"type": "EXTERNAL_OPTION",
46+
"name": "PLAYER_MAX_INT_VALUE",
47+
"//": "Sets a cap on maximum effective intelligence for characters.",
48+
"stype": "int",
49+
"value": 20
50+
},
2351
{
2452
"type": "EXTERNAL_OPTION",
2553
"name": "PLAYER_CARDIOFIT_STAMINA_SCALING",

data/mods/Magiclysm/modinfo.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,33 @@
1616
"display_category": "display_ranged",
1717
"sort_rank": 14500,
1818
"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."
19+
},
20+
{
21+
"type": "EXTERNAL_OPTION",
22+
"name": "PLAYER_MAX_STR_VALUE",
23+
"//": "Sets a cap on maximum effective strength for characters.",
24+
"stype": "int",
25+
"value": 35
26+
},
27+
{
28+
"type": "EXTERNAL_OPTION",
29+
"name": "PLAYER_MAX_DEX_VALUE",
30+
"//": "Sets a cap on maximum effective dexterity for characters.",
31+
"stype": "int",
32+
"value": 35
33+
},
34+
{
35+
"type": "EXTERNAL_OPTION",
36+
"name": "PLAYER_MAX_PER_VALUE",
37+
"//": "Sets a cap on maximum effective perception for characters.",
38+
"stype": "int",
39+
"value": 35
40+
},
41+
{
42+
"type": "EXTERNAL_OPTION",
43+
"name": "PLAYER_MAX_INT_VALUE",
44+
"//": "Sets a cap on maximum effective inteligence for characters.",
45+
"stype": "int",
46+
"value": 35
1947
}
2048
]

data/mods/MindOverMatter/modinfo.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,26 @@
99
"category": "content",
1010
"dependencies": [ "dda" ],
1111
"conflicts": [ "aftershock_exoplanet" ]
12+
},
13+
{
14+
"type": "EXTERNAL_OPTION",
15+
"name": "PLAYER_MAX_STR_VALUE",
16+
"//": "Sets a cap on maximum effective strength for characters.",
17+
"stype": "int",
18+
"value": 35
19+
},
20+
{
21+
"type": "EXTERNAL_OPTION",
22+
"name": "PLAYER_MAX_DEX_VALUE",
23+
"//": "Sets a cap on maximum effective dexterity for characters.",
24+
"stype": "int",
25+
"value": 35
26+
},
27+
{
28+
"type": "EXTERNAL_OPTION",
29+
"name": "PLAYER_MAX_PER_VALUE",
30+
"//": "Sets a cap on maximum effective perception for characters.",
31+
"stype": "int",
32+
"value": 35
1233
}
1334
]

data/mods/TEST_DATA/enchantments.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"condition": "ALWAYS",
66
"emitter": "emit_shadow_field",
77
"values": [
8-
{ "value": "DEXTERITY", "multiply": 2, "add": 25 },
8+
{ "value": "DEXTERITY", "multiply": 1, "add": 1 },
99
{ "value": "SOCIAL_LIE", "multiply": 0.5, "add": 15 },
1010
{ "value": "SOCIAL_PERSUADE", "multiply": 0.5, "add": 15 },
1111
{ "value": "SOCIAL_INTIMIDATE", "multiply": 0.5, "add": 1 }

data/mods/TEST_DATA/items.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5245,7 +5245,7 @@
52455245
"passive_effects": [
52465246
{
52475247
"values": [
5248-
{ "value": "STRENGTH", "add": 3, "multiply": 1 },
5248+
{ "value": "STRENGTH", "add": 2, "multiply": 0.25 },
52495249
{ "value": "DEXTERITY", "add": -2 },
52505250
{ "value": "INTELLIGENCE", "add": 1, "multiply": -0.5 },
52515251
{ "value": "PERCEPTION", "add": -7 }

data/mods/Xedra_Evolved/modinfo.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,33 @@
99
"category": "content",
1010
"dependencies": [ "dda" ],
1111
"loading_images": [ "xedra1.png", "xedra2.png", "xedra3.png", "xedra4.png", "xedra5.png" ]
12+
},
13+
{
14+
"type": "EXTERNAL_OPTION",
15+
"name": "PLAYER_MAX_STR_VALUE",
16+
"//": "Sets a cap on maximum effective strength for characters.",
17+
"stype": "int",
18+
"value": 35
19+
},
20+
{
21+
"type": "EXTERNAL_OPTION",
22+
"name": "PLAYER_MAX_DEX_VALUE",
23+
"//": "Sets a cap on maximum effective dexterity for characters.",
24+
"stype": "int",
25+
"value": 35
26+
},
27+
{
28+
"type": "EXTERNAL_OPTION",
29+
"name": "PLAYER_MAX_PER_VALUE",
30+
"//": "Sets a cap on maximum effective perception for characters.",
31+
"stype": "int",
32+
"value": 35
33+
},
34+
{
35+
"type": "EXTERNAL_OPTION",
36+
"name": "PLAYER_MAX_INT_VALUE",
37+
"//": "Sets a cap on maximum effective inteligence for characters.",
38+
"stype": "int",
39+
"value": 35
1240
}
1341
]

src/character.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ static const std::string type_skin_tone( "skin_tone" );
513513
static const std::string type_facial_hair( "facial_hair" );
514514
static const std::string type_eye_color( "eye_color" );
515515

516+
int character_max_str = 20;
517+
int character_max_dex = 20;
518+
int character_max_per = 20;
519+
int character_max_int = 20;
520+
516521
namespace io
517522
{
518523

@@ -4330,36 +4335,36 @@ body_part_set Character::exclusive_flag_coverage( const flag_id &flag ) const
43304335
// get_stat_bonus() is always just the bonus amount
43314336
int Character::get_str() const
43324337
{
4333-
return std::max( 0, get_str_base() + str_bonus );
4338+
return std::min( character_max_str, std::max( 0, get_str_base() + str_bonus ) );
43344339
}
43354340
int Character::get_dex() const
43364341
{
4337-
return std::max( 0, get_dex_base() + dex_bonus );
4342+
return std::min( character_max_dex, std::max( 0, get_dex_base() + dex_bonus ) );
43384343
}
43394344
int Character::get_per() const
43404345
{
4341-
return std::max( 0, get_per_base() + per_bonus );
4346+
return std::min( character_max_per, std::max( 0, get_per_base() + per_bonus ) );
43424347
}
43434348
int Character::get_int() const
43444349
{
4345-
return std::max( 0, get_int_base() + int_bonus );
4350+
return std::min( character_max_int, std::max( 0, get_int_base() + int_bonus ) );
43464351
}
43474352

43484353
int Character::get_str_base() const
43494354
{
4350-
return str_max;
4355+
return std::min( character_max_str, str_max );
43514356
}
43524357
int Character::get_dex_base() const
43534358
{
4354-
return dex_max;
4359+
return std::min( character_max_dex, dex_max );
43554360
}
43564361
int Character::get_per_base() const
43574362
{
4358-
return per_max;
4363+
return std::min( character_max_per, per_max );
43594364
}
43604365
int Character::get_int_base() const
43614366
{
4362-
return int_max;
4367+
return std::min( character_max_int, int_max );
43634368
}
43644369

43654370
int Character::get_str_bonus() const

src/character.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ template <typename E> struct enum_traits;
123123

124124
using bionic_uid = unsigned int;
125125

126+
extern int character_max_str;
127+
extern int character_max_dex;
128+
extern int character_max_per;
129+
extern int character_max_int;
130+
126131
constexpr int MAX_CLAIRVOYANCE = 40;
127132
// kcal in a kilogram of fat, used to convert stored kcal into body weight. 3500kcal/lb * 2.20462lb/kg = 7716.17
128133
constexpr float KCAL_PER_KG = 3500 * 2.20462;

src/options.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4033,6 +4033,21 @@ void options_manager::update_options_cache()
40334033
trigdist = ::get_option<bool>( "CIRCLEDIST" );
40344034
use_tiles = ::get_option<bool>( "USE_TILES" );
40354035

4036+
// Since these are external options they aren't loaded before the first time
4037+
// update_options_cache is called, so they're conditionally loaded.
4038+
if( ::has_option( "PLAYER_MAX_STR_VALUE" ) ) {
4039+
character_max_str = ::get_option<int>( "PLAYER_MAX_STR_VALUE" );
4040+
}
4041+
if( ::has_option( "PLAYER_MAX_DEX_VALUE" ) ) {
4042+
character_max_dex = ::get_option<int>( "PLAYER_MAX_DEX_VALUE" );
4043+
}
4044+
if( ::has_option( "PLAYER_MAX_PER_VALUE" ) ) {
4045+
character_max_per = ::get_option<int>( "PLAYER_MAX_PER_VALUE" );
4046+
}
4047+
if( ::has_option( "PLAYER_MAX_INT_VALUE" ) ) {
4048+
character_max_int = ::get_option<int>( "PLAYER_MAX_INT_VALUE" );
4049+
}
4050+
40364051
prevent_occlusion = ::get_option<int>( "PREVENT_OCCLUSION" );
40374052
prevent_occlusion_retract = ::get_option<bool>( "PREVENT_OCCLUSION_RETRACT" );
40384053
prevent_occlusion_transp = ::get_option<bool>( "PREVENT_OCCLUSION_TRANSP" );

tests/enchantments_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void test_generic_ench( avatar &p, enchant_test enc_test )
7373
// wait a turn for the effect to kick in
7474
p.process_turn();
7575

76-
CHECK( p.get_dex() == ( enc_test.dex_before + 25 ) * 3 );
76+
CHECK( p.get_dex() == ( enc_test.dex_before + 1 ) * 2 );
7777
CHECK( get_talker_for( p )->trial_chance_mod( "lie" ) == static_cast<int>( round( (
7878
enc_test.lie_before + 15 ) * 1.5 ) ) );
7979
CHECK( get_talker_for( p )->trial_chance_mod( "persuade" ) == static_cast<int>( round( (
@@ -167,7 +167,7 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" )
167167
guy.recalculate_enchantment_cache();
168168
advance_turn( guy );
169169
INFO( "Stats change accordingly" );
170-
REQUIRE( guy.get_str() == 22 );
170+
REQUIRE( guy.get_str() == 12 );
171171
REQUIRE( guy.get_dex() == 6 );
172172
REQUIRE( guy.get_int() == 5 );
173173
REQUIRE( guy.get_per() == 1 );
@@ -191,7 +191,7 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" )
191191
guy.recalculate_enchantment_cache();
192192
advance_turn( guy );
193193
INFO( "Stats change accordingly" );
194-
REQUIRE( guy.get_str() == 42 );
194+
REQUIRE( guy.get_str() == 18 );
195195
REQUIRE( guy.get_dex() == 4 );
196196
REQUIRE( guy.get_int() == 0 );
197197
REQUIRE( guy.get_per() == 0 );

0 commit comments

Comments
 (0)