Skip to content

Commit

Permalink
Hallucinations: Misc NPC fixes
Browse files Browse the repository at this point in the history
- Prevent hallucinations from opening doors
- Prevent player from stealing from hallucinations
- Prevent player from trading with ally hallucinations
- Prevent player from asking ally hallucinations to drop items
- Prevent hallucinations from training the player (and vis-versa)
  • Loading branch information
dseguin committed Jan 12, 2022
1 parent 5ec8f25 commit 4f18da9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions data/json/npcs/TALK_COMMON_ALLY.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
{ "npc_need": "hunger", "amount": 160 },
{ "npc_need": "fatigue", "level": "TIRED" },
{ "npc_has_effect": "asked_to_train" },
{ "npc_has_trait": "HALLUCINATION" },
"u_driving",
"npc_driving"
]
Expand All @@ -132,7 +133,7 @@
},
{
"text": "Can you host a training seminar?",
"condition": { "not": "is_by_radio" },
"condition": { "and": [ { "not": "is_by_radio" }, { "not": { "npc_has_trait": "HALLUCINATION" } } ] },
"trial": {
"type": "CONDITION",
"condition": {
Expand All @@ -156,7 +157,8 @@
{ "not": "u_driving" },
{ "not": "npc_driving" },
{ "not": "is_by_radio" },
{ "not": { "u_has_effect": "asked_to_train" } }
{ "not": { "u_has_effect": "asked_to_train" } },
{ "not": { "npc_has_trait": "HALLUCINATION" } }
]
},
"topic": "TALK_TRAIN_NPC"
Expand Down Expand Up @@ -202,7 +204,7 @@
},
{
"text": "Drop off any items you're not using.",
"condition": { "not": "is_by_radio" },
"condition": { "and": [ { "not": "is_by_radio" }, { "not": { "npc_has_trait": "HALLUCINATION" } } ] },
"topic": "TALK_DONE",
"effect": "drop_items_in_place"
},
Expand Down
8 changes: 7 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
#include "string_input_popup.h"
#include "submap.h"
#include "talker.h"
#include "text_snippets.h"
#include "tileray.h"
#include "timed_event.h"
#include "translations.h"
Expand Down Expand Up @@ -5277,7 +5278,12 @@ bool game::npc_menu( npc &who )
} else if( choice == steal && query_yn( _( "You may be attacked! Proceed?" ) ) ) {
u.steal( who );
} else if( choice == trade ) {
npc_trading::trade( who, 0, _( "Trade" ) );
if( who.is_hallucination() ) {
who.say( SNIPPET.random_from_category( "<hallu_dont_trade>" ).value_or(
translation() ).translated() );
} else {
npc_trading::trade( who, 0, _( "Trade" ) );
}
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2839,7 +2839,7 @@ void avatar::steal( npc &target )
int their_roll = dice( 5, target.get_per() );

const item *it = loc.get_item();
if( my_roll >= their_roll ) {
if( my_roll >= their_roll && !target.is_hallucination() ) {
add_msg( _( "You sneakily steal %1$s from %2$s!" ),
it->tname(), target.get_name() );
i_add( target.i_rem( it ) );
Expand Down
3 changes: 2 additions & 1 deletion src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,8 @@ bool npc::update_path( const tripoint &p, const bool no_bashing, bool force )

bool npc::can_open_door( const tripoint &p, const bool inside ) const
{
return !rules.has_flag( ally_rule::avoid_doors ) && get_map().open_door( p, inside, true );
return !is_hallucination() && !rules.has_flag( ally_rule::avoid_doors ) &&
get_map().open_door( p, inside, true );
}

bool npc::can_move_to( const tripoint &p, bool no_bashing ) const
Expand Down

0 comments on commit 4f18da9

Please sign in to comment.