Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add <u_name> and <npc_name> to tag parsing. Update docs for others #56066

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions doc/NPCs.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,15 @@ Field | Default messages/snippets | Used for...

### Special Custom Entries

Certain entries like the snippets above are taken from the game state as opposed to JSON they are found in the npctalk function parse_tags. They are as follows:
`<yrwp>` | displays avatars wielded item
`<ammo>` | displays avatars ammo
Certain entries like the snippets above are taken from the game state as opposed to JSON; they are found in the npctalk function parse_tags. They are as follows:
`<yrwp>` | displays avatar's wielded item
`<mywp>` | displays npc's wielded item
`<u_name>` | displays avatar's name
`<npc_name>` | displays npc's name
`<ammo>` | displays avatar's ammo
`<current_activity>` | displays npc's current activity
`<punc>` | displays a random punctuation from: `.`, `…`, `!`
`<mypronoun>` | displays npc's pronoun
`<topic_item>` | referenced item
`<topic_item_price>` | referenced item unit price
`<topic_item_my_total_price>` | TODO Add
Expand Down
4 changes: 4 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,10 @@ void parse_tags( std::string &phrase, const Character &u, const Character &me,
} else {
phrase.replace( fa, l, remove_color_tags( me_weapon.tname() ) );
}
} else if( tag == "<u_name>" ) {
phrase.replace( fa, l, u.get_name() );
} else if( tag == "<npc_name>" ) {
phrase.replace( fa, l, me.get_name() );
} else if( tag == "<ammo>" ) {
if( !me_weapon.is_gun() ) {
phrase.replace( fa, l, _( "BADAMMO" ) );
Expand Down