Skip to content

Commit

Permalink
feat: JSONize hardcoded effects of Parkour Expert, implement and use …
Browse files Browse the repository at this point in the history
…`falling_damage_multiplier` (#5624)

* feat: JSONize hardcoded effects of Parkour Expert, implement and use `falling_damage_multiplier`, document it and several mutation properties

* Stylomizin'

* Update mutations.json
  • Loading branch information
chaosvolt authored Nov 15, 2024
1 parent edcb7c6 commit cf30576
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 20 deletions.
24 changes: 16 additions & 8 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@
"id": "PARKOUR",
"name": { "str": "Parkour Expert" },
"points": 2,
"description": "You're skilled at clearing obstacles; terrain like railings or counters are as easy for you to move on as solid ground.",
"description": "You're skilled at clearing obstacles; terrain like railings or counters are as easy for you to move on as solid ground. Your experience also allows you to take reduced damage from falls.",
"starting_trait": true,
"valid": false,
"cancels": [ "BADKNEES", "FELINE_FLEXIBILITY" ],
"movecost_obstacle_modifier": 0.5
"movecost_obstacle_modifier": 0.5,
"falling_damage_multiplier": 0.66
},
{
"type": "mutation",
Expand Down Expand Up @@ -3459,6 +3460,8 @@
"visibility": 4,
"ugliness": 2,
"description": "You have a pair of large, feathered wings. Your body is too heavy to be able to fly, but you can use them to slow your descent during a fall, and will not take falling damage under any circumstances.",
"//": "Immunity to falls is already hardcoded in, but this will make the effect consistent with other wing traits since hulk tosses check the same multiplier.",
"falling_damage_multiplier": 0.75,
"types": [ "WINGS" ],
"prereqs": [ "WINGS_STUB" ],
"category": [ "BIRD" ]
Expand All @@ -3470,7 +3473,7 @@
"points": 1,
"visibility": 4,
"ugliness": 4,
"description": "You have a pair of large, translucent wings. They are too small to lift you, but are powerful enough to greatly speed your movement, with some effort and noise.",
"description": "You have a pair of large, translucent wings. They are too small to provide lift, but can reduce falling damage and if activated will greatly speed your movement, with some effort and noise.",
"types": [ "WINGS" ],
"prereqs": [ "WINGS_STUB" ],
"category": [ "INSECT" ],
Expand All @@ -3480,7 +3483,8 @@
"fatigue": true,
"hunger": true,
"thirst": true,
"movecost_modifier": 0.75
"movecost_modifier": 0.75,
"falling_damage_multiplier": 0.75
},
{
"type": "mutation",
Expand Down Expand Up @@ -4242,10 +4246,11 @@
"points": -1,
"visibility": 9,
"ugliness": 4,
"description": "You have a pair of large, leathery wings. You can move them a little, but they are useless, and in fact put you off balance, reducing your ability to dodge slightly.",
"description": "You have a pair of large, leathery wings. You can move them a little, but they only catch enough air to reduce falling damage a bit, and in fact put you off balance, reducing your ability to dodge slightly.",
"types": [ "WINGS" ],
"prereqs": [ "WINGS_STUB" ],
"dodge_modifier": -3
"dodge_modifier": -3,
"falling_damage_multiplier": 0.75
},
{
"type": "mutation",
Expand All @@ -4265,7 +4270,9 @@
"restricts_gear": [ "torso" ],
"social_modifiers": { "lie": 15, "persuade": 5, "intimidate": -20 },
"dodge_modifier": -4,
"movecost_modifier": 0.9
"movecost_modifier": 0.9,
"//": "Hardcoded effects include a 50% chance to negate a fall outright, this multiplier kicks in if you fall that roll or when tossed by a hulk.",
"falling_damage_multiplier": 0.75
},
{
"type": "mutation",
Expand Down Expand Up @@ -6487,13 +6494,14 @@
"id": "FELINE_FLEXIBILITY",
"name": { "str": "Feline Flexibility" },
"points": 4,
"description": "Your muscles, joints, and the movement center of your brain have changed internally somewhat, allowing you to traverse obstacles with ease. It also helps you avoid attacks a bit more easily.",
"description": "Your muscles, joints, and the movement center of your brain have changed internally somewhat, allowing you to traverse obstacles with ease. It also helps you avoid attacks a bit more easily, and flex with falls to take less damage.",
"valid": false,
"purifiable": false,
"cancels": [ "PARKOUR", "BADKNEES" ],
"threshreq": [ "THRESH_FELINE" ],
"category": [ "FELINE" ],
"movecost_obstacle_modifier": 0.3,
"falling_damage_multiplier": 0.5,
"dodge_modifier": 1
},
{
Expand Down
3 changes: 2 additions & 1 deletion data/mods/Aftershock/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@
"points": 1,
"visibility": 4,
"ugliness": 8,
"description": "You have a pair of large, veiny wings. They don't appear to be made for this atmosphere but they grant a powerful buffeting attack.",
"description": "You have a pair of large, veiny wings. They don't appear to be made for this atmosphere but they grant a powerful buffeting attack, and reduce falling damage.",
"types": [ "WINGS" ],
"prereqs": [ "WINGS_STUB" ],
"category": [ "MIGO" ],
"falling_damage_multiplier": 0.75,
"attacks": {
"attack_text_u": "You buffet %s with your wings",
"attack_text_npc": "%1$s buffets %2$s with their wings",
Expand Down
11 changes: 11 additions & 0 deletions doc/src/content/docs/en/mod/json/reference/json_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,17 @@ wake up for the first time after 24 hours into the game.
{ "bash" : 1 } // ...and gives them those resistances instead
]
],
"dodge_modifier" : 1, // Bonus granted to your effective change to dodge. Negative values inflict a penalty instead.
"speed_modifier" : 2.0, // Multiplies your current speed by this amount. Higher means more speed, with 1.0 being no change.
"movecost_modifier" : 0.5, // Multiplies the amount of moves it takes to perform most actions, with lower meaning faster actions.
"movecost_flatground_modifier" : 0.5, // Multiplies the movecost of terrain/furniture that is easy to move over. Lower means faster movement.
"movecost_obstacle_modifier" : 0.5, // Multipliers the movecost across rough terrain, lower means faster movement
"movecost_swim_modifier" : 0.5, // Multiplies the movecost needed to swim. Lower is faster.
"falling_damage_multiplier" : 0.5, // Multiplier on how much damage you take when falling into pits, falling off ledges, or being tossed by a hulk. Zero grants immunity.
"attackcost_modifier" : 0.5, // Multiplier on the movecost of attacks. Lower is better.
"weight_capacity_modifier" : 0.5, // Multiplies how much weight you can carry before being penalized.
"hearing_modifier" : 0.5, // Multiplier for how good your hearing is, higher values mean detecting sounds from farther away. A value of zero renders you completely deaf.
"noise_modifier" : 0.5, // Multiplier for how much noise you make while moving, with zero making your footsteps silent.
"stealth_modifier" : 0, // Percentage to be subtracted from player's visibility range, capped to 60. Negative values work, but are not very effective due to the way vision ranges are capped
"night_vision_range" : 0.0, // Night range vision. Only the best and the worst value out of all mutations are added. A value of 8 or higher will allow reading in complete darkness as though the player were in dim lighting. (default: 0.0)
"active" : true, //When set the mutation is an active mutation that the player needs to activate (default: false)
Expand Down
6 changes: 2 additions & 4 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ static const trait_id trait_PACKMULE( "PACKMULE" );
static const trait_id trait_PADDED_FEET( "PADDED_FEET" );
static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" );
static const trait_id trait_PAINRESIST( "PAINRESIST" );
static const trait_id trait_PARKOUR( "PARKOUR" );
static const trait_id trait_PAWS_LARGE( "PAWS_LARGE" );
static const trait_id trait_PAWS( "PAWS" );
static const trait_id trait_PER_SLIME_OK( "PER_SLIME_OK" );
Expand Down Expand Up @@ -6968,6 +6967,7 @@ mutation_value_map = {
{ "movecost_flatground_modifier", calc_mutation_value_multiplicative<&mutation_branch::movecost_flatground_modifier> },
{ "movecost_obstacle_modifier", calc_mutation_value_multiplicative<&mutation_branch::movecost_obstacle_modifier> },
{ "attackcost_modifier", calc_mutation_value_multiplicative<&mutation_branch::attackcost_modifier> },
{ "falling_damage_multiplier", calc_mutation_value_multiplicative<&mutation_branch::falling_damage_multiplier> },
{ "max_stamina_modifier", calc_mutation_value_multiplicative<&mutation_branch::max_stamina_modifier> },
{ "weight_capacity_modifier", calc_mutation_value_multiplicative<&mutation_branch::weight_capacity_modifier> },
{ "hearing_modifier", calc_mutation_value_multiplicative<&mutation_branch::hearing_modifier> },
Expand Down Expand Up @@ -11257,9 +11257,7 @@ float Character::fall_damage_mod() const
// 100% damage at 0, 75% at 10, 50% at 20 and so on
ret *= ( 100.0f - ( dex_dodge * 4.0f ) ) / 100.0f;

if( has_trait( trait_PARKOUR ) ) {
ret *= 2.0f / 3.0f;
}
ret *= mutation_value( "falling_damage_multiplier" );

// TODO: Bonus for Judo, mutations. Penalty for heavy weight (including mutations)
return std::max( 0.0f, ret );
Expand Down
9 changes: 5 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ static const trait_id trait_BADKNEES( "BADKNEES" );
static const trait_id trait_ILLITERATE( "ILLITERATE" );
static const trait_id trait_LEG_TENT_BRACE( "LEG_TENT_BRACE" );
static const trait_id trait_M_IMMUNE( "M_IMMUNE" );
static const trait_id trait_PARKOUR( "PARKOUR" );
static const trait_id trait_PROF_FERAL( "PROF_FERAL" );
static const trait_id trait_VINES2( "VINES2" );
static const trait_id trait_VINES3( "VINES3" );
Expand Down Expand Up @@ -8971,7 +8970,8 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp )
const bool fungus = m.has_flag_ter_or_furn( "FUNGUS", u.pos() ) ||
m.has_flag_ter_or_furn( "FUNGUS",
dest_loc ); //fungal furniture has no slowing effect on mycus characters
const bool slowed = ( ( !u.has_trait( trait_PARKOUR ) && ( mcost_to > 2 || mcost_from > 2 ) ) ||
const bool slowed = ( ( u.mutation_value( "movecost_obstacle_modifier" ) > 0.5f && ( mcost_to > 2 ||
mcost_from > 2 ) ) ||
mcost_to > 4 || mcost_from > 4 ) &&
!( u.has_trait( trait_M_IMMUNE ) && fungus );
if( slowed && !u.is_mounted() ) {
Expand Down Expand Up @@ -9133,8 +9133,9 @@ point game::place_player( const tripoint &dest_loc )
}
///\EFFECT_DEX increases chance of avoiding cuts on sharp terrain
if( m.has_flag( "SHARP", dest_loc ) && !one_in( 3 ) && !x_in_y( 1 + u.dex_cur / 2.0, 40 ) &&
( !u.in_vehicle && !m.veh_at( dest_loc ) ) && ( !u.has_trait( trait_PARKOUR ) ||
one_in( 4 ) ) && ( u.has_trait( trait_THICKSKIN ) ? !one_in( 8 ) : true ) ) {
( !u.in_vehicle && !m.veh_at( dest_loc ) ) &&
( u.mutation_value( "movecost_obstacle_modifier" ) > 0.5f ||
one_in( 4 ) ) && ( u.has_trait( trait_THICKSKIN ) ? !one_in( 8 ) : true ) ) {
if( u.is_mounted() ) {
add_msg( _( "Your %s gets cut!" ), u.mounted_creature->get_name() );
u.mounted_creature->apply_damage( nullptr, bodypart_id( "torso" ), rng( 1, 10 ) );
Expand Down
6 changes: 3 additions & 3 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ static const trait_id trait_M_DEPENDENT( "M_DEPENDENT" );
static const trait_id trait_M_FERTILE( "M_FERTILE" );
static const trait_id trait_M_SPORES( "M_SPORES" );
static const trait_id trait_NOPAIN( "NOPAIN" );
static const trait_id trait_PARKOUR( "PARKOUR" );
static const trait_id trait_PROBOSCIS( "PROBOSCIS" );
static const trait_id trait_THRESH_MARLOSS( "THRESH_MARLOSS" );
static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" );
Expand Down Expand Up @@ -1073,7 +1072,8 @@ void iexamine::chainfence( player &p, const tripoint &examp )
}

map &here = get_map();
if( here.has_flag( flag_CLIMB_SIMPLE, examp ) && p.has_trait( trait_PARKOUR ) ) {
if( here.has_flag( flag_CLIMB_SIMPLE, examp ) &&
p.mutation_value( "movecost_obstacle_modifier" ) <= 0.5f ) {
add_msg( _( "You vault over the obstacle with ease." ) );
p.moves -= 100; // Not tall enough to warrant spider-climbing, so only relevant trait.
} else if( here.has_flag( flag_CLIMB_SIMPLE, examp ) ) {
Expand All @@ -1087,7 +1087,7 @@ void iexamine::chainfence( player &p, const tripoint &examp )
!p.wearing_something_on( bodypart_id( "torso" ) ) ) {
add_msg( _( "You quickly scale the fence." ) );
p.moves -= 90;
} else if( p.has_trait( trait_PARKOUR ) ) {
} else if( p.mutation_value( "movecost_obstacle_modifier" ) <= 0.5f ) {
add_msg( _( "This obstacle is no match for your freerunning abilities." ) );
p.moves -= 100;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct mutation_branch {
float movecost_flatground_modifier = 1.0f;
float movecost_obstacle_modifier = 1.0f;
float attackcost_modifier = 1.0f;
float falling_damage_multiplier = 1.0f;
float max_stamina_modifier = 1.0f;
float weight_capacity_modifier = 1.0f;
float hearing_modifier = 1.0f;
Expand Down
1 change: 1 addition & 0 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "movecost_obstacle_modifier", movecost_obstacle_modifier, 1.0f );
optional( jo, was_loaded, "movecost_swim_modifier", movecost_swim_modifier, 1.0f );
optional( jo, was_loaded, "attackcost_modifier", attackcost_modifier, 1.0f );
optional( jo, was_loaded, "falling_damage_multiplier", falling_damage_multiplier, 1.0f );
optional( jo, was_loaded, "max_stamina_modifier", max_stamina_modifier, 1.0f );
optional( jo, was_loaded, "weight_capacity_modifier", weight_capacity_modifier, 1.0f );
optional( jo, was_loaded, "hearing_modifier", hearing_modifier, 1.0f );
Expand Down

0 comments on commit cf30576

Please sign in to comment.