# Overwriting NPC snippets

**URL:** <https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430>\
**Category:** The Toolbox\
**Created:** [December 17, 2021, 6:16pm UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430 "2021-12-17T18:16:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NetSysFire](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@NetSysFire](https://discourse.cataclysmdda.org/u/NetSysFire)\
**Post date:** [December 17, 2021, 6:16pm UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430/1 "2021-12-17T18:16:15Z")

</div>

I am working on a mod which replaces insults, `<name_b>` in `data/json/npc/talk_tags.json` completely so it only uses my custom set. So I created `modinfo.json` and put the following in in `talk_tags.json`:

```json
[
  {
    "type": "snippet",
    "category": "<name_b>",
    "//": "generic negative/hostile pronouns",
    "text": [
      "lutefisk",
      "protein ration",
      "wastebread"
    ]
  }
]

```

Yet when I create a new world and choose the mod I just created, which looks correct and all, and steal something from the refugee center, they still use the old insults, so it is probably appending those instead of completely overwriting the snippet.  
Is there a way to completely overwrite it? I tried to add the same category but make `"text"` an empty array but that did not seem to work either.

The purpose of that mod is to replace all the mean insults with some more humorous ones.

---

<div class="post-metadata">

**Author:** ![wwkk222208](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wwkk222208/32/11715_2.png) [@wwkk222208](https://discourse.cataclysmdda.org/u/wwkk222208)\
**Post date:** [December 21, 2021, 11:53am UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430/2 "2021-12-21T11:53:27Z")

</div>

I am planning to solve this problem in a PR. The general idea is to allow all snippets to have tags which can distinguish between insults and harmonious ones.

---

<div class="post-metadata">

**Author:** ![NetSysFire](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@NetSysFire](https://discourse.cataclysmdda.org/u/NetSysFire)\
**Post date:** [December 21, 2021, 3:19pm UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430/3 "2021-12-21T15:19:42Z")

</div>

I am already working on this small mod, but I fear that we can not overwrite or clear snippets and only append. Might be a technical limitation. It would be great if we could do this to just clear the snippet and replace it:

```json
[
  {
    "type": "snippet",
    "category": "<name_b>",
    "text": []
  },
  {
    "type": "snippet",
    "category": "<name_b>",
    "text": ["this is the only insult now"]
  }
]

```

If you could implement the above in a PR this would be absolutely great.

---

<div class="post-metadata">

**Author:** ![wwkk222208](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wwkk222208/32/11715_2.png) [@wwkk222208](https://discourse.cataclysmdda.org/u/wwkk222208)\
**Post date:** [December 23, 2021, 10:20am UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430/4 "2021-12-23T10:20:30Z")

</div>

What I want to do is to subdivide the types of snippets, not just to distinguish insults. This requires some C++ code changes.

---

<div class="post-metadata">

**Author:** ![wwkk222208](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wwkk222208/32/11715_2.png) [@wwkk222208](https://discourse.cataclysmdda.org/u/wwkk222208)\
**Post date:** [December 23, 2021, 10:42am UTC](https://discourse.cataclysmdda.org/t/overwriting-npc-snippets/27430/5 "2021-12-23T10:42:45Z")

</div>

This is the draft:

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/53706>
>
> \<!-- HOW TO USE: Under each "#### Heading" below, enter information relevant to …your pull request.
> Leave the headings unless they don't apply to your PR.
> 
> Please read carefully and don't delete the comments delimited by "\< !--" and "-- \>"
> Once a pull request is submitted automatic stylistic and consistency checks will be performed on the PR's changes.
> The results of these can be either seen under the "Files changed" section of a PR or in the check's details.
> 
> NOTE: Please grant permission for repository maintainers to edit your PR. It is EXTREMELY common for PRs to be held up due to trivial changes being requested and the author being unavailable to make them. --\>
> 
> \#### Summary
> None
> \<!-- This section should consist of exactly one line, edit the one above.
> Category must be one of these: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N. Or replace the whole line with just the word None for no changelog entry.
> For more on the meaning of each category, see:
> https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG\_GUIDELINES.md
> If approved and merged, your summary will be added to the project changelog:
> https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt --\>
> 
> \#### Purpose of change
> The npc snippets in the current game are very rigid, because they are always randomly selected and not related to the character of NPCs. Players will find that NPCs quickly switch between being polite and rude.
> \<!-- With a few sentences, describe your reasons for making this change. If it relates to an existing issue, you can link it with a # followed by the GitHub issue number, like #1234. If your pull request \*fully\* resolves an issue, include the word "Fix" or "Fixes" before the issue number, like: Fixes #1234.
> If there is no related issue, explain here what issue, feature, or other concern you are addressing. If this is a bugfix, include steps to reproduce the original bug, so your fix can be verified. --\>
> 
> \#### Describe the solution
> 
> \- \[x\] Change the data storage format of snippets.
> 
> \- \[\] Make flags of ssnippets loadable.
> 
> \- \[\] Make snippets with specific flags can be filtered out when randomly selecting snippets, according to the personality and attitude to the player of NPCs.
> 
> \- \[\] Add flags to insults in json.
> 
> 
> 
> \#### Describe alternatives you've considered
> 
> 
> 
> \#### Testing
> 
> 
> 
> \#### Additional context
