From e2fec0c17ed02cddc9f3a590b4b71a2d50b0f5ad Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sun, 1 Dec 2024 10:54:56 +0000 Subject: [PATCH 1/2] Debug and summon_vehicle spell spawning ignore VEHICLE_STATUS_AT_SPAWN --- src/debug_menu.cpp | 2 +- src/magic_spell_effect.cpp | 2 +- src/map.h | 11 +++++++---- src/mapgen.cpp | 11 +++++++---- src/vehicle.cpp | 7 +++++-- src/vehicle.h | 3 ++- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index d966a3d6904d8..4fd0d4a2fa079 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -3157,7 +3157,7 @@ static void debug_menu_spawn_vehicle() if( veh_cond_menu.ret >= 0 && veh_cond_menu.ret < 4 ) { // TODO: Allow picking this when add_vehicle has 3d argument vehicle *veh = here.add_vehicle( - selected_opt, dest, -90_degrees, 100, veh_cond_menu.ret - 1 ); + selected_opt, dest, -90_degrees, 100, veh_cond_menu.ret - 1, true, true ); if( veh != nullptr ) { here.board_vehicle( dest, &player_character ); } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 1637ea0a97876..3bcc36f264ad2 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -1352,7 +1352,7 @@ void spell_effect::spawn_summoned_vehicle( const spell &sp, Creature &caster, return; } if( vehicle *veh = here.add_vehicle( sp.summon_vehicle_id(), target, -90_degrees, - 100, 0, false ) ) { + 100, 2, false, true ) ) { veh->unlock(); veh->magic = true; if( !sp.has_flag( spell_flag::PERMANENT ) ) { diff --git a/src/map.h b/src/map.h index 2c09ea9864179..5e83ad8b54904 100644 --- a/src/map.h +++ b/src/map.h @@ -2024,9 +2024,11 @@ class map // if false and vehicle will overlap aborts and returns nullptr // TODO: Get rid of untyped overload vehicle *add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir, - int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); + int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true, + bool force_status = false ); vehicle *add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, const units::angle &dir, - int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); + int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true, + bool force_status = false ); // Light/transparency float light_transparency( const tripoint_bub_ms &p ) const; @@ -2825,9 +2827,10 @@ class tinymap : private map return map::veh_at( rebase_bub( p ) ); } vehicle *add_vehicle( const vproto_id &type, const tripoint_omt_ms &p, const units::angle &dir, - int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ) { + int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true, + bool force_status = false ) { return map::add_vehicle( type, rebase_bub( p ), dir, init_veh_fuel, init_veh_status, - merge_wrecks ); + merge_wrecks, force_status ); } void add_splatter_trail( const field_type_id &type, const tripoint_omt_ms &from, const tripoint_omt_ms &to ) { diff --git a/src/mapgen.cpp b/src/mapgen.cpp index cb8c4ad472e44..b5f756f5013be 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -6808,13 +6808,16 @@ void map::add_spawn( } vehicle *map::add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir, - const int veh_fuel, const int veh_status, const bool merge_wrecks ) + const int veh_fuel, const int veh_status, const bool merge_wrecks, + const bool force_status/* = false*/ ) { - return map::add_vehicle( type, tripoint_bub_ms( p ), dir, veh_fuel, veh_status, merge_wrecks ); + return map::add_vehicle( type, tripoint_bub_ms( p ), dir, veh_fuel, veh_status, merge_wrecks, + force_status ); } vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, const units::angle &dir, - const int veh_fuel, const int veh_status, const bool merge_wrecks ) + const int veh_fuel, const int veh_status, const bool merge_wrecks, + const bool force_status/* = false*/ ) { if( !type.is_valid() ) { debugmsg( "Nonexistent vehicle type: \"%s\"", type.c_str() ); @@ -6833,7 +6836,7 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, cons std::tie( quotient, remainder ) = coords::project_remain( p_ms ); veh->sm_pos = quotient.raw(); veh->pos = remainder; - veh->init_state( *this, veh_fuel, veh_status ); + veh->init_state( *this, veh_fuel, veh_status, force_status ); veh->place_spawn_items(); veh->face.init( dir ); veh->turn_dir = dir; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d77a0f0a19b08..a93d59c5190dd 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -312,7 +312,8 @@ bool vehicle::remote_controlled( const Character &p ) const return false; } -void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status ) +void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status, + const bool force_status/* = false*/ ) { // vehicle parts excluding engines in non-owned vehicles are by default turned off for( vehicle_part &pt : parts ) { @@ -333,7 +334,9 @@ void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status last_update = calendar::turn_zero; if( get_option( "OVERRIDE_VEHICLE_INIT_STATE" ) ) { - init_veh_status = get_option( "VEHICLE_STATUS_AT_SPAWN" ); + if( !force_status ) { + init_veh_status = get_option( "VEHICLE_STATUS_AT_SPAWN" ); + } init_veh_fuel = get_option( "VEHICLE_FUEL_AT_SPAWN" ); } diff --git a/src/vehicle.h b/src/vehicle.h index cdd20eb899611..66d9015a62a49 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -939,7 +939,8 @@ class vehicle bool remote_controlled( const Character &p ) const; // initializes parts and fuel state for randomly generated vehicle and calls refresh() - void init_state( map &placed_on, int init_veh_fuel, int init_veh_status ); + void init_state( map &placed_on, int init_veh_fuel, int init_veh_status, + const bool force_status = false ); // damages all parts of a vehicle by a random amount void smash( map &m, float hp_percent_loss_min = 0.1f, float hp_percent_loss_max = 1.2f, From 73a8a40b5a847d5c767865f52c3ca4e34d902995 Mon Sep 17 00:00:00 2001 From: Anton Burmistrov Date: Wed, 4 Dec 2024 22:38:32 +0400 Subject: [PATCH 2/2] Forbid learning spells from spellbooks with low morale (#78298) * Forbid learning spells from spellbooks with low morale * Added TODO * Apply suggestions from code review --- src/iuse_actor.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index ac13b904a5f51..e3fb154d99d4b 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -2391,12 +2391,18 @@ void learn_spell_actor::info( const item &, std::vector &dump ) const std::optional learn_spell_actor::use( Character *p, item &, const tripoint & ) const { + //TODO: combine/replace the checks below with "checks for conditions" from Character::check_read_condition + if( p->fine_detail_vision_mod() > 4 ) { - p->add_msg_if_player( _( "It's too dark to read." ) ); + p->add_msg_if_player( m_bad, _( "It's too dark to read." ) ); return std::nullopt; } if( p->has_trait( trait_ILLITERATE ) ) { - p->add_msg_if_player( _( "You can't read." ) ); + p->add_msg_if_player( m_bad, _( "You can't read." ) ); + return std::nullopt; + } + if( !p->has_morale_to_read() ) { + p->add_msg_if_player( m_bad, _( "What's the point of studying? (Your morale is too low!)" ) ); return std::nullopt; } std::vector uilist_initializer;