Changeset 194

Show
Ignore:
Timestamp:
06/18/07 15:35:19 (1 year ago)
Author:
andrewdoull
Message:

Allow weapons and armour to be damaged instead of destroyed by inventory damage effects.

Files:

Legend:

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

    r152 r194  
    753753 
    754754        char o_name[80]; 
    755  
     755         
     756        bool damage; 
    756757 
    757758        /* Count the casualties */ 
     
    775776                        int chance = perc * 100; 
    776777 
    777                         /* Rods are tough */ 
    778                         if (o_ptr->tval == TV_ROD) chance = (chance / 4); 
     778                        damage = FALSE; 
     779 
     780                        /* Analyze the type to see if we just damage it */ 
     781                        switch (o_ptr->tval) 
     782                        { 
     783                                /* Weapons */ 
     784                                case TV_BOW: 
     785                                case TV_SWORD: 
     786                                case TV_HAFTED: 
     787                                case TV_POLEARM: 
     788                                case TV_DIGGING: 
     789                                { 
     790                                        /* Chance to damage it */ 
     791                                        if (rand_int(100) < perc) 
     792                                        { 
     793                                                /* Damage the item */ 
     794                                                o_ptr->to_h--; 
     795                                                o_ptr->to_d--; 
     796 
     797                                                /* Damaged! */ 
     798                                                damage = TRUE; 
     799                                        } 
     800                                        else continue; 
     801 
     802                                        break; 
     803                                } 
     804 
     805                                /* Wearable items */ 
     806                                case TV_HELM: 
     807                                case TV_CROWN: 
     808                                case TV_SHIELD: 
     809                                case TV_BOOTS: 
     810                                case TV_GLOVES: 
     811                                case TV_CLOAK: 
     812                                case TV_SOFT_ARMOR: 
     813                                case TV_HARD_ARMOR: 
     814                                case TV_DRAG_ARMOR: 
     815                                { 
     816                                        /* Chance to damage it */ 
     817                                        if (rand_int(100) < perc) 
     818                                        { 
     819                                                /* Damage the item */ 
     820                                                o_ptr->to_a--; 
     821 
     822                                                /* Damaged! */ 
     823                                                damage = TRUE; 
     824                                        } 
     825                                        else continue; 
     826 
     827                                        break; 
     828                                } 
     829                                 
     830                                /* Rods are tough */ 
     831                                case TV_ROD: 
     832                                { 
     833                                        chance = (chance / 4); 
     834                                         
     835                                        break; 
     836                                } 
     837                        } 
     838 
     839                        /* Damage instead of destroy */ 
     840                        if (damage) 
     841                        { 
     842                                /* Calculate bonuses */ 
     843                                p_ptr->update |= (PU_BONUS); 
     844 
     845                                /* Window stuff */ 
     846                                p_ptr->window |= (PW_EQUIP | PW_PLAYER_0 | PW_PLAYER_1); 
     847 
     848                                /* Casualty count */ 
     849                                amt = o_ptr->number; 
     850                        } 
    779851 
    780852                        /* Count the casualties */ 
    781                         for (amt = j = 0; j < o_ptr->number; ++j) 
     853                        else for (amt = j = 0; j < o_ptr->number; ++j) 
    782854                        { 
    783855                                if (rand_int(10000) < chance) amt++; 
     
    791863 
    792864                                /* Message */ 
    793                                 message_format(MSG_DESTROY, 0, "%sour %s (%c) %s destroyed!", 
     865                                message_format(MSG_DESTROY, 0, "%sour %s (%c) %s %s!", 
    794866                                           ((o_ptr->number > 1) ? 
    795867                                            ((amt == o_ptr->number) ? "All of y" : 
    796868                                             (amt > 1 ? "Some of y" : "One of y")) : "Y"), 
    797869                                           o_name, index_to_label(i), 
    798                                            ((amt > 1) ? "were" : "was")); 
     870                                           ((amt > 1) ? "were" : "was"), 
     871                                           (damage ? "damaged" : "destroyed")); 
     872 
     873                                /* Damage already done? */ 
     874                                if (damage) continue; 
    799875 
    800876                                /* Hack -- If rods, wands, or staves are destroyed, the total