| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#include "angband.h" |
|---|
| 20 |
#include "game-event.h" |
|---|
| 21 |
#include "tvalsval.h" |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
struct flag_event_trigger |
|---|
| 25 |
{ |
|---|
| 26 |
u32b flag; |
|---|
| 27 |
game_event_type event; |
|---|
| 28 |
}; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
s16b modify_stat_value(int value, int amount) |
|---|
| 40 |
{ |
|---|
| 41 |
int i; |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
if (amount > 0) |
|---|
| 45 |
{ |
|---|
| 46 |
|
|---|
| 47 |
for (i = 0; i < amount; i++) |
|---|
| 48 |
{ |
|---|
| 49 |
|
|---|
| 50 |
if (value < 18) value++; |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
else value += 10; |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
else if (amount < 0) |
|---|
| 59 |
{ |
|---|
| 60 |
|
|---|
| 61 |
for (i = 0; i < (0 - amount); i++) |
|---|
| 62 |
{ |
|---|
| 63 |
|
|---|
| 64 |
if (value >= 18+10) value -= 10; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
else if (value > 18) value = 18; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
else if (value > 3) value--; |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
return (value); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
static void calc_spells(void) |
|---|
| 87 |
{ |
|---|
| 88 |
int i, j, k, levels; |
|---|
| 89 |
int num_allowed, num_known; |
|---|
| 90 |
int percent_spells; |
|---|
| 91 |
|
|---|
| 92 |
const magic_type *s_ptr; |
|---|
| 93 |
|
|---|
| 94 |
s16b old_spells; |
|---|
| 95 |
|
|---|
| 96 |
cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
if (!cp_ptr->spell_book) return; |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
if (!character_generated) return; |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
if (character_xtra) return; |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
old_spells = p_ptr->new_spells; |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
levels = p_ptr->lev - cp_ptr->spell_first + 1; |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
if (levels < 0) levels = 0; |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
percent_spells = adj_mag_study[p_ptr->stat_ind[cp_ptr->spell_stat]]; |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
num_allowed = (((percent_spells * levels) + 50) / 100); |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
num_known = 0; |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
for (j = 0; j < PY_MAX_SPELLS; j++) |
|---|
| 129 |
{ |
|---|
| 130 |
|
|---|
| 131 |
if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED) |
|---|
| 132 |
{ |
|---|
| 133 |
num_known++; |
|---|
| 134 |
} |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
p_ptr->new_spells = num_allowed - num_known; |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
for (i = PY_MAX_SPELLS - 1; i >= 0; i--) |
|---|
| 144 |
{ |
|---|
| 145 |
|
|---|
| 146 |
j = p_ptr->spell_order[i]; |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
if (j >= 99) continue; |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
s_ptr = &mp_ptr->info[j]; |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
if (s_ptr->slevel <= p_ptr->lev) continue; |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED) |
|---|
| 159 |
{ |
|---|
| 160 |
|
|---|
| 161 |
p_ptr->spell_flags[j] |= PY_SPELL_FORGOTTEN; |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
p_ptr->spell_flags[j] &= ~PY_SPELL_LEARNED; |
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
msg_format("You have forgotten the %s of %s.", p, |
|---|
| 168 |
get_spell_name(cp_ptr->spell_book, j)); |
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
p_ptr->new_spells++; |
|---|
| 172 |
} |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
for (i = PY_MAX_SPELLS - 1; i >= 0; i--) |
|---|
| 178 |
{ |
|---|
| 179 |
|
|---|
| 180 |
if (p_ptr->new_spells >= 0) break; |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
j = p_ptr->spell_order[i]; |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
if (j >= 99) continue; |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED) |
|---|
| 190 |
{ |
|---|
| 191 |
|
|---|
| 192 |
p_ptr->spell_flags[j] |= PY_SPELL_FORGOTTEN; |
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
p_ptr->spell_flags[j] &= ~PY_SPELL_LEARNED; |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
msg_format("You have forgotten the %s of %s.", p, |
|---|
| 199 |
get_spell_name(cp_ptr->spell_book, j)); |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
p_ptr->new_spells++; |
|---|
| 203 |
} |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
for (i = 0; i < PY_MAX_SPELLS; i++) |
|---|
| 209 |
{ |
|---|
| 210 |
|
|---|
| 211 |
if (p_ptr->new_spells <= 0) break; |
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
j = p_ptr->spell_order[i]; |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
if (j >= 99) break; |
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
s_ptr = &mp_ptr->info[j]; |
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
if (s_ptr->slevel > p_ptr->lev) continue; |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
if (p_ptr->spell_flags[j] & PY_SPELL_FORGOTTEN) |
|---|
| 227 |
{ |
|---|
| 228 |
|
|---|
| 229 |
p_ptr->spell_flags[j] &= ~PY_SPELL_FORGOTTEN; |
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
p_ptr->spell_flags[j] |= PY_SPELL_LEARNED; |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
msg_format("You have remembered the %s of %s.", |
|---|
| 236 |
p, get_spell_name(cp_ptr->spell_book, j)); |
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
p_ptr->new_spells--; |
|---|
| 240 |
} |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
k = 0; |
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
for (j = 0; j < PY_MAX_SPELLS; j++) |
|---|
| 249 |
{ |
|---|
| 250 |
|
|---|
| 251 |
s_ptr = &mp_ptr->info[j]; |
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
if (s_ptr->slevel > p_ptr->lev) continue; |
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED) |
|---|
| 258 |
{ |
|---|
| 259 |
continue; |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
k++; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
if (p_ptr->new_spells > k) p_ptr->new_spells = k; |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
if (old_spells != p_ptr->new_spells) |
|---|
| 271 |
{ |
|---|
| 272 |
|
|---|
| 273 |
if (p_ptr->new_spells) |
|---|
| 274 |
{ |
|---|
| 275 |
|
|---|
| 276 |
msg_format("You can learn %d more %s%s.", |
|---|
| 277 |
p_ptr->new_spells, p, |
|---|
| 278 |
(p_ptr->new_spells != 1) ? "s" : ""); |
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
p_ptr->redraw |= (PR_STUDY | PR_OBJECT); |
|---|
| 283 |
} |
|---|
| 284 |
} |
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
static void calc_mana(void) |
|---|
| 294 |
{ |
|---|
| 295 |
int msp, levels, cur_wgt, max_wgt; |
|---|
| 296 |
|
|---|
| 297 |
object_type *o_ptr; |
|---|
| 298 |
|
|---|
| 299 |
bool old_cumber_glove = p_ptr->cumber_glove; |
|---|
| 300 |
bool old_cumber_armor = p_ptr->cumber_armor; |
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
if (!cp_ptr->spell_book) return; |
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
levels = (p_ptr->lev - cp_ptr->spell_first) + 1; |
|---|
| 308 |
if (levels > 0) |
|---|
| 309 |
{ |
|---|
| 310 |
msp = 1; |
|---|
| 311 |
msp += adj_mag_mana[p_ptr->stat_ind[cp_ptr->spell_stat]] * levels / 100; |
|---|
| 312 |
} |
|---|
| 313 |
else |
|---|
| 314 |
{ |
|---|
| 315 |
levels = 0; |
|---|
| 316 |
msp = 0; |
|---|
| 317 |
} |
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
if (cp_ptr->flags & CF_CUMBER_GLOVE) |
|---|
| 321 |
{ |
|---|
| 322 |
u32b f1, f2, f3; |
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
p_ptr->cumber_glove = FALSE; |
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
o_ptr = &inventory[INVEN_HANDS]; |
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
object_flags(o_ptr, &f1, &f2, &f3); |
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 |
if (o_ptr->k_idx && |
|---|
| 335 |
!(f3 & (TR3_FREE_ACT)) && |
|---|
| 336 |
!((f1 & (TR1_DEX)) && (o_ptr->pval > 0))) |
|---|
| 337 |
{ |
|---|
| 338 |
|
|---|
| 339 |
p_ptr->cumber_glove = TRUE; |
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
msp = (3 * msp) / 4; |
|---|
| 343 |
} |
|---|
| 344 |
} |
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
p_ptr->cumber_armor = FALSE; |
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
cur_wgt = 0; |
|---|
| 352 |
cur_wgt += inventory[INVEN_BODY].weight; |
|---|
| 353 |
cur_wgt += inventory[INVEN_HEAD].weight; |
|---|
| 354 |
cur_wgt += inventory[INVEN_ARM].weight; |
|---|
| 355 |
cur_wgt += inventory[INVEN_OUTER].weight; |
|---|
| 356 |
cur_wgt += inventory[INVEN_HANDS].weight; |
|---|
| 357 |
cur_wgt += inventory[INVEN_FEET].weight; |
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
max_wgt = cp_ptr->spell_weight; |
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
if (((cur_wgt - max_wgt) / 10) > 0) |
|---|
| 364 |
{ |
|---|
| 365 |
|
|---|
| 366 |
p_ptr->cumber_armor = TRUE; |
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
msp -= ((cur_wgt - max_wgt) / 10); |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
if (msp < 0) msp = 0; |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
if (p_ptr->msp != msp) |
|---|
| 379 |
{ |
|---|
| 380 |
|
|---|
| 381 |
p_ptr->msp = msp; |
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
if (p_ptr->csp >= msp) |
|---|
| 385 |
{ |
|---|
| 386 |
p_ptr->csp = msp; |
|---|
| 387 |
p_ptr->csp_frac = 0; |
|---|
| 388 |
} |
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
p_ptr->redraw |= (PR_MANA); |
|---|
| 392 |
} |
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 |
if (character_xtra) return; |
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
if (old_cumber_glove != p_ptr->cumber_glove) |
|---|
| 400 |
{ |
|---|
| 401 |
|
|---|
| 402 |
if (p_ptr->cumber_glove) |
|---|
| 403 |
{ |
|---|
| 404 |
msg_print("Your covered hands feel unsuitable for spellcasting."); |
|---|
| 405 |
} |
|---|
| 406 |
else |
|---|
| 407 |
{ |
|---|
| 408 |
msg_print("Your hands feel more suitable for spellcasting."); |
|---|
| 409 |
} |
|---|
| 410 |
} |
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 |
if (old_cumber_armor != p_ptr->cumber_armor) |
|---|
| 415 |
{ |
|---|
| 416 |
|
|---|
| 417 |
if (p_ptr->cumber_armor) |
|---|
| 418 |
{ |
|---|
| 419 |
msg_print("The weight of your armor encumbers your movement."); |
|---|
| 420 |
} |
|---|
| 421 |
else |
|---|
| 422 |
{ |
|---|
| 423 |
msg_print("You feel able to move more freely."); |
|---|
| 424 |
} |
|---|
| 425 |
} |
|---|
| 426 |
} |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
static void calc_hitpoints(void) |
|---|
| 435 |
{ |
|---|
| 436 |
long bonus; |
|---|
| 437 |
int mhp; |
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
bonus = adj_con_mhp[p_ptr->stat_ind[A_CON]]; |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
mhp = p_ptr->player_hp[p_ptr->lev-1] + (bonus * p_ptr->lev / 100); |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1; |
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
if (p_ptr->mhp != mhp) |
|---|
| 450 |
{ |
|---|
| 451 |
|
|---|
| 452 |
p_ptr->mhp = mhp; |
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
if (p_ptr->chp >= mhp) |
|---|
| 456 |
{ |
|---|
| 457 |
p_ptr->chp = mhp; |
|---|
| 458 |
p_ptr->chp_frac = 0; |
|---|
| 459 |
} |
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
p_ptr->redraw |= (PR_HP); |
|---|
| 463 |
} |
|---|
| 464 |
} |
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
static void calc_torch(void) |
|---|
| 476 |
{ |
|---|
| 477 |
int i; |
|---|
| 478 |
|
|---|
| 479 |
s16b old_lite = p_ptr->cur_lite; |
|---|
| 480 |
bool burn_light = TRUE; |
|---|
| 481 |
|
|---|
| 482 |
s16b new_lite = 0; |
|---|
| 483 |
int extra_lite = 0; |
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
if (!p_ptr->depth && ((turn % (10L * TOWN_DAWN)) < ((10L * TOWN_DAWN) / 2))) |
|---|
| 489 |
burn_light = FALSE; |
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 |
|
|---|
| 493 |
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) |
|---|
| 494 |
{ |
|---|
| 495 |
u32b f1, f2, f3; |
|---|
| 496 |
|
|---|
| 497 |
int amt = 0; |
|---|
| 498 |
object_type *o_ptr = &inventory[i]; |
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
if (!o_ptr->k_idx) continue; |
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
object_flags(o_ptr, &f1, &f2, &f3); |
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
if (f3 & TR3_LIGHT_CURSE) |
|---|
| 508 |
{ |
|---|
| 509 |
amt = 0; |
|---|
| 510 |
} |
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
else if (o_ptr->tval == TV_LITE) |
|---|
| 514 |
{ |
|---|
| 515 |
int flag_inc = (f3 & TR3_LITE) ? 1 : 0; |
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
if (artifact_p(o_ptr)) |
|---|
| 519 |
amt = 3 + flag_inc; |
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
else if (!burn_light || o_ptr->timeout == 0) |
|---|
| 523 |
amt = 0; |
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
else |
|---|
| 527 |
{ |
|---|
| 528 |
amt = 2 + flag_inc; |
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
if (o_ptr->sval == SV_LITE_TORCH && o_ptr->timeout < (FUEL_TORCH / 4)) |
|---|
| 532 |
amt--; |
|---|
| 533 |
} |
|---|
| 534 |
} |
|---|
| 535 |
|
|---|
| 536 |
else |
|---|
| 537 |
{ |
|---|
| 538 |
|
|---|
| 539 |
if (f3 & TR3_LITE) extra_lite++; |
|---|
| 540 |
} |
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
if (new_lite < amt) |
|---|
| 544 |
new_lite = amt; |
|---|
| 545 |
} |
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
new_lite += extra_lite; |
|---|
| 549 |
|
|---|
| 550 |
|
|---|
| 551 |
new_lite = MIN(new_lite, 5); |
|---|
| 552 |
new_lite = MAX(new_lite, 0); |
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 |
if (old_lite != new_lite) |
|---|
| 556 |
{ |
|---|
| 557 |
|
|---|
| 558 |
p_ptr->cur_lite = new_lite; |
|---|
| 559 |
p_ptr->update |= (PU_UPDATE_VIEW | PU_MONSTERS); |
|---|
| 560 |
} |
|---|
| 561 |
} |
|---|
| 562 |
|
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
int calc_blows(const object_type *o_ptr) |
|---|
| 567 |
{ |
|---|
| 568 |
int blows; |
|---|
| 569 |
int str_index1, str_index2, dex_index1, dex_index2; |
|---|
| 570 |
int div; |
|---|
| 571 |
|
|---|
| 572 |
object_type *j_ptr = &inventory[INVEN_WIELD]; |
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
div = ((o_ptr->weight < cp_ptr->min_weight) ? cp_ptr->min_weight : o_ptr->weight); |
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
if (o_ptr == j_ptr) |
|---|
| 579 |
{ |
|---|
| 580 |
str_index1 = p_ptr->stat_ind[A_STR]; |
|---|
| 581 |
dex_index1 = p_ptr->stat_ind[A_DEX]; |
|---|
| 582 |
} |
|---|
| 583 |
else |
|---|
| 584 |
{ |
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
int str_change = 0, dex_change = 0; |
|---|
| 588 |
int new_str = p_ptr->stat_use[A_STR]; |
|---|
| 589 |
int new_dex = p_ptr->stat_use[A_DEX]; |
|---|
| 590 |
|
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
u32b jf1, jf2, jf3; |
|---|
| 594 |
u32b of1, of2, of3; |
|---|
| 595 |
|
|---|
| 596 |
|
|---|
| 597 |
object_flags(j_ptr, &jf1, &jf2, &jf3); |
|---|
| 598 |
if (jf1 & (TR1_STR)) str_change -= j_ptr->pval; |
|---|
| 599 |
if (jf1 & (TR1_DEX)) dex_change -= j_ptr->pval; |
|---|
| 600 |
|
|---|
| 601 |
|
|---|
| 602 |
object_flags(o_ptr, &of1, &of2, &of3); |
|---|
| 603 |
if (of1 & (TR1_STR)) str_change += o_ptr->pval; |
|---|
| 604 |
if (of1 & (TR1_DEX)) dex_change += o_ptr->pval; |
|---|
| 605 |
|
|---|
| 606 |
new_str = modify_stat_value(new_str, str_change); |
|---|
| 607 |
new_dex = modify_stat_value(new_dex, dex_change); |
|---|
| 608 |
|
|---|
| 609 |
if (new_str <= 18) |
|---|
| 610 |
str_index1 = new_str - 3; |
|---|
| 611 |
else if (new_str <= 18+219) |
|---|
| 612 |
str_index1 = (15 + (new_str - 18) / 10); |
|---|
| 613 |
else |
|---|
| 614 |
str_index1 = 37; |
|---|
| 615 |
|
|---|
| 616 |
if (new_dex <= 18) |
|---|
| 617 |
dex_index1 = new_dex - 3; |
|---|
| 618 |
else if (new_dex <= 18+219) |
|---|
| 619 |
dex_index1 = (15 + (new_dex - 18) / 10); |
|---|
| 620 |
else |
|---|
| 621 |
dex_index1 = 37; |
|---|
| 622 |
} |
|---|
| 623 |
|
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 |
str_index2 = (adj_str_blow[str_index1] * cp_ptr->att_multiply / div); |
|---|
| 627 |
|
|---|
| 628 |
|
|---|
| 629 |
if (str_index2 > 11) str_index2 = 11; |
|---|
| 630 |
|
|---|
| 631 |
|
|---|
| 632 |
dex_index2 = MIN(adj_dex_blow[dex_index1], 11); |
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 |
blows = MIN(blows_table[str_index2][dex_index2], cp_ptr->max_attacks); |
|---|
| 636 |
|
|---|
| 637 |
|
|---|
| 638 |
return MAX(blows, 1); |
|---|
| 639 |
} |
|---|
| 640 |
|
|---|
| 641 |
|
|---|
| 642 |
|
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 |
static int weight_limit(void) |
|---|
| 646 |
{ |
|---|
| 647 |
int i; |
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
i = adj_str_wgt[p_ptr->stat_ind[A_STR]] * 100; |
|---|
| 651 |
|
|---|
| 652 |
|
|---|
| 653 |
return (i); |
|---|
| 654 |
} |
|---|
| 655 |
|
|---|
| 656 |
|
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 |
|
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 |
|
|---|
| 666 |
|
|---|
| 667 |
|
|---|
| 668 |
|
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
|
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
|
|---|
| 677 |
static void calc_bonuses(void) |
|---|
| 678 |
{ |
|---|
| 679 |
int i, j, hold; |
|---|
| 680 |
|
|---|
| 681 |
int old_speed; |
|---|
| 682 |
|
|---|
| 683 |
int old_telepathy; |
|---|
| 684 |
int old_see_inv; |
|---|
| 685 |
|
|---|
| 686 |
int old_dis_ac; |
|---|
| 687 |
int old_dis_to_a; |
|---|
| 688 |
|
|---|
| 689 |
int extra_blows; |
|---|
| 690 |
int extra_shots; |
|---|
| 691 |
int extra_might; |
|---|
| 692 |
|
|---|
| 693 |
int old_stat_top[A_MAX]; |
|---|
| 694 |
int old_stat_use[A_MAX]; |
|---|
| 695 |
int old_stat_ind[A_MAX]; |
|---|
| 696 |
|
|---|
| 697 |
bool old_heavy_shoot; |
|---|
| 698 |
bool old_heavy_wield; |
|---|
| 699 |
bool old_icky_wield; |
|---|
| 700 |
|
|---|
| 701 |
object_type *o_ptr; |
|---|
| 702 |
|
|---|
| 703 |
u32b f1, f2, f3; |
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 |
|
|---|
| 708 |
|
|---|
| 709 |
old_speed = p_ptr->pspeed; |
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 |
old_telepathy = p_ptr->telepathy; |
|---|
| 713 |
old_see_inv = p_ptr->see_inv; |
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 |
old_dis_ac = p_ptr->dis_ac; |
|---|
| 717 |
old_dis_to_a = p_ptr->dis_to_a; |
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 |
for (i = 0; i < A_MAX; i++) |
|---|
| 721 |
{ |
|---|
| 722 |
old_stat_top[i] = p_ptr->stat_top[i]; |
|---|
| 723 |
old_stat_use[i] = p_ptr->stat_use[i]; |
|---|
| 724 |
old_stat_ind[i] = p_ptr->stat_ind[i]; |
|---|
| 725 |
} |
|---|
| 726 |
|
|---|
| 727 |
old_heavy_shoot = p_ptr->heavy_shoot; |
|---|
| 728 |
old_heavy_wield = p_ptr->heavy_wield; |
|---|
| 729 |
old_icky_wield = p_ptr->icky_wield; |
|---|
| 730 |
|
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
|
|---|
| 734 |
|
|---|
| 735 |
p_ptr->pspeed = 110; |
|---|
| 736 |
|
|---|
| 737 |
|
|---|
| 738 |
p_ptr->num_blow = 1; |
|---|
| 739 |
extra_blows = 0; |
|---|
| 740 |
|
|---|
| 741 |
|
|---|
| 742 |
p_ptr->num_fire = 0; |
|---|
| 743 |
p_ptr->ammo_mult = 0; |
|---|
| 744 |
p_ptr->ammo_tval = 0; |
|---|
| 745 |
extra_shots = 0; |
|---|
| 746 |
extra_might = 0; |
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 |
for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0; |
|---|
| 750 |
|
|---|
| 751 |
|
|---|
| 752 |
p_ptr->dis_ac = p_ptr->ac = 0; |
|---|
| 753 |
|
|---|
| 754 |
|
|---|
| 755 |
p_ptr->dis_to_h = p_ptr->to_h = 0; |
|---|
| 756 |
p_ptr->dis_to_d = p_ptr->to_d = 0; |
|---|
| 757 |
p_ptr->dis_to_a = p_ptr->to_a = 0; |
|---|
| 758 |
|
|---|
| 759 |
|
|---|
| 760 |
p_ptr->aggravate = FALSE; |
|---|
| 761 |
p_ptr->teleport = FALSE; |
|---|
| 762 |
p_ptr->exp_drain = FALSE; |
|---|
| 763 |
p_ptr->bless_blade = FALSE; |
|---|
| 764 |
p_ptr->impact = FALSE; |
|---|
| 765 |
p_ptr->see_inv = FALSE; |
|---|
| 766 |
p_ptr->free_act = FALSE; |
|---|
| 767 |
p_ptr->slow_digest = FALSE; |
|---|
| 768 |
p_ptr->impair_hp = FALSE; |
|---|
| 769 |
p_ptr->impair_mana = FALSE; |
|---|
| 770 |
p_ptr->regenerate = FALSE; |
|---|
| 771 |
p_ptr->ffall = FALSE; |
|---|
| 772 |
p_ptr->hold_life = FALSE; |
|---|
| 773 |
p_ptr->afraid = FALSE; |
|---|
| 774 |
p_ptr->telepathy = FALSE; |
|---|
| 775 |
p_ptr->sustain_str = FALSE; |
|---|
| 776 |
p_ptr->sustain_int = FALSE; |
|---|
| 777 |
p_ptr->sustain_wis = FALSE; |
|---|
| 778 |
p_ptr->sustain_con = FALSE; |
|---|
| 779 |
p_ptr->sustain_dex = FALSE; |
|---|
| 780 |
p_ptr->sustain_chr = FALSE; |
|---|
| 781 |
p_ptr->resist_acid = FALSE; |
|---|
| 782 |
p_ptr->resist_elec = FALSE; |
|---|
| 783 |
p_ptr->resist_fire = FALSE; |
|---|
| 784 |
p_ptr->resist_cold = FALSE; |
|---|
| 785 |
p_ptr->resist_pois = FALSE; |
|---|
| 786 |
p_ptr->resist_fear = FALSE; |
|---|
| 787 |
p_ptr->resist_lite = FALSE; |
|---|
| 788 |
p_ptr->resist_dark = FALSE; |
|---|
| 789 |
p_ptr->resist_blind = FALSE; |
|---|
| 790 |
p_ptr->resist_confu = FALSE; |
|---|
| 791 |
p_ptr->resist_sound = FALSE; |
|---|
| 792 |
p_ptr->resist_chaos = FALSE; |
|---|
| 793 |
p_ptr->resist_disen = FALSE; |
|---|
| 794 |
p_ptr->resist_shard = FALSE; |
|---|
| 795 |
p_ptr->resist_nexus = FALSE; |
|---|
| 796 |
p_ptr->resist_nethr = FALSE; |
|---|
| 797 |
p_ptr->immune_acid = FALSE; |
|---|
| 798 |
p_ptr->immune_elec = FALSE; |
|---|
| 799 |
p_ptr->immune_fire = FALSE; |
|---|
| 800 |
p_ptr->immune_cold = FALSE; |
|---|
| 801 |
p_ptr->vuln_acid = FALSE; |
|---|
| 802 |
p_ptr->vuln_elec = FALSE; |
|---|
| 803 |
p_ptr->vuln_fire = FALSE; |
|---|
| 804 |
p_ptr->vuln_cold = FALSE; |
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 |
|
|---|
| 808 |
|
|---|
| 809 |
|
|---|
| 810 |
p_ptr->see_infra = rp_ptr->infra; |
|---|
| 811 |
|
|---|
| 812 |
|
|---|
| 813 |
for (i = 0; i < SKILL_MAX_NO_RACE_CLASS; i++) |
|---|
| 814 |
{ |
|---|
| 815 |
p_ptr->skills[i] = rp_ptr->r_skills[i] + cp_ptr->c_skills[i]; |
|---|
| 816 |
} |
|---|
| 817 |
|
|---|
| 818 |
|
|---|
| 819 |
p_ptr->skills[SKILL_TO_HIT_THROW] = p_ptr->skills[SKILL_TO_HIT_BOW]; |
|---|
| 820 |
|
|---|
| 821 |
|
|---|
| 822 |
p_ptr->skills[SKILL_DIGGING] = 0; |
|---|
| 823 |
|
|---|
| 824 |
|
|---|
| 825 |
|
|---|
| 826 |
|
|---|
| 827 |
player_flags(&f1, &f2, &f3); |
|---|
| 828 |
|
|---|
| 829 |
|
|---|
| 830 |
if (f3 & (TR3_SLOW_DIGEST)) p_ptr->slow_digest = TRUE; |
|---|
| 831 |
if (f3 & (TR3_FEATHER)) p_ptr->ffall = TRUE; |
|---|
| 832 |
if (f3 & (TR3_REGEN)) p_ptr->regenerate = TRUE; |
|---|
| 833 |
if (f3 & (TR3_TELEPATHY)) p_ptr->telepathy = TRUE; |
|---|
| 834 |
if (f3 & (TR3_SEE_INVIS)) p_ptr->see_inv = TRUE; |
|---|
| 835 |
if (f3 & (TR3_FREE_ACT)) p_ptr->free_act = TRUE; |
|---|
| 836 |
if (f3 & (TR3_HOLD_LIFE)) p_ptr->hold_life = TRUE; |
|---|
| 837 |
|
|---|
| 838 |
|
|---|
| 839 |
if (f3 & (TR3_BLESSED)) p_ptr->bless_blade = TRUE; |
|---|
| 840 |
|
|---|
| 841 |
|
|---|
| 842 |
if (f3 & (TR3_IMPACT)) p_ptr->impact = TRUE; |
|---|
| 843 |
if (f3 & (TR3_AGGRAVATE)) p_ptr->aggravate = TRUE; |
|---|
| 844 |
if (f3 & (TR3_TELEPORT)) p_ptr->teleport = TRUE; |
|---|
| 845 |
if (f3 & (TR3_DRAIN_EXP)) p_ptr->exp_drain = TRUE; |
|---|
| 846 |
if (f3 & (TR3_IMPAIR_HP)) p_ptr->impair_hp = TRUE; |
|---|
| 847 |
if (f3 & (TR3_IMPAIR_MANA)) p_ptr->impair_mana = TRUE; |
|---|
| 848 |
if (f3 & (TR3_AFRAID)) p_ptr->afraid = TRUE; |
|---|
| 849 |
|
|---|
| 850 |
|
|---|
| 851 |
if (f2 & (TR2_VULN_FIRE)) p_ptr->vuln_fire = TRUE; |
|---|
| 852 |
if (f2 & (TR2_VULN_ACID)) p_ptr->vuln_acid = TRUE; |
|---|
| 853 |
if (f2 & (TR2_VULN_COLD)) p_ptr->vuln_cold = TRUE; |
|---|
| 854 |
if (f2 & (TR2_VULN_ELEC)) p_ptr->vuln_elec = TRUE; |
|---|
| 855 |
|
|---|
| 856 |
|
|---|
| 857 |
if (f2 & (TR2_IM_FIRE)) p_ptr->immune_fire = TRUE; |
|---|
| 858 |
if (f2 & (TR2_IM_ACID)) p_ptr->immune_acid = TRUE; |
|---|
| 859 |
if (f2 & (TR2_IM_COLD)) p_ptr->immune_cold = TRUE; |
|---|
| 860 |
if (f2 & (TR2_IM_ELEC)) p_ptr->immune_elec = TRUE; |
|---|
| 861 |
|
|---|
| 862 |
|
|---|
| 863 |
if (f2 & (TR2_RES_ACID)) p_ptr->resist_acid = TRUE; |
|---|
| 864 |
if (f2 & (TR2_RES_ELEC)) p_ptr->resist_elec = TRUE; |
|---|
| 865 |
if (f2 & (TR2_RES_FIRE)) p_ptr->resist_fire = TRUE; |
|---|
| 866 |
if (f2 & (TR2_RES_COLD)) p_ptr->resist_cold = TRUE; |
|---|
| 867 |
if (f2 & (TR2_RES_POIS)) p_ptr->resist_pois = TRUE; |
|---|
| 868 |
if (f2 & (TR2_RES_FEAR)) p_ptr->resist_fear = TRUE; |
|---|
| 869 |
if (f2 & (TR2_RES_LITE)) p_ptr->resist_lite = TRUE; |
|---|
| 870 |
if (f2 & (TR2_RES_DARK)) p_ptr->resist_dark = TRUE; |
|---|
| 871 |
if (f2 & (TR2_RES_BLIND)) p_ptr->resist_blind = TRUE; |
|---|
| 872 |
if (f2 & (TR2_RES_CONFU)) p_ptr->resist_confu = TRUE; |
|---|
| 873 |
if (f2 & (TR2_RES_SOUND)) p_ptr->resist_sound = TRUE; |
|---|
| 874 |
if (f2 & (TR2_RES_SHARD)) p_ptr->resist_shard = TRUE; |
|---|
| 875 |
if (f2 & (TR2_RES_NEXUS)) p_ptr->resist_nexus = TRUE; |
|---|
| 876 |
if (f2 & (TR2_RES_NETHR)) p_ptr->resist_nethr = TRUE; |
|---|
| 877 |
if (f2 & (TR2_RES_CHAOS)) p_ptr->resist_chaos = TRUE; |
|---|
| 878 |
if (f2 & (TR2_RES_DISEN)) p_ptr->resist_disen = TRUE; |
|---|
| 879 |
|
|---|
| 880 |
|
|---|
| 881 |
if (f2 & (TR2_SUST_STR)) p_ptr->sustain_str = TRUE; |
|---|
| 882 |
if (f2 & (TR2_SUST_INT)) p_ptr->sustain_int = TRUE; |
|---|
| 883 |
if (f2 & (TR2_SUST_WIS)) p_ptr->sustain_wis = TRUE; |
|---|
| 884 |
if (f2 & (TR2_SUST_DEX)) p_ptr->sustain_dex = TRUE; |
|---|
| 885 |
if (f2 & (TR2_SUST_CON)) p_ptr->sustain_con = TRUE; |
|---|
| 886 |
if (f2 & (TR2_SUST_CHR)) p_ptr->sustain_chr = TRUE; |
|---|
| 887 |
|
|---|
| 888 |
|
|---|
| 889 |
|
|---|
| 890 |
|
|---|
| 891 |
|
|---|
| 892 |
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) |
|---|
| 893 |
{ |
|---|
| 894 |
o_ptr = &inventory[i]; |
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 |
if (!o_ptr->k_idx) continue; |
|---|
| 898 |
|
|---|
| 899 |
|
|---|
| 900 |
object_flags(o_ptr, &f1, &f2, &f3); |
|---|
| 901 |
|
|---|
| 902 |
|
|---|
| 903 |
if (f1 & (TR1_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval; |
|---|
| 904 |
if (f1 & (TR1_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval; |
|---|
| 905 |
if (f1 & (TR1_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval; |
|---|
| 906 |
if (f1 & (TR1_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval; |
|---|
| 907 |
if (f1 & (TR1_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval; |
|---|
| 908 |
if (f1 & (TR1_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval; |
|---|
| 909 |
|
|---|
| 910 |
|
|---|
| 911 |
if (f1 & (TR1_STEALTH)) p_ptr->skills[SKILL_STEALTH] += o_ptr->pval; |
|---|
| 912 |
|
|---|
| 913 |
|
|---|
| 914 |
if (f1 & (TR1_SEARCH)) p_ptr->skills[SKILL_SEARCH] += (o_ptr->pval * 5); |
|---|
| 915 |
|
|---|
| 916 |
|
|---|
| 917 |
if (f1 & (TR1_SEARCH)) p_ptr->skills[SKILL_SEARCH_FREQUENCY] += (o_ptr->pval * 5); |
|---|
| 918 |
|
|---|
| 919 |
|
|---|
| 920 |
if (f1 & (TR1_INFRA)) p_ptr->see_infra += o_ptr->pval; |
|---|
| 921 |
|
|---|
| 922 |
|
|---|
| 923 |
if (f1 & (TR1_TUNNEL)) p_ptr->skills[SKILL_DIGGING] += (o_ptr->pval * 20); |
|---|
| 924 |
|
|---|
| 925 |
|
|---|
| 926 |
if (f1 & (TR1_SPEED)) p_ptr->pspeed += o_ptr->pval; |
|---|
| 927 |
|
|---|
| 928 |
|
|---|