Skip to content

Commit

Permalink
Merge pull request CleverRaven#76264 from RenechCDDA/Init_mon_baby_timer
Browse files Browse the repository at this point in the history
Initialize monster baby_timer for new monsters
  • Loading branch information
Maleclypse authored Nov 10, 2024
2 parents b4dc54d + 9c8c26c commit c4a19f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ monster::monster( const mtype_id &id ) : monster()
faction = type->default_faction;
upgrades = type->upgrades && ( type->half_life || type->age_grow );
reproduces = type->reproduces && type->baby_timer && !monster::has_flag( mon_flag_NO_BREED );
if( reproduces && type->baby_timer ) {
baby_timer.emplace( calendar::turn + *type->baby_timer );
}
biosignatures = type->biosignatures;
if( monster::has_flag( mon_flag_AQUATIC ) ) {
fish_population = dice( 1, 20 );
Expand Down Expand Up @@ -561,12 +564,6 @@ void monster::try_reproduce()
return;
}

if( !baby_timer && has_eaten_enough() ) {
// Assume this is a freshly spawned monster (because baby_timer is not set yet), set the point when it reproduce to somewhere in the future.
// Monsters need to have eaten eat to start their pregnancy timer, but that's all.
baby_timer.emplace( calendar::turn + *type->baby_timer );
}

bool season_spawn = false;
bool season_match = true;

Expand Down
2 changes: 2 additions & 0 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,8 @@ void monster::load( const JsonObject &data )
data.read( "baby_timer", baby_timer );
if( baby_timer && *baby_timer == calendar::before_time_starts ) {
baby_timer.reset();
} else if( reproduces && type->baby_timer && !baby_timer ) { // Remove after 0.I
baby_timer.emplace( calendar::turn + *type->baby_timer );
}

biosignatures = data.get_bool( "biosignatures", type->biosignatures );
Expand Down

0 comments on commit c4a19f1

Please sign in to comment.