More Specific NPC Dialogs

This commit is contained in:
Thomas S 2024-03-13 22:32:02 +00:00 committed by Isse
parent 1a433f0ba4
commit 9a922016ea
2 changed files with 31 additions and 4 deletions

View File

@ -16,7 +16,6 @@ npc-speech-villager_adventurous =
.a1 = I'd like to go spelunking in a cave when I'm stronger.
npc-speech-villager_closed =
.a0 = You're not from around here are you?
.a1 = Don't you think our village is the best?
.a2 = They say mushrooms are good for your health. Never eat them myself.
.a3 = To be, or not to be? I think I'll be a farmer.
npc-speech-villager_conscientious =
@ -264,6 +263,11 @@ npc-speech-tell_site =
.a2 = If you travel { $dist } { $dir }, you can get to { $site }.
.a3 = { $dir } you'll find { $site }, it's { $dist }.
npc-speech-site =
.a0 = Don't you think our village is the best?
.a1 = Welcome to { $site } !
.a2 = { $site } is a pleasant village to live in.
## NPC monster hints
## Available variables:
## - $dir references npc-speech-dir-* variables below
@ -315,3 +319,7 @@ npc-speech-welcome-aboard =
.a0 = Welcome aboard!
.a1 = Can I see your ticket... just kidding it's free!
.a2 = Have a nice ride!
npc-speech-night =
.a0 = Lanterns are handy for getting around at night!
.a1 = I hope we are alone in the dark...
.a2 = Boo!

View File

@ -22,7 +22,7 @@ use common::{
Content,
},
path::Path,
rtsim::{Actor, ChunkResource, NpcInput, Profession, Role, SiteId},
rtsim::{Actor, ChunkResource, NpcInput, PersonalityTrait, Profession, Role, SiteId},
spiral::Spiral2d,
store::Id,
terrain::{CoordinateConversions, TerrainChunkSize},
@ -613,6 +613,19 @@ fn talk_to<S: State>(tgt: Actor, _subject: Option<Subject>) -> impl Action<S> +
.localize_npc(),
),
])
// Mention current site
} else if ctx.rng.gen_bool(0.3)
&& let Some(current_site) = ctx.npc.current_site
&& let Some(current_site) = ctx.state.data().sites.get(current_site)
&& let Some(current_site_name) = current_site
.world_site
.map(|ws| ctx.index.sites.get(ws).name().to_string())
{
Content::localized_with_args("npc-speech-site", [(
"site",
Content::Plain(current_site_name),
)])
// Mention nearby monsters
} else if ctx.rng.gen_bool(0.3)
&& let Some(monster) = ctx
@ -635,6 +648,9 @@ fn talk_to<S: State>(tgt: Actor, _subject: Option<Subject>) -> impl Action<S> +
.localize_npc(),
),
])
// Specific night dialog
} else if ctx.rng.gen_bool(0.6) && DayPeriod::from(ctx.time_of_day.0).is_dark() {
Content::localized("npc-speech-night")
} else {
ctx.npc.personality.get_generic_comment(&mut ctx.rng)
};
@ -656,7 +672,10 @@ fn talk_to<S: State>(tgt: Actor, _subject: Option<Subject>) -> impl Action<S> +
fn socialize() -> impl Action<EveryRange> + Clone {
now(move |ctx, socialize: &mut EveryRange| {
// Skip most socialising actions if we're not loaded
if matches!(ctx.npc.mode, SimulationMode::Loaded) && socialize.should(ctx) {
if matches!(ctx.npc.mode, SimulationMode::Loaded)
&& socialize.should(ctx)
&& !ctx.npc.personality.is(PersonalityTrait::Introverted)
{
// Sometimes dance
if ctx.rng.gen_bool(0.15) {
return just(|ctx, _| ctx.controller.do_dance(None))
@ -874,7 +893,7 @@ fn villager(visiting_site: SiteId) -> impl Action<DefaultState> {
}
// Go do something fun on evenings and holidays, or on random days.
else if
// Ain't no rest for the wicked
// Ain't no rest for the wicked
!matches!(ctx.npc.profession(), Some(Profession::Guard))
&& (matches!(day_period, DayPeriod::Evening) || is_weekend || ctx.rng.gen_bool(0.05)) {
let mut fun_stuff = Vec::new();