Skip to content

Commit 5570e0a

Browse files
authored
revert kill_xp updates removal to preserve functionality of in-repo mods (#82882)
* revert kill_xp updates removal to preserve functionality of in-repo mods * actually capture the killer pointer * re-add savegame serialization for kill_xp
2 parents 8a37783 + fd45e59 commit 5570e0a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/kill_tracker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ static Character *get_avatar_or_follower( const character_id &id )
104104
return nullptr;
105105
}
106106

107+
// Legacy value, maintained until kill_xp rework/removal from dependent in-repo mods
108+
static constexpr int npc_kill_xp = 10;
109+
107110
void kill_tracker::notify( const cata::event &e )
108111
{
109112
switch( e.type() ) {
@@ -112,16 +115,20 @@ void kill_tracker::notify( const cata::event &e )
112115
if( Character *killer = get_avatar_or_follower( killer_id ) ) {
113116
const mtype_id victim_type = e.get<mtype_id>( "victim_type" );
114117
kills[victim_type]++;
118+
// Legacy value update, maintained until kill_xp rework/removal from dependent in-repo mods
119+
killer->kill_xp += e.get<int>( "exp" );
115120
victim_type.obj().families.practice_kill( *killer );
116121
}
117122
break;
118123
}
119124
case event_type::character_kills_character: {
120125
const character_id killer_id = e.get<character_id>( "killer" );
121126
// player is credited for NPC kills they or their followers make
122-
if( get_avatar_or_follower( killer_id ) ) {
127+
if( Character *killer = get_avatar_or_follower( killer_id ) ) {
123128
const std::string victim_name = e.get<cata_variant_type::string>( "victim_name" );
124129
npc_kills.push_back( victim_name );
130+
// Legacy value update, maintained until kill_xp rework/removal from dependent in-repo mods
131+
killer->kill_xp += npc_kill_xp;
125132
}
126133
break;
127134
}

src/savegame_json.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,9 @@ void Character::load( const JsonObject &data )
777777
data.read( "stim", stim );
778778
data.read( "stamina", stamina );
779779

780+
//legacy value, maintained until kill_xp dependency removed from in-repo mods
781+
data.read( "kill_xp", kill_xp );
782+
780783
data.read( "moncams", moncams );
781784

782785
data.read( "magic", magic );
@@ -1411,6 +1414,9 @@ void Character::store( JsonOut &json ) const
14111414
json.member( "type_of_scent", type_of_scent );
14121415
json.member( "focus_pool", focus_pool );
14131416

1417+
//legacy value, maintained until kill_xp dependency removed from in-repo mods
1418+
json.member( "kill_xp", kill_xp );
1419+
14141420
// breathing
14151421
json.member( "underwater", underwater );
14161422
json.member( "oxygen", oxygen );

0 commit comments

Comments
 (0)