- in addob(), prevent placing innate attack objects into non-lf obpiles.

- when parsing object names, require an exact match for innate attack objects.
This commit is contained in:
Rob Pearce 2016-05-31 10:41:00 +10:00
parent 54643ca5b9
commit 99fc225519
4 changed files with 36 additions and 9 deletions

9
data.c
View File

@ -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);

1
defs.h
View File

@ -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,

View File

@ -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;
@ -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,9 +4057,10 @@ 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 (!hasflag(ot->flags, F_UNARMEDWEP)) {
if (strstr(ot->name, modname)) {
free(modname);
// found it!
@ -4058,6 +4068,7 @@ objecttype_t *findotn(char *name) {
}
}
}
}
free(modname);
return NULL;
@ -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;

View File

@ -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);