- [+] IMPLEMENT proper object conditions

- [+] first:
        - [+] create reimplmemnt AO_xxx
        - [+] get rid of obmatchescondition (use new obMEETScondition
              instead)
            - [+] doaskobject
            - [+] askobjectmulti
            - [+] askobject
            - [+] askobjectwithflag
        - [+] ----- TEST ------
        - [+] new cc_ types for obejcts and obtypes
            - [+] CC_MINDR
            - [+] CC_MAXDR
            - [+] CC_MINAR
        - [+] then fix up getrandomobofclass. use CC_HASOBCLASS instead
        - [+] replace all calls to getrandomobofclass to use condsets
        - [+] then fix up other getrandomob routines
            - [+] real_getrandomob
                - [+] maxsize
                - [+] wepsk
                - [+] obclass (OR)
                - [+] damtype (OR)
                - [+] wantflag
                - [+] fix function.
                - [+] fix calls...
            - [+] getrandomob
            - [+] getrandomobofsize
            - [+] getrandomobwithdt
            - [+] getrandomofwithflag
            - [+] getrandomobwithclass
- [+] auto code to stop low TR monsters starting with super rare
      weapons.
    - [+] apply_wep_tr_limit(lifeform_t *lf, condset_t *cs)
        - [+] implement max weapon DR based on TR:
- [+] baby battery lizard
- [+] battery lizard
This commit is contained in:
Rob Pearce 2012-11-30 12:05:29 +00:00
parent c6fed68ba2
commit a144e9c4a6
13 changed files with 780 additions and 351 deletions

201
data.c
View File

