Skip to content

Commit

Permalink
feat: eggs from friendly wildlife critters spawn friendly offspring (c…
Browse files Browse the repository at this point in the history
…ataclysmbnteam#4289)

It's tedious to require the player to keep taming offspring of the
animals they have already tamed in the first place so this change
addresses that, especially for chickens who multiply aggressively!
Mostly meant as QoL change for farm players.
  • Loading branch information
ekaratzas authored Mar 4, 2024
1 parent 261705f commit 95816f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@
"context": [ "GENERIC", "TOOL" ],
"info": "As a weapon, this item needs considerable space to use properly and does 70% of its normal damage to adjacent enemies."
},
{
"id": "SPAWN_FRIENDLY",
"type": "json_flag",
"context": [ "GENERIC" ],
"//": "This item will spawn friendly. Used for pets and such."
},
{
"id": "STAB",
"type": "json_flag",
Expand Down
1 change: 1 addition & 0 deletions src/flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ const flag_id flag_SMOKABLE( "SMOKABLE" );
const flag_id flag_SMOKED( "SMOKED" );
const flag_id flag_SOLARPACK( "SOLARPACK" );
const flag_id flag_SOLARPACK_ON( "SOLARPACK_ON" );
const flag_id flag_SPAWN_FRIENDLY( "SPAWN_FRIENDLY" );
const flag_id flag_SPEAR( "SPEAR" );
const flag_id flag_SPEEDLOADER( "SPEEDLOADER" );
const flag_id flag_SPLINT( "SPLINT" );
Expand Down
1 change: 1 addition & 0 deletions src/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ extern const flag_id flag_SMOKABLE;
extern const flag_id flag_SMOKED;
extern const flag_id flag_SOLARPACK;
extern const flag_id flag_SOLARPACK_ON;
extern const flag_id flag_SPAWN_FRIENDLY;
extern const flag_id flag_SPEAR;
extern const flag_id flag_SPEEDLOADER;
extern const flag_id flag_SPLINT;
Expand Down
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7320,7 +7320,7 @@ void map::rotten_item_spawn( const item &item, const tripoint &pnt )
get_option<float>( "CARRION_SPAWNRATE" ) );
if( rng( 0, 100 ) < chance ) {
MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup( mgroup );
add_spawn( spawn_details.name, 1, pnt, false );
add_spawn( spawn_details.name, 1, pnt, item.has_own_flag( flag_SPAWN_FRIENDLY ) );
if( g->u.sees( pnt ) ) {
if( item.is_seed() ) {
add_msg( m_warning, _( "Something has crawled out of the %s plants!" ), item.get_plant_name() );
Expand Down
7 changes: 6 additions & 1 deletion src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "event.h"
#include "explosion.h"
#include "field_type.h"
#include "flag.h"
#include "flat_set.h"
#include "game_constants.h"
#include "game.h"
Expand Down Expand Up @@ -516,7 +517,11 @@ void monster::try_reproduce()
if( type->baby_monster ) {
g->m.add_spawn( type->baby_monster, spawn_cnt, pos(), friendly_parent );
} else {
g->m.add_item_or_charges( pos(), item::spawn( type->baby_egg, *baby_timer, spawn_cnt ), true );
detached_ptr<item> item_to_spawn = item::spawn( type->baby_egg, *baby_timer, spawn_cnt );
if( friendly_parent ) {
item_to_spawn->set_flag( flag_SPAWN_FRIENDLY );
}
g->m.add_item_or_charges( pos(), std::move( item_to_spawn ), true );
}
}

Expand Down

0 comments on commit 95816f2

Please sign in to comment.