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

Grab cleanup #66732

Merged
merged 4 commits into from
Jul 10, 2023
Merged
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
14 changes: 0 additions & 14 deletions data/json/body_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"hit_difficulty": 1,
"side": "both",
"legacy_id": "TORSO",
"grabbing_effect": "grabbing_torso",
"stylish_bonus": 6,
"hot_morale_mod": 2,
"cold_morale_mod": 2,
Expand Down Expand Up @@ -128,7 +127,6 @@
"hit_size": 4,
"hit_difficulty": 1.2,
"side": "both",
"grabbing_effect": "grabbing_head",
"stylish_bonus": 3,
"hot_morale_mod": 2,
"cold_morale_mod": 2,
Expand Down Expand Up @@ -221,7 +219,6 @@
"hit_difficulty": 1.2,
"side": "both",
"legacy_id": "HEAD",
"grabbing_effect": "grabbing_head",
"stylish_bonus": 3,
"hot_morale_mod": 2,
"cold_morale_mod": 2,
Expand Down Expand Up @@ -312,7 +309,6 @@
"side": "both",
"legacy_id": "EYES",
"//": "Shouldn't happen, but consistency is nice",
"grabbing_effect": "grabbing_eyes",
"stylish_bonus": 2,
"squeamish_penalty": 8,
"base_hp": 60,
Expand Down Expand Up @@ -350,7 +346,6 @@
"limb_scores": [ [ "breathing", 1.0 ], [ "manip", 0.05, 0.2 ] ],
"side": "both",
"legacy_id": "MOUTH",
"grabbing_effect": "grabbing_mouth",
"stylish_bonus": 2,
"hot_morale_mod": 2,
"cold_morale_mod": 2,
Expand Down Expand Up @@ -387,7 +382,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "lift", 0.5 ], [ "balance", 0.15 ], [ "block", 1.0 ], [ "swim", 0.1 ], [ "crawl", 0.3 ] ],
"side": "left",
"legacy_id": "ARM_L",
"grabbing_effect": "grabbing_arm_l",
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
"fire_warmth_bonus": 600,
Expand Down Expand Up @@ -472,7 +466,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "lift", 0.5 ], [ "balance", 0.15 ], [ "block", 1.0 ], [ "swim", 0.1 ], [ "crawl", 0.3 ] ],
"side": "right",
"legacy_id": "ARM_R",
"grabbing_effect": "grabbing_arm_r",
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
"fire_warmth_bonus": 600,
Expand Down Expand Up @@ -554,7 +547,6 @@
"limb_scores": [ [ "grip", 0.5 ], [ "manip", 0.5, 1.0 ], [ "swim", 0.15 ] ],
"side": "left",
"legacy_id": "HAND_L",
"grabbing_effect": "grabbing_hand_l",
"stylish_bonus": 0.5,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -586,7 +578,6 @@
"limb_scores": [ [ "grip", 0.5 ], [ "manip", 0.5, 1.0 ], [ "swim", 0.15 ] ],
"side": "right",
"legacy_id": "HAND_R",
"grabbing_effect": "grabbing_hand_r",
"stylish_bonus": 0.5,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -621,7 +612,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "move_speed", 0.5 ], [ "swim", 0.15 ], [ "block", 1 ], [ "crawl", 0.2 ] ],
"side": "left",
"legacy_id": "LEG_L",
"grabbing_effect": "grabbing_leg_l",
"stylish_bonus": 1,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -715,7 +705,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "move_speed", 0.5 ], [ "swim", 0.15 ], [ "block", 1 ], [ "crawl", 0.2 ] ],
"side": "right",
"legacy_id": "LEG_R",
"grabbing_effect": "grabbing_leg_r",
"stylish_bonus": 1,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -807,7 +796,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "footing", 0.5 ], [ "swim", 0.1 ] ],
"side": "left",
"legacy_id": "FOOT_L",
"grabbing_effect": "grabbing_foot_l",
"stylish_bonus": 0.5,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -841,7 +829,6 @@
"limb_scores": [ [ "manip", 0.1, 0.2 ], [ "footing", 0.5 ], [ "swim", 0.1 ] ],
"side": "right",
"legacy_id": "FOOT_R",
"grabbing_effect": "grabbing_foot_r",
"stylish_bonus": 0.5,
"hot_morale_mod": 0.5,
"cold_morale_mod": 0.5,
Expand Down Expand Up @@ -878,7 +865,6 @@
"accusative": { "ctxt": "bodypart_accusative", "str": "debug tail" },
"hp_bar_ui_text": "DBG TAIL",
"base_hp": 20,
"grabbing_effect": "grabbing_tail",
"flags": [ "ALWAYS_BLOCK", "NONSTANDARD_BLOCK", "MEND_LIMB", "WALL_CLING" ],
"armor": { "bash": 10 },
"unarmed_damage": [ { "damage_type": "acid", "amount": 10 }, { "damage_type": "bullet", "amount": 5, "armor_penetration": 100 } ],
Expand Down
155 changes: 1 addition & 154 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,143 +305,6 @@
"desc": [ "AI tag used for robot monsters losing mechanical fluid. This is a bug if you have it." ],
"show_in_info": true
},
{
"type": "effect_type",
"id": "grabbing_head",
"name": [ "Grabbing Head" ],
"show_in_info": true,
"//": "Grab filter effect for dedicated removal, per-bptype",
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the head of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_eyes",
"name": [ "Grabbing Eyes" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You've caught the eye of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_mouth",
"name": [ "Grabbing Mouth" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the mouth of somebody. Somehow." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_torso",
"name": [ "Grabbing Torso" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're hugging somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_arm_l",
"name": [ "Grabbing Left Arm" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the left arm of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_arm_r",
"name": [ "Grabbing Right Arm" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the right arm of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_hand_l",
"name": [ "Grabbing Left Hand" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're holding hands(left)." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_hand_r",
"name": [ "Grabbing Right Hand" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're holding hands(right)." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_leg_l",
"name": [ "Grabbing Left Leg" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the left leg of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_leg_r",
"name": [ "Grabbing Right Leg" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the right leg of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_foot_l",
"name": [ "Grabbing Left Foot" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the left foot of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_foot_r",
"name": [ "Grabbing Right Foot" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the right foot of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_tail",
"name": [ "Grabbing Tail" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the tail of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_gastropod_foot",
"name": [ "Grabbing G. Foot" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"desc": [ "You're grabbing the snail like lower body of somebody." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "grabbing_appendix",
"name": [ "Grabbing" ],
"show_in_info": true,
"base_mods": { "dodge_mod": [ -8 ] },
"//": "Null-BP grabbing effect for safety and monsters",
"desc": [ "This sounds pretty invasive." ],
"flags": [ "GRAB_FILTER" ]
},
{
"type": "effect_type",
"id": "staggered",
Expand All @@ -451,23 +314,7 @@
"apply_message": "You're staggered off-balance.",
"max_duration": "5 s",
"base_mods": { "speed_mod": [ -20 ] },
"removes_effects": [
"grabbing",
"grabbing_2",
"grabbing_head",
"grabbing_eyes",
"grabbing_mouth",
"grabbing_hand_l",
"grabbing_hand_r",
"grabbing_arm_l",
"grabbing_arm_r",
"grabbing_leg_l",
"grabbing_leg_r",
"grabbing_foot_l",
"grabbing_foot_r",
"grabbing_appendix",
"grabbing_tail"
],
"removes_effects": [ "grabbing", "grabbing_2" ],
"rating": "bad",
"show_in_info": true
},
Expand Down
1 change: 0 additions & 1 deletion data/json/mutations/mutation_limbs.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"hit_size": 30,
"hit_difficulty": 1.2,
"side": "both",
"grabbing_effect": "grabbing_gastropod_foot",
"stylish_bonus": 3,
"hot_morale_mod": 2,
"cold_morale_mod": 2,
Expand Down
1 change: 0 additions & 1 deletion data/mods/Xedra_Evolved/body_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"limb_type": "sensor",
"limb_scores": [ [ "vision", 2.0 ], [ "night_vis", 12 ], [ "reaction", 1.4 ] ],
"side": "both",
"grabbing_effect": "grabbing_eyes",
"base_hp": 60,
"drench_capacity": 0,
"flags": [ "IGNORE_TEMP", "LIMB_UPPER" ],
Expand Down
3 changes: 0 additions & 3 deletions src/bodypart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const bodypart_str_id body_part_leg_r( "leg_r" );
const bodypart_str_id body_part_mouth( "mouth" );
const bodypart_str_id body_part_torso( "torso" );

static const efftype_id effect_grabbing_appendix( "grabbing_appendix" );

const sub_bodypart_str_id sub_body_part_sub_limb_debug( "sub_limb_debug" );

side opposite_side( side s )
Expand Down Expand Up @@ -404,7 +402,6 @@ void body_part_type::load( const JsonObject &jo, const std::string_view )

optional( jo, was_loaded, "flags", flags );
optional( jo, was_loaded, "conditional_flags", conditional_flags );
optional( jo, was_loaded, "grabbing_effect", grabbing_effect, effect_grabbing_appendix );

optional( jo, was_loaded, "encumbrance_threshold", encumbrance_threshold, 0 );
optional( jo, was_loaded, "encumbrance_limit", encumbrance_limit, 100 );
Expand Down
3 changes: 0 additions & 3 deletions src/bodypart.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ struct body_part_type {
// Effects to trigger on getting hit
std::vector<bp_onhit_effect> effects_on_hit;

// Monster effect added to mobs grabbing this limb (for dedicated removal)
efftype_id grabbing_effect;

// Those are stored untranslated
translation name;
translation name_multiple;
Expand Down
8 changes: 4 additions & 4 deletions src/character_escape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool Character::try_remove_grab( bool attacking )
monster *grabber = nullptr;
for( const tripoint loc : surrounding ) {
monster *mon = creatures.creature_at<monster>( loc );
if( mon && mon->has_effect( eff.get_bp()->grabbing_effect ) ) {
if( mon && mon->is_grabbing( eff.get_bp().id() ) ) {
add_msg_debug( debugmode::DF_MATTACK, "Grabber %s found", mon->name() );
grabber = mon;
break;
Expand Down Expand Up @@ -266,9 +266,9 @@ bool Character::try_remove_grab( bool attacking )
// Every attempt burns some stamina - maybe some moves?
mod_stamina( -5 * eff.get_intensity() );
if( x_in_y( escape_chance, grabber_roll ) ) {
grabber->remove_effect( eff.get_bp()->grabbing_effect );
add_msg_debug( debugmode::DF_MATTACK, "Removed grab filter effect %s from monster %s",
eff.get_bp()->grabbing_effect.c_str(), grabber->name() );
grabber->remove_grab( eff.get_bp().id() );
add_msg_debug( debugmode::DF_MATTACK, "Removed grab effect %s from monster %s",
eff.get_bp()->name, grabber->name() );

if( grab_break_factor > 0 ) {
add_msg_if_player( m_info, martial_arts_data->get_grab_break( *this ).avatar_message.translated(),
Expand Down
8 changes: 4 additions & 4 deletions src/mattack_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ int melee_actor::do_grab( monster &z, Creature *target, bodypart_id bp_id ) cons

if( grab_data.grab_effect != effect_null ) {
if( foe ) {
z.add_effect( bp_id->grabbing_effect, 1_days, true, 1 );
add_msg_debug( debugmode::DF_MATTACK, "Added grabbing filter effect %s",
bp_id->grabbing_effect.c_str() );
z.add_grab( bp_id.id() );
add_msg_debug( debugmode::DF_MATTACK, "Added grabbing on %s",
bp_id->name );
// Add grabbed - permanent, removal handled in try_remove_grab on move/wait
target->add_effect( grab_data.grab_effect, 1_days, bp_id, true, eff_grab_strength );
} else {
Expand Down Expand Up @@ -751,7 +751,7 @@ bool melee_actor::call( monster &z ) const
monster *mon = creatures.creature_at<monster>( loc );
if( mon && mon->has_effect_with_flag( json_flag_GRAB_FILTER ) && mon->attack_target() == target ) {
if( target->is_monster() || ( !target->is_monster() &&
mon->has_effect( eff.get_bp()->grabbing_effect ) ) ) {
mon->is_grabbing( eff.get_bp().id() ) ) ) {
grabber = mon;
break;
}
Expand Down
13 changes: 8 additions & 5 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,11 +1906,14 @@ void Character::perform_technique( const ma_technique &technique, Creature &t,
// Remove our grab if we knocked back our grabber (if we can do so is handled by tech conditions)
if( has_flag( json_flag_GRAB ) && t.has_effect_with_flag( json_flag_GRAB_FILTER ) ) {
for( const effect &eff : get_effects_with_flag( json_flag_GRAB ) ) {
if( t.has_effect( eff.get_bp()->grabbing_effect ) ) {
t.remove_effect( eff.get_bp()->grabbing_effect );
remove_effect( eff.get_id(), eff.get_bp() );
add_msg_debug( debugmode::DF_MELEE, "Grabber %s knocked back, grab on %s removed", t.get_name(),
eff.get_bp()->name );
if( t.is_monster() ) {
monster *m = t.as_monster();
if( m->is_grabbing( eff.get_bp().id() ) ) {
m->remove_grab( eff.get_bp().id() );
remove_effect( eff.get_id(), eff.get_bp() );
add_msg_debug( debugmode::DF_MELEE, "Grabber %s knocked back, grab on %s removed", t.get_name(),
eff.get_bp()->name );
}
}
}
}
Expand Down
Loading