healthy food has a chance of curing poison

This commit is contained in:
Rob Pearce 2019-08-20 18:19:13 +10:00
parent b89c0fe7b9
commit 9456fba0f7
5 changed files with 1805 additions and 1778 deletions

298
attack.c
View File

@ -75,7 +75,7 @@ int applyarmourdamage(lifeform_t *lf, object_t *wep, int dam, enum DAMTYPE damty
if (f) {
ar = f->val[0];
}
rust = hasflag(armour->flags, F_RUSTED);
actualdam = dam;
@ -83,7 +83,7 @@ int applyarmourdamage(lifeform_t *lf, object_t *wep, int dam, enum DAMTYPE damty
/*
// adjust how much damage to do to armour
if ( ((armour->type->id == OT_FLAKJACKET) && (damtype == DT_PROJECTILE)) ||
(damtype == DT_ACID) ||
(damtype == DT_ACID) ||
rust ) {
// ALL of damage reduction goes towards armour
} else {
@ -131,7 +131,7 @@ void applyarmourdamreduction(lifeform_t *lf, object_t *wep, int reduceamt, int *
if (dam) {
int ar;
newdam = *dam;
ar = getarmourrating(lf, NULL, NULL, NULL, NULL);
ar = getarmourrating(lf, NULL, NULL, NULL, NULL);
// if you did at least one damage...
if ((*dam >= 1) && (reduceamt >= 0)) {
@ -163,7 +163,7 @@ void applyarmourdamreduction(lifeform_t *lf, object_t *wep, int reduceamt, int *
}
*dam = newdam;
}
}
}
@ -207,7 +207,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
// anyone there? if so just attack.
if (c->lf) {
// warnings
// warnings
if (!force && isplayer(lf)) {
int h,m,s;
splittime(&h,&m,&s);
@ -229,9 +229,9 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
}
}
if (!areenemies(lf,c->lf) && (getraceclass(c->lf) != RC_PLANT) &&
if (!areenemies(lf,c->lf) && (getraceclass(c->lf) != RC_PLANT) &&
cansee(lf, c->lf) &&
!lfhasflag(lf, F_RAGE)
!lfhasflag(lf, F_RAGE)
) {
switch (getallegiance(c->lf)) {
case AL_PEACEFUL:
@ -249,7 +249,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
}
if (strlen(warnbuf)) {
ch = askchar(warnbuf, "yn","n", B_TRUE, B_FALSE);
ch = askchar(warnbuf, "yn","n", B_TRUE, B_FALSE);
if (ch == 'n') {
// cancel.
return B_TRUE;
@ -259,10 +259,10 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
// non-evil players get no xp for attacking peaceful lfs
if ((isplayer(lf) || areallies(player, lf)) && (getalignment(player) != AL_EVIL)) {
killflagsofid(c->lf->flags, F_XPVAL);
addflag(c->lf->flags, F_XPVAL, 0, NA, NA, NULL);
addflag(c->lf->flags, F_XPVAL, 0, NA, NA, NULL);
real_warnabout(TEXT_WARN_NOXP_GOODVSPEACEFUL, PERMENANT, B_FALSE);
}
} else if ((c->lf->race->raceclass->id == RC_PLANT) &&
} else if ((c->lf->race->raceclass->id == RC_PLANT) &&
(c->map->region->rtype->id == BH_WOODS)) {
int willwarn = B_FALSE;
@ -273,7 +273,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
}
if (willwarn) {
snprintf(warnbuf, BUFLEN, "Really attack %s while in the Sylvan Woods?",victimname);
ch = askchar(warnbuf, "yn","n", B_TRUE, B_FALSE);
ch = askchar(warnbuf, "yn","n", B_TRUE, B_FALSE);
if (ch == 'n') {
// cancel.
return B_TRUE;
@ -330,8 +330,8 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
if (priwep && willrust(priwep)) {
char victimname[BUFLEN],wepname[BUFLEN],buf[BUFLEN];
getlfname(c->lf, victimname);
real_getobname(priwep, wepname, priwep->amt, B_NOPREMODS,
B_NOCONDITION, B_BLINDADJUST,
real_getobname(priwep, wepname, priwep->amt, B_NOPREMODS,
B_NOCONDITION, B_BLINDADJUST,
B_NOBLESSINGS, B_NOUSED, B_NOSHOWALL);
snprintf(buf, BUFLEN, "Attacking %s might rust your %s - proceed anyway?",victimname, noprefix(wepname));
if (!warnabout(buf)) {
@ -351,7 +351,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
if (lfhasflag(c->lf, F_FEIGNINGDEATH)) {
char vicname[BUFLEN];
killflagsofid(c->lf->flags, F_FEIGNINGDEATH);
getlfname(c->lf, vicname);
getlfname(c->lf, vicname);
capitalise(vicname);
if (cansee(lf, c->lf)) {
msg("Hey! %s was just feigning death!", vicname);
@ -374,7 +374,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
attackedhelpless = ishelplessvictim(attacktarget, lf, NULL);
} else {
object_t *o;
// has an impassable object?
// has an impassable object?
o = hasobwithflag(c->obpile, F_IMPASSABLE);
if (o) {
object_t *priwep;
@ -385,7 +385,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
// confirm ?
if (!force && isplayer(lf)) {
if (wepdullable(priwep) &&
if (wepdullable(priwep) &&
(getattrbracket(getattr(player, A_IQ), A_IQ, NULL) >= AT_GTAVERAGE) &&
!lfhasflag(lf, F_RAGE)) {
if (!hasflagknown(priwep->flags, F_IMMUTABLE)) {
@ -394,17 +394,17 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
real_getobname(o, obname, o->amt, B_NOPREMODS, B_NOCONDITION, B_BLINDADJUST, B_NOBLESSINGS, B_NOUSED, B_NOSHOWALL);
getobname(priwep, wepname, priwep->amt);
snprintf(buf, BUFLEN, "Attacking %s might damage your %s. Proceed?", obname, noprefix(wepname));
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
if (ch == 'n') {
// cancel.
return B_TRUE;
}
}
} else if ((o->type->obclass->id == OC_FLORA) &&
} else if ((o->type->obclass->id == OC_FLORA) &&
(c->map->region->rtype->id == BH_WOODS)) {
int willwarn = B_FALSE;
char obname[BUFLEN];
real_getobname(o, obname, o->amt, B_NOPREMODS, B_NOCONDITION,
real_getobname(o, obname, o->amt, B_NOPREMODS, B_NOCONDITION,
B_BLINDADJUST, B_NOBLESSINGS, B_NOUSED, B_NOSHOWALL);
if (lfhasflag(lf, F_SYLVANWARN)) {
@ -416,7 +416,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
char ch;
char buf[BUFLEN];
snprintf(buf, BUFLEN, "Really attack %s while in the Sylvan Woods?",obname);
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
if (ch == 'n') {
// cancel.
return B_TRUE;
@ -457,7 +457,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
// pick one randomly
o = poss[rnd(0,nposs-1)];
}
if (o) {
attacktype = AT_OB;
attacktarget = o;
@ -472,7 +472,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
attacktype = AT_WALL;
attacktarget = c;
if ((c->type->id == CT_WALLTREE) &&
if ((c->type->id == CT_WALLTREE) &&
(c->map->region->rtype->id == BH_WOODS)) {
int willwarn = B_FALSE;
@ -485,14 +485,14 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
char ch;
char buf[BUFLEN];
snprintf(buf, BUFLEN, "Really attack %s while in the Sylvan Woods?",c->type->name);
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
ch = askchar(buf, "yn","n", B_TRUE, B_FALSE);
if (ch == 'n') {
// cancel.
return B_TRUE;
}
}
}
} else {
} else {
if (isplayer(lf)) {
msg("There is nothing there to attack!");
}
@ -536,7 +536,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
innateattacks = countinnateattacks(lf);
attacktime = getattackspeed(lf);
if (nweps <= 0) {
if (isplayer(lf)) {
msg("You cannot attack!");
@ -561,7 +561,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
/*
// if we have a weapon, this takes the place of one of our
// attacks.
// attacks.
// - for monsters, pick which one to replace randomly.
// - for players, never pick the weapon to replace randomly.
*/
@ -612,13 +612,13 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
getlfname(victim, victimname);
dt = getdamtype(wep[0]);
if (isimmuneto(victim->flags, dt, B_FALSE)) {
snprintf(buf, BUFLEN, "%s is immune to %s damage. Really attack?",victimname,
snprintf(buf, BUFLEN, "%s is immune to %s damage. Really attack?",victimname,
getdamname(dt));
if (!warnabout(buf)) {
return B_TRUE;
}
} else if (isresistantto(victim->flags, dt, B_FALSE)) {
snprintf(buf, BUFLEN, "%s is resistant to %s damage. Really attack?",victimname,
snprintf(buf, BUFLEN, "%s is resistant to %s damage. Really attack?",victimname,
getdamname(dt));
if (!warnabout(buf)) {
return B_TRUE;
@ -632,7 +632,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
if (maxattacks) {
addflagifneeded(lf->flags, F_TOOKACTION, B_TRUE, NA, NA, NULL);
if (!lfhasflag(lf, F_COMBOSTRIKE)) {
taketime(lf, attacktime);
taketime(lf, attacktime);
}
}
@ -685,10 +685,10 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
char ch,ques[BUFLEN];
char vname[BUFLEN];
getlfname(victim, vname);
sprintf(ques, "Continue attacking the fleeing %s?",
sprintf(ques, "Continue attacking the fleeing %s?",
noprefix(vname));
ch = askchar(ques, "yn","y", B_TRUE, B_FALSE);
ch = askchar(ques, "yn","y", B_TRUE, B_FALSE);
if (ch == 'n') {
break;
}
@ -787,14 +787,14 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
pleasegodmaybe(R_GODTHIEVES, 5);
pleasegodmaybe(R_GODDEATH, 10);
}
}
}
if ( ((lifeform_t *)attacktarget)->race->raceclass->id == RC_PLANT) {
lifeform_t *ll;
ll = (lifeform_t *)attacktarget;
if (angergodmaybe(R_GODNATURE, 25, GA_ATTACKOBJECT)) angered = B_TRUE;
if ((ll->race->raceclass->id == RC_PLANT) &&
!isdeaf(ll) &&
if ((ll->race->raceclass->id == RC_PLANT) &&
!isdeaf(ll) &&
(lf->cell->map->region->rtype->id == BH_WOODS)) {
magicwoods_warn(lf);
}
@ -903,8 +903,8 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
return B_TRUE;
}
// if you have somehow attacked someone who was
// hiding (bump into them?) then you have now
// if you have somehow attacked someone who was
// hiding (bump into them?) then you have now
// spotted them.
if (ishidingfrom(victim, lf)) {
spot_hiding_lf(lf, victim);
@ -957,14 +957,14 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
// for each level that victim is higher, -10%.
if (pctchance(50 - (victr - lftr))) protected = B_TRUE;
}
if (protected) {
if (isplayer(lf)) {
msg("^wA %s force prevents you from attacking %s!",
msg("^wA %s force prevents you from attacking %s!",
(f->val[1] == AL_GOOD) ? "demonic" : "holy",
victimname);
} else if (cansee(player, lf)) {
msg("^wA %s force prevents %s from attacking %s!",
msg("^wA %s force prevents %s from attacking %s!",
(f->val[1] == AL_GOOD) ? "demonic" : "holy",
attackername, victimname);
}
@ -1010,7 +1010,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
return B_FALSE;
}
}
// long weapon in an enclosed space?
if (wep && hasflag(wep->flags, F_NEEDSSPACE) && (getdamtype(wep) != DT_PIERCE)) {
@ -1026,7 +1026,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
}
}
}
// did you hit?
ndam = 0;
@ -1092,7 +1092,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
// weapon passing through ghosts etc?
if (hit) {
if (lfhasflag(victim, F_NONCORPOREAL) &&
if (lfhasflag(victim, F_NONCORPOREAL) &&
!lfhasflag(lf, F_NONCORPOREAL) ) {
// using a magical or blessed weapon? if so you're ok.
if (wep && (ismagical(wep) || isblessed(wep) || (wep->material->id == MT_SILVER)) ) {
@ -1148,7 +1148,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
return B_TRUE;
}
}
// determine base damage
@ -1171,7 +1171,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (isexhausted(lf)) {
dam[0] = pctof(75, dam[0]);
}
if (dam[0] < 0) {
willheal = B_TRUE;
}
@ -1182,7 +1182,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (!willheal) {
enum SKILLLEVEL slev;
float loreadd = 0;
// blessed vs undead
// blessed vs undead
adjustdamforblessings(lf, &(dam[0]), victim, wep->blessed);
// modify for weapon skill, strength, rings of wounding etc
@ -1285,7 +1285,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
break;
}
// blocked by defender's shield?
// blocked by defender's shield?
if (i == 0) {
int difficulty;
char attackname[BUFLEN];
@ -1320,11 +1320,11 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (!magicarm) {
// armour doesn't reduce damage for backstabs or critical hits.
// BUT in the case of a critical hit, the armour might get
// BUT in the case of a critical hit, the armour might get
// damaged during the call to criticalhit() later on.
//
// normally armour would be handled by losehp() & losehpeffects(), but
// normally armour would be handled by losehp() & losehpeffects(), but
// in this case we need to know whether the armour was hit beforehand,
// in order to construct the "you hit xxx" string.
if ((dam[i] > 0) && !backstab && !critical) {
@ -1354,7 +1354,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
fatal = B_TRUE;
}
// another check for phantasms
// another check for phantasms
if (lfhasflag(lf, F_PHANTASM)) dam[0] = 0;
// is the victim feigning death? if so, stop now.
@ -1377,7 +1377,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (getstamina(victim)) {
if (isplayer(victim)) {
candodge = B_TRUE;
} else if (onein(3)) {
} else if (onein(3)) {
candodge = B_TRUE;
}
}
@ -1463,7 +1463,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
char wepname[BUFLEN];
real_getobname(wep, wepname, 1, B_PREMODS, B_NOCONDITION, B_NOBLINDADJUST, B_BLESSINGS, B_NOUSED, B_NOSHOWALL);
/*
snprintf(buf, BUFLEN, "%s^%s %s",attackername2,
snprintf(buf, BUFLEN, "%s^%s %s",attackername2,
(lf == victim) ? "using" : "weilding",
wepname);
*/
@ -1482,15 +1482,15 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
// "xxx hits you with a flaming sword."
// don't adjust damage for resistences - we've already done that
losehp_real(victim, dam[i], damtype[i], lf, buf, B_NODAMADJUST, wep, B_NORETALIATE,
&waskod, B_NODAMEFFECTS, critpos, critical);
losehp_real(victim, dam[i], damtype[i], lf, buf, B_NODAMADJUST, wep, B_NORETALIATE,
&waskod, B_NODAMEFFECTS, critpos, critical);
}
// was it fatal ? override previously calculated value.
if ((victim->hp <= 0) && !waskod) {
fatal = B_TRUE;
} else {
fatal = B_FALSE;
}
}
// announce the hit
if (!feigneddeath) {
if (isplayer(lf) || isplayer(victim) || cansee(player, lf) || cansee(player, victim)) {
@ -1519,7 +1519,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (damtypecausesbleed(damtype[i], wep)) {
int bloodamt = 0,n;
switch (getlfsize(victim)) {
case SZ_MINI:
case SZ_MINI:
if (onein(3)) bloodamt = 1;
break;
case SZ_TINY: bloodamt = rnd(0,1); break;
@ -1528,8 +1528,8 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
case SZ_HUMAN: bloodamt = rnd(3,5); break;
case SZ_LARGE: bloodamt = rnd(5,10); break;
case SZ_HUGE: bloodamt = rnd(10,15); break;
case SZ_ENORMOUS:
case SZ_MAX:
case SZ_ENORMOUS:
case SZ_MAX:
bloodamt = rnd(15,20); break;
default: bloodamt = 0; break;
}
@ -1558,10 +1558,10 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (cansee(player, victim)) {
msg("^%c%s looks stronger!", getlfcol(victim, CC_GOOD), victimname);
}
}
}
/// ... used to apply armour damage here...
// make noise
@ -1580,10 +1580,10 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
pleasegodmaybe(R_GODTHIEVES, 4);
}
}
// now handle the extra hp loss effects which we postponed above.
losehpeffects(victim, dam[i], damtype[i], lf, wep, B_NORETALIATE, waskod,
losehpeffects(victim, dam[i], damtype[i], lf, wep, B_NORETALIATE, waskod,
&waskod, prebleed, BP_NONE, damreducedbyarmour, critical);
if (fatal || waskod || dodged || stopnow) break; // stop now, don't process further damtypes!
@ -1613,7 +1613,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (isimmuneto(victim->flags, DT_COLD, B_FALSE) || skillcheck(victim, SC_RESISTMAG, diff, 0)) {
if (isplayer(victim)) {
msg("You feel mildly chilly.");
}
}
} else {
// victim turns to ice for a while!
freezelf(victim, lf, f->val[1]);
@ -1654,7 +1654,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
}
}
// if victim was flying and took >= 40% of its hit points, it drops to the ground.
// if victim was flying and took >= 40% of its hit points, it drops to the ground.
if (isphysicaldam(damtype[i]) && (dam[i] >= pctof(40, victim->maxhp))) {
fall_from_air(victim);
}
@ -1672,8 +1672,8 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
if (cansee(player, lf) || cansee(player, victim)) {
char wepname[BUFLEN];
real_getobname(wep, wepname, 1, B_PREMODS, B_NOCONDITION, B_NOBLINDADJUST, B_BLESSINGS, B_NOUSED, B_NOSHOWALL);
msg("^%c%s%s %s %s to %s!", getlfcol(lf, CC_BAD),
attackername, getpossessive(attackername), noprefix(wepname),
msg("^%c%s%s %s %s to %s!", getlfcol(lf, CC_BAD),
attackername, getpossessive(attackername), noprefix(wepname),
(wep->amt == 1) ? "sticks" : "stick", victimname);
}
moveob(wep, victim->pack, wep->amt);
@ -1690,13 +1690,13 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
loctext = strdup(f->text);
p = readuntil(dicetext, loctext, '^');
readuntil(obname, p, '^');
rdam = roll(dicetext);
if (cansee(player, victim)) {
msg("^%c%s%s %s %s %s!", getlfcol(lf, CC_BAD), victimname, getpossessive(victimname),
noprefix(obname),
noprefix(obname),
getattackverb(victim, NULL, f->val[0], rdam, lf->maxhp),
attackername);
attackername);
}
snprintf(damstring, BUFLEN, "%s%s %s", victimname, getpossessive(victimname), noprefix(obname));
losehp_real(lf, rdam, f->val[0], victim, damstring, B_TRUE, NULL, B_TRUE, NULL, B_TRUE, critpos, critical);
@ -1722,7 +1722,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
snprintf(buf, BUFLEN, "%s",attackername);
msg("^w%s%s magnetic shield repels %s%s attack.", victimname, getpossessive(victimname),
buf, getpossessive(buf));
buf, getpossessive(buf));
}
} else {
char missamt[BUFLEN];
@ -1742,7 +1742,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
// capitalise first letter
snprintf(buf, BUFLEN, "%s",attackername);
msg("%s %smisses %s.", buf, missamt, victimname);
msg("%s %smisses %s.", buf, missamt, victimname);
}
}
@ -1825,7 +1825,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
}
if (bonus) {
addtempflag(lf->flags, F_ACCURACYMOD, bonus, NA, NA, NULL, 1);
}
}
}
}
}
@ -1869,13 +1869,13 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
} else {
maxhp = 1;
}
if (hasflag(wep->flags, F_UNARMEDWEP)) {
isunarmed = B_TRUE;
}
getobname(wep, wepname, 1);
// don't need to figure out accuracy - we always hit.
// determine damage
@ -1971,8 +1971,8 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
}
// smash wood bonus
if ((wep->type->id == OT_FISTS) &&
(o->material->id == MT_WOOD) &&
if ((wep->type->id == OT_FISTS) &&
(o->material->id == MT_WOOD) &&
(getskill(lf, SK_UNARMED) >= PR_ADEPT)) {
dam[i] += rnd(1,6);
}
@ -2033,7 +2033,7 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
msg("You break the lock!");
}
killflagsofid(o->flags, F_LOCKED);
}
}
}
}
@ -2172,8 +2172,8 @@ int attackwall(lifeform_t *lf, cell_t *c, object_t *wep, flag_t *damflag) {
}
// smash wood bonus
if ((wep->type->id == OT_FISTS) &&
(c->type->material->id == MT_WOOD) &&
if ((wep->type->id == OT_FISTS) &&
(c->type->material->id == MT_WOOD) &&
(getskill(lf, SK_UNARMED) >= PR_ADEPT)) {
dam[i] += rnd(1,6);
}
@ -2208,10 +2208,10 @@ enum DAMTYPE basedamagetype(enum DAMTYPE dt) {
return dt;
}
// returns B_TRUE if victim blocked lf's attack
// returns B_TRUE if victim blocked lf's attack
//
// Note: sometimes we'll call this function with a check difficulty of IMPOSSIBLE.
// This means that it'sonly possible to block the attack if you are in
// This means that it'sonly possible to block the attack if you are in
// 'fullshield' mode.
int check_for_block(lifeform_t *lf, lifeform_t *victim, int dam, enum DAMTYPE damtype, int difficulty, char *attackname, int ranged) {
object_t *shield[MAXPILEOBS];
@ -2261,12 +2261,12 @@ int check_for_block(lifeform_t *lf, lifeform_t *victim, int dam, enum DAMTYPE da
char shname[BUFLEN];
char victimname[BUFLEN];
getlfname(victim, victimname);
// announce
// announce
real_getobname(shield[i], shname, 1, B_PREMODS, B_NOCONDITION, B_BLINDADJUST, B_NOBLESSINGS, B_NOUSED, B_NOSHOWALL);
if (lf && isplayer(lf)) { // player is atatcking
msg("%s blocks %s with %s.", victimname, attackname, shname);
} else if ((lf && cansee(player, lf)) || cansee(player, victim)) { // monster is attacking
msg("%s block%s %s with %s.", victimname, isplayer(victim) ? "" : "s",
msg("%s block%s %s with %s.", victimname, isplayer(victim) ? "" : "s",
attackname, shname);
}
if (isshield(shield[i])) {
@ -2283,14 +2283,14 @@ int check_for_block(lifeform_t *lf, lifeform_t *victim, int dam, enum DAMTYPE da
if (cansee(player, lf) || cansee(player, victim)) {
char attname[BUFLEN];
getlfname(lf, attname);
msg("^%c%s%s %s %s to %s!", getlfcol(victim, CC_BAD),
victimname, getpossessive(victimname), noprefix(shname),
msg("^%c%s%s %s %s to %s!", getlfcol(victim, CC_BAD),
victimname, getpossessive(victimname), noprefix(shname),
(shield[i]->amt == 1) ? "sticks" : "stick", attname);
}
moveob(shield[i], lf->pack, shield[i]->amt);
}
}
}
// stop checking.
return B_TRUE;
@ -2323,10 +2323,10 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
flag_t *retflag[MAXCANDIDATES];
strcpy(bpname, getbodypartname(victim, hitpos));
// special case
if (!victim->race->id == R_HYDRA) {
if (victim->race->id != R_HYDRA) {
// remove it
addflag(victim->flags, F_NOBODYPART, hitpos, NA, NA, NULL);
// remove hasattack flags
// remove hasattack flags
getflags(victim->flags, retflag, &nretflags, F_CANCAST, F_HASATTACK, F_NONE);
for (i = 0; i < nretflags; i++) {
if (retflag[i]->id == F_CANCAST) {
@ -2350,7 +2350,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
} else {
strcpy(lfname, "Something");
}
msg("^%c%s slice%s off %s%s %s!", getlfcol(victim, CC_VBAD),
msg("^%c%s slice%s off %s%s %s!", getlfcol(victim, CC_VBAD),
lfname, isplayer(lf) ? "" : "s", vname, getpossessive(vname), bpname);
}
// take extra damage based on number of severable limbs
@ -2390,7 +2390,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
// some kind of non-injury effect
switch (rnd(1,2)) {
case 1: fall(victim, lf, B_TRUE); break;
case 2:
case 2:
if (lf) {
if (cansee(player, lf) || cansee(player, victim)) {
getlfname(lf, lfname);
@ -2411,7 +2411,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
if ((armour = getarmour(victim, BP_BODY)) != NULL) {
protected = checkcritprotection(victim,armour);
takedamage(armour, dam, damtype, lf);
}
}
if (!protected) injure(victim, BP_BODY, damtype, IJ_NONE);
break;
case BP_HEAD:
@ -2452,7 +2452,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
if ((armour = getarmour(victim, BP_HANDS)) != NULL) {
protected = checkcritprotection(victim,armour);
takedamage(armour, dam, damtype, lf);
}
}
if (!protected) injure(victim, BP_HANDS, damtype, IJ_NONE);
if (onein(2)) {
@ -2485,7 +2485,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
if ((armour = getarmour(victim, hitpos)) != NULL) {
protected = checkcritprotection(victim,armour);
takedamage(armour, dam, damtype, lf);
}
}
if (!protected) injure(victim, hitpos, damtype, IJ_NONE);
} else if (damtype == DT_EXPLOSIVE) {
if ((armour = getarmour(victim, hitpos)) != NULL) {
@ -2495,7 +2495,7 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, objec
min = max / 2;
limit(&min, 1, NA);
takedamage(armour, rnd(min,max), DT_EXPLOSIVE, lf);
}
}
if (!protected) injure(victim, hitpos, damtype, IJ_NONE);
}
@ -2547,8 +2547,8 @@ int getarmourdamreduction(lifeform_t *lf, object_t *wep, int dam, enum DAMTYPE d
if (wep && hasflag(wep->flags, F_ARMOURIGNORE)) {
return 0;
}
ar = getarmourrating(lf, NULL, NULL, NULL, NULL);
}
ar = getarmourrating(lf, NULL, NULL, NULL, NULL);
// between 25% and 75% of AR.
// ie. with AR of 20, all damage is reduced by 5-15.
@ -2592,7 +2592,7 @@ void getarrange(int arating, int *min, int *max) {
/*
object_t *getattackwep(lifeform_t *lf, obpile_t **unarmedpile, flag_t **unarmedflag) {
object_t *wep;
wep = getweapon(lf);
if (!wep) {
// ie. unarmed
@ -2662,8 +2662,8 @@ int getextradamlf(lifeform_t *lf, int *dam, enum DAMTYPE *damtype, int *ndam, in
*(damtypewhere) = f->val[0];
}
if ((f->lifetime == FROMOBEQUIP) ||
(f->lifetime == FROMOBHOLD) ||
if ((f->lifetime == FROMOBEQUIP) ||
(f->lifetime == FROMOBHOLD) ||
(f->lifetime == FROMOBACTIVATE) ) {
object_t *obfrom;
obfrom = findobbyid(lf->pack, f->obfrom);
@ -2713,10 +2713,10 @@ int getextradamwep(object_t *wep, int *dam, enum DAMTYPE *damtype, int *ndam, in
usecharge(wep);
}
// deal extra damage of the given type
*(dam + *ndam) = real_roll(f->text, fordisplay);
*(dam + *ndam) = real_roll(f->text, fordisplay);
*(damtype + *ndam) = f->val[0];
(*ndam)++;
}
}
}
@ -2725,8 +2725,8 @@ int getextradamwep(object_t *wep, int *dam, enum DAMTYPE *damtype, int *ndam, in
if (owner && owner->mp) {
f = hasflag(wep->flags, F_ENCHANTED);
if (f) {
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
} else {
*(dam + *ndam) = real_roll("1d2", fordisplay); // default: 1d2 extra damage
}
@ -2764,23 +2764,23 @@ int getextradamwep(object_t *wep, int *dam, enum DAMTYPE *damtype, int *ndam, in
}
if (f->id == F_ONFIRE) {
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
} else {
*(dam + *ndam) = real_roll("1d4", fordisplay);
}
*(damtype + *ndam) = DT_FIRE;
(*ndam)++;
} else if (f->id == F_HOT) {
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
if (strlen(f->text)) {
*(dam + *ndam) = real_roll(f->text, fordisplay);
} else {
*(dam + *ndam) = real_roll("1d2", fordisplay);
}
*(damtype + *ndam) = DT_HEAT;
(*ndam)++;
} else if (f->id == F_FROZEN) {
*(dam + *ndam) = real_roll("1d4", fordisplay);
*(dam + *ndam) = real_roll("1d4", fordisplay);
*(damtype + *ndam) = DT_COLD;
(*ndam)++;
}
@ -2799,7 +2799,7 @@ void getdamrange(object_t *o, flag_t *f, int *min, int *max) {
if (f) {
if (hasflag(o->flags, F_MASTERWORK)) {
// 85%-100%
mindam = pctof(85,f->val[1]);
mindam = pctof(85,f->val[1]);
maxdam = f->val[1];
} else if (hasflag(o->flags, F_SHODDY)) {
// 25% - 75%
@ -2959,16 +2959,16 @@ int ismeleedam(enum DAMTYPE damtype) {
int iskineticdam(enum DAMTYPE damtype) {
switch (damtype) {
case DT_BASH:
case DT_BITE:
case DT_CHOP:
case DT_CRUSH:
case DT_EXPLOSIVE:
case DT_FALL:
case DT_PIERCE:
case DT_PROJECTILE:
case DT_SLASH:
case DT_UNARMED:
case DT_BASH:
case DT_BITE:
case DT_CHOP:
case DT_CRUSH:
case DT_EXPLOSIVE:
case DT_FALL:
case DT_PIERCE:
case DT_PROJECTILE:
case DT_SLASH:
case DT_UNARMED:
return B_TRUE;
default:
break;
@ -2979,20 +2979,20 @@ int iskineticdam(enum DAMTYPE damtype) {
int isphysicaldam(enum DAMTYPE damtype) {
switch (damtype) {
case DT_BASH:
case DT_BITE:
case DT_CHOP:
case DT_COLD:
case DT_CRUSH:
case DT_ELECTRIC:
case DT_EXPLOSIVE:
case DT_FALL:
case DT_FIRE:
case DT_MAGIC:
case DT_PIERCE:
case DT_PROJECTILE:
case DT_SLASH:
case DT_UNARMED:
case DT_BASH:
case DT_BITE:
case DT_CHOP:
case DT_COLD:
case DT_CRUSH:
case DT_ELECTRIC:
case DT_EXPLOSIVE:
case DT_FALL:
case DT_FIRE:
case DT_MAGIC:
case DT_PIERCE:
case DT_PROJECTILE:
case DT_SLASH:
case DT_UNARMED:
return B_TRUE;
default:
break;
@ -3001,13 +3001,13 @@ int isphysicaldam(enum DAMTYPE damtype) {
}
// 'howmuch' is the amount to adjust 'val' by for every size bracket
// difference.
// difference.
//
// how can be M_PCT (adjust by this val% per size bracket)
// how can be M_VAL (adjust by this number per size bracket)
//
// if lf is bigger than victim, ADD howmuch.
// if lf is smaller than victim, SUBTRACT howmuch.
// if lf is bigger than victim, ADD howmuch.
// if lf is smaller than victim, SUBTRACT howmuch.
void modifyforsize(int *val, lifeform_t *lf, lifeform_t *victim, int howmuch, enum MODTYPE how) {
enum LFSIZE szlf,szvictim;
@ -3072,7 +3072,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
// remember lore about victim...
lorelev = getlorelevel(lf, victim->race->raceclass->id);
f = lfhasflag(lf, F_TRUESTRIKE);
if (f) {
if (f->val[0] > 1) {
@ -3116,7 +3116,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
acc += 30;
if (db) dblog("%s: +30 as victim is holding us -> %d", lfname, acc);
}
// MUCH easier to hit things which you have grabbed
// MUCH easier to hit things which you have grabbed
if (lfhasflagval(lf, F_GRABBING, victim->id, NA, NA, NULL)) {
acc += 50;
if (db) dblog("%s: +50 as we are holding victim -> %d", lfname, acc);
@ -3126,7 +3126,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
f = hasflag(wep->flags, F_ADJACCMOD);
if (f) {
acc += f->val[0];
if (db) dblog("%s: %s%d for weapon adjacency modifier -> %d", lfname,
if (db) dblog("%s: %s%d for weapon adjacency modifier -> %d", lfname,
(f->val[0] < 0) ? "" : "+", f->val[0], acc);
}
}
@ -3205,7 +3205,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
}
}
// critical chance
// critical chance
if (critical && gothit && critpossible) {
if (lfhasflag(lf, F_AIMEDSTRIKE)) {
*critical = 1;
@ -3229,7 +3229,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
}
}
limit(&critroll, minroll, 100);
if (critroll <= getcritchance(lf, wep,victim)) *critical = 1;
}
}
@ -3239,7 +3239,7 @@ int rolltohit(lifeform_t *lf, lifeform_t *victim, object_t *wep, int *critical,
int nfailed = 0, i;
int nrolls = 1;
int newacc;
if (getskill(lf, SK_COMBAT) >= PR_BEGINNER) {
if (getskill(lf, SK_COMBAT) >= PR_BEGINNER) {
newacc = pctof(150, baseacc);
} else {
newacc = baseacc;
@ -3310,7 +3310,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam, int isu
}
}
getflags(fp, retflag, &nretflags, F_AUTOTANGLE, F_DRAINONHIT, F_DRAINATTONHIT, F_FLAMESTRIKE, F_HEAVYBLOW, F_HITCONFER,
getflags(fp, retflag, &nretflags, F_AUTOTANGLE, F_DRAINONHIT, F_DRAINATTONHIT, F_FLAMESTRIKE, F_HEAVYBLOW, F_HITCONFER,
F_RACESLAY, F_REVENGE, F_RUSTED, F_NONE);
for (i = 0; i < nretflags; i++) {
f = retflag[i];
@ -3374,7 +3374,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam, int isu
// figure out hp percentage
ratio = 1.0 - ((float)owner->hp / (float)owner->maxhp);
dampct = (ratio * 100); // ie. lower hp% = higher dampct
if (dampct >= 50) {
getdamrange(wep, NULL, NULL, &maxdam);
extradam = (int)((dampct/100) * (float)maxdam);
@ -3498,7 +3498,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam, int isu
} else if (fid == F_ASLEEP) {
fallasleep(victim, ST_ASLEEP, howlong);
} else {
// flag values
// flag values
if (valflag) {
addtempflag(victim->flags, fid, valflag->val[0], valflag->val[1], valflag->val[2], valflag->text, howlong);
} else {
@ -3518,18 +3518,18 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam, int isu
} else if ((f->id == F_RUSTED) && victim && !isdead(victim) ) {
int pct;
pct = f->val[0] * 10;
if (pctchance(pct)) {
if (pctchance(pct)) {
poison(victim, PERMENANT, P_TETANUS, 1, frombuf, owner ? owner->race->id : R_NONE, B_FALSE);
}
} // end if (fid == xxx)
} // end if (fid == xxx)
}
if (wep && owner && victim) {
enum DRAINTYPE draintype = DR_NONE;
flag_t *vampflag;
vampflag = lfhasflag(owner, F_VAMPIRIC);
if ((wep->type->id == OT_TEETH) && vampflag &&
if ((wep->type->id == OT_TEETH) && vampflag &&
((vampflag->val[0] == B_TRUE) || islowhp(victim))
) {
draintype = DR_FROMBITE;
@ -3564,7 +3564,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam, int isu
} else {
if (isplayer(owner)) {
msg("Life force surges into you!");
}
}
}
}
}

8
data.c
View File

@ -3453,6 +3453,7 @@ void initobjects(void) {
addot(OT_APPLE, "apple", "A crunchy apple.", MT_FOOD, 0.5, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_LIGHTGREEN, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 40, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 30, NA, "");
addflag(lastot->flags, F_BRUISABLE, B_TRUE, NA, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL);
@ -3460,6 +3461,7 @@ void initobjects(void) {
addot(OT_BANANA, "banana", "Ba-na-na-na-na-na na-na na-na-na.", MT_FOOD, 0.3, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_YELLOW, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 50, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 30, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, RR_RARE, NULL);
@ -3496,6 +3498,7 @@ void initobjects(void) {
addot(OT_BREADGARLIC, "loaf of garlic bread", "A pungent loaf of garlic bread. Nauseates those around you and restores some health.", MT_FOOD, 0.5, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_DARKYELLOW, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 100, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 75, NA, "");
addflag(lastot->flags, F_EATCONFER, F_STENCH, 1, 1, "100");
addflag(lastot->flags, F_FEELTEXT, NA, NA, NA, "some bread");
addot(OT_CAKEFRUIT, "fruit cake", "A very dense fruit cake. Restores all Stamina, Hit Points and Mana.", MT_FOOD, 0.5, OC_FOOD, SZ_TINY);
@ -3504,6 +3507,7 @@ void initobjects(void) {
addot(OT_CARROT, "carrot", "A stout orange carrot. Rumour has it that carrots are good for your eyesight.", MT_FOOD, 0.2, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_ORANGE, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 60, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 30, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_RARITY, H_ANTNEST, 100, RR_COMMON, NULL);
@ -3524,6 +3528,7 @@ void initobjects(void) {
addot(OT_CURADOUGH, "loaf of curadough", "This very rare form of bread can magically heal whoever eats it, as well as lowering their metabolism for a short period afterwards.", MT_FOOD, 0.5, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_LIGHTYELLOW, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 250, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 100, NA, "");
addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_VERYRARE, NULL);
addflag(lastot->flags, F_FEELTEXT, NA, NA, NA, "some bread");
addot(OT_BREADSTALE, "loaf of stale bread", "A small loaf of old, stale bread.", MT_FOOD, 0.5, OC_FOOD, SZ_TINY);
@ -3547,6 +3552,7 @@ void initobjects(void) {
addot(OT_GARLIC, "clove of garlic", "A very pungent clove of raw garlic. ", MT_FOOD, 0.1, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_FLESH, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 5, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 50, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, RR_COMMON, NULL);
@ -3564,6 +3570,7 @@ void initobjects(void) {
addot(OT_MUSHROOMSHI, "shiitake mushroom", "A large brown mushroom.", MT_FOOD, 0.05, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_BONE, '%', NA, NULL);
addflag(lastot->flags, F_EDIBLE, B_TRUE, 30, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 15, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 90, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_FREQUENT, NULL);
addflag(lastot->flags, F_RARITY, H_SWAMP, 100, RR_FREQUENT, NULL);
@ -3676,6 +3683,7 @@ void initobjects(void) {
addot(OT_TOMATO, "tomato", "A juicy red tomato.", MT_FOOD, 0.3, OC_FOOD, SZ_TINY);
addflag(lastot->flags, F_GLYPH, C_RED, '%', NA, NULL);
addflag(lastot->flags, F_BRUISABLE, B_TRUE, NA, NA, "");
addflag(lastot->flags, F_HEALTHY, B_TRUE, 20, NA, "");
addflag(lastot->flags, F_EDIBLE, B_TRUE, 30, NA, "");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, NA, NULL);

411
defs.h

File diff suppressed because it is too large Load Diff

1342
io.c

File diff suppressed because it is too large Load Diff

1524
lf.c

File diff suppressed because it is too large Load Diff