Ticket #1693: 0002-Do-not-allow-stats-below-3-and-force-usage-of-points.patch

File 0002-Do-not-allow-stats-below-3-and-force-usage-of-points.patch, 1.9 KB (added by daniel.santos, 7 years ago)
  • src/birth.c

    From 531231a75250008d187c609b60cc486d7e930b76 Mon Sep 17 00:00:00 2001
    From: Daniel Santos <daniel.santos@pobox.com>
    Date: Mon, 15 Oct 2012 01:39:09 -0500
    Subject: [PATCH v2 2/3] Do not allow stats below 3 and force usage of points to get them there
    
    ---
     src/birth.c |   27 +++++++++++++++++++++++----
     1 files changed, 23 insertions(+), 4 deletions(-)
    
    diff --git a/src/birth.c b/src/birth.c
    index 8d0f45e..3c769af 100644
    a b static void reset_stats(int stats[A_MAX], int points_spent[A_MAX], int *points_l 
    642642 
    643643        for (i = 0; i < A_MAX; i++) 
    644644        { 
    645                 /* Initial stats are all 10 and costs are zero */ 
    646                 stats[i] = 10; 
    647                 points_spent[i] = 0; 
     645                /* Initial stats are all 10 and costs are zero, unless race and class 
     646                 * adjustments bring it below 3, in which case we force them to spend 
     647                 * points to bring it up to 3, considering that the minimum acceptable. 
     648                 * to be an adventurer. 
     649                 */ 
     650                int adj = p_ptr->race->r_adj[i] + p_ptr->class->c_adj[i]; 
     651                int penalty; 
     652 
     653                if (adj > -8) 
     654                        penalty = 0; 
     655                else 
     656                        penalty = -(adj + 7); 
     657 
     658                stats[i] = 10 + penalty; 
     659                points_spent[i] = penalty; 
     660                *points_left -= penalty; 
    648661        } 
    649662 
    650663        /* Use the new "birth stat" values to work out the "other" 
    static bool buy_stat(int choice, int stats[A_MAX], int points_spent[A_MAX], int 
    688701static bool sell_stat(int choice, int stats[A_MAX], int points_spent[A_MAX], 
    689702                                          int *points_left) 
    690703{ 
    691         /* Must be a valid stat, and we can't "sell" stats below the base of 10. */ 
     704        /* Must be a valid stat, and we can't "sell" stats below the base of 10 
     705         * or best of 3. 
     706         */ 
    692707        if (!(choice >= A_MAX || choice < 0) && (stats[choice] > 10)) 
    693708        { 
     709                int adj = p_ptr->race->r_adj[choice] + p_ptr->class->c_adj[choice]; 
    694710                int stat_cost = birth_stat_costs[stats[choice]]; 
    695711 
     712                if ((stats[choice] + adj) <= 3) 
     713                        return FALSE; 
     714 
    696715                stats[choice]--; 
    697716                points_spent[choice] -= stat_cost; 
    698717                *points_left += stat_cost;