@ -3329,6 +3329,22 @@ void initobjects(void) {
addflag(lastot->flags, F_DTVULN, DT_FIRE, NA, NA, "2d6");
addflag(lastot->flags, F_DTVULN, DT_CHOP, NA, NA, NULL);
addflag(lastot->flags, F_GROWSTO, OT_TREE, VT_OB, NA, NULL);
addot(OT_STICK, "stick", "A sturdy wooden stick. It's brown and sticky.", MT_WOOD, 0.5, OC_FLORA, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, NA, NULL);
addflag(lastot->flags, F_DAM, DT_BASH, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_CLUBS, NA, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_RODSHAPED, B_TRUE, NA, NA, NULL);
addot(OT_STUMP, "tree stump", "A large tree stump.", MT_WOOD, 150, OC_FLORA, SZ_LARGE);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_FREQUENT, "");
addflag(lastot->flags, F_GLYPH, C_BROWN, '\'', NA, NULL);
@ -6286,6 +6302,19 @@ void initobjects(void) {
addflag(lastot->flags, F_DIGCELLMAT, MT_DIRT, NA, NA, NULL);
addflag(lastot->flags, F_OPERSOUND, SV_SHOUT, NA, NA, "the sound of digging");
addot(OT_SPANNER, "spanner", "A long, heavy metal wrench.", MT_METAL, 1, OC_WEAPON, SZ_MEDIUM);
addflag(lastot->flags, F_EXTRADESC, NA, NA, NA, "It makes metalwork easier.");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 70, NA, NULL);
addflag(lastot->flags, F_DAM, DT_BASH, 4, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 75, NA, NA, NULL);
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_OPERNEEDDIR, B_TRUE, NA, NA, "Use your spanner in which direction");
addflag(lastot->flags, F_HELPSDISARM, 5, NA, NA, NULL);
addflag(lastot->flags, F_HELPSREPAIR, MT_METAL, 2, 15, NULL);
addflag(lastot->flags, F_USESSKILL, SK_CLUBS, NA, NA, NULL);
addflag(lastot->flags, F_OPERSOUND, SV_SHOUT, NA, NA, "a metallic clanging");
addot(OT_TORCH, "torch", "A metre-long wooden rod with a flammable end.", MT_WOOD, 2, OC_TOOLS, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_ALL, 85, NA, NULL);
addflag(lastot->flags, F_VALUE, 25, NA, NA, NULL);
@ -6784,6 +6813,43 @@ void initobjects(void) {
// tech - l6 ???
// misc
addot(OT_TUSK, "ivory tusk", "A large ivory tusk from a slain elephant. Could be used as weapon by very large creatures.", MT_BONE, 61, OC_MISC, SZ_HUMAN);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_VALUE, 450, NA, NA, NULL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 120, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_PIERCE, 12, NA, NULL);
addflag(lastot->flags, F_ALTDAM, DT_BASH, 4, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 70, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_LONGBLADES, NA, NA, NULL);
addflag(lastot->flags, F_ATTREQ, A_STR, 80, NA, "3");
addflag(lastot->flags, F_CRITCHANCE, 1, NA, NA, NULL);
addflag(lastot->flags, F_CANBLOCK, DT_SLASH, NA, NA, NULL);
addot(OT_FORK, "fork", "A common kitchen fork.", MT_METAL, 0.2, OC_MISC, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 50, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_PIERCE, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 65, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 2, 2, NA, NULL);
addflag(lastot->flags, F_ATTREQ, A_AGI, NA, 65, "10");
addflag(lastot->flags, F_USESSKILL, SK_SHORTBLADES, NA, NA, NULL);
addot(OT_STEAKKNIFE, "steak knife", "A common kitchen knife.", MT_METAL, 0.2, OC_MISC, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 50, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_SLASH, 2, NA, NULL);
addflag(lastot->flags, F_ALTDAM, DT_PIERCE, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL);
addflag(lastot->flags, F_THROWMISSILE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_DAMAGABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_STACKABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 5, 5, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_SHORTBLADES, NA, NA, NULL);
addot(OT_BONE, "bone", "A bone from an unknown creature.", MT_BONE, 0.1, OC_MISC, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_ALL, 75, NA, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 90, NA, NULL);
@ -9105,15 +9171,6 @@ void initobjects(void) {
addflag(lastot->flags, F_CRITCHANCE, 2, NA, NA, NULL);
addflag(lastot->flags, F_CANBEDIFFMAT, MT_SILVER, 10, NA, NULL);
addflag(lastot->flags, F_ATTREQ, A_STR, NA, 65, "10");
addot(OT_FORK, "fork", "A common kitchen fork.", MT_METAL, 0.2, OC_WEAPON, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 50, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_PIERCE, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 65, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 2, 2, NA, NULL);
addflag(lastot->flags, F_ATTREQ, A_AGI, NA, 65, "10");
addflag(lastot->flags, F_USESSKILL, SK_SHORTBLADES, NA, NA, NULL);
addot(OT_KNIFE, "knife", "A moderately sharp stabbing tool.", MT_METAL, 0.5, OC_WEAPON, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
@ -9208,19 +9265,6 @@ void initobjects(void) {
addflag(lastot->flags, F_ACCURACY, 75, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_SHORTBLADES, NA, NA, NULL);
addflag(lastot->flags, F_CRITCHANCE, 2, NA, NA, NULL);
addot(OT_STEAKKNIFE, "steak knife", "A common kitchen knife.", MT_METAL, 0.2, OC_WEAPON, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 50, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_SLASH, 2, NA, NULL);
addflag(lastot->flags, F_ALTDAM, DT_PIERCE, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL);
addflag(lastot->flags, F_THROWMISSILE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_DAMAGABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_STACKABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 5, 5, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_SHORTBLADES, NA, NA, NULL);
// long blades
addot(OT_RAPIER, "rapier", "A long, narrow French sword lacking a cutting edge. Made for stabbing.", MT_METAL, 3.5, OC_WEAPON, SZ_MEDIUM);
@ -9338,20 +9382,6 @@ void initobjects(void) {
addflag(lastot->flags, F_CRITCHANCE, 7, NA, NA, NULL);
addflag(lastot->flags, F_CANBLOCK, DT_SLASH, NA, NA, NULL);
addot(OT_TUSK, "ivory tusk", "A large ivory tusk from a slain elephant. Could be used as weapon by very large creatures.", MT_BONE, 61, OC_WEAPON, SZ_HUMAN);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_VALUE, 450, NA, NA, NULL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, NA, RR_VERYRARE, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 120, NA, NA, NULL);
addflag(lastot->flags, F_DAM, DT_PIERCE, 12, NA, NULL);
addflag(lastot->flags, F_ALTDAM, DT_BASH, 4, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 70, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_LONGBLADES, NA, NA, NULL);
addflag(lastot->flags, F_ATTREQ, A_STR, 80, NA, "3");
addflag(lastot->flags, F_CRITCHANCE, 1, NA, NA, NULL);
addflag(lastot->flags, F_CANBLOCK, DT_SLASH, NA, NA, NULL);
addot(OT_ZWEIHANDER, "zweihander", "Even more dangerous than the mighty greatsword, the Zweihander is almost absurdly long, making it very hard to dodge.", MT_METAL, 12, OC_WEAPON, SZ_MEDIUM);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 55, RR_VERYRARE, NULL);
@ -9680,17 +9710,7 @@ void initobjects(void) {
addflag(lastot->flags, F_ATTREQ, A_STR, 65, 75, "10");
addflag(lastot->flags, F_CRITCHANCE, 8, NA, NA, NULL);
addflag(lastot->flags, F_OBATTACKDELAY, 150, NA, NA, NULL);
addot(OT_SPANNER, "spanner", "A long, heavy metal wrench.", MT_METAL, 1, OC_WEAPON, SZ_MEDIUM);
addflag(lastot->flags, F_EXTRADESC, NA, NA, NA, "It makes metalwork easier.");
addflag(lastot->flags, F_RARITY, H_DUNGEON, 70, NA, NULL);
addflag(lastot->flags, F_DAM, DT_BASH, 4, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 75, NA, NA, NULL);
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_OPERNEEDDIR, B_TRUE, NA, NA, "Use your spanner in which direction");
addflag(lastot->flags, F_HELPSDISARM, 5, NA, NA, NULL);
addflag(lastot->flags, F_HELPSREPAIR, MT_METAL, 2, 15, NULL);
addflag(lastot->flags, F_USESSKILL, SK_CLUBS, NA, NA, NULL);
addflag(lastot->flags, F_OPERSOUND, SV_SHOUT, NA, NA, "a metallic clanging");
addot(OT_SHILLELAGH, "shillelagh", "An small cudgel with a strap, lightweight yet surprisingly effective. Irish in origin.", MT_WOOD, 2, OC_WEAPON, SZ_MEDIUM);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
@ -9698,16 +9718,7 @@ void initobjects(void) {
addflag(lastot->flags, F_ACCURACY, 90, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_CLUBS, NA, NA, NULL);
addflag(lastot->flags, F_CANBLOCK, DT_SLASH, NA, NA, NULL);
addot(OT_STICK, "stick", "A sturdy wooden stick. It's brown and sticky.", MT_WOOD, 0.5, OC_WEAPON, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_CAVE, 100, NA, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, NA, NULL);
addflag(lastot->flags, F_DAM, DT_BASH, 2, NA, NULL);
addflag(lastot->flags, F_ACCURACY, 80, NA, NA, NULL);
addflag(lastot->flags, F_NOBLESS, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_USESSKILL, SK_CLUBS, NA, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addflag(lastot->flags, F_RODSHAPED, B_TRUE, NA, NA, NULL);
// hammer
addot(OT_WARHAMMER, "warhammer", "A double-headed metal wedge mounted upon a long pole.", MT_METAL, 12, OC_WEAPON, SZ_MEDIUM);
@ -10978,7 +10989,7 @@ void initrace(void) {
addflag(lastrace->flags, F_ALIGNMENT, AL_NONE, NA, NA, NULL);
addflag(lastrace->flags, F_HOSTILE, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_SIZE, SZ_MEDIUM, NA, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_ALL, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_ALL, NA, RR_VERYRARE, NULL);
addflag(lastrace->flags, F_RARITY, H_MASTERVAULTS, NA, RR_UNCOMMON, NULL);
addflag(lastrace->flags, F_NOSTAIRS, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_HITDICE, 0, 1, NA, NULL);
@ -12121,7 +12132,7 @@ void initrace(void) {
addflag(lastrace->flags, F_RARITY, H_DUNGEON, NA, RR_VERYRARE, NULL);
addflag(lastrace->flags, F_RARITY, H_FOREST, NA, RR_COMMON, NULL);
addflag(lastrace->flags, F_HITDICE, 2, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 3, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 4, NA, NA, NULL);
addflag(lastrace->flags, F_MOVESPEED, SP_NORMAL, NA, NA, NULL);
addflag(lastrace->flags, F_ACTIONSPEED, SP_NORMAL, NA, NA, "");
addflag(lastrace->flags, F_STARTATT, A_STR, AT_LTAVERAGE, NA, NULL);
@ -12628,9 +12639,9 @@ void initrace(void) {
addflag(lastrace->flags, F_RARITY, H_FOREST, 87, RR_COMMON, NULL);
addflag(lastrace->flags, F_RARITY, H_SWAMP, 87, RR_COMMON, NULL);
addflag(lastrace->flags, F_SIZE, SZ_MEDIUM, NA, NA, NULL);
addflag(lastrace->flags, F_HITDICE, 2, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 3, NA, NA, NULL);
addflag(lastrace->flags, F_EVASION, 10, NA, NA, NULL);
addflag(lastrace->flags, F_HITDICE, 1, 3, NA, NULL);
addflag(lastrace->flags, F_TR, 2, NA, NA, NULL);
addflag(lastrace->flags, F_EVASION, 5, NA, NA, NULL);
addflag(lastrace->flags, F_MOVESPEED, SP_NORMAL, NA, NA, NULL);
addflag(lastrace->flags, F_ACTIONSPEED, SP_NORMAL, NA, NA, "");
addflag(lastrace->flags, F_HASATTACK, OT_CLAWS, 4, NA, NULL);
@ -12641,9 +12652,9 @@ void initrace(void) {
addflag(lastrace->flags, F_STARTATT, A_WIS, AT_LOW, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CHA, AT_LOW, NA, NULL);
addflag(lastrace->flags, F_STARTOB, 50, NA, NA, "1-25 gold dollars");
addflag(lastrace->flags, F_STARTOB, 50, NA, NA, "sling");
addflag(lastrace->flags, F_STARTOB, 25, NA, NA, "sling");
f = addflag(lastrace->flags, F_STARTOBWEPSK, 100, SK_SHORTBLADES, NA, "common");
addcondition(f, FC_NOCONDITION, 90);
addcondition(f, FC_NOCONDITION, 50);
addaltval(f, F_STARTOBWEPSK, 100, SK_WHIPS, NA, "common");
addflag(lastrace->flags, F_STARTOBCLASS, 40, OC_POTION, NA, NULL);
addflag(lastrace->flags, F_WANTSBETTERWEP, B_TRUE, B_COVETS, NA, NULL);
@ -12755,14 +12766,14 @@ void initrace(void) {
addflag(lastrace->flags, F_ALIGNMENT, AL_EVIL, NA, NA, NULL);
addflag(lastrace->flags, F_CORPSETYPE, NA, NA, NA, "goblin corpse");
addflag(lastrace->flags, F_HOSTILE, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, 75, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_CAVE, NA, RR_COMMON, NULL);
addflag(lastrace->flags, F_RARITY, H_FOREST, 75, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_SWAMP, 75, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, 75, RR_VERYRARE, NULL);
addflag(lastrace->flags, F_RARITY, H_CAVE, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_FOREST, 75, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_SWAMP, 75, RR_VERYRARE, NULL);
addflag(lastrace->flags, F_RARITY, H_MASTERVAULTS, NA, RR_COMMON, NULL);
addflag(lastrace->flags, F_SIZE, SZ_MEDIUM, NA, NA, NULL);
addflag(lastrace->flags, F_HITDICE, 4, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 5, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 4, NA, NA, NULL);
addflag(lastrace->flags, F_EVASION, 5, NA, NA, NULL);
addflag(lastrace->flags, F_MOVESPEED, SP_NORMAL, NA, NA, NULL);
addflag(lastrace->flags, F_ACTIONSPEED, SP_NORMAL, NA, NA, "");
@ -18224,6 +18235,54 @@ void initrace(void) {
addflag(lastrace->flags, F_MORALE, 0, NA, NA, NULL);
addflag(lastrace->flags, F_AWARENESS, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_EATMUTATE, F_PRODUCESLIGHT, 3, NA, "100");
addrace(R_LIZARDBAT, "battery lizard", 2, 'x', C_WHITE, MT_FLESH, RC_ANIMAL, "A reptilian beast whose lizardlike form has developed a natural electrical charge.");
setbodytype(lastrace, BT_QUADRAPED);
addflag(lastrace->flags, F_HOSTILE, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_SIZE, SZ_SMALL, NA, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_SWAMP, NA, RR_UNCOMMON, NULL);
addflag(lastrace->flags, F_HITDICE, 3, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 3, NA, NA, NULL);
addflag(lastrace->flags, F_MOVESPEED, SP_NORMAL, NA, NA, NULL);
addflag(lastrace->flags, F_ACTIONSPEED, SP_NORMAL, NA, NA, "");
addflag(lastrace->flags, F_DTIMMUNE, DT_ELECTRIC, NA, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_STR, AT_LTAVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_IQ, IQ_ANIMAL, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_AGI, AT_AVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CON, AT_RANDOM, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_WIS, AT_LOW, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CHA, AT_AVERAGE, NA, NULL);
addflag(lastrace->flags, F_COLDBLOOD, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_DTVULN, DT_COLD, B_TRUE, NA, NULL);
addflag(lastrace->flags, F_HASATTACK, OT_ZAPPER, 6, NA, NULL);
addflag(lastrace->flags, F_NOISETEXT, N_GETANGRY, 4, NA, "sparks^arcing electricity");
addflag(lastrace->flags, F_DAMAGEGROUNDOBS, 4, DT_ELECTRIC, NA, NULL);
addflag(lastrace->flags, F_CANEATRAW, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_EATMUTATE, F_DTRESIST, DT_ELECTRIC, NA, "10");
addrace(R_LIZARDBATB, "baby battery lizard", 2, 'x', C_WHITE, MT_FLESH, RC_ANIMAL, "A baby reptilian beast whose lizardlike form has developed a natural electrical charge.");
setbodytype(lastrace, BT_QUADRAPED);
addflag(lastrace->flags, F_HOSTILE, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_SIZE, SZ_SMALL, NA, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_SWAMP, NA, RR_UNCOMMON, NULL);
addflag(lastrace->flags, F_HITDICE, 1, NA, NA, NULL);
addflag(lastrace->flags, F_TR, 1, NA, NA, NULL);
addflag(lastrace->flags, F_MOVESPEED, SP_SLOW, NA, NA, NULL);
addflag(lastrace->flags, F_ACTIONSPEED, SP_NORMAL, NA, NA, "");
addflag(lastrace->flags, F_DTIMMUNE, DT_ELECTRIC, NA, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_STR, AT_LTAVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_IQ, IQ_ANIMAL, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_AGI, AT_AVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CON, AT_RANDOM, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_WIS, AT_LOW, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CHA, AT_AVERAGE, NA, NULL);
addflag(lastrace->flags, F_COLDBLOOD, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_DTVULN, DT_COLD, B_TRUE, NA, NULL);
addflag(lastrace->flags, F_HASATTACK, OT_ZAPPER, 1, NA, NULL);
addflag(lastrace->flags, F_NOISETEXT, N_GETANGRY, 4, NA, "sparks^arcing electricity");
addflag(lastrace->flags, F_DAMAGEGROUNDOBS, 2, DT_ELECTRIC, NA, NULL);
addflag(lastrace->flags, F_CANEATRAW, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_EATMUTATE, F_DTRESIST, DT_ELECTRIC, NA, "5");
addrace(R_STINKBUG, "stinkbeetle", 1, 'x', C_MAGENTA, MT_FLESH, RC_INSECT, "A dog-sized beetle with tough scales. Emits a foul odour upon death.");
setbodytype(lastrace, BT_QUADRAPED);
addflag(lastrace->flags, F_INSECT, B_TRUE, NA, NA, NULL);
@ -19245,8 +19304,8 @@ void initrace(void) {
addflag(lastrace->flags, F_STARTATT, A_WIS, AT_AVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CON, AT_GTAVERAGE, NA, NULL);
addflag(lastrace->flags, F_STARTATT, A_CHA, AT_LOW, NA, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, NA, RR_UNCOMMON, NULL);
addflag(lastrace->flags, F_RARITY, H_FOREST, NA, RR_UNCOMMON, NULL);
addflag(lastrace->flags, F_RARITY, H_DUNGEON, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_FOREST, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_RARITY, H_ICECAVE, NA, RR_RARE, NULL);
addflag(lastrace->flags, F_HOSTILE, B_TRUE, NA, NA, NULL);
addflag(lastrace->flags, F_HUMANOID, B_TRUE, NA, NA, NULL);

43
defs.h
View File

@ -10,6 +10,8 @@
#define OBS1(o) (o->amt == 1) ? "s" : ""
#define OBNOS1(o) (o->amt == 1) ? "" : "s"
#define ISINRANGE(a,min,max) ((a >= min) && (a <= max))
// #define PRACTICETIME 15 // #attempts it takes to learn new weapon skill
// Probabilities
@ -99,6 +101,7 @@
#define B_FALSE (0)
#define B_TRUE (-1)
#define B_MAYBE (-2)
#define B_ONEOF (-3)
#define B_ADD 1
#define B_REMOVE -1
@ -300,6 +303,7 @@
#define MAX_TEMPERATURE 45
// askobject options
/*
#define AO_NONE 0
#define AO_INCLUDENOTHING 1
#define AO_ONLYEQUIPPED 2
@ -316,6 +320,7 @@
#define AO_NOTKNOWN 4096
#define AO_DAMAGED 8192
#define AO_DRINKABLE 16384
*/
// askcoords target types
#define TT_SPECIFIED -1
@ -441,7 +446,6 @@ enum CELLCONDITION {
CC_OKFORPORTAL, // no arg
CC_OKFORSTAIRS, // no arg
CC_HASLF, // no arg
CC_HASMATERIAL, // arg is material id
CC_HASOBTYPE, // arg is ob id
CC_HASROOMID, // arg is room id
CC_IMPASSABLE, // no arg
@ -450,9 +454,32 @@ enum CELLCONDITION {
CC_WALKABLE, // no arg
CC_WALKABLEFOR, // arg is lfid
// RACES
CC_HASFLAG, // arg is flagid
CC_HASCORPSE, // no arg
CC_HASSIZE, // arg is enum lfsize
// SHARED
CC_HASFLAG, // arg is flagid, races+objects
CC_HASMATERIAL, // arg is material id, cells+objects
CC_HASSIZE, // arg is enum lfsize, races+objects
// OBJECTS/OBTYPES
CC_ARMOUR,
CC_DAMAGED,
CC_DAMTYPE,
CC_DRINKABLE,
CC_EQUIPPED,
CC_EDIBLE,
CC_KNOWN,
CC_IDENTIFIED,
CC_MINAR, // arg
CC_MINDR, // arg
CC_MAXDR, // arg
CC_MAXSIZE, // arg is max size
CC_OBCLASS,
CC_OPERABLE,
CC_POURABLE,
CC_READABLE,
CC_SPECIFIED, // hard - does retlist contain this ??
CC_WEARABLE,
CC_WEAPON,
CC_WEPSK
};
enum GODBONUS {
@ -1433,6 +1460,8 @@ enum RACE {
R_GLOWBUG,
R_GIANTFLY,
R_GIANTBLOWFLY,
R_LIZARDBATB,
R_LIZARDBAT,
R_STINKBUG,
R_STIRGE,
// demons
@ -1704,6 +1733,7 @@ enum OBTYPE {
OT_MOSSMOON,
OT_MOSSSUN,
OT_SHRUB,
OT_STICK,
OT_STUMP,
OT_TREE,
// food
@ -2185,6 +2215,7 @@ enum OBTYPE {
OT_SACKHUGE,
OT_SAFEBOX,
OT_SHOVEL,
OT_SPANNER,
OT_TORCH,
OT_TOWEL,
OT_UNICORNHORN,
@ -2254,6 +2285,8 @@ enum OBTYPE {
OT_CHESTORNATE,
OT_EMPTYFLASK,
OT_EMPTYVIAL,
OT_FORK,
OT_STEAKKNIFE,
OT_GLASSJAR,
OT_CALTROP,
OT_BROKENGLASS,
@ -2493,7 +2526,6 @@ enum OBTYPE {
OT_BASELARD,
OT_COMBATKNIFE,
OT_DAGGER,
OT_FORK,
OT_GLADIUS,
OT_KNIFE,
OT_MEATCLEAVER,
@ -2501,7 +2533,6 @@ enum OBTYPE {
OT_RAPIER,
OT_SABRE,
OT_SHORTSWORD,
OT_STEAKKNIFE,
OT_SICKLE,
// long swords
OT_BASTARDSWORD,
@ -2555,8 +2586,6 @@ enum OBTYPE {
OT_MACE,
OT_MORNINGSTAR,
OT_SHILLELAGH,
OT_SPANNER,
OT_STICK,
// hammers
OT_WARHAMMER,
OT_SLEDGEHAMMER,

8
god.c
View File

@ -1493,8 +1493,12 @@ int godgiftmaybe(enum RACE rid, int fromtemple, int announce) {
// good ranged weapon
if (getskill(player, SK_RANGED)) {
char obname[BUFLEN];
if (real_getrandomob(NULL, obname, 25, NA, getlfsize(player),
SK_RANGED, RR_NONE, B_TRUE, OC_WEAPON, OC_NONE, DT_NONE, F_NONE)) {
condset_t cs;
initcondv(&cs, CC_HASSIZE, B_TRUE, getlfsize(player),
CC_WEPSK, B_TRUE, SK_RANGED,
CC_OBCLASS, B_TRUE, OC_WEAPON,
CC_NONE);
if (real_getrandomob(NULL, obname, 25, NA, RR_NONE, B_TRUE, &cs)) {
snprintf(obtogive, BUFLEN, "excellent %s", obname);
} else {
rollagain = B_TRUE;

132
io.c
View File

@ -1193,10 +1193,10 @@ cell_t *real_askcoords(char *prompt, char *subprompt, int targettype, lifeform_t
tempob = addob(c->obpile, obname);
}
// show objects
o = doaskobject(c->obpile, "Describe which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(c->obpile, "Describe which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, NULL, B_FALSE);
while (o) {
describeob(o);
o = doaskobject(c->obpile, "Describe which object",NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(c->obpile, "Describe which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, NULL, B_FALSE);
}
if (tempob) killob(tempob);
}
@ -3250,16 +3250,12 @@ lifeform_t *askgod(char *prompttext, int onlyprayed, int forpray) {
return lf;
}
object_t *askobject(obpile_t *op, char *prompt, char *noobtext, int *count, char action, long opts) {
object_t *askobject(obpile_t *op, char *prompt, char *noobtext, int *count, char action, condset_t *cs, int includenothing) {
int showlong = B_TRUE;
if (op->owner && isplayer(op->owner)) {
showlong = B_FALSE;
}
return doaskobject(op, prompt, noobtext, count, showlong, B_TRUE, B_FALSE, action, NULL, SA_NONE, MT_NOTHING, opts, F_NONE);
}
object_t *askobjectwithflag(obpile_t *op, char *prompt, char *noobtext, int *count, char action, long opts, enum FLAG withflag) {
return doaskobject(op, prompt, noobtext, count, B_TRUE, B_TRUE, B_FALSE, action, NULL, SA_NONE, MT_NOTHING, opts, withflag, F_NONE);
return doaskobject(op, prompt, noobtext, count, showlong, B_TRUE, B_FALSE, action, NULL, SA_NONE, cs, includenothing);
}
int contains(enum OBCLASS *array, int nargs, enum OBCLASS want) {
@ -3391,13 +3387,7 @@ void listobs(WINDOW *win, object_t **mylist, int *sellist, int *selcount, int fi
}
// varargs are a list of flags which we want:
// F_xxx
// F_xxx
// F_NONE
//
// If you pass "sellshop", DONT also pass F_xxx.
object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, int showlong, int forpickup, int showpoints, char action, object_t *sellshop, enum SHOPACTION sellaction, int wantmaterial, long opts, ...) {
object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, int showlong, int forpickup, int showpoints, char action, object_t *sellshop, enum SHOPACTION sellaction, condset_t *cs, int includenothing) {
int c,i;
char defchar = '\0';
static char defaults[52] = {'\0'};
@ -3415,23 +3405,9 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
char nextlet = 'a';
int useobletters;
//flag_t *f;
enum FLAG wantflag[MAXCANDIDATES];
va_list flags;
int nwantflags;
flag_t *sellflag[MAXCANDIDATES];
int nsellflags = 0;
// construct list of valid obclasses
va_start(flags, opts);
nwantflags = 0;
wantflag[nwantflags] = va_arg(flags, enum FLAG);
while (wantflag[nwantflags] != F_NONE) {
nwantflags++;
wantflag[nwantflags] = va_arg(flags, enum FLAG);
}
va_end(flags);
//dblog("nwantflags is %d",nwantflags);
if (sellshop) {
getflags(sellshop->flags, sellflag, &nsellflags, F_SHOPACCEPTSFLAG, F_NONE);
}
@ -3489,19 +3465,11 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
for (o = op->first ; o ; o = o->next) {
if (o->type->obclass->id == sortorder[c]) {
int ok;
int n;
// can we include this object?
ok = B_TRUE;
if (!canseeob(player, o)) ok = B_FALSE;
if (ok) {
if ((wantmaterial != MT_NOTHING) && (o->material->id != wantmaterial)) {
ok = B_FALSE;
}
}
// shop flags?
if (ok && nsellflags) {
int n;
@ -3515,18 +3483,8 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
}
}
if (ok) {
// check for wanted flags
for (n = 0; n < nwantflags; n++) {
if (!hasflag(o->flags, wantflag[n])) {
ok = B_FALSE;
break;
}
}
}
if (ok) {
ok = obmatchescondition(o, opts);
if (ok && cs) {
ok = obmeets(o, cs);
}
if (ok) {
@ -3582,7 +3540,7 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
}
snprintf(fullprompt, BUFLEN, "%s (%sESC=quit%s)%s: ",prompt,
(opts & AO_INCLUDENOTHING) ? "- for nothing, " : "",
includenothing ? "- for nothing, " : "",
showlong ? "" : ",?=list",
fullnumstring);
@ -3686,7 +3644,7 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
return o;
}
} else if ((ch == '-') && (opts & AO_INCLUDENOTHING)) { // select nothing
} else if ((ch == '-') && includenothing) { // select nothing
reason = E_SELNOTHING;
// display game windows again
restoregamewindows();
@ -3720,7 +3678,7 @@ object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, in
return NULL;
}
int askobjectmulti(obpile_t *op, char *prompt, long opts) {
int askobjectmulti(obpile_t *op, char *prompt, condset_t *cs, int includenothing) {
int c,i;
object_t *mylist[MAXPILEOBS+1];
int selected[MAXPILEOBS+1];
@ -3780,7 +3738,7 @@ int askobjectmulti(obpile_t *op, char *prompt, long opts) {
if (!canseeob(player, o)) {
ok = B_FALSE;
} else {
ok = obmatchescondition(o, opts);
ok = obmeets(o, cs);
}
if (ok) {
@ -3838,11 +3796,11 @@ int askobjectmulti(obpile_t *op, char *prompt, long opts) {
snprintf(pbuf, BUFLEN,"%s (ESC to quit): ", altprompt);
} else if (strlen(numstring) > 0) {
snprintf(pbuf, BUFLEN,"%s (%s','=all, ESC to quit) [%s]: ", prompt,
(opts & AO_INCLUDENOTHING) ? "- for nothing, " : "",
includenothing ? "- for nothing, " : "",
numstring);
} else {
snprintf(pbuf, BUFLEN,"%s (%sESC to quit): ", prompt,
(opts & AO_INCLUDENOTHING) ? "- for nothing, " : "");
includenothing ? "- for nothing, " : "");
}
// show how many items we've picked, and how much they weigh
@ -3916,7 +3874,7 @@ int askobjectmulti(obpile_t *op, char *prompt, long opts) {
count = ALL;
}
}
} else if ((ch == '-') && (opts & AO_INCLUDENOTHING)) { // select nothing
} else if ((ch == '-') && includenothing) { // select nothing
reason = E_SELNOTHING;
nretobs = 0;
// display game windows again
@ -4699,7 +4657,7 @@ void docomms(lifeform_t *lf) {
if (askforob) {
// ask what to give
snprintf(buf, BUFLEN, "What will you offer to %s?",lfname);
o = askobject(player->pack, buf, NULL, &count, '\0', AO_NONE);
o = askobject(player->pack, buf, NULL, &count, '\0', NULL, B_FALSE);
}
if (o) {
if (o->type->id == OT_GOLD) {
@ -5330,9 +5288,9 @@ void dodrop(obpile_t *op, int wantmulti, obpile_t *dst) {
}
if (wantmulti) {
askobjectmulti(op, buf, AO_NONE);
askobjectmulti(op, buf, NULL, B_FALSE);
} else {
o = askobject(op, buf, NULL, &count, '\0', AO_NONE);
o = askobject(op, buf, NULL, &count, '\0', NULL, B_FALSE);
if (o) {
retobs[0] = o;
retobscount[0] = count;
@ -5464,12 +5422,15 @@ void doeat(obpile_t *op) {
}
if (!eatob) {
condset_t cs;
if (!hasedibleob(player->pack)) {
msg("You have nothing to eat!");
return;
}
eatob = askobject(op, "Eat what", "You have nothing to eat!", NULL, 'e', AO_EDIBLE);
initcondv(&cs, CC_EDIBLE, B_TRUE, NA,
CC_NONE);
eatob = askobject(op, "Eat what", "You have nothing to eat!", NULL, 'e', &cs, B_FALSE);
}
if (eatob) {
if (isunknownbadobject(eatob) && skillcheck(player, A_WIS, 120, 0)) {
@ -5485,7 +5446,10 @@ void doeat(obpile_t *op) {
int dowear(obpile_t *op) {
object_t *o;
int rv;
o = askobject(op, "Wear what", "You have nothing to wear!", NULL, '\0', AO_WEARABLE);
condset_t cs;
initcondv(&cs, CC_WEARABLE, B_TRUE, NA,
CC_NONE);
o = askobject(op, "Wear what", "You have nothing to wear!", NULL, '\0', &cs, B_FALSE);
if (o) {
if (isunknownbadobject(o) && skillcheck(player, A_WIS, 120, 0)) {
if (!confirm_badfeeling(o)) {
@ -5507,7 +5471,11 @@ int doweild(obpile_t *op) {
object_t *o;
int count = ALL;
int rv;
o = askobject(op, "Weild what", "You have nothing to weild.", &count, 'w', AO_WEILDABLE | AO_INCLUDENOTHING);
condset_t cs;
// include _anything_ which could be weilded, even if not neccesarily a weapon.
initcondv(&cs, CC_HASFLAG, B_TRUE, F_DAM,
CC_NONE);
o = askobject(op, "Weild what", "You have nothing to weild.", &count, 'w', &cs, B_TRUE);
if (o) {
if (isunknownbadobject(o) && skillcheck(player, A_WIS, 120, 0)) {
if (!confirm_badfeeling(o)) {
@ -8591,6 +8559,7 @@ void domsghist(void) {
void dooperate(obpile_t *op) {
object_t *o;
condset_t cs;
// operable objects here?
for (o = player->cell->obpile->first; o ; o = o->next) {
@ -8615,7 +8584,9 @@ void dooperate(obpile_t *op) {
}
// ask which object to read
o = askobject(op, "Operate what", "You have nothing to operate.", NULL, 'o', AO_OPERABLE);
initcondv(&cs, CC_OPERABLE, B_TRUE, NA,
CC_NONE);
o = askobject(op, "Operate what", "You have nothing to operate.", NULL, 'o', &cs, B_FALSE);
if (o) {
operate(player, o, NULL);
}
@ -8745,7 +8716,7 @@ int dopickup(obpile_t *op, int forceask) {
strcpy(buf, "Pick up what");
}
// prompt which one to pick up
askobjectmulti(op, buf, AO_NONE);
askobjectmulti(op, buf, NULL, B_FALSE);
}
if (nretobs <= 0) {
@ -8808,12 +8779,13 @@ void doexplain(char *question) {
void dofinaloblist(obpile_t *op) {
object_t *o;
o = doaskobject(op, "Your final possessions were", NULL, NULL, B_TRUE, B_FALSE, B_TRUE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(op, "Your final possessions were", NULL, NULL, B_TRUE, B_FALSE, B_TRUE, '\0', NULL, SA_NONE, NULL, B_FALSE);
while (o) {
// describe it
describeob(o);
// ask for another one
o = doaskobject(op, "Your final possessions were",NULL, NULL, B_TRUE, B_FALSE, B_TRUE,'\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(op, "Your final possessions were",NULL, NULL, B_TRUE, B_FALSE, B_TRUE,'\0', NULL, SA_NONE, NULL, B_FALSE);
}
real_clearmsg(B_TRUE);
}
@ -8971,12 +8943,13 @@ void doinventory(obpile_t *op) {
maxweight = getmaxcarryweight(player);
pct = (packweight / maxweight) * 100;
snprintf(buf, BUFLEN, "Inventory (%0.0f/%0.0f kg, %0.0f%%)", packweight, maxweight, pct);
o = doaskobject(op, buf, NULL, NULL, B_TRUE, B_TRUE, B_FALSE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(op, buf, NULL, NULL, B_TRUE, B_TRUE, B_FALSE, '\0', NULL, SA_NONE, NULL, B_FALSE);
while (o) {
// describe it
describeob(o);
// ask for another one
o = askobject(op, buf, NULL, NULL, '\0', AO_NONE);
o = askobject(op, buf, NULL, NULL, '\0', NULL, B_FALSE);
}
real_clearmsg(B_TRUE);
}
@ -9010,7 +8983,10 @@ void doquaff(obpile_t *op) {
// ask which object to quaff
if (!liquid) {
liquid = askobjectwithflag(op, "Quaff what", "You have nothing drinkable.", NULL, 'q', AO_NONE, F_DRINKABLE);
condset_t cs;
initcondv(&cs, CC_DRINKABLE, B_TRUE, NA,
CC_NONE);
liquid = askobject(op, "Quaff what", "You have nothing drinkable.", NULL, 'q', &cs, B_FALSE);
}
if (liquid) {
if (canquaff(player, liquid)) {
@ -9090,9 +9066,12 @@ void donextguntarget(void) {
void dopour(obpile_t *op) {
object_t *o;
condset_t cs;
initcondv(&cs, CC_POURABLE, B_TRUE, NA,
CC_NONE);
// ask which object to read
o = askobject(op, "Pour what", "You are not holding anything pourable.", NULL, 'P', AO_POURABLE);
o = askobject(op, "Pour what", "You are not holding anything pourable.", NULL, 'P', &cs, B_FALSE);
if (o) {
if (ispourable(o)) {
pour(player, o);
@ -9113,6 +9092,7 @@ void doquit(void) {
void doread(obpile_t *op) {
object_t *o;
condset_t cs;
if (isblind(player)) {
msg("You can't read while blind!");
@ -9121,7 +9101,9 @@ void doread(obpile_t *op) {
// ask which object to read
o = askobject(op, "Read what", "You have nothing to read.", NULL, 'r', AO_READABLE);
initcondv(&cs, CC_READABLE, B_TRUE, NA,
CC_NONE);
o = askobject(op, "Read what", "You have nothing to read.", NULL, 'r', &cs, B_FALSE);
if (o) {
if (isreadable(o)) {
readsomething(player, o);
@ -9209,9 +9191,13 @@ int dotakeoff(obpile_t *op) {
object_t *o;
flag_t *f;
int rv = B_TRUE;
condset_t cs;
// ask which object to read
o = askobject(op, "Take off what", "You are not wearing anything!", NULL, 'T', AO_EQUIPPEDNONWEAPON );
initcondv(&cs, CC_EQUIPPED, B_TRUE, NA,
CC_WEAPON, B_FALSE, NA,
CC_NONE);
o = askobject(op, "Take off what", "You are not wearing anything!", NULL, 'T', &cs, B_FALSE );
if (o) {
if (isarmour(o)) {
f = hasflag(o->flags, F_EQUIPPED);
@ -9241,7 +9227,7 @@ int dothrow(obpile_t *op, object_t *o) {
// ask which object to throw
if (!o) {
o = askobject(op, "Throw what", "You have nothing to throw!", NULL, 't', AO_NONE);
o = askobject(op, "Throw what", "You have nothing to throw!", NULL, 't', NULL, B_FALSE);
}
if (o) {
int maxdist;

7
io.h
View File

@ -22,10 +22,9 @@ void announcetime(int h, int m, int s, int showfull);
int confirm_badfeeling(object_t *o);
int confirm_injury_action(enum BODYPART bp, enum DAMTYPE dt, char *actionname);
lifeform_t *askgod(char *prompt, int onlyprayed, int forpray);
object_t *askobject(obpile_t *op, char *title, char *noobtext, int *count, char action, long opts);
object_t *askobjectwithflag(obpile_t *op, char *title, char *noobtext,int *count, char action, long opts, enum FLAG withflag);
object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, int showlong, int forpickup, int showpoints, char action, object_t *sellshop, enum SHOPACTION sellaction, int wantmaterial, long opts, ...);
int askobjectmulti(obpile_t *op, char *prompt, long opts);
object_t *askobject(obpile_t *op, char *title, char *noobtext, int *count, char action, condset_t *cs, int includenothing);
object_t *doaskobject(obpile_t *op, char *prompt, char *noobtext, int *count, int showlong, int forpickup, int showpoints, char action, object_t *sellshop, enum SHOPACTION sellaction, condset_t *cs, int includenothing);
int askobjectmulti(obpile_t *op, char *prompt, condset_t *cs, int includenothing);
char askchar(char *prompt, char *validchars, char *def, int showchars, int maycancel);
cell_t *askcoords(char *prompt, char *subprompt, int targettype, lifeform_t *srclf, int maxrange, enum LOFTYPE loftype, int wanttrail);
cell_t *real_askcoords(char *prompt, char *subprompt, int targettype, lifeform_t *srclf, int minrange, int maxrange, enum LOFTYPE loftype, int wanttrail, cell_t **spectarg, int nspectargs);

79
lf.c
View File

@ -12474,6 +12474,7 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
} else if (id == F_STARTOBRND) {
if (rnd(1,100) <= val[0]) {
int depthmod;
condset_t cs;
depthmod = val[1];
switch (depthmod) {
case NA: depthmod = 0; break;
@ -12481,7 +12482,11 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
default: break;
}
depthmod += depthmod2;
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, maxobsize, SK_NONE, RR_NONE, B_TRUE, OC_NONE, DT_NONE, F_NONE)) {
initcondv(&cs, CC_MAXSIZE, B_TRUE, maxobsize,
CC_NONE);
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, RR_NONE, B_TRUE, &cs)) {
if (isshop) apply_shopob_restrictions(buf);
o = addob(op, buf);
}
@ -12489,6 +12494,7 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
} else if (id == F_STARTOBDT) {
if (rnd(1,100) <= val[0]) {
int depthmod;
condset_t cs;
if (db) {
snprintf(buf2, BUFLEN, "calling startobdt");
}
@ -12500,8 +12506,18 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
default: break;
}
depthmod += depthmod2;
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, maxobsize, SK_NONE,
RR_NONE, B_TRUE, OC_NONE, val[1], DT_NONE, F_NONE)) {
initcondv(&cs, CC_MAXSIZE, B_TRUE, maxobsize,
CC_DAMTYPE, B_TRUE, val[1],
CC_OBCLASS, B_TRUE, OC_WEAPON,
CC_NONE);
if (lf) {
apply_wep_tr_limit(lf, &cs);
}
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, RR_NONE, B_TRUE, &cs )) {
if (db) snprintf(buf2, BUFLEN, "finished startobdt successfuly.");
if (isshop) apply_shopob_restrictions(buf);
o = addob(op, buf);
@ -12513,6 +12529,7 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
} else if (id == F_STARTOBWEPSK) {
if (rnd(1,100) <= val[0]) {
int depthmod;
condset_t cs;
if (db) {
snprintf(buf2, BUFLEN, "calling startobwepsk");
}
@ -12524,8 +12541,17 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
default: break;
}
depthmod += depthmod2;
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, maxobsize, val[1],
getrarityval(text), B_TRUE, OC_NONE, DT_NONE, F_NONE)) {
initcondv(&cs, CC_MAXSIZE, B_TRUE, maxobsize,
CC_WEPSK, B_TRUE, val[1],
CC_OBCLASS, B_TRUE, OC_WEAPON,
CC_NONE);
if (lf) {
apply_wep_tr_limit(lf, &cs);
}
if (real_getrandomob(targmap, buf, targmap->depth + depthmod, NA, getrarityval(text), B_TRUE, &cs)) {
char buf3[BUFLEN];
if (db) snprintf(buf2, BUFLEN, "finished startobwepsk successfuly.");
sprintf(buf3, "%s%s%s",text,strlen(text) ? " " : "",buf);
@ -12537,7 +12563,7 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
} else if (id == F_STARTOBCLASS) {
if (rnd(1,100) <= val[0]) {
int depthmod;
enum FLAG wantflagid = F_NONE;
condset_t cs;
if (db) {
snprintf(buf2, BUFLEN, "calling startobclass");
}
@ -12550,15 +12576,21 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
}
depthmod += depthmod2;
initcondv(&cs, CC_MAXSIZE, B_TRUE, maxobsize,
CC_OBCLASS, B_TRUE, val[1],
CC_NONE);
if (lf && (val[1] == OC_WEAPON)) {
apply_wep_tr_limit(lf, &cs);
}
// special case
if (targob && (targob->type->id == OT_FRIDGE)) {
wantflagid = F_ISMEAT;
addcond(&cs, CC_HASFLAG, B_TRUE, F_ISMEAT);
}
//obdb = B_TRUE;
if (real_getrandomob(targmap, buf, getmapdifficulty(targmap) + depthmod,
NA, maxobsize, SK_NONE, RR_NONE, B_TRUE,
val[1], OC_NONE, DT_NONE, wantflagid, F_NONE)) {
if (real_getrandomob(targmap, buf, getmapdifficulty(targmap) + depthmod, NA, RR_NONE, B_TRUE, &cs)) {
if (db) snprintf(buf2, BUFLEN, "finished startobclass, success.");
if (isshop) apply_shopob_restrictions(buf);
o = addob(op, buf);
@ -12620,7 +12652,7 @@ void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp) {
// added an object?
if (o) {
if (lf) {
// undead can't have cursed objecst
// undead can't have blessed objecst
if (isundead(lf)) {
if (o->blessed == B_BLESSED) setblessed(o, B_CURSED);
}
@ -13534,13 +13566,16 @@ int lockpick(lifeform_t *lf, cell_t *targcell, object_t *target, object_t *devic
// what will we use?
if (!device) {
condset_t cs;
if (!hasobwithflag(lf->pack, F_PICKLOCKS)) {
msg("You have nothing to use for lockpicking!");
return B_TRUE;
}
// ask which object to use
device = askobjectwithflag(lf->pack, "Lockpick using what", NULL, NULL, 'p', AO_NONE, F_PICKLOCKS);
initcondv(&cs, CC_HASFLAG, B_TRUE, F_PICKLOCKS,
CC_NONE);
device = askobject(lf->pack, "Lockpick using what", NULL, NULL, 'p', &cs, B_FALSE);
if (!device) {
msg("Cancelled.");
return B_TRUE;
@ -15629,6 +15664,26 @@ void applywalkdam(lifeform_t *lf, int dam, enum DAMTYPE damtype, object_t *o, in
}
}
void apply_wep_tr_limit(lifeform_t *lf, condset_t *cs) {
if (!isplayer(lf)) {
int tr,maxdr = NA;
// generate a set of conditions for this lf's weapon.
// this is basically to prevent lowlevel monsters from
// starting with super strong weapon!
tr = gettr(lf);
if (ISINRANGE(tr,0,4)) {
getgoodnessdr(G_AVERAGE, NULL, &maxdr);
} else if (ISINRANGE(tr,5,7)) {
getgoodnessdr(G_GOOD, NULL, &maxdr);
} else if (ISINRANGE(tr,8,10)) {
getgoodnessdr(G_EXCELLENT, NULL, &maxdr);
}
if (maxdr != NA) {
addcond(cs, CC_MAXDR, B_TRUE, maxdr);
}
}
}
int areallies(lifeform_t *lf1, lifeform_t *lf2) {
int master1,master2;
master1 = getmasterid(lf1);

1
lf.h
View File

@ -19,6 +19,7 @@ void age(lifeform_t *lf, int pct);
void adjustdamforblessings(lifeform_t *attacker, int *dam, lifeform_t *victim, int blessed);
void applylfdammod(int *dam, lifeform_t *lf, object_t *wep);
void applywalkdam(lifeform_t *lf, int dam, enum DAMTYPE damtype, object_t *o, int bodypart);
void apply_wep_tr_limit(lifeform_t *lf, condset_t *cs);
int areallies(lifeform_t *lf1, lifeform_t *lf2);
int areenemies(lifeform_t *lf1, lifeform_t *lf2);
int armourfits(lifeform_t *lf, object_t *o, enum ERROR *reason);

5
map.c
View File

@ -601,13 +601,16 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int randomjobok
object_t *addrandomob(cell_t *c) {
char buf[BUFLEN];
int db = B_FALSE;
condset_t cs;
object_t *o = NULL;
if (c->type->solid) {
return NULL;
}
if (real_getrandomob(c->map, buf, NA, c->habitat->id, SZ_MAX, SK_NONE, RR_NONE, B_FALSE, OC_NONE, DT_NONE, F_NONE)) {
initcond(&cs);
if (real_getrandomob(c->map, buf, NA, c->habitat->id, RR_NONE, B_FALSE, &cs)) {
if (db) dblog("adding rand obj %s to cell %d,%d",buf,c->x,c->y);
o = addob(c->obpile, buf);
}

2
move.c
View File

@ -1904,7 +1904,7 @@ int moveto(lifeform_t *lf, cell_t *newcell, int onpurpose, int dontclearmsg) {
// just clear the message buffer
if (!didmsg) clearmsg();
} else { // tell player what is here
if (onpurpose) {
if (onpurpose && !lfhasflag(player, F_RAGE)) {
dolook(newcell, B_FALSE);
}
}

562
objects.c
View File

@ -504,7 +504,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
enum OBTYPE wantfountaintype = OT_NONE;
enum LFSIZE wantarmsize = SZ_ANY;
enum MATERIAL wantdiffmat = MT_NOTHING;
int minar = 0; // minimum AR for armour
int minar = NA; // minimum AR for armour
int mindr = NA,maxdr = NA; // minimum DR for weapons
map_t *targetmap = NULL; // for portals
cell_t *targetcell = NULL; // for portals
@ -892,14 +892,14 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
wantgoodness = G_AVERAGE;
p += strlen("average ");
donesomething = B_TRUE;
mindr = 3; maxdr = 5;
getgoodnessdr(wantgoodness, &mindr, &maxdr);
} else if (strstarts(p, "good ")) {
wantgoodness = G_GOOD;
if (onein(4)) wantblessed = B_BLESSED;
p += strlen("good ");
donesomething = B_TRUE;
limit(&minar, 1, NA);
mindr = 6; maxdr = 8;
getgoodnessdr(wantgoodness, &mindr, &maxdr);
} else if (strstarts(p, "great ")) {
wantgoodness = G_GREAT;
if (onein(3)) wantblessed = B_BLESSED;
@ -907,7 +907,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
p += strlen("great ");
limit(&minar, 2, NA);
donesomething = B_TRUE;
mindr = 9; maxdr = 11;
getgoodnessdr(wantgoodness, &mindr, &maxdr);
} else if (strstarts(p, "excellent ")) {
wantgoodness = G_EXCELLENT;
if (onein(2)) wantblessed = B_BLESSED;
@ -915,7 +915,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
p += strlen("excellent ");
limit(&minar, 3, NA);
donesomething = B_TRUE;
mindr = 12; maxdr = NA;
getgoodnessdr(wantgoodness, &mindr, &maxdr);
// object names
// brands
} else if (strstarts(p, "branded ")) {
@ -1111,12 +1111,15 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
if (matched) {
int minrarity,maxrarity;
enum FLAG musthaveflag = F_NONE;
condset_t cs;
initcond(&cs);
// want a specific rarity?
rrtorarity(wantrarity, &minrarity, &maxrarity);
if (strstr(p, "firearm")) {
musthaveflag = F_FIREARM;
addcond(&cs, CC_HASFLAG, B_TRUE, F_FIREARM);
}
// want actual armour as opposed to clothing?
@ -1124,7 +1127,19 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
limit(&minar, 1, NA);
}
ot = getrandomobofclass(oc->id, minrarity, maxrarity, matchlfskills, minar, mindr, maxdr, musthaveflag);
if ((minar != NA) && (oc->id == OC_ARMOUR)) {
addcond(&cs, CC_MINAR, B_TRUE, minar);
}
if (oc->id == OC_WEAPON) {
if (mindr != NA) {
addcond(&cs, CC_MINDR, B_TRUE, mindr);
}
if (maxdr != NA) {
addcond(&cs, CC_MAXDR, B_TRUE, maxdr);
}
}
ot = getrandomobofclass(oc->id, minrarity, maxrarity, matchlfskills, &cs);
if (ot) {
found = B_TRUE;
break;
@ -1137,10 +1152,13 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
if (!found) {
if (strstarts(p, "random gem")) {
int minrarity,maxrarity;
condset_t cs;
// want a specific rarity?
rrtorarity(wantrarity, &minrarity, &maxrarity);
ot = getrandomobofclass(OC_ROCK, minrarity, maxrarity, NULL, B_FALSE, NA, NA, F_GEM);
initcondv(&cs, CC_HASFLAG, B_TRUE, F_GEM,
CC_NONE);
ot = getrandomobofclass(OC_ROCK, minrarity, maxrarity, NULL, &cs);
if (ot) {
found = B_TRUE;
}
@ -1641,8 +1659,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int dolinks, enum
int min,max;
getrarityrange(where->where->map->depth, &min, &max, RARITYVARIANCEOB, B_FALSE);
// random potion type
ot = getrandomobofclass(OC_POTION, min, max, NULL, B_FALSE, NA, NA, F_NONE);
ot = getrandomobofclass(OC_POTION, min, max, NULL, NULL);
if (ot) {
f->val[0] = ot->id;
}
@ -4114,6 +4131,31 @@ void fragments(cell_t *centre, char *what, int speed, int howfar) {
}
}
void getgoodnessdr(enum GOODNESS gd, int *mindr, int *maxdr) {
// default
if (mindr) *mindr = NA;
if (maxdr) *maxdr = NA;
switch (gd) {
case G_AVERAGE:
if (mindr) *mindr = 3;
if (maxdr) *maxdr = 5;
break;
case G_GOOD:
if (mindr) *mindr = 6;
if (maxdr) *maxdr = 8;
break;
case G_GREAT:
if (mindr) *mindr = 9;
if (maxdr) *maxdr = 11;
break;
case G_EXCELLENT:
if (mindr) *mindr = 12;
if (maxdr) *maxdr = NA;
break;
default: break;
}
}
int gethardness(enum MATERIAL matid) {
material_t *m;
m = findmaterial(matid);
@ -4939,7 +4981,7 @@ int getrandomgrimoirelev(void) {
return wantlev;
}
objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity, lifeform_t *forlf, int minar, int mindr, int maxdr, enum FLAG musthaveflag) {
objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity, lifeform_t *forlf, condset_t *cs) {
objecttype_t *ot;
int totcount = 0, count = 0;
flag_t *f;
@ -4957,9 +4999,8 @@ objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity
if ((ot->obclass->id == ocid) && !hasflag(ot->flags, F_UNIQUE)) {
int rarityok = B_FALSE;
int skillok = B_FALSE;
int armourok = B_FALSE;
int wepok = B_FALSE;
int flagok = B_FALSE;
int condok = B_FALSE;
// does rarity match?
f = hasflag(ot->flags, F_RARITY);
if (f) {
@ -4980,6 +5021,14 @@ objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity
}
} else skillok = B_TRUE;
if (cs) {
if (otmeets(ot, cs)) {
condok = B_TRUE;
}
} else condok = B_TRUE;
/*
// minar only applies if we're asking for armour
if (minar && (ocid == OC_ARMOUR)) {
flag_t *f;
@ -5012,9 +5061,10 @@ objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity
flagok = B_TRUE;
}
} else flagok = B_TRUE;
*/
if (skillok && rarityok && armourok && wepok && flagok) {
if (skillok && rarityok && condok) {
poss[nposs++] = ot;
count++;
}
@ -6676,20 +6726,11 @@ objecttype_t *getoppositestairs(objecttype_t *ot) {
return findot(f->val[0]);
}
// varargs are:
// OC_CLASS1, OC_CLAS2, OC_NONE, ..., DT_DAMTYPE1, DT_DAMTYPE2, .., DT_NONE, F_WANTFLAG1, F_WANTFLAG2, ..., F_NONE
//
// if no objectclass given then it will be picked randomly, or (if wepsk isn't sk_none) set to oc_weapon.
objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum LFSIZE maxsize, enum SKILL wepsk, enum RARITY forcerr, int forpickup, ... ) {
va_list args;
//objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum LFSIZE maxsize, enum SKILL wepsk, enum RARITY forcerr, int forpickup, ... ) {
objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum RARITY forcerr, int forpickup, condset_t *cs) {
objecttype_t *ot;
objecttype_t *poss[MAXRANDOMOBCANDIDATES];
enum OBCLASS wantclass[MAXCANDIDATES];
int nwantclass = 0;
enum DAMTYPE wantdt[MAXCANDIDATES];
int nwantdt = 0;
enum FLAG wantflag[MAXCANDIDATES];
int nwantflag = 0;
int nposs = 0;
int selidx;
int amt;
@ -6710,34 +6751,11 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
char habname[BUFLEN];
int rrmoddir = -1;
int brandchance;
skill_t *wantsk = NULL;
enum OBTYPE wantcl = OC_NONE;
int multiwantcl = B_FALSE;
if (!db) db = obdb;
va_start(args, forpickup);
wantclass[nwantclass] = va_arg(args, enum OBCLASS);
while (wantclass[nwantclass] != OC_NONE) {
nwantclass++;
wantclass[nwantclass] = va_arg(args, enum OBCLASS);
}
wantdt[nwantdt] = va_arg(args, enum DAMTYPE);
while (wantdt[nwantdt] != DT_NONE) {
nwantdt++;
wantdt[nwantdt] = va_arg(args, enum DAMTYPE);
}
wantflag[nwantflag] = va_arg(args, enum FLAG);
while (wantflag[nwantflag] != F_NONE) {
nwantflag++;
wantflag[nwantflag] = va_arg(args, enum FLAG);
}
va_end(args);
if (wepsk) {
wantsk = findskill(wepsk);
}
if (forcehabitat != NA) {
hab = findhabitat(forcehabitat);
} else if (map) {
@ -6770,6 +6788,19 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
origwantrr = wantrr;
// no obclass given? pick one randomly.
wantcl = OC_NONE;
multiwantcl = B_FALSE;
for (i = 0; i < cs->nconds; i++) {
if (cs->cond[i] == CC_OBCLASS) {
if (wantcl == OC_NONE) wantcl = cs->arg[i];
else multiwantcl = B_TRUE;
}
}
if (wantcl == OC_NONE) {
addcond(cs, CC_OBCLASS, B_TRUE, getrandomobclass(hab->id));
}
/*
if (!nwantclass) {
if (wantsk || nwantdt) {
wantclass[0] = OC_WEAPON;
@ -6783,8 +6814,9 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
//}
}
}
*/
if ((nwantclass == 1) && (wantclass[0] == OC_BUILDING)) {
if (!multiwantcl && (wantcl == OC_BUILDING)) {
int minused = 9999;
objecttype_t *selot = NULL;
// find least used building
@ -6814,34 +6846,6 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
if (db || partdb) dblog("adding random object with rarity value between %d - %d and rr <= %d(%s), for habitat %s",
raritymin,raritymax,wantrr, getrarityname(wantrr), habname);
if (db || partdb) {
char dbuf[BUFLEN];
if (wantsk) {
sprintf(dbuf, " must have wepskill: %s", wantsk->name);
dblog("%s", dbuf);
}
if (nwantclass) {
objectclass_t *oc = NULL;
sprintf(dbuf, " must have obclass: ");
for (i = 0; i < nwantclass; i++) {
oc = findoc(wantclass[i]);
strcat(dbuf, oc->name);
if (i != nwantclass - 1) strcat(dbuf, ",");
}
dblog("%s", dbuf);
}
if (nwantdt) {
sprintf(dbuf, " must have damtype: ");
for (i = 0; i < nwantdt; i++) {
char dname[BUFLEN];
strcpy(dname, getdamname(wantdt[i]));
if (strstr(dname, "unknown")) {
assert("unknown wantdt in real_getrandomob()" == 0);
}
strcat(dbuf, dname);
if (i != nwantdt - 1) strcat(dbuf, ",");
}
dblog("%s", dbuf);
}
if (forpickup) {
dblog(" must be holdable");
}
@ -6893,57 +6897,12 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
}
if (rarok) {
int found;
if (db) dblog(" %s passes rarity check.", ot->name);
// matches obclass?
if (nwantclass) {
found = B_FALSE;
for (i = 0; i < nwantclass; i++) {
if (ot->obclass->id == wantclass[i]) {
found = B_TRUE;
}
}
if (!found) {
condok = B_FALSE;
if (db) dblog(" %s fails obclass check.", ot->name);
}
}
// matches damtype?
if (nwantdt) {
found = B_FALSE;
for (i = 0; i < nwantdt; i++) {
if (hasflagval(ot->flags, F_DAM, wantdt[i], NA, NA, NULL)) {
found = B_TRUE;
break;
}
}
if (!found) {
condok = B_FALSE;
if (db) dblog(" %s fails damtype check.", ot->name);
}
}
// matches wanted flags?
if (nwantflag) {
found = B_TRUE;
for (i = 0; i < nwantflag; i++) {
if (!hasflag(ot->flags, wantflag[i])) {
found = B_FALSE;
break;
}
}
if (!found) {
// matches conditions?
if (!otmeets(ot, cs)) {
condok = B_FALSE;
if (db) dblog(" %s fails wantflag check.", ot->name);
}
}
// matches wanted weapon skill?
if (wantsk) {
if (!hasflagval(ot->flags, F_USESSKILL, wantsk->id, NA, NA, NULL)) {
condok = B_FALSE;
if (db) dblog(" %s doesn't use correct weapon skill.", ot->name);
}
if (db) dblog(" %s doesn't match conditions.", ot->name);
}
if (forpickup) {
@ -6954,7 +6913,7 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
}
}
if (rarok && condok && (ot->size <= maxsize)) {
if (rarok && condok) {
if (db) dblog("-> possibility: %s, rarity=%d",ot->name, rarflag->val[1]);
poss[nposs] = ot;
nposs++;
@ -7110,25 +7069,17 @@ objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forceh
}
objecttype_t *getrandomob(map_t *map, char *buf) {
return real_getrandomob(map, buf, NA, NA, SZ_MAX, SK_NONE, RR_NONE, B_FALSE, OC_NONE, DT_NONE, F_NONE);
condset_t cs;
initcond(&cs);
return real_getrandomob(map, buf, NA, NA, RR_NONE, B_FALSE, &cs);
}
objecttype_t *getrandomobofsize(map_t *map, char *buf, enum LFSIZE maxsize) {
return real_getrandomob(map, buf, NA, NA, maxsize, SK_NONE,RR_NONE, B_FALSE, OC_NONE, DT_NONE, F_NONE);
}
objecttype_t *getrandomobwithdt(map_t *map, enum DAMTYPE damtype, char *buf) {
return real_getrandomob(map, buf, NA, NA, SZ_MAX, SK_NONE,RR_NONE, B_TRUE, OC_NONE, damtype, DT_NONE, F_NONE);
}
objecttype_t *getrandomobwithflag(map_t *map, enum FLAG fid, char *buf) {
return real_getrandomob(map, buf, NA, NA, SZ_MAX, SK_NONE,RR_NONE, B_TRUE, OC_NONE, DT_NONE, fid, F_NONE);
}
objecttype_t *getrandomobwithclass(map_t *map, enum OBCLASS cid, char *buf, int depthmod) {
//return real_getrandomob(map, buf, RO_OBCLASS, cid, map->depth + depthmod);
//if (depthmod == NA) depthmod = 0;
return real_getrandomob(map, buf, getmapdifficulty(map) + depthmod, NA, SZ_MAX, SK_NONE, RR_NONE, B_FALSE, cid, OC_NONE, DT_NONE, F_NONE);
condset_t cs;
initcondv(&cs, CC_HASFLAG, B_TRUE, fid,
CC_NONE);
return real_getrandomob(map, buf, NA, NA, RR_NONE, B_FALSE, &cs);
}
enum OBCLASS getrandomobclass(enum HABITAT hab) {
@ -7136,7 +7087,6 @@ enum OBCLASS getrandomobclass(enum HABITAT hab) {
objectclass_t *oc,*poss[MAXCANDIDATES];
int nposs = 0;
wantrr = pickrr(TT_OBJECT);
while (!nposs) {
for (oc = objectclass ; oc ; oc = oc->next) {
@ -9660,6 +9610,303 @@ int brandappliesto(brand_t *br, objecttype_t *ot) {
return B_TRUE;
}
// if val is B_ONEOF, then at least one of the conditions with ONEOF must match.
int obmeets(object_t *o, condset_t *cs) {
int i,n,found;
struct {
enum CELLCONDITION cond;
int got;
} oneof [MAXCANDIDATES];
int noneof = 0;
if (!cs) return B_TRUE;
for (i = 0; i < cs->nconds; i++ ){
if (cs->val[i] == B_ONEOF) {
found = B_FALSE;
for (n = 0; n < noneof; n++) {
if (oneof[n].cond == cs->cond[i]) {
found = B_TRUE;
}
}
if (!found) {
oneof[noneof].cond = cs->cond[i];
oneof[noneof].got = 0;
}
}
if (obmeetscondition(o, cs->cond[i], cs->arg[i], cs->val[i])) {
if (cs->val[i] == B_ONEOF) {
found = B_FALSE;
for (n = 0; n < noneof; n++) {
if (oneof[n].cond == cs->cond[i]) {
oneof[n].got = B_TRUE;
found = B_TRUE;
}
}
assert(found);
}
} else {
if (cs->val[i] != B_ONEOF) return B_FALSE;
}
}
if (noneof) {
for (n = 0; n < noneof; n++) {
if (oneof[n].got == B_FALSE) return B_FALSE;
}
}
return B_TRUE;
}
int obmeetscondition(object_t *o, enum CELLCONDITION cond, int arg, int value) {
flag_t *f;
int ok = B_FALSE,n;
skill_t *sk = NULL;
int check = B_FALSE;
assert(o);
switch (cond) {
case CC_ARMOUR:
if (o->type->obclass->id == OC_ARMOUR) check = B_TRUE;
break;
case CC_DAMAGED:
if (isdamaged(o)) check = B_TRUE;
break;
case CC_DAMTYPE:
if (hasflagval(o->flags, F_DAM, arg, NA, NA, NULL)) check = B_TRUE;
break;
case CC_DRINKABLE:
if (isdrinkable(o)) check = B_TRUE;
break;
case CC_EDIBLE:
if (isedible(o)) check = B_TRUE;
break;
case CC_EQUIPPED:
if (hasflag(o->flags, F_EQUIPPED)) check = B_TRUE;
break;
case CC_KNOWN:
if (isknown(o)) check = B_TRUE;
break;
case CC_HASFLAG:
if (hasflag(o->flags, arg)) check = B_TRUE;
break;
case CC_HASSIZE:
if (getobsize(o) == arg) check = B_TRUE;
break;
case CC_IDENTIFIED:
if (isidentified(o)) check = B_TRUE;
break;
case CC_MINAR:
f = hasflag(o->flags, F_ARMOURRATING);
if (f) {
if (f->val[0] >= arg) {
check = B_TRUE;
}
}
break;
case CC_MINDR:
f = hasflag(o->flags, F_DAM);
if (f) {
if (f->val[1] >= arg) {
check = B_TRUE;
}
}
break;
case CC_MAXDR:
f = hasflag(o->flags, F_DAM);
if (f) {
if (f->val[1] <= arg) {
check = B_TRUE;
}
}
break;
case CC_MAXSIZE:
if (getobsize(o) <= arg) check = B_TRUE;
break;
case CC_OBCLASS:
if (o->type->obclass->id == arg) check = B_TRUE;
break;
case CC_OPERABLE:
if (isoperable(o)) check = B_TRUE;
break;
case CC_POURABLE:
if (ispourable(o)) check = B_TRUE;
break;
case CC_READABLE:
if (isreadable(o)) check = B_TRUE;
break;
case CC_SPECIFIED:
// does retlist contain this?
for (n = 0; n < nretobs; n++) {
if (retobs[n] == o) {
check = B_TRUE;
break;
}
}
break;
case CC_WEARABLE:
if (iswearable(o)) check = B_TRUE;
break;
case CC_WEAPON:
if (isweapon(o)) check = B_TRUE;
break;
case CC_WEPSK:
sk = getobskill(o->flags);
if (sk && (sk->id == arg)) check = B_TRUE;
break;
case CC_NONE: ok = B_TRUE; break;
default: break;
}
if (value && check) {
ok = B_TRUE;
} else if (!value && !check) {
ok = B_TRUE;
}
return ok;
}
int otmeets(objecttype_t *ot, condset_t *cs) {
int i,n,found;
struct {
enum CELLCONDITION cond;
int got;
} oneof [MAXCANDIDATES];
int noneof = 0;
if (!cs) return B_TRUE;
for (i = 0; i < cs->nconds; i++ ){
if (cs->val[i] == B_ONEOF) {
found = B_FALSE;
for (n = 0; n < noneof; n++) {
if (oneof[n].cond == cs->cond[i]) {
found = B_TRUE;
}
}
if (!found) {
oneof[noneof].cond = cs->cond[i];
oneof[noneof].got = 0;
}
}
if (otmeetscondition(ot, cs->cond[i], cs->arg[i], cs->val[i])) {
if (cs->val[i] == B_ONEOF) {
found = B_FALSE;
for (n = 0; n < noneof; n++) {
if (oneof[n].cond == cs->cond[i]) {
oneof[n].got = B_TRUE;
found = B_TRUE;
}
}
assert(found);
}
} else {
if (cs->val[i] != B_ONEOF) return B_FALSE;
}
}
if (noneof) {
for (n = 0; n < noneof; n++) {
if (oneof[n].got == B_FALSE) return B_FALSE;
}
}
return B_TRUE;
}
int otmeetscondition(objecttype_t *ot, enum CELLCONDITION cond, int arg, int value) {
int ok = B_FALSE;
int check = B_FALSE;
skill_t *sk = NULL;
flag_t *f;
assert(ot);
switch (cond) {
case CC_ARMOUR:
if (ot->obclass->id == OC_ARMOUR) check = B_TRUE;
break;
case CC_DAMAGED:
assert("CC_DAMAGED not applicable to objecttypes");
break;
case CC_DAMTYPE:
if (hasflagval(ot->flags, F_DAM, arg, NA, NA, NULL)) check = B_TRUE;
break;
case CC_DRINKABLE:
if ((ot->obclass->id == OC_POTION) || hasflag(ot->flags, F_DRINKABLE)) check = B_TRUE;
break;
case CC_EDIBLE:
if (hasflag(ot->flags, F_EDIBLE)) check = B_TRUE;
break;
case CC_EQUIPPED:
assert("CC_EQUIPPED not applicable to objecttypes");
break;
case CC_KNOWN:
if (isknownot(ot)) check = B_TRUE;
break;
case CC_HASFLAG:
if (hasflag(ot->flags, arg)) check = B_TRUE;
break;
case CC_HASSIZE:
if (ot->size == arg) check = B_TRUE;
break;
case CC_IDENTIFIED:
assert("CC_IDENTIFIED not applicable to objecttypes");
break;
case CC_MINAR:
f = hasflag(ot->flags, F_ARMOURRATING);
if (f) {
if (f->val[0] >= arg) {
check = B_TRUE;
}
}
break;
case CC_MINDR:
f = hasflag(ot->flags, F_DAM);
if (f) {
if (f->val[1] >= arg) {
check = B_TRUE;
}
}
break;
case CC_MAXDR:
f = hasflag(ot->flags, F_DAM);
if (f) {
if (f->val[1] <= arg) {
check = B_TRUE;
}
}
break;
case CC_MAXSIZE:
if (ot->size <= arg) check = B_TRUE;
break;
case CC_OBCLASS:
if (ot->obclass->id == arg) check = B_TRUE;
break;
case CC_OPERABLE:
if (hasflag(ot->flags, F_OPERABLE)) check = B_TRUE;
break;
case CC_POURABLE:
if (hasflag(ot->flags, F_POURABLE)) check = B_TRUE;
break;
case CC_READABLE:
if ((ot->obclass->id == OC_SCROLL) || (ot->obclass->id == OC_BOOK)) check = B_TRUE;
break;
case CC_SPECIFIED:
assert("CC_SPECIFIED not applicable to objecttypes");
break;
case CC_WEARABLE:
if (hasflag(ot->flags, F_GOESON)) check = B_TRUE;
break;
case CC_WEAPON:
if ((ot->obclass->id == OC_WEAPON) || hasflag(ot->flags, F_DAM)) check = B_TRUE;
break;
case CC_WEPSK:
sk = getobskill(ot->flags);
if (sk && (sk->id == arg)) check = B_TRUE;
break;
case CC_NONE: ok = B_TRUE; break;
default: break;
}
if (value && check) {
ok = B_TRUE;
} else if (!value && !check) {
ok = B_TRUE;
}
return ok;
}
/*
int obmatchescondition(object_t *o, long opts) {
int ok;
@ -9712,6 +9959,7 @@ int obmatchescondition(object_t *o, long opts) {
return ok;
}
*/
// returns the amount of light produced
int obproduceslight(object_t *o) {
@ -10250,8 +10498,11 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
msg(buf);
return B_TRUE;
} else {
condset_t cs;
initcondv(&cs, CC_SPECIFIED, B_TRUE, NA,
CC_NONE);
snprintf(buf, BUFLEN, "Load %s with what ammo",obname);
oo = askobject(lf->pack, buf, NULL, NULL, 'l', AO_SPECIFIED);
oo = askobject(lf->pack, buf, NULL, NULL, 'l', &cs, B_FALSE);
if (oo) {
if (isammofor(oo->type, o)) {
loadfirearm(lf, o, oo);
@ -10592,9 +10843,13 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
} else if (o->type->id == OT_ENERGYPACK) {
object_t *targob;
if (isplayer(lf)) {
condset_t cs;
// ask for an object
targob = doaskobject(lf->pack, "Recharge which object", NULL, NULL, B_TRUE, B_TRUE, B_FALSE, '^', NULL, SA_NONE,
MT_NOTHING, AO_NONE, F_REPLENISHABLE, F_TECHLEVEL, F_NONE);
initcondv(&cs, CC_HASFLAG, B_TRUE, F_REPLENISHABLE,
CC_HASFLAG, B_TRUE, F_TECHLEVEL,
CC_NONE);
targob = doaskobject(lf->pack, "Recharge which object", NULL, NULL, B_TRUE, B_TRUE, B_FALSE, '^', NULL, SA_NONE, &cs, B_FALSE);
if (targob) {
f = hasflag(targob->flags, F_CHARGES);
if (f) {
@ -11400,7 +11655,10 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
}
snprintf(buf, BUFLEN, "Mix %s into what",obname);
if (isplayer(lf)) {
oo = askobject(lf->pack, buf, NULL, NULL, '\0', AO_SPECIFIED);
condset_t cs;
initcondv(&cs, CC_SPECIFIED, B_TRUE, NA,
CC_NONE);
oo = askobject(lf->pack, buf, NULL, NULL, '\0', &cs, B_FALSE);
} else {
oo = retobs[rnd(0,nretobs-1)];
}
@ -11537,7 +11795,7 @@ int pour(lifeform_t *lf, object_t *o) {
} else {
snprintf(buf, BUFLEN, "Pour %s onto what", obname);
// tip onto another object
dst = askobject(lf->pack, buf, NULL, NULL, '\0', AO_NONE);
dst = askobject(lf->pack, buf, NULL, NULL, '\0', NULL, B_FALSE);
if (!dst) {
msg("Cancelled.");
return B_TRUE;
@ -12609,7 +12867,7 @@ int readsomething(lifeform_t *lf, object_t *o) {
if (needsob && isplayer(lf) && !isknown(o)) {
flag_t *f2;
f2 = addflag(o->flags, F_BEINGUSED, B_TRUE, NA, NA, NULL);
targob = askobject(lf->pack, "Target which object", NULL, NULL, '\0', AO_NONE);
targob = askobject(lf->pack, "Target which object", NULL, NULL, '\0', NULL, B_FALSE);
killflag(f2);
if (targob) {
if (isplayer(lf)) {

View File

@ -110,12 +110,13 @@ object_t *getrandomammo(lifeform_t *lf);
objecttype_t *getrandomammofor(object_t *o, int usebasic);
brand_t *getrandombrandfor(objecttype_t *ot);
int getrandomgrimoirelev(void);
objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity, lifeform_t *forlf, int minar, int mindr, int maxdr, enum FLAG musthaveflag);
objecttype_t *getrandomobofclass(enum OBCLASS ocid, int minrarity, int maxrarity, lifeform_t *forlf, condset_t *cs);
enum OBTYPE getrandomtrapforob(object_t *o);
int getrustdampct(object_t *o);
int getfirearmrange(object_t *o);
int getfirearmspeed(object_t *o);
glyph_t *getglyph(object_t *o);
void getgoodnessdr(enum GOODNESS gd, int *mindr, int *maxdr);
int gethardness(enum MATERIAL matid);
char *genhiddenname(enum OBCLASS id);
char *gethiddenname(object_t *o);
@ -149,12 +150,10 @@ char *getobhurtname(object_t *o, enum DAMTYPE damtype);
float getobweight(object_t *o);
float getobunitweight(object_t *o);
objecttype_t *getoppositestairs(objecttype_t *ot);
objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum LFSIZE maxsize, enum SKILL wepsk, enum RARITY forcerr, int forpickup, ... );
//objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum LFSIZE maxsize, enum SKILL wepsk, enum RARITY forcerr, int forpickup, ... );
objecttype_t *real_getrandomob(map_t *map, char *buf, int forcedepth, int forcehabitat, enum RARITY forcerr, int forpickup, condset_t *cs);
objecttype_t *getrandomob(map_t *map, char *buf);
objecttype_t *getrandomobofsize(map_t *map, char *buf, enum LFSIZE maxsize);
objecttype_t *getrandomobwithdt(map_t *map, enum DAMTYPE damtype, char *buf);
objecttype_t *getrandomobwithflag(map_t *map, enum FLAG fid, char *buf);
objecttype_t *getrandomobwithclass(map_t *map, enum OBCLASS cid, char *buf, int depthmod);
enum OBCLASS getrandomobclass(enum HABITAT hab);
int getobrarity(object_t *o, enum RARITY *rr);
enum SPELLSCHOOL getschool(enum OBTYPE sid);
@ -266,7 +265,11 @@ int obfits(object_t *o, obpile_t *op);
int obgoesinbones(object_t *o);
enum DAMTYPE oblastdamtype(object_t *o);
int brandappliesto(brand_t *om, objecttype_t *ot);
int obmatchescondition(object_t *o, long opts);
int obmeets(object_t *o, condset_t *cs);
int obmeetscondition(object_t *o, enum CELLCONDITION cond, int arg, int value);
int otmeets(objecttype_t *ot, condset_t *cs);
int otmeetscondition(objecttype_t *ot, enum CELLCONDITION cond, int arg, int value);
//int obmatchescondition(object_t *o, long opts);
int obproduceslight(object_t *o);
int obpropsmatch(object_t *a, object_t *b);
int obotpropsmatch(object_t *a, objecttype_t *b);

View File

@ -460,7 +460,7 @@ enum SHOPRETURN shopdonate(lifeform_t *lf, object_t *vm, int starty, char *topte
default: wantflag = F_NONE; wantoc = OC_NONE; break;
}
*/
o = doaskobject(lf->pack, "What will you donate?", NULL, &count, B_TRUE, B_FALSE, B_FALSE, '\0', vm, SA_DONATE, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(lf->pack, "What will you donate?", NULL, &count, B_TRUE, B_FALSE, B_FALSE, '\0', vm, SA_DONATE, NULL, B_FALSE);
// validate it
if (o) {
@ -1304,7 +1304,7 @@ enum SHOPRETURN shopsell(lifeform_t *lf, object_t *vm, int starty, char *toptext
// ask what to sell
sprintf(buf, "What will you sell (you have $%d)?", countmoney(lf->pack));
o = doaskobject(player->pack, buf, NULL, &count, B_TRUE, B_FALSE, B_FALSE, '\0', vm, SA_SELL, MT_NOTHING, AO_NONE, F_NONE);
o = doaskobject(player->pack, buf, NULL, &count, B_TRUE, B_FALSE, B_FALSE, '\0', vm, SA_SELL, NULL, B_FALSE);
if (!o) {
return SR_BACK;
}

70
spell.c
View File

@ -2126,7 +2126,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
if (targcell->obpile->first) {
if (isplayer(user)) {
// select object from cell...
o = askobject(targcell->obpile, "Snatch which object", NULL, NULL, '\0', AO_NONE);
o = askobject(targcell->obpile, "Snatch which object", NULL, NULL, '\0', NULL, B_FALSE);
} else {
object_t *oo;
for (oo = targcell->obpile->first; oo ; oo = oo->next) {
@ -4297,7 +4297,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
// needs:
// object = which object to convert
if (!targob && isplayer(caster)) {
targob = doaskobject(caster->pack, "Convert which object to gold", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_STONE, AO_NONE, F_NONE);
condset_t cs;
initcondv(&cs, CC_HASMATERIAL, B_TRUE, MT_STONE,
CC_NONE);
targob = doaskobject(caster->pack, "Convert which object to gold", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, &cs, B_FALSE);
}
if (!targob) {
fizzle(caster);
@ -4554,7 +4558,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
// more than object?
if (targcell->obpile->first->next) {
// select object from cell...
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', AO_NONE);
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', NULL, B_FALSE);
} else {
targob = targcell->obpile->first;
}
@ -5123,7 +5127,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (targcell->obpile->first) {
// select object from cell...
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', AO_NONE);
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', NULL, B_FALSE);
if (!targob) {
failed = B_TRUE;
}
@ -5743,7 +5747,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
return B_TRUE;
}
for (i = 0; i < power; i++) {
ot = getrandomobofclass(OC_FOOD, NA, NA, NULL, B_FALSE, NA, NA, F_NONE);
ot = getrandomobofclass(OC_FOOD, NA, NA, NULL, NULL);
o = addobfast(targcell->obpile, ot->id);
if (i == 0) {
getobname(o, obname, o->amt);
@ -7392,7 +7396,10 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
o = targob;
} else {
// ask for an object
o = askobjectwithflag(caster->pack, "Enchant which object", NULL, NULL, '\0', AO_NONE, F_ENCHANTABLE);
condset_t cs;
initcondv(&cs, CC_HASFLAG, B_TRUE, F_ENCHANTABLE,
CC_NONE);
o = askobject(caster->pack, "Enchant which object", NULL, NULL, '\0', &cs, B_FALSE);
}
if (!o) {
fizzle(caster);
@ -8070,8 +8077,12 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (targob) {
o = targob;
} else {
condset_t cs;
initcondv(&cs, CC_HASMATERIAL, B_TRUE, MT_METAL,
CC_HASFLAG, B_TRUE, F_DAM,
CC_NONE);
// ask for an object
o = doaskobject(caster->pack, "Hone which metal weapon", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_METAL, AO_WEILDABLE, F_NONE);
o = doaskobject(caster->pack, "Hone which metal weapon", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, &cs, B_FALSE);
}
if (!o) {
fizzle(caster);
@ -8259,7 +8270,10 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
o = targob;
} else {
// ask for an object
o = askobject(target->pack, "Identify which object", "You have nothing which needs identifying.", NULL, '\0', AO_NOTIDENTIFIED);
condset_t cs;
initcondv(&cs, CC_IDENTIFIED, B_FALSE, NA,
CC_NONE);
o = askobject(target->pack, "Identify which object", "You have nothing which needs identifying.", NULL, '\0', &cs, B_FALSE);
}
if (!o) {
fizzle(caster);
@ -8834,7 +8848,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
int seen;
if (targcell->obpile->first) {
targob = doaskobject(targcell->obpile, "Target which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
targob = doaskobject(targcell->obpile, "Target which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, NULL, B_FALSE);
}
if (!targob) {
@ -8923,7 +8937,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
int seen;
if (targcell->obpile->first) {
targob = doaskobject(targcell->obpile, "Target which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_NOTHING, AO_NONE, F_NONE);
targob = doaskobject(targcell->obpile, "Target which object", NULL, NULL, B_TRUE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, NULL, B_FALSE);
}
strcpy(obtocreate, "");
@ -9016,11 +9030,14 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (!targob) {
// ask for an object
if (spellid == OT_S_ACCELMETAL) {
condset_t cs;
initcondv(&cs, CC_HASMATERIAL, B_TRUE, MT_METAL,
CC_NONE);
// TODO: handle ai casting
targob = askobject(caster->pack, "Accelerate which metal object", NULL, NULL, 't', AO_NONE);
targob = askobject(caster->pack, "Accelerate which metal object", NULL, NULL, 't', &cs, B_FALSE);
} else { // ie. propel
if (isplayer(caster)) {
targob = askobject(caster->pack, "Propel which object", NULL, NULL, 't', AO_NONE);
targob = askobject(caster->pack, "Propel which object", NULL, NULL, 't', NULL, B_FALSE);
} else {
lifeform_t *target;
target = gettargetlf(caster);
@ -9703,7 +9720,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
} else if (targcell->obpile->first) { // no lifeform there
targob = NULL;
// select object from cell...
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', AO_NONE);
targob = askobject(targcell->obpile, "Target which object", NULL, NULL, '\0', NULL, B_FALSE);
if (targob) {
if (ismetal(targob->material->id)) {
@ -10471,8 +10488,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (targob) {
o = targob;
} else {
condset_t cs;
initcondv(&cs, CC_DAMAGED, B_TRUE, NA,
CC_NONE);
// ask for an object
o = askobject(caster->pack, "Mend which object", NULL, NULL, '\0', AO_DAMAGED);
o = askobject(caster->pack, "Mend which object", NULL, NULL, '\0', &cs, B_FALSE);
}
if (!o) {
fizzle(caster);
@ -11161,8 +11181,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (!targob) {
if (isplayer(caster)) {
condset_t cs;
initcondv(&cs, CC_HASFLAG, B_TRUE, F_REPLENISHABLE,
CC_NONE);
// ask for an object
targob = askobjectwithflag(caster->pack, "Replenish which object", NULL, NULL, '\0', AO_NONE, F_REPLENISHABLE);
targob = askobject(caster->pack, "Replenish which object", NULL, NULL, '\0', &cs, B_FALSE);
}
}
if (!targob) {
@ -11219,8 +11242,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
} else if (spellid == OT_S_RESSURECTION) {
lifeform_t *newlf;
if (!targob) {
condset_t cs;
initcondv(&cs, CC_HASFLAG, B_TRUE, F_CORPSEOF,
CC_NONE);
// select object from cell...
targob = askobjectwithflag(targcell->obpile, "Revive which corpse", NULL, NULL, '\0', AO_NONE, F_CORPSEOF);
targob = askobject(targcell->obpile, "Revive which corpse", NULL, NULL, '\0', &cs, B_FALSE);
if (!targob) {
fizzle(caster);
return B_TRUE;
@ -11425,8 +11451,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (targob) {
o = targob;
} else {
condset_t cs;
initcondv(&cs, CC_HASMATERIAL, B_TRUE, MT_METAL,
CC_NONE);
// ask for an object
o = doaskobject(caster->pack, "Repair which metal object", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, MT_METAL, AO_NONE, F_NONE);
o = doaskobject(caster->pack, "Repair which metal object", NULL, NULL, B_FALSE, B_FALSE, B_FALSE, '\0', NULL, SA_NONE, &cs, B_FALSE);
}
if (!o) {
fizzle(caster);
@ -12307,7 +12336,10 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
// object = which potion to throw
// cell = where to throw the potion
if (!targob && isplayer(caster)) {
targob = askobjectwithflag(caster->pack, "Superheat which potion", NULL, NULL, 'q', AO_NONE, F_DRINKABLE);
condset_t cs;
initcondv(&cs, CC_DRINKABLE, B_TRUE, NA,
CC_NONE);
targob = askobject(caster->pack, "Superheat which potion", NULL, NULL, 'q', &cs, B_FALSE);
}
if (!targob) {
fizzle(caster);
@ -12582,7 +12614,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
if (where && haslos(caster, where)) {
if (where->obpile->first) {
// select object from cell...
targob = askobject(where->obpile, "Target which object", NULL, NULL, '\0', AO_NONE);
targob = askobject(where->obpile, "Target which object", NULL, NULL, '\0', NULL, B_FALSE);
if (!targob) {
failed = B_TRUE;
}