Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooses2k authored and kevingranade committed Jun 11, 2019
1 parent 8001c32 commit a30c173
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
19 changes: 19 additions & 0 deletions data/json/npcs/TALK_COMMON_ALLY.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@
}
]
},
{
"and": [
{ "npc_override": "follow_distance_2", "yes": " OVERRIDE: ", "no": " " },
{
"npc_rule": "follow_distance_2",
"yes": "<ally_rule_follow_distance_2_true_text>",
"no": "<ally_rule_follow_distance_2_false_text>"
}
]
},
{
"and": [
{ "npc_override": "use_guns", "yes": " OVERRIDE: ", "no": " " },
Expand Down Expand Up @@ -237,6 +247,15 @@
"topic": "TALK_COMBAT_COMMANDS",
"effect": { "toggle_npc_rule": "follow_close" }
},
{
"truefalsetext": {
"condition": { "npc_rule": "follow_distance_2" },
"true": "<ally_rule_follow_distance_2_true_text>",
"false": "<ally_rule_follow_distance_2_false_text>"
},
"topic": "TALK_COMBAT_COMMANDS",
"effect": { "toggle_npc_rule": "follow_distance_2" }
},
{
"truefalsetext": {
"condition": { "npc_rule": "use_guns" },
Expand Down
10 changes: 10 additions & 0 deletions data/json/npcs/talk_tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,16 @@
"category": "<ally_rule_follow_close_false_text>",
"text": "<mypronoun> will move freely as needed."
},
{
"type": "snippet",
"category": "<ally_rule_follow_distance_2_true_text>",
"text": "<mypronoun> will follow you at about two paces."
},
{
"type": "snippet",
"category": "<ally_rule_follow_distance_2_false_text>",
"text": "<mypronoun> will follow you at about four paces."
},
{
"type": "snippet",
"category": "<ally_rule_avoid_doors_true_text>",
Expand Down
10 changes: 9 additions & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,14 @@ int npc::follow_distance() const
g->m.has_flag( TFLAG_GOES_UP, g->u.pos() ) ) ) {
return 1;
}
// TODO: Allow player to set that
// Uses ally_rule follow_distance_2 to determine if should follow by 2 or 4 tiles
if( rules.has_flag( ally_rule::follow_distance_2 ) ) {
return 2;
}
// If NPC doesn't see player, change follow distance to 2
if( !sees( g->u ) ) {
return 2;
}
return 4;
}

Expand Down Expand Up @@ -2681,6 +2688,7 @@ npc_follower_rules::npc_follower_rules()
clear_flag( ally_rule::hold_the_line );
clear_flag( ally_rule::ignore_noise );
clear_flag( ally_rule::forbid_engage );
set_flag( ally_rule::follow_distance_2 );
}

bool npc_follower_rules::has_flag( ally_rule test, bool check_override ) const
Expand Down
10 changes: 9 additions & 1 deletion src/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ enum class ally_rule {
avoid_doors = 2048,
hold_the_line = 4096,
ignore_noise = 8192,
forbid_engage = 16384
forbid_engage = 16384,
follow_distance_2 = 32768
};

struct ally_rule_data {
Expand Down Expand Up @@ -396,6 +397,13 @@ const std::unordered_map<std::string, ally_rule_data> ally_rule_strs = { {
"<ally_rule_forbid_engage_true_text>",
"<ally_rule_forbid_engage_false_text>"
}
},
{
"follow_distance_2", {
ally_rule::follow_distance_2,
"<ally_rule_follow_distance_2_true_text>",
"<ally_rule_follow_distance_2_false_text>"
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions tests/npc_talk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,17 @@ TEST_CASE( "npc_talk_test" )
CHECK( !has_item( g->u, "beer", 1 ) );

d.add_topic( "TALK_COMBAT_COMMANDS" );
gen_response_lines( d, 9 );
gen_response_lines( d, 10 );
CHECK( d.responses[0].text == "Change your engagement rules..." );
CHECK( d.responses[1].text == "Change your aiming rules..." );
CHECK( d.responses[2].text == "Stick close to me, no matter what." );
CHECK( d.responses[3].text == "Don't use ranged weapons anymore." );
CHECK( d.responses[4].text == "Use only silent weapons." );
CHECK( d.responses[5].text == "Don't use grenades anymore." );
CHECK( d.responses[6].text == "Don't worry about shooting an ally." );
CHECK( d.responses[7].text == "Hold the line: don't move onto obstacles adjacent to me." );
CHECK( d.responses[8].text == "Never mind." );
CHECK( d.responses[3].text == "<ally_rule_follow_distance_2_true_text>" );
CHECK( d.responses[4].text == "Don't use ranged weapons anymore." );
CHECK( d.responses[5].text == "Use only silent weapons." );
CHECK( d.responses[6].text == "Don't use grenades anymore." );
CHECK( d.responses[7].text == "Don't worry about shooting an ally." );
CHECK( d.responses[8].text == "Hold the line: don't move onto obstacles adjacent to me." );
CHECK( d.responses[9].text == "Never mind." );

d.add_topic( "TALK_TEST_VARS" );
gen_response_lines( d, 3 );
Expand Down

0 comments on commit a30c173

Please sign in to comment.