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

Migrate NPC rules to a new, dedicated imgui menu #74359

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
613 changes: 1 addition & 612 deletions data/json/npcs/common_chat/TALK_COMMON_ALLY.json

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions data/json/npcs/talk_tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,114 @@
"it's a million miles away!"
]
},
{
"type": "snippet",
"category": "<ally_rule_cbm_recharge_all_text>",
"text": "<mypronoun> will recharge power CBMs until <mypronoun> has 90% of total power."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_recharge_most_text>",
"text": "<mypronoun> will recharge power CBMs until <mypronoun> has 75% of total power."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_recharge_some_text>",
"text": "<mypronoun> will recharge power CBMs until <mypronoun> has 50% of total power."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_recharge_little_text>",
"text": "<mypronoun> will recharge power CBMs until <mypronoun> has 25% of total power."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_recharge_none_text>",
"text": "<mypronoun> will recharge power CBMs until <mypronoun> has 10% of total power."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_reserve_all_text>",
"text": "<mypronoun> will reserve 100% of CBM power for defense or utility CBMs."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_reserve_most_text>",
"text": "<mypronoun> will reserve 75% of CBM power for defense or utility CBMs."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_reserve_some_text>",
"text": "<mypronoun> will reserve 50% of CBM power for defense or utility CBMs."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_reserve_little_text>",
"text": "<mypronoun> will reserve 25% of CBM power for defense or utility CBMs."
},
{
"type": "snippet",
"category": "<ally_rule_cbm_reserve_none_text>",
"text": "<mypronoun> will not reserve any power for defense or utility CBMs."
},
{
"type": "snippet",
"category": "<ally_rule_aim_when_convenient>",
"text": "<mypronoun> will aim when it's convenient."
},
{
"type": "snippet",
"category": "<ally_rule_aim_spray>",
"text": "<mypronoun> will not bother to aim at all."
},
{
"type": "snippet",
"category": "<ally_rule_aim_precise>",
"text": "<mypronoun> will take time and aim carefully."
},
{
"type": "snippet",
"category": "<ally_rule_aim_strictly_precise>",
"text": "<mypronoun> will only shoot after taking a long time to aim."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_none>",
"text": "<mypronoun> won't fight unless their life depends on it."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_close>",
"text": "<mypronoun> will attack enemies that get too close."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_weak>",
"text": "<mypronoun> will attack enemies that they can kill easily."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_hit>",
"text": "<mypronoun> will attack only enemies that you attack first."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_all>",
"text": [
{ "text": "<mypronoun> will attack anything they want.", "weight": 999 },
{ "text": "<npc_name> has permission to go <color_red>ABSOLUTELY AXE CRAZY!</color>", "weight": 1 }
]
},
{
"type": "snippet",
"category": "<ally_rule_engagement_free_fire>",
"text": "<mypronoun> will attack any enemy within range of their ranged weapon, but won't move."
},
{
"type": "snippet",
"category": "<ally_rule_engagement_no_move>",
"text": "<mypronoun> will attack only enemies they can reach without moving."
},
{
"type": "snippet",
"category": "<ally_rule_use_guns_true_text>",
Expand Down
2 changes: 1 addition & 1 deletion src/mission_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void mission_ui::draw_mission_ui()

p_impl.last_action = ctxt.handle_input();

if( p_impl.last_action == "QUIT" ) {
if( p_impl.last_action == "QUIT" || !p_impl.get_is_open() ) {
RenechCDDA marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,11 @@ void npc_follower_rules::clear_overrides()
override_enable = ally_rule::DEFAULT;
}

void npc_follower_rules::clear_flags()
{
flags = ally_rule::DEFAULT;
}

int npc::get_thirst() const
{
return Character::get_thirst() - units::to_milliliter<int>( stomach.get_water() ) / 5;
Expand Down
1 change: 1 addition & 0 deletions src/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ struct npc_follower_rules {
void clear_override( ally_rule clearit );

void set_danger_overrides();
void clear_flags();
void clear_overrides();
};

Expand Down
13 changes: 13 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "mutation.h"
#include "npc.h"
#include "npctalk.h"
#include "npctalk_rules.h"
#include "npctrade.h"
#include "output.h"
#include "overmapbuffer.h"
Expand Down Expand Up @@ -3480,6 +3481,14 @@ talk_effect_fun_t::func f_add_debt( const JsonObject &jo, std::string_view membe
};
}

talk_effect_fun_t::func f_npc_rules_menu()
{
return []( dialogue const & d ) {
follower_rules_ui new_ui;
new_ui.draw_follower_rules_ui( d.actor( true )->get_npc() );
};
}

talk_effect_fun_t::func f_toggle_npc_rule( const JsonObject &jo, std::string_view member )
{
str_or_var rule = get_str_or_var( jo.get_member( member ), member, true );
Expand Down Expand Up @@ -6674,6 +6683,10 @@ void talk_effect_t::parse_string_effect( const std::string &effect_id, const Jso
set_effect( talk_effect_fun_t( talk_effect_fun::f_wants_to_talk( true ) ) );
return;
}
if( effect_id == "npc_rules_menu" ) {
set_effect( talk_effect_fun_t( talk_effect_fun::f_npc_rules_menu() ) );
return;
}
jo.throw_error_at( effect_id, "unknown effect string" );
}

Expand Down
Loading
Loading