version 1.26 | | version 1.27 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.26 2000/12/15 20:23:52 peterm Exp $"; | | * "$Id: apply.c,v 1.27 2000/12/18 02:45:56 peterm Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
} | | } |
| | |
void apply_changes_to_player(object *player, object *change) { | | void apply_changes_to_player(object *player, object *change) { |
| | int excess_stat=0; /* if the stat goes over the maximum |
| | for the race, put the excess stat some |
| | where else. */ |
switch (change->type) { | | switch (change->type) { |
case CLASS: | | case CLASS: |
{ | | { |
| | |
object *walk; | | object *walk; |
int flag_change_face=1; | | int flag_change_face=1; |
| | |
/* reshuffle the stats */ | | /* the following code assigns stats up to the stat max |
stats->Str += ns->Str; | | for the race, and if the stat max is exceeded, |
stats->Dex += ns->Dex; | | tries to randomly reassign the excess stat */ |
stats->Con += ns->Con; | | int i,j; |
stats->Int += ns->Int; | | for(i=0;i<7;i++) { |
stats->Wis += ns->Wis; | | int stat=get_attr_value(stats,i); |
stats->Pow += ns->Pow; | | int race_bonus = get_attr_value(&(player->arch->clone.stats),i); |
stats->Cha += ns->Cha; | | stat += get_attr_value(ns,i); |
| | if(stat > 20 + race_bonus) { |
| | excess_stat++; |
| | stat = 20+race_bonus; |
| | } |
| | set_attr_value(stats,i,stat); |
| | } |
| | for(j=0;excess_stat >0 && j<100;j++) {/* try 100 times to assign excess stats */ |
| | int i = RANDOM() %7; |
| | int stat=get_attr_value(stats,i); |
| | int race_bonus = get_attr_value(&(player->arch->clone.stats),i); |
| | if(i==CHA) continue; /* exclude cha from this */ |
| | if( stat < 20 + race_bonus) { |
| | change_attr_value(stats,i,1); |
| | excess_stat--; |
| | } |
| | } |
| | |
/* insert the randomitems from the change's treasurelist into | | /* insert the randomitems from the change's treasurelist into |
the player ref: player.c*/ | | the player ref: player.c*/ |