From 865b50fff2d7b6b605fbd76464d6534ea93e9ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Sun, 16 Apr 2023 17:40:26 +0200 Subject: [PATCH] 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. --- assets/voxygen/i18n/en/npc.ftl | 4 ++++ rtsim/src/rule/npc_ai.rs | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/assets/voxygen/i18n/en/npc.ftl b/assets/voxygen/i18n/en/npc.ftl index 9f6025afa4..071f93a284 100644 --- a/assets/voxygen/i18n/en/npc.ftl +++ b/assets/voxygen/i18n/en/npc.ftl @@ -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! diff --git a/rtsim/src/rule/npc_ai.rs b/rtsim/src/rule/npc_ai.rs index cf24019378..45815c6a0c 100644 --- a/rtsim/src/rule/npc_ai.rs +++ b/rtsim/src/rule/npc_ai.rs @@ -958,8 +958,7 @@ fn check_inbox(ctx: &mut NpcCtx) -> Option { 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 { // 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" } - "npc-speech-witness_murder" } else { "npc-speech-witness_death" };