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

Refine the yell (C) menu for interactions with NPCs and follower orders #30358

Merged
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
76 changes: 43 additions & 33 deletions data/json/npcs/TALK_COMMON_ALLY.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
},
{
"and": [
{ "npc_override": "avoid_combat", "yes": " OVERRIDE: ", "no": " " },
{ "npc_override": "follow_close", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "avoid_combat",
"yes": "<mypronoun> will follow you instead of fighting.",
"no": "<mypronoun> will fight instead of following you."
"npc_rule": "follow_close",
"yes": "<ally_rule_follow_close_true_text>",
"no": "<ally_rule_follow_close_false_text>"
}
]
},
Expand All @@ -172,12 +172,12 @@
{ "npc_override": "use_silent", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "use_silent",
"yes": "<mypronoun> will use silenced ranged weapons.",
"no": "<mypronoun> will use ranged weapons."
"yes": "<ally_rule_use_silent_true_text>",
"no": "<ally_rule_use_guns_true_text>"
}
]
},
"no": "<mypronoun> will not use ranged weapons."
"no": "<ally_rule_use_guns_false_text>"
}
]
},
Expand All @@ -186,8 +186,8 @@
{ "npc_override": "use_grenades", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "use_grenades",
"yes": "<mypronoun> will use grenades.",
"no": "<mypronoun> will not use grenades."
"yes": "<ally_rule_use_grenades_true_text>",
"no": "<ally_rule_use_grenades_false_text>"
}
]
},
Expand All @@ -196,8 +196,8 @@
{ "npc_override": "avoid_friendly_fire", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "avoid_friendly_fire",
"yes": "<mypronoun> will avoid shooting if allies are in the line of fire.",
"no": "<mypronoun> will shoot even if allies are in the line of fire."
"yes": "<ally_rule_avoid_friendly_fire_true_text>",
"no": "<ally_rule_avoid_friendly_fire_false_text>"
}
]
},
Expand All @@ -206,8 +206,8 @@
{ "npc_override": "hold_the_line", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "hold_the_line",
"yes": "<mypronoun> will hold the line by not moving into doorways or obstructions adjacent to you.",
"no": "<mypronoun> will move freely to attack enemies."
"yes": "<ally_rule_hold_the_line_true_text>",
"no": "<ally_rule_hold_the_line_false_text>"
}
]
},
Expand All @@ -219,12 +219,12 @@
{ "text": "Change your aiming rules...", "topic": "TALK_AIM_RULES" },
{
"truefalsetext": {
"condition": { "npc_rule": "avoid_combat" },
"true": "Stand and fight.",
"false": "If you see me running away, you follow me."
"condition": { "npc_rule": "follow_close" },
"true": "Move freely as you need to.",
"false": "Stick close to me, no matter what."
},
"topic": "TALK_COMBAT_COMMANDS",
"effect": { "toggle_npc_rule": "avoid_combat" }
"effect": { "toggle_npc_rule": "follow_close" }
},
{
"truefalsetext": {
Expand Down Expand Up @@ -405,8 +405,8 @@
{ "npc_override": "allow_pick_up", "yes": "OVERRIDE: " },
{
"npc_rule": "allow_pick_up",
"yes": { "has_pickup_list": "* will pick up items from the whitelist.", "no": "* will pick up all items." },
"no": "* will not pick up items."
"yes": { "has_pickup_list": "<ally_rule_allow_pick_up_true_list_text>", "no": "<ally_rule_allow_pick_up_true_text>" },
"no": "<ally_rule_allow_pick_up_false_text>"
}
]
},
Expand All @@ -415,8 +415,8 @@
{ "npc_override": "allow_bash", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "allow_bash",
"yes": "<mypronoun> will bash down obstacles.",
"no": "<mypronoun> will not bash down obstacles."
"yes": "<ally_rule_allow_bash_true_text>",
"no": "<ally_rule_allow_bash_false_text>"
}
]
},
Expand All @@ -425,8 +425,8 @@
{ "npc_override": "allow_sleep", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "allow_sleep",
"yes": "<mypronoun> will sleep when tired.",
"no": "<mypronoun> will sleep only when exhausted."
"yes": "<ally_rule_allow_sleep_true_text>",
"no": "<ally_rule_allow_sleep_false_text>"
}
]
},
Expand All @@ -435,8 +435,8 @@
{ "npc_override": "allow_complain", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "allow_complain",
"yes": "<mypronoun> will complain about wounds and needs.",
"no": "<mypronoun> will only complain in an emergency."
"yes": "<ally_rule_allow_complain_true_text>",
"no": "<ally_rule_allow_complain_false_text>"
}
]
},
Expand All @@ -445,8 +445,8 @@
{ "npc_override": "allow_pulp", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "allow_pulp",
"yes": "<mypronoun> will smash nearby zombie corpses.",
"no": "<mypronoun> will leave zombie corpses intact."
"yes": "<ally_rule_allow_pulp_true_text>",
"no": "<ally_rule_allow_pulp_false_text>"
}
]
},
Expand All @@ -455,8 +455,8 @@
{ "npc_override": "close_doors", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "close_doors",
"yes": "<mypronoun> will close doors behind themselves.",
"no": "<mypronoun> will leave doors open."
"yes": "<ally_rule_close_doors_true_text>",
"no": "<ally_rule_close_doors_false_text>"
}
]
},
Expand All @@ -465,8 +465,8 @@
{ "npc_override": "ignore_noise", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "ignore_noise",
"yes": "<mypronoun> will not investigate noises.",
"no": "<mypronoun> will investigate noises coming from unseen places."
"yes": "<ally_rule_ignore_noise_true_text>",
"no": "<ally_rule_ignore_noise_false_text>"
}
]
},
Expand All @@ -475,8 +475,18 @@
{ "npc_override": "avoid_doors", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "avoid_doors",
"yes": "<mypronoun> will not go places that require opening a door.",
"no": "<mypronoun> will open doors to reach a destination."
"yes": "<ally_rule_avoid_doors_true_text>",
"no": "<ally_rule_avoid_doors_false_text>"
}
]
},
{
"and": [
{ "npc_override": "forbid_engage", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "forbid_engage",
"yes": "<ally_rule_forbid_engage_true_text>",
"no": "<ally_rule_forbid_engage_false_text>"
}
]
}
Expand Down
155 changes: 155 additions & 0 deletions data/json/npcs/talk_tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,5 +994,160 @@
"type": "snippet",
"category": "<granny_name_g>",
"text": [ "child", "my child", "dear", "my dear", "friend", "survivor" ]
},
{
"type": "snippet",
"category": "<ally_rule_use_guns_true_text>",
"text": "<mypronoun> will use ranged weapons."
},
{
"type": "snippet",
"category": "<ally_rule_use_guns_false_text>",
"text": "<mypronoun> will not use ranged weapons."
},
{
"type": "snippet",
"category": "<ally_rule_use_grenades_true_text>",
"text": "<mypronoun> will use grenades."
},
{
"type": "snippet",
"category": "<ally_rule_use_grenades_false_text>",
"text": "<mypronoun> will not use grenades."
},
{
"type": "snippet",
"category": "<ally_rule_use_silent_true_text>",
"text": "<mypronoun> will only use silenced ranged weapons."
},
{
"type": "snippet",
"category": "<ally_rule_use_silent_false_text>",
"text": "<mypronoun> will use any ranged weapons."
},
{
"type": "snippet",
"category": "<ally_rule_avoid_friendly_fire_true_text>",
"text": "<mypronoun> will avoid shooting if allies are in the line of fire."
},
{
"type": "snippet",
"category": "<ally_rule_avoid_friendly_fire_false_text>",
"text": "<mypronoun> will shoot even if allies are in the line of fire."
},
{
"type": "snippet",
"category": "<ally_rule_allow_pick_up_true_text>",
"text": "* will pick up items."
},
{
"type": "snippet",
"category": "<ally_rule_allow_pick_up_true_list_text>",
"text": "* will only pick up items from the whitelist."
},
{
"type": "snippet",
"category": "<ally_rule_allow_pick_up_false_text>",
"text": "* will not pick up items."
},
{
"type": "snippet",
"category": "<ally_rule_allow_bash_true_text>",
"text": "<mypronoun> will bash down obstacles."
},
{
"type": "snippet",
"category": "<ally_rule_allow_bash_false_text>",
"text": "<mypronoun> will not bash down obstacles."
},
{
"type": "snippet",
"category": "<ally_rule_allow_sleep_true_text>",
"text": "<mypronoun> will sleep when tired."
},
{
"type": "snippet",
"category": "<ally_rule_allow_sleep_false_text>",
"text": "<mypronoun> will stay awake as long as possible."
},
{
"type": "snippet",
"category": "<ally_rule_allow_complain_true_text>",
"text": "<mypronoun> will complain about wounds and needs."
},
{
"type": "snippet",
"category": "<ally_rule_allow_complain_false_text>",
"text": "<mypronoun> will only complain in an emergency."
},
{
"type": "snippet",
"category": "<ally_rule_allow_pulp_true_text>",
"text": "<mypronoun> will smash nearby zombie corpses."
},
{
"type": "snippet",
"category": "<ally_rule_allow_pulp_false_text>",
"text": "<mypronoun> will leave zombie corpses intact."
},
{
"type": "snippet",
"category": "<ally_rule_close_doors_true_text>",
"text": "<mypronoun> will close doors after passing through."
},
{
"type": "snippet",
"category": "<ally_rule_close_doors_false_text>",
"text": "<mypronoun> will not close doors."
},
{
"type": "snippet",
"category": "<ally_rule_follow_close_true_text>",
"text": "<mypronoun> will follow you closely even when threatened."
},
{
"type": "snippet",
"category": "<ally_rule_follow_close_false_text>",
"text": "<mypronoun> will move freely as needed."
},
{
"type": "snippet",
"category": "<ally_rule_avoid_doors_true_text>",
"text": "<mypronoun> will not go places that require opening a door."
},
{
"type": "snippet",
"category": "<ally_rule_avoid_doors_false_text>",
"text": "<mypronoun> will open doors to reach a destination."
},
{
"type": "snippet",
"category": "<ally_rule_hold_the_line_true_text>",
"text": "<mypronoun> will hold the line by not moving into doorways or obstructions adjacent to you."
},
{
"type": "snippet",
"category": "<ally_rule_hold_the_line_false_text>",
"text": "<mypronoun> will move freely to attack enemies."
},
{
"type": "snippet",
"category": "<ally_rule_ignore_noise_true_text>",
"text": "<mypronoun> will not investigate noises."
},
{
"type": "snippet",
"category": "<ally_rule_ignore_noise_false_text>",
"text": "<mypronoun> will investigate noises from unseen places."
},
{
"type": "snippet",
"category": "<ally_rule_forbid_engage_true_text>",
"text": "<mypronoun> will not engage enemies if avoidable."
},
{
"type": "snippet",
"category": "<ally_rule_forbid_engage_false_text>",
"text": "<mypronoun> will follow normal engagement rules."
}
]
26 changes: 23 additions & 3 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2600,10 +2600,11 @@ npc_follower_rules::npc_follower_rules()
set_flag( ally_rule::allow_complain );
set_flag( ally_rule::allow_pulp );
clear_flag( ally_rule::close_doors );
clear_flag( ally_rule::avoid_combat );
clear_flag( ally_rule::follow_close );
clear_flag( ally_rule::avoid_doors );
clear_flag( ally_rule::hold_the_line );
clear_flag( ally_rule::ignore_noise );
clear_flag( ally_rule::forbid_engage );
}

