* [+] bag of holding
- [+] change getobpileweight() to traverse into containers!
This commit is contained in:
parent
07844bb69e
commit
9481e41701
9
defs.h
9
defs.h
|
@ -1159,6 +1159,9 @@ enum OBTYPE {
|
||||||
// tools - unique
|
// tools - unique
|
||||||
OT_ORBDUNGEONEXIT,
|
OT_ORBDUNGEONEXIT,
|
||||||
// tools
|
// tools
|
||||||
|
OT_BAGOFHOLDING,
|
||||||
|
OT_BAGOFHOLDINGLARGE,
|
||||||
|
OT_BAGOFHOLDINGHUGE,
|
||||||
OT_BLANKET,
|
OT_BLANKET,
|
||||||
OT_BLINDFOLD,
|
OT_BLINDFOLD,
|
||||||
OT_BUGLAMP,
|
OT_BUGLAMP,
|
||||||
|
@ -1171,6 +1174,7 @@ enum OBTYPE {
|
||||||
OT_PICKAXE,
|
OT_PICKAXE,
|
||||||
OT_ROPE,
|
OT_ROPE,
|
||||||
OT_SACK,
|
OT_SACK,
|
||||||
|
OT_SACKLARGE,
|
||||||
OT_SACKHUGE,
|
OT_SACKHUGE,
|
||||||
OT_SAFEBOX,
|
OT_SAFEBOX,
|
||||||
OT_TORCH,
|
OT_TORCH,
|
||||||
|
@ -1643,6 +1647,9 @@ enum FLAG {
|
||||||
// -1 means "nutrition is weight x abs(val1)"
|
// -1 means "nutrition is weight x abs(val1)"
|
||||||
// if v2=DONTKILL, this object does NOT die when drunk.
|
// if v2=DONTKILL, this object does NOT die when drunk.
|
||||||
F_OPERABLE, // can operate?
|
F_OPERABLE, // can operate?
|
||||||
|
F_OPERWITHOUTID, // can operate without knowing what it is?
|
||||||
|
F_NOTRIED, // don't show '[tried]' or update knowledge
|
||||||
|
// after you have tried this object.
|
||||||
F_POURABLE, // can pour?
|
F_POURABLE, // can pour?
|
||||||
F_PUSHABLE, // can push this object
|
F_PUSHABLE, // can push this object
|
||||||
F_PICKLOCKS, // can pick locks? val0=% change,
|
F_PICKLOCKS, // can pick locks? val0=% change,
|
||||||
|
@ -1870,6 +1877,8 @@ enum FLAG {
|
||||||
// v1 = depth modifier. can use 'RANDOM'
|
// v1 = depth modifier. can use 'RANDOM'
|
||||||
F_CONTAINER, // this object is a container - you can use 'o'
|
F_CONTAINER, // this object is a container - you can use 'o'
|
||||||
// to take stuff out or put it in.
|
// to take stuff out or put it in.
|
||||||
|
F_HOLDING, // this container is a xxx of holding and makes objects
|
||||||
|
// inside become weightless
|
||||||
F_STARTJOB, // val0 = %chance of starting with it, v1 = jobid
|
F_STARTJOB, // val0 = %chance of starting with it, v1 = jobid
|
||||||
F_STARTSKILL, // val0 = skill id
|
F_STARTSKILL, // val0 = skill id
|
||||||
F_STARTATT, // val0 = A_xxx, val0 = start bracket (ie. IQ_GENIUS)
|
F_STARTATT, // val0 = A_xxx, val0 = start bracket (ie. IQ_GENIUS)
|
||||||
|
|
6
io.c
6
io.c
|
@ -4364,7 +4364,11 @@ void dodrop(obpile_t *op, int wantmulti, obpile_t *dst) {
|
||||||
getobname(o, buf, o->amt);
|
getobname(o, buf, o->amt);
|
||||||
msg("You put %s into %s.",buf, toname);
|
msg("You put %s into %s.",buf, toname);
|
||||||
} else {
|
} else {
|
||||||
msg("You can't put %s into %s.",buf, toname);
|
if (reason == E_NOSPACE) {
|
||||||
|
msg("%s won't fit into %s.",buf, toname);
|
||||||
|
} else {
|
||||||
|
msg("You can't put %s into %s.",buf, toname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
drop(o, count);
|
drop(o, count);
|
||||||
|
|
2
lf.c
2
lf.c
|
@ -8065,7 +8065,7 @@ void initrace(void) {
|
||||||
addflag(lastrace->flags, F_ACTIONSPEED, SP_SLOW, NA, NA, NULL);
|
addflag(lastrace->flags, F_ACTIONSPEED, SP_SLOW, NA, NA, NULL);
|
||||||
addflag(lastrace->flags, F_HASATTACK, OT_FISTS, NA, NA, "1d2");
|
addflag(lastrace->flags, F_HASATTACK, OT_FISTS, NA, NA, "1d2");
|
||||||
addflag(lastrace->flags, F_STARTOB, 100, NA, NA, "blessed ring of hunger");
|
addflag(lastrace->flags, F_STARTOB, 100, NA, NA, "blessed ring of hunger");
|
||||||
addflag(lastrace->flags, F_STARTOB, 100, NA, NA, "10 huge sacks");
|
addflag(lastrace->flags, F_STARTOB, 100, NA, NA, "10 huge bags of holding");
|
||||||
//addflag(lastrace->flags, F_WANTS, OT_GOLD, NA, NA, NULL);
|
//addflag(lastrace->flags, F_WANTS, OT_GOLD, NA, NA, NULL);
|
||||||
addflag(lastrace->flags, F_WANTSOBFLAG, F_RARITY, NA, NA, NULL); // ie. everything
|
addflag(lastrace->flags, F_WANTSOBFLAG, F_RARITY, NA, NA, NULL); // ie. everything
|
||||||
addflag(lastrace->flags, F_HUMANOID, B_TRUE, NA, NA, NULL);
|
addflag(lastrace->flags, F_HUMANOID, B_TRUE, NA, NA, NULL);
|
||||||
|
|
113
objects.c
113
objects.c
|
@ -2661,6 +2661,7 @@ objecttype_t *findotn(char *name) {
|
||||||
|
|
||||||
// make some replacements
|
// make some replacements
|
||||||
//replace scrolls with scroll etc
|
//replace scrolls with scroll etc
|
||||||
|
modname = strrep(modname, "bags ", "bag ", NULL);
|
||||||
modname = strrep(modname, "berries ", "berry ", NULL);
|
modname = strrep(modname, "berries ", "berry ", NULL);
|
||||||
modname = strrep(modname, "blocks ", "block ", NULL);
|
modname = strrep(modname, "blocks ", "block ", NULL);
|
||||||
modname = strrep(modname, "cans ", "can ", NULL);
|
modname = strrep(modname, "cans ", "can ", NULL);
|
||||||
|
@ -3868,7 +3869,18 @@ char *getobdesc(object_t *o, char *buf) {
|
||||||
sprintf(buf, "%s", o->type->desc);
|
sprintf(buf, "%s", o->type->desc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "%s", o->type->obclass->desc);
|
objecttype_t *ot = NULL;
|
||||||
|
flag_t *f;
|
||||||
|
f = hasflag(o->flags, F_HASHIDDENNAME);
|
||||||
|
if (f) {
|
||||||
|
ot = findotn(f->text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ot) {
|
||||||
|
sprintf(buf, "%s", ot->desc);
|
||||||
|
} else {
|
||||||
|
sprintf(buf, "%s", o->type->obclass->desc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -4547,6 +4559,10 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
||||||
float getobpileweight(obpile_t *op) {
|
float getobpileweight(obpile_t *op) {
|
||||||
object_t *o;
|
object_t *o;
|
||||||
float weight = 0;
|
float weight = 0;
|
||||||
|
if (op->parentob && hasflag(op->parentob->flags, F_HOLDING)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (o = op->first ; o ; o = o->next) {
|
for (o = op->first ; o ; o = o->next) {
|
||||||
weight += getobweight(o);
|
weight += getobweight(o);
|
||||||
}
|
}
|
||||||
|
@ -4632,6 +4648,13 @@ float getobweight(object_t *o) {
|
||||||
float weight;
|
float weight;
|
||||||
|
|
||||||
weight = getobunitweight(o) * o->amt;
|
weight = getobunitweight(o) * o->amt;
|
||||||
|
|
||||||
|
// object contents
|
||||||
|
if (hasflag(o->flags, F_CONTAINER) && !hasflag(o->flags, F_HOLDING)) {
|
||||||
|
float containerweight = 0;
|
||||||
|
containerweight = getobpileweight(o->contents);
|
||||||
|
weight += containerweight;
|
||||||
|
}
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
@ -4640,6 +4663,11 @@ float getobunitweight(object_t *o) {
|
||||||
float weight;
|
float weight;
|
||||||
flag_t *f;
|
flag_t *f;
|
||||||
|
|
||||||
|
// bag of holding?
|
||||||
|
if (o->pile->parentob && hasflag(o->pile->parentob->flags, F_HOLDING)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (o->type->id == OT_WATERDEEP) {
|
if (o->type->id == OT_WATERDEEP) {
|
||||||
weight = 75 * getobdepth(o, NULL);
|
weight = 75 * getobdepth(o, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
@ -5641,6 +5669,7 @@ void initobjects(void) {
|
||||||
addflag(lastobjectclass->flags, F_DTIMMUNE, DT_FIRE, NA, NA, NULL);
|
addflag(lastobjectclass->flags, F_DTIMMUNE, DT_FIRE, NA, NA, NULL);
|
||||||
addflag(lastobjectclass->flags, F_HASHIDDENNAME, B_TRUE, NA, NA, NULL);
|
addflag(lastobjectclass->flags, F_HASHIDDENNAME, B_TRUE, NA, NA, NULL);
|
||||||
addflag(lastobjectclass->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
addflag(lastobjectclass->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastobjectclass->flags, F_OPERWITHOUTID, B_TRUE, NA, NA, NULL);
|
||||||
addflag(lastobjectclass->flags, F_OPERUSECHARGE, B_TRUE, NA, NA, NULL);
|
addflag(lastobjectclass->flags, F_OPERUSECHARGE, B_TRUE, NA, NA, NULL);
|
||||||
addflag(lastobjectclass->flags, F_RNDCHARGES, 1, 8, NA, NULL);
|
addflag(lastobjectclass->flags, F_RNDCHARGES, 1, 8, NA, NULL);
|
||||||
|
|
||||||
|
@ -7550,7 +7579,7 @@ void initobjects(void) {
|
||||||
addflag(lastot->flags, F_RARITY, H_FOREST, 75, NA, NULL);
|
addflag(lastot->flags, F_RARITY, H_FOREST, 75, NA, NULL);
|
||||||
addflag(lastot->flags, F_HELPSCLIMB, 3, NA, NA, NULL);
|
addflag(lastot->flags, F_HELPSCLIMB, 3, NA, NA, NULL);
|
||||||
|
|
||||||
addot(OT_SACK, "sack", "A small cloth sack.", MT_CLOTH, 1, OC_TOOLS, SZ_SMALL);
|
addot(OT_SACK, "sack", "A small cloth sack.", MT_CLOTH, 0.5, OC_TOOLS, SZ_SMALL);
|
||||||
addflag(lastot->flags, F_RARITY, H_ALL, 80, RR_COMMON, NULL);
|
addflag(lastot->flags, F_RARITY, H_ALL, 80, RR_COMMON, NULL);
|
||||||
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
@ -7562,6 +7591,18 @@ void initobjects(void) {
|
||||||
addflag(lastot->flags, F_STARTOBRND, 30, NA, NA, NULL);
|
addflag(lastot->flags, F_STARTOBRND, 30, NA, NA, NULL);
|
||||||
addflag(lastot->flags, F_STARTOBRND, 10, NA, NA, NULL);
|
addflag(lastot->flags, F_STARTOBRND, 10, NA, NA, NULL);
|
||||||
|
|
||||||
|
addot(OT_SACKLARGE, "large sack", "A large cloth sack.", MT_CLOTH, 1, OC_TOOLS, SZ_MEDIUM);
|
||||||
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_DAMAGABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OBHP, 50, 50, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_CONTAINER, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
|
||||||
addot(OT_SACKHUGE, "huge sack", "An enormous cloth sack.", MT_CLOTH, 1, OC_TOOLS, SZ_LARGE);
|
addot(OT_SACKHUGE, "huge sack", "An enormous cloth sack.", MT_CLOTH, 1, OC_TOOLS, SZ_LARGE);
|
||||||
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
@ -7578,6 +7619,55 @@ void initobjects(void) {
|
||||||
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
addot(OT_BAGOFHOLDING, "bag of holding", "A magical sack which causes items placed inside it to become weightless.", MT_CLOTH, 0.5, OC_TOOLS, SZ_SMALL);
|
||||||
|
addflag(lastot->flags, F_RARITY, H_ALL, 80, RR_RARE, NULL);
|
||||||
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERWITHOUTID, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_NOTRIED, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_CONTAINER, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HOLDING, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 30, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 10, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HASHIDDENNAME, B_TRUE, NA, NA, "sack");
|
||||||
|
|
||||||
|
addot(OT_BAGOFHOLDINGLARGE, "large bag of holding", "A large magical sack which causes items placed inside it to become weightless.", MT_CLOTH, 0.5, OC_TOOLS, SZ_MEDIUM);
|
||||||
|
addflag(lastot->flags, F_RARITY, H_ALL, 80, RR_RARE, NULL);
|
||||||
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERWITHOUTID, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_NOTRIED, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_CONTAINER, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HOLDING, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HASHIDDENNAME, B_TRUE, NA, NA, "large sack");
|
||||||
|
|
||||||
|
addot(OT_BAGOFHOLDINGHUGE, "huge bag of holding", "An enormous magical sack which causes items placed inside it to become weightless.", MT_CLOTH, 0.5, OC_TOOLS, SZ_LARGE);
|
||||||
|
addflag(lastot->flags, F_RARITY, H_ALL, 80, RR_VERYRARE, NULL);
|
||||||
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
|
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERWITHOUTID, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_NOTRIED, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_CONTAINER, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HOLDING, B_TRUE, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 100, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_STARTOBRND, 50, NA, NA, NULL);
|
||||||
|
addflag(lastot->flags, F_HASHIDDENNAME, B_TRUE, NA, NA, "huge sack");
|
||||||
|
|
||||||
addot(OT_SAFEBOX, "safebox", "A small metal container for safely storing valuables.", MT_METAL, 2, OC_TOOLS, SZ_SMALL);
|
addot(OT_SAFEBOX, "safebox", "A small metal container for safely storing valuables.", MT_METAL, 2, OC_TOOLS, SZ_SMALL);
|
||||||
addflag(lastot->flags, F_RARITY, H_DUNGEON, 77, RR_UNCOMMON, NULL);
|
addflag(lastot->flags, F_RARITY, H_DUNGEON, 77, RR_UNCOMMON, NULL);
|
||||||
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
addflag(lastot->flags, F_GLYPH, C_YELLOW, NA, NA, "(");
|
||||||
|
@ -10189,6 +10279,13 @@ void makeknown(enum OBTYPE otid) {
|
||||||
|
|
||||||
void maketried(enum OBTYPE otid) {
|
void maketried(enum OBTYPE otid) {
|
||||||
knowledge_t *k;
|
knowledge_t *k;
|
||||||
|
objecttype_t *ot;
|
||||||
|
|
||||||
|
// avoid adding '[tried]' to certain objects
|
||||||
|
ot = findot(otid);
|
||||||
|
if (ot && hasflag(ot->flags, F_NOTRIED)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (k = knowledge; k ; k = k->next) {
|
for (k = knowledge; k ; k = k->next) {
|
||||||
if (k->id == otid) {
|
if (k->id == otid) {
|
||||||
|
@ -10901,9 +10998,15 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
||||||
// if not a wand, must know what a tool is before you can use it
|
// if not a wand, must know what a tool is before you can use it
|
||||||
|
|
||||||
// also use the same message whn you try to operate something non-operable
|
// also use the same message whn you try to operate something non-operable
|
||||||
// to avoid using this to identify mistletoe.
|
// to avoid using this to identify mistletoe, etc.
|
||||||
if (!isoperable(o) ||
|
if (!isoperable(o)) {
|
||||||
(!isknown(o) && (o->type->obclass->id != OC_WAND)) ) {
|
if (isplayer(lf)) {
|
||||||
|
msg("You don't know how to use %s!", obname);
|
||||||
|
}
|
||||||
|
return B_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isknown(o) && !hasflag(o->flags, F_OPERWITHOUTID)) {
|
||||||
if (isplayer(lf)) {
|
if (isplayer(lf)) {
|
||||||
msg("You don't know how to use %s!", obname);
|
msg("You don't know how to use %s!", obname);
|
||||||
}
|
}
|
||||||
|
|
2
text.c
2
text.c
|
@ -398,6 +398,8 @@ char *makeplural(char *text) {
|
||||||
newtext = strdup(text);
|
newtext = strdup(text);
|
||||||
|
|
||||||
// scrolls
|
// scrolls
|
||||||
|
newtext = strrep(newtext, "bag ", "bags ", &rv);
|
||||||
|
if (rv) return newtext;
|
||||||
newtext = strrep(newtext, "berry ", "berries ", &rv);
|
newtext = strrep(newtext, "berry ", "berries ", &rv);
|
||||||
if (rv) return newtext;
|
if (rv) return newtext;
|
||||||
newtext = strrep(newtext, "block ", "blocks ", &rv);
|
newtext = strrep(newtext, "block ", "blocks ", &rv);
|
||||||
|
|
Loading…
Reference in New Issue