From c80afda67bbd9faf01182e7fb4aa5051f46ef75a Mon Sep 17 00:00:00 2001 From: deskull Date: Mon, 5 Apr 2021 19:31:59 +0900 Subject: [PATCH] =?utf8?q?[Add]=20=E4=B8=8D=E6=BB=85=E3=83=81=E3=83=BC?= =?utf8?q?=E3=83=88=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E5=AE=9F?= =?utf8?q?=E8=A3=85=EF=BC=8E=E3=80=80/=20Implement=20cheat=5Fimmortal.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/birth/game-play-initializer.cpp | 1 + src/core/game-play.cpp | 2 +- src/core/player-processor.cpp | 3 ++- src/dungeon/dungeon-processor.cpp | 1 + src/game-option/cheat-options.cpp | 1 + src/game-option/cheat-options.h | 1 + src/game-option/option-types-table.cpp | 6 +++++- src/game-option/option-types-table.h | 2 +- src/io/signal-handlers.cpp | 4 +++- src/load/option-loader.cpp | 1 + src/player/player-damage.cpp | 6 ++++-- src/save/info-writer.cpp | 3 +++ 12 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/birth/game-play-initializer.cpp b/src/birth/game-play-initializer.cpp index 2e86d2d0f..cd64bf7cb 100644 --- a/src/birth/game-play-initializer.cpp +++ b/src/birth/game-play-initializer.cpp @@ -125,6 +125,7 @@ void player_wipe_without_name(player_type *creature_ptr) cheat_save = FALSE; cheat_diary_output = FALSE; cheat_turn = FALSE; + cheat_immortal = FALSE; current_world_ptr->total_winner = FALSE; creature_ptr->timewalk = FALSE; diff --git a/src/core/game-play.cpp b/src/core/game-play.cpp index af3215ab0..ac5e8c0fe 100644 --- a/src/core/game-play.cpp +++ b/src/core/game-play.cpp @@ -425,7 +425,7 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie) player_outfit(player_ptr); init_io(player_ptr); - if (player_ptr->chp < 0) + if (player_ptr->chp < 0 && !cheat_immortal) player_ptr->is_dead = TRUE; if (player_ptr->prace == RACE_ANDROID) diff --git a/src/core/player-processor.cpp b/src/core/player-processor.cpp index 69c05532d..671ca9ee7 100644 --- a/src/core/player-processor.cpp +++ b/src/core/player-processor.cpp @@ -13,6 +13,7 @@ #include "floor/wild.h" #include "game-option/disturbance-options.h" #include "game-option/map-screen-options.h" +#include "game-option/cheat-options.h" #include "grid/grid.h" #include "inventory/pack-overflow.h" #include "io/cursor.h" @@ -264,7 +265,7 @@ void process_player(player_type *creature_ptr) move_cursor_relative(creature_ptr->y, creature_ptr->x); command_cmd = SPECIAL_KEY_BUILDING; process_command(creature_ptr); - } else if (creature_ptr->paralyzed || (creature_ptr->stun >= 100)) { + } else if ((creature_ptr->paralyzed || creature_ptr->stun >= 100) && !cheat_immortal) { take_turn(creature_ptr, 100); } else if (creature_ptr->action == ACTION_REST) { if (creature_ptr->resting > 0) { diff --git a/src/dungeon/dungeon-processor.cpp b/src/dungeon/dungeon-processor.cpp index 1ae6071d4..88b4791ec 100644 --- a/src/dungeon/dungeon-processor.cpp +++ b/src/dungeon/dungeon-processor.cpp @@ -17,6 +17,7 @@ #include "floor/floor-save.h" #include "game-option/map-screen-options.h" #include "game-option/play-record-options.h" +#include "game-option/cheat-options.h" #include "io/cursor.h" #include "io/input-key-requester.h" #include "io/write-diary.h" diff --git a/src/game-option/cheat-options.cpp b/src/game-option/cheat-options.cpp index 4bf1e1b82..dbcf4ed0b 100644 --- a/src/game-option/cheat-options.cpp +++ b/src/game-option/cheat-options.cpp @@ -10,3 +10,4 @@ bool cheat_save; /* Ask for saving death */ bool cheat_diary_output; /* Detailed info to diary */ bool cheat_turn; /* Peek turn */ bool cheat_sight; +bool cheat_immortal; diff --git a/src/game-option/cheat-options.h b/src/game-option/cheat-options.h index 2357da5ef..1f8d1ae41 100644 --- a/src/game-option/cheat-options.h +++ b/src/game-option/cheat-options.h @@ -12,3 +12,4 @@ extern bool cheat_save; extern bool cheat_diary_output; extern bool cheat_turn; extern bool cheat_sight; +extern bool cheat_immortal; diff --git a/src/game-option/option-types-table.cpp b/src/game-option/option-types-table.cpp index 94e01d4cf..1221026b6 100644 --- a/src/game-option/option-types-table.cpp +++ b/src/game-option/option-types-table.cpp @@ -319,7 +319,11 @@ const option_type cheat_info[MAX_CHEAT_OPTIONS] { &cheat_turn, FALSE, 255, 0x81, 0x00, "cheat_turn", _("ゲームメッセージにターン表示を行う", "Put turn in game messages.") }, - { &cheat_sight, FALSE, 255, 0x82, 0x00, "cheat_sight", _("「見る」コマンドを拡張する。", "Expand \"L\"ook command.") } }; + { &cheat_sight, FALSE, 255, 0x82, 0x00, "cheat_sight", _("「見る」コマンドを拡張する。", "Expand \"L\"ook command.") }, + + { &cheat_immortal, FALSE, 255, 0x83, 0x00, "cheat_immortal", _("完全な不滅状態になる。", "Completely immortal.") } }; + + /*! * 自動セーブオプションテーブル diff --git a/src/game-option/option-types-table.h b/src/game-option/option-types-table.h index 351823789..b2520dfef 100644 --- a/src/game-option/option-types-table.h +++ b/src/game-option/option-types-table.h @@ -24,7 +24,7 @@ struct option_type { }; #define MAX_OPTION_INFO 125 -#define MAX_CHEAT_OPTIONS 10 +#define MAX_CHEAT_OPTIONS 11 #define MAX_AUTOSAVE_INFO 2 extern const std::array option_info; diff --git a/src/io/signal-handlers.cpp b/src/io/signal-handlers.cpp index 12ab8876b..c84039f95 100644 --- a/src/io/signal-handlers.cpp +++ b/src/io/signal-handlers.cpp @@ -11,6 +11,7 @@ #include "floor/floor-events.h" #include "io/write-diary.h" #include "monster-floor/monster-lite.h" +#include "game-option/cheat-options.h" #include "save/save.h" #include "system/system-variables.h" #include "term/term-color-types.h" @@ -78,7 +79,8 @@ static void handle_signal_simple(int sig) forget_view(p_ptr->current_floor_ptr); clear_mon_lite(p_ptr->current_floor_ptr); p_ptr->playing = FALSE; - p_ptr->is_dead = TRUE; + if (!cheat_immortal) + p_ptr->is_dead = TRUE; p_ptr->leaving = TRUE; close_game(p_ptr); quit(_("強制終了", "interrupt")); diff --git a/src/load/option-loader.cpp b/src/load/option-loader.cpp index f51534584..835ca5523 100644 --- a/src/load/option-loader.cpp +++ b/src/load/option-loader.cpp @@ -56,6 +56,7 @@ void rd_options(void) cheat_diary_output = (c & 0x8000) ? TRUE : FALSE; cheat_turn = (c & 0x0080) ? TRUE : FALSE; cheat_sight = (c & 0x0040) ? TRUE : FALSE; + cheat_immortal = (c & 0x0020) ? TRUE : FALSE; rd_byte((byte *)&autosave_l); rd_byte((byte *)&autosave_t); diff --git a/src/player/player-damage.cpp b/src/player/player-damage.cpp index 44da0a6be..5f05c206a 100644 --- a/src/player/player-damage.cpp +++ b/src/player/player-damage.cpp @@ -327,6 +327,8 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp } creature_ptr->chp -= damage; + if (creature_ptr->chp < -9999) + creature_ptr->chp = -9999; if (damage_type == DAMAGE_GENO && creature_ptr->chp < 0) { damage += creature_ptr->chp; creature_ptr->chp = 0; @@ -340,7 +342,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp chg_virtue(creature_ptr, V_CHANCE, 2); } - if (creature_ptr->chp < 0) { + if (creature_ptr->chp < 0 && !cheat_immortal) { bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE); #ifdef JP @@ -353,7 +355,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp chg_virtue(creature_ptr, V_SACRIFICE, 10); handle_stuff(creature_ptr); creature_ptr->leaving = TRUE; - creature_ptr->is_dead = TRUE; + if(!cheat_immortal) creature_ptr->is_dead = TRUE; if (creature_ptr->current_floor_ptr->inside_arena) { concptr m_name = r_info[arena_info[creature_ptr->arena_number].r_idx].name.c_str(); msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name); diff --git a/src/save/info-writer.cpp b/src/save/info-writer.cpp index 5716acef2..61f757d07 100644 --- a/src/save/info-writer.cpp +++ b/src/save/info-writer.cpp @@ -90,6 +90,9 @@ void wr_options(save_type type) if (cheat_diary_output) c |= 0x8000; + if (cheat_immortal) + c |= 0x0020; + if (type == SAVE_TYPE_DEBUG) c |= 0xFFFF; -- 2.11.0