From 1de13a1904a000cf61f2f6779bb6cea4e8c12099 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Fri, 22 Jun 2012 02:48:39 +0000 Subject: [PATCH] - [+] lots of unneccesary redraws when using stairs - [+] don't ever redraw during new level creation - [+] lots of calls to setlosdirty() - for the player, this causes instant screen redraw. - [+] remember if player is changing level. if so, setlosdirty won't redraw. - [+] fixed! - [+] basic clothing shouldn't be able to be cursed - [+] don't show"you have no clear line of fire to here" if all the things in the way are invisible! - [+] argument to haslof: "knowlofonly" - already there. - [+] apply this to all checks where it is from someone's point of view only. - [+] (ie. aimove) - [+] (ie throw) - [+] (ie spell aiming) --- ai.c | 15 ++++++++------- data.c | 24 ++++++++++++++++++++++-- defs.h | 8 ++++++++ io.c | 8 +++++--- lf.c | 28 +++++++++++++++++++++++----- lf.h | 1 + map.c | 5 +++++ move.c | 11 +++++++++++ objects.c | 6 +++--- spell.c | 25 ++++++++++++++++++------- 10 files changed, 104 insertions(+), 27 deletions(-) diff --git a/ai.c b/ai.c index 3b65fbb..4e8e78e 100644 --- a/ai.c +++ b/ai.c @@ -1593,7 +1593,7 @@ int aimovetolf(lifeform_t *lf, lifeform_t *target, int wantattack) { else spellchance = 30; // some attacks can always happen - if (cancast(lf, OT_A_THRUST, NULL) && (dist == 2) && haslof(lf->cell, target->cell, LOF_NEED, NULL)) { + if (cancast(lf, OT_A_THRUST, NULL) && (dist == 2) && haslofknown(lf->cell, target->cell, LOF_NEED, NULL)) { spellchance = 100; } @@ -1779,7 +1779,7 @@ int aimovetolf(lifeform_t *lf, lifeform_t *target, int wantattack) { if (attackok) { // if not adjacent, check for guns, wands, throwing if ( (rangedattack != RA_NONE) && // we have a ranged attack - haslof(lf->cell, target->cell, LOF_NEED, NULL) && // and we have line of fire to them + haslofknown(lf->cell, target->cell, LOF_NEED, NULL) && // and we have line of fire to them (closethrowok || onein(2) || (getcelldist(lf->cell, target->cell) > 1) )) { // and we're not adjacent to target OR random if (rangedattack == RA_GUN) { setguntarget(lf, target); @@ -2309,7 +2309,7 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG if (db) dblog(".oO { cant cast %s - no LOS to victim }", ot ? ot->name : "?unkownspell?"); return B_FALSE; } - if (needlof && !haslof(lf->cell, victim->cell, needlof, NULL) ) { + if (needlof && !haslofknown(lf->cell, victim->cell, needlof, NULL) ) { if (db) dblog(".oO { cant cast %s - no LOF to victim }", ot ? ot->name : "?unkownspell?"); return B_FALSE; } @@ -2443,7 +2443,8 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG } } else if (ot->id == OT_S_SUPERHEAT) { // got a potion? - if (victim && hasobwithflag(lf->pack, F_DRINKABLE) && haslof(lf->cell, victim->cell, LOF_NEED, NULL)) { + if (victim && hasobwithflag(lf->pack, F_DRINKABLE) && + haslofknown(lf->cell, victim->cell, LOF_NEED, NULL)) { ok = B_TRUE; } } else { @@ -2674,7 +2675,7 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG adjcell = get_closest_adjcell(lf->cell, victim->cell); if (!adjcell || celldangerous(lf, adjcell, B_TRUE, NULL)) { // don't charge into dangerous cells specificcheckok = B_FALSE; - } else if (!haslof(lf->cell, victim->cell, LOF_NEED,NULL)) { + } else if (!haslofknown(lf->cell, victim->cell, LOF_NEED,NULL)) { specificcheckok = B_FALSE; } else if (isimmobile(lf)) { specificcheckok = B_FALSE; @@ -2974,13 +2975,13 @@ int lookforobs(lifeform_t *lf) { if (gothere) { // cast a spell? - if (cancast(lf, OT_S_CALLWIND, NULL) && haslof(lf->cell, c, LOF_NEED, NULL)) { + if (cancast(lf, OT_S_CALLWIND, NULL) && haslofknown(lf->cell, c, LOF_NEED, NULL)) { if (!castspell(lf, OT_S_CALLWIND, NULL, o, c, NULL, NULL)) { // successful return B_TRUE; } } - if (cancast(lf, OT_A_SNATCH, NULL) && haslof(lf->cell, c, LOF_NEED, NULL)) { + if (cancast(lf, OT_A_SNATCH, NULL) && haslofknown(lf->cell, c, LOF_NEED, NULL)) { if (!useability(lf, OT_A_SNATCH, NULL, c)) { // successful return B_TRUE; diff --git a/data.c b/data.c index 214bccd..d2b540e 100644 --- a/data.c +++ b/data.c @@ -514,6 +514,7 @@ void initjobs(void) { addflag(lastjob->flags, F_CANLEARN, SK_STEALTH, PR_ADEPT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_SWIMMING, NA, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_THROWING, NA, NA, NULL); + addflag(lastjob->flags, F_CANLEARN, SK_TECHUSAGE, PR_NOVICE, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_TRAPS, PR_ADEPT, NA, NULL); // abilities addflag(lastjob->flags, F_VEGETARIAN, B_TRUE, NA, NA, NULL); @@ -682,7 +683,7 @@ void initjobs(void) { addflag(lastjob->flags, F_CANLEARN, SK_STAVES, NA, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_WHIPS, NA, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_STEALTH, PR_ADEPT, NA, NULL); - addflag(lastjob->flags, F_CANLEARN, SK_TECHUSAGE, PR_BEGINNER, NA, NULL); + addflag(lastjob->flags, F_CANLEARN, SK_TECHUSAGE, PR_ADEPT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_TWOWEAPON, NA, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_LORE_DRAGONS, PR_SKILLED, NA, NULL); // abilities @@ -809,6 +810,7 @@ void initjobs(void) { addflag(lastjob->flags, F_STARTSKILL, SK_PERCEPTION, PR_NOVICE, NA, NULL); addflag(lastjob->flags, F_STARTSKILL, SK_SHORTBLADES, PR_NOVICE, NA, NULL); addflag(lastjob->flags, F_STARTSKILL, SK_SPEECH, PR_NOVICE, NA, NULL); + addflag(lastjob->flags, F_STARTSKILL, SK_TECHUSAGE, PR_BEGINNER, NA, NULL); addflag(lastjob->flags, F_STARTSKILL, SK_THIEVERY, PR_BEGINNER, NA, NULL); addflag(lastjob->flags, F_STARTSKILL, SK_THROWING, PR_NOVICE, NA, NULL); addflag(lastjob->flags, F_STARTSKILL, SK_LORE_HUMANOID, PR_BEGINNER, NA, NULL); @@ -822,7 +824,6 @@ void initjobs(void) { addflag(lastjob->flags, F_CANLEARN, SK_STAVES, PR_ADEPT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_WHIPS, PR_ADEPT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_SWIMMING, NA, NA, NULL); - addflag(lastjob->flags, F_CANLEARN, SK_TECHUSAGE, NA, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_TWOWEAPON, PR_EXPERT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_UNARMED, PR_EXPERT, NA, NULL); addflag(lastjob->flags, F_CANLEARN, SK_SS_DIVINATION, PR_ADEPT, NA, NULL); @@ -6358,6 +6359,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 30, 30, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_STR, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 80, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); // armour - body addot(OT_CHEFJACKET, "set of chef whites", "A large double-breasted white jacket. Its thick cotton cloth is resistant to heat.", MT_CLOTH, 2, OC_ARMOUR, SZ_MEDIUM); @@ -6371,6 +6373,7 @@ void initobjects(void) { addflag(lastot->flags, F_CRITPROTECTION, 33, NA, NA, NULL); killflagsofid(lastot->flags, F_FLAMMABLE); killflagsofid(lastot->flags, F_DTVULN); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_COTTONSHIRT, "cotton shirt", "A comfortable white cotton shirt.", MT_CLOTH, 0.7, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); @@ -6381,6 +6384,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 20, 20, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 33, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_ARMOURDEMON, "demonskin vest", "Body armour created by flaying the flesh from a living demon, it retains its innate immunity to fire.", MT_FLESH, 7, OC_ARMOUR, SZ_MEDIUM); killflagsofid(lastot->flags, F_FLAMMABLE); @@ -6467,6 +6471,7 @@ void initobjects(void) { addflag(lastot->flags, F_ATTREQ, A_AGI, 35, NA, NULL); addflag(lastot->flags, F_OBHP, 20, 20, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 85, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_SILKSHIRT, "silk shirt", "A lightweight, comfortable white silk shirt.", MT_SILK, 0.5, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_UNCOMMON, NULL); @@ -6476,6 +6481,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 50, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_ROBE, "robe", "A plain robe.", MT_CLOTH, 4, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_MULTISIZE, B_TRUE, NA, NA, NULL); @@ -6519,6 +6525,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 20, 20, NA, NULL); addflag(lastot->flags, F_WATERPROOF, B_TRUE, NA, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 80, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); // armour - waist addot(OT_BELTLEATHER, "leather belt", "A plain leather belt.", MT_LEATHER, 0.2, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); @@ -6535,6 +6542,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 15, 15, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 60, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_RIDINGTROUSERS, "pair of riding trousers", "A tight pair of durable leather trousers.", MT_LEATHER, 2, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_MULTISIZE, B_TRUE, NA, NA, NULL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); @@ -6544,6 +6552,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 30, 30, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 75, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_COMBATPANTS, "pair of combat pants", "An lightly-armoured pair of camoflauged trousers.", MT_CLOTH, 2, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_GOESON, BP_LEGS, NA, NA, NULL); @@ -6552,6 +6561,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 50, 50, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 90, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_GREAVES, "set of greaves", "A set of heavy metal greaves.", MT_METAL, 4, OC_ARMOUR, SZ_MEDIUM); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_UNCOMMON, NULL); addflag(lastot->flags, F_GOESON, BP_LEGS, NA, NA, NULL); @@ -6571,6 +6581,7 @@ void initobjects(void) { addflag(lastot->flags, F_ARMOURRATING, 0, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 30, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_SHOESLEATHER, "pair of leather shoes", "Cheap and rather uncomfortable leather shoes.", MT_LEATHER, 2, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL); @@ -6627,6 +6638,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 20, 20, NA, NULL); addflag(lastot->flags, F_ATTREQ, A_AGI, 15, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 70, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_GLOVESLEATHER, "pair of leather gloves", "A pair of coarse leather gloves.", MT_LEATHER, 0.25, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HANDS, NA, NA, NULL); @@ -6652,6 +6664,7 @@ void initobjects(void) { addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_PIRATEHAT, "tricorne", "A three cornered hat with a skull and crossbones emblem.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_UNCOMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); @@ -6667,6 +6680,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_ANONYMOUS, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_CAP, "cap", "Close-fitting headwear with a short shade visor at the front.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL); @@ -6675,6 +6689,7 @@ void initobjects(void) { addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 5, 5, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_CHEFHAT, "toque", "A tall white hat with no brim. Commonly worn by professional cooks.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL); @@ -6682,6 +6697,7 @@ void initobjects(void) { addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 5, 5, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_GASMASK, "gas mask", "A full face mask which protects the wearer from toxic gasses.", MT_RUBBER, 3.5, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); @@ -6692,6 +6708,7 @@ void initobjects(void) { addflag(lastot->flags, F_EQUIPCONFER, F_VISRANGEMOD, -2, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 65, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_HELM, "helmet", "A plain metal helmet.", MT_METAL, 2, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 100, RR_COMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); @@ -6707,6 +6724,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 40, 40, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_VISRANGEMOD, -1, NA, NULL); addflag(lastot->flags, F_CRITPROTECTION, 100, NA, NA, NULL); + addflag(lastot->flags, F_STARTSPLAIN, B_TRUE, NA, NA, NULL); addot(OT_GOLDCROWN, "golden crown", "A heavy gold crown, encrusted with jewels.", MT_GOLD, 5, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_ALL, 25, RR_RARE, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); @@ -6739,6 +6757,8 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 5, 5, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_DEAF, NA, NA, NULL); addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); + addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL); + killflagsofid(lastot->flags, F_ENCHANTABLE); // armour - eyes addot(OT_SAFETYGLASSES, "pair of safety goggles", "A plastic eyemask designed for protection.", MT_PLASTIC, 0.01, OC_ARMOUR, SZ_TINY); diff --git a/defs.h b/defs.h index 79c7cfc..ae0285e 100644 --- a/defs.h +++ b/defs.h @@ -2803,6 +2803,8 @@ enum FLAG { F_MAGICBOOST, // boost power of all spells by v0 F_TEMPMAGICBOOST, // boost power of next spell cast (only) by v0 F_WHIP, // this weapon is a whip - use different damtext. + F_STARTSPLAIN, // this object is never randomly generated with + // a bless/curse or with a +xxx bonus. F_CANHAVEOBMOD, // weapon can have obmod om_v0 applied // optional: v1 is chance of randomly having it F_ATTREQ, // requires attrib v0 to be at least v1 @@ -4453,9 +4455,15 @@ typedef struct lifeform_s { // the first rotation in a turn is free, others cost time. int rotated; + // is the player in the process of changing levels + int changinglev; + // set to TRUE after lf has being created int born; + // debugging + int redraws; // # actual screen redraws during this lf's turn. + // for ai movement and pushers. DO save these. struct cell_s *prevcell[2]; diff --git a/io.c b/io.c index 68b3f7a..fdbbf85 100644 --- a/io.c +++ b/io.c @@ -1033,7 +1033,7 @@ cell_t *real_askcoords(char *prompt, char *subprompt, int targettype, lifeform_t cell_t *newcell; int bad = B_FALSE; if (srclf) { - if (!haslof_real(srclf->cell, c, loftype, &newcell, srclf, B_TRUE)) { + if (!haslofknown(srclf->cell, c, loftype, &newcell)) { bad = B_TRUE; } } else { @@ -8554,7 +8554,7 @@ void donextguntarget(void) { cell_t *c; c = player->los[i]; if (c->lf && (c->lf != player) && (c->lf != targ)) { - if (haslof(player->cell, c, LOF_NEED, NULL) && isingunrange(player, c)) { + if (haslofknown(player->cell, c, LOF_NEED, NULL) && isingunrange(player, c)) { // found one! setguntarget(player, c->lf); done = B_TRUE; @@ -8759,7 +8759,7 @@ int dothrow(obpile_t *op, object_t *o) { if (where) { cell_t *newwhere = NULL; - if (!haslof(player->cell, where, LOF_WALLSTOP, &newwhere)) { + if (!haslofknown(player->cell, where, LOF_WALLSTOP, &newwhere)) { if (newwhere && (newwhere != player->cell)) { char ch; ch = askchar("Your line of fire is blocked - really throw here", "yn", "y", B_TRUE, B_FALSE); @@ -8986,6 +8986,8 @@ void drawlevelfor(lifeform_t *lf) { precalclos(player); } + lf->redraws++; + //dbtimestart("drawscreen"); map = lf->cell->map; diff --git a/lf.c b/lf.c index 23f5273..2eb432d 100644 --- a/lf.c +++ b/lf.c @@ -3761,7 +3761,13 @@ void dumplf(void) { startmap = firstmap; } for (lf = startmap->lf ; lf ; lf = lf->next) { - dblog(" timespent=%3d id %d race %s",lf->timespent, lf->id, lf->race->name); + char buf[BUFLEN]; + sprintf(buf," timespent=%3d id %d race %s, redraws last turn=%d",lf->timespent, lf->id, lf->race->name, + lf->redraws); + if (cansee(player, lf)) { + strcat(buf, "(seen by player)"); + } + dblog("%s", buf); count++; } dblog("END LIFEFORM DUMP (%d found)",count); @@ -12642,6 +12648,9 @@ int haslof(cell_t *src, cell_t *dest, enum LOFTYPE loftype, cell_t **newdest) { return haslof_real(src, dest, loftype, newdest, NULL, B_TRUE); } +int haslofknown(cell_t *src, cell_t *dest, enum LOFTYPE loftype, cell_t **newdest) { + return haslof_real(src, dest, loftype, newdest, src->lf, B_TRUE); +} // got line of fire to dest? if lof is blocked, return last cell in 'newdest' // if 'srclf' is set, we are checking whether 'srclf' THINKS they have line of fire. ie invisible/unseed // lifeforms don't block lof. @@ -13760,6 +13769,11 @@ lifeform_t *real_addlf(cell_t *cell, enum RACE rid, int level, int controller) { a->eyeadjustment = 0; + a->changinglev = B_FALSE; + + // debug + a->redraws = 0; + // for ai // avoid messages when equipping initial obs @@ -18983,8 +18997,10 @@ void setlosdirty(lifeform_t *lf) { lf->losdirty = B_TRUE; if (lf->losdirty && isplayer(lf)) { - needredraw = B_TRUE; - drawscreen(); + if (!lf->changinglev) { + needredraw = B_TRUE; + drawscreen(); + } } } @@ -19560,6 +19576,9 @@ void startlfturn(lifeform_t *lf) { if (db) dblog("startlfturn for lf id %d %s", lf->id, lf->race->name); + // debugging + lf->redraws = 0; + // MOVE OUT OF STOMACHS WHICH DONT EXIST ANYMORE sf = hasflag(map->flags, F_STOMACHOF); if (sf) { @@ -21107,8 +21126,6 @@ int stone(lifeform_t *lf) { } getlfname(lf, lfname); - - // kill lifeform addflag(lf->flags, F_NODEATHANNOUNCE, B_TRUE, NA, NA, NULL); @@ -22290,6 +22307,7 @@ int usestairs(lifeform_t *lf, object_t *o, int onpurpose, int climb) { } } + // do stairs go somewhere? generate new maps if required. newcell = getstairdestination(o, &madenewmap); if (newcell) { diff --git a/lf.h b/lf.h index f771695..fb8deb6 100644 --- a/lf.h +++ b/lf.h @@ -312,6 +312,7 @@ void loseobflags(lifeform_t *lf, object_t *o, int kind); int hasbp(lifeform_t *lf, enum BODYPART bp); flag_t *hasactivespell(lifeform_t *lf, enum OBTYPE sid); int haslof(cell_t *src, cell_t *dest, enum LOFTYPE loftype, cell_t **newdest); +int haslofknown(cell_t *src, cell_t *dest, enum LOFTYPE loftype, cell_t **newdest); int haslof_real(cell_t *src, cell_t *dest, enum LOFTYPE loftype, cell_t **newdest, lifeform_t *srclf, int walllfsok); int haslos(lifeform_t *viewer, cell_t *dest); int haslosdark(lifeform_t *viewer, cell_t *dest); diff --git a/map.c b/map.c index 0327b03..3c6dc9b 100644 --- a/map.c +++ b/map.c @@ -3812,6 +3812,9 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex int nprevaults = 0; int db = B_TRUE; + // don't redraw screen during level change calculations + noredraw = B_TRUE; + //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging // determine habitat based on region @@ -4432,6 +4435,8 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex } //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging + noredraw = B_FALSE; + map->beingcreated = B_FALSE; if (db) dblog(" Map creation finished."); } diff --git a/move.c b/move.c index 525ec38..1a128cf 100644 --- a/move.c +++ b/move.c @@ -27,6 +27,8 @@ extern enum GAMEMODE gamemode; extern enum ERROR reason; extern void *rdata; +extern int noredraw; + extern long curtime; extern WINDOW *gamewin, *msgwin; @@ -1180,8 +1182,13 @@ int movelf(lifeform_t *lf, cell_t *newcell) { needredraw = B_TRUE; } + + + if (newcell->map != lf->cell->map) { changedlev = B_TRUE; + lf->changinglev = B_TRUE; + setlosdirty(lf); if (isplayer(lf)) { // remember the time which we exitted this map. @@ -1211,6 +1218,8 @@ int movelf(lifeform_t *lf, cell_t *newcell) { // now remove the barrier o = hasobid(newcell->obpile, barrierid); if (o) killob(o); + + if (isplayer(lf)) noredraw = B_FALSE; } // remember current cell + room id @@ -1621,6 +1630,8 @@ int movelf(lifeform_t *lf, cell_t *newcell) { } } // end if gamestarted + lf->changinglev = B_FALSE; + return didmsg; } diff --git a/objects.c b/objects.c index 3fa8fb7..94c2962 100644 --- a/objects.c +++ b/objects.c @@ -6407,7 +6407,7 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh // chance to be blessed or cursed? 15% chance each way strcpy(cursestr, ""); - if (!hasflag(ot->flags, F_NOBLESS)) { + if (!hasflag(ot->flags, F_NOBLESS) && !hasflag(ot->flags, F_STARTSPLAIN)) { int num; num = rnd(1,100); if (num <= 15) { @@ -6418,7 +6418,7 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh } - if (hasflag(ot->flags, F_ENCHANTABLE)) { + if (hasflag(ot->flags, F_ENCHANTABLE) && !hasflag(ot->flags, F_STARTSPLAIN)) { char buf2[BUFLENSMALL]; int bonus = 0; int dir,chance; @@ -6431,7 +6431,7 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh chance = 30; dir = 1; } else { - chance = 25; + chance = 10; dir = 1; } while (rnd(1,100) <= chance) { diff --git a/spell.c b/spell.c index 850e035..11c3e18 100644 --- a/spell.c +++ b/spell.c @@ -157,7 +157,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef if (!target) { if (isplayer(user)) msg("There is nobody there!"); return TRUE; - } else if (!haslof(user->cell, targcell, LOF_NEED, NULL)) { + } else if (!haslof_real(user->cell, targcell, LOF_NEED, NULL, user, B_FALSE)) { if (isplayer(user)) msg("Your path there is blocked!"); return TRUE; } @@ -3526,7 +3526,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_ targcell = retcell[maxr]; } - // adjust for LOF + // adjust for LOF (we already validated this during castspell()'s call to validatespellcell(), + // but check again in case, for example, there was an invisible lf in the way which we couldn't + // see. loft = getspellloftype(spellid); if (loft != LOF_DONTNEED) { cell_t *newtarg; @@ -12450,6 +12452,12 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_ ch = rnd('a', 'f'); } } + + // warn if this was bad... + if (isplayer(target) && (blessed == B_CURSED)) { + msg("^%cUh oh, you have a bad feeling about this...", getlfcol(target, CC_VBAD)); more(); + } + if (ch == 'a') { // wealth (gold, bad: goldtouch) snprintf(buf, BUFLEN, "1000-2000 gold coins"); } else if (ch == 'b') { // power (weapons, bad: battery) @@ -12527,9 +12535,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_ snprintf(buf, BUFLEN, "sun hat"); } } else { - snprintf(buf, BUFLEN, "sun hat"); + stone(caster); } - } else if (ch == 'd') { // fame (allies bad: useless allies) + } else if (ch == 'd') { // fame (allies bad: useless allies or monsters) lifeform_t *lf; cell_t *c; job_t *j; @@ -12543,7 +12551,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_ if (cansee(player, lf)) { msg("%s appears!", lfname); } - petify(lf, target); + if (blessed == B_CURSED) { + aiattack(lf, target, aigetchasetime(lf)); + } else { + petify(lf, target); + } if (isplayer(target)) { p = assignnpcname(lf->flags); @@ -14056,7 +14068,6 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e enum LOFTYPE needlof = LOF_NEED; int minrange = 0; - if (!caster) { return *targcell; } else if ((caster->race->raceclass->id == RC_GOD) && targcell) { @@ -14093,7 +14104,7 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e } // line of fire interrupted? - if (where && needlof && !haslof(caster->cell, where, needlof, &newwhere)) { + if (where && needlof && !haslofknown(caster->cell, where, needlof, &newwhere)) { if (newwhere) { if (isplayer(caster) && !frompot) { // warn!