/// </summary>
[DataField("wordReplacements")]
public Dictionary<string, string>? WordReplacements;
+
+ /// <summary>
+ /// Allows you to substitute words, not always, but with some chance
+ /// </summary>
+ [DataField]
+ public float ReplacementChance = 1f;
}
/// <summary>
[DataField("accent", customTypeSerializer: typeof(PrototypeIdSerializer<ReplacementAccentPrototype>), required: true)]
public string Accent = default!;
- /// <summary>
- /// Allows you to substitute words, not always, but with some chance
- /// </summary>
- [DataField]
- public float ReplacementChance = 1f;
}
}
private void OnAccent(EntityUid uid, ReplacementAccentComponent component, AccentGetEvent args)
{
- if (!_random.Prob(component.ReplacementChance))
- return;
-
args.Message = ApplyReplacements(args.Message, component.Accent);
}
if (!_proto.TryIndex<ReplacementAccentPrototype>(accent, out var prototype))
return message;
+ if (!_random.Prob(prototype.ReplacementChance))
+ return message;
+
// Prioritize fully replacing if that exists--
// ideally both aren't used at the same time (but we don't have a way to enforce that in serialization yet)
if (prototype.FullReplacements != null)
- type: accent
id: liar
+ replacementChance: 0.15
wordReplacements:
liar-word-1: liar-word-replacement-1
liar-word-2: liar-word-replacement-2
liar-word-39: liar-word-replacement-39
liar-word-40: liar-word-replacement-40
liar-word-41: liar-word-replacement-41
- liar-word-42: liar-word-replacement-42
\ No newline at end of file
+ liar-word-42: liar-word-replacement-42
-- type: trait
+- type: trait
id: PirateAccent
name: trait-pirate-accent-name
description: trait-pirate-accent-desc
description: trait-liar-desc
components:
- type: ReplacementAccent
- replacementChance: 0.15
accent: liar