rtsim: positive sentiment gain for killing enemies

As per the age old saying: "the enemy of my enemy is my friend".

NPCs will start liking the killer of their enemy more.
This commit is contained in:
Julian Tölle 2023-04-16 17:40:26 +02:00
parent b931b350fd
commit 865b50fff2
2 changed files with 18 additions and 4 deletions

View File

@ -258,6 +258,10 @@ npc-speech-witness_murder =
.a0 = Murderer!
.a1 = How could you do this?
.a2 = Aaargh!
npc-speech-witness_enemy_murder =
.a0 = My Hero!
.a1 = Finally someone did it!
.a2 = Yeaah!
npc-speech-witness_death =
.a0 = No!
.a1 = This is terrible!

View File

@ -958,8 +958,7 @@ fn check_inbox(ctx: &mut NpcCtx) -> Option<impl Action> {
Some(report_id) if !ctx.known_reports.contains(&report_id) => {
#[allow(clippy::single_match)]
match ctx.state.data().reports.get(report_id).map(|r| r.kind) {
Some(ReportKind::Death { killer, .. }) => {
// TODO: Sentiment should be positive if we didn't like actor that died
Some(ReportKind::Death { killer, actor, .. }) => {
// TODO: Don't report self
let phrase = if let Some(killer) = killer {
// TODO: For now, we don't make sentiment changes if the killer was an
@ -967,9 +966,20 @@ fn check_inbox(ctx: &mut NpcCtx) -> Option<impl Action> {
// This should be changed in the future.
if !matches!(killer, Actor::Npc(_)) {
// TODO: Don't hard-code sentiment change
ctx.sentiments.change_by(killer, -0.7, Sentiment::VILLAIN);
let mut change = -0.7;
if ctx.sentiments.toward(actor).is(Sentiment::ENEMY) {
// Like the killer if we have negative sentiment towards the
// killed.
change *= -1.0;
}
ctx.sentiments.change_by(killer, change, Sentiment::VILLAIN);
}
if ctx.sentiments.toward(actor).is(Sentiment::ENEMY) {
"npc-speech-witness_enemy_murder"
} else {
"npc-speech-witness_murder"
}
} else {
"npc-speech-witness_death"
};