Changeset 1000
- Timestamp:
- 10/01/08 03:07:19 (3 months ago)
- Files:
-
- trunk/src/object/obj-info.c (modified) (1 diff)
- trunk/src/player/calcs.c (modified) (5 diffs)
- trunk/src/player/player.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/object/obj-info.c
r999 r1000 361 361 if (weapon) 362 362 { 363 int blows = calc_blows(o_ptr); 364 365 if (f1 & (TR1_BLOWS)) blows += o_ptr->pval; 363 /* 364 * Get the player's hypothetical state, were they to be 365 * wielding this item. 366 */ 367 player_state state; 368 object_type inven[INVEN_TOTAL]; 369 370 memcpy(inven, inventory, INVEN_TOTAL * sizeof(object_type)); 371 inven[INVEN_WIELD] = *o_ptr; 372 373 calc_bonuses(inven, &state); 374 366 375 367 376 dam = ((o_ptr->ds + 1) * o_ptr->dd * 5); 368 369 xtra_dam = (p_ptr->state.to_d * 10); 370 if (object_known_p(o_ptr)) 371 xtra_dam += (o_ptr->to_d * 10); 377 xtra_dam = state.dis_to_d * 10; 372 378 373 379 /* Warn about heavy weapons */ 374 if (adj_str_hold[p_ptr->state.stat_ind[A_STR]] < o_ptr->weight / 10) 375 { 380 if (adj_str_hold[state.stat_ind[A_STR]] < o_ptr->weight / 10) 376 381 text_out_c(TERM_L_RED, "You are too weak to use this weapon effectively!\n"); 377 blows = 1;378 }379 382 380 383 text_out("With this weapon, you would currently get "); 381 text_out_c(TERM_L_GREEN, format("%d ", blows));382 if ( blows> 1)384 text_out_c(TERM_L_GREEN, format("%d ", state.num_blow)); 385 if (state.num_blow > 1) 383 386 text_out("blows per round. Each blow will do an average damage of "); 384 387 else trunk/src/player/calcs.c
r999 r1000 510 510 * Calculate the blows a player would get, in current condition, wielding "o_ptr". 511 511 */ 512 int calc_blows(const object_type *o_ptr)512 static int calc_blows(const object_type *o_ptr, player_state *state) 513 513 { 514 514 int blows; 515 int str_index 1, str_index2, dex_index1, dex_index2;515 int str_index, dex_index; 516 516 int div; 517 518 object_type *j_ptr = &inventory[INVEN_WIELD];519 517 520 518 /* Enforce a minimum "weight" (tenth pounds) */ 521 519 div = ((o_ptr->weight < cp_ptr->min_weight) ? cp_ptr->min_weight : o_ptr->weight); 522 520 523 /* If we're wielding this weapon, use the current stats */524 if (o_ptr == j_ptr)525 {526 str_index1 = p_ptr->state.stat_ind[A_STR];527 dex_index1 = p_ptr->state.stat_ind[A_DEX];528 }529 else530 {531 /* Recalculate bonuses as if we were wielding this weapon */532 533 int str_change = 0, dex_change = 0;534 int new_str = p_ptr->state.stat_use[A_STR];535 int new_dex = p_ptr->state.stat_use[A_DEX];536 537 /* object_type *j_ptr = &inventory[INVEN_WIELD]; */538 539 u32b jf1, jf2, jf3;540 u32b of1, of2, of3;541 542 /* Examine the wielded weapon */543 object_flags(j_ptr, &jf1, &jf2, &jf3);544 if (jf1 & (TR1_STR)) str_change -= j_ptr->pval;545 if (jf1 & (TR1_DEX)) dex_change -= j_ptr->pval;546 547 /* Examine the weapon in the pack*/548 object_flags(o_ptr, &of1, &of2, &of3);549 if (of1 & (TR1_STR)) str_change += o_ptr->pval;550 if (of1 & (TR1_DEX)) dex_change += o_ptr->pval;551 552 new_str = modify_stat_value(new_str, str_change);553 new_dex = modify_stat_value(new_dex, dex_change);554 555 if (new_str <= 18)556 str_index1 = new_str - 3;557 else if (new_str <= 18+219)558 str_index1 = (15 + (new_str - 18) / 10);559 else560 str_index1 = 37;561 562 if (new_dex <= 18)563 dex_index1 = new_dex - 3;564 else if (new_dex <= 18+219)565 dex_index1 = (15 + (new_dex - 18) / 10);566 else567 dex_index1 = 37;568 }569 570 571 521 /* Get the strength vs weight */ 572 str_index2 = (adj_str_blow[str_index1] * cp_ptr->att_multiply / div); 522 str_index = adj_str_blow[p_ptr->state.stat_ind[A_STR]] * 523 cp_ptr->att_multiply / div; 573 524 574 525 /* Maximal value */ 575 if (str_index 2 > 11) str_index2= 11;526 if (str_index > 11) str_index = 11; 576 527 577 528 /* Index by dexterity */ 578 dex_index 2 = MIN(adj_dex_blow[dex_index1], 11);529 dex_index = MIN(adj_dex_blow[p_ptr->state.stat_ind[A_DEX]], 11); 579 530 580 531 /* Use the blows table */ 581 blows = MIN(blows_table[str_index 2][dex_index2], cp_ptr->max_attacks);532 blows = MIN(blows_table[str_index][dex_index], cp_ptr->max_attacks); 582 533 583 534 /* Require at least one blow */ … … 589 540 * Computes current weight limit. 590 541 */ 591 static int weight_limit( void)542 static int weight_limit(player_state *state) 592 543 { 593 544 int i; 594 545 595 546 /* Weight limit based only on strength */ 596 i = adj_str_wgt[ p_ptr->state.stat_ind[A_STR]] * 100;547 i = adj_str_wgt[state->stat_ind[A_STR]] * 100; 597 548 598 549 /* Return the result */ … … 619 570 * are actually added in later, at the appropriate place. 620 571 */ 621 staticvoid calc_bonuses(object_type inventory[], player_state *state)572 void calc_bonuses(object_type inventory[], player_state *state) 622 573 { 623 574 int i, j, hold; … … 956 907 957 908 /* Extract the "weight limit" (in tenth pounds) */ 958 i = weight_limit( );909 i = weight_limit(state); 959 910 960 911 /* Apply "encumbrance" from weight */ … … 1145 1096 { 1146 1097 /* Calculate number of blows */ 1147 state->num_blow = calc_blows(o_ptr ) + extra_blows;1098 state->num_blow = calc_blows(o_ptr, state) + extra_blows; 1148 1099 1149 1100 /* Boost digging skill by weapon weight */ trunk/src/player/player.h
r996 r1000 1 1 /* calcs.c */ 2 int calc_blows(const object_type *o_ptr);2 void calc_bonuses(object_type inventory[], player_state *state); 3 3 void notice_stuff(void); 4 4 void update_stuff(void);
