Ticket #1693: 0001-Anomalous-races-Use-points-to-keep-stats-above-3.patch

File 0001-Anomalous-races-Use-points-to-keep-stats-above-3.patch, 2.4 KB (added by daniel.santos, 7 years ago)
  • src/birth.c

    From 640ab4ffa99e7b5eac2cf864f459c761f477efb7 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 01/11] Anomalous races: Use points to keep stats above 3
    
    Currently, no matter how badly a stat is adjusted downwards, it the
    "best" value will always result in three.  In fact, it can never go
    below that point.  Such an assumption makes sense in the face of
    existing race/class combinations, but future races (e.g., Trolls) and/or
    classes could bring the baseline lower.  As is, the code will give them
    a free upgrade to 3 and we don't want that.
    
    This patch will force the usage of spendable stat points to bring all
    stats up to three.
    ---
     src/birth.c |   27 +++++++++++++++++++++++----
     1 files changed, 23 insertions(+), 4 deletions(-)
    
    diff --git a/src/birth.c b/src/birth.c
    index 8618bcd..3f34bce 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 >= -7) 
     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 
    694707static bool sell_stat(int choice, int stats[A_MAX], int points_spent[A_MAX], 
    695708        int *points_left, bool update_display) 
    696709{ 
    697         /* Must be a valid stat, and we can't "sell" stats below the base of 10. */ 
     710        /* Must be a valid stat, and we can't "sell" stats below the base of 10 
     711         * or best of 3. 
     712         */ 
    698713        if (!(choice >= A_MAX || choice < 0) && (stats[choice] > 10)) 
    699714        { 
     715                int adj = p_ptr->race->r_adj[choice] + p_ptr->class->c_adj[choice]; 
    700716                int stat_cost = birth_stat_costs[stats[choice]]; 
    701717 
     718                if ((stats[choice] + adj) <= 3) 
     719                        return FALSE; 
     720 
    702721                stats[choice]--; 
    703722                points_spent[choice] -= stat_cost; 
    704723                *points_left += stat_cost;