Skip to content

Commit

Permalink
fix: add limits and side effects to ABSORBS_SPLITS behavior (#4249)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt authored Mar 1, 2024
1 parent 6d088c8 commit e6c0196
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 9 additions & 0 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@
"name": [ "Pushed" ],
"desc": [ "AI tag used for monsters pushing each other. This is a bug if you have it." ]
},
{
"type": "effect_type",
"id": "mon_mitosis",
"name": [ "Recently Split" ],
"desc": [
"AI tag for ABSORBS_SPLITS monsters having recently divided, forcing a cooldown between splits. This is a bug if you have it."
],
"max_duration": "1 m"
},
{
"//": "ACTUAL PLAYER EFFECTS START HERE",
"type": "effect_type",
Expand Down
2 changes: 1 addition & 1 deletion data/json/monsters/nether.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@
"special_attacks": [ [ "PARROT", 40 ] ],
"death_function": [ "MELT" ],
"regenerates": 50,
"regeneration_modifiers": [ { "effect": "onfire", "base_mod": -0.3, "scaling_mod": -0.15 } ],
"regeneration_modifiers": [ { "effect": "onfire", "base_mod": -0.3, "scaling_mod": -0.15 }, { "effect": "mon_mitosis", "base_mod": -1.0 } ],
"regen_morale": true,
"flags": [ "SEES", "SMELLS", "SWIMS", "PLASTIC", "SLUDGEPROOF", "ACID_BLOOD", "ACIDPROOF", "NOHEAD", "ABSORBS_SPLITS", "NOGIB" ]
},
Expand Down
12 changes: 10 additions & 2 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static const efftype_id effect_downed( "downed" );
static const efftype_id effect_dragging( "dragging" );
static const efftype_id effect_grabbed( "grabbed" );
static const efftype_id effect_harnessed( "harnessed" );
static const efftype_id effect_mon_mitosis( "mon_mitosis" );
static const efftype_id effect_no_sight( "no_sight" );
static const efftype_id effect_operating( "operating" );
static const efftype_id effect_pacified( "pacified" );
Expand Down Expand Up @@ -701,21 +702,28 @@ void monster::move()
//The monster can consume objects it stands on. Check if there are any.
//If there are. Consume them.
// TODO: Stick this in a map and dispatch to it via the action string.
if( action == "consume_items" ) {
if( action == "consume_items" && ( !has_effect( effect_mon_mitosis ) || hp < type->hp * 3 ) ) {
// Eat items unless we're both recently split AND binged too hard afterwards
if( g->u.sees( *this ) ) {
add_msg( _( "The %s flows around the objects on the floor and they are quickly dissolved!" ),
name() );
}
static const auto volume_per_hp = 250_ml;
for( auto &elem : g->m.i_at( pos() ) ) {
hp += elem->volume() / volume_per_hp; // Yeah this means it can get more HP than normal.
if( has_flag( MF_ABSORBS_SPLITS ) ) {
// Don't split if we're still recovering from last time
if( has_flag( MF_ABSORBS_SPLITS ) && !has_effect( effect_mon_mitosis ) ) {
while( hp / 2 > type->hp ) {
monster *const spawn = g->place_critter_around( type->id, pos(), 1 );
if( !spawn ) {
break;
}
// Splitting takes a bit out of both
hp -= type->hp;
hp *= 0.75;
add_effect( effect_mon_mitosis, 1_minutes );
spawn->hp *= 0.75;
spawn->add_effect( effect_mon_mitosis, 1_minutes );
//this is a new copy of the monster. Ideally we should copy the stats/effects that affect the parent
spawn->make_ally( *this );
if( g->u.sees( *this ) ) {
Expand Down

0 comments on commit e6c0196

Please sign in to comment.