| 152 | | |
|---|
| 153 | | /* |
|---|
| 154 | | * Describe the special slays and executes of an item. |
|---|
| 155 | | */ |
|---|
| 156 | | static bool describe_slay(const object_type *o_ptr, u32b f1) |
|---|
| 157 | | { |
|---|
| 158 | | cptr slays[8], execs[3]; |
|---|
| 159 | | int slcnt = 0, excnt = 0; |
|---|
| 160 | | bool prev = FALSE; |
|---|
| 161 | | |
|---|
| 162 | | /* Unused parameter */ |
|---|
| 163 | | (void)o_ptr; |
|---|
| 164 | | |
|---|
| 165 | | /* Collect brands */ |
|---|
| 166 | | if (f1 & (TR1_SLAY_ANIMAL)) slays[slcnt++] = "animals"; |
|---|
| 167 | | if (f1 & (TR1_SLAY_ORC)) slays[slcnt++] = "orcs"; |
|---|
| 168 | | if (f1 & (TR1_SLAY_TROLL)) slays[slcnt++] = "trolls"; |
|---|
| 169 | | if (f1 & (TR1_SLAY_GIANT)) slays[slcnt++] = "giants"; |
|---|
| 170 | | |
|---|
| 171 | | /* Dragon slay/execute */ |
|---|
| 172 | | if (f1 & TR1_KILL_DRAGON) |
|---|
| 173 | | execs[excnt++] = "dragons"; |
|---|
| 174 | | else if (f1 & TR1_SLAY_DRAGON) |
|---|
| 175 | | slays[slcnt++] = "dragons"; |
|---|
| 176 | | |
|---|
| 177 | | /* Demon slay/execute */ |
|---|
| 178 | | if (f1 & TR1_KILL_DEMON) |
|---|
| 179 | | execs[excnt++] = "demons"; |
|---|
| 180 | | else if (f1 & TR1_SLAY_DEMON) |
|---|
| 181 | | slays[slcnt++] = "demons"; |
|---|
| 182 | | |
|---|
| 183 | | /* Undead slay/execute */ |
|---|
| 184 | | if (f1 & TR1_KILL_UNDEAD) |
|---|
| 185 | | execs[excnt++] = "undead"; |
|---|
| 186 | | else if (f1 & TR1_SLAY_UNDEAD) |
|---|
| 187 | | slays[slcnt++] = "undead"; |
|---|
| 188 | | |
|---|
| 189 | | if (f1 & (TR1_SLAY_EVIL)) slays[slcnt++] = "all evil creatures"; |
|---|
| 190 | | |
|---|
| 191 | | if (slcnt) |
|---|
| 192 | | { |
|---|
| 193 | | p_text_out("It slays "); |
|---|
| 194 | | output_list(slays, slcnt); |
|---|
| 195 | | prev = TRUE; |
|---|
| 196 | | } |
|---|
| 197 | | |
|---|
| 198 | | if (excnt) |
|---|
| 199 | | { |
|---|
| 200 | | /* Intro */ |
|---|
| 201 | | if (prev) text_out(", and is especially deadly against "); |
|---|
| 202 | | else p_text_out("It is especially deadly against "); |
|---|
| 203 | | |
|---|
| 204 | | /* List */ |
|---|
| 205 | | output_list(execs, excnt); |
|---|
| 206 | | prev = TRUE; |
|---|
| 207 | | } |
|---|
| 208 | | |
|---|
| 209 | | /* Output end */ |
|---|
| 210 | | if (prev) text_out(". "); |
|---|
| 211 | | |
|---|
| 212 | | /* We are done here */ |
|---|
| 213 | | return prev; |
|---|
| 214 | | } |
|---|
| 215 | | |
|---|
| 216 | | |
|---|
| 217 | | /* |
|---|
| 218 | | * Describe elemental brands. |
|---|
| 219 | | */ |
|---|
| 220 | | static bool describe_brand(const object_type *o_ptr, u32b f1) |
|---|
| 221 | | { |
|---|
| 222 | | cptr descs[5]; |
|---|
| | 152 | /* |
|---|
| | 153 | * list[] and mult[] must be > 11 in size |
|---|
| | 154 | */ |
|---|
| | 155 | static int collect_slays(cptr desc[], int mult[], u32b f1) |
|---|
| | 156 | { |
|---|
| 225 | | /* Unused parameter */ |
|---|
| 226 | | (void)o_ptr; |
|---|
| 227 | | |
|---|
| 228 | | /* Collect brands */ |
|---|
| 229 | | if (f1 & (TR1_BRAND_ACID)) descs[cnt++] = "acid"; |
|---|
| 230 | | if (f1 & (TR1_BRAND_ELEC)) descs[cnt++] = "electricity"; |
|---|
| 231 | | if (f1 & (TR1_BRAND_FIRE)) descs[cnt++] = "fire"; |
|---|
| 232 | | if (f1 & (TR1_BRAND_COLD)) descs[cnt++] = "frost"; |
|---|
| 233 | | if (f1 & (TR1_BRAND_POIS)) descs[cnt++] = "poison"; |
|---|
| 234 | | |
|---|
| 235 | | /* Describe brands */ |
|---|
| 236 | | output_desc_list("It is branded with ", descs, cnt); |
|---|
| 237 | | |
|---|
| 238 | | /* We are done here */ |
|---|
| 239 | | return (cnt ? TRUE : FALSE); |
|---|
| | 159 | /* Collect slays */ |
|---|
| | 160 | if (f1 & TR1_SLAY_ANIMAL) { mult[cnt] = 2; desc[cnt++] = "animals"; } |
|---|
| | 161 | if (f1 & TR1_SLAY_EVIL) { mult[cnt] = 2; desc[cnt++] = "evil creatures"; } |
|---|
| | 162 | |
|---|
| | 163 | if (f1 & TR1_SLAY_ORC) { mult[cnt] = 3; desc[cnt++] = "orcs"; } |
|---|
| | 164 | if (f1 & TR1_SLAY_TROLL) { mult[cnt] = 3; desc[cnt++] = "trolls"; } |
|---|
| | 165 | if (f1 & TR1_SLAY_GIANT) { mult[cnt] = 3; desc[cnt++] = "giants"; } |
|---|
| | 166 | if (f1 & TR1_SLAY_DRAGON) { mult[cnt] = 3; desc[cnt++] = "dragons"; } |
|---|
| | 167 | if (f1 & TR1_SLAY_DEMON) { mult[cnt] = 3; desc[cnt++] = "demons"; } |
|---|
| | 168 | if (f1 & TR1_SLAY_UNDEAD) { mult[cnt] = 3; desc[cnt++] = "undead"; } |
|---|
| | 169 | |
|---|
| | 170 | if (f1 & TR1_BRAND_ACID) { mult[cnt] = 3; desc[cnt++] = "acid-vulnerable creatures"; } |
|---|
| | 171 | if (f1 & TR1_BRAND_ELEC) { mult[cnt] = 3; desc[cnt++] = "electricity-vulnerable creatures"; } |
|---|
| | 172 | if (f1 & TR1_BRAND_FIRE) { mult[cnt] = 3; desc[cnt++] = "fire-vulnerable creatures"; } |
|---|
| | 173 | if (f1 & TR1_BRAND_COLD) { mult[cnt] = 3; desc[cnt++] = "frost-vulnerable creatures"; } |
|---|
| | 174 | if (f1 & TR1_BRAND_POIS) { mult[cnt] = 3; desc[cnt++] = "poison-vulnerable creatures"; } |
|---|
| | 175 | |
|---|
| | 176 | if (f1 & TR1_KILL_DRAGON) { mult[cnt] = 5; desc[cnt++] = "dragons"; } |
|---|
| | 177 | if (f1 & TR1_KILL_DEMON) { mult[cnt] = 5; desc[cnt++] = "demons"; } |
|---|
| | 178 | if (f1 & TR1_KILL_UNDEAD) { mult[cnt] = 5; desc[cnt++] = "undead"; } |
|---|
| | 179 | |
|---|
| | 180 | return cnt; |
|---|
| | 181 | } |
|---|
| | 182 | |
|---|
| | 183 | |
|---|
| | 184 | /* |
|---|
| | 185 | * Describe combat advantages. |
|---|
| | 186 | */ |
|---|
| | 187 | static bool describe_combat(const object_type *o_ptr, u32b f1) |
|---|
| | 188 | { |
|---|
| | 189 | cptr desc[15]; |
|---|
| | 190 | int mult[15]; |
|---|
| | 191 | int cnt, dam; |
|---|
| | 192 | object_type *j_ptr = &inventory[INVEN_BOW]; |
|---|
| | 193 | |
|---|
| | 194 | bool weapon = (wield_slot(o_ptr) == INVEN_WIELD); |
|---|
| | 195 | bool ammo = (p_ptr->ammo_tval == o_ptr->tval) && |
|---|
| | 196 | (j_ptr->k_idx); |
|---|
| | 197 | |
|---|
| | 198 | /* Abort if we've nothing to say */ |
|---|
| | 199 | if (!weapon && !ammo) return FALSE; |
|---|
| | 200 | |
|---|
| | 201 | if (weapon) |
|---|
| | 202 | { |
|---|
| | 203 | int blows = calc_blows(o_ptr); |
|---|
| | 204 | |
|---|
| | 205 | dam = (o_ptr->ds * o_ptr->dd * 5); |
|---|
| | 206 | dam += (o_ptr->to_d + p_ptr->to_d) * 10; |
|---|
| | 207 | |
|---|
| | 208 | p_text_out("Using this weapon, in your current condition, you are able to score "); |
|---|
| | 209 | text_out_c(TERM_L_GREEN, format("%d ", blows)); |
|---|
| | 210 | if (blows > 1) |
|---|
| | 211 | text_out("blows per round. Each blow will do an average damage of "); |
|---|
| | 212 | else |
|---|
| | 213 | text_out("blow per round, averaging a damage of "); |
|---|
| | 214 | } |
|---|
| | 215 | else |
|---|
| | 216 | { |
|---|
| | 217 | int tdis = 10 + 5 * p_ptr->ammo_mult; |
|---|
| | 218 | |
|---|
| | 219 | /* Calculate damage */ |
|---|
| | 220 | dam = (o_ptr->ds * o_ptr->dd * 5); |
|---|
| | 221 | dam += (o_ptr->to_d + j_ptr->to_d * 10); |
|---|
| | 222 | dam *= p_ptr->ammo_mult; |
|---|
| | 223 | |
|---|
| | 224 | p_text_out("Fired from your current bow, this arrow will hit targets up to "); |
|---|
| | 225 | text_out_c(TERM_L_GREEN, format("%d", tdis * 10)); |
|---|
| | 226 | text_out(" feet away, inflicting an average damage of "); |
|---|
| | 227 | } |
|---|
| | 228 | |
|---|
| | 229 | /* Collect slays */ |
|---|
| | 230 | cnt = collect_slays(desc, mult, f1); |
|---|
| | 231 | if (object_known_p(o_ptr) && cnt) |
|---|
| | 232 | { |
|---|
| | 233 | size_t i; |
|---|
| | 234 | |
|---|
| | 235 | for (i = 0; i < cnt; i++) |
|---|
| | 236 | { |
|---|
| | 237 | text_out_c(TERM_L_GREEN, "%d", (dam * mult[i]) / 10); |
|---|
| | 238 | text_out(" against %s, ", desc[i]); |
|---|
| | 239 | } |
|---|
| | 240 | |
|---|
| | 241 | text_out("and "); |
|---|
| | 242 | } |
|---|
| | 243 | |
|---|
| | 244 | if (dam % 10) |
|---|
| | 245 | text_out_c(TERM_L_GREEN, "%d.%d", dam / 10, dam % 10); |
|---|
| | 246 | else |
|---|
| | 247 | text_out_c(TERM_L_GREEN, "%d", dam / 10); |
|---|
| | 248 | |
|---|
| | 249 | text_out(" against normal creatures. "); |
|---|
| | 250 | |
|---|
| | 251 | /* You always have something to say... */ |
|---|
| | 252 | return TRUE; |
|---|