This commit is contained in:
Rob Pearce 2011-03-10 05:47:18 +00:00
parent 020f47b808
commit 4ddc70a314
22 changed files with 54977 additions and 3218 deletions

5
ai.c
View File

@ -57,6 +57,11 @@ enum OBTYPE aigetattackspell(lifeform_t *lf, lifeform_t *victim) {
} else { } else {
ok = B_TRUE; ok = B_TRUE;
} }
} else if (ot->id == OT_A_CRUSH) {
// can only crush if you first grab something
if (lfhasflag(lf, F_GRABBING)) {
ok = B_TRUE;
}
} else { } else {
ok = B_TRUE; ok = B_TRUE;
} }

167
attack.c
View File

@ -296,7 +296,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim) {
sprintf(buf, "%s",attackername); sprintf(buf, "%s",attackername);
capitalise(buf); capitalise(buf);
if (wep && !unarmedflag && (lf->race->id != R_DANCINGWEAPON)) { if (wep && !unarmedflag && (lf->race->id != R_DANCINGWEAPON) && haslos(player, lf->cell)) {
sprintf(withwep, " with %s", wepname); sprintf(withwep, " with %s", wepname);
} else { } else {
strcpy(withwep, ""); strcpy(withwep, "");
@ -328,16 +328,19 @@ int attacklf(lifeform_t *lf, lifeform_t *victim) {
gainhp(victim, dam[i]); gainhp(victim, dam[i]);
} }
} else { } else {
char attackername2[BUFLEN];
real_getlfname(lf, attackername2, B_FALSE);
// victim loses hp // victim loses hp
// don't adjust damage - we've already done that // don't adjust damage - we've already done that
if (wep && !unarmedflag) { if (wep && !unarmedflag) {
char wepname[BUFLEN]; char wepname[BUFLEN];
getobname(wep, wepname, 1); getobname(wep, wepname, 1);
sprintf(buf, "%s^%s %s",attackername, sprintf(buf, "%s^%s %s",attackername2,
(lf == victim) ? "using" : "weilding", (lf == victim) ? "using" : "weilding",
wepname); wepname);
} else { } else {
strcpy(buf, attackername); char attackername2[BUFLEN];
strcpy(buf, attackername2);
} }
losehp_real(victim, dam[i], damtype[i], lf, buf, B_FALSE); losehp_real(victim, dam[i], damtype[i], lf, buf, B_FALSE);
@ -368,7 +371,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim) {
int dam; int dam;
char lfname[BUFLEN]; char lfname[BUFLEN];
dam = rolldie(f->val[0], f->val[1]) + f->val[2]; dam = rolldie(f->val[0], f->val[1]) + f->val[2];
getlfname(lf, lfname); real_getlfname(lf, lfname, B_FALSE);
losehp_real(victim, dam, DT_BITE, lf, lfname, B_FALSE); losehp_real(victim, dam, DT_BITE, lf, lfname, B_FALSE);
if (isplayer(victim) || haslos(player, victim->cell)) { if (isplayer(victim) || haslos(player, victim->cell)) {
msg("%s bites %s!", lfname, victimname); msg("%s bites %s!", lfname, victimname);
@ -619,8 +622,78 @@ int getarmourdamreduction(lifeform_t *lf, object_t *wep, int dam, enum DAMTYPE d
char *getattackverb(enum DAMTYPE damtype, int dam, int maxhp) { char *getattackverb(enum DAMTYPE damtype, int dam, int maxhp) {
float pct; float pct;
pct = (int)(((float) dam / (float) maxhp) * 100.0); pct = (int)(((float) dam / (float) maxhp) * 100.0);
if (damtype == DT_PROJECTILE) { if (damtype == DT_BASH) {
if (pct <= 5) {
return "whack";
} else if (pct <= 20) {
if (rnd(1,2) == 1) {
return "hit"; return "hit";
} else {
return "bash";
}
} else {
return "pummel";
}
} else if (damtype == DT_BITE) {
if (pct <= 5) {
return "gnaw";
} else if (pct <= 30) {
return "bite";
} else {
return "savage";
}
} else if (damtype == DT_CLAW) {
if (pct <= 5) {
return "scratch";
} else if (pct <= 15) {
return "claw";
} else if (pct <= 30) {
return "tear";
} else if (pct <= 40) {
return "rake";
} else if (pct <= 50) {
return "gouge";
} else {
return "eviscerate";
}
} else if (damtype == DT_CHOP) {
if (pct <= 5) {
return "hit";
} else if (pct <= 15) {
return "hack";
} else {
return "chop";
}
} else if (damtype == DT_COLD) {
if (pct <= 10) {
return "chill";
} else {
return "freeze";
}
} else if (damtype == DT_CRUSH) {
return "crush";
} else if (damtype == DT_ELECTRIC) {
if (pct <= 5) {
return "zap";
} else if (pct <= 15) {
return "jolt";
} else if (pct <= 20) {
return "shock";
} else if (pct <= 30) {
return "electrify";
} else {
return "electrocute";
}
} else if (damtype == DT_FIRE) {
if (pct <= 5) {
return "scorch";
} else if (pct <= 20) {
return "burn";
} else if (pct <= 40) {
return "scald";
} else {
return "incinerate";
}
} else if (damtype == DT_HOLY) { } else if (damtype == DT_HOLY) {
switch (rnd(1,2)) { switch (rnd(1,2)) {
case 1: case 1:
@ -642,32 +715,8 @@ char *getattackverb(enum DAMTYPE damtype, int dam, int maxhp) {
} }
} else if (damtype == DT_POISONGAS) { } else if (damtype == DT_POISONGAS) {
return "poison"; return "poison";
} else if (damtype == DT_ELECTRIC) { } else if (damtype == DT_PROJECTILE) {
if (pct <= 5) { return "hit";
return "zap";
} else if (pct <= 15) {
return "jolt";
} else if (pct <= 20) {
return "shock";
} else if (pct <= 30) {
return "electrify";
} else {
return "electrocute";
}
} else if (damtype == DT_CLAW) {
if (pct <= 5) {
return "scratch";
} else if (pct <= 15) {
return "claw";
} else if (pct <= 30) {
return "tear";
} else if (pct <= 40) {
return "rake";
} else if (pct <= 50) {
return "gouge";
} else {
return "eviscerate";
}
} else if (damtype == DT_SLASH) { } else if (damtype == DT_SLASH) {
if (pct <= 5) { if (pct <= 5) {
return "scratch"; return "scratch";
@ -678,58 +727,14 @@ char *getattackverb(enum DAMTYPE damtype, int dam, int maxhp) {
} else { } else {
return "slice"; return "slice";
} }
} else if (damtype == DT_CHOP) { } else if (damtype == DT_TOUCH) {
if (pct <= 5) { return "touch";
return "hit";
} else if (pct <= 15) {
return "hack";
} else {
return "chop";
}
} else if (damtype == DT_BASH) {
if (pct <= 5) {
return "whack";
} else if (pct <= 20) {
if (rnd(1,2) == 1) {
return "hit";
} else {
return "bash";
}
} else {
return "pummel";
}
} else if (damtype == DT_BITE) {
if (pct <= 5) {
return "gnaw";
} else if (pct <= 30) {
return "bite";
} else {
return "savage";
}
} else if (damtype == DT_FIRE) {
if (pct <= 5) {
return "scorch";
} else if (pct <= 20) {
return "burn";
} else if (pct <= 40) {
return "scald";
} else {
return "incinerate";
}
} else if (damtype == DT_COLD) {
if (pct <= 10) {
return "chill";
} else {
return "freeze";
}
} else if (damtype == DT_UNARMED) { } else if (damtype == DT_UNARMED) {
if (rnd(1,2) == 1) { if (rnd(1,2) == 1) {
return "punch"; return "punch";
} else { } else {
return "hit"; return "hit";
} }
} else if (damtype == DT_TOUCH) {
return "touch";
} }
return "hit"; return "hit";
} }
@ -786,6 +791,10 @@ char *getkillverb(lifeform_t *victim, enum DAMTYPE damtype, int dam, int maxhp)
return "shatter"; return "shatter";
} }
if (damtype == DT_CRUSH) {
return "crush";
}
if (damtype == DT_HOLY) { if (damtype == DT_HOLY) {
return "smite"; return "smite";
} }
@ -1182,10 +1191,12 @@ void wepeffects(object_t *wep, cell_t *where) {
extradam = (int)(dampct * (float)maxdam); extradam = (int)(dampct * (float)maxdam);
if (extradam > 0) { if (extradam > 0) {
char buf[BUFLEN]; char buf[BUFLEN];
char buf2[BUFLEN];
char obname[BUFLEN]; char obname[BUFLEN];
char damstring[BUFLEN]; char damstring[BUFLEN];
char victimname[BUFLEN]; char victimname[BUFLEN];
getlfname(owner, buf); getlfname(owner, buf);
real_getlfname(owner, buf2, B_FALSE);
getlfname(victim, victimname); getlfname(victim, victimname);
getobname(wep, obname, 1); getobname(wep, obname, 1);
@ -1198,7 +1209,7 @@ void wepeffects(object_t *wep, cell_t *where) {
f->known = B_TRUE; f->known = B_TRUE;
} }
sprintf(damstring, "%s%s blast of revenge",buf, getpossessive(buf)); sprintf(damstring, "%s%s blast of revenge",buf2, getpossessive(buf2));
losehp(victim, extradam, DT_DIRECT, owner, damstring); losehp(victim, extradam, DT_DIRECT, owner, damstring);
} }
} // end if dampct > 50 } // end if dampct > 50

146
defs.h
View File

@ -22,17 +22,20 @@ enum ATTRIB {
A_STR = 0, A_STR = 0,
A_DEX = 1, A_DEX = 1,
A_IQ = 2, A_IQ = 2,
A_CON = 3,
}; };
#define MAXATTS 3 #define MAXATTS 4
enum CHECKTYPE { enum CHECKTYPE {
SC_STR, SC_STR,
SC_DEX, SC_DEX,
SC_IQ, SC_IQ,
SC_CON,
////////// //////////
SC_DODGE, SC_DODGE,
SC_SLIP, SC_SLIP,
SC_MORALE, SC_MORALE,
SC_OPENLOCKS,
}; };
enum BURDENED { enum BURDENED {
@ -72,7 +75,8 @@ enum LFCONDITION {
#define FROMOBACTIVATE (-9868) #define FROMOBACTIVATE (-9868)
#define FROMMAT (-9867) #define FROMMAT (-9867)
#define FROMBLESSING (-9866) #define FROMBLESSING (-9866)
#define FROMOBMOD (-9865) #define FROMBRAND (-9865)
#define FROMOBMOD (-9864)
#define IFKNOWN (-9772) // used by f_xxconfer. only confer a flag if item is known. #define IFKNOWN (-9772) // used by f_xxconfer. only confer a flag if item is known.
@ -165,6 +169,7 @@ enum LFCONDITION {
#define AO_SPECIFIED 512 #define AO_SPECIFIED 512
#define AO_READABLE 1024 #define AO_READABLE 1024
#define AO_ARMOUR 2048 #define AO_ARMOUR 2048
#define AO_NOTKNOWN 4096
// askcoords target types // askcoords target types
#define TT_NONE 0 #define TT_NONE 0
@ -273,6 +278,7 @@ enum SPELLSCHOOL {
}; };
enum STRBRACKET { enum STRBRACKET {
ST_RANDOM = -1,
ST_HELPLESS = 0, ST_HELPLESS = 0,
ST_FEEBLE = 1, ST_FEEBLE = 1,
ST_VWEAK = 2, ST_VWEAK = 2,
@ -284,6 +290,7 @@ enum STRBRACKET {
}; };
enum DEXBRACKET { enum DEXBRACKET {
DX_RANDOM = -1,
DX_INCOMPETENT = 0, DX_INCOMPETENT = 0,
DX_OAFISH = 1, DX_OAFISH = 1,
DX_INEPT = 2, DX_INEPT = 2,
@ -298,6 +305,7 @@ enum DEXBRACKET {
}; };
enum IQBRACKET { enum IQBRACKET {
IQ_RANDOM = -1,
IQ_MINDLESS = 0, IQ_MINDLESS = 0,
IQ_VEGETABLE = 1, IQ_VEGETABLE = 1,
IQ_ANIMAL = 2, IQ_ANIMAL = 2,
@ -310,6 +318,18 @@ enum IQBRACKET {
IQ_GENIUS = 9, IQ_GENIUS = 9,
}; };
enum CONBRACKET {
CN_RANDOM = -1,
CN_FRAIL = 0,
CN_SICKLY = 1,
CN_UNHEALTHY = 2,
CN_UNFIT = 3,
CN_AVERAGE = 4,
CN_HEALTHY = 5,
CN_FIT = 6,
CN_HARDY = 7,
};
// damage type // damage type
enum DAMTYPE { enum DAMTYPE {
DT_ALL = -1, DT_ALL = -1,
@ -334,9 +354,11 @@ enum DAMTYPE {
DT_TOUCH = 18, DT_TOUCH = 18,
DT_POISONGAS = 19, DT_POISONGAS = 19,
DT_UNARMED = 20, DT_UNARMED = 20,
DT_NONE = 21, // for direclty dealt damage, not really any type DT_LIGHT = 21,
DT_CRUSH = 22,
DT_NONE = 23, // for direclty dealt damage, not really any type
}; };
#define MAXDAMTYPE 22 #define MAXDAMTYPE 24
// Object Classes // Object Classes
enum OBCLASS { enum OBCLASS {
@ -390,6 +412,7 @@ enum RACE {
R_HUMAN, R_HUMAN,
// monsters // monsters
R_BUGBEAR, R_BUGBEAR,
R_DARKMANTLE,
R_EYEBAT, R_EYEBAT,
R_GIANTHILL, R_GIANTHILL,
R_GIANTFIRE, R_GIANTFIRE,
@ -696,11 +719,13 @@ enum OBTYPE {
OT_S_GIFT, OT_S_GIFT,
// abilities // abilities
OT_A_GRAB, OT_A_GRAB,
OT_A_CRUSH,
OT_A_JUMP, OT_A_JUMP,
OT_A_SPRINT, OT_A_SPRINT,
OT_A_DEBUG, OT_A_DEBUG,
OT_A_EMPLOY, OT_A_EMPLOY,
OT_A_HEAVYBLOW, OT_A_HEAVYBLOW,
OT_A_INSPECT,
// wands // wands
OT_WAND_COLD, OT_WAND_COLD,
OT_WAND_DETONATION, OT_WAND_DETONATION,
@ -817,6 +842,7 @@ enum OBTYPE {
OT_FISTS, OT_FISTS,
OT_TAIL, OT_TAIL,
OT_TEETH, OT_TEETH,
OT_TENTACLE,
OT_ZAPPER, OT_ZAPPER,
// monster weapons // monster weapons
OT_ACIDATTACK, OT_ACIDATTACK,
@ -954,10 +980,11 @@ enum FLAG {
F_DTIMMUNE, // immune to damtype val0 F_DTIMMUNE, // immune to damtype val0
F_DTRESIST, // half dam from damtype val0 F_DTRESIST, // half dam from damtype val0
F_DTVULN, // double dam from damtype val0 F_DTVULN, // double dam from damtype val0
// if dam=0, set dam to textfield dice (eg.text="2d6")
F_MATIMMUNE, // immune to damage from obs with material 'mat' F_MATIMMUNE, // immune to damage from obs with material 'mat'
F_DAMAGABLE, // this ob can be damaged via takedamage() F_DAMAGABLE, // this ob can be damaged via takedamage()
F_TINTED, // when worn on eyes, protects against bright lights F_TINTED, // when worn on eyes, protects against bright lights
F_HASOBMOD, // has the object mod v0 (ie. OM_FLAMESTRIKE) F_HASBRAND, // has the object mod v0 (ie. OM_FLAMESTRIKE)
F_HOLDCONFER, // gives flag v0+v1 when carried. v2 specifies if it must be id'd. F_HOLDCONFER, // gives flag v0+v1 when carried. v2 specifies if it must be id'd.
F_EQUIPCONFER, // gives flag v0+v1 when weilded/worn. v2 specifies if it must be id'd. F_EQUIPCONFER, // gives flag v0+v1 when weilded/worn. v2 specifies if it must be id'd.
F_ACTIVATECONFER, // gives flag v0+v1 when activated. v2 specifies if it must be id'd. F_ACTIVATECONFER, // gives flag v0+v1 when activated. v2 specifies if it must be id'd.
@ -1011,6 +1038,8 @@ enum FLAG {
// object mods/effects // object mods/effects
F_ONFIRE, // burning, also deals extra fire damage F_ONFIRE, // burning, also deals extra fire damage
F_HEADLESS, // for corpses. can go on LFs too. F_HEADLESS, // for corpses. can go on LFs too.
F_MASTERWORK, // weps do higher damager, armour protects better
F_SHODDY, // weps do less damage, armour protects less.
// weapon flags // weapon flags
F_OBATTACKDELAY, // how long weapon takes to attack F_OBATTACKDELAY, // how long weapon takes to attack
F_DAMTYPE, // val0 = damage type F_DAMTYPE, // val0 = damage type
@ -1077,12 +1106,11 @@ enum FLAG {
F_LASTCMD, // text[0] = last command performed, v0/1 = x/y of cell, v2=various F_LASTCMD, // text[0] = last command performed, v0/1 = x/y of cell, v2=various
F_STARTOB, // val0 = %chance of starting with it, text = ob name F_STARTOB, // val0 = %chance of starting with it, text = ob name
// val1,2 = min/max amounts. if NA, min=max=1. // val1,2 = min/max amounts. if NA, min=max=1.
F_STARTSKILL, // val0 = skill id
F_STARTOBDT, // val0 = %chance of starting with damtype val1 F_STARTOBDT, // val0 = %chance of starting with damtype val1
F_STARTOBCLASS, // val0 = %chance of starting with obclass val1 F_STARTOBCLASS, // val0 = %chance of starting with obclass val1
F_STARTJOB, // val0 = %chance of starting with it, v1 = jobid F_STARTJOB, // val0 = %chance of starting with it, v1 = jobid
F_STARTIQ, // val0 = start iq bracket (ie. IQ_GENIUS) F_STARTATT, // val0 = A_xxx, val0 = start bracket (ie. IQ_GENIUS)
F_STARTDEX, // val0 = start dex bracket (ie. DEX_xxx)
F_STARTSTR, // val0 = start str bracket (ie. STR_STRONG)
F_CORPSETYPE, // text field specifies what corpse obtype to leave F_CORPSETYPE, // text field specifies what corpse obtype to leave
F_NOCORPSE, // monster's body crumbles to dust after death F_NOCORPSE, // monster's body crumbles to dust after death
F_LFSUFFIX, // text = suffix. eg. "skeleton" F_LFSUFFIX, // text = suffix. eg. "skeleton"
@ -1091,6 +1119,8 @@ enum FLAG {
F_GUNTARGET, // current projectile weapon target F_GUNTARGET, // current projectile weapon target
F_CASTINGSPELL, // set while the player is casting a spell F_CASTINGSPELL, // set while the player is casting a spell
// v0 is spell id // v0 is spell id
// ABILITY FLAGS
F_FAILEDINSPECT, // lf has failed an inspect check for item id v0
// MONSTER AI FLAGS // MONSTER AI FLAGS
F_HOSTILE, // lf will attack the player if in sight F_HOSTILE, // lf will attack the player if in sight
F_FRIENDLY, // lf will attack all non-players if in sight F_FRIENDLY, // lf will attack all non-players if in sight
@ -1199,6 +1229,8 @@ enum FLAG {
F_TIRED, // you are too tired to sprint F_TIRED, // you are too tired to sprint
F_DODGES, // you dodge missed attacks F_DODGES, // you dodge missed attacks
F_NOTIME, // this lf's actions don't take time F_NOTIME, // this lf's actions don't take time
// skills
F_HASSKILL, // lf has skill v0 at level v1
// COMBAT // COMBAT
F_HASATTACK, // objecttype id to use when attacking unarmed F_HASATTACK, // objecttype id to use when attacking unarmed
// if val0-3 are filled in, they override the object's // if val0-3 are filled in, they override the object's
@ -1252,12 +1284,13 @@ enum HUNGER {
//#define B_NOT (-3) //#define B_NOT (-3)
enum LIGHTLEV { enum LIGHTLEV {
L_DARK = -1, L_PERMDARK = -1,
L_NOTLIT = 0, L_NOTLIT = 0,
L_TEMP = 1, L_TEMP = 1,
L_PERM = 2, L_PERMLIGHT = 2,
}; };
#define B_DIEONFAIL (-1) #define B_DIEONFAIL (-1)
#define B_BLUNTONFAIL (-2) #define B_BLUNTONFAIL (-2)
@ -1403,6 +1436,8 @@ typedef struct cell_s {
struct celltype_s *type; struct celltype_s *type;
struct obpile_s *obpile; struct obpile_s *obpile;
enum LIGHTLEV lit; enum LIGHTLEV lit;
enum LIGHTLEV origlit;
int littimer;
char *writing; char *writing;
@ -1528,6 +1563,38 @@ typedef struct material_s {
struct material_s *next,*prev; struct material_s *next,*prev;
} material_t; } material_t;
enum SKILL {
SK_LOCKPICKING,
SK_RESEARCH,
};
// proficiency levels
enum SKILLLEVEL {
PR_INEPT = 0,
PR_NOVICE = 1,
PR_BEGINNER = 2,
PR_ADEPT = 3,
PR_SKILLED = 4,
PR_EXPERT = 5,
PR_MASTER = 6,
};
typedef struct skill_s {
enum SKILL id;
char *name;
char *desc;
struct skill_s *next, *prev;
} skill_t;
typedef struct hiddenname_s {
enum OBCLASS obclass;
char *text;
int used;
struct hiddenname_s *next, *prev;
} hiddenname_t;
typedef struct knowledge_s { typedef struct knowledge_s {
enum OBTYPE id; enum OBTYPE id;
char *hiddenname; char *hiddenname;
@ -1584,34 +1651,49 @@ typedef struct object_s {
} object_t; } object_t;
enum OBMOD { enum OBMOD {
OM_BALANCE, OM_FLAMING,
OM_DEXTERITY, OM_HEADLESS,
OM_FEEBLENESS, OM_MASTERWORK,
OM_FLIGHT, OM_SHODDY,
OM_GIANTSTRENGTH, };
OM_IMPACT, #define MAXOBMODS 4
OM_INTELLIGENCE,
OM_KNOWLEDGE, enum BRAND {
OM_LEVITATION, BR_BALANCE,
OM_MAGRESIST, BR_DEXTERITY,
OM_SHARPNESS, BR_FEEBLENESS,
OM_PYROMANIA, BR_FLIGHT,
OM_REVENGE, BR_GIANTSTRENGTH,
OM_SLOTH, BR_IMPACT,
OM_SPEED, BR_INTELLIGENCE,
OM_STRENGTH, BR_KNOWLEDGE,
OM_SWIFTNESS, BR_LEVITATION,
OM_TELEKINESIS, BR_MAGRESIST,
OM_TELEPATHY, BR_SHARPNESS,
OM_WEAKNESS, BR_PYROMANIA,
BR_REVENGE,
BR_SLOTH,
BR_SPEED,
BR_STRENGTH,
BR_SWIFTNESS,
BR_TELEKINESIS,
BR_TELEPATHY,
BR_WEAKNESS,
}; };
typedef struct obmod_s { typedef struct brand_s {
enum OBMOD id; enum BRAND id;
char *description; char *description;
char *suffix; char *suffix;
flagpile_t *flags; flagpile_t *flags;
enum BODYPART bp; enum BODYPART bp;
struct brand_s *next, *prev;
} brand_t;
typedef struct obmod_s {
enum OBMOD id;
char *prefix;
flagpile_t *flags;
struct obmod_s *next, *prev; struct obmod_s *next, *prev;
} obmod_t; } obmod_t;

18
doc/add_attrib.txt Normal file
View File

@ -0,0 +1,18 @@
defs.h:
add A_xxx
inc MAXATTS
add CHECKTYPE (SC_xxx)
add xxxBRACKET
lf.c:
add getxxxname()
update rollstat()
add rollxxx()
update skillcheck()
update gainlevel() question
update givejob()
ooooooo replace startxxx with startstat

View File

@ -13,3 +13,4 @@ in attack.c
will dull a weapon. will dull a weapon.
ie. hitting a door with DT_CHOP won't damage the weapon ie. hitting a door with DT_CHOP won't damage the weapon
ie. hitting a door with DT_SLASH _will_ damage the weapon ie. hitting a door with DT_SLASH _will_ damage the weapon

5
flag.c
View File

@ -295,10 +295,9 @@ void killflag(flag_t *f) {
int howlong; int howlong;
// you get tired when you finish sprinting // you get tired when you finish sprinting
// TODO: change this based on
// constitution
// running skill
howlong = 5; howlong = 5;
// adjust for constitution
howlong = howlong - (int) ((float)howlong * (getstatmod(lf, A_CON) / 100) );
addtempflag(f->pile, F_TIRED, B_TRUE, NA, NA, NULL, howlong); addtempflag(f->pile, F_TIRED, B_TRUE, NA, NA, NULL, howlong);
} }

186
io.c
View File

@ -806,7 +806,7 @@ int announceflaggain(lifeform_t *lf, flag_t *f) {
} }
break; break;
case F_PRODUCESLIGHT: case F_PRODUCESLIGHT:
msg("%s start%s glowing!", lfname, isplayer(lf) ? "" : "s"); msg("%s start%s producing light!", lfname, isplayer(lf) ? "" : "s");
donesomething = B_TRUE; donesomething = B_TRUE;
break; break;
case F_REGENERATES: case F_REGENERATES:
@ -1055,7 +1055,7 @@ int announceflagloss(lifeform_t *lf, flag_t *f) {
if (lf2 && !isdead(lf2)) { if (lf2 && !isdead(lf2)) {
char buf[BUFLEN]; char buf[BUFLEN];
getlfname(lf2, buf); getlfname(lf2, buf);
msg("%s releases %s.",buf, lfname); msg("%s break%s free from %s!",lfname, isplayer(lf) ? "" : "s", buf);
donesomething = B_TRUE; donesomething = B_TRUE;
} }
break; break;
@ -1100,7 +1100,7 @@ int announceflagloss(lifeform_t *lf, flag_t *f) {
} }
break; break;
case F_PRODUCESLIGHT: case F_PRODUCESLIGHT:
msg("%s stop%s glowing!", lfname, isplayer(lf) ? "" : "s"); msg("%s stop%s glowing.", lfname, isplayer(lf) ? "" : "s");
donesomething = B_TRUE; donesomething = B_TRUE;
break; break;
case F_REGENERATES: case F_REGENERATES:
@ -1282,15 +1282,15 @@ void announceobflagloss(object_t *o, flag_t *f) {
} }
object_t *askobject(obpile_t *op, char *prompt, int *count, int opts) { object_t *askobject(obpile_t *op, char *prompt, int *count, long opts) {
return doaskobject(op, prompt, count, opts, F_NONE, OC_NULL); return doaskobject(op, prompt, count, opts, F_NONE, OC_NULL);
} }
object_t *askobjectwithflag(obpile_t *op, char *prompt, int *count, int opts, enum FLAG withflag) { object_t *askobjectwithflag(obpile_t *op, char *prompt, int *count, long opts, enum FLAG withflag) {
return doaskobject(op, prompt, count, opts, withflag, OC_NULL); return doaskobject(op, prompt, count, opts, withflag, OC_NULL);
} }
object_t *askobjectofclass(obpile_t *op, char *prompt, int *count, int opts, enum OBCLASS obclass) { object_t *askobjectofclass(obpile_t *op, char *prompt, int *count, long opts, enum OBCLASS obclass) {
return doaskobject(op, prompt, count, opts, F_NONE, obclass, OC_NULL); return doaskobject(op, prompt, count, opts, F_NONE, obclass, OC_NULL);
} }
@ -1305,7 +1305,7 @@ int contains(enum OBCLASS *array, int nargs, enum OBCLASS want) {
return B_FALSE; return B_FALSE;
} }
object_t *doaskobject(obpile_t *op, char *prompt, int *count, int opts, enum FLAG withflag, ...) { object_t *doaskobject(obpile_t *op, char *prompt, int *count, long opts, enum FLAG withflag, ...) {
int c,i; int c,i;
object_t *mylist[MAXPILEOBS+1]; object_t *mylist[MAXPILEOBS+1];
char myletters[MAXPILEOBS+1]; char myletters[MAXPILEOBS+1];
@ -1395,40 +1395,7 @@ object_t *doaskobject(obpile_t *op, char *prompt, int *count, int opts, enum FLA
ok = B_FALSE; ok = B_FALSE;
} }
} }
if ((opts & AO_ONLYEQUIPPED) && !hasflag(o->flags, F_EQUIPPED)) { ok = obmatchescondition(o, opts);
ok = B_FALSE;
}
if ((opts & AO_EQUIPPEDARMOUR)) {
flag_t *ff;
ff = hasflag(o->flags, F_EQUIPPED);
if (!ff) {
ok = B_FALSE;
} else if (ff->val[0] == BP_WEAPON) {
ok = B_FALSE;
}
}
if ((opts & AO_EDIBLE) && !isedible(o)) ok = B_FALSE;
if ((opts & AO_READABLE) && !isreadable(o)) ok = B_FALSE;
if ((opts & AO_ARMOUR) && (o->type->obclass->id != OC_ARMOUR)) ok = B_FALSE;
if ((opts & AO_WEARABLE) && !iswearable(o)) {
ok = B_FALSE;
}
if ((opts & AO_WEILDABLE) && !isweapon(o)) {
ok = B_FALSE;
}
if ((opts & AO_OPERABLE) && !isoperable(o)) {
ok = B_FALSE;
}
if ((opts & AO_POURABLE) && !ispourable(o)) {
ok = B_FALSE;
}
if (opts & AO_NOTIDENTIFIED) {
// if ob is identified
if (isidentified(o)) {
ok = B_FALSE;
}
}
if (ok) { if (ok) {
mylist[i] = o; mylist[i] = o;
myletters[i] = nextlet; myletters[i] = nextlet;
@ -1573,7 +1540,7 @@ object_t *doaskobject(obpile_t *op, char *prompt, int *count, int opts, enum FLA
return NULL; return NULL;
} }
int askobjectmulti(obpile_t *op, char *prompt, int opts) { int askobjectmulti(obpile_t *op, char *prompt, long opts) {
int c,i; int c,i;
object_t *mylist[MAXPILEOBS+1]; object_t *mylist[MAXPILEOBS+1];
int selected[MAXPILEOBS+1]; int selected[MAXPILEOBS+1];
@ -1635,40 +1602,7 @@ int askobjectmulti(obpile_t *op, char *prompt, int opts) {
if (o->type->obclass->id == sortorder[c]) { if (o->type->obclass->id == sortorder[c]) {
int ok; int ok;
// can we include this object? // can we include this object?
ok = B_TRUE; ok = obmatchescondition(o, opts);
if ((opts & AO_ONLYEQUIPPED) && !hasflag(o->flags, F_EQUIPPED)) {
ok = B_FALSE;
}
if ((opts & AO_EQUIPPEDARMOUR)) {
flag_t *ff;
ff = hasflag(o->flags, F_EQUIPPED);
if (!ff) {
ok = B_FALSE;
} else if (ff->val[0] == BP_WEAPON) {
ok = B_FALSE;
}
}
if ((opts & AO_EDIBLE) && !isedible(o)) ok = B_FALSE;
if ((opts & AO_READABLE) && !isreadable(o)) ok = B_FALSE;
if ((opts & AO_ARMOUR) && (o->type->obclass->id != OC_ARMOUR)) ok = B_FALSE;
if ((opts & AO_WEARABLE) && !iswearable(o)) {
ok = B_FALSE;
}
if ((opts & AO_WEILDABLE) && !isweapon(o)) {
ok = B_FALSE;
}
if ((opts & AO_OPERABLE) && !isoperable(o)) {
ok = B_FALSE;
}
if ((opts & AO_POURABLE) && !ispourable(o)) {
ok = B_FALSE;
}
if (opts & AO_NOTIDENTIFIED) {
// if ob is identified
if (isidentified(o)) {
ok = B_FALSE;
}
}
if (ok) { if (ok) {
mylist[i] = o; mylist[i] = o;
@ -2092,6 +2026,8 @@ void describeob(object_t *o) {
f = hasflag(o->flags, F_DAM); f = hasflag(o->flags, F_DAM);
if (f) { if (f) {
char buf[BUFLEN];
char dicebuf[BUFLEN];
int mindam,maxdam; int mindam,maxdam;
getdamrange(o->flags, &mindam, &maxdam); getdamrange(o->flags, &mindam, &maxdam);
mindam += bonus; mindam += bonus;
@ -2099,14 +2035,21 @@ void describeob(object_t *o) {
if (mindam < 0) mindam = 0; if (mindam < 0) mindam = 0;
if (maxdam < 0) maxdam = 0; if (maxdam < 0) maxdam = 0;
if (mindam == maxdam) {
sprintf(buf, "It inflicts %d %s damage",maxdam, getdamname(damtype));
} else {
sprintf(buf, "It inflicts %d-%d %s damage",mindam,maxdam, getdamname(damtype));
}
if (f->val[2] == NA) { if (f->val[2] == NA) {
mvwprintw(mainwin, y, 0, "It inflicts %d-%d %s damage (%dd%d).",mindam,maxdam, sprintf(dicebuf, " (%dd%d).", f->val[0], f->val[1]);
getdamname(damtype), f->val[0], f->val[1]);
} else { } else {
mvwprintw(mainwin, y, 0, "It inflicts %d-%d %s damage (%dd%d%c%d).",mindam,maxdam, sprintf(dicebuf, " (%dd%d%c%d).", f->val[0], f->val[1],
getdamname(damtype), f->val[0], f->val[1], (f->val[2] > 0) ? '+' : '-', abs(f->val[2])); (f->val[2] > 0) ? '+' : '-',
abs(f->val[2]));
} }
strcat(buf,dicebuf);
mvwprintw(mainwin, y, 0, "%s",buf);
y++; y++;
} else { } else {
mvwprintw(mainwin, y, 0, "It inflicts %s damage.",getdamname(damtype)); mvwprintw(mainwin, y, 0, "It inflicts %s damage.",getdamname(damtype));
@ -2198,9 +2141,21 @@ void describeob(object_t *o) {
y++; y++;
} }
// now special flags... // now special flags...
y++; y++;
f = hasflag(o->flags, F_MASTERWORK);
if (f && f->known) {
mvwprintw(mainwin, y, 0, "It is extremely well crafted.");
y++;
}
f = hasflag(o->flags, F_SHODDY);
if (f && f->known) {
mvwprintw(mainwin, y, 0, "It is very poorly crafted.");
y++;
}
f = hasflag(o->flags, F_ONFIRE); f = hasflag(o->flags, F_ONFIRE);
if (f) { if (f) {
mvwprintw(mainwin, y, 0, "It is on fire."); mvwprintw(mainwin, y, 0, "It is on fire.");
@ -2436,7 +2391,7 @@ void describespell(objecttype_t *ot) {
// properties // properties
y = 4; y = 5;
f = hasflag(ot->flags, F_SPELLLEVEL); f = hasflag(ot->flags, F_SPELLLEVEL);
if (f) { if (f) {
flag_t *sf; flag_t *sf;
@ -2880,7 +2835,7 @@ void domagic(enum OBTYPE spellid, int cellx, int celly) {
// add to list // add to list
poss[nposs] = ot->id; poss[nposs] = ot->id;
mpcost[nposs] = cost; mpcost[nposs] = cost;
sprintf(mpdesc[nposs], "(%d MP)", mpcost[nposs]); sprintf(mpdesc[nposs], "(cost: %d MP)", mpcost[nposs]);
if (player->mp >= cost) { if (player->mp >= cost) {
validspell[nposs] = B_TRUE; validspell[nposs] = B_TRUE;
} else { } else {
@ -3529,13 +3484,16 @@ void drawscannedcell(cell_t *cell, int x, int y) {
} }
*/ */
void downline(int *y, int h, char *heading, char *subheading) { // returns TRUE if escape pressed
int downline(int *y, int h, char *heading, char *subheading) {
char headbuf[BUFLEN]; char headbuf[BUFLEN];
int ch;
sprintf(headbuf, "%s (continued)", heading); sprintf(headbuf, "%s (continued)", heading);
(*y)++; (*y)++;
if (*y >= (h-2)) { if (*y >= (h-2)) {
centre(mainwin, h-1, MORESTRING); centre(mainwin, h-1, MORESTRING);
getch(); ch = getch();
if (getch() == 27) { return B_TRUE; }
cls(); *y = 0; cls(); *y = 0;
centre(mainwin, *y, headbuf); centre(mainwin, *y, headbuf);
*y += 2; *y += 2;
@ -3544,6 +3502,7 @@ void downline(int *y, int h, char *heading, char *subheading) {
doheading(mainwin, y, 0, subheading); doheading(mainwin, y, 0, subheading);
} }
} }
return B_FALSE;
} }
@ -4502,7 +4461,7 @@ void drawstatus(void) {
char waitbuf[BUFLEN]; char waitbuf[BUFLEN];
char pname[BUFLEN]; char pname[BUFLEN];
flag_t *f; flag_t *f;
int str,dex,iq; int str,dex,iq,con;
getplayernamefull(pname); getplayernamefull(pname);
@ -4599,14 +4558,16 @@ void drawstatus(void) {
str = getattr(player, A_STR); str = getattr(player, A_STR);
dex = getattr(player, A_DEX); dex = getattr(player, A_DEX);
iq = getattr(player, A_IQ); iq = getattr(player, A_IQ);
con = getattr(player, A_CON);
//redraw(); //redraw();
sprintf(buf, "HP:%d/%d MP:%d/%d %12sST:%2d%c DX:%2d%c IQ:%2d%c DLev:%2d", sprintf(buf, "HP:%d/%d MP:%d/%d %12sST:%2d%c DX:%2d%c IQ:%2d%c CN:%2d%c DLev:%2d",
player->hp,player->maxhp, player->hp,player->maxhp,
player->mp, player->maxmp, player->mp, player->maxmp,
" ", " ",
str, (str == player->baseatt[A_STR]) ? ' ' : '*', str, (str == player->baseatt[A_STR]) ? ' ' : '*',
dex, (dex == player->baseatt[A_DEX]) ? ' ' : '*', dex, (dex == player->baseatt[A_DEX]) ? ' ' : '*',
iq, (iq == player->baseatt[A_IQ]) ? ' ' : '*', iq, (iq == player->baseatt[A_IQ]) ? ' ' : '*',
con, (con == player->baseatt[A_CON]) ? ' ' : '*',
player->cell->map->depth player->cell->map->depth
); );
mvwprintw(statwin, 1, 0, buf); mvwprintw(statwin, 1, 0, buf);
@ -4938,6 +4899,25 @@ void showlfstats(lifeform_t *lf, int showall) {
wprintw(mainwin, "%s", buf); y++; wprintw(mainwin, "%s", buf); y++;
} }
if (showall) {
char buf2[BUFLEN];
int con;
con = getattr(lf, A_CON);
getconname(con, buf2);
sprintf(buf, "%d (%s)",con, buf2);
if (con != lf->baseatt[A_CON]) strcat(buf, "*");
mvwprintw(mainwin, y, 0, ftext, "CON");
wprintw(mainwin, "%s", buf); y++;
} else if (!isplayer(lf)) {
int con;
// just show name
con = getattr(lf, A_CON);
getconname(con, buf);
if (con != lf->baseatt[A_CON]) strcat(buf, "*");
mvwprintw(mainwin, y, 0, ftext, "CON");
wprintw(mainwin, "%s", buf); y++;
}
//mvwprintw(mainwin, y, 0, ftext, "XP"); //mvwprintw(mainwin, y, 0, ftext, "XP");
//wprintw(mainwin, "%ld (%ld more for next level)", lf->xp, xpneeded); y++; //wprintw(mainwin, "%ld (%ld more for next level)", lf->xp, xpneeded); y++;
@ -5344,7 +5324,8 @@ void showlfstats(lifeform_t *lf, int showall) {
// wait for key // wait for key
centre(mainwin, h-1, "[Press any key]"); centre(mainwin, h-1, "[Press any key]");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
if (showall) { if (showall) {
int anyfound = B_FALSE; int anyfound = B_FALSE;
char subheading[BUFLEN]; char subheading[BUFLEN];
@ -5373,13 +5354,28 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
sprintf(buf, "%-12s%s%s", ot->name, ot->desc, expirebuf); sprintf(buf, "%-12s%s%s", ot->name, ot->desc, expirebuf);
mvwprintw(mainwin, y, 0, buf); mvwprintw(mainwin, y, 0, buf);
downline(&y, h, "ABILITIES", NULL); if (downline(&y, h, "ABILITIES", NULL)) {
drawscreen(); real_clearmsg(B_TRUE); return;
}
}
}
}
y++;
if (hasflag(lf->flags, F_HASSKILL)) {
centre(mainwin, y, "SKILLS"); y += 2;
for (f = lf->flags->first ; f ; f = f->next) {
if (f->id == F_HASSKILL) {
mvwprintw(mainwin, y, 0, "- %s %s",getskilllevelname(f->val[1]), getskillname(f->val[0]));
if (downline(&y, h, "SKILLS", NULL)) {
drawscreen(); real_clearmsg(B_TRUE); return;
}
} }
} }
} }
centre(mainwin, h-1, "[Press any key]"); centre(mainwin, h-1, "[Press any key]");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
cls(); y = 0; cls(); y = 0;
//wmove(mainwin, y, 0); //wmove(mainwin, y, 0);
centre(mainwin, y, "SPELLS"); y += 2; centre(mainwin, y, "SPELLS"); y += 2;
@ -5408,7 +5404,9 @@ void showlfstats(lifeform_t *lf, int showall) {
sprintf(buf, " %-4d%-25s%-22s%s",thislev, ot->name, getschoolname(getspellschool(ot->id)), mpbuf); sprintf(buf, " %-4d%-25s%-22s%s",thislev, ot->name, getschoolname(getspellschool(ot->id)), mpbuf);
mvwprintw(mainwin, y, 0, "%s\n", buf); mvwprintw(mainwin, y, 0, "%s\n", buf);
anyfound = B_TRUE; anyfound = B_TRUE;
downline(&y, h, "SPELLS", subheading); if (downline(&y, h, "SPELLS", subheading)) {
drawscreen(); real_clearmsg(B_TRUE); return;
}
} }
} }
} }
@ -5420,7 +5418,7 @@ void showlfstats(lifeform_t *lf, int showall) {
//} //}
centre(mainwin, h-1, "[Press any key]"); centre(mainwin, h-1, "[Press any key]");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
cls(); y = 0; cls(); y = 0;
x = 0; // override x = 0; // override
@ -5630,7 +5628,7 @@ void showlfstats(lifeform_t *lf, int showall) {
// wait for key // wait for key
centre(mainwin, h-1, "[Press any key]"); centre(mainwin, h-1, "[Press any key]");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
} }
if (!isplayer(lf) && showall) { if (!isplayer(lf) && showall) {
@ -5649,7 +5647,7 @@ void showlfstats(lifeform_t *lf, int showall) {
if (y >= (h-3) && (o->next)) { if (y >= (h-3) && (o->next)) {
// wait for key // wait for key
centre(mainwin, h-1, "-- More --"); centre(mainwin, h-1, "-- More --");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
cls(); cls();
centre(mainwin, 0, "INVENTORY"); centre(mainwin, 0, "INVENTORY");
y = 2; y = 2;
@ -5657,7 +5655,7 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
// wait for key // wait for key
centre(mainwin, h-1, "[Press any key]"); centre(mainwin, h-1, "[Press any key]");
getch(); if (getch() == 27) { drawscreen(); real_clearmsg(B_TRUE); return; }
} }
drawscreen(); drawscreen();

12
io.h
View File

@ -12,11 +12,11 @@ int announceflaggain(lifeform_t *lf, flag_t *f);
int announceflagloss(lifeform_t *lf, flag_t *f); int announceflagloss(lifeform_t *lf, flag_t *f);
int announceobflaggain(object_t *o, flag_t *f); int announceobflaggain(object_t *o, flag_t *f);
void announceobflagloss(object_t *o, flag_t *f); void announceobflagloss(object_t *o, flag_t *f);
object_t *askobject(obpile_t *op, char *title, int *count, int opts); object_t *askobject(obpile_t *op, char *title, int *count, long opts);
object_t *askobjectwithflag(obpile_t *op, char *title, int *count, int opts, enum FLAG withflag); object_t *askobjectwithflag(obpile_t *op, char *title, int *count, long opts, enum FLAG withflag);
object_t *askobjectofclass(obpile_t *op, char *title, int *count, int opts, enum OBCLASS obclass); object_t *askobjectofclass(obpile_t *op, char *title, int *count, long opts, enum OBCLASS obclass);
object_t *doaskobject(obpile_t *op, char *title, int *count, int opts, enum FLAG withflag, ...); object_t *doaskobject(obpile_t *op, char *title, int *count, long opts, enum FLAG withflag, ...);
int askobjectmulti(obpile_t *op, char *prompt, int opts); int askobjectmulti(obpile_t *op, char *prompt, long opts);
char askchar(char *prompt, char *validchars, char *def, int showchars); char askchar(char *prompt, char *validchars, char *def, int showchars);
cell_t *askcoords(char *prompt, int targettype); cell_t *askcoords(char *prompt, int targettype);
char *askstring(char *prompt, char punc, char *retbuf, int retbuflen, char *def); char *askstring(char *prompt, char punc, char *retbuf, int retbuflen, char *def);
@ -59,7 +59,7 @@ void dothrow(obpile_t *op);
void dovendingmachine(lifeform_t *lf, object_t *vm); void dovendingmachine(lifeform_t *lf, object_t *vm);
int dowear(obpile_t *op); int dowear(obpile_t *op);
int doweild(obpile_t *op); int doweild(obpile_t *op);
void downline(int *y, int h, char *heading, char *subheading); int downline(int *y, int h, char *heading, char *subheading);
void drawunviscell(cell_t *cell, int x, int y); void drawunviscell(cell_t *cell, int x, int y);
void drawcellwithcontents(cell_t *cell, int x, int y); void drawcellwithcontents(cell_t *cell, int x, int y);
void drawcursor(void); void drawcursor(void);

639
lf.c

File diff suppressed because it is too large Load Diff

15
lf.h
View File

@ -4,6 +4,7 @@ lifeform_t *addlf(cell_t *cell, enum RACE rid, int level);
lifeform_t *real_addlf(cell_t *cell, enum RACE rid, int level, int controller); lifeform_t *real_addlf(cell_t *cell, enum RACE rid, int level, int controller);
job_t *addjob(enum JOB id, char *name); job_t *addjob(enum JOB id, char *name);
race_t *addrace(enum RACE id, char *name, float weight, char glyph, enum MATERIAL mat); race_t *addrace(enum RACE id, char *name, float weight, char glyph, enum MATERIAL mat);
skill_t *addskill(enum SKILL id, char *name, char *desc);
void adjustdamlf(lifeform_t *lf, int *amt, enum DAMTYPE damtype); void adjustdamlf(lifeform_t *lf, int *amt, enum DAMTYPE damtype);
void autotarget(lifeform_t *lf); void autotarget(lifeform_t *lf);
void autoweild(lifeform_t *lf); void autoweild(lifeform_t *lf);
@ -33,6 +34,7 @@ job_t *findjobbyname(char *name);
lifeform_t *findlf(map_t *m, int lfid); lifeform_t *findlf(map_t *m, int lfid);
race_t *findrace(enum RACE id); race_t *findrace(enum RACE id);
race_t *findracebyname(char *name); race_t *findracebyname(char *name);
skill_t *findskill(enum SKILL id);
int flee(lifeform_t *lf); int flee(lifeform_t *lf);
int freezelf(lifeform_t *freezee, lifeform_t *freezer, int howlong); int freezelf(lifeform_t *freezee, lifeform_t *freezer, int howlong);
void gainhp(lifeform_t *lf, int amt); void gainhp(lifeform_t *lf, int amt);
@ -77,6 +79,7 @@ int getmovespeed(lifeform_t *lf);
char *getmoveverb(lifeform_t *lf); char *getmoveverb(lifeform_t *lf);
char *getmoveverbother(lifeform_t *lf); char *getmoveverbother(lifeform_t *lf);
char *getlfname(lifeform_t *lf, char *buf); char *getlfname(lifeform_t *lf, char *buf);
char *real_getlfname(lifeform_t *lf, char *buf, int usevis);
char *getlfnamea(lifeform_t *lf, char *buf); char *getlfnamea(lifeform_t *lf, char *buf);
enum LFSIZE getlfsize(lifeform_t *lf); enum LFSIZE getlfsize(lifeform_t *lf);
float getlfweight(lifeform_t *lf, int withobs); float getlfweight(lifeform_t *lf, int withobs);
@ -87,17 +90,24 @@ object_t *getrandomarmour(lifeform_t *lf);
//int getrandommonlevel(int depth); //int getrandommonlevel(int depth);
race_t *getrandomrace(map_t *map); race_t *getrandomrace(map_t *map);
race_t *getreallyrandomrace(void); race_t *getreallyrandomrace(void);
enum SKILLLEVEL getskill(lifeform_t *lf, enum SKILL id);
char *getspeedname(int speed, char *buf); char *getspeedname(int speed, char *buf);
float getstatmod(lifeform_t *lf, enum ATTRIB att); float getstatmod(lifeform_t *lf, enum ATTRIB att);
enum CONBRACKET getconname(int str, char *buf);
enum STRBRACKET getstrname(int str, char *buf); enum STRBRACKET getstrname(int str, char *buf);
enum DEXBRACKET getdexname(int dex, char *buf); enum DEXBRACKET getdexname(int dex, char *buf);
enum IQBRACKET getiqname(int iq, char *buf); enum IQBRACKET getiqname(int iq, char *buf);
char *getskilldesc(enum SKILL id );
char *getskillname(enum SKILL id );
char *getskilllevelname(enum SKILLLEVEL sl);
int getthrowspeed(int str); int getthrowspeed(int str);
object_t *getweapon(lifeform_t *lf); object_t *getweapon(lifeform_t *lf);
long getxpforlev(int level); long getxpforlev(int level);
void givejob(lifeform_t *lf, enum JOB jobid); void givejob(lifeform_t *lf, enum JOB jobid);
void giveobflags(lifeform_t *lf, object_t *o, enum FLAG whattype); void giveobflags(lifeform_t *lf, object_t *o, enum FLAG whattype);
int giveskill(lifeform_t *lf, enum SKILL id);
void givestartobs(lifeform_t *lf, flagpile_t *fp); void givestartobs(lifeform_t *lf, flagpile_t *fp);
void givestartskills(lifeform_t *lf, flagpile_t *fp);
map_t *gotolev(lifeform_t *lf, int depth, object_t *fromstairs); map_t *gotolev(lifeform_t *lf, int depth, object_t *fromstairs);
job_t *hasjob(lifeform_t *lf, enum JOB job); job_t *hasjob(lifeform_t *lf, enum JOB job);
flag_t *lfhasflag(lifeform_t *lf, enum FLAG fid); flag_t *lfhasflag(lifeform_t *lf, enum FLAG fid);
@ -111,6 +121,7 @@ int haslos(lifeform_t *viewer, cell_t *dest);
int hasmr(lifeform_t *lf); int hasmr(lifeform_t *lf);
void initjobs(void); void initjobs(void);
void initrace(void); void initrace(void);
void initskills(void);
void interrupt(lifeform_t *lf); void interrupt(lifeform_t *lf);
int isairborne(lifeform_t *lf); int isairborne(lifeform_t *lf);
int isbleeding(lifeform_t *lf); int isbleeding(lifeform_t *lf);
@ -141,6 +152,7 @@ lifeform_t *makezombie(object_t *o);
void mayusespellschool(flagpile_t *fp, enum SPELLSCHOOL ss, enum FLAG how); void mayusespellschool(flagpile_t *fp, enum SPELLSCHOOL ss, enum FLAG how);
int modattr(lifeform_t *lf, enum ATTRIB attr, int amt); int modattr(lifeform_t *lf, enum ATTRIB attr, int amt);
void modhunger(lifeform_t *lf, int amt); void modhunger(lifeform_t *lf, int amt);
float modifybystat(float num, lifeform_t *lf, enum ATTRIB att);
void outfitlf(lifeform_t *lf); void outfitlf(lifeform_t *lf);
int pickup(lifeform_t *lf, object_t *what, int howmany, int fromground); int pickup(lifeform_t *lf, object_t *what, int howmany, int fromground);
void precalclos(lifeform_t *lf); void precalclos(lifeform_t *lf);
@ -148,6 +160,7 @@ int push(lifeform_t *lf, object_t *o, int dir);
void relinklf(lifeform_t *src, map_t *dst); void relinklf(lifeform_t *src, map_t *dst);
int rest(lifeform_t *lf, int onpurpose); int rest(lifeform_t *lf, int onpurpose);
void startresting(lifeform_t *lf); void startresting(lifeform_t *lf);
int rollcon(enum CONBRACKET bracket);
int rolldex(enum DEXBRACKET bracket); int rolldex(enum DEXBRACKET bracket);
int rolliq(enum IQBRACKET bracket); int rolliq(enum IQBRACKET bracket);
int rollstr(enum STRBRACKET bracket); int rollstr(enum STRBRACKET bracket);
@ -160,6 +173,8 @@ void setrace(lifeform_t *lf, enum RACE rid);
void setlastdam(lifeform_t *lf, char *buf); void setlastdam(lifeform_t *lf, char *buf);
int shoot(lifeform_t *lf); int shoot(lifeform_t *lf);
int skillcheck(lifeform_t *lf, enum CHECKTYPE ct, int diff, int mod); int skillcheck(lifeform_t *lf, enum CHECKTYPE ct, int diff, int mod);
int real_skillcheck(lifeform_t *lf, enum CHECKTYPE ct, int diff, int mod, int *result);
int skillcheckvs(lifeform_t *lf1, enum CHECKTYPE ct1, int mod1, lifeform_t *lf2, enum CHECKTYPE ct2, int mod2);
int slipon(lifeform_t *lf, object_t *o); int slipon(lifeform_t *lf, object_t *o);
void sortlf(map_t *map, lifeform_t *lf); void sortlf(map_t *map, lifeform_t *lf);
int stone(lifeform_t *lf); int stone(lifeform_t *lf);

55827
log.txt

File diff suppressed because it is too large Load Diff

46
map.c
View File

@ -32,6 +32,8 @@ cell_t *addcell(map_t *m, int x, int y) {
cell->lf = NULL; cell->lf = NULL;
cell->roomid = -1; cell->roomid = -1;
cell->lit = L_NOTLIT; cell->lit = L_NOTLIT;
cell->origlit = L_NOTLIT;
cell->littimer = 0;
cell->writing = NULL; cell->writing = NULL;
cell->known = B_FALSE; cell->known = B_FALSE;
return cell; return cell;
@ -358,7 +360,8 @@ void calclight(map_t *map) {
for (y = 0; y < map->h; y++) { for (y = 0; y < map->h; y++) {
for (x = 0; x < map->w; x++) { for (x = 0; x < map->w; x++) {
c = getcellat(map, x,y); c = getcellat(map, x,y);
if (c && (c->lit == L_PERM) && (c->lit != L_DARK)) c->lit = B_FALSE; //if (c && (c->lit == L_PERMLIGHT) && (c->lit != L_PERMDARK)) c->lit = B_FALSE;
if (c && (c->lit != L_PERMLIGHT) && (c->lit != L_PERMDARK)) c->lit = B_FALSE;
} }
} }
for (y = 0; y < map->h; y++) { for (y = 0; y < map->h; y++) {
@ -367,23 +370,28 @@ void calclight(map_t *map) {
if (c) { if (c) {
int radius; int radius;
object_t *o; object_t *o;
// lit based on depth // lit based on depth
if ((map->depth <= 5) && (c->lit != L_DARK)) { if ((map->depth <= 5) && (c->lit != L_PERMDARK)) {
c->lit = L_PERM; c->lit = L_PERMLIGHT;
} }
// TODO: has dark producing lf?
// TODO: has dark producing object?
// has lightproducing lf? (ie.hasflag f_produceslight) // has lightproducing lf? (ie.hasflag f_produceslight)
if (c->lf) { if (c->lf) {
if (lfhasflag(c->lf, F_PRODUCESLIGHT)) { if (lfhasflag(c->lf, F_PRODUCESLIGHT)) {
sumflags(c->lf->flags, F_PRODUCESLIGHT, &radius, NULL, NULL); sumflags(c->lf->flags, F_PRODUCESLIGHT, &radius, NULL, NULL);
makelitradius(c, radius, L_TEMP); makelitradius(c, radius, L_TEMP, -1);
} }
// objects in hands or on body... // objects in hands or on body...
for (o = c->lf->pack->first ; o ; o = o->next) { for (o = c->lf->pack->first ; o ; o = o->next) {
if (obproduceslight(o) && isequipped(o)) { if (obproduceslight(o) && isequipped(o)) {
sumflags(o->flags, F_PRODUCESLIGHT, &radius, NULL, NULL); sumflags(o->flags, F_PRODUCESLIGHT, &radius, NULL, NULL);
makelitradius(c, radius, L_TEMP); makelitradius(c, radius, L_TEMP, -1);
} }
} }
} }
@ -391,7 +399,7 @@ void calclight(map_t *map) {
for (o = c->obpile->first ; o ; o = o->next) { for (o = c->obpile->first ; o ; o = o->next) {
if (obproduceslight(o)) { if (obproduceslight(o)) {
sumflags(o->flags, F_PRODUCESLIGHT, &radius, NULL, NULL); sumflags(o->flags, F_PRODUCESLIGHT, &radius, NULL, NULL);
makelitradius(c, radius, L_TEMP); makelitradius(c, radius, L_TEMP, -1);
} }
} }
@ -1244,7 +1252,9 @@ void createroom(map_t *map, int minx, int miny, int w, int h, int roomid) {
// make it a border or room // make it a border or room
if ((y == miny) || (y == maxy) || if ((y == miny) || (y == maxy) ||
(x == minx) || (x == maxx)) { (x == minx) || (x == maxx)) {
if (cell->type->solid) {
setcelltype(cell, CT_ROOMWALL); setcelltype(cell, CT_ROOMWALL);
}
} else { } else {
setcelltype(cell, CT_ROOM); setcelltype(cell, CT_ROOM);
} }
@ -1835,6 +1845,9 @@ int getslipperyness(cell_t *c, object_t **slipob) {
thisslip *= o->amt; thisslip *= o->amt;
totalslip += thisslip; totalslip += thisslip;
} }
totalslip *= 2;
return totalslip; return totalslip;
} }
@ -1951,7 +1964,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, char *glyph) {
int islit(cell_t *c) { int islit(cell_t *c) {
switch (c->lit) { switch (c->lit) {
case L_TEMP: case L_TEMP:
case L_PERM: case L_PERMLIGHT:
return B_TRUE; return B_TRUE;
default: default:
break; break;
@ -2034,16 +2047,23 @@ void makedoor(cell_t *cell) {
} }
void makelit(cell_t *c, enum LIGHTLEV how) { void makelit(cell_t *c, enum LIGHTLEV how, int howlong) {
// don't override permenant light with temp light! // don't override permenant light with temp light!
if ((c->lit == L_PERM) && (how == L_TEMP)) { //if ((c->lit == L_PERMLIGHT) && (how == L_TEMP)) {
if (how == L_TEMP) {
//if ((c->lit == L_PERMLIGHT) || (c->lit == L_PERMDARK)) {
if (c->lit == L_PERMLIGHT) {
return; return;
} else {
c->lit = how;
} }
}
if (howlong > 0) {
c->littimer = howlong;
c->origlit = c->lit;
}
c->lit = how;
} }
void makelitradius(cell_t *c, int radius, enum LIGHTLEV how) { void makelitradius(cell_t *c, int radius, enum LIGHTLEV how, int howlong) {
int x,y; int x,y;
cell_t *c2; cell_t *c2;
@ -2054,7 +2074,7 @@ void makelitradius(cell_t *c, int radius, enum LIGHTLEV how) {
c2 = getcellat(c->map, x, y); c2 = getcellat(c->map, x, y);
if (c2 && (getcelldistorth(c, c2) <= radius)) { if (c2 && (getcelldistorth(c, c2) <= radius)) {
if (cellhaslos(c,c2)) { if (cellhaslos(c,c2)) {
makelit(c2, how); makelit(c2, how,howlong);
} }
} }
} }

4
map.h
View File

@ -50,7 +50,7 @@ int isnewcellok(cell_t *cell, char *err);
int isonmap(map_t *map, int x, int y); int isonmap(map_t *map, int x, int y);
int iswallindir(cell_t *cell, int dir); int iswallindir(cell_t *cell, int dir);
void makedoor(cell_t *cell); void makedoor(cell_t *cell);
void makelit(cell_t *c, enum LIGHTLEV how); void makelit(cell_t *c, enum LIGHTLEV how, int howlong);
void makelitradius(cell_t *c, int radius, enum LIGHTLEV how); void makelitradius(cell_t *c, int radius, enum LIGHTLEV how, int howlong);
void setcelltype(cell_t *cell, int id); void setcelltype(cell_t *cell, int id);
void updateknowncells(void); void updateknowncells(void);

45
move.c
View File

@ -18,6 +18,8 @@ extern lifeform_t *player;
extern int statdirty; extern int statdirty;
extern int needredraw; extern int needredraw;
extern int gamestarted;
extern enum ERROR reason; extern enum ERROR reason;
extern void *rdata; extern void *rdata;
@ -454,6 +456,16 @@ int movelf(lifeform_t *lf, cell_t *newcell) {
} }
} }
// remove grabs
f = lfhasflag(lf, F_GRABBING);
if (f) {
lifeform_t *grabee;
grabee = findlf(NULL, f->val[0]);
assert(grabee);
killflagsofid(grabee->flags, F_GRABBEDBY);
killflagsofid(lf->flags, F_GRABBING);
}
// check ground objects // check ground objects
if (!isairborne(lf)) { if (!isairborne(lf)) {
@ -522,6 +534,7 @@ int movelf(lifeform_t *lf, cell_t *newcell) {
} }
// does anyone else see you? // does anyone else see you?
if (gamestarted) {
for (l = newcell->map->lf ; l ; l = l->next) { for (l = newcell->map->lf ; l ; l = l->next) {
if (l != lf) { if (l != lf) {
if (haslos(l, newcell)) { if (haslos(l, newcell)) {
@ -537,6 +550,7 @@ int movelf(lifeform_t *lf, cell_t *newcell) {
} }
} }
} }
}
return didmsg; return didmsg;
} }
@ -545,6 +559,10 @@ int movelf(lifeform_t *lf, cell_t *newcell) {
// does other game things like telling the player // does other game things like telling the player
// what is here. // what is here.
int moveto(lifeform_t *lf, cell_t *newcell) { int moveto(lifeform_t *lf, cell_t *newcell) {
return real_moveto(lf,newcell,B_FALSE);
}
int real_moveto(lifeform_t *lf, cell_t *newcell, int dontclearmsg) {
char lfname[BUFLEN]; char lfname[BUFLEN];
int didmsg; int didmsg;
@ -553,6 +571,10 @@ int moveto(lifeform_t *lf, cell_t *newcell) {
// actually do the move // actually do the move
didmsg = movelf(lf, newcell); didmsg = movelf(lf, newcell);
if (dontclearmsg) {
didmsg = B_TRUE;
}
// tell player about things // tell player about things
if (!isdead(lf)) { if (!isdead(lf)) {
// some lifeforms can go through things // some lifeforms can go through things
@ -1058,14 +1080,27 @@ int trymove(lifeform_t *lf, int dir) {
taketime(lf, getmovespeed(lf)); taketime(lf, getmovespeed(lf));
break; break;
case E_GRABBEDBY: case E_GRABBEDBY:
if (isplayer(lf)) {
char lfname[BUFLEN];
if (rdata) { if (rdata) {
getlfname((lifeform_t *)rdata, lfname); lifeform_t *grabbedby;
char gbname[BUFLEN];
// skill check to escape.
grabbedby = (lifeform_t *)rdata;
getlfname(grabbedby, gbname);
if (!cell->lf && skillcheckvs(lf, SC_STR, 0, grabbedby, SC_STR, 0)) {
// broke free
killflagsofid(lf->flags, F_GRABBEDBY);
killflagsofid(grabbedby->flags, F_GRABBING);
// move - don't clear the 'you break free from' msg
real_moveto(lf, cell, B_TRUE);
} else { } else {
sprintf(lfname, "whatever is holding you"); if (isplayer(lf)) {
msg("You cannot get away from %s!",gbname);
}
}
} else {
if (isplayer(lf)) {
msg("You cannot get away from whatever is holding you!");
} }
msg("You cannot get away from %s!",lfname);
} }
taketime(lf, getmovespeed(lf)); taketime(lf, getmovespeed(lf));
break; break;

1
move.h
View File

@ -14,6 +14,7 @@ int knockback(lifeform_t *lf, int dir, int howfar, lifeform_t *pusher);
int moveawayfrom(lifeform_t *lf, cell_t *dst); int moveawayfrom(lifeform_t *lf, cell_t *dst);
int movelf(lifeform_t *lf, cell_t *newcell); int movelf(lifeform_t *lf, cell_t *newcell);
int moveto(lifeform_t *lf, cell_t *newcell); int moveto(lifeform_t *lf, cell_t *newcell);
int real_moveto(lifeform_t *lf, cell_t *newcell, int dontclearmsg);
int movetowards(lifeform_t *lf, cell_t *dst); int movetowards(lifeform_t *lf, cell_t *dst);
int opendoorat(lifeform_t *lf, cell_t *c); int opendoorat(lifeform_t *lf, cell_t *c);
int opendoor(lifeform_t *lf, object_t *o); int opendoor(lifeform_t *lf, object_t *o);

49
nexus.c
View File

@ -19,13 +19,16 @@
material_t *material = NULL,*lastmaterial = NULL; material_t *material = NULL,*lastmaterial = NULL;
objectclass_t *objectclass = NULL,*lastobjectclass = NULL; objectclass_t *objectclass = NULL,*lastobjectclass = NULL;
objecttype_t *objecttype = NULL,*lastobjecttype = NULL; objecttype_t *objecttype = NULL,*lastobjecttype = NULL;
brand_t *firstbrand = NULL,*lastbrand = NULL;
obmod_t *firstobmod = NULL,*lastobmod = NULL; obmod_t *firstobmod = NULL,*lastobmod = NULL;
celltype_t *firstcelltype = NULL,*lastcelltype = NULL; celltype_t *firstcelltype = NULL,*lastcelltype = NULL;
command_t *firstcommand = NULL,*lastcommand = NULL; command_t *firstcommand = NULL,*lastcommand = NULL;
race_t *firstrace = NULL,*lastrace = NULL; race_t *firstrace = NULL,*lastrace = NULL;
job_t *firstjob = NULL,*lastjob = NULL; job_t *firstjob = NULL,*lastjob = NULL;
skill_t *firstskill = NULL,*lastskill = NULL;
map_t *firstmap = NULL,*lastmap = NULL; map_t *firstmap = NULL,*lastmap = NULL;
knowledge_t *knowledge = NULL, *lastknowledge = NULL; knowledge_t *knowledge = NULL, *lastknowledge = NULL;
hiddenname_t *firsthiddenname = NULL, *lasthiddenname = NULL;
// maintains unique lifeform ID numbers // maintains unique lifeform ID numbers
long nextlfid = 0; long nextlfid = 0;
@ -311,7 +314,7 @@ void cleanup(void) {
// free maps // free maps
// free knowledge // free knowledge
// free obmods // free brands
// free obtypes // free obtypes
// free objects // free objects
// free materials // free materials
@ -447,7 +450,7 @@ void getrarity(int depth, int *min, int *max, int range) {
//*max = mid + range; if (*max > 100) *max = 100; //*max = mid + range; if (*max > 100) *max = 100;
*max = 100; *max = 100;
if (*min > 75) *min = 75; if (*min > 85) *min = 85;
if (*max < 25) *max = 25; if (*max < 25) *max = 25;
} }
@ -459,6 +462,7 @@ int init(void) {
initcommands(); initcommands();
initobjects(); initobjects();
initskills();
initjobs(); initjobs();
initrace(); initrace();
@ -572,7 +576,10 @@ int rolldie(int ndice, int sides) {
int rollhitdice(lifeform_t *lf) { int rollhitdice(lifeform_t *lf) {
flag_t *f; flag_t *f;
int ndice, plus; int ndice, plus;
int roll; int roll = 0;
int i;
float mod;
int db = B_TRUE;
f = hasflag(lf->flags, F_HITDICE); f = hasflag(lf->flags, F_HITDICE);
if (f) { if (f) {
@ -583,7 +590,33 @@ int rollhitdice(lifeform_t *lf) {
ndice = 1; ndice = 1;
plus = 0; plus = 0;
} }
roll = rolldie(ndice, 4) + plus; if (db && isplayer(lf)) dblog("rollhitdice() - rolling %dd4 + %d",ndice,plus);
mod = getstatmod(lf, A_CON);
if (mod > 0) mod *= 2;
if (db && isplayer(lf)) dblog("rollhitdice() - mod is +%0.0f%%",mod);
if (ndice == 0) {
int thisroll;
// just the bonus
thisroll = plus;
thisroll = thisroll + (int)((float)thisroll * (mod/100));
if (thisroll < 1) thisroll = 1;
roll += thisroll;
} else {
for (i = 0; i < ndice; i++) {
int thisroll;
thisroll = rolldie(1, 4) + plus;
if (thisroll < 1) thisroll = 1;
if (db && isplayer(lf)) dblog("rollhitdice() ---- die %d/%d == %d",i+1,ndice,thisroll);
roll += thisroll;
}
}
if (db && isplayer(lf)) dblog("TOTAL: %d",roll);
roll = roll + (int)((float)roll * (mod/100));
if (db && isplayer(lf)) dblog(" -> modified to: %d",roll);
return roll; return roll;
} }
@ -808,6 +841,14 @@ void timeeffectsworld(map_t *map) {
timeeffectsob(o); timeeffectsob(o);
} // end foreach object here } // end foreach object here
// expire light effects
if (c->littimer > 0) {
c->littimer--;
if (c->littimer == 0) {
c->lit = c->origlit;
}
}
} }
} }
} // end for (y... } // end for (y...

751
objects.c

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,16 @@
#define __OBJECTS_H #define __OBJECTS_H
#include "defs.h" #include "defs.h"
brand_t *addbrand(enum BRAND id, char *suffix, enum BODYPART bp);
object_t *addemptyob(obpile_t *where, object_t *o); object_t *addemptyob(obpile_t *where, object_t *o);
hiddenname_t *addhiddenname(enum OBCLASS obclass, char *text);
knowledge_t *addknowledge(enum OBCLASS id, char *hiddenname, int known); knowledge_t *addknowledge(enum OBCLASS id, char *hiddenname, int known);
material_t *addmaterial(enum MATERIAL id, char *name, float weightrating); material_t *addmaterial(enum MATERIAL id, char *name, float weightrating);
objectclass_t *addoc(enum OBCLASS id, char *name, char *desc, char glyph); objectclass_t *addoc(enum OBCLASS id, char *name, char *desc, char glyph);
object_t *addob(obpile_t *where, char *name); object_t *addob(obpile_t *where, char *name);
object_t *addobject(obpile_t *where, char *name, int canstack); object_t *addobject(obpile_t *where, char *name, int canstack);
int addobburst(cell_t *where, int range, int dirtype, char *name); int addobburst(cell_t *where, int range, int dirtype, char *name);
obmod_t *addobmod(enum OBMOD id, char *suffix, enum BODYPART bp); obmod_t *addobmod(enum OBMOD id, char *prefix);
obpile_t *addobpile(lifeform_t *owner, cell_t *where); obpile_t *addobpile(lifeform_t *owner, cell_t *where);
objecttype_t *addot(int id, char *name, char *description, int material, float weight, int obclassid); objecttype_t *addot(int id, char *name, char *description, int material, float weight, int obclassid);
void adjustdammaterial(unsigned int *dam, enum DAMTYPE damtype, enum MATERIAL mat); void adjustdammaterial(unsigned int *dam, enum DAMTYPE damtype, enum MATERIAL mat);
@ -33,6 +35,7 @@ material_t *findmaterial(int id);
objectclass_t *findoc(int id); objectclass_t *findoc(int id);
object_t *findobbyid(obpile_t *op, long oid); object_t *findobbyid(obpile_t *op, long oid);
object_t *findobl(obpile_t *op, char let); // find object by letter object_t *findobl(obpile_t *op, char let); // find object by letter
brand_t *findbrand(enum BRAND id);
obmod_t *findobmod(enum OBMOD id); obmod_t *findobmod(enum OBMOD id);
objecttype_t *findot(enum OBTYPE id); objecttype_t *findot(enum OBTYPE id);
objecttype_t *findotn(char *name); // find objecttype by name objecttype_t *findotn(char *name); // find objecttype by name
@ -141,7 +144,8 @@ object_t *obexists(enum OBTYPE obid);
void obdie(object_t *o); void obdie(object_t *o);
int obfits(object_t *o, obpile_t *op); int obfits(object_t *o, obpile_t *op);
enum DAMTYPE oblastdamtype(object_t *o); enum DAMTYPE oblastdamtype(object_t *o);
int obmodappliesto(obmod_t *om, objecttype_t *ot); int brandappliesto(brand_t *om, objecttype_t *ot);
int obmatchescondition(object_t *o, long opts);
flag_t *obproduceslight(object_t *o); flag_t *obproduceslight(object_t *o);
int obpropsmatch(object_t *a, object_t *b); int obpropsmatch(object_t *a, object_t *b);
int obotpropsmatch(object_t *a, objecttype_t *b); int obotpropsmatch(object_t *a, objecttype_t *b);

8
save.c
View File

@ -315,8 +315,8 @@ map_t *loadmap(char *basefile) {
*/ */
// cell info // cell info
fscanf(f, "%d,%d,%d,%d,%d\n", fscanf(f, "%d,%d,%d,%d,%d,%d,%d\n",
&c->roomid, &celltypeid, &c->known, &c->visited, &c->lit); &c->roomid, &celltypeid, &c->known, &c->visited, &c->lit, &c->origlit, &c->littimer);
ct = findcelltype(celltypeid); ct = findcelltype(celltypeid);
@ -725,8 +725,8 @@ int savemap(map_t *m) {
cell_t *c; cell_t *c;
c = getcellat(m, x, y); c = getcellat(m, x, y);
// cell info // cell info
fprintf(f, "%d,%d,%d,%d,%d\n", fprintf(f, "%d,%d,%d,%d,%d,%d,%d\n",
c->roomid, c->type->id, c->known, c->visited,c->lit); c->roomid, c->type->id, c->known, c->visited,c->lit,c->origlit,c->littimer);
// cell objects // cell objects
for (o = c->obpile->first ; o ; o = o->next) { for (o = c->obpile->first ; o ; o = o->next) {
fprintf(f, "ob:%ld\n",o->id); fprintf(f, "ob:%ld\n",o->id);

170
spell.c
View File

@ -32,6 +32,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
if (abilid == OT_A_GRAB) { if (abilid == OT_A_GRAB) {
char dirch; char dirch;
flag_t *f; flag_t *f;
char targetname[BUFLEN];
f = lfhasflag(user, F_GRABBING); f = lfhasflag(user, F_GRABBING);
if (f) { if (f) {
@ -68,8 +69,66 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
return B_TRUE; return B_TRUE;
} }
getlfname(target, targetname);
// victim gets a skilcheck to avoid being grabbed
if (skillcheck(target, SC_DODGE, getattr(user, A_DEX)+11, 0)) {
msg("%s evade%s %s%s grasp.", targetname, isplayer(target) ? "" : "s",
username, getpossessive(username));
} else {
addflag(user->flags, F_GRABBING, target->id, NA, NA, NULL); addflag(user->flags, F_GRABBING, target->id, NA, NA, NULL);
addflag(target->flags, F_GRABBEDBY, user->id, NA, NA, NULL); addflag(target->flags, F_GRABBEDBY, user->id, NA, NA, NULL);
}
taketime(user, getactspeed(user));
} else if (abilid == OT_A_CRUSH) {
flag_t *f;
lifeform_t *grabee;
char gbname[BUFLEN];
int dam = 0;
if (isimmobile(user)) {
if (isplayer(user)) msg("You cannot move!");
return B_TRUE;
}
f = lfhasflag(user, F_GRABBING);
if (!f) {
if (isplayer(user)) msg("You need to hold someone before using this ability.");
return B_TRUE;
}
grabee = findlf(NULL, f->val[0]);
assert(grabee);
getlfname(grabee, gbname);
// announce
if (haslos(player, grabee->cell)) {
msg("%s squeeze%s %s tightly!", username, isplayer(user) ? "" : "s", gbname);
}
// victim gets a skilcheck to avoid damage...
if (skillcheckvs(grabee, SC_STR, 0, user, SC_STR, 1)) {
if (haslos(player, grabee->cell)) {
// broke free
killflagsofid(grabee->flags, F_GRABBEDBY);
killflagsofid(user->flags, F_GRABBING);
}
} else {
char killername[BUFLEN];
int str;
// determine damage baesd on crusher's strength
str = getattr(user, A_STR);
dam = modifybystat((str/2), user, A_STR);
// announce
if (haslos(player, grabee->cell)) {
msg("%s %s being crushed!", gbname, isplayer(grabee) ? "are" : "is");
}
real_getlfname(user,killername, B_FALSE);
losehp(grabee, dam, DT_CRUSH, user, killername);
}
taketime(user, getactspeed(user));
} else if (abilid == OT_A_JUMP) { } else if (abilid == OT_A_JUMP) {
lifeform_t *victim = NULL; lifeform_t *victim = NULL;
char victimname[BUFLEN]; char victimname[BUFLEN];
@ -196,10 +255,17 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
} }
return B_TRUE; return B_TRUE;
} }
// TODO: calculate time based on:
// constitution (or max hp?)
// running speed
howlong = 5; howlong = 5;
// modify for constitution
howlong = modifybystat(howlong, user, A_CON);
if (howlong <= 1) {
if (isplayer(user)) {
msg("You are too unfit to sprint.");
}
return B_TRUE;
}
addtempflag(user->flags, F_SPRINTING, B_TRUE, NA, NA, NULL, howlong); addtempflag(user->flags, F_SPRINTING, B_TRUE, NA, NA, NULL, howlong);
} else if (abilid == OT_A_DEBUG) { } else if (abilid == OT_A_DEBUG) {
cell_t *where; cell_t *where;
@ -289,6 +355,71 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
f = addflag(wep->flags, F_HEAVYBLOW, B_TRUE, NA, NA, NULL); f = addflag(wep->flags, F_HEAVYBLOW, B_TRUE, NA, NA, NULL);
attackcell(user, targcell); attackcell(user, targcell);
killflag(f); killflag(f);
} else if (abilid == OT_A_INSPECT) {
object_t *o;
int difficulty;
int rarity;
int mod;
enum SKILLLEVEL slev;
flag_t *f;
// only players can do this
if (!isplayer(user)) {
return B_TRUE;
}
// blind?
if (isblind(user)) {
msg("You must be able to see before you can inspect something.");
return B_TRUE;
}
// ask what to inspect
o = askobject(user->pack, "Inspect which object", NULL, AO_NOTKNOWN);
if (!o) {
msg("Cancelled");
return B_TRUE;
}
if (isknown(o)) {
msg("You already know what that is!");
return B_TRUE;
}
// failed this already?
if (lfhasflagval(user, F_FAILEDINSPECT, o->type->id, NA, NA, NULL)) {
msg("You won't be able to recognise this until you are more experienced.");
return B_TRUE;
}
// skillcheck...
f = hasflag(o->flags, F_RARITY);
if (f) {
rarity = f->val[1];
} else {
rarity = 0;
}
difficulty = 25 + ((100 - rarity) / 5);
slev = getskill(user, SK_RESEARCH);
switch (slev) {
case PR_INEPT:
mod = -5;
break;
default:
mod = slev*4;
break;
}
if (skillcheck(user, SC_IQ, difficulty, mod)) {
char obname[BUFLEN];
// passed!
makeknown(o->type->id);
getobname(o, obname, o->amt);
msgnocap("This seems to be %s!", obname);
} else {
msg("You are not yet sure what this is.");
addflag(user->flags, F_FAILEDINSPECT, o->type->id, NA, NA, NULL);
}
taketime(user, getactspeed(user));
} }
// expire ability // expire ability
@ -706,12 +837,19 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, lifeform_t *target,
return B_TRUE; return B_TRUE;
} }
} else if (spellid == OT_S_DARKNESS) { } else if (spellid == OT_S_DARKNESS) {
if (!targcell) targcell = caster->cell;
// centre on the caster // centre on the caster
if (isplayer(caster) || haslos(player, caster->cell)) { if (haslos(player, targcell)) {
msg("A cloud of darkness descends!"); msg("A cloud of darkness descends!");
if (seenbyplayer) *seenbyplayer = B_TRUE; if (seenbyplayer) *seenbyplayer = B_TRUE;
} }
makelitradius(caster->cell, 10, L_DARK); if (blessed) {
// permenant darkness
makelitradius(targcell, 10, L_PERMDARK, -1);
} else {
// temporary darkness
makelitradius(targcell, 10, L_PERMDARK, rnd(5,10) );
}
} else if (spellid == OT_S_DETECTAURA) { } else if (spellid == OT_S_DETECTAURA) {
if (isplayer(caster)) { if (isplayer(caster)) {
object_t *o; object_t *o;
@ -1941,12 +2079,21 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, lifeform_t *target,
} }
} else if (spellid == OT_S_LIGHT) { } else if (spellid == OT_S_LIGHT) {
lifeform_t *l; lifeform_t *l;
if (!targcell) targcell = caster->cell;
// centre light on the caster // centre light on the caster
if (isplayer(caster) || haslos(player, caster->cell)) { if (haslos(player, targcell)) {
msg("The area is lit by a magical light!"); msg("The area is lit by a magical light!");
if (seenbyplayer) *seenbyplayer = B_TRUE; if (seenbyplayer) *seenbyplayer = B_TRUE;
} }
makelitradius(caster->cell, 10, L_PERM); if (blessed) {
// permenant light
makelitradius(targcell, 10, L_PERMLIGHT, -1);
} else {
// temporary light
makelitradius(targcell, 10, L_PERMLIGHT, rnd(5,10) );
}
// blind anyone with nightvis who sees it // blind anyone with nightvis who sees it
// (player last) // (player last)
@ -1975,6 +2122,11 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, lifeform_t *target,
} }
} }
// anyone there glows
if ((targcell != caster->cell) && targcell->lf) {
addtempflag(targcell->lf->flags, F_PRODUCESLIGHT, B_TRUE, NA, NA, NULL, rnd(10,20));
}
} else if (spellid == OT_S_GRAVBOOST) { } else if (spellid == OT_S_GRAVBOOST) {
// ask for target // ask for target
if (!target) { if (!target) {
@ -2413,12 +2565,12 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, lifeform_t *target,
} }
} else { } else {
// couldn't make it appear // couldn't make it appear
msg("The air in front of %s seems to ripple for a while.", lfname); msg("The air in front of %s seems to ripple for a moment.", lfname);
} }
} }
} else { } else {
// couldn't make it appear - ob doesn't exist // couldn't make it appear - ob doesn't exist
msg("The air in front of %s seems to ripple for a moment.", lfname); msg("The air in front of %s seems to ripple for a while.", lfname);
} }
} else { } else {
// monsters can't wish // monsters can't wish

35
text.c
View File

@ -342,6 +342,41 @@ int strpixmatch(char *haystack, char *needle) {
return matched; return matched;
} }
int texttodice(char *text, int *ndice, int *nsides, int *bonus) {
char *dummy;
char *localtext;
char *p;
localtext = strdup(text);
// number of dice
p = strtok_r(localtext, "d", &dummy);
if (!p) {
return B_TRUE;
}
if (ndice) {
*ndice = atoi(p);
}
// sides on each die
p = strtok_r(NULL, "d", &dummy);
if (!p) {
return B_TRUE;
}
if (nsides) {
*nsides = atoi(p);
}
// bonus/plus
if (bonus) {
p = strtok_r(NULL, "+", &dummy);
if (p) {
*bonus = atoi(p);
} else {
*bonus = 0;
}
}
free(localtext);
return B_FALSE;
}
char *you(lifeform_t *lf) { char *you(lifeform_t *lf) {
if (isplayer(lf)) { if (isplayer(lf)) {
return "You"; return "You";

1
text.h
View File

@ -15,6 +15,7 @@ void splittime(int *hours, int *mins, int *secs);
char *strrep(char *text, char *oldtok, char *newtok, int *rv); char *strrep(char *text, char *oldtok, char *newtok, int *rv);
char *dostrrep(char* in, char** out, char* oldtok, char* newtok, int *rv); char *dostrrep(char* in, char** out, char* oldtok, char* newtok, int *rv);
int strpixmatch(char *haystack, char *needle); int strpixmatch(char *haystack, char *needle);
int texttodice(char *text, int *ndice, int *nsides, int *bonus);
char *you(lifeform_t *lf); char *you(lifeform_t *lf);
char *you_l(lifeform_t *lf); char *you_l(lifeform_t *lf);
char *your(lifeform_t *lf); char *your(lifeform_t *lf);