From 99fc225519422d719f70d62437c2f8ce3860a64f Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 31 May 2016 10:41:00 +1000 Subject: [PATCH] - in addob(), prevent placing innate attack objects into non-lf obpiles. - when parsing object names, require an exact match for innate attack objects. --- data.c | 9 ++++++++- defs.h | 1 + objects.c | 34 ++++++++++++++++++++++++++-------- objects.h | 1 + 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/data.c b/data.c index 7e63388..01037e1 100644 --- a/data.c +++ b/data.c @@ -265,7 +265,7 @@ void initjobs(void) { addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "a digital watch"); addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "10 blessed scrolls of create monster"); addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "10 blessed potions of experience"); - addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "ring of miracles"); + addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "ring of greater arcane power"); addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "ring of control"); addflag(lastjob->flags, F_STARTOB, 100, NA, NA, "infovisor"); addflag(lastjob->flags, F_STARTSKILL, SK_LORE_ARCANA, PR_NOVICE, NA, NULL); @@ -8724,10 +8724,13 @@ void initobjects(void) { addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, ""); addflag(lastot->flags, F_EQUIPCONFER, F_MEDITATES, B_TRUE, NA, NULL); addflag(lastot->flags, F_VALUE, 250, NA, NA, NULL); + addot(OT_RING_SPELLBOOST, "ring of arcane power", "Increases the power of the wearer's spells.", MT_METAL, 0.1, OC_RING, SZ_MINI); addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, ""); addflag(lastot->flags, F_VALUE, 250, NA, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_MAGICBOOST, 1, NA, NULL); + + addot(OT_RING_DECELERATION, "ring of deceleration", "Slows down all nearby projectiles, providing protection from projectile attacks but also limiting their use.", MT_METAL, 0.1, OC_RING, SZ_MINI); addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_UNCOMMON, ""); addflag(lastot->flags, F_EQUIPCONFER, F_DTIMMUNE, DT_PROJECTILE, B_TRUE, NULL); @@ -8768,6 +8771,10 @@ void initobjects(void) { addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_RARE, ""); addflag(lastot->flags, F_EQUIPCONFER, F_LEARNBOOST, 35, NA, NULL); addflag(lastot->flags, F_VALUE, 300, NA, NA, NULL); + addot(OT_RING_SPELLBOOST2, "ring of greater arcane power", "Greatly increases the power of the wearer's spells.", MT_METAL, 0.1, OC_RING, SZ_MINI); + addflag(lastot->flags, F_RARITY, H_ALL, 75, RR_RARE, ""); + addflag(lastot->flags, F_VALUE, 450, NA, NA, NULL); + addflag(lastot->flags, F_EQUIPCONFER, F_MAGICBOOST, 3, NA, NULL); // rings - very rare addot(OT_RING_REGENERATION, "ring of regeneration", "Slowly regenerates the wearer's health, even when not resting.", MT_METAL, 0.1, OC_RING, SZ_MINI); diff --git a/defs.h b/defs.h index 460195d..0113365 100644 --- a/defs.h +++ b/defs.h @@ -2531,6 +2531,7 @@ enum OBTYPE { OT_RING_MEDITATION, OT_RING_MIRACLES, OT_RING_SPELLBOOST, + OT_RING_SPELLBOOST2, OT_RING_MPREGEN, OT_RING_PROTFIRE, OT_RING_PROTCOLD, diff --git a/objects.c b/objects.c index 475c023..8d980d8 100644 --- a/objects.c +++ b/objects.c @@ -612,7 +612,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum } } - // parse name string + // parse number string nsp = numstringmin; for (p = localname ; isdigit(*p) ; p++) { *nsp = *p; @@ -635,7 +635,6 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum // "p" should now point at the start of the actual // object name. - // are we giving multiple objects? if (strlen(numstringmin) > 0) { int min,max; @@ -1311,7 +1310,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum ot = findot(OT_BLOODSTAIN); } } - + if (gamemode != GM_LOADING) { // don't put floor gratings on low floors @@ -1351,6 +1350,16 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum return NULL; } } + + // don't put innate attack objects anywhere other than on a lifeform + if (!where->owner && !istempobpile(where) && hasflag(ot->flags, F_UNARMEDWEP)) { + if (db) dblog("DB: Cannot give innate attack objects to non-lifeforms. object name '%s'", ot->name ); + + nretobs = 0; + killflagpile(wantflags); + if (localname) free(localname); + return NULL; + } } if (bonus > 0) { @@ -4048,13 +4057,15 @@ objecttype_t *findotn(char *name) { } } - // then partial matches on real name + // then partial matches on real name, but exclude certain things like innate attacks ("whipattack") for (ot = objecttype ; ot ; ot = ot->next) { if ((ot->obclass->id != OC_SPELL) && (ot->obclass->id != OC_ABILITY)) { - if (strstr(ot->name, modname)) { - free(modname); - // found it! - return ot; + if (!hasflag(ot->flags, F_UNARMEDWEP)) { + if (strstr(ot->name, modname)) { + free(modname); + // found it! + return ot; + } } } } @@ -8207,6 +8218,13 @@ int ismetal(enum MATERIAL mat) { return metal; } +int istempobpile(obpile_t *op) { + if ((op->owner == NULL) && (op->where == NULL) && (op->parentob == NULL)) { + return B_TRUE; + } + return B_FALSE; +} + int isthrowmissile(object_t *o) { if (hasflag(o->flags, F_THROWMISSILE)) { return B_TRUE; diff --git a/objects.h b/objects.h index e635646..3211b22 100644 --- a/objects.h +++ b/objects.h @@ -228,6 +228,7 @@ int isrotting(object_t *o); flag_t *issecretdoor(object_t *o); flag_t *isshield(object_t *o); int issmellableob(object_t *o); +int istempobpile(obpile_t *op); int isthrownmissile(object_t *o); knowledge_t *istried(object_t *o); knowledge_t *istriedot(objecttype_t *ot);