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

Moving quadrupedally through certain traps now applies appropriate damage to arms/hands #74662

Merged
merged 47 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3a5f349
updates traps
GalacticApple Jun 19, 2024
e8fb5b6
syntax fix
GalacticApple Jun 19, 2024
8eadaa8
syntax fix 2
GalacticApple Jun 19, 2024
c91cc7b
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
e99df0a
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
aa63c68
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
4be2158
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
b20d465
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
ef2a0b3
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
af63dad
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
9a3d47c
Update src/trapfunc.cpp
GalacticApple Jun 19, 2024
6b04c9a
Update trapfunc.cpp
GalacticApple Jun 19, 2024
8fb0d3e
added ground contact function
GalacticApple Jun 21, 2024
d3ae1e2
Update src/creature.cpp
GalacticApple Jun 21, 2024
5c1fa6e
Update src/creature.cpp
GalacticApple Jun 21, 2024
142e582
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
3255987
Update src/creature.cpp
GalacticApple Jun 21, 2024
0851998
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
7a25d08
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
0e855a4
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
6a4c955
Update src/map_field.cpp
GalacticApple Jun 21, 2024
eb65440
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
7bb6a6f
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
5fbb32a
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
97f5482
Update trapfunc.cpp
GalacticApple Jun 21, 2024
76be5e3
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
ea07ad8
Update src/trapfunc.cpp
GalacticApple Jun 21, 2024
7861f11
Merge branch 'CleverRaven:master' into allhands
GalacticApple Jun 21, 2024
7a14515
hardcoding fixes
GalacticApple Jun 22, 2024
aed2cdb
Update src/creature.cpp
GalacticApple Jun 22, 2024
82ef2d8
Update src/map_field.cpp
GalacticApple Jun 22, 2024
be35793
Update src/map_field.cpp
GalacticApple Jun 22, 2024
df7f051
Update src/map_field.cpp
GalacticApple Jun 22, 2024
ddfcde3
Update src/trapfunc.cpp
GalacticApple Jun 22, 2024
f334986
string_format
GalacticApple Jun 23, 2024
d6ccb29
Update map_field.cpp
GalacticApple Jun 23, 2024
24d5258
Merge branch 'CleverRaven:master' into allhands
GalacticApple Jun 23, 2024
9f459b1
Update src/trapfunc.cpp
GalacticApple Jun 23, 2024
c9c6338
adds enumerate_as_string text
GalacticApple Jun 23, 2024
29072e7
Update src/creature.cpp
GalacticApple Jun 23, 2024
83c7ecf
Update src/map_field.cpp
GalacticApple Jun 23, 2024
7071b3b
Merge branch 'CleverRaven:master' into allhands
GalacticApple Jun 24, 2024
2bcad37
remove extra effects
GalacticApple Jun 25, 2024
e31dc0a
reference fix
GalacticApple Jun 26, 2024
7a3616a
Update src/creature.cpp
GalacticApple Jun 26, 2024
96b8bcd
Update src/trapfunc.cpp
GalacticApple Jun 26, 2024
54c4468
Merge branch 'CleverRaven:master' into allhands
GalacticApple Jun 27, 2024
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
3 changes: 2 additions & 1 deletion data/json/enchantments.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
{ "not": "u_can_drop_weapon" }
]
},
"values": [ { "value": "MOVE_COST", "multiply": -0.5 } ]
"values": [ { "value": "MOVE_COST", "multiply": -0.5 } ],
"ench_effects": [ { "effect": "quadruped_half", "intensity": 1 } ]
},
{
"id": "combat_exoskeleton_inactive",
Expand Down
50 changes: 50 additions & 0 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ static const efftype_id effect_no_sight( "no_sight" );
static const efftype_id effect_npc_suspend( "npc_suspend" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_paralyzepoison( "paralyzepoison" );
static const efftype_id effect_quadruped_full( "quadruped_full" );
static const efftype_id effect_quadruped_half( "quadruped_half" );
static const efftype_id effect_ridden( "ridden" );
static const efftype_id effect_riding( "riding" );
static const efftype_id effect_sap( "sap" );
Expand Down Expand Up @@ -2833,6 +2835,54 @@ body_part_set Creature::get_drenching_body_parts( bool upper, bool mid, bool low
return ret;
}

std::vector<bodypart_id> Creature::get_ground_contact_bodyparts( bool arms_legs ) const
{
std::vector<bodypart_id> arms = get_all_body_parts_of_type( body_part_type::type::arm );
std::vector<bodypart_id> legs = get_all_body_parts_of_type( body_part_type::type::leg );
std::vector<bodypart_id> hands = get_all_body_parts_of_type( body_part_type::type::hand );
std::vector<bodypart_id> feet = get_all_body_parts_of_type( body_part_type::type::foot );

if( has_effect( effect_quadruped_full ) || has_effect( effect_quadruped_half ) ) {
if( arms_legs == true ) {
std::vector<bodypart_id> bodyparts( arms.size() + legs.size() );
std::merge( arms.begin(), arms.end(), legs.begin(), legs.end(), bodyparts.begin() );
return bodyparts;
} else {
std::vector<bodypart_id> bodyparts( hands.size() + feet.size() );
std::merge( hands.begin(), hands.end(), feet.begin(), feet.end(), bodyparts.begin() );
return bodyparts;
}
} else {
std::vector<bodypart_id> bodyparts;
if( arms_legs == true ) {
bodyparts = get_all_body_parts_of_type( body_part_type::type::leg );
} else {
bodyparts = get_all_body_parts_of_type( body_part_type::type::foot );
}
return bodyparts;
}
}

std::string Creature::get_ground_contact_bodyparts_string( bool arms_legs ) const
{
std::string bodyparts;
if( has_effect( effect_quadruped_full ) || has_effect( effect_quadruped_half ) ) {
if( arms_legs == true ) {
bodyparts = "arms and legs";
} else {
bodyparts = "hands and feet";
}
return bodyparts;
} else {
if( arms_legs == true ) {
bodyparts = "legs";
} else {
bodyparts = "feet";
}
return bodyparts;
}
}

int Creature::get_num_body_parts_of_type( body_part_type::type part_type ) const
{
return static_cast<int>( get_all_body_parts_of_type( part_type ).size() );
Expand Down
5 changes: 5 additions & 0 deletions src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,11 @@ class Creature : public viewer
body_part_set get_drenching_body_parts( bool upper = true, bool mid = true,
bool lower = true ) const;

/* Returns the which limbs are being used for movement of a given type*/
std::vector<bodypart_id> get_ground_contact_bodyparts( bool arms_legs = false ) const;

std::string get_ground_contact_bodyparts_string( bool arms_legs = false ) const;

/* Returns the number of bodyparts of a given type*/
int get_num_body_parts_of_type( body_part_type::type part_type ) const;

Expand Down
27 changes: 12 additions & 15 deletions src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static const efftype_id effect_fungus( "fungus" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_poison( "poison" );
static const efftype_id effect_quadruped_full( "quadruped_full" );
static const efftype_id effect_quadruped_half( "quadruped_half" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_teargas( "teargas" );

Expand Down Expand Up @@ -1471,20 +1472,15 @@ void map::player_in_field( Character &you )
// you're certainly not standing in it.
if( !you.in_vehicle && !you.has_trait( trait_ACIDPROOF ) ) {
int total_damage = 0;
total_damage += burn_body_part( you, cur, bodypart_id( "foot_l" ), 2 );
total_damage += burn_body_part( you, cur, bodypart_id( "foot_r" ), 2 );
if( you.has_effect( effect_quadruped_full ) ) {
total_damage += burn_body_part( you, cur, bodypart_id( "hand_l" ), 2 );
total_damage += burn_body_part( you, cur, bodypart_id( "hand_r" ), 2 );
}
const bool on_ground = you.is_on_ground();
if( on_ground ) {
if( !on_ground ) {
for( const bodypart_id &bp : you.get_ground_contact_bodyparts() ) {
total_damage += burn_body_part( you, cur, bp, 2 );
}
} else {
// Apply the effect to the remaining body parts
total_damage += burn_body_part( you, cur, bodypart_id( "leg_l" ), 2 );
total_damage += burn_body_part( you, cur, bodypart_id( "leg_r" ), 2 );
if( !you.has_effect( effect_quadruped_full ) ) {
total_damage += burn_body_part( you, cur, bodypart_id( "hand_l" ), 2 );
total_damage += burn_body_part( you, cur, bodypart_id( "hand_r" ), 2 );
for( const bodypart_id &bp : you.get_ground_contact_bodyparts( true ) ) {
total_damage += burn_body_part( you, cur, bp, 2 );
}
total_damage += burn_body_part( you, cur, bodypart_id( "torso" ), 2 );
// Less arms = less ability to keep upright
Expand All @@ -1499,8 +1495,9 @@ void map::player_in_field( Character &you )
you.add_msg_player_or_npc( m_bad, _( "The acid burns your body!" ),
_( "The acid burns <npcname>'s body!" ) );
} else if( total_damage > 0 ) {
you.add_msg_player_or_npc( m_bad, _( "The acid burns your legs and feet!" ),
_( "The acid burns <npcname>'s legs and feet!" ) );
you.add_msg_player_or_npc( m_bad,
_( "The acid burns your " ) + you.get_ground_contact_bodyparts_string() + "!",
_( "The acid burns <npcname>'s " ) + you.get_ground_contact_bodyparts_string() + "!" );
GalacticApple marked this conversation as resolved.
Show resolved Hide resolved
} else if( on_ground ) {
you.add_msg_if_player( m_warning, _( "You're lying in a pool of acid!" ) );
} else if( !you.is_immune_field( fd_acid ) ) {
Expand Down Expand Up @@ -1585,7 +1582,7 @@ void map::player_in_field( Character &you )
parts_burned.emplace_back( "leg_l" );
parts_burned.emplace_back( "leg_r" );
}
} else if( you.has_effect( effect_quadruped_full ) ) {
} else if( you.has_effect( effect_quadruped_full ) || you.has_effect( effect_quadruped_half ) ) {
GalacticApple marked this conversation as resolved.
Show resolved Hide resolved
// Moving on all-fours through a fire is a bad idea, hits every body part.
msg_num = 3;
const std::vector<bodypart_id> all_parts = you.get_all_body_parts();
Expand Down
75 changes: 43 additions & 32 deletions src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
static const efftype_id effect_heavysnare( "heavysnare" );
static const efftype_id effect_in_pit( "in_pit" );
static const efftype_id effect_lightsnare( "lightsnare" );
static const efftype_id effect_quadruped_full( "quadruped_full" );

Check failure on line 57 in src/trapfunc.cpp

View workflow job for this annotation

GitHub Actions / build (src)

Variable 'effect_quadruped_full' declared but not used. [cata-unused-statics,-warnings-as-errors]
static const efftype_id effect_quadruped_half( "quadruped_half" );

Check failure on line 58 in src/trapfunc.cpp

View workflow job for this annotation

GitHub Actions / build (src)

Variable 'effect_quadruped_half' declared but not used. [cata-unused-statics,-warnings-as-errors]
static const efftype_id effect_ridden( "ridden" );
static const efftype_id effect_slimed( "slimed" );
static const efftype_id effect_slow_descent( "slow_descent" );
Expand Down Expand Up @@ -156,8 +158,9 @@
z->mod_moves( -z->get_speed() * 0.8 );
}
if( dmg > 0 ) {
c->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, dmg ) );
c->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, dmg ) );
for( const bodypart_id &bp : c->get_ground_contact_bodyparts() ) {
c->deal_damage( nullptr, bp, damage_instance( damage_cut, dmg ) );
}
c->check_dead_state();
}
}
Expand Down Expand Up @@ -189,11 +192,13 @@
here.remove_trap( p );
if( c != nullptr ) {
// What got hit?
const bodypart_id hit = one_in( 2 ) ? bodypart_id( "leg_l" ) : bodypart_id( "leg_r" );
const bodypart_id hit = random_entry( c->get_ground_contact_bodyparts( true ) );

// Messages
c->add_msg_player_or_npc( m_bad, _( "A bear trap closes on your foot!" ),
_( "A bear trap closes on <npcname>'s foot!" ) );
c->add_msg_player_or_npc( m_bad,
string_format( _( "A bear trap closes on your %s" ), body_part_name_accusative( hit ) ),
string_format( _( "A bear trap closes on <npcname>'s %s" ), body_part_name( hit ) ) );

if( c->has_effect( effect_ridden ) ) {
add_msg( m_warning, _( "Your %s is caught by a beartrap!" ), c->get_name() );
}
Expand Down Expand Up @@ -244,12 +249,13 @@
z->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, rng( 3,
5 ) ) );
} else {
dealt_damage_instance dealt_dmg_l = c->deal_damage( nullptr, bodypart_id( "foot_l" ),
damage_instance( damage_cut, rng( 6, 10 ) ) );
dealt_damage_instance dealt_dmg_r = c->deal_damage( nullptr, bodypart_id( "foot_r" ),
damage_instance( damage_cut, rng( 6, 10 ) ) );
int total_cut_dmg = dealt_dmg_l.type_damage( damage_cut ) + dealt_dmg_l.type_damage(
damage_cut );
int total_cut_dmg = 0;

for( const bodypart_id &bp : c->get_ground_contact_bodyparts() ) {
dealt_damage_instance dd = c->deal_damage( nullptr, bp, damage_instance( damage_cut, rng( 6,
10 ) ) );
total_cut_dmg += dd.type_damage( damage_cut );
}
if( !you->has_flag( json_flag_INFECTION_IMMUNE ) && total_cut_dmg > 0 ) {
const int chance_in = you->has_trait( trait_INFRESIST ) ? 256 : 35;
if( one_in( chance_in ) ) {
Expand Down Expand Up @@ -285,23 +291,19 @@
z->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, rng( 9,
15 ) ) );
} else {
dealt_damage_instance dealt_dmg_l = c->deal_damage( nullptr, bodypart_id( "foot_l" ),
damage_instance( damage_cut, rng( 9,
30 ) ) );
dealt_damage_instance dealt_dmg_r = c->deal_damage( nullptr, bodypart_id( "foot_r" ),
damage_instance( damage_cut, rng( 9,
30 ) ) );

const int total_cut_dmg = dealt_dmg_l.type_damage( damage_cut ) + dealt_dmg_l.type_damage(
damage_cut );
int total_cut_dmg = 0;
for( const bodypart_id &bp : c->get_ground_contact_bodyparts() ) {
dealt_damage_instance dd = c->deal_damage( nullptr, bp, damage_instance( damage_cut, rng( 9,
30 ) ) );
total_cut_dmg += dd.type_damage( damage_cut );
}
Character *you = dynamic_cast<Character *>( c );
if( you != nullptr && !you->has_flag( json_flag_INFECTION_IMMUNE ) && total_cut_dmg > 0 ) {
const int chance_in = you->has_trait( trait_INFRESIST ) ? 256 : 35;
if( one_in( chance_in ) ) {
you->add_effect( effect_tetanus, 1_turns, true );
}
}

}
c->check_dead_state();
return true;
Expand All @@ -324,8 +326,10 @@
z->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, rng( 9, 15 ) ) );
z->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, rng( 9, 15 ) ) );
} else {
c->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, rng( 9, 30 ) ) );
c->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, rng( 9, 30 ) ) );
for( const bodypart_id &bp : c->get_ground_contact_bodyparts() ) {
dealt_damage_instance dd = c->deal_damage( nullptr, bp, damage_instance( damage_cut, rng( 9,
30 ) ) );
GalacticApple marked this conversation as resolved.
Show resolved Hide resolved
}
}
c->check_dead_state();
if( get_player_view().sees( p ) ) {
Expand Down Expand Up @@ -744,12 +748,17 @@
monster *z = dynamic_cast<monster *>( c );
Character *you = dynamic_cast<Character *>( c );
if( you != nullptr ) {
you->add_env_effect( effect_slimed, bodypart_id( "foot_l" ), 6, 2_minutes );
you->add_env_effect( effect_slimed, bodypart_id( "foot_r" ), 6, 2_minutes );
for( const bodypart_id &bp : you->get_ground_contact_bodyparts() ) {
you->add_env_effect( effect_slimed, bp, 6, 2_minutes );
}
if( one_in( 3 ) ) {
you->add_msg_if_player( m_bad, _( "The acidic goo eats away at your feet." ) );
you->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, 5 ) );
you->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, 5 ) );
for( const bodypart_id &bp : you->get_ground_contact_bodyparts() ) {
you->deal_damage( nullptr, bp, damage_instance( damage_cut, 5 ) );
}
you->add_msg_player_or_npc( m_bad,
_( "The acidic goo eats away at your " ) + you->get_ground_contact_bodyparts_string() + "!",
_( "The acidic goo eats away at <npcname>'s " ) + you->get_ground_contact_bodyparts_string() +
"!" );
you->check_dead_state();
}
return true;
Expand Down Expand Up @@ -1066,10 +1075,12 @@
monster *z = dynamic_cast<monster *>( c );
Character *you = dynamic_cast<Character *>( c );
if( you != nullptr ) {
you->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_heat, 20 ) );
you->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_heat, 20 ) );
you->deal_damage( nullptr, bodypart_id( "leg_l" ), damage_instance( damage_heat, 20 ) );
you->deal_damage( nullptr, bodypart_id( "leg_r" ), damage_instance( damage_heat, 20 ) );
for( const bodypart_id &bp : you->get_ground_contact_bodyparts( true ) ) {
you->deal_damage( nullptr, bp, damage_instance( damage_heat, 20 ) );
}
for( const bodypart_id &bp : you->get_ground_contact_bodyparts() ) {
you->deal_damage( nullptr, bp, damage_instance( damage_heat, 20 ) );
}
} else if( z != nullptr ) {
if( z->has_effect( effect_ridden ) ) {
add_msg( m_bad, _( "Your %s is burned by the lava!" ), z->get_name() );
Expand Down
Loading