Changeset 336

Show
Ignore:
Timestamp:
07/13/07 18:54:23 (1 year ago)
Author:
takkaria
Message:
  • Implement weapon and ammo damage display. (closes #26)
  • Fix some warnings.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/effects.c

    r325 r336  
    10261026                { 
    10271027                        if (!p_ptr->timed[TMD_FAST]) 
     1028                        { 
    10281029                                if (set_timed(TMD_FAST, damroll(2, 10) + 20)) *ident = TRUE; 
     1030                        } 
    10291031                        else 
     1032                        { 
    10301033                                (void)inc_timed(TMD_FAST, 5); 
     1034                        } 
    10311035 
    10321036                        return TRUE; 
     
    10361040                { 
    10371041                        if (!p_ptr->timed[TMD_FAST]) 
     1042                        { 
    10381043                                if (set_timed(TMD_FAST, randint(20) + 20)) *ident = TRUE; 
     1044                        } 
    10391045                        else 
     1046                        { 
    10401047                                (void)inc_timed(TMD_FAST, 5); 
     1048                        } 
    10411049 
    10421050                        return TRUE; 
     
    10461054                { 
    10471055                        if (!p_ptr->timed[TMD_FAST]) 
     1056                        { 
    10481057                                if (set_timed(TMD_FAST, randint(75) + 75)) *ident = TRUE; 
     1058                        } 
    10491059                        else 
     1060                        { 
    10501061                                (void)inc_timed(TMD_FAST, 5); 
     1062                        } 
    10511063 
    10521064                        return TRUE; 
  • trunk/src/externs.h

    r325 r336  
    691691extern void cnv_stat(int val, char *out_val, size_t len); 
    692692extern s16b modify_stat_value(int value, int amount); 
     693extern int calc_blows(const object_type *o_ptr); 
    693694extern void notice_stuff(void); 
    694695extern void update_stuff(void); 
  • trunk/src/monster1.c

    r313 r336  
    139139} 
    140140 
    141  
     141/* 
     142 * Dump flavour text 
     143 */ 
    142144static void describe_monster_desc(int r_idx) 
    143145{ 
    144146        const monster_race *r_ptr = &r_info[r_idx]; 
    145         char buf[2048]; 
    146  
    147         /* Dump it */ 
    148         text_out(r_text + r_ptr->text); 
    149         text_out("\n"); 
     147        text_out("%s\n", r_text + r_ptr->text); 
    150148} 
    151149 
     
    353351        const monster_race *r_ptr = &r_info[r_idx]; 
    354352 
    355         bool sin = FALSE; 
    356  
    357353        int n; 
    358  
    359         const char *p = NULL; 
    360  
    361354        int msex = 0; 
    362355 
     
    567560        const monster_race *r_ptr = &r_info[r_idx]; 
    568561 
    569         int n; 
    570         bool prev = FALSE; 
    571  
    572562        int vn; 
    573563        cptr vp[64]; 
    574  
     564        bool prev = FALSE; 
     565         
    575566        int msex = 0; 
    576567 
  • trunk/src/obj-info.c

    r325 r336  
    150150} 
    151151 
    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 */ 
     155static int collect_slays(cptr desc[], int mult[], u32b f1) 
     156
    223157        int cnt = 0; 
    224158 
    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 */ 
     187static 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; 
    240253} 
    241254 
     
    566579 
    567580 
    568         /* Describe the object */ 
     581        /* Describe combat bits */ 
     582        new_paragraph = TRUE; 
     583        if (describe_combat(o_ptr, f1)) something = TRUE; 
     584 
     585        /* Describe other bits */ 
    569586        new_paragraph = TRUE; 
    570587        if (describe_stats(o_ptr, f1)) something = TRUE; 
    571         if (describe_slay(o_ptr, f1)) something = TRUE; 
    572         if (describe_brand(o_ptr, f1)) something = TRUE; 
    573588        if (describe_immune(o_ptr, f2, f3)) something = TRUE; 
    574589        if (describe_sustains(o_ptr, f2)) something = TRUE; 
  • trunk/src/store.c

    r321 r336  
    174174 
    175175        const char *owner_name = &b_name[ot_ptr->owner_name]; 
    176         int i = p_ptr->lev / 5; 
     176        int i = (p_ptr->lev - 1) / 5; 
    177177 
    178178        /* Only show the message one in four times to stop it being irritating. */ 
    179179        if (!rand_int(4)) return; 
    180  
    181         /* Make sure level 50 players don't overflow */ 
    182         i = MIN(i, N_ELEMENTS(comment_welcome) - 1); 
    183180 
    184181        /* Welcome the character */ 
  • trunk/src/xtra1.c

    r311 r336  
    602602struct state_info 
    603603{ 
    604         size_t value; 
     604        int value; 
    605605        const char *str; 
    606606        size_t len; 
     
    16131613                p_ptr->update |= (PU_UPDATE_VIEW | PU_MONSTERS); 
    16141614        } 
     1615} 
     1616 
     1617/* 
     1618 * Calculate the blows a player would get, in current condition, wielding "o_ptr". 
     1619 */ 
     1620int calc_blows(const object_type *o_ptr) 
     1621{ 
     1622        int blows; 
     1623        int str_index, dex_index; 
     1624        int div; 
     1625 
     1626        /* Enforce a minimum "weight" (tenth pounds) */ 
     1627        div = ((o_ptr->weight < cp_ptr->min_weight) ? cp_ptr->min_weight : o_ptr->weight); 
     1628 
     1629        /* Get the strength vs weight */ 
     1630        str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * cp_ptr->att_multiply / div); 
     1631 
     1632        /* Maximal value */ 
     1633        if (str_index > 11) str_index = 11; 
     1634 
     1635        /* Index by dexterity */ 
     1636        dex_index = MIN(adj_dex_blow[p_ptr->stat_ind[A_DEX]], 11); 
     1637 
     1638        /* Use the blows table */ 
     1639        blows = MIN(blows_table[str_index][dex_index], cp_ptr->max_attacks); 
     1640 
     1641        /* Require at least one blow */ 
     1642        return MAX(blows, 1); 
    16151643} 
    16161644 
     
    23372365        if (o_ptr->k_idx && !p_ptr->heavy_wield) 
    23382366        { 
    2339                 int str_index, dex_index; 
    2340  
    2341                 int div; 
    2342  
    2343                 /* Enforce a minimum "weight" (tenth pounds) */ 
    2344                 div = ((o_ptr->weight < cp_ptr->min_weight) ? cp_ptr->min_weight : o_ptr->weight); 
    2345  
    2346                 /* Get the strength vs weight */ 
    2347                 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * cp_ptr->att_multiply / div); 
    2348  
    2349                 /* Maximal value */ 
    2350                 if (str_index > 11) str_index = 11; 
    2351  
    2352                 /* Index by dexterity */ 
    2353                 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]); 
    2354  
    2355                 /* Maximal value */ 
    2356                 if (dex_index > 11) dex_index = 11; 
    2357  
    2358                 /* Use the blows table */ 
    2359                 p_ptr->num_blow = blows_table[str_index][dex_index]; 
    2360  
    2361                 /* Maximal value */ 
    2362                 if (p_ptr->num_blow > cp_ptr->max_attacks) p_ptr->num_blow = cp_ptr->max_attacks; 
    2363  
    2364                 /* Add in the "bonus blows" */ 
    2365                 p_ptr->num_blow += extra_blows; 
    2366  
    2367                 /* Require at least one blow */ 
    2368                 if (p_ptr->num_blow < 1) p_ptr->num_blow = 1; 
     2367                /* Calculate number of blows */ 
     2368                p_ptr->num_blow = calc_blows(o_ptr) + extra_blows;; 
    23692369 
    23702370                /* Boost digging skill by weapon weight */