Permalink
Browse files

part 2 of intrinsic changes

  • Loading branch information...
remirol committed Oct 29, 2007
1 parent dea967c commit dedf0b3ee6d792725b71dcfbc88db1ec1d390191
Showing with 413 additions and 341 deletions.
  1. +4 −4 src/artifact.c
  2. +24 −12 src/cmd.c
  3. +2 −4 src/do.c
  4. +46 −58 src/eat.c
  5. +5 −5 src/explode.c
  6. +5 −5 src/fountain.c
  7. +4 −4 src/hack.c
  8. +12 −8 src/mcastu.c
  9. +79 −66 src/mhitu.c
  10. +4 −4 src/mon.c
  11. +1 −1 src/mthrowu.c
  12. +77 −20 src/potion.c
  13. +15 −15 src/pray.c
  14. +10 −11 src/read.c
  15. +2 −2 src/region.c
  16. +12 −15 src/sit.c
  17. +2 −3 src/spell.c
  18. +5 −3 src/timeout.c
  19. +11 −11 src/trap.c
  20. +39 −36 src/uhitm.c
  21. +54 −54 src/zap.c
@@ -737,16 +737,16 @@ struct monst *mtmp;
return FALSE;
switch(weap->attk.adtyp) {
case AD_FIRE:
return !(yours ? Fire_resistance : resists_fire(mtmp));
return !(!yours ? resists_fire(mtmp) : (how_resistant(FIRE_RES) > 99) ? TRUE : FALSE);
case AD_COLD:
return !(yours ? Cold_resistance : resists_cold(mtmp));
return !(!yours ? resists_cold(mtmp) : (how_resistant(COLD_RES) > 99) ? TRUE : FALSE);
case AD_ELEC:
return !(yours ? Shock_resistance : resists_elec(mtmp));
return !(!yours ? resists_elec(mtmp) : (how_resistant(SHOCK_RES) > 99) ? TRUE : FALSE);
case AD_MAGM:
case AD_STUN:
return !(yours ? Antimagic : (rn2(100) < ptr->mr));
case AD_DRST:
return !(yours ? Poison_resistance : resists_poison(mtmp));
return !(!yours ? resists_poison(mtmp) : (how_resistant(POISON_RES) > 99) ? TRUE : FALSE);
case AD_DRLI:
return !(yours ? Drain_resistance : resists_drli(mtmp));
case AD_STON:
@@ -874,12 +874,18 @@ int final; /* 0 => still in progress; 1 => over, survived; 2 => dead */
#endif
/*** Resistances to troubles ***/
if (Fire_resistance) you_are("fire resistant");
if (Cold_resistance) you_are("cold resistant");
if (Sleep_resistance) you_are("sleep resistant");
if (Disint_resistance) you_are("disintegration-resistant");
if (Shock_resistance) you_are("shock resistant");
if (Poison_resistance) you_are("poison resistant");
Sprintf(buf,"%d%% fire resistant",how_resistant(FIRE_RES));
if (Fire_resistance) you_are(buf);
Sprintf(buf,"%d%% cold resistant",how_resistant(COLD_RES));
if (Cold_resistance) you_are(buf);
Sprintf(buf,"%d%% sleep resistant",how_resistant(SLEEP_RES));
if (Sleep_resistance) you_are(buf);
Sprintf(buf,"%d%% disintegration-resistant",how_resistant(DISINT_RES));
if (Disint_resistance) you_are(buf);
Sprintf(buf,"%d%% shock resistant",how_resistant(SHOCK_RES));
if (Shock_resistance) you_are(buf);
Sprintf(buf,"%d%% poison resistant",how_resistant(POISON_RES));
if (Poison_resistance) you_are(buf);
if (Drain_resistance) you_are("level-drain resistant");
if (Sick_resistance) you_are("immune to sickness");
if (Antimagic) you_are("magic-protected");
@@ -1208,12 +1214,18 @@ int final;
/*** Resistances to troubles ***/
if (Fire_resistance) dump(youwere, "fire resistant");
if (Cold_resistance) dump(youwere, "cold resistant");
if (Sleep_resistance) dump(youwere, "sleep resistant");
if (Disint_resistance) dump(youwere, "disintegration-resistant");
if (Shock_resistance) dump(youwere, "shock resistant");
if (Poison_resistance) dump(youwere, "poison resistant");
Sprintf(buf,"%d%% fire resistant",how_resistant(FIRE_RES));
if (Fire_resistance) dump(youwere,buf);
Sprintf(buf,"%d%% cold resistant",how_resistant(COLD_RES));
if (Cold_resistance) dump(youwere,buf);
Sprintf(buf,"%d%% sleep resistant",how_resistant(SLEEP_RES));
if (Sleep_resistance) dump(youwere,buf);
Sprintf(buf,"%d%% disintegration-resistant",how_resistant(DISINT_RES));
if (Disint_resistance) dump(youwere,buf);
Sprintf(buf,"%d%% shock resistant",how_resistant(SHOCK_RES));
if (Shock_resistance) dump(youwere,buf);
Sprintf(buf,"%d%% poison resistant",how_resistant(POISON_RES));
if (Poison_resistance) dump(youwere,buf);
if (Drain_resistance) dump(youwere, "level-drain resistant");
if (Sick_resistance) dump(youwere, "immune to sickness");
if (Antimagic) dump(youwere, "magic-protected");
@@ -108,11 +108,9 @@ boolean pushing;
vision_full_recalc = 1;
You("find yourself on dry land again!");
} else if (lava && distu(rx,ry) <= 2) {
You("are hit by molten lava%c",
Fire_resistance ? '.' : '!');
You("are hit by molten lava%c", (how_resistant(FIRE_RES) > 50) ? '.' : '!');
burn_away_slime();
losehp(d((Fire_resistance ? 1 : 3), 6),
"molten lava", KILLED_BY);
losehp(resist_reduce(d(3,6),FIRE_RES), "molten lava", KILLED_BY);
} else if (!fills_up && flags.verbose &&
(pushing ? !Blind : cansee(rx,ry)))
pline("It sinks without a trace!");
104 src/eat.c
@@ -656,19 +656,13 @@ int type;
register struct permonst *ptr;
{
register int chance;
long percentincrease;
#ifdef DEBUG
debugpline("Attempting to give intrinsic %d", type);
#endif
/* some intrinsics are easier to get than others */
switch (type) {
case POISON_RES:
if ((ptr == &mons[PM_KILLER_BEE] ||
ptr == &mons[PM_SCORPION]) && !rn2(4))
chance = 1;
else
chance = 15;
break;
case TELEPORT:
chance = 10;
break;
@@ -679,75 +673,76 @@ register struct permonst *ptr;
chance = 1;
break;
default:
chance = 15;
chance = 1; /* the rest use the new system, give it to them all the time */
break;
}
if (ptr->mlevel <= rn2(chance))
return; /* failed die roll */
percentincrease = (ptr->cwt / 45);
if (percentincrease < 10) { percentincrease = 10; }
switch (type) {
/* All these use the new system, which is based on corpse weight. */
case FIRE_RES:
#ifdef DEBUG
debugpline("Trying to give fire resistance");
#endif
if(!(HFire_resistance & FROMOUTSIDE)) {
You(Hallucination ? "be chillin'." :
"feel a momentary chill.");
HFire_resistance |= FROMOUTSIDE;
if((HFire_resistance & TIMEOUT) < 100) {
You(Hallucination ? "be chillin'." : "feel a momentary chill.");
incr_resistance(&HFire_resistance,percentincrease);
}
break;
case SLEEP_RES:
#ifdef DEBUG
debugpline("Trying to give sleep resistance");
#endif
if(!(HSleep_resistance & FROMOUTSIDE)) {
if((HSleep_resistance & TIMEOUT) < 100) {
You_feel("wide awake.");
HSleep_resistance |= FROMOUTSIDE;
incr_resistance(&HSleep_resistance,percentincrease);
}
break;
case COLD_RES:
#ifdef DEBUG
debugpline("Trying to give cold resistance");
#endif
if(!(HCold_resistance & FROMOUTSIDE)) {
if((HCold_resistance & TIMEOUT) < 100) {
You_feel("full of hot air.");
HCold_resistance |= FROMOUTSIDE;
incr_resistance(&HCold_resistance,percentincrease);
}
break;
case DISINT_RES:
#ifdef DEBUG
debugpline("Trying to give disintegration resistance");
#endif
if(!(HDisint_resistance & FROMOUTSIDE)) {
You_feel(Hallucination ?
"totally together, man." :
"very firm.");
HDisint_resistance |= FROMOUTSIDE;
if((HDisint_resistance & TIMEOUT) < 100) {
You_feel(Hallucination ? "totally together, man." : "very firm.");
incr_resistance(&HDisint_resistance,percentincrease);
}
break;
case SHOCK_RES: /* shock (electricity) resistance */
#ifdef DEBUG
debugpline("Trying to give shock resistance");
#endif
if(!(HShock_resistance & FROMOUTSIDE)) {
if((HShock_resistance & TIMEOUT) < 100) {
if (Hallucination)
You_feel("grounded in reality.");
else
Your("health currently feels amplified!");
HShock_resistance |= FROMOUTSIDE;
incr_resistance(&HShock_resistance,percentincrease);
}
break;
case POISON_RES:
#ifdef DEBUG
debugpline("Trying to give poison resistance");
#endif
if(!(HPoison_resistance & FROMOUTSIDE)) {
You_feel(Poison_resistance ?
"especially healthy." : "healthy.");
HPoison_resistance |= FROMOUTSIDE;
if((HPoison_resistance & TIMEOUT) < 100) {
You_feel(how_resistant(POISON_RES) == 100 ? "especially healthy." : "healthy.");
incr_resistance(&HPoison_resistance,percentincrease);
}
break;
/* From here forward, we'll use the old stuff. But. */
case TELEPORT:
#ifdef DEBUG
debugpline("Trying to give teleport");
@@ -960,30 +955,23 @@ register int pm;
* Elliott Kleinrock, October 5, 1990
*/
/* Above proof recorded for posterity, even though i'm about
* to vigorously jostle the means of getting most of
* the resistances in the first place; it's no longer random
* for anything except telecontrol, teleport, and telepathy.
*
* Derek S. Ray, October 28, 2007
*/
count = 0; /* number of possible intrinsics */
tmp = 0; /* which one we will try to give */
for (i = 1; i <= LAST_PROP; i++) {
if (intrinsic_possible(i, ptr)) {
count++;
/* a 1 in count chance of replacing the old
* one with this one, and a count-1 in count
* chance of keeping the old one. (note
* that 1 in 1 and 0 in 1 are what we want
* for the first one
*/
if (!rn2(count)) {
#ifdef DEBUG
debugpline("Intrinsic %d replacing %d",
i, tmp);
#endif
tmp = i;
}
givit(i,ptr);
}
}
/* if any found try to give them one */
if (count) givit(tmp, ptr);
}
}
break;
}
@@ -1303,9 +1291,9 @@ eatcorpse(otmp) /* called when a corpse is selected as food */
} else if (poisonous(&mons[mnum]) && rn2(5)) {
tp++;
pline("Ecch - that must have been poisonous!");
if(!Poison_resistance) {
losestr(rnd(4));
losehp(rnd(15), "poisonous corpse", KILLED_BY_AN);
if(how_resistant(POISON_RES) < 100) {
losestr(resist_reduce(rnd(4),POISON_RES));
losehp(resist_reduce(rnd(15),POISON_RES), "poisonous corpse", KILLED_BY_AN);
} else You("seem unaffected by the poison.");
/* now any corpse left too long will make you mildly ill */
} else if ((rotted > 5L || (rotted > 3L && rn2(5)))
@@ -1566,13 +1554,13 @@ struct obj *otmp;
flags.botl = 1;
break;
case RIN_FREE_ACTION:
/* Give sleep resistance instead */
if (!(HSleep_resistance & FROMOUTSIDE))
accessory_has_effect(otmp);
if (!Sleep_resistance)
You_feel("wide awake.");
HSleep_resistance |= FROMOUTSIDE;
break;
/* Give sleep resistance instead */
if (how_resistant(SLEEP_RES) < 100) {
accessory_has_effect(otmp);
You_feel("wide awake.");
}
incr_resistance(&HSleep_resistance,100);
break;
case AMULET_OF_CHANGE:
accessory_has_effect(otmp);
makeknown(typ);
@@ -1819,7 +1807,7 @@ struct obj *otmp;
if (yn_function(buf,ynchars,'n')=='n') return 1;
else return 2;
}
if (cadaver && poisonous(&mons[mnum]) && !Poison_resistance) {
if (cadaver && poisonous(&mons[mnum]) && how_resistant(POISON_RES) < 100) {
/* poisonous */
Sprintf(buf, "%s like %s might be poisonous! %s",
foodsmell, it_or_they, eat_it_anyway);
@@ -1985,9 +1973,9 @@ doeat() /* generic "eat" command funtion (see cmd.c) */
if (otmp->oclass == WEAPON_CLASS && otmp->opoisoned) {
pline("Ecch - that must have been poisonous!");
if(!Poison_resistance) {
losestr(rnd(4));
losehp(rnd(15), xname(otmp), KILLED_BY_AN);
if (how_resistant(POISON_RES) < 100) {
losestr(resist_reduce(rnd(4),POISON_RES));
losehp(resist_reduce(rnd(15),POISON_RES), xname(otmp), KILLED_BY_AN);
} else
You("seem unaffected by the poison.");
} else if (!otmp->cursed)
@@ -104,21 +104,21 @@ int expltype;
explmask[i][j] = !!Antimagic;
break;
case AD_FIRE:
explmask[i][j] = !!Fire_resistance;
explmask[i][j] = (how_resistant(FIRE_RES) > 50);
break;
case AD_COLD:
explmask[i][j] = !!Cold_resistance;
explmask[i][j] = (how_resistant(COLD_RES) > 50);
break;
case AD_DISN:
explmask[i][j] = (olet == WAND_CLASS) ?
!!(nonliving(youmonst.data) || is_demon(youmonst.data)) :
!!Disint_resistance;
(how_resistant(DISINT_RES) > 50);
break;
case AD_ELEC:
explmask[i][j] = !!Shock_resistance;
explmask[i][j] = (how_resistant(SHOCK_RES) > 50);
break;
case AD_DRST:
explmask[i][j] = !!Poison_resistance;
explmask[i][j] = (how_resistant(POISON_RES) > 50);
break;
case AD_ACID:
explmask[i][j] = !!Acid_resistance;
@@ -254,16 +254,16 @@ drinkfountain()
case 21: /* Poisonous */
pline_The("water is contaminated!");
if (Poison_resistance) {
if (how_resistant(POISON_RES) == 100) {
pline(
"Perhaps it is runoff from the nearby %s farm.",
fruitname(FALSE));
losehp(rnd(4),"unrefrigerated sip of juice",
KILLED_BY_AN);
break;
}
losestr(rn1(4,3));
losehp(rnd(10),"contaminated water", KILLED_BY);
losestr(resist_reduce(rn1(4,3),POISON_RES));
losehp(resist_reduce(rnd(10),POISON_RES),"contaminated water", KILLED_BY);
exercise(A_CON, FALSE);
break;
@@ -522,11 +522,11 @@ drinksink()
case 1: You("take a sip of very warm water.");
break;
case 2: You("take a sip of scalding hot water.");
if (Fire_resistance) {
if (how_resistant(FIRE_RES) == 100) {
pline("It seems quite tasty.");
monstseesu(M_SEEN_FIRE);
}
else losehp(rnd(6), "sipping boiling water", KILLED_BY);
else losehp(resist_reduce(rnd(6),FIRE_RES), "sipping boiling water", KILLED_BY);
break;
case 3: if (mvitals[PM_SEWER_RAT].mvflags & G_GONE)
pline_The("sink seems quite dirty.");
@@ -927,10 +927,10 @@ domove()
|| is_floater(youmonst.data) || is_clinger(youmonst.data)
|| is_whirly(youmonst.data))
on_ice = FALSE;
else if (!rn2(Cold_resistance ? 3 : 2)) {
HFumbling |= FROMOUTSIDE;
HFumbling &= ~TIMEOUT;
HFumbling += 1; /* slip on next move */
else if (!rn2((how_resistant(COLD_RES) > 50) ? 3 : 2)) {
HFumbling |= FROMOUTSIDE;
HFumbling &= ~TIMEOUT;
HFumbling += 1; /* slip on next move */
}
}
if (!on_ice && (HFumbling & FROMOUTSIDE))
Oops, something went wrong.

0 comments on commit dedf0b3

Please sign in to comment.