diff --git a/data.c b/data.c index 8854f12..a315f6e 100755 --- a/data.c +++ b/data.c @@ -8729,7 +8729,8 @@ void initobjects(void) { addflag(lastot->flags, F_VALUE, 300, NA, NA, NULL); addot(OT_RING_GREED, "ring of greed", "Much sought after by treasure hunters, this ring detects the presence of any nearby objects.", MT_METAL, 0.1, OC_RING, SZ_MINI); addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, ""); - addflag(lastot->flags, F_EQUIPCONFER, F_DETECTOBS, 10, NA, NULL); + addflag(lastot->flags, F_EQUIPCONFER, F_DETECTOBS, 10, NA, "50"); + addflag(lastot->flags, F_EQUIPCONFER, F_DETECTMETAL, NA, NA, NULL); addflag(lastot->flags, F_VALUE, 250, NA, NA, NULL); addot(OT_RING_SIGHT, "ring of sight", "Allows the caster to see the invisible, and in the dark.", MT_METAL, 0.1, OC_RING, SZ_MINI); addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, ""); @@ -9657,7 +9658,7 @@ void initobjects(void) { addflag(lastot->flags, F_ALTDAM, DT_BASH, 3, NA, "hilt bash"); // with the hilt addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL); addflag(lastot->flags, F_USESSKILL, SK_LONGBLADES, NA, NA, NULL); - addflag(lastot->flags, F_ATTREQ, A_STR, 40, 60, "3"); + addflag(lastot->flags, F_ATTREQ, A_AGI, 40, 60, "3"); addflag(lastot->flags, F_CRITCHANCE, 7, NA, NA, NULL); addflag(lastot->flags, F_CANBLOCK, DT_SLASH, NA, NA, NULL); @@ -9984,7 +9985,8 @@ void initobjects(void) { addflag(lastot->flags, F_RARITY, H_DUNGEON, 70, NA, NULL); addflag(lastot->flags, F_RARITY, H_CAVE, 70, NA, NULL); addflag(lastot->flags, F_OBATTACKDELAY, 150, NA, NA, NULL); - addflag(lastot->flags, F_DAM, DT_BASH, 12, NA, NULL); + addflag(lastot->flags, F_DAM, DT_BASH, 9, NA, NULL); + addflag(lastot->flags, F_EXTRADAM, DT_PIERCE, NA, NA, "1d4"); addflag(lastot->flags, F_ARMOURPIERCE, 6, NA, NA, ""); addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL); addflag(lastot->flags, F_TWOHANDED, SZ_HUMAN, NA, NA, NULL); @@ -20769,6 +20771,7 @@ void initskills(void) { addskilldesc(SK_ARMOUR, PR_NOVICE, "^gReduces armour penalties by 10%.^n", B_FALSE); addskilldesc(SK_ARMOUR, PR_NOVICE, "^gYou can now recognise the quality of armour.^n", B_FALSE); addskilldesc(SK_ARMOUR, PR_BEGINNER, "^gReduces armour penalties by 20%.^n", B_FALSE); + addskilldesc(SK_ARMOUR, PR_BEGINNER, "^gYou can determine the value of armour.^n", B_FALSE); addskilldesc(SK_ARMOUR, PR_ADEPT, "^gReduces armour penalties by 30%.^n", B_FALSE); addskilldesc(SK_ARMOUR, PR_SKILLED, "^gReduces armour penalties by 40%.^n", B_FALSE); addskilldesc(SK_ARMOUR, PR_EXPERT, "^gReduces armour penalties by 50%.^n", B_FALSE); @@ -20835,6 +20838,7 @@ void initskills(void) { addskilldesc(SK_COOKING, PR_BEGINNER, "^gYou now recognise bad food.^n", B_TRUE); addskilldesc(SK_COOKING, PR_BEGINNER, "^gYou can now cook recipes using up to 2 ingredients.^n", B_TRUE); addskilldesc(SK_COOKING, PR_BEGINNER, "^gYou can now cook up to Small sized corpses.^n", B_TRUE); + addskilldesc(SK_COOKING, PR_BEGINNER, "^gYou can determine the value of all food.^n", B_FALSE); addskilldesc(SK_COOKING, PR_ADEPT, "^gYou can now cook recipes using up to 3 ingredients.^n", B_TRUE); addskilldesc(SK_COOKING, PR_ADEPT, "^gYou can now cook up to Medium sized corpses.^n", B_TRUE); addskilldesc(SK_COOKING, PR_SKILLED, "^gYou can now cook recipes using up to 4 ingredients.^n", B_TRUE); @@ -20925,6 +20929,7 @@ void initskills(void) { addskilldesc(SK_SHIELDS, PR_NOVICE, "^gYou can now recognise the quality of shields.^n", B_FALSE); addskilldesc(SK_SHIELDS, PR_BEGINNER, "^gShield accuracy penalties are reduced by 2.^n", B_FALSE); addskillabil(SK_SHIELDS, PR_BEGINNER, OT_A_SHIELDBASH, NA, NULL, B_TRUE); + addskilldesc(SK_SHIELDS, PR_BEGINNER, "^gYou can determine the value of shields.^n", B_FALSE); addskilldesc(SK_SHIELDS, PR_ADEPT, "^gShield accuracy penalties are reduced by 3.^n", B_FALSE); addskillabil(SK_SHIELDS, PR_ADEPT, OT_A_FULLSHIELD, NA, NULL, B_TRUE); addskilldesc(SK_SHIELDS, PR_SKILLED, "^gShield accuracy penalties are reduced by 4.^n", B_FALSE); @@ -21012,6 +21017,7 @@ void initskills(void) { addskilldesc(SK_LORE_ARCANA, PR_NOVICE, "^gYou can attempt to identify wands with the 'inspect' ability.^n", B_FALSE); addskillabil(SK_LORE_ARCANA, PR_NOVICE, OT_A_INSPECT, NA, NULL, B_FALSE); addskilldesc(SK_LORE_ARCANA, PR_BEGINNER, "^gYou can now recognise very common wands.", B_TRUE); + addskilldesc(SK_LORE_ARCANA, PR_BEGINNER, "^gYou can determine the value of all wands.^n", B_FALSE); addskilldesc(SK_LORE_ARCANA, PR_ADEPT, "^gYou can now recognise common wands.", B_TRUE); addskilldesc(SK_LORE_ARCANA, PR_EXPERT, "^gYou can now recognise uncommon wands.", B_TRUE); addskilldesc(SK_LORE_ARCANA, PR_MASTER, "^gYou can now recognise rare wands.", B_TRUE); @@ -21021,6 +21027,7 @@ void initskills(void) { addskillabil(SK_LORE_CHEMISTRY, PR_NOVICE, OT_A_INSPECT, NA, NULL, B_FALSE); addskilldesc(SK_LORE_CHEMISTRY, PR_NOVICE, "^gYou can now mix venom sacs into potions to create poison.^n", B_TRUE); addskilldesc(SK_LORE_CHEMISTRY, PR_BEGINNER, "^gYou can now recognise very common potions.^n", B_TRUE); + addskilldesc(SK_LORE_CHEMISTRY, PR_BEGINNER, "^gYou can determine the value of all potions.^n", B_FALSE); addskilldesc(SK_LORE_CHEMISTRY, PR_ADEPT, "^gYou can now recognise common potions.^n", B_TRUE); addskilldesc(SK_LORE_CHEMISTRY, PR_SKILLED, "^gYou can now bottle the blood of all creatures.^n", B_TRUE); addskilldesc(SK_LORE_CHEMISTRY, PR_EXPERT, "^gYou can now recognise uncommon potions.^n", B_TRUE); @@ -21036,16 +21043,19 @@ void initskills(void) { addskillabil(SK_LORE_LANGUAGE, PR_NOVICE, OT_A_INSPECT, NA, NULL, B_FALSE); addskillabil(SK_LORE_LANGUAGE, PR_ADEPT, OT_A_STUDYSCROLL, NA, NULL, B_TRUE); addskilldesc(SK_LORE_LANGUAGE, PR_BEGINNER, "^gYou can now recognise very common scrolls and books.", B_TRUE); + addskilldesc(SK_LORE_LANGUAGE, PR_BEGINNER, "^gYou can determine the value of all scrolls and books.^n", B_FALSE); addskilldesc(SK_LORE_LANGUAGE, PR_ADEPT, "^gYou can now recognise common scrolls and books.", B_TRUE); addskilldesc(SK_LORE_LANGUAGE, PR_EXPERT, "^gYou can now recognise uncommon scrolls and books.", B_TRUE); addskilldesc(SK_LORE_LANGUAGE, PR_MASTER, "^gYou can now recognise rare scrolls and books.", B_TRUE); addskill(SK_LORE_NATURE, "Lore:Nature", "Determines your knowledge of plants, animals and insects.", 5); + addskilldesc(SK_LORE_NATURE, PR_BEGINNER, "^gYou can determine the value of all flora.^n", B_FALSE); addskill(SK_LORE_UNDEAD, "Lore:Undead", "Determines your knowledge of the undead.", 5); addskill(SK_LORE_DRAGONS, "Lore:Wyrms", "Determines your knowledge about wryms.", 5); addskill(SK_LORE_RELICS, "Lore:Relics", "Allows you a chance of recognising rings and amulets.", 5); addskilldesc(SK_LORE_RELICS, PR_NOVICE, "^gYou can attempt to identify rings/amulets with the 'inspect' ability.^n", B_FALSE); addskillabil(SK_LORE_RELICS, PR_NOVICE, OT_A_INSPECT, NA, NULL, B_FALSE); addskilldesc(SK_LORE_RELICS, PR_BEGINNER, "^gYou can now recognise very common rings and amulets.", B_TRUE); + addskilldesc(SK_LORE_RELICS, PR_BEGINNER, "^gYou can determine the value of all rings and amulets.^n", B_FALSE); addskilldesc(SK_LORE_RELICS, PR_ADEPT, "^gYou can now recognise common rings and amulets.", B_TRUE); addskilldesc(SK_LORE_RELICS, PR_EXPERT, "^gYou can now recognise uncommon rings and amulets.", B_TRUE); addskilldesc(SK_LORE_RELICS, PR_MASTER, "^gYou can now recognise rare rings and amulets.", B_TRUE); @@ -21208,6 +21218,7 @@ void initskills(void) { addskilldesc(sk->id, PR_NOVICE, "^gEliminates accuracy penalties with matching weapons.^n", B_FALSE); addskilldesc(sk->id, PR_BEGINNER, "^g+1 accuracy.^n", B_FALSE); addskilldesc(sk->id, PR_BEGINNER, "^gYou gain the 'wild strike' ability.^n", B_FALSE); + addskilldesc(sk->id, PR_BEGINNER, "^gYou can determine the value of matching weapons.^n", B_FALSE); addskilldesc(sk->id, PR_ADEPT, "^g+10% damage bonus.^n", B_FALSE); addskilldesc(sk->id, PR_ADEPT, "^g+2 accuracy.^n", B_FALSE); if (sk->id == SK_UNARMED) { diff --git a/defs.h b/defs.h index 25698f1..651c3e2 100755 --- a/defs.h +++ b/defs.h @@ -401,7 +401,8 @@ #define SPEEDUNIT 5 // experience -#define SKILLXPPERPOINT 150 +//#define SKILLXPPERPOINT 150 +#define SKILLXPPERPOINT 100 // speed settings (lower is faster) #define SPEED_ATTACK SP_NORMAL @@ -3440,8 +3441,10 @@ enum FLAG { // damage dealt to less than v0. // if v0 = b_true (or less than 0) it will // pierce ALL armour - F_TWOHANDED, // weapon uses two hands to weild, if lf is size v0 - // or smaller. + F_TWOHANDED, // weapon uses two hands to weild, unless: + // lf size is greater than v0 + // _OR_ + // lf str is >= getonehandedstr(o) F_NEEDSSPACE, // weapon needs space to swing - 75% chance of hitting // a wall if used with < 3 empty cells around you // gun flags @@ -3748,7 +3751,7 @@ enum FLAG { F_CAREFULMOVE, // moving slowly on purpose to avoid slipping. F_AUTOCMD, // val0 = how many times to repeat this F_LASTCMD, // text[0] = last command performed, v0/1 = x/y of cell, v2=various - F_LASTSPELL, // val0=id of last spell cast, for player only + F_LASTSPELL, // val0=id of last spell cast, for player only F_WILLTHROW, // this lf will treat obid v0 as a thrown missile. F_CANSTUDY, // lf can study spells from school v0 F_CANLEARN, // lf is able to learn skill val0 @@ -4227,9 +4230,10 @@ enum FLAG { // if v1 is true, actual lf glyphs are shown. // otherwise just an indicative size is shown F_DETECTMAGIC, // autodetect magic/special objects - F_DETECTMETAL, // autodetect nearby metal - F_DETECTOBS, // autodetect nearby obs of type v1 in orthog dist v0 + F_DETECTMETAL, // autodetect nearby metal within orthog distance v0 + F_DETECTOBS, // autodetect nearby obs of type v1 & value >= txt in orthog dist v0 // v1 = NA means everything. + // txt = NULL means everything. F_DISEASEIMMUNE, // lf can't be diseased F_DRUNK, // v0 is drunknness - 1-5. F_ENHANCESEARCH, // gives v0 bonus on search checks. @@ -4703,6 +4707,7 @@ enum ERROR { E_VEGETARIAN, E_PARTVEGETARIAN, E_CARNIVORE, + E_NAUSEATED, E_NOOB, E_LEVITATING, E_PRONE, diff --git a/io.c b/io.c index 8264ff1..0880311 100755 --- a/io.c +++ b/io.c @@ -1,6 +1,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -1739,7 +1740,18 @@ int announceflaggain(lifeform_t *lf, flag_t *f) { break; case F_DETECTOBS: if (isplayer(lf)) { // don't know if monsters get it - msg("You can now detect nearby objects."); + objecttype_t *ot; + char *p = NULL; + if (f->val[1] != NA && (ot = findot(f->val[1]))) { + p = strdup(ot->name); + makeplural(&p); + } + if (f->text) { + msg("You can now detect nearby %s worth at least $%s.", p ? p : "objects", f->text); + } else { + msg("You can now detect nearby %s.", p ? p : "objects"); + } + if (p) free(p); donesomething = B_TRUE; } break; @@ -5012,7 +5024,7 @@ void docommslf(lifeform_t *lf, char ch, lifeform_t *lf2, cell_t *targc) { noresponse = B_TRUE; } if (noresponse) { - + if (cansee(player, lf)) msg("%s doesn't respond.", lfname); break; } @@ -6265,11 +6277,12 @@ char *makedesc_ob(object_t *o, char *retbuf) { char buf3[BUFLEN]; recipe_t *rec; flag_t *f; + objecttype_t *ot; int obknown,i,throwrange, b; flag_t *retflag[MAXCANDIDATES]; int nretflags; object_t *compareob = NULL; - char *loctext,*p; + char *loctext,*p = NULL; char retalname[BUFLEN],dicetext[BUFLEN]; // do we need to compare this object with an equipped on? @@ -6328,6 +6341,7 @@ char *makedesc_ob(object_t *o, char *retbuf) { strncat(retbuf, "It is very poorly crafted.\n", HUGEBUFLEN); } + // weight if (o->material->id != MT_NOTHING) { float obw; @@ -6434,9 +6448,11 @@ char *makedesc_ob(object_t *o, char *retbuf) { // unknown items? if (isknown(o)) { + int showvalue = B_FALSE; // weapons? if (isfirearm(o)) { flag_t *ff, *ff2,*twohandf; + int ohs; twohandf = hasflag(o->flags, F_TWOHANDED); sprintf(buf, "It is a %s firearm.\n", twohandf ? "two-handed" : "single handed"); @@ -6446,9 +6462,13 @@ char *makedesc_ob(object_t *o, char *retbuf) { char sizebuf[BUFLEN]; sprintf(sizebuf, "%s", getsizetext(twohandf->val[0] + 1)); capitalise(sizebuf); - snprintf(buf2, BUFLEN, "@%s creatures can weild it in one hand.\n", sizebuf); + snprintf(buf2, BUFLEN, "@%s creatures can wield it in one hand.\n", sizebuf); strncat(retbuf, buf2, HUGEBUFLEN); } + if ((ohs = getonehandedstr(o)) != IMPOSSIBLE) { + snprintf(buf2, BUFLEN, "@Creatures with a Strength of at least %d can wield it in one hand.\n", ohs); + strncat(retbuf, buf2, HUGEBUFLEN); + } f = hasflag(o->flags, F_ACCURACY); if (f) { @@ -6505,8 +6525,7 @@ char *makedesc_ob(object_t *o, char *retbuf) { } else if (isweapon(o) && isknown(o)) { flag_t *damflag,*twohandf; float stamcost = STAMTOATTACK; - int delay; - int critchance; + int delay,critchance,ohs; twohandf = hasflag(o->flags, F_TWOHANDED); @@ -6557,6 +6576,10 @@ char *makedesc_ob(object_t *o, char *retbuf) { snprintf(buf2, BUFLEN, "@%s creatures can weild it in one hand.\n", sizebuf); strcat(buf, buf2 ); } + if ((ohs = getonehandedstr(o)) != IMPOSSIBLE) { + snprintf(buf2, BUFLEN, "@Creatures with a Strength of at least %d can wield it in one hand.\n", ohs); + strncat(buf, buf2, HUGEBUFLEN); + } snprintf(buf2, BUFLEN, "@It has a base Damage Rating of %d",dr); strcat(buf, buf2); @@ -7034,6 +7057,90 @@ char *makedesc_ob(object_t *o, char *retbuf) { strncat(retbuf, buf, HUGEBUFLEN); } } + + // item value + if (getskill(player, SK_PERCEPTION) >= PR_EXPERT) { + showvalue = B_TRUE; + } + if (!showvalue) { + f = hasflag(o->flags, F_USESSKILL); + if (f && (f->val[0] != SK_NONE)) { + if (getskill(player, f->val[0]) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + } + if (!showvalue && !hasflag(o->flags, F_SHIELD)) { + if (getskill(player, SK_SHIELDS) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_ARMOUR && + !hasflag(o->flags, F_SHIELD)) { + if (getskill(player, SK_ARMOUR) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && + (o->type->obclass->id == OC_RING || + o->type->obclass->id == OC_AMULET) + ) { + if (getskill(player, SK_LORE_RELICS) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + + if (!showvalue && + (o->type->obclass->id == OC_BOOK || + o->type->obclass->id == OC_SCROLL) + ) { + if (getskill(player, SK_LORE_LANGUAGE) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_WAND) { + if (getskill(player, SK_LORE_ARCANA) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_POTION) { + if (getskill(player, SK_LORE_CHEMISTRY) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_TECH) { + if (getskill(player, SK_TECHUSAGE) >= gettechlevel(o->type->id)) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_FOOD) { + if (getskill(player, SK_COOKING) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue && o->type->obclass->id == OC_FLORA) { + if (getskill(player, SK_LORE_NATURE) >= PR_BEGINNER) { + showvalue = B_TRUE; + } + } + if (!showvalue) { + enum MATERIAL repairablemats[MAXCANDIDATES]; + int nmats = 0; + getworkablematerials(player, SK_METALWORK, repairablemats, NULL, &nmats); + getworkablematerials(player, SK_SEWING, repairablemats, NULL, &nmats); + for (i = 0; i < nmats; i++) { + if (o->material->id == repairablemats[i]) { + showvalue = B_TRUE; + break; + } + } + } + if (showvalue) { + int value; + value = getobvalue(o); + snprintf(buf, BUFLEN, "It is worth roughly $%d.\n", value); + strncat(retbuf, buf, HUGEBUFLEN); + } } // end if isknown // charges remaining @@ -7243,7 +7350,6 @@ char *makedesc_ob(object_t *o, char *retbuf) { for (f = o->flags->first[b] ; f ; f = f->next) { if ((f->id == F_HOLDCONFER) || (f->id == F_EQUIPCONFER) || (f->id == F_ACTIVATECONFER)) { if (obknown && f->known) { - objecttype_t *ot; if (f->id == F_HOLDCONFER) strcpy(buf, "When held, it"); else if (f->id == F_ACTIVATECONFER) strcpy(buf, "When activated, it"); else if (f->id == F_HITCONFER) strcpy(buf, "When hit by it, it"); @@ -7321,8 +7427,20 @@ char *makedesc_ob(object_t *o, char *retbuf) { strncat(retbuf, buf2, HUGEBUFLEN); break; case F_DETECTOBS: - snprintf(buf2, BUFLEN, "%s lets you detect nearby objects.\n", buf); + if (f->val[2] != NA) { + ot = findot(f->val[2]); + if (ot) { + p = strdup(ot->name); + makeplural(&p); + } + } + if (f->text) { + snprintf(buf2, BUFLEN, "%s lets you detect nearby %s worth at least $%s.\n", buf, p ? p : "objects", f->text); + } else { + snprintf(buf2, BUFLEN, "%s lets you detect nearby %s.\n", buf, p ? p : "objects"); + } strncat(retbuf, buf2, HUGEBUFLEN); + if (p) free(p); break; case F_DETECTMAGIC: snprintf(buf2, BUFLEN, "%s will detect magical enchantments on objects.\n", buf); @@ -8278,7 +8396,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel case F_VEGETARIAN: if (lorelev >= PR_ADEPT) sprintf(buf, "Will not eat meat."); break; case F_VISRANGEMOD: if (lorelev >= PR_BEGINNER) { - if (f->val[0] < 0) sprintf(buf, "Reduced vision range (%d)", f->val[0]); + if (f->val[0] < 0) sprintf(buf, "Reduced vision range (%d)", f->val[0]); } break; case F_PARTVEGETARIAN: if (lorelev >= PR_ADEPT) sprintf(buf, "Will only eat meat when hungry."); break; @@ -9970,7 +10088,7 @@ void drawlevelfor(lifeform_t *lf) { // only draw if screen char/colour is different //if (!screenglyphmatches(x, y, &glyph)) { drawglyph(&glyph, x, y); - //if (db) { dblog(" drawing char '%lc'/%d at %d,%d (screenglyph was '%lc'/%d)\n\n", glyph.ch, glyph.ch, x,y, screenglyph.ch, screenglyph.ch); } + //if (db) { dblog(" drawing char '%lc'/%d at %d,%d (screenglyph was '%lc'/%d)\n\n", glyph.ch, glyph.ch, x,y, screenglyph.ch, screenglyph.ch); } ndrawn++; //} } @@ -10058,15 +10176,25 @@ void initgfx(void) { int i; short r,g,b; struct winsize ws; - int w,h; + //int w = 0,h = 0,rv; + int rv; - ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); - w = ws.ws_col; - h = ws.ws_row; + ws.ws_col = 0; + ws.ws_row = 0; - if ((w < 80) || (h < 25)) { - printf("Error - Terminal size must be at least 80x25 (current: %d x %d).\n", w, h); - exit(1); + rv = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); + if (rv != -1 || ws.ws_col == 0 || ws.ws_row == 0) { + // handle lldb dumbness + int fd = open("/dev/tty", O_RDONLY); + if (fd != -1) { + ioctl(fd, TIOCGWINSZ, &ws); + close(fd); + } + } + + if ((ws.ws_col < 80) || (ws.ws_row < 25)) { + printf("Error - Terminal size must be at least 80x25 (current: %d x %d).\n", ws.ws_col, ws.ws_row); + exit(1); } setlocale(LC_CTYPE, ""); @@ -14611,9 +14739,20 @@ void showlfstats(lifeform_t *lf, int showall) { } f = lfhasknownflag(lf, F_DETECTOBS); if (f) { - getflagsourcetext(f,source); - effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect nearby objects.%s", you(lf),source); + objecttype_t *ot; + char *p = NULL; + if (f->val[1] != NA && (ot = findot(f->val[1]))) { + p = strdup(ot->name); + makeplural(&p); + } + getflagsourcetext(f,source); + if (f->text) { + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect nearby %s worth at least $%s.%s", you(lf), p ? p : "objects", f->text, source); + } else { + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect nearby %s.%s", you(lf), p ? p : "objects", source); + } + if (p) free(p); } f = lfhasknownflag(lf, F_ENHANCESEARCH); if (f) { diff --git a/lf.c b/lf.c index 21a8def..f157d33 100755 --- a/lf.c +++ b/lf.c @@ -1011,6 +1011,10 @@ int caneat(lifeform_t *lf, object_t *o) { reason = E_CARNIVORE; return B_FALSE; } + if (lfhasflag(lf, F_NAUSEATED)) { + reason = E_NAUSEATED; + return B_FALSE; + } } if (lfhasflag(lf, F_PARTVEGETARIAN) && hasflag(o->flags, F_ISMEAT)) { @@ -5078,6 +5082,9 @@ int eat(lifeform_t *lf, object_t *o) { getobname(oo,buf, 1); msg("You can't eat through your %s!", noprefix(buf)); break; + case E_NAUSEATED: + msg("You are too nauseated to eat."); + break; case E_WRONGOBTYPE: default: msg("You can't eat that!"); diff --git a/map.c b/map.c index 5641d82..0b0214a 100755 --- a/map.c +++ b/map.c @@ -63,12 +63,12 @@ extern condset_t ccroom; cell_t *addcell(map_t *m, int x, int y) { cell_t *cell; - + // already allocated? cell = m->cell[(y*m->w)+x]; if (cell) { clearcell(cell); - killcell(&cell); + killcell(&cell); //free(cell); } @@ -105,7 +105,7 @@ cell_t *addcell(map_t *m, int x, int y) { habitat_t *addhabitat(enum HABITAT id, char *name, enum CELLTYPE emptycell, enum CELLTYPE solidcell, int thingchance, int obchance, int vaultchance, int maxvisrange, enum OBTYPE upstairtype, enum OBTYPE downstairtype, int stairsinrooms, enum TEMPERATURE temp) { habitat_t *a; - // add to the end of the list + // add to the end of the list if (firsthabitat == NULL) { firsthabitat = malloc(sizeof(habitat_t)); a = firsthabitat; @@ -172,7 +172,7 @@ void addhomeobs(lifeform_t *lf, int dolevelobs) { if (range != NA) { getradiuscells(lf->cell, range, DT_COMPASS, B_FALSE, LOF_NEED, B_FALSE, retcell, &nretcells, B_FALSE); } - + for (i = 0; i < amt; i++) { object_t *o = NULL; cell_t *c; @@ -194,7 +194,7 @@ void addhomeobs(lifeform_t *lf, int dolevelobs) { } else { // within 'range' cells c = retcell[rnd(0,nretcells - 1)]; - o = addob(c->obpile, f->text); + o = addob(c->obpile, f->text); } if (o) { @@ -219,9 +219,9 @@ map_t *addmap(void) { id = lastmap->id + 1; } else { id = 0; - } + } - // add to the end of the list + // add to the end of the list if (firstmap == NULL) { firstmap = malloc(sizeof(map_t)); a = firstmap; @@ -250,7 +250,7 @@ map_t *addmap(void) { a->illumination = IL_FULLLIT; a->habitat = findhabitat(H_DUNGEON); // default!!! a->lastplayervisit = -1; - a->nfixedrooms = 0; + a->nfixedrooms = 0; return a; } @@ -312,7 +312,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok killflagpile(wantflags); return NULL; } - + if (db) { char buf[BUFLEN]; snprintf(buf, BUFLEN, "addmonster for '%s'->%s",racename, r->name); @@ -335,7 +335,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok killflagpile(wantflags); return lf; } - } + } //if gamemode == GM_GAMESTARTED checkallflags(player->cell->map); // debugging lf = addlf(c, r->id, getrandommonlevel(r, c->map)); @@ -343,7 +343,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok //if gamemode == GM_GAMESTARTED checkallflags(player->cell->map); // debugging if (lf) { flag_t *f; - + if (nadded) (*nadded)++; if (db) dblog("checking for job"); @@ -392,7 +392,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok if (rnd(1,100) <= f->val[0]) { // note: if we start off hidden, we have no hide penalty. // this is so we can have monsters which start hidden, but - // don't have the 'hide' skill. + // don't have the 'hide' skill. addflag(wantflags, F_HIDING, 0, NA, NA, NULL); } } @@ -415,7 +415,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok } } if (willsleep) { - addflag(wantflags, F_ASLEEP, NA, ST_ASLEEP, NA, NULL); + addflag(wantflags, F_ASLEEP, NA, ST_ASLEEP, NA, NULL); } } } @@ -567,15 +567,15 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok } //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging - + if (db) dblog("handling random objects"); - // sometimes give the lf random objects (extra monsters through + // sometimes give the lf random objects (extra monsters through // 'numappears' don't get them). if (onein(3)) { giverandomobs(lf, rnd(1,3)); while (onein(3)) { giverandomobs(lf, 1); - } + } } //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging @@ -613,7 +613,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging } // end if lf - } // end if r + } // end if r //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging // free mem @@ -670,7 +670,7 @@ int addrandomthing(cell_t *c, int obchance, int *nadded) { // ensure it has proper resistances copyflags(lf->flags, c->habitat->monflags, NA); } - } + } //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging } return rv; @@ -690,7 +690,7 @@ map_t *getmapindir(map_t *src, int dir) { return other; } -// +// int getmapmaxvisrange(map_t *m) { int maxrange; @@ -781,7 +781,7 @@ void getradiuscells(cell_t *centre, int radius, int dirtype, int outsideonly, en int getroomid(cell_t *c) { if (c->room) { return c->room->id; - } + } return -1; } @@ -859,9 +859,9 @@ region_t *addregion(enum BRANCH rtype, region_t *parent, int outlineid, int dept id = lastregion->id + 1; } else { id = 0; - } + } - // add to the end of the list + // add to the end of the list if (firstregion == NULL) { firstregion = malloc(sizeof(region_t)); a = firstregion; @@ -914,7 +914,7 @@ regionoutline_t *addregionoutline(enum BRANCH rtype) { nextid = lastregionoutline->id + 1; } - // add to the end of the list + // add to the end of the list if (firstregionoutline == NULL) { firstregionoutline = malloc(sizeof(regionoutline_t)); a = firstregionoutline; @@ -966,7 +966,7 @@ regionthing_t *addregionthing(regionoutline_t *ro, int depth, int x, int y, enum branch_t *addbranch(enum BRANCH id, char *name, int pluralname, enum HABITAT defaulthabitat, int maxdepth, int stairsperlev, int deeperdir, int major, int depthmod, int addparentdepth) { branch_t *a; - // add to the end of the list + // add to the end of the list if (firstbranch == NULL) { firstbranch = malloc(sizeof(branch_t)); a = firstbranch; @@ -1072,9 +1072,9 @@ void adjustcellglyph(cell_t *c, glyph_t *g, enum CELLADJUSTTYPE how) { g->ch = 0x253c; break; default: if (c->known) { - g->ch = c->knownglyph.ch; + g->ch = c->knownglyph.ch; } else { - g->ch = 0x2500; + g->ch = 0x2500; } break; } @@ -1191,7 +1191,7 @@ int autodoors(map_t *map, int roomid, int minx, int miny, int maxx, int maxy, in break; } sel = rnd(0,nposs-1); - used[poss[sel]] = B_TRUE; + used[poss[sel]] = B_TRUE; dodoor[ndoors++] = poss[sel]; } @@ -1230,7 +1230,7 @@ void breakwall(cell_t *c, char *why, ...) { va_start(args, why); vsnprintf( buf, BUFLEN, why, args ); va_end(args); - } + } origtype = c->type; roomwall = isroom(c); @@ -1290,7 +1290,7 @@ int cellhaslos(cell_t *c1, cell_t *dest) { // can always see your own cell if ((deltax == 0) && (deltay == 0)) { return B_TRUE; - } + } if (deltax >= deltay) { numpixels = deltax + 1; @@ -1351,7 +1351,7 @@ int cellhaslos(cell_t *c1, cell_t *dest) { if (!cell->type->transparent) { return B_FALSE; } - + /* // check for smoke if ((x != x1) || (y != y1)) { // if not in first cell @@ -1373,7 +1373,7 @@ int cellhaslos(cell_t *c1, cell_t *dest) { // ok. } else { return B_FALSE; - } + } } else { return B_FALSE; } @@ -1393,9 +1393,9 @@ int cellhaslos(cell_t *c1, cell_t *dest) { // is the given cell a wall of a vault with maintain_edge, and not marked as an exit? int cellisfixedvaultwall(cell_t *c) { - if ( getcellvault(c) && - c->type->solid && - hasflag(c->room->vault->flags, F_MAINTAINEDGE) && + if ( getcellvault(c) && + c->type->solid && + hasflag(c->room->vault->flags, F_MAINTAINEDGE) && !hasflagval(c->map->flags, F_ROOMEXIT, c->room->id, c->x, c->y, NULL) ) { return B_TRUE; } @@ -1405,7 +1405,7 @@ int cellisfixedvaultwall(cell_t *c) { int adjcellokforreachability(cell_t *c, int srcroomid, int dir, int wantfilled) { int proomid; proomid = getroomid(c); - if ( ((srcroomid == -1) || (proomid != srcroomid)) && + if ( ((srcroomid == -1) || (proomid != srcroomid)) && cellwalkable(NULL, c, NULL) && !c->locked) { if ((proomid >= 0) && (dir != D_NONE) && (c->isroomwall != D_NONE) && (c->isroomwall != diropposite(dir))) { @@ -1614,7 +1614,7 @@ int cellokforreachability(cell_t *startcell, cell_t *c, int srcroomid, int dir, if (db) dblog(" going %s hits locked cell(%s). invalid.", getdirname(dir),c->lockedreason); if (why) sprintf(why, " going %s hits locked cell(%s). invalid.", getdirname(dir),c->lockedreason); return B_FALSE; - } else if ((srcroomid >= 0) && (getroomid(c) == srcroomid) && c->type->solid && startcell->type->solid) { + } else if ((srcroomid >= 0) && (getroomid(c) == srcroomid) && c->type->solid && startcell->type->solid) { // hits a wall of the same room, // and start cell NOT one inside the room. @@ -1623,7 +1623,7 @@ int cellokforreachability(cell_t *startcell, cell_t *c, int srcroomid, int dir, if (db) dblog(" going %s hits wall of same room. invalid.", getdirname(dir)); if (why) sprintf(why," going %s hits wall of same room. invalid.", getdirname(dir)); return B_FALSE; - } else if (isroom(c) && (getroomid(c) != srcroomid) && (c->isroomwall != D_NONE) && (dir != D_NONE) && + } else if (isroom(c) && (getroomid(c) != srcroomid) && (c->isroomwall != D_NONE) && (dir != D_NONE) && (c->isroomwall != diropposite(dir))) { // cell is in a different room, but not the correct edge // invalid @@ -1829,7 +1829,7 @@ int delve(map_t *map, int neighbourmin, int neighbourmax, int connchance, int ch } ncount = countadjcellsoftype(c, empty, DT_COMPASS); ngroups = delve_countadjgroups(c, empty); - + // for the moment, stay close to the origin if (c->type->solid && (getcelldist(c,startcell) <= 2) && (ncount <= neighbourmax) && ((ngroups <= 1) || (pctchance(connchance)) ) ) { @@ -1922,7 +1922,7 @@ int delve(map_t *map, int neighbourmin, int neighbourmax, int connchance, int ch dblog("generated map:"); dumpmap(map, B_FALSE, NULL); dblog("END DELVE DEBUG:"); - + return cellsdone; } @@ -1984,7 +1984,7 @@ int delve_countadjgroups(cell_t *centre, enum CELLTYPE ct) { // started. if (d == DC_N) { int dd,foundend = B_FALSE; - for (dd = DC_NW; dd >= DC_NE; dd--){ + for (dd = DC_NW; dd >= DC_NE; dd--){ cell_t *c2; c2 = getcellindir(centre, dd); // doesn't match? stop here. @@ -1995,7 +1995,7 @@ int delve_countadjgroups(cell_t *centre, enum CELLTYPE ct) { } } if (!foundend) { - // ie. completely surrounded by + // ie. completely surrounded by // correct type. this means 1 group. return 1; } @@ -2053,7 +2053,7 @@ int delve_digcell(cellstore_t *cs, cell_t *centre, enum CELLTYPE empty, enum CEL for (i = 0 ; i < 8; i++) { int newpos; int temp; - newpos = rnd(0,7); + newpos = rnd(0,7); temp = dir[newpos]; dir[newpos] = dir[i]; dir[i] = temp; @@ -2095,9 +2095,9 @@ void delve_killcellstore(cellstore_t *cs) { cell_t *delve_rndpull(cellstore_t *cs, cell_t **c) { int index,min,max; *c = NULL; - + if (cs->ncells <= 0) return NULL; - + // *** "fluffy" patterns if (cs->ncells < cs->cutoff) { min = 0; @@ -2146,7 +2146,7 @@ void delve_storecell(cellstore_t *cs, cell_t *c) { int damagecell(cell_t *c, int amt, enum DAMTYPE damtype, lifeform_t *fromlf) { if (!c->type->solid) return B_TRUE; - // adjust dam + // adjust dam adjustdammaterial(&amt, damtype, c->type->material->id); if (amt <= 0) return B_TRUE; @@ -2174,7 +2174,7 @@ int damagecell(cell_t *c, int amt, enum DAMTYPE damtype, lifeform_t *fromlf) { shattered = B_TRUE; noise(c, NULL, NC_OTHER, SV_CAR, "something shattering.", NULL); if (getshardobname(cellmat, what)) { - fragments(c, what, 3, 3); + fragments(c, what, 3, 3); } } else { switch (cellmat) { @@ -2203,7 +2203,7 @@ int doelementspread(cell_t *c) { //int db = B_FALSE; object_t *fireob = NULL; - if (!c || c->type->solid) { + if (!c || c->type->solid) { return B_FALSE; } @@ -2233,10 +2233,10 @@ int doelementspread(cell_t *c) { // ok = B_FALSE; // //ok = B_TRUE; //} else if (newc->type->floorheight < c->type->floorheight) { - // // ie. downhill. don't include these + // // ie. downhill. don't include these // ok = B_FALSE; //} else if (newc->type->floorheight > c->type->floorheight) { - // // ie. uphill. + // // ie. uphill. // ok = B_TRUE; //} if (newc->type->floorheight == c->type->floorheight) { @@ -2256,7 +2256,7 @@ int doelementspread(cell_t *c) { } } - + // if there were any posisble cells around us if (nsurround) { float newdepth; @@ -2279,7 +2279,7 @@ int doelementspread(cell_t *c) { flag_t *f; sc = surroundcell[i]; - + f = hasflagval(sc->map->flags, F_NEWWATERDEPTH, sc->x, sc->y, NA, NULL); if (f) { f->val[2] += newdepth; @@ -2287,7 +2287,7 @@ int doelementspread(cell_t *c) { addflag(sc->map->flags, F_NEWWATERDEPTH, sc->x, sc->y, (int)newdepth, NULL); } } - + return B_TRUE; } } @@ -2302,7 +2302,7 @@ int doelementspread(cell_t *c) { object_t *oo,*nextoo; damflag = hasflagval(fireob->flags, F_WALKDAM, DT_FIRE, NA, NA, NULL); - + // check adjacent cells (and this one) for flammable stuff getradiuscells(c, 1, DT_COMPASS, B_FALSE, LOF_DONTNEED, B_TRUE, retcell, &nretcells, B_FALSE); for (i = 0; i < nretcells; i++) { @@ -2314,7 +2314,7 @@ int doelementspread(cell_t *c) { flag_t *f; nextoo = oo->next; - // there's already a fire here. + // there's already a fire here. // f_onfire flags won't expire if there is fire there. if (hasfire) { f = hasflag(oo->flags, F_ONFIRE); @@ -2370,7 +2370,7 @@ int doelementspread(cell_t *c) { } } } - return B_FALSE; + return B_FALSE; } // returns # cells filled in @@ -2400,7 +2400,7 @@ int dodoorfill(cell_t *c) { if (db) { int order[9] = { DC_NW, DC_N, DC_NE, - DC_W, D_NONE, DC_E, + DC_W, D_NONE, DC_E, DC_SW, DC_S, DC_SE }; int i; @@ -2415,7 +2415,7 @@ int dodoorfill(cell_t *c) { c2 = getcellindir(c, dir); if (c2) { if (c2->filled) { - strcat(buf, "F"); + strcat(buf, "F"); } else { if (issolid(c2)) { strcat(buf, "#"); @@ -2436,7 +2436,7 @@ int dodoorfill(cell_t *c) { break; } } - + } return nfilled; @@ -2502,12 +2502,12 @@ int fix_reachability(map_t *m) { } // floodfill floodfill(c); - + // any remaining non-filled empty cells? nunreach = 0; nreach = 0; for (i = 0; i < m->w * m->h; i++) { - if (!m->cell[i]->type->solid && !m->cell[i]->filled && + if (!m->cell[i]->type->solid && !m->cell[i]->filled && ((m->cell[i]->room && m->cell[i]->room->prevault) || !m->cell[i]->locked ) ) { vault_t *v; // cell is unreachable @@ -2515,7 +2515,7 @@ int fix_reachability(map_t *m) { if (v && hasflag(v->flags, F_VAULTNOLINK)) { // don't need to link it. } else if (!countcellexits(c, DT_COMPASS) && !hasobwithflag(c->obpile, F_STAIRS)) { - // completely surrounded by walls. + // completely surrounded by walls. clearcell(c); setcelltype(c,getmapsolid(m)); } else { @@ -2569,7 +2569,7 @@ int fix_reachability(map_t *m) { int ptries = 0,maxtries = 5; // failed! try to link via portals. if (db) dblog(" couldn't link via tunnels. trying to link via portals."); - // select random REACHABLE cell + // select random REACHABLE cell while (ptries < maxtries) { rcell = reachcell[rnd(0,nreach-1)]; if (!createportallink(ucell,rcell, OT_PORTAL)) { @@ -2609,24 +2609,24 @@ int fix_reachability(map_t *m) { // be non-solid if (!celltypefromvault(unreachcell[i]) && (unreachcell[i]->type->id == curemp) ) { - // chance floor style + // chance floor style setcelltype(unreachcell[i], newemp); } // check for surrounding walls for (dir = DC_N; dir <= DC_NW; dir++) { cell_t *c2; c2 = getcellindir(unreachcell[i], dir); - if (c2 && issolid(c2) && !celltypefromvault(c2) && + if (c2 && issolid(c2) && !celltypefromvault(c2) && !cellisfixedvaultwall(c2)) { if (c2->type->id == cursol) { - // chance wall style + // chance wall style setcelltype(c2, newsol); } } } } } - + // now run the test again. // 'c' will be where the next flood will will happen. c = ucell; @@ -2700,7 +2700,7 @@ void floodfill(cell_t *startcell) { // new levels due to unlinked portals. f = hasflag(o->flags, F_MAPLINK); if (f && (f->val[0] == startcell->map->id) && - (f->val[1] != NA) && (f->val[2] != NA)) { + (f->val[1] != NA) && (f->val[2] != NA)) { cell_t *c; c = getcellat(startcell->map, f->val[1], f->val[2]); if (c) { @@ -2759,7 +2759,7 @@ int getbranchlinks(regionthing_t **thing, int *nthings, ...) { } } else if (temp->whatkind == RT_HABITAT) { thing[(*nthings)++] = temp; - } + } } } } @@ -2785,9 +2785,9 @@ cell_t *getcell_cond(map_t *map, condset_t *cs ) { c = poss[rnd(0,nposs-1)]; } else { c = NULL; - } + } free(poss); - + return c; } @@ -2821,7 +2821,7 @@ int getcellclimbdifficultyavg(cell_t *c) { int d; int diff = 0; int nwalls = 0; - + for (d = DC_N; d <= DC_NW; d++) { cell_t *newcell; newcell = getcellindir(c, d); @@ -2925,7 +2925,7 @@ void getcellglyph(glyph_t *g, cell_t *c, lifeform_t *viewer) { if (g->ch == '.') { g->ch = ' '; } - // out of LOS - show as dark + // out of LOS - show as dark // unless it's a certain kind of glyph if ((slev >= PR_BEGINNER) && (c->known == KG_STAIRS)) { ////////// colour ?? @@ -2951,7 +2951,7 @@ enum CELLTYPE getcellempty(cell_t *c) { if (c->habitat == c->map->habitat) { f = hasflag(c->map->flags, F_CELLTYPEEMPTY); if (f) return f->val[0]; - } + } return c->habitat->emptycelltype; } @@ -2969,7 +2969,7 @@ enum CELLTYPE getcellsolid(cell_t *c) { if (c->habitat == c->map->habitat) { f = hasflag(c->map->flags, F_CELLTYPESOLID); if (f) return f->val[0]; - } + } return c->habitat->solidcelltype; } @@ -3008,18 +3008,18 @@ enum DEPTH getcellwaterdepth(cell_t *c, lifeform_t *lf) { int getconnectedwatercells(cell_t *c, cell_t **retcell, int *ncells) { int d; int i,found = B_FALSE; - + for (i = 0; i < *ncells; i++) { if (retcell[i] == c) { found = B_TRUE; break; } } - + if (c && // not off the map !found && // not already processed !c->type->solid && // empty cell - hasobofmaterial(c->obpile, MT_WATER)) { // has water + hasobofmaterial(c->obpile, MT_WATER)) { // has water retcell[*ncells] = c; (*ncells)++; } else { @@ -3070,7 +3070,7 @@ cell_t *get_explore_target(lifeform_t *lf) { newcell = getcellat(lf->cell->map,x,y); if (newcell) { nok++; - if (newcell->known != KG_UNKNOWN && + if (newcell->known != KG_UNKNOWN && cellwalkable(lf, newcell, NULL) && countadjcellsknown(newcell, B_FALSE, DT_COMPASS)) { poss[nposs] = newcell; @@ -3212,7 +3212,7 @@ void calclight(map_t *map) { player->los[i]->lastlit = player->los[i]->lit; } } - + for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { c = getcellat(map, x,y); @@ -3249,7 +3249,7 @@ void calclight(map_t *map) { makelitradius(c, radius, L_TEMP, -1); } } - + } } } @@ -3276,7 +3276,7 @@ void calclight(map_t *map) { } */ -// if "stayclose" is non-zero, then room must be within 'stayclose' cells of another room. +// if "stayclose" is non-zero, then room must be within 'stayclose' cells of another room. int calcroompos(map_t *map, int w, int h, int xmargin, int ymargin, int *bx, int *by, int force, int stayclose) { int x,y,i; int bestscore = 9888; @@ -3305,7 +3305,7 @@ int calcroompos(map_t *map, int w, int h, int xmargin, int ymargin, int *bx, int x = coord[i].x; y = coord[i].y; // would the room fit here? - if ( ((x + w) <= (map->w - xmargin)) && + if ( ((x + w) <= (map->w - xmargin)) && ((y + h) <= (map->h - ymargin))) { int valid = B_TRUE; int rx,ry; @@ -3366,9 +3366,9 @@ int calcroompos(map_t *map, int w, int h, int xmargin, int ymargin, int *bx, int cell = getcellat(map, rx,ry); // NEVER create a room whcih will: - // - be on top of the player (normally this can't happen, + // - be on top of the player (normally this can't happen, // but debugging via 'create vault' could do it) - if (cell->lf && isplayer(cell->lf)) { + if (cell->lf && isplayer(cell->lf)) { valid = B_FALSE; continue; } // - overlap a cell with an important object @@ -3410,13 +3410,13 @@ int calcroompos(map_t *map, int w, int h, int xmargin, int ymargin, int *bx, int ((ry == y+h-1) && (rx == (x+w-1))) ) { // corner. don't check this cell for scores. } else { - includethiscell = B_TRUE; + includethiscell = B_TRUE; } } else { // not adjacent to any empty cells. ok. - includethiscell = B_TRUE; + includethiscell = B_TRUE; } - + if (includethiscell) { // is this cell empty itself? if (!cell->type->solid) { @@ -3463,7 +3463,7 @@ int calcroompos(map_t *map, int w, int h, int xmargin, int ymargin, int *bx, int } if (foundvalid) { - // now go through and make a list of all BEST positions + // now go through and make a list of all BEST positions nposs = 0; assert(bestscore != 9888); for (i = 0; i < ncoords; i++) { @@ -3581,7 +3581,7 @@ int countadjrooms(cell_t *cell, int dirtype) { int countadjdoors(cell_t *cell) { int d; int doors = 0; - + for (d = DC_N; d <= DC_NW; d++) { cell_t *newcell; newcell = getcellindir(cell, d); @@ -3595,7 +3595,7 @@ int countadjdoors(cell_t *cell) { int countadjwalls(cell_t *cell) { int d; int walls = 0; - + for (d = DC_N; d <= DC_NW; d++) { cell_t *newcell; newcell = getcellindir(cell, d); @@ -3619,7 +3619,7 @@ int countcellexits(cell_t *cell, int dirtype) { start = DC_N; end = DC_NW; } - + for (d = start; d <= end; d++) { newcell = getcellindir(cell, d); if (newcell && !newcell->type->solid) { @@ -3712,7 +3712,7 @@ void createantnest(map_t *map, int depth, map_t *parentmap, int exitdir, object_ // what kind of cells will 'empty' ones be? emptycell = getmapempty(map); solidcell = getmapsolid(map); - + // fill entire maze with walls for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { @@ -3777,7 +3777,7 @@ void createbyhut(map_t *map, int depth, map_t *parentmap, int exitdir, object_t cell_t *c; vault_t *v; //object_t *o; - + // what kind of cells will 'empty' ones be? emptycell = getmapempty(map); solidcell = getmapsolid(map); @@ -3814,7 +3814,7 @@ void createcave(map_t *map, int depth, map_t *parentmap, int exitdir, object_t * int numstartpos = 5; int numpasses = 50; - + // is the map lit? /* @@ -3854,7 +3854,7 @@ void createcave(map_t *map, int depth, map_t *parentmap, int exitdir, object_t * } - // pick initial random points + // pick initial random points for (i = 0; i < numstartpos; i++) { c = getrandomcell(map); if (!c->locked) { @@ -3882,7 +3882,7 @@ void createcave(map_t *map, int depth, map_t *parentmap, int exitdir, object_t * if (!createvault(map, map->nrooms, v, NULL, NULL, NULL, NULL)) { // success continue; - } + } } // just do a normal room calcposandmakeroom(map, map->nrooms, NA, NA, NA, NA, DEF_VAULTMARGIN, DEF_VAULTMARGIN, NULL, NULL, NULL, NULL, 50, 25, B_FALSE, 0); @@ -3909,7 +3909,7 @@ void createcave(map_t *map, int depth, map_t *parentmap, int exitdir, object_t * // now do a border createborder(map, solidcell); } -// +// void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_t *entryob) { int wantrooms = B_TRUE; int d; @@ -3956,7 +3956,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ // less sparse. sparseness -= 10; } - + // select dungeon shape. dbtime("Starting shape selection."); if (onein(3)) { @@ -3971,7 +3971,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ case MS_HORZ: // horizontal bar // ###### // ###### - // + // // ###### // ###### for (y = 0; y < map->h/4; y++) { @@ -3982,7 +3982,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ } for (y = (map->h/4)*3; y < map->h; y++) { for (x = 0; x < map->w; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "horzbar"); } } @@ -3995,13 +3995,13 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ // ## ## for (x = 0; x < map->w/4; x++) { for (y = 0; y < map->h; y++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "vertbar"); } } for (x = (map->w/4)*3; x < map->w; x++) { for (y = 0; y < map->h; y++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "vertbar"); } } @@ -4009,12 +4009,12 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ case MS_CROSS: // cross // ## ## // ## ## - // + // // ## ## // ## ## for (y = 0; y < map->h/3; y++) { for (x = 0; x < map->w/3; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "cross"); } for (x = map->w - (map->w/3); x < map->w; x++) { @@ -4024,11 +4024,11 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ } for (y = map->h-(map->h/3); y < map->h; y++) { for (x = 0; x < map->w/3; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "cross"); } for (x = map->w - (map->w/3); x < map->w; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "cross"); } } @@ -4045,7 +4045,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ // ########## for (y = (map->h/4); y < map->h/3; y++) { for (x = map->w/3; x < map->w - (map->w/3); x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "turret"); } } @@ -4057,7 +4057,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ } for (y = map->h-(map->h/3); y < map->h - (map->h/4); y++) { for (x = map->w/3; x < map->w - (map->w/3); x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "turret"); } } @@ -4069,10 +4069,10 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { float val; - val = (pow(x - centre->x, 2) / pow(w/2, 2)) + + val = (pow(x - centre->x, 2) / pow(w/2, 2)) + (pow(y - centre->y, 2) / pow(h/2, 2)); if (val > 1) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); setcelllocked(c, "circle"); } } @@ -4083,7 +4083,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); if (c->locked) { c->visited = B_TRUE; } @@ -4096,7 +4096,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ for (y = 0; y < map->h; y++) { strcpy(buf, ""); for (x = 0; x < map->w; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); if (c->locked) { c->visited = B_TRUE; } @@ -4111,7 +4111,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ */ // randomise dungeon parameters - turnpct += (rnd(0,40)-20); // (-20 to +20)% + turnpct += (rnd(0,40)-20); // (-20 to +20)% sparseness += (rnd(0,30)-10); // -10 to +20 looppct -= (rnd(0,10)); // subtract 0 - 10 @@ -4147,7 +4147,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ } } - // pick initial random spot + // pick initial random spot if (corridortype == CDT_NORMAL) { c = getrandomcell(map); setcelltype(c, emptycell); @@ -4163,10 +4163,10 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ while (!done) { // get random direction based on turnpct dir = D_NONE; - while ((dir == D_NONE) && !done) { + while ((dir == D_NONE) && !done) { int badcount; if (digdb) printf("- At (%d,%d), moved %d, finding new direction...\n",c->x, c->y, moved); - + dir = getnewdigdir(c, lastdir, (moved < 2) ? 0 : turnpct, &moved); badcount = 0; @@ -4177,7 +4177,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ done = B_TRUE; break; } - + // pick new EMPTY random spot c = getrandomcell(map); while (!isempty(c)) { @@ -4197,7 +4197,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ c = getcellindir(c, dir); if (digdb) printf("- Now at (%d,%d)\n",c->x, c->y); moved++; - + // blank it setcelltype(c,emptycell); c->visited = B_TRUE; @@ -4261,13 +4261,13 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ // pick a random directory dir = getnewdigdir(c, D_UNKNOWN,100, &moved); - - if (dir == D_NONE) { + + if (dir == D_NONE) { // can't make a loop from here. loopok = B_FALSE; - } else { + } else { int tries = 0; - // if we go this dir, will we hit a + // if we go this dir, will we hit a // corridor? while (!isloopdirok(c, dir)) { tries++; @@ -4276,7 +4276,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ loopok = B_FALSE; break; } - // turn... + // turn... if (++dir >= MAXDIR_ORTH) { dir = 0; } @@ -4285,7 +4285,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ if (loopok) { // keep digging until we hit another corridor - while (!connected) { + while (!connected) { cell_t *newcell; // find adjacent cell in the given direction newcell = getcellindir(c, dir); @@ -4340,7 +4340,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ } } // just do a normal room - calcposandmakeroom(map, map->nrooms, minroomw, minroomh, maxroomw, maxroomh, + calcposandmakeroom(map, map->nrooms, minroomw, minroomh, maxroomw, maxroomh, DEF_VAULTMARGIN, DEF_VAULTMARGIN, NULL, NULL, NULL, NULL, 50, 25, B_FALSE, 0); //roomvault[i] = B_FALSE; } @@ -4393,7 +4393,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ for (n = 0; n < numpillars;n++ ) { //dblog("----> Adding pillar %d/%d",n+1,numpillars); condset_t cs; - initcondv(&cs, CC_HASROOMID, B_TRUE, i, + initcondv(&cs, CC_HASROOMID, B_TRUE, i, CC_EMPTY, B_TRUE, NA, CC_NONE); //c = getrandomroomcell(map, i, WE_EMPTY); c = getcell_cond(map, &cs); @@ -4407,7 +4407,7 @@ void createdungeon(map_t *map, int depth, map_t *parentmap, int exitdir, object_ numobsmin = 0; numobsmax = MAXOF(rw,rh) / 2; //numobsmax = MAXOF(roomw[i],roomh[i]); - + // then objects/monsters if (numobsmax <= numobsmin) { numobs = numobsmin; @@ -4497,7 +4497,7 @@ void createforest(map_t *map, int depth, map_t *parentmap, int exitdir, object_t int nretcells; int numrooms = 0; //object_t *o; - + // fill entire maze with emptiness emptycell = getmapempty(map); solidcell = getmapsolid(map); @@ -4509,12 +4509,12 @@ void createforest(map_t *map, int depth, map_t *parentmap, int exitdir, object_t } } - + switch (rnd(1,2)) { case 1: // forest type 1: add trees in x% of cells, then add some clearings // determine density density = rnd(40,70); - // add a plant to density percent of cells + // add a plant to density percent of cells ntrees = (int)(((float)density/100.0) * (float)(map->w*map->h)); for (i = 0; i < ntrees; i++) { c = getrandomcell(map); @@ -4648,7 +4648,7 @@ void createheaven(map_t *map, int depth, map_t *parentmap, int exitdir, object_t vault_t *v; int i = -1; //object_t *o; - + // what kind of cells will 'empty' ones be? emptycell = getmapempty(map); solidcell = getmapsolid(map); @@ -4680,7 +4680,7 @@ void createheaven(map_t *map, int depth, map_t *parentmap, int exitdir, object_t dblog("ERROR - couldn't find home position for god!"); msg("ERROR - couldn't find home position for god!"); assert("failed to find home pos for god" == 0); - } + } c = map->cell[i]; } // place god @@ -4770,10 +4770,10 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex } */ map->beingcreated = B_TRUE; - + map->depth = depth; map->region = region; - + getregionname(buf, map, NULL, RF_SHORT); if (db) { dblog("createmap() - Creating new map of region '%s', depth %d",buf, depth); @@ -4816,7 +4816,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex if (parentmap->region->id == map->region->id) { // we came from a previous map in the same region if (db) dblog(" linking to same region parentmap %s in dir %s", parentmap->name, getdirname(diropposite(exitdir))); - // ONLY change parent map's nextmap if it's + // ONLY change parent map's nextmap if it's // in the same region. parentmap->nextmap[exitdir] = map->id; map->nextmap[diropposite(exitdir)] = parentmap->id; @@ -4938,7 +4938,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex for (i = 0; i < region->outline->nthings; i++) { int matched = B_FALSE; if (db) { - dblog(" Checking outlinething #%d (thing:depth=%d,x=%d,y=%d thismap:depth=%d,x=%d,y=%d ).", i, + dblog(" Checking outlinething #%d (thing:depth=%d,x=%d,y=%d thismap:depth=%d,x=%d,y=%d ).", i, region->outline->thing[i].depth, region->outline->thing[i].x, region->outline->thing[i].y, @@ -4946,13 +4946,13 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex ); } - if ((region->rtype->id == BH_WORLDMAP) && + if ((region->rtype->id == BH_WORLDMAP) && (region->outline->thing[i].depth == NA)) { // match on x/y coords if ((region->outline->thing[i].x == x) && (region->outline->thing[i].y == y)) { matched = B_TRUE; } } else { // match on depth - if (region->outline->thing[i].depth == map->depth) { + if (region->outline->thing[i].depth == map->depth) { matched = B_TRUE; } } @@ -5052,7 +5052,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex failed = B_TRUE; } break; - default: + default: break; } @@ -5076,7 +5076,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex } // remember that this room was made before the rest of the map. // it will counteract the fact that we locked this room's cells - // when we call fix_reachability(). + // when we call fix_reachability(). r->prevault = B_TRUE; nprevaults++; } @@ -5130,7 +5130,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex c = getcell_cond(map, &ccwalkableroom); if (!c) c = getrandomcell(map); c = real_getrandomadjcell(c, &ccwalkable, B_ALLOWEXPAND, LOF_DONTNEED, NULL, NULL); - addmonster(c, R_SPECIFIED, thing[i]->what, B_FALSE, thing[i]->value, B_TRUE, + addmonster(c, R_SPECIFIED, thing[i]->what, B_FALSE, thing[i]->value, B_TRUE, B_ALLOWEXTRA, NULL); break; case RT_BRANCHLINK: @@ -5141,7 +5141,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex break; case RT_NONE: break; - default: + default: break; } } @@ -5181,7 +5181,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex if (!failed) { if (fix_reachability(map)) { failed = B_TRUE; - } + } } if (db) dblog(" finished reachability fix."); //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging @@ -5191,7 +5191,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex unmakemap(map); continue; } - // + // } // end while failed) // at this point, we know failed == false. @@ -5212,7 +5212,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex failed = B_TRUE; dblog("********* Map finalisation failed. Testarting map creation. *********"); dblog("********* Map finalisation failed. Testarting map creation. *********"); - } else { + } else { if (db) { dblog("Finalisation finished."); } @@ -5255,33 +5255,33 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex // decide where the gate will be (not the corner) for (dir = D_N; dir <= D_W; dir++) { switch (dir) { - case D_N: - gx[dir] = rnd(x1+2,x2-2); - gy[dir] = y1; + case D_N: + gx[dir] = rnd(x1+2,x2-2); + gy[dir] = y1; guardx[dir][0] = gx[dir]-1; guardy[dir][0] = gy[dir]+1; guardx[dir][1] = gx[dir]+1; guardy[dir][1] = gy[dir]+1; break; - case D_E: - gx[dir] = x2; - gy[dir] = rnd(y1+2,y2-2); + case D_E: + gx[dir] = x2; + gy[dir] = rnd(y1+2,y2-2); guardx[dir][0] = gx[dir]-1; guardy[dir][0] = gy[dir]-1; guardx[dir][1] = gx[dir]-1; guardy[dir][1] = gy[dir]+1; break; - case D_S: - gx[dir] = rnd(x1+2,x2-2); - gy[dir] = y2; + case D_S: + gx[dir] = rnd(x1+2,x2-2); + gy[dir] = y2; guardx[dir][0] = gx[dir]-1; guardy[dir][0] = gy[dir]-1; guardx[dir][1] = gx[dir]+1; guardy[dir][1] = gy[dir]-1; break; - case D_W: - gx[dir] = x1; - gy[dir] = rnd(y1+2,y2-2); + case D_W: + gx[dir] = x1; + gy[dir] = rnd(y1+2,y2-2); guardx[dir][0] = gx[dir]+1; guardy[dir][0] = gy[dir]-1; guardx[dir][1] = gx[dir]+1; @@ -5303,7 +5303,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex // mark as different habitat to outside c->habitat = findhabitat(H_VILLAGE); - if (!isroom(c)) { + if (!isroom(c)) { // get rid of objects (ie. trees) here killallobs(c->obpile); // make the ground dirt @@ -5318,7 +5318,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex setcelltype(c, CT_DIRT); addob(c->obpile, "wooden fence"); } - } + } for (dir = D_N; dir <= D_W; dir++) { // town gate location @@ -5328,10 +5328,10 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex clearcell(c); setcelltype(c, CT_DIRT); addob(c->obpile, "wooden gate"); - // also make surrounding forest cells be dirt and no trees, + // also make surrounding forest cells be dirt and no trees, for (d2 = DC_N; d2 <= DC_NW; d2++) { c2 = getcellindir(c, d2); - if (c2 && (c2->habitat->id != H_VILLAGE)) { + if (c2 && (c2->habitat->id != H_VILLAGE)) { clearcell(c2); setcelltype(c2, CT_DIRT); } @@ -5359,13 +5359,13 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex dblog("About to autolink holes."); } - // link up holes - this will create NEW holes in THIS map connecting to + // link up holes - this will create NEW holes in THIS map connecting to // EXISTING unlinked holes in adjacent maps // // do this BEFORE linking stairs, in case the act of linking holes generates the next map. // if this happens then we want to also join up unlinked stairs. // if we don't do this then when the player tries to use stairs, we will find - // that an existing map below/above exists but has no stairs linked, + // that an existing map below/above exists but has no stairs linked, // which isn't meant to happen. i = linkholes(map); if (db) { @@ -5389,7 +5389,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex if (o && !hasflag(o->flags, F_PORTAL) && !getstairdestination(o, NULL) && !hasflag(o->flags, F_MAPLINK)) { dblog(" Trying to link '%s'",o->type->name); // this will join these stairs to existing ones on - // existing adjacent maps + // existing adjacent maps if (!linkstairs(o, NULL)) { if (db) { cell_t *dst; @@ -5442,7 +5442,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex } //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging - // look for adjacent maps + // look for adjacent maps if (db) dblog(" linking to adjacent maps"); getmapcoords(map, &x, &y); assert(x != -999); @@ -5508,8 +5508,8 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t int numon = 0; char buf[BUFLEN]; - corridorsize = rnd(2,3); - roomfullsize = rnd(5,9); if ((roomfullsize % 2) == 0) roomfullsize++; + corridorsize = rnd(2,3); + roomfullsize = rnd(5,9); if ((roomfullsize % 2) == 0) roomfullsize++; sectionsize = corridorsize + roomfullsize; roomsize = roomfullsize - 2; // don't include outer walls. @@ -5524,8 +5524,8 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t // Room --- Room --- Room xxx // x x x // x x x - // - // == Across: 3 rooms, 2 corridors + // + // == Across: 3 rooms, 2 corridors // == Down: 2 rooms, 1 corridor /// x = left over sectionsize maxroomsx = ((map->w - 2) ) / (sectionsize); @@ -5565,7 +5565,7 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t } } - // now figure first/last rooms in each row + // now figure first/last rooms in each row for (ry = 0; ry < roomcounty; ry++) { rowfirst[ry] = -1; for (rx = 0; rx < roomcountx; rx++) { @@ -5578,7 +5578,7 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t } } } - // now figure first/last rooms in each column + // now figure first/last rooms in each column for (rx = 0; rx < roomcountx; rx++) { colfirst[rx] = -1; for (ry = 0; ry < roomcounty; ry++) { @@ -5591,7 +5591,7 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t } } } - + dblog("SEWER debug:"); dblog(" sectionsize is %d (room=%d, corridor=%d)", sectionsize, roomfullsize, corridorsize); dblog(" roomcountx is %d, roomcounty is %d", roomcountx, roomcounty); @@ -5654,7 +5654,7 @@ void createsewer(map_t *map, int depth, map_t *parentmap, int exitdir, object_t linkexits(map, map->room[i].id); } - // replace all empty cells with slime (except the exit one) + // replace all empty cells with slime (except the exit one) for (i = 0; i < (map->w*map->h); i++){ c = map->cell[i]; if (!c->type->solid) { @@ -5857,7 +5857,7 @@ int createvault(map_t *map, int roomid, vault_t *v, int *retw, int *reth, int *r dblog("** couldn't find position for vault %s (roomid %d)!\n", v->id, roomid); //msg("** ALERT: couldn't make vault room!\n"); return B_TRUE; - } + } maxx = minx + (w-1); maxy = miny + (h-1); @@ -5974,7 +5974,7 @@ void killcell(cell_t **c) { // if (c) { clearcell(*c); killobpile((*c)->obpile); - free(*c); + free(*c); *c = NULL; // } } @@ -5983,7 +5983,7 @@ void killbranch(branch_t *b) { branch_t *nextone, *lastone; // free mem free(b->name); - + // remove from list nextone = b->next; if (nextone != NULL) { @@ -6040,7 +6040,7 @@ void killhabitat(habitat_t *h) { free(h->name); killflagpile(h->monflags); h->monflags = NULL; - + // remove from list nextone = h->next; if (nextone != NULL) { @@ -6066,11 +6066,11 @@ void killmap(map_t *m) { int i; // free mem while (m->lf) killlf(m->lf); - + free(m->name); killflagpile(m->flags); m->flags = NULL; - + for (i = 0; i < (m->w*m->h); i++) { killcell(&(m->cell[i])); } @@ -6150,7 +6150,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { directendcell[d] = NULL; } - // link it. + // link it. // if our cell is marked specifically as a room exit, our first direction MUST be out the // door. if (startcell->isroomwall != D_NONE) { @@ -6163,7 +6163,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { dblog(" checking all start dirs"); } - // otherwise, starting from the door, count the number of cells in + // otherwise, starting from the door, count the number of cells in // each direction until we hit an empty (walkable) cell which isn't a room. // if we hit a cell of this roomid, mark this dir as invalid. @@ -6192,7 +6192,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { if (db) dblog(" %d,%d going %s maybe ok...", c->x, c->y, getdirname(d)); perpdir[0] = d - 1; if (perpdir[0] < D_N) perpdir[0] = D_W; perpdir[1] = d + 1; if (perpdir[1] > D_W) perpdir[1] = D_N; - // is there an adjacent walkable cell in a perpendicular direction + // is there an adjacent walkable cell in a perpendicular direction // which isn't from the starting room? for (n = 0; n <= 1; n++) { pcell = getcellindir(c, perpdir[n]); @@ -6203,9 +6203,9 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { break; } } - } + } // check next cell - c = getcellindir(c, d); + c = getcellindir(c, d); } if (!c) { if (db) dblog(" going %s hits edge of map.", getdirname(d)); @@ -6253,7 +6253,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { midcell[i] = tempcell; roomidx[i] = tempidx; donesomething = B_TRUE; - } + } } } if (db) { @@ -6272,7 +6272,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { int destroomid; int done = B_FALSE,i,n; node_t *cur; - int nopen = 0,nclosed = 0; + int nopen = 0,nclosed = 0; int okforreach; destroomid = m->room[roomidx[a]].id; @@ -6284,7 +6284,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { clearnode(&closed[i]); } nopen = 0; - nclosed = 0; + nclosed = 0; if (db) dblog("linkexit() pathfind - finding path from %d,%d (room %d) to room %d.", startcell->x, startcell->y, roomid, destroomid); @@ -6300,7 +6300,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { while (!done) { char why[BUFLEN]; - // if open list empty? + // if open list empty? if (!nopen) { // if so, there is NO path. fail. if (db) dblog("linkexit() pathfind - open list is empty. FAILED."); @@ -6359,7 +6359,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { // adjcell->x, adjcell->y); continue; } - + //walkable = cellwalkable(lf, adjcell, &whynot); ok = cellokforreachability(startcell, adjcell, roomid, i, wantfilled, NULL, why); if (ok) { @@ -6378,7 +6378,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { if (db) dblog(" %s = already on open list. recalcing.", getdirname(i)); //if (db) dblog(" %s (%d,%d): on open list (position %d).",getdirnameshort(i), // adjcell->x, adjcell->y, openpos); - + // recalc fromstart of adjcell using node[cur] as a parent. newfromstart = calcg_map(open[openpos].c, cur, i); if (newfromstart < open[openpos].fromstart) { @@ -6386,12 +6386,12 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { //if (db) dblog(" %s (%d,%d): better cost - recalcing.", // getdirnameshort(i), // adjcell->x, adjcell->y); - + // change parent of adjcell to node[cur] // and recalc new costings (and re-sort list) temp = open[openpos]; - temp.parent = cur; - temp.dirfromparent = i; + temp.parent = cur; + temp.dirfromparent = i; assert(isadjacent(temp.c, temp.parent->c)); temp.fromstart = calcg_map(temp.c, temp.parent, i); temp.heur = calch_map(temp.c, destroomid); @@ -6461,7 +6461,7 @@ int linkexit(cell_t *startcell, int wantfilled, int *ncellsadded) { if (db) dblog(" Cannot find a way to link up."); // debugging - a failure here during fix_reachability is fatal. //if (wantfilled) { - // assert(0 == 1); + // assert(0 == 1); //} //raise(SIGINT); return B_TRUE; @@ -6546,7 +6546,7 @@ int linkexits(map_t *m, int roomid) { if (db) { char buf[BUFLEN]; //c = getrandomroomcell(m, roomid, WE_NONE); - snprintf(buf, BUFLEN, "*** linkexits for roomid %d (%s) [%d,%d-%d,%d]", roomid, + snprintf(buf, BUFLEN, "*** linkexits for roomid %d (%s) [%d,%d-%d,%d]", roomid, v ? v->id : "novault", minx,miny,maxx,maxy); dblog("%s", buf); @@ -6577,7 +6577,7 @@ int linkexits(map_t *m, int roomid) { for (i = 0; i < nposs; i++) { int ncorridors = 0,d; - if (db) dblog("exit #%d at %d,%d: (%s)",i, poss[i]->x, poss[i]->y, + if (db) dblog("exit #%d at %d,%d: (%s)",i, poss[i]->x, poss[i]->y, (poss[i]->isroomwall != D_NONE) ? getdirname(poss[i]->isroomwall) : "nodir"); // if exit is solid and COMPLETELY surrounded by solid, ignore it. if (poss[i]->type->solid && (countcellexits(poss[i], DT_ORTH) == 0)){ @@ -6634,7 +6634,7 @@ void createmastervaults(map_t *map, int depth, map_t *parentmap, int exitdir, ob // what kind of cells will 'empty' ones be? emptycell = getmapempty(map); solidcell = getmapsolid(map); - + // fill entire maze with walls for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { @@ -6650,7 +6650,7 @@ void createmastervaults(map_t *map, int depth, map_t *parentmap, int exitdir, ob while (rv) { rv = calcposandmakeroom(map, map->nrooms, minw,minh,maxw,maxh, xmarg,ymarg, NULL, NULL, NULL, NULL, 100, 0, B_TRUE, 0); } - + // place more rooms, but they must be within 3 cells of each other. nextrarooms = rnd(4,8); @@ -6662,7 +6662,7 @@ void createmastervaults(map_t *map, int depth, map_t *parentmap, int exitdir, ob } - // clear all solid cells with adjacent rooms + // clear all solid cells with adjacent rooms for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { c = getcellat(map, x, y); @@ -6677,7 +6677,7 @@ void createmastervaults(map_t *map, int depth, map_t *parentmap, int exitdir, ob int nchests; condset_t cs; nchests = rnd(1,5); - initcondv(&cs, CC_HASROOMID, B_TRUE, i, + initcondv(&cs, CC_HASROOMID, B_TRUE, i, CC_WALKABLE, B_TRUE, NA, CC_NONE); //c = getrandomroomcell(map, i, WE_WALKABLE); c = getcell_cond(map, &cs); @@ -6708,7 +6708,7 @@ void createpit(map_t *map, int depth, map_t *parentmap, int exitdir, object_t *e c = getrandomcell(map); // clear it setcelltype(c, CT_CORRIDOR); - // put an exit here + // put an exit here o = addobject(c->obpile, NULL, B_FALSE, B_FALSE, OT_HOLEINROOF); assert(o); // link it @@ -6725,7 +6725,7 @@ void createbranchlink(map_t *m, cell_t *c, object_t *o, char *obname, enum BRANC if (nrt->addparentdepth) { basedepth = getmapdifficulty(m); } - // create a new region. + // create a new region. r = addregion(newbranch, m->region, -1, basedepth, m->id); // add stairs going to the new region, if required if (!c) { @@ -6760,7 +6760,7 @@ int createportallink(cell_t *src, cell_t *dst, enum OBTYPE portalid) { dblog(" createportals(): src or dst cell is solid"); return B_TRUE; } - + // make sure neither cell has a portal already if (hasob(src->obpile, portalid) || hasob(dst->obpile, portalid)) { dblog(" createportals(): src or dst cell already has a portal"); @@ -6801,9 +6801,9 @@ void createriver(map_t *m) { dblog("Creating river on map %s (depth %d)!", m->name, m->depth); // pick direction dir = rnd(B_VERT,B_HORZ); - // pick random river width + // pick random river width width = rnd(0,2); - // pick random spot along top && bottom ( x >= width and x <= w-width-1) + // pick random spot along top && bottom ( x >= width and x <= w-width-1) // then bresnham between spots to make centrelist if (dir == B_VERT) { startcentre = rnd(1,m->w - width - 1); @@ -6822,11 +6822,11 @@ void createriver(map_t *m) { int pos,start,end,n; // make a second list of rivercells (rivercell->x - wid) to (rivercell->x + wid) if (dir == B_VERT) { - start = retcell[i]->x; - end = retcell[i]->x + width; + start = retcell[i]->x; + end = retcell[i]->x + width; } else { - start = retcell[i]->y; - end = retcell[i]->y + width; + start = retcell[i]->y; + end = retcell[i]->y + width; } limit(&start, 0, m->w-1); limit(&end, 0, m->w-1); @@ -6934,7 +6934,7 @@ int calcposandmakeroom(map_t *map, int roomid, int overrideminw, int overridemin if (calcroompos(map, w, h, xmargin, ymargin, &minx, &miny, B_FALSE, stayclose)) { dblog("** couldn't make room!\n"); return B_TRUE; - } + } dbtime("end calcroompos"); if (retx) *retx = minx; @@ -6970,7 +6970,7 @@ int dirtox(int dt, int dir) { return 1; case D_W: return -1; - default: + default: return 0; } } else if (dt == DT_COMPASS) { @@ -6983,7 +6983,7 @@ int dirtox(int dt, int dir) { case DC_W: case DC_SW: return -1; - default: + default: return 0; } } @@ -6997,7 +6997,7 @@ int dirtoy(int dt, int dir) { return 1; case D_N: return -1; - default: + default: return 0; } } else if (dt == DT_COMPASS) { @@ -7010,7 +7010,7 @@ int dirtoy(int dt, int dir) { case DC_N: case DC_NW: return -1; - default: + default: return 0; } } @@ -7072,7 +7072,7 @@ dblog("dump of map '%s' (%d x %d):\n",map->name, map->w, map->h); if (ch == '.') { if (showrooms && isroom(cell)) { ch = '0' + getroomid(cell); - } + } if (ch == '.') { if (cell->filled) { @@ -7106,11 +7106,11 @@ void dumpoutlines(void) { branch_t *rtype; rtype = findbranch(rt->value); dblog(" at %s: link to %s (%s)",loctext, rtype->name, rt->what); - } else if (rt->whatkind == RT_HABITAT) { + } else if (rt->whatkind == RT_HABITAT) { habitat_t *h; h = findhabitat(rt->value); dblog(" at %s: %s",loctext, h->name); - } else if (rt->whatkind == RT_VAULT) { + } else if (rt->whatkind == RT_VAULT) { vault_t *v; v = findvault(rt->what); dblog(" at %s: %s",loctext, v->id); @@ -7129,7 +7129,7 @@ void explodecells(cell_t *c, int dam, int killwalls, object_t *o, int range, int int nretcells,i; if (wantannounce) { sprintf(buf, "You see %s explosion!", (range > 0) ? "a huge" : "an"); - } + } if (dirtype == DT_COMPASS) { animradial(c, range, '}', C_RED, DT_COMPASS, wantannounce ? buf : NULL, wantannounce ? buf : NULL); @@ -7152,7 +7152,7 @@ void explodecells(cell_t *c, int dam, int killwalls, object_t *o, int range, int void explosion_knockback(cell_t *c, int radius, int dirtype, int dam, lifeform_t *fromwho) { cell_t *retcell[MAXRETCELLS]; int nretcells,i; - // lfs up to 1 cell away are knocked back, if no walls in the way + // lfs up to 1 cell away are knocked back, if no walls in the way getradiuscells(c, radius, dirtype, B_FALSE, LOF_WALLSTOP, B_TRUE, retcell, &nretcells, B_FALSE); for (i = 0; i < nretcells; i++) { cell_t *cc; @@ -7165,11 +7165,11 @@ void explosion_knockback(cell_t *c, int radius, int dirtype, int dam, lifeform_t // critical hit? 100% chance in middle, 60 at one cell, 20 at two cells critchance = 100 - (mydist*40); if (pctchance(critchance)) { - criticalhit(NULL, cc->lf, getrandomcorebp(cc->lf, NULL), + criticalhit(NULL, cc->lf, getrandomcorebp(cc->lf, NULL), NULL, pctof(critchance, dam), DT_EXPLOSIVE); } // move away from centre of explosion - knockback(cc->lf, getdiraway(cc, c, NULL, B_FALSE, DT_COMPASS, B_FALSE), + knockback(cc->lf, getdiraway(cc, c, NULL, B_FALSE, DT_COMPASS, B_FALSE), 2, fromwho, 200-(mydist*50), B_DOANNOUNCE, B_DODAM); } } @@ -7191,7 +7191,7 @@ void expand_cave(map_t *map, int numpasses) { // check for surrounding solid cells for (dir = DC_N; dir <= DC_NW; dir++) { c2 = getcellindir(c, dir); - if (c2 && c2->type->solid && !c2->locked && pctchance(chancetoclear)) { + if (c2 && c2->type->solid && !c2->locked && pctchance(chancetoclear)) { setcelltype(c2, getmapempty(map)); } } @@ -7264,7 +7264,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { // make sure this map has sufficient up/down staircases as defined by its // region type. - // + // // first dungeon level is a special case. it has 1 up stairs, 3 down. upstairtype = map->habitat->upstairtype; @@ -7282,7 +7282,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { ndownstairsneeded = ndownstairsreq - countmapobs(map, downstairtype); - if ( (nupstairsneeded && (upstairtype == OT_NONE)) || + if ( (nupstairsneeded && (upstairtype == OT_NONE)) || (ndownstairsneeded && (downstairtype == OT_NONE)) ) { dblog("ERROR - need up/down stairs, but no stairtype defined for habitat %s!", map->habitat->name); msg("ERROR - need up/down stairs, but no stairtype defined for habitat %s!", map->habitat->name); more(); @@ -7352,7 +7352,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { o = addobfast(c->obpile, upstairtype); assert(o); if (db) dblog("Created upstairs '%s'", o->type->name); - if (entryob && (exitdir == D_DOWN) && !linkedentry && + if (entryob && (exitdir == D_DOWN) && !linkedentry && entryoppositetype && (entryoppositetype->id == o->type->id)) { linkstairs(o, entryob); linkedentry = B_TRUE; @@ -7376,7 +7376,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { if (!c || countobs(c->obpile, B_TRUE)) { //c = getrandomroomcell(map, ANYROOM, WE_EMPTY); c = getcell_cond(map, &okforstairs); - if (c) { + if (c) { trytokillobs(c->obpile); } else { dblog("ERROR - couldnt find pos for down stairs while making habitat %s.", map->habitat->name); @@ -7387,7 +7387,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { o = addobfast(c->obpile, downstairtype); assert(o); if (db) dblog("Created downstairs '%s'", o->type->name); - if (entryob && (exitdir == D_UP) && !linkedentry && + if (entryob && (exitdir == D_UP) && !linkedentry && entryoppositetype && (entryoppositetype->id == o->type->id)) { linkstairs(o, entryob); linkedentry = B_TRUE; @@ -7414,7 +7414,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { for (x = 0; (x < map->w) && !linkedentry; x++) { c = getcellat(map, x, y); o = hasob(c->obpile, wantoid); - if (o && !hasflag(o->flags, F_MAPLINK) && entryoppositetype && + if (o && !hasflag(o->flags, F_MAPLINK) && entryoppositetype && (entryoppositetype->id == o->type->id)) { if (db) dblog("Found candidate: %s",o->type->name); linkstairs(o, entryob); @@ -7450,7 +7450,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { } } - + if (!linkedentry) { dblog("ERROR - couldn't link stairs back to map entry object."); msg("ERROR - couldn't link stairs back to map entry object."); more(); @@ -7473,7 +7473,7 @@ int finalisemap(map_t *map, object_t *entryob, int exitdir) { } } - // if map if not fully lit, scatter light sources around. + // if map if not fully lit, scatter light sources around. /* switch (map->illumination) { case IL_FULLLIT: break; @@ -7579,7 +7579,7 @@ void finalisemonster(lifeform_t *lf, lifeform_t *leader, flagpile_t *wantflags, if (wantflags && hasflag(wantflags, F_ASLEEP)) { // already going to be asleep? } else { - addflag(wantflags, F_ASLEEP, NA, ST_ASLEEP, NA, NULL); + addflag(wantflags, F_ASLEEP, NA, ST_ASLEEP, NA, NULL); } } } @@ -7599,7 +7599,7 @@ void finalisemonster(lifeform_t *lf, lifeform_t *leader, flagpile_t *wantflags, // might get a random behaviour if one wasn't specified if ((wantbehaviour == BH_NONE) && canhaverandombehaviour(lf) && onein(6)) { wantbehaviour = getrandombehaviour(); - } + } givebehaviour(lf, wantbehaviour); } @@ -7771,7 +7771,7 @@ object_t *findmapobwithflagval(map_t *m, enum FLAG flagid, int val0, int val1, i cell_t *findmapentrypoint(map_t *m, int side, lifeform_t *lf) { int x,y,xinc,yinc; - + cell_t *selection = NULL; cell_t *bestcell = NULL; int closest = 999; @@ -7892,7 +7892,7 @@ branch_t *findrandombranchwithname(char *name) { } if (nposs) { return poss[rnd(0,nposs-1)]; - } + } return NULL; } @@ -7931,7 +7931,7 @@ regionthing_t *findbranchlink(enum BRANCH rtid) { if (!r->outline) continue; for (i = 0; i < r->outline->nthings; i++ ){ rt = &r->outline->thing[i]; - if ((rt->whatkind == RT_BRANCHLINK) && (rt->value == rtid)) { + if ((rt->whatkind == RT_BRANCHLINK) && (rt->value == rtid)) { return rt; } } @@ -7949,7 +7949,7 @@ regionthing_t *findregionthing(int id, region_t **retregion) { if (!r->outline) continue; for (i = 0; i < r->outline->nthings; i++ ){ rt = &r->outline->thing[i]; - if (rt->id == id) { + if (rt->id == id) { if (retregion) *retregion = r; return rt; } @@ -8102,7 +8102,7 @@ enum TEMPERATURE getcelltemp(cell_t *c, int *actualtemp) { vault_t *getcellvault(cell_t *c) { if (c->room) { return c->room->vault; - } + } return NULL; } @@ -8139,8 +8139,8 @@ int getnewdigdir(cell_t *cell, int lastdir, int turnpct, int *moved) { } while (!foundvaliddir) { // keep going until we get a valid direction - if (numtries >= MAXDIR_ORTH) { // no valid dirs - return D_NONE; // (pick a new random spot and refresh tried dirs and current dir) + if (numtries >= MAXDIR_ORTH) { // no valid dirs + return D_NONE; // (pick a new random spot and refresh tried dirs and current dir) } if (lastdir == D_UNKNOWN) { @@ -8215,7 +8215,7 @@ int getnewdigdir(cell_t *cell, int lastdir, int turnpct, int *moved) { tried[dir] = B_TRUE; lastdir = D_UNKNOWN; numtries++; - } + } } } //newcell = getcellindir(cell, dir); @@ -8249,9 +8249,9 @@ cell_t *real_getrandomadjcell(cell_t *c, condset_t *cs, int allowexpand, enum LO gotlof = B_TRUE; numwithlof++; } - if (new && - (new != c) && - (getcelldist(c,new) == radius) && + if (new && + (new != c) && + (getcelldist(c,new) == radius) && (new != dontwantcell) && gotlof) { int ok = B_FALSE; @@ -8297,7 +8297,7 @@ cell_t *real_getrandomadjcell(cell_t *c, condset_t *cs, int allowexpand, enum LO if (numwithlof) { // increment radius radius++; - // more than map width? fail. + // more than map width? fail. if (radius >= MAXOF(MAX_MAPH,MAX_MAPW)) return NULL; } else { if (preferlos) { @@ -8345,10 +8345,10 @@ cell_t *getrandomcell_forteleport(map_t *map, lifeform_t *lf) { while (!c) { int ok = B_TRUE; c = getrandomcell(map); - if (!c || c->type->solid || haslf(c) || !cellwalkable(lf, c, NULL) || + if (!c || c->type->solid || haslf(c) || !cellwalkable(lf, c, NULL) || hasobwithflag(c->obpile, F_CLIMBABLE)) { ok = B_FALSE; - } + } if (!ok) { c = NULL; @@ -8357,7 +8357,7 @@ cell_t *getrandomcell_forteleport(map_t *map, lifeform_t *lf) { } } } - + return c; } @@ -8393,7 +8393,7 @@ int getrandomdir(int dirtype) { } else { // ie. DT_COMPASS return rnd(DC_N, DC_NW); } - + } int getrandomdirexcept(int dirtype, int exception) { int dir; @@ -8420,10 +8420,10 @@ cell_t *getrandomroomcell(map_t *map, int roomid, int wantempty) { npossible = 0; for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { - c = getcellat(map, x, y); + c = getcellat(map, x, y); // is this cell in the correct room and not a wall? - // using c->type->solid in case we have a room - // filled with boulders + // using c->type->solid in case we have a room + // filled with boulders //if (c && cellwalkable(NULL, c, NULL)) { if (c && !c->type->solid) { int ok = B_FALSE; @@ -8474,29 +8474,29 @@ int getslipperyness(cell_t *c, object_t **slipob) { object_t *o,*bestob = NULL; int bestslip = 0; int totalslip = 0; - int addition = 0; + int addition = 0; int pctmod = 100; if (slipob) *slipob = NULL; switch (c->type->id) { case CT_MOSSROCK: - addition = 15; + addition = 15; pctmod += 50; break; case CT_FLOORSNOW: - addition = 10; + addition = 10; pctmod += 50; break; case CT_FLOORTILE: - addition = 5; + addition = 5; pctmod += 25; break; - case CT_FLOORCARPET: - addition = -10; + case CT_FLOORCARPET: + addition = -10; pctmod -= 50; break; - default: - addition = 0; + default: + addition = 0; pctmod = 100; break; } @@ -8782,7 +8782,7 @@ void initmap(void) { addbranch(BH_SEWER, "A Sewer", B_FALSE, H_SEWER, 1, 0, D_NONE, B_FALSE, 2, B_TRUE); addbranch(BH_STOMACH, "A Stomach", B_FALSE, H_STOMACH, 1, 0, D_NONE, B_FALSE, 0, B_FALSE); // special - + } @@ -8844,15 +8844,15 @@ void initmaplayout(void) { // *************** MAP OUTLINE *************** addregionoutline(BH_MAINDUNGEON); addregionthing(lastregionoutline, 1, NA, NA, RT_RNDVAULTWITHFLAG, F_VAULTISPLAYERSTART, NULL); - // l2-4: sylvan woods + // l2-4: sylvan woods addregionthing(lastregionoutline, rnd(2,4), NA, NA, RT_BRANCHLINK, BH_WOODS, "hollow tree leading down"); // l2-5: goblin caves addregionthing(lastregionoutline, rnd(2,4), NA, NA, RT_BRANCHLINK, BH_CAVE, "tunnel leading down"); - // l3-7: ice caverns + // l3-7: ice caverns addregionthing(lastregionoutline, rnd(3,7), NA, NA, RT_BRANCHLINK, BH_ICECAVERNS, "icy passage leading down"); // l6: jimbo's lair addregionthing(lastregionoutline, 6, NA, NA, RT_VAULT, NA, "jimbos_lair"); - // l7 - 10: ants nest + // l7 - 10: ants nest i = rnd(7,10); addregionthing(lastregionoutline, i, NA, NA, RT_HABITAT, H_ANTNEST, NULL); addregionthing(lastregionoutline, i, NA, NA, RT_LF, NA, "queen ant"); @@ -8865,11 +8865,11 @@ void initmaplayout(void) { // 1-3 fixed sewers addregionthing(lastregionoutline, rnd(1,25), NA, NA, RT_BRANCHLINK, BH_SEWER, "drainage grate"); for (i = 0; i < 2; i++) { - if (onein(2)) { + if (onein(2)) { addregionthing(lastregionoutline, rnd(1,25), NA, NA, RT_BRANCHLINK, BH_SEWER, "drainage grate"); } } - + // forced shops: addregionthing(lastregionoutline, rnd(2,4), NA, NA, RT_OBJECT, NA, "random building"); @@ -8909,7 +8909,7 @@ void initmaplayout(void) { addregionthing(ro, wantdepth, NA, NA, RT_LF, 1, r->name); } } - + } } @@ -8946,13 +8946,13 @@ int isdiggable(cell_t *c, enum OBTYPE withwhat) { // just check whether the cell material // is EVER diggable. switch (c->type->id) { - case CT_WALLFLESH: + case CT_WALLFLESH: case CT_WALLDIRT: - case CT_WALL: - case CT_WALLWOOD: + case CT_WALL: + case CT_WALLWOOD: // for digging down - case CT_CORRIDOR: - case CT_MOSSROCK: + case CT_CORRIDOR: + case CT_MOSSROCK: case CT_LOOPCORRIDOR: case CT_FLOORCARPET: case CT_FLOORFLESH: @@ -8961,7 +8961,7 @@ int isdiggable(cell_t *c, enum OBTYPE withwhat) { case CT_DIRT: case CT_LOWFLOOR: case CT_VLOWFLOOR: - //case CT_WALLGLASS: + //case CT_WALLGLASS: return B_TRUE; default: break; @@ -8974,7 +8974,7 @@ int isdiggable(cell_t *c, enum OBTYPE withwhat) { return B_TRUE; default: break; } - } else { + } else { flag_t *retflag[MAXCANDIDATES],*f; int nretflags,i; getflags(ot->flags, retflag, &nretflags, F_DIGCELLTYPE, F_DIGCELLMAT, F_NONE); @@ -8990,7 +8990,7 @@ int isdiggable(cell_t *c, enum OBTYPE withwhat) { return B_FALSE; } -// if isopen provided, returns whether or not the door is opened +// if isopen provided, returns whether or not the door is opened int isdoor(object_t *o, int *isopen) { int isdoor = B_FALSE; if (hasflag(o->flags, F_DOOR)) { @@ -9028,7 +9028,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { // handle scanner if (c->lf) { if (areallies(player, c->lf) && !isplayer(c->lf) && canhear(player, c, SV_SHOUT, NULL)) { - // assume that allies will keep in contact with the player, as long + // assume that allies will keep in contact with the player, as long // as they're not asleep if (!lfhasflag(c->lf, F_ASLEEP)) { set_scanned_glyph(TT_MONSTER, c->lf, " (heard ally)", desc, glyph); @@ -9065,7 +9065,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { *thing = c->lf; return TT_MONSTER; } - } + } f = lfhasflagval(player, F_CANHEARLF, c->lf->id, NA, NA, NULL); if (f) { // can hear them using listen skill? @@ -9078,7 +9078,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { glyph->colour = C_GREY; } if (desc) sprintf(desc, "heard: %s", f->text); - } + } *thing = c->lf; return TT_MONSTER; } @@ -9107,7 +9107,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { case F_UNSEENATTACKER: strcat(desc, " (unseen attacker)"); break; - default: + default: // should never happen strcat(desc, " (detected)"); break; @@ -9153,7 +9153,10 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { if (getcelldistorth(player->cell, c) <= f->val[0]) { object_t *o; for (o = c->obpile->first ; o ; o = o->next) { - if ((f->id == F_DETECTOBS) && ((f->val[1] == NA) || (o->type->id == f->val[1]))) { + if ((f->id == F_DETECTOBS) && + ((f->val[1] == NA) || (o->type->id == f->val[1])) && + (!f->text || getobvalue(o) >= atoi(f->text) )) + { if (!hasflag(o->flags, F_NOPICKUP) && !hasflag(o->flags, F_DOOR)) { *thing = o; if (glyph) { @@ -9179,7 +9182,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) { } } } - + return B_FALSE; } @@ -9254,7 +9257,7 @@ int isnewcellok(cell_t *cell, char *err) { } else if ( !cell->type->solid) { // already an empty space there if (err) snprintf(err, BUFLEN,"goes to an empty space (%d,%d)",cell->x,cell->y); return B_FALSE; - } + } // ok! if (err) snprintf(err, BUFLEN, "OK!"); @@ -9264,9 +9267,9 @@ int isnewcellok(cell_t *cell, char *err) { cell_t *getroommidcell(map_t *m, int roomid) { int midx,midy; cell_t *c; - midx = m->room[roomid].x1 + + midx = m->room[roomid].x1 + ((m->room[roomid].x2 - m->room[roomid].x1)/2); - midy = m->room[roomid].y1 + + midy = m->room[roomid].y1 + ((m->room[roomid].y2 - m->room[roomid].y1)/2); c = getcellat(m, midx, midy); assert(c); @@ -9324,7 +9327,7 @@ enum TEMPERATURE gettempbracket(int temp) { // default return T_NORMAL; } - + enum TIMEPHASE gettimephase(void) { int h,m,s; splittime(&h, &m, &s); @@ -9456,12 +9459,12 @@ int linkholes(map_t *map) { ot = getoppositestairs(o->type); // make a link to it in this map, as close as possible to same pos c2 = getcellat(map, x, y); - if (c2->lf || hasobid(c2->obpile, ot->id)) { + if (c2->lf || hasobid(c2->obpile, ot->id)) { condset_t cs; // this will automatically avoid lifeforms since we're using // we_walkable rather than we_notwall. this saves problems // with someine coming up underneath you! - initcondv(&cs, CC_HASLF, B_FALSE, NA, + initcondv(&cs, CC_HASLF, B_FALSE, NA, CC_HASOBTYPE, B_FALSE, ot->id, CC_NONE); c2 = real_getrandomadjcell(c2, &cs, B_ALLOWEXPAND, LOF_DONTNEED, NULL, NULL); @@ -9503,9 +9506,9 @@ object_t *linkportaltodepth(object_t *srcportal, int wantdepth) { if (!newmap) { // create new map newmap = addmap(); - createmap(newmap, wantdepth, srcloc->map->region, NULL, D_NONE, NULL); + createmap(newmap, wantdepth, srcloc->map->region, NULL, D_NONE, NULL); } - + // find a random cell there newcell = getrandomcell(newmap); while (!cellwalkable(NULL, newcell, NULL) || hasenterableobject(newcell) || getcellwaterdepth(newcell, NULL)) { @@ -9522,7 +9525,7 @@ object_t *linkportaltodepth(object_t *srcportal, int wantdepth) { } // link the staircase 'o' to a free one in adjacent maps. -// o2 is optional. if o2 isn't provided, we will try to find +// o2 is optional. if o2 isn't provided, we will try to find // something to link to ourself. // returns TRUE if it failed because othermap doesn't exist. int linkstairs(object_t *o, object_t *o2) { @@ -9539,7 +9542,7 @@ int linkstairs(object_t *o, object_t *o2) { staircell = getoblocation(o); stairmap = staircell->map; - + if (o2) { cell_t *othercell; objecttype_t *ot; @@ -9604,7 +9607,7 @@ int linkstairs(object_t *o, object_t *o2) { if (!found) { dblog("ERROR - stairs should link to existing map ('%s', depth %d), but it has no free stairs.", othermap->name, othermap->depth); - msg("ERROR - stairs should link to existing map ('%s', depth %d), but it has no free stairs.", + msg("ERROR - stairs should link to existing map ('%s', depth %d), but it has no free stairs.", othermap->name, othermap->depth); more(); raise(SIGINT); // debug @@ -9653,7 +9656,7 @@ void makedoor(cell_t *cell, int openchance) { assert(!cell->type->solid); strcpy(doorbuf, ""); - // in master vaults, doors are always locked. + // in master vaults, doors are always locked. if (m->habitat->id == H_MASTERVAULTS) { strcpy(doorbuf, "locked "); } @@ -9723,7 +9726,7 @@ void makelit(cell_t *c, enum LIGHTLEV how, int howlong) { //if ((gamemode == GM_GAMESTARTED) && (c->lit != how)) { if (gamemode == GM_GAMESTARTED) { lifeform_t *lf; - for (lf = c->map->lf ; lf ; lf = lf->next) { + for (lf = c->map->lf ; lf ; lf = lf->next) { //if (haslos(lf, c) || haslosdark(lf, c)) { if ((lf->cell == c) || haslos(lf, c)) { setlosdirty(lf); @@ -9773,7 +9776,7 @@ void makelitradius(cell_t *c, int radius, enum OBTYPE how, int howlong, int powe /* if (gamemode == GM_GAMESTARTED) { lifeform_t *lf; - for (lf = c->map->lf ; lf ; lf = lf->next) { + for (lf = c->map->lf ; lf ; lf = lf->next) { //OLD: if (haslos(lf, c) || haslosdark(lf, c)) { // need to verify lf->cell because it might be NULL if we're // swapping places with someone else. @@ -9886,7 +9889,7 @@ void mapentereffects(map_t *m) { if (nturns >= 50) { dowandering = B_TRUE; } - limit(&nturns, NA, 20); + limit(&nturns, NA, 20); //nturns *= countlfs(m); for (i = 0; i < nturns; i++) { donextturn(m); @@ -9900,7 +9903,7 @@ void mapentereffects(map_t *m) { monchance = getmapdifficulty(m)*5; for (i = 0; i < m->nrooms; i++) { if (pctchance(monchance)) { - initcondv(&cs, CC_HASROOMID, B_TRUE, m->room[i].id, + initcondv(&cs, CC_HASROOMID, B_TRUE, m->room[i].id, CC_WALKABLE, B_TRUE, NA, CC_NONE); //c = getrandomroomcell(m, m->room[i].id, WE_WALKABLE); c = getcell_cond(m, &cs); @@ -9945,8 +9948,8 @@ void moveobtoclearcell(object_t *o) { startcell = getoblocation(o); c = startcell; - while ((c == startcell) || - !cellwalkable(NULL, c, NULL) || + while ((c == startcell) || + !cellwalkable(NULL, c, NULL) || hasobwithflag(c->obpile, F_CLIMBABLE) || hasobwithflag(c->obpile, F_DEEPWATER) ) { c = getrandomcell(startcell->map); @@ -10157,7 +10160,7 @@ enum RACE parserace(char *name, flagpile_t *wantflags, condset_t *cs, enum JOB * if (r) { free(localname); return r->id; - } + } } free(localname); return R_NONE; @@ -10169,7 +10172,7 @@ int remove_deadends(map_t *m, int howmuch) { int i,n,count = 0; solidcell = getmapsolid(m); - + for (i = 0; i < howmuch; i++) { int thiscount = 0; for (n = 0; n < m->w * m->h; n++) { @@ -10178,17 +10181,17 @@ int remove_deadends(map_t *m, int howmuch) { if (!c->room) { int exits; exits = countcellexits(c, DT_ORTH); - //if ((countcellexits(c, DT_ORTH) == 1) || + //if ((countcellexits(c, DT_ORTH) == 1) || // (countcellexits(c, DT_COMPASS) == 1)) { if (exits == 1) { - // erase this cell + // erase this cell clearcell(c); setcelltype(c, solidcell); setcellreason(c, "dead-end removed."); count++; thiscount++; } else if (exits == 0) { - // erase this cell + // erase this cell clearcell(c); setcelltype(c, solidcell); setcellreason(c, "zero-exit deadend removed."); @@ -10301,7 +10304,7 @@ void selectcelltypes(map_t *map, int solchance, int empchance, enum CELLTYPE *so } } } - + void set_scanned_glyph(int targettype, void *what, char *descappend, char *desc, glyph_t *glyph) { if (targettype == TT_MONSTER) { if (desc) { @@ -10354,7 +10357,7 @@ void setcellknown(cell_t *cell, int forcelev) { //ct = findcelltype(getmapsolid(cell->map)); cell->knownglyph = ct->glyph; } else { - cell->knownglyph = cell->type->glyph; + cell->knownglyph = cell->type->glyph; } adjustcellglyph(cell, &(cell->knownglyph), CA_CH); @@ -10453,11 +10456,11 @@ void setcelltype(cell_t *cell, enum CELLTYPE id) { //assert(!cell->obpile->first); } if (gamemode == GM_GAMESTARTED) { - + // digging out of a stomach if (cell->map && - !cell->map->beingcreated && - !cell->type->solid && + !cell->map->beingcreated && + !cell->type->solid && (cell->map->habitat->id == H_STOMACH)) { object_t *o,*exit; cell_t *exitcell; @@ -10519,7 +10522,7 @@ int shattercell(cell_t *c, lifeform_t *fromlf, char *damstring) { int shuffledown(map_t *map) { lifeform_t *l; int firsttime; - firsttime = map->lf->timespent; + firsttime = map->lf->timespent; if (firsttime == 0) return B_FALSE; for (l = map->lf ; l ; l = l->next) { //dblog("shuffling id %d %s timespent=%d -> %d",l->id,l->race->name, l->timespent, l->timespent - firstlftime); @@ -10560,10 +10563,10 @@ int smallroomat(cell_t *where) { } else { // we can have one exit through the // wall - if (!gotexit) { + if (!gotexit) { gotexit = B_TRUE; matched = B_TRUE; - } + } } } if (!matched) return B_FALSE; @@ -10589,13 +10592,13 @@ int unlinkstairsto(map_t *unlinkmap) { c = getcellat(unlinkmap, x,y); for (o = c->obpile->first ; o ; o = o->next) { if (hasflag(o->flags, F_MAPLINK)) { - badid[nbadids++] = o->id; + badid[nbadids++] = o->id; } } } } if (db) dblog(" found %d stairs on unlinkmap.",nbadids); - + // go through all maps and remove any stairs which link to unlinkmap if (db) dblog(" searching other maps for stairs linking TO unlinkmap."); for (m = firstmap ; m ; m = m->next) { @@ -10607,7 +10610,7 @@ int unlinkstairsto(map_t *unlinkmap) { for (i = 0; i < nretflags; i++) { int killit = B_FALSE,n; if (retflag[i]->val[0] == unlinkmap->id) { - + if (db) dblog(" on map '%s': found '%s' linking to unlinkmap's id.", m->name,o->type->name); killit = B_TRUE; } else { @@ -10775,7 +10778,7 @@ int validateregionthing(regionthing_t *thing) { int wallstoleftright(cell_t *c, int dir) { int d1,d2; switch (dir) { - case D_N: + case D_N: case D_S: d1 = D_E; d2 = D_W; break; case D_E: diff --git a/objects.c b/objects.c index ce454b0..d1883dc 100755 --- a/objects.c +++ b/objects.c @@ -5089,6 +5089,16 @@ int real_getobvalue(object_t *o, int amt) { return (int) price; } +int getonehandedstr(object_t *o) { + flag_t *ff; + if ((ff = hasflagval(o->flags, F_ATTREQ, A_STR, NA, NA, NULL))) { + if (ff->val[1] != NA) { + return floor(((float)ff->val[1] * 1.3)); + } + } + return IMPOSSIBLE; +} + char *getoperateverb(object_t *o) { if (hasflag(o->flags, F_SHOP)) { return "enter"; @@ -8733,10 +8743,15 @@ int istwohandedfor(object_t *o, lifeform_t *lf) { flag_t *f; f = hasflag(o->flags, F_TWOHANDED); if (f) { - // twohanded for everyone - if (f->val[0] <= 0) return B_TRUE; - if (!lf) return B_TRUE; - if (getlfsize(lf) <= f->val[0]) return B_TRUE; + if (lf) { + // large lf + if (f->val[0] > 0 && getlfsize(lf) > f->val[0]) return B_FALSE; + // strong lf + if (getattr(lf, A_STR) >= getonehandedstr(o)) { + return B_FALSE; + } + } + return B_TRUE; } return B_FALSE; } diff --git a/objects.h b/objects.h index 0617a75..b5eb816 100755 --- a/objects.h +++ b/objects.h @@ -66,7 +66,7 @@ object_t *fillpotfrom(object_t *flask, object_t *fillfrom, int reduceliquid); object_t *findammoinobpile(object_t *gun, obpile_t *op); material_t *findmaterial(int id); objectclass_t *findoc(int id); -object_t *findobbyid(obpile_t *op, long oid); +object_t *findobbyid(obpile_t *op, long oid); object_t *findobl(obpile_t *op, char let); // find object by letter brand_t *findbrand(enum BRAND id); obmod_t *findobmod(enum OBMOD id); @@ -108,6 +108,7 @@ enum LFSIZE getobsize(object_t *o); int getobspellpower(object_t *o, lifeform_t *lf); int getobvalue(object_t *o); int real_getobvalue(object_t *o, int amt); +int getonehandedstr(object_t *o); char *getoperateverb(object_t *o); object_t *getoutercontainer(object_t *o); object_t *getoutercontainerop(obpile_t *op); diff --git a/spell.c b/spell.c index e0e455d..b2e4469 100755 --- a/spell.c +++ b/spell.c @@ -15422,18 +15422,18 @@ int getworkablematerials(lifeform_t *lf, enum SKILL skid , enum MATERIAL *repair if (cutoff < 100) { if (skid == SK_METALWORK) { repairablemats[*nmats] = MT_METAL; - cutoffpct[*nmats] = cutoff; + if (cutoffpct) cutoffpct[*nmats] = cutoff; (*nmats)++; nworkable++; } else if (skid == SK_SEWING) { repairablemats[*nmats] = MT_CLOTH; - cutoffpct[*nmats] = cutoff; + if (cutoffpct) cutoffpct[*nmats] = cutoff; (*nmats)++; repairablemats[*nmats] = MT_LEATHER; - cutoffpct[*nmats] = cutoff; + if (cutoffpct) cutoffpct[*nmats] = cutoff; (*nmats)++; repairablemats[*nmats] = MT_FLESH; - cutoffpct[*nmats] = cutoff; + if (cutoffpct) cutoffpct[*nmats] = cutoff; (*nmats)++; nworkable += 2; }