version 1.3 | | version 1.4 |
---|
| | |
| | |
/* | | /* |
* static char *rcs_treasure_c = | | * static char *rcs_treasure_c = |
* "$Id: treasure.c,v 1.3 2000/05/26 09:50:45 jec Exp $"; | | * "$Id: treasure.c,v 1.4 2000/12/04 00:40:03 cvs Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
if (op->arch) { | | if (op->arch) { |
if (op->type == ARMOUR) | | if (op->type == ARMOUR) |
ARMOUR_SPEED(op)=(ARMOUR_SPEED(&op->arch->clone)*(100+magic*10))/100; | | ARMOUR_SPEED(op)=(ARMOUR_SPEED(&op->arch->clone)*(100+magic*10))/100; |
if (op->armour) | | |
op->armour=op->arch->clone.armour + (op->arch->clone.armour * magic)/20; | | |
if (magic < 0 && !(RANDOM()%3)) /* You can't just check the weight always */ | | if (magic < 0 && !(RANDOM()%3)) /* You can't just check the weight always */ |
magic = (-magic); | | magic = (-magic); |
op->weight = (op->arch->clone.weight*(100-magic*10))/100; | | op->weight = (op->arch->clone.weight*(100-magic*10))/100; |
} else { | | } else { |
if(op->type==ARMOUR) | | if(op->type==ARMOUR) |
ARMOUR_SPEED(op)=(ARMOUR_SPEED(op)*(100+magic*10))/100; | | ARMOUR_SPEED(op)=(ARMOUR_SPEED(op)*(100+magic*10))/100; |
if(op->armour) | | |
op->armour+=(op->armour*magic)/20; | | |
if (magic < 0 && !(RANDOM()%3)) /* You can't just check the weight always */ | | if (magic < 0 && !(RANDOM()%3)) /* You can't just check the weight always */ |
magic = (-magic); | | magic = (-magic); |
op->weight=(op->weight*(100-magic*10))/100; | | op->weight=(op->weight*(100-magic*10))/100; |
| | |
| | |
/* | | /* |
* Randomly adds one magical ability to the given object. | | * Randomly adds one magical ability to the given object. |
| | * Modified for Partial Resistance in many ways: |
| | * 1) Since rings can have multiple bonuses, if the same bonus |
| | * is rolled again, increase it - the bonuses now stack with |
| | * other bonuses previously rolled and ones the item might natively have. |
| | * 2) Add code to deal with new PR method. |
*/ | | */ |
| | |
void set_ring_bonus(object *op,int bonus) { | | void set_ring_bonus(object *op,int bonus) { |
| | |
} | | } |
| | |
switch(r) { | | switch(r) { |
| | /* Redone by MSW 2000-11-26 to have much less code. Also, |
| | * bonuses and penalties will stack and add to existing values. |
| | * of the item. |
| | */ |
case 0: | | case 0: |
if(op->stats.Str) | | |
return; | | |
op->stats.Str=bonus; | | |
break; | | |
case 1: | | case 1: |
if(op->stats.Int) | | |
return; | | |
op->stats.Int=bonus; | | |
break; | | |
case 2: | | case 2: |
if(op->stats.Con) | | |
return; | | |
op->stats.Con=bonus; | | |
break; | | |
case 3: | | case 3: |
if(op->stats.Dex) | | |
return; | | |
op->stats.Dex=bonus; | | |
break; | | |
case 4: | | case 4: |
if(op->stats.Cha) | | |
return; | | |
op->stats.Cha=bonus; | | |
break; | | |
case 5: | | case 5: |
if(op->stats.Wis) | | |
return; | | |
op->stats.Wis=bonus; | | |
break; | | |
case 6: | | case 6: |
if(op->stats.Pow) | | set_attr_value(&op->stats, r, bonus + get_attr_value(&op->stats,r)); |
return; | | |
op->stats.Pow=bonus; | | |
break; | | break; |
| | |
case 7: | | case 7: |
if(op->stats.dam) | | op->stats.dam+=bonus; |
return; | | |
op->stats.dam=bonus; | | |
break; | | break; |
| | |
case 8: | | case 8: |
if(op->stats.wc) | | op->stats.wc+=bonus; |
return; | | |
op->stats.wc=bonus; | | |
break; | | break; |
| | |
case 9: | | case 9: |
if(op->stats.food) | | op->stats.food+=bonus; /* hunger/sustenance */ |
return; | | |
op->stats.food=bonus; /* hunger/sustenance */ | | |
break; | | break; |
| | |
case 10: | | case 10: |
if(op->stats.ac) | | op->stats.ac+=bonus; |
return; | | |
op->stats.ac=bonus; | | |
break; | | break; |
| | |
| | /* Item that gives protections/vulnerabilities */ |
case 11: | | case 11: |
if(bonus==2) { /* Maybe make an artifact of this? */ | | |
op->immune|=AT_PARALYZE; | | |
op->immune|=AT_SLOW; | | |
op->stats.exp+=1; | | |
op->value*=5; | | |
} else | | |
op->protected|=AT_PARALYZE; | | |
break; | | |
case 12: | | case 12: |
op->protected|=AT_MAGIC; | | |
op->value*=2; | | |
break; | | |
case 13: | | case 13: |
op->protected|=AT_ELECTRICITY; | | |
break; | | |
case 14: | | case 14: |
op->protected|=AT_FIRE; | | |
op->vulnerable|=AT_COLD; | | |
op->value=(op->value*3)/2; | | |
break; | | |
case 15: | | case 15: |
op->protected|=AT_DRAIN; | | |
break; | | |
case 16: | | case 16: |
op->protected|=AT_SLOW; | | |
break; | | |
case 17: | | case 17: |
op->protected|=AT_COLD; | | |
op->vulnerable|=AT_FIRE; | | |
break; | | |
case 18: | | case 18: |
op->protected|=AT_POISON; | | |
break; | | |
case 19: | | case 19: |
op->protected|=AT_FEAR; | | { |
| | int b=5+FABS(bonus),val,resist=RANDOM() % num_resist_table; |
| | |
| | /* Roughly generate a bonus between 100 and 35 (depending on the bonus) */ |
| | val = 10 + RANDOM() % b + RANDOM() % b + RANDOM() % b + RANDOM() % b; |
| | |
| | /* Cursed items need to have higher negative values to equal out with |
| | * positive values for how protections work out. Put another |
| | * little random element in since that they don't always end up with |
| | * even values. |
| | */ |
| | if (bonus<0) val = 2*-val - RANDOM() % b; |
| | if (val>35) val=35; /* Upper limit */ |
| | b=0; |
| | while (op->resist[resist_table[resist]]!=0 && b<4) { |
| | resist=RANDOM() % num_resist_table; |
| | } |
| | if (b==4) return; /* Not able to find a free resistance */ |
| | op->resist[resist_table[resist]] = val; |
| | /* We should probably do something more clever here to adjust value |
| | * based on how good a resistance we gave. |
| | */ |
break; | | break; |
| | } |
case 20: | | case 20: |
if(op->type==AMULET) { | | if(op->type==AMULET) { |
SET_FLAG(op,FLAG_REFL_SPELL); | | SET_FLAG(op,FLAG_REFL_SPELL); |
| | |
op->value*=4; | | op->value*=4; |
} | | } |
break; | | break; |
| | |
case 21: | | case 21: |
if(op->type==AMULET) { | | if(op->type==AMULET) { |
SET_FLAG(op,FLAG_REFL_MISSILE); | | SET_FLAG(op,FLAG_REFL_MISSILE); |
| | |
op->value*=3; | | op->value*=3; |
} | | } |
break; | | break; |
| | |
case 22: | | case 22: |
if(op->stats.exp) | | op->stats.exp+=bonus; /* Speed! */ |
return; | | |
op->stats.exp=bonus; /* Speed! */ | | |
op->value=(op->value*2)/3; | | op->value=(op->value*2)/3; |
break; | | break; |
} | | } |
| | |
if (RANDOM()%2) | | if (RANDOM()%2) |
SET_FLAG(op, FLAG_CURSED); | | SET_FLAG(op, FLAG_CURSED); |
} | | } |
#if 0 | | |
if (op->arch == NULL) | | |
LOG(llevDebug, "fix_generated_item(%s) had no arch.\n", op->name); | | |
else | | |
op->value = op->arch->clone.value / 2; | | |
#endif | | |
/* Often times cursed rings show up with the only 'bad' effect being that | | |
* they are cursed - they are still providing normal protections and | | |
* immunities. This makes cursed items really bad - make it vulnerable | | |
* to whatever it protected/immune, and clear the protections/immunities. | | |
*/ | | |
if (QUERY_FLAG(op, FLAG_CURSED)) { | | |
op->vulnerable |= op->protected | op->immune; | | |
op->immune=0; | | |
op->protected=0; | | |
} | | |
} | | } |
| | |
/* | | /* |
| | |
if ((QUERY_FLAG(change,FLAG_CURSED) || QUERY_FLAG(change,FLAG_DAMNED)) | | if ((QUERY_FLAG(change,FLAG_CURSED) || QUERY_FLAG(change,FLAG_DAMNED)) |
&& op->magic > 0) | | && op->magic > 0) |
set_abs_magic(op, -op->magic); | | set_abs_magic(op, -op->magic); |
op->immune |= change->immune; | | |
op->protected |= change->protected; | | |
op->attacktype |= change->attacktype; | | op->attacktype |= change->attacktype; |
op->vulnerable |= change->vulnerable; | | |
op->path_attuned |= change->path_attuned; | | op->path_attuned |= change->path_attuned; |
op->path_repelled |= change->path_repelled; | | op->path_repelled |= change->path_repelled; |
op->path_denied |= change->path_denied; | | op->path_denied |= change->path_denied; |
| | |
op->level = -(change->level); | | op->level = -(change->level); |
else | | else |
op->level += change->level; | | op->level += change->level; |
if (change->armour) { | | |
if (change->armour < 0) | | |
op->armour = (-change->armour); | | for (i=0; i<NROFATTACKS; i++) { |
else | | if (change->resist[i]) { |
op->armour = (signed char) (((int)op->armour * (int)change->armour)/10); | | if (change->resist[i] < 0) |
| | op->resist[i] = change->resist[i]; |
| | else if (change->resist[i] > 0) { |
| | if ((op->type==ARMOUR || op->type==HELMET || op->type==SHIELD) && i==ATNR_PHYSICAL) { |
| | op->resist[i] = (op->resist[i] * change->resist[i])/10; |
| | } |
| | else { |
| | op->resist[i] += change->resist[i]; |
| | } |
| | } |
| | } |
} | | } |
if (change->stats.dam) { | | if (change->stats.dam) { |
if (change->stats.dam < 0) | | if (change->stats.dam < 0) |
| | |
| | |
void fix_flesh_item(object *item, object *donor) { | | void fix_flesh_item(object *item, object *donor) { |
char tmpbuf[MAX_BUF]; | | char tmpbuf[MAX_BUF]; |
| | int i; |
| | |
if(item->type==FLESH && donor) { | | if(item->type==FLESH && donor) { |
/* change the name */ | | /* change the name */ |
| | |
/* weight is FLESH weight/100 * donor */ | | /* weight is FLESH weight/100 * donor */ |
if((item->weight = (float) (item->weight/100.0) * donor->weight)==0) | | if((item->weight = (float) (item->weight/100.0) * donor->weight)==0) |
item->weight=1; | | item->weight=1; |
| | |
/* value is multiplied by level of donor */ | | /* value is multiplied by level of donor */ |
item->value *= isqrt(donor->level*2); | | item->value *= isqrt(donor->level*2); |
| | |
/* food value */ | | /* food value */ |
item->stats.food += (donor->stats.hp/100) + donor->stats.Con; | | item->stats.food += (donor->stats.hp/100) + donor->stats.Con; |
/* flesh items inherit vuln, prot of donor */ | | |
item->vulnerable = donor->vulnerable; | | /* flesh items inherit some abilities of donor, but not |
item->protected = donor->protected; | | * full effect. |
| | */ |
| | for (i=0; i<NROFATTACKS; i++) |
| | item->resist[i] = donor->resist[i]/2; |
| | |
/* if donor has some attacktypes, the flesh is poisonous */ | | /* if donor has some attacktypes, the flesh is poisonous */ |
if(donor->attacktype&AT_POISON) | | if(donor->attacktype&AT_POISON) |
item->type=POISON; | | item->type=POISON; |
| | |
| | |
int special_potion (object *op) { | | int special_potion (object *op) { |
| | |
| | int i; |
| | |
if(op->attacktype) return 1; | | if(op->attacktype) return 1; |
if(op->immune || op->vulnerable || op->protected) return 1; | | |
if(op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow | | if(op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow |
|| op->stats.Wis || op->stats.Int || op->stats.Cha ) return 1; | | || op->stats.Wis || op->stats.Int || op->stats.Cha ) return 1; |
| | |
| | for (i=0; i<NROFATTACKS; i++) |
| | if (op->resist[i]) return 1; |
| | |
return 0; | | return 0; |
} | | } |
| | |