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

Hallucinations: Misc fixes #54307

Merged
merged 2 commits into from
Jan 12, 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
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
8 changes: 6 additions & 2 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ void monster::move()
}

tripoint_abs_ms next_step;
const bool can_open_doors = has_flag( MF_CAN_OPEN_DOORS );
const bool can_open_doors = has_flag( MF_CAN_OPEN_DOORS ) && !is_hallucination();
const bool staggers = has_flag( MF_STUMBLES );
if( moved ) {
// Implement both avoiding obstacles and staggering.
Expand Down Expand Up @@ -981,6 +981,10 @@ void monster::move()

const Creature *target = creatures.creature_at( candidate, is_hallucination() );
if( target != nullptr ) {
if( is_hallucination() != target->is_hallucination() && !target->is_avatar() ) {
// Hallucinations should only be capable of targetting the player or other hallucinations.
continue;
}
const Attitude att = attitude_to( *target );
if( att == Attitude::HOSTILE ) {
// When attacking an adjacent enemy, we're direct.
Expand Down Expand Up @@ -2106,7 +2110,7 @@ void monster::shove_vehicle( const tripoint &remote_destination,
const tripoint &nearby_destination )
{
map &here = get_map();
if( this->has_flag( MF_PUSH_VEH ) ) {
if( this->has_flag( MF_PUSH_VEH ) && !is_hallucination() ) {
optional_vpart_position vp = here.veh_at( nearby_destination );
if( vp ) {
vehicle &veh = vp->vehicle();
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