OSDN Git Service

5ed4eeeb113759a9b6080c99d899dcccd0b51197
[hengbandforosx/hengbandosx.git] / src / racial / racial-android.c
1 #include "racial/racial-android.h"
2 #include "inventory/inventory-slot-types.h"
3 #include "object-enchant/object-ego.h"
4 #include "object-enchant/trg-types.h"
5 #include "object-hook/hook-enchant.h"
6 #include "object-hook/hook-weapon.h"
7 #include "object/object-generator.h"
8 #include "object/object-kind.h"
9 #include "object/object-value-calc.h"
10 #include "object/object-value.h"
11 #include "spell-kind/spells-launcher.h"
12 #include "spell/spell-types.h"
13 #include "sv-definition/sv-armor-types.h"
14 #include "sv-definition/sv-protector-types.h"
15 #include "sv-definition/sv-weapon-types.h"
16 #include "system/artifact-type-definition.h"
17 #include "system/object-type-definition.h"
18 #include "target/target-getter.h"
19 #include "view/display-messages.h"
20
21 bool android_inside_weapon(player_type *creature_ptr)
22 {
23     DIRECTION dir;
24     if (!get_aim_dir(creature_ptr, &dir))
25         return FALSE;
26
27     if (creature_ptr->lev < 10) {
28         msg_print(_("レイガンを発射した。", "You fire your ray gun."));
29         fire_bolt(creature_ptr, GF_MISSILE, dir, (creature_ptr->lev + 1) / 2);
30         return TRUE;
31     }
32
33     if (creature_ptr->lev < 25) {
34         msg_print(_("ブラスターを発射した。", "You fire your blaster."));
35         fire_bolt(creature_ptr, GF_MISSILE, dir, creature_ptr->lev);
36         return TRUE;
37     }
38
39     if (creature_ptr->lev < 35) {
40         msg_print(_("バズーカを発射した。", "You fire your bazooka."));
41         fire_ball(creature_ptr, GF_MISSILE, dir, creature_ptr->lev * 2, 2);
42         return TRUE;
43     }
44
45     if (creature_ptr->lev < 45) {
46         msg_print(_("ビームキャノンを発射した。", "You fire a beam cannon."));
47         fire_beam(creature_ptr, GF_MISSILE, dir, creature_ptr->lev * 2);
48         return TRUE;
49     }
50
51     msg_print(_("ロケットを発射した。", "You fire a rocket."));
52     fire_rocket(creature_ptr, GF_ROCKET, dir, creature_ptr->lev * 5, 2);
53     return TRUE;
54 }
55
56 void calc_android_exp(player_type *creature_ptr)
57 {
58     u32b total_exp = 0;
59     if (creature_ptr->is_dead || (creature_ptr->prace != RACE_ANDROID))
60         return;
61
62     for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
63         object_type *o_ptr = &creature_ptr->inventory_list[i];
64         object_type forge;
65         object_type *q_ptr = &forge;
66         u32b value, exp;
67         DEPTH level = MAX(k_info[o_ptr->k_idx].level - 8, 1);
68
69         if ((i == INVEN_MAIN_RING) || (i == INVEN_SUB_RING) || (i == INVEN_NECK) || (i == INVEN_LITE))
70             continue;
71         if (!o_ptr->k_idx)
72             continue;
73
74         object_wipe(q_ptr);
75         object_copy(q_ptr, o_ptr);
76         q_ptr->discount = 0;
77         q_ptr->curse_flags = 0L;
78
79         if (object_is_fixed_artifact(o_ptr)) {
80             level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
81             level += MIN(20, a_info[o_ptr->name1].rarity / (a_info[o_ptr->name1].gen_flags & TRG_INSTA_ART ? 10 : 3));
82         } else if (object_is_ego(o_ptr)) {
83             level += MAX(3, (e_info[o_ptr->name2].rating - 5) / 2);
84         } else if (o_ptr->art_name) {
85             s32b total_flags = flag_cost(creature_ptr, o_ptr, o_ptr->pval);
86             int fake_level;
87
88             if (!object_is_weapon_ammo(o_ptr)) {
89                 if (total_flags < 15000)
90                     fake_level = 10;
91                 else if (total_flags < 35000)
92                     fake_level = 25;
93                 else
94                     fake_level = 40;
95             } else {
96                 if (total_flags < 20000)
97                     fake_level = 10;
98                 else if (total_flags < 45000)
99                     fake_level = 25;
100                 else
101                     fake_level = 40;
102             }
103
104             level = MAX(level, (level + MAX(fake_level - 8, 5)) / 2 + 3);
105         }
106
107         value = object_value_real(creature_ptr, q_ptr);
108         if (value <= 0)
109             continue;
110         if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI) && (creature_ptr->pseikaku != PERSONALITY_SEXY))
111             value /= 32;
112         if (value > 5000000L)
113             value = 5000000L;
114         if ((o_ptr->tval == TV_DRAG_ARMOR) || (o_ptr->tval == TV_CARD))
115             level /= 2;
116
117         if (object_is_artifact(o_ptr) || object_is_ego(o_ptr) || (o_ptr->tval == TV_DRAG_ARMOR) || ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
118             || ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) || ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
119             || ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)) || ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE))) {
120             if (level > 65)
121                 level = 35 + (level - 65) / 5;
122             else if (level > 35)
123                 level = 25 + (level - 35) / 3;
124             else if (level > 15)
125                 level = 15 + (level - 15) / 2;
126             exp = MIN(100000L, value) / 2 * level * level;
127             if (value > 100000L)
128                 exp += (value - 100000L) / 8 * level * level;
129         } else {
130             exp = MIN(100000L, value) * level;
131             if (value > 100000L)
132                 exp += (value - 100000L) / 4 * level;
133         }
134         if ((((i == INVEN_MAIN_HAND) || (i == INVEN_SUB_HAND)) && (has_melee_weapon(creature_ptr, i))) || (i == INVEN_BOW))
135             total_exp += exp / 48;
136         else
137             total_exp += exp / 16;
138         if (i == INVEN_BODY)
139             total_exp += exp / 32;
140     }
141
142     creature_ptr->exp = creature_ptr->max_exp = total_exp;
143     check_experience(creature_ptr);
144 }