bool npc_follower_rules::has_flag( ally_rule test, bool check_override ) const
Expand Down Expand Up @@ -2639,6 +2640,25 @@ void npc_follower_rules::toggle_flag( ally_rule toggle )
}
}

void npc_follower_rules::set_specific_override_state( ally_rule rule, bool state )
{
if( state ) {
set_override( rule );
} else {
clear_override( rule );
}
enable_override( rule );
}

void npc_follower_rules::toggle_specific_override_state( ally_rule rule, bool state )
{
if( has_override_enable( rule ) && has_override( rule ) == state ) {
clear_override( rule );
disable_override( rule );
} else {
set_specific_override_state( rule, state );
}
}

bool npc::is_hallucination() const
{
Expand Down Expand Up @@ -2682,10 +2702,10 @@ void npc_follower_rules::set_danger_overrides()
{
overrides = ally_rule::DEFAULT;
override_enable = ally_rule::DEFAULT;
set_override( ally_rule::avoid_combat );
set_override( ally_rule::follow_close );
set_override( ally_rule::avoid_doors );
set_override( ally_rule::hold_the_line );
enable_override( ally_rule::avoid_combat );
enable_override( ally_rule::follow_close );
enable_override( ally_rule::allow_sleep );
enable_override( ally_rule::close_doors );
enable_override( ally_rule::avoid_doors );
Expand Down
Loading