OSDN Git Service

[Refactor] #3286 Removed player-redraw-types.h
[hengbandforosx/hengbandosx.git] / src / cmd-item / cmd-throw.cpp
1 /*
2  * @brief アイテム投擲コマンドの実装
3  * @date 2021/08/20
4  * @author Hourier
5  */
6 #include "cmd-item/cmd-throw.h"
7 #include "game-option/special-options.h"
8 #include "inventory/inventory-slot-types.h"
9 #include "object-use/throw-execution.h"
10 #include "object/object-broken.h"
11 #include "player-base/player-class.h"
12 #include "player-info/samurai-data-type.h"
13 #include "player/attack-defense-types.h"
14 #include "player/special-defense-types.h"
15 #include "specific-object/torch.h"
16 #include "status/action-setter.h"
17 #include "system/item-entity.h"
18 #include "system/player-type-definition.h"
19 #include "system/redrawing-flags-updater.h"
20
21 ThrowCommand::ThrowCommand(PlayerType *player_ptr)
22     : player_ptr(player_ptr)
23 {
24 }
25
26 /*!
27  * @brief 投射処理メインルーチン /
28  * Throw an object from the pack or floor.
29  * @param mult 威力の倍率
30  * @param player_ptr プレイヤーへの参照ポインタ
31  * @param boomerang ブーメラン処理ならばTRUE
32  * @param shuriken 忍者の手裏剣処理ならばTRUE ← 間違い、-1が渡されてくることがある。要調査.
33  * @return ターンを消費した場合TRUEを返す
34  * @details
35  * <pre>
36  * Note: "unseen" monsters are very hard to hit.
37  *
38  * Should throwing a weapon do full damage?  Should it allow the magic
39  * to hit bonus of the weapon to have an effect?  Should it ever cause
40  * the item to be destroyed?  Should it do any damage at all?
41  * </pre>
42  */
43 bool ThrowCommand::do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
44 {
45     if (this->player_ptr->wild_mode) {
46         return false;
47     }
48
49     PlayerClass pc(this->player_ptr);
50     pc.break_samurai_stance({ SamuraiStanceType::MUSOU });
51
52     ItemEntity tmp_object;
53     ObjectThrowEntity ote(this->player_ptr, &tmp_object, delay_factor, mult, boomerang, shuriken);
54     if (!ote.check_can_throw()) {
55         return false;
56     }
57
58     ote.calc_throw_range();
59     if (!ote.calc_throw_grid()) {
60         return false;
61     }
62
63     ote.reflect_inventory_by_throw();
64     if (ote.item >= INVEN_MAIN_HAND) {
65         ote.equiped_item = true;
66         RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::EQUIPPY);
67     }
68
69     ote.set_class_specific_throw_params();
70     ote.set_racial_chance();
71     ote.prev_y = ote.y;
72     ote.prev_x = ote.x;
73     ote.exe_throw();
74     if (ote.hit_body) {
75         torch_lost_fuel(ote.q_ptr);
76     }
77
78     ote.corruption_possibility = ote.hit_body ? breakage_chance(this->player_ptr, ote.q_ptr, pc.equals(PlayerClassType::ARCHER), 0) : 0;
79     ote.display_figurine_throw();
80     ote.display_potion_throw();
81     ote.check_boomerang_throw();
82     ote.process_boomerang_back();
83     ote.drop_thrown_item();
84     return true;
85 }