- [+] sleeping mosnters aren't waking up soon enough!!! make difficulty
of listen check easier. - [+] they tend to only wake when i'm 1 sq away - [+] get rid of sprintf - [+] replace all with snprintf via macro - [+] then search for HUGEBUFLEN etc and fix up - [+] compile with -O2, fix up warnings. - [+] gaze attacks (ie eyebat, beholder) now need 2way los, and glasses will protect you - [+] use "wrapprint" to show physical props in @@ - [+] glowbugs should flash upon death - [+] should stop gaze attacks (like eyebat) - [+] golden cobra - acidspit at eyes - [+] bright flash (glowbug, and make some of them hostile) - [+] flashbangs (make them more common) - [+] combine tracking with searching and call it "Perception" - [+] replace all occurences of SK_xxx - [+] replace skillcheck (or make it use different skill)
This commit is contained in:
parent
b1b8e2506a
commit
c181893ae4
3
Makefile
3
Makefile
|
@ -1,2 +1,5 @@
|
|||
nexus: Makefile defs.h nexus.c nexus.h ai.c ai.h attack.c attack.h flag.c flag.h god.c god.h io.c io.h lf.c lf.h map.c map.h move.c move.h objects.c objects.h text.c text.h save.c save.h spell.c spell.h vault.c vault.h
|
||||
gcc -Wall -g -pg -o nexus nexus.c ai.c attack.c flag.c god.c io.c lf.c map.c move.c objects.c text.c save.c spell.c vault.c vault.h -lncurses -lsqlite3
|
||||
|
||||
check: Makefile defs.h nexus.c nexus.h ai.c ai.h attack.c attack.h flag.c flag.h god.c god.h io.c io.h lf.c lf.h map.c map.h move.c move.h objects.c objects.h text.c text.h save.c save.h spell.c spell.h vault.c vault.h
|
||||
splint -onlytrans -nullret -nullstate -branchstate -usedef -type -retvalint -retvalother +posixlib -unrecog -boolops -mustfreefresh -predboolint -unqualifiedtrans -compdef *.c
|
||||
|
|
59
ai.c
59
ai.c
|
@ -110,12 +110,11 @@ int aiattack(lifeform_t *lf, lifeform_t *victim, int timelimit) {
|
|||
|
||||
enum OBTYPE aigetattackspell(lifeform_t *lf, lifeform_t *victim) {
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
flag_t *f;
|
||||
enum OBTYPE poss[MAXPILEOBS];
|
||||
int nposs = 0;
|
||||
int nposs = 0,i;
|
||||
int db = B_FALSE;
|
||||
int castok = B_TRUE;
|
||||
|
||||
if (lfhasflag(lf, F_DEBUG)) {
|
||||
db = B_TRUE;
|
||||
|
@ -123,11 +122,26 @@ enum OBTYPE aigetattackspell(lifeform_t *lf, lifeform_t *victim) {
|
|||
|
||||
f = lfhasflag(lf, F_NEEDOBFORSPELLS);
|
||||
if (f && !hasob(lf->pack, f->val[0])) {
|
||||
castok = B_FALSE;
|
||||
if (db) dblog(".oO { Cannot cast spell, I don't have my spellcast object }");
|
||||
return OT_NONE;
|
||||
}
|
||||
f = lfhasflag(lf, F_CASTTYPE);
|
||||
if (f) {
|
||||
switch (f->val[0]) {
|
||||
case CT_GAZE: // gaze into victim's eyes: they must be able to see you and vice versa
|
||||
if (!cansee(victim, lf) || !cansee(lf, victim)) {
|
||||
if (db) dblog(".oO { Cannot cast spell, no 2way los for gaze attack or victims eyes covered }");
|
||||
return OT_NONE;
|
||||
}
|
||||
break;
|
||||
case CT_EYESPIT: // spit into the victim's eyes. lof is checked in aispellok
|
||||
if (!cansee(victim, lf) ) {
|
||||
if (db) dblog(".oO { Cannot cast spell, no 2way los for gaze attack or victims eyes covered }");
|
||||
return OT_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (castok) {
|
||||
int i;
|
||||
|
||||
getflags(lf->flags, retflag, &nretflags, F_CANCAST, F_CANWILL, F_NONE);
|
||||
for (i = 0; i < nretflags; i++) {
|
||||
|
@ -137,7 +151,6 @@ enum OBTYPE aigetattackspell(lifeform_t *lf, lifeform_t *victim) {
|
|||
nposs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// select a random one
|
||||
if (nposs > 0) {
|
||||
|
@ -159,9 +172,9 @@ enum OBTYPE aigetfleespell(lifeform_t *lf) {
|
|||
enum OBTYPE poss[MAXPILEOBS];
|
||||
int nposs = 0,i;
|
||||
int db = B_FALSE;
|
||||
lifeform_t *fleefrom;
|
||||
lifeform_t *fleefrom = NULL;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (lfhasflag(lf, F_DEBUG)) {
|
||||
db = B_TRUE;
|
||||
|
@ -193,7 +206,7 @@ enum OBTYPE aigetfleespell(lifeform_t *lf) {
|
|||
|
||||
// this function assumes that you can't just SEE the target!
|
||||
cell_t *aigetlastknownpos(lifeform_t *lf, lifeform_t *target, int *lastx, int *lasty, int *lastdir) {
|
||||
flag_t *f, *tflag, *bestflag;
|
||||
flag_t *f, *tflag, *bestflag = NULL;
|
||||
cell_t *c = NULL;
|
||||
int besttime = -1;
|
||||
int i;
|
||||
|
@ -208,7 +221,7 @@ cell_t *aigetlastknownpos(lifeform_t *lf, lifeform_t *target, int *lastx, int *l
|
|||
}
|
||||
}
|
||||
}
|
||||
if (c) {
|
||||
if (bestflag && c) {
|
||||
if (lastx) *lastx = c->x;
|
||||
if (lasty) *lasty = c->y;
|
||||
if (lastdir) {
|
||||
|
@ -456,9 +469,9 @@ flag_t *aigoto(lifeform_t *lf, cell_t *c, enum MOVEREASON why, void *data, int t
|
|||
killflagsofid(lf->flags, F_TARGETCELL);
|
||||
|
||||
if (why == MR_LF) {
|
||||
sprintf(whybuf, "%d", ((lifeform_t *)data)->id);
|
||||
snprintf(whybuf, BUFLEN, "%d", ((lifeform_t *)data)->id);
|
||||
} else if (why == MR_OB) {
|
||||
sprintf(whybuf, "%ld", ((object_t *)data)->id);
|
||||
snprintf(whybuf, BUFLEN, "%ld", ((object_t *)data)->id);
|
||||
} else {
|
||||
strcpy(whybuf, "");
|
||||
}
|
||||
|
@ -923,7 +936,7 @@ void aiturn(lifeform_t *lf) {
|
|||
enum ATTRBRACKET iqb;
|
||||
int n,i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1490,6 +1503,18 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG
|
|||
needlof = f->val[1];
|
||||
}
|
||||
}
|
||||
// override needlos/lof based on cast type
|
||||
f = lfhasflag(lf, F_CASTTYPE);
|
||||
if (f) {
|
||||
switch (f->val[0]) {
|
||||
case CT_GAZE:
|
||||
needlos = B_TRUE;
|
||||
break;
|
||||
case CT_EYESPIT:
|
||||
needlof = LOF_NEED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// enough mp etc?
|
||||
if (!cancast(lf, spellid, NULL)) {
|
||||
|
@ -1535,7 +1560,7 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG
|
|||
int range;
|
||||
switch (f->val[0]) {
|
||||
case ST_VICTIM:
|
||||
range = getspellrange(spellid, getspellpower(lf, spellid));
|
||||
range = getspellrange(lf, spellid, getspellpower(lf, spellid));
|
||||
if ((range == UNLIMITED) || (getcelldist(lf->cell, victim->cell) <= range)) {
|
||||
if (db) {
|
||||
dblog(".oO { spell possibility: %s }", ot ? ot->name : "?unkownspell?");
|
||||
|
@ -2045,7 +2070,7 @@ void makewantedoblist(lifeform_t *lf, int *noids, enum OBTYPE *oid, int *oidcove
|
|||
int i;
|
||||
flag_t *f;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
// construct a list of objects which we want
|
||||
*noids = 0;
|
||||
|
|
63
attack.c
63
attack.c
|
@ -166,7 +166,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
|
|||
flag_t *sf;
|
||||
int saysorry = B_FALSE;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
// anyone there? if so just attack.
|
||||
if (c->lf) {
|
||||
|
@ -177,13 +177,13 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
|
|||
getlfname(c->lf, victimname);
|
||||
switch (getallegiance(c->lf)) {
|
||||
case AL_PEACEFUL:
|
||||
sprintf(buf, "Really attack the peaceful %s?",noprefix(victimname));
|
||||
snprintf(buf, BUFLEN, "Really attack the peaceful %s?",noprefix(victimname));
|
||||
break;
|
||||
case AL_FRIENDLY:
|
||||
sprintf(buf, "Really attack the allied %s?",noprefix(victimname));
|
||||
snprintf(buf, BUFLEN, "Really attack the allied %s?",noprefix(victimname));
|
||||
break;
|
||||
default:
|
||||
sprintf(buf, "Really attack the allied %s?",noprefix(victimname));
|
||||
snprintf(buf, BUFLEN, "Really attack the allied %s?",noprefix(victimname));
|
||||
break;
|
||||
}
|
||||
ch = askchar(buf, "yn","n", B_TRUE);
|
||||
|
@ -212,7 +212,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
|
|||
char ch;
|
||||
real_getobname(o, obname, o->amt, B_FALSE, B_FALSE, B_TRUE, B_FALSE, B_FALSE);
|
||||
getobname(priwep, wepname, priwep->amt);
|
||||
sprintf(buf, "Attacking %s might damage your %s. Proceed?", obname, noprefix(wepname));
|
||||
snprintf(buf, BUFLEN, "Attacking %s might damage your %s. Proceed?", obname, noprefix(wepname));
|
||||
ch = askchar(buf, "yn","n", B_TRUE);
|
||||
if (ch == 'n') {
|
||||
// cancel.
|
||||
|
@ -424,7 +424,7 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
|
|||
sayphrase(lf, SP_SORRY, -1, NA, NULL);
|
||||
}
|
||||
|
||||
if (lfhasflagval(lf, F_INJURY, BP_HANDS, DT_SLASH, NA, NULL)) {
|
||||
if (lfhasflagval(lf, F_INJURY, NA, BP_HANDS, DT_SLASH, NULL)) {
|
||||
bleed(lf);
|
||||
losehp(lf, 1, DT_DIRECT, NULL, "blood loss");
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
int isunarmed = B_FALSE;
|
||||
skill_t *wepsk = NULL;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
int aidb = B_FALSE;
|
||||
flag_t *f;
|
||||
enum BODYPART critpos = BP_NONE;
|
||||
|
@ -537,10 +537,10 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
critpos = getrandomcorebp(victim);
|
||||
// replace victicname to include body part
|
||||
if ((lf == victim) && !isplayer(lf)) {
|
||||
sprintf(victimbpname, "its %s", getbodypartname(critpos));
|
||||
snprintf(victimbpname, BUFLEN, "its %s", getbodypartname(critpos));
|
||||
} else {
|
||||
getlfname(victim, buf);
|
||||
sprintf(victimbpname, "%s%s %s", buf, getpossessive(buf), getbodypartname(critpos));
|
||||
snprintf(victimbpname, BUFLEN, "%s%s %s", buf, getpossessive(buf), getbodypartname(critpos));
|
||||
}
|
||||
} else {
|
||||
strcpy(victimbpname, "");
|
||||
|
@ -801,7 +801,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
strcpy(extradambuf, "");
|
||||
|
||||
if (wep && !ismeleeweapon(wep)) {
|
||||
sprintf(withwep, " with %s", wepname);
|
||||
snprintf(withwep, BUFLEN, " with %s", wepname);
|
||||
} else {
|
||||
strcpy(withwep, "");
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
strcpy(extradambuf, " ineffectually");
|
||||
}
|
||||
} else if (lfhasflag(player, F_EXTRAINFO) || lfhasflag(player, F_OMNIPOTENT) ) {
|
||||
sprintf(extradambuf, " [%d dmg]",dam[i]);
|
||||
snprintf(extradambuf, BUFLEN, " [%d dmg]",dam[i]);
|
||||
}
|
||||
|
||||
if (backstab && (i == 0)) {
|
||||
|
@ -846,7 +846,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
if (needfree) {
|
||||
free(verb);
|
||||
}
|
||||
} else {
|
||||
} else { // ie. the attacker is a monster
|
||||
if (cansee(player, lf) || isplayer(victim)) {
|
||||
char withwep[BUFLEN];
|
||||
char attackverb[BUFLEN];
|
||||
|
@ -858,7 +858,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
capitalise(buf);
|
||||
|
||||
if (wep && !isunarmed && (lf->race->id != R_DANCINGWEAPON) && cansee(player, lf)) {
|
||||
sprintf(withwep, " with %s", wepname);
|
||||
snprintf(withwep, BUFLEN, " with %s", wepname);
|
||||
} else {
|
||||
strcpy(withwep, "");
|
||||
}
|
||||
|
@ -875,9 +875,11 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
needses(attackverb) ? "es" : "s",
|
||||
usecrittext ? victimbpname : victimname,withwep, nodamstr);
|
||||
}
|
||||
if (!isplayer(victim)) {
|
||||
noise(lf->cell, lf, NC_OTHER, 3, "sounds of fighting.", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (willheal) {
|
||||
|
@ -915,7 +917,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
if (wep && !isunarmed) {
|
||||
char wepname[BUFLEN];
|
||||
getobname(wep, wepname, 1);
|
||||
sprintf(buf, "%s^%s %s",attackername2,
|
||||
snprintf(buf, BUFLEN, "%s^%s %s",attackername2,
|
||||
(lf == victim) ? "using" : "weilding",
|
||||
wepname);
|
||||
} else {
|
||||
|
@ -991,7 +993,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
}
|
||||
if (nmatched >= f->val[2]) {
|
||||
char damstring[BUFLEN];
|
||||
sprintf(damstring, "%s pack", lfname);
|
||||
snprintf(damstring, BUFLEN, "%s pack", lfname);
|
||||
losehp(victim, f->val[0], f->val[1], lf, damstring);
|
||||
if (isplayer(victim) || cansee(player, victim)) {
|
||||
msg("%c%s pack attacks %s!", isplayer(victim) ? 'b' : 'c', lfname, victimname);
|
||||
|
@ -1050,7 +1052,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
getattackverb(victim, NULL, f->val[2], rdam, lf->maxhp),
|
||||
attackername);
|
||||
}
|
||||
sprintf(damstring, "%s%s %s", victimname, getpossessive(victimname), noprefix(f->text));
|
||||
snprintf(damstring, BUFLEN, "%s%s %s", victimname, getpossessive(victimname), noprefix(f->text));
|
||||
losehp(lf, rdam, f->val[2], victim, damstring);
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1070,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
}
|
||||
} else if (lfhasflag(victim, F_MAGSHIELD) && ismetal(wep->material->id)) {
|
||||
if (isplayer(lf) || cansee(player, lf)) {
|
||||
sprintf(buf, "%s",attackername);
|
||||
snprintf(buf, BUFLEN, "%s",attackername);
|
||||
|
||||
msg("^w%s%s magnetic shield repels %s%s attack.", victimname, getpossessive(victimname),
|
||||
buf, getpossessive(buf));
|
||||
|
@ -1079,7 +1081,7 @@ int attacklf(lifeform_t *lf, lifeform_t *victim, object_t *wep, flag_t *damflag)
|
|||
} else {
|
||||
if (cansee(player, lf)) {
|
||||
// capitalise first letter
|
||||
sprintf(buf, "%s",attackername);
|
||||
snprintf(buf, BUFLEN, "%s",attackername);
|
||||
|
||||
msg("%s misses %s.", buf, victimname);
|
||||
}
|
||||
|
@ -1247,7 +1249,7 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
|
|||
if (isplayer(lf)) {
|
||||
char extradambuf[BUFLEN];
|
||||
if (lfhasflag(player, F_EXTRAINFO) || lfhasflag(player, F_OMNIPOTENT) ) {
|
||||
sprintf(extradambuf, " [%d dmg]",dam[i]);
|
||||
snprintf(extradambuf, BUFLEN, " [%d dmg]",dam[i]);
|
||||
} else {
|
||||
strcpy(extradambuf, "");
|
||||
}
|
||||
|
@ -1257,7 +1259,7 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
|
|||
char withwep[BUFLEN];
|
||||
|
||||
if (wep && !isunarmed && !isblind(player)) { // announce weapon used
|
||||
sprintf(withwep, " with %s", wepname);
|
||||
snprintf(withwep, BUFLEN, " with %s", wepname);
|
||||
} else {
|
||||
strcpy(withwep, "");
|
||||
}
|
||||
|
@ -1276,7 +1278,7 @@ int attackob(lifeform_t *lf, object_t *o, object_t *wep, flag_t *damflag) {
|
|||
// ok
|
||||
} else {
|
||||
char buf[BUFLEN];
|
||||
sprintf(buf, "punching %s", obname);
|
||||
snprintf(buf, BUFLEN, "punching %s", obname);
|
||||
if ( losehp(lf, 1, DT_BASH, lf, buf)) {
|
||||
if (isplayer(lf)) {
|
||||
msg("^bOw!");
|
||||
|
@ -1326,7 +1328,6 @@ void criticalhit(lifeform_t *lf, lifeform_t *victim, enum BODYPART hitpos, enum
|
|||
object_t *o;
|
||||
// replace some dam types
|
||||
if (damtype == DT_UNARMED) damtype = DT_BASH;
|
||||
|
||||
if (damtype == DT_BITE) damtype = DT_SLASH;
|
||||
if (damtype == DT_PIERCE) damtype = DT_SLASH;
|
||||
if (damtype == DT_CHOP) damtype = DT_SLASH;
|
||||
|
@ -1459,7 +1460,7 @@ char *getattackverb(lifeform_t *lf, object_t *wep, enum DAMTYPE damtype, int dam
|
|||
float pct;
|
||||
enum LFSIZE ownersize = SZ_HUMAN;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (lf) {
|
||||
ownersize = getlfsize(lf);
|
||||
|
@ -1649,7 +1650,7 @@ int getextradamlf(lifeform_t *lf, int *dam, enum DAMTYPE *damtype, int *ndam) {
|
|||
flag_t *f;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
// special case - EXTRADAM goes onto INITIAL dam[] if the same type, rather than
|
||||
// adding a new one.
|
||||
getflags(lf->flags, retflag, &nretflags, F_EXTRADAM, F_NONE);
|
||||
|
@ -1697,7 +1698,7 @@ int getextradamwep(object_t *wep, int *dam, enum DAMTYPE *damtype, int *ndam) {
|
|||
flag_t *f;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
getflags(wep->flags, retflag, &nretflags, F_FROZEN, F_ONFIRE, F_NONE);
|
||||
for (i = 0; i < nretflags; i++) {
|
||||
f = retflag[i];
|
||||
|
@ -1734,7 +1735,7 @@ char *getkillverb(lifeform_t *victim, object_t *wep, enum DAMTYPE damtype, int d
|
|||
flag_t *f;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
getflags(wep->flags, retflag, &nretflags, F_KILLVERB, F_NONE);
|
||||
for (i = 0; i < nretflags; i++) {
|
||||
f = retflag[i];
|
||||
|
@ -1863,7 +1864,7 @@ int getdamroll(object_t *o, lifeform_t *victim, flag_t *damflag) {
|
|||
}
|
||||
|
||||
if (victim) {
|
||||
if (lfhasflagval(victim, F_INJURY, BP_BODY, DT_SLASH, NA, NULL)) {
|
||||
if (lfhasflagval(victim, F_INJURY, NA, BP_BODY, DT_SLASH, NULL)) {
|
||||
// extra damage
|
||||
dam += rnd(1,2);
|
||||
}
|
||||
|
@ -2130,7 +2131,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam) {
|
|||
object_t *wep;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (!where) return;
|
||||
|
||||
|
@ -2195,7 +2196,7 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam) {
|
|||
f->known = B_TRUE;
|
||||
}
|
||||
|
||||
sprintf(damstring, "%s%s blast of revenge",buf2, getpossessive(buf2));
|
||||
snprintf(damstring, BUFLEN, "%s%s blast of revenge",buf2, getpossessive(buf2));
|
||||
losehp(victim, extradam, DT_DIRECT, owner, damstring);
|
||||
}
|
||||
} // end if dampct > 50
|
||||
|
@ -2297,12 +2298,12 @@ void wepeffects(flagpile_t *fp, cell_t *where, flag_t *damflag, int dam) {
|
|||
getlfnamea(owner, lfname);
|
||||
getobname(wep, wepname, 1);
|
||||
// ie. "a goblin's poisoned short sword"
|
||||
sprintf(frombuf, "%s%s %s",lfname,getpossessive(lfname), wepname);
|
||||
snprintf(frombuf, BUFLEN, "%s%s %s",lfname,getpossessive(lfname), wepname);
|
||||
} else {
|
||||
char wepname[BUFLEN];
|
||||
getobname(wep, wepname, 1);
|
||||
// ie "a poisoned short sword"
|
||||
sprintf(frombuf, "%s", wepname);
|
||||
snprintf(frombuf, BUFLEN, "%s", wepname);
|
||||
}
|
||||
} else {
|
||||
strcpy(frombuf, "something unknown");
|
||||
|
|
37
defs.h
37
defs.h
|
@ -48,6 +48,7 @@
|
|||
#define B_MAYCHASE (-1)
|
||||
#define B_NODOORS (0)
|
||||
#define B_DONTKILL (-1)
|
||||
#define B_APPENDYOU (-1)
|
||||
|
||||
//#define B_TEMP (-1)
|
||||
//#define B_PERM (-2)
|
||||
|
@ -253,6 +254,7 @@
|
|||
#define PCT (65432) // must be POSITIVE
|
||||
#define RANDOM (-2610)
|
||||
#define AUTO (-7654)
|
||||
#define HEAVYWEPKG (5)
|
||||
|
||||
// Time periods
|
||||
#define TM_DRUNKTIME (10) // how long it takes for alcohol to wear off
|
||||
|
@ -320,6 +322,11 @@ enum COLOUR {
|
|||
};
|
||||
#define BLUEBG 50
|
||||
|
||||
enum CASTTYPE {
|
||||
CT_NORMAL = 0,
|
||||
CT_GAZE,
|
||||
CT_EYESPIT
|
||||
};
|
||||
|
||||
enum NOISECLASS {
|
||||
NC_NONE = 0,
|
||||
|
@ -793,7 +800,8 @@ enum RACE {
|
|||
R_RAT,
|
||||
R_SNAKE,
|
||||
R_SNAKECARPET,
|
||||
R_SNAKECOBRA,
|
||||
R_SNAKECOBRABLACK,
|
||||
R_SNAKECOBRAGOLDEN,
|
||||
R_SNAKECONSTRICTOR,
|
||||
R_SNAKETREE,
|
||||
R_SNAKEWATER,
|
||||
|
@ -1595,6 +1603,7 @@ enum FLAG {
|
|||
F_NEWWATERDEPTH, // temp flag for the spread of f_deepwater obs.
|
||||
// v0+1 are x/y, v2 is new depth.
|
||||
// object flags
|
||||
F_BEINGUSED, // this object is currently being used
|
||||
F_DEAD, // object will be removed
|
||||
F_ONEPERCELL, // only one of these objects can exist per cell
|
||||
F_CREATEDBY, // object was made by lf id v0, text=real lfname
|
||||
|
@ -2096,6 +2105,8 @@ enum FLAG {
|
|||
F_SPELLCASTTEXT, // text is announcement for spellcast
|
||||
// if text is empty, then don't announce
|
||||
// this lf's spell casting at all.
|
||||
// if v2 is 'appendyou' " at xxx" will
|
||||
// be appended.
|
||||
F_NODEATHANNOUNCE, // don't say 'the xx dies' if this lf dies
|
||||
F_BEHEADED, // use special corpse drop code
|
||||
F_MOVESPEED, // override default move speed
|
||||
|
@ -2168,6 +2179,9 @@ enum FLAG {
|
|||
F_BLIND, // cannot see anything
|
||||
F_DEAF, // cannot hear
|
||||
F_NEEDOBFORSPELLS, // lf can only cast spells if it has object v0
|
||||
F_CASTTYPE, // lf uses enum CASTTYPE v0 for spells
|
||||
// optional v1 is colour for casttype-based animations
|
||||
// (ie. spit spells)
|
||||
F_CAFFEINATED, // can't sleep.
|
||||
F_CANCAST, // can cast the spell val0 (need MP)
|
||||
F_CANHEARLF, // you can hear lifeform id v0 (show their glyph)
|
||||
|
@ -2184,6 +2198,7 @@ enum FLAG {
|
|||
// dam:xdy+b; damage
|
||||
// needgrab:xx; do you need to grab first?
|
||||
// range:xx;
|
||||
// gaze (this is a gaze spell)
|
||||
F_CHARMEDBY,// you've been charmed by lf id v0
|
||||
F_CONTROL,// you control polymorphs, teleports and createmonsters
|
||||
F_DETECTAURAS, // autodetect bless/curse
|
||||
|
@ -2222,7 +2237,8 @@ enum FLAG {
|
|||
F_HIDING, // lifeform is hiding. v0 is modifier to stealth checks.
|
||||
F_ICESLIDE, // lf has "slide" spell active.
|
||||
// v0 = timeleft (since 'lifetime' is used for FROMSPELL)
|
||||
F_INJURY, // v0 = where, v1 = damtype
|
||||
F_INJURY, // v0 = enum injury, v1 = where (enum bp), v2 = damtype
|
||||
// text is desc, ie "rib is cracked"
|
||||
F_INVISIBLE, // lifeform is invisible
|
||||
F_INVULNERABLE,// immune to most damage
|
||||
// this can apply to objects too!
|
||||
|
@ -2384,6 +2400,22 @@ enum HUNGER {
|
|||
H_STARVED = 5
|
||||
};
|
||||
|
||||
// injuries
|
||||
enum INJURY {
|
||||
IJ_NONE,
|
||||
IJ_BLACKEYE,
|
||||
IJ_CHESTBLEED,
|
||||
IJ_FINGERBROKEN,
|
||||
IJ_HANDBLEED,
|
||||
IJ_LEGBLEED,
|
||||
IJ_LEGBROKEN,
|
||||
IJ_LEGBRUISE,
|
||||
IJ_RIBCRACKED,
|
||||
IJ_SHOULDERDISLOCATED,
|
||||
IJ_TENDONCUT,
|
||||
};
|
||||
|
||||
|
||||
#define PIETYPRAYLOSS 75
|
||||
|
||||
#define PIETY_MIN -200
|
||||
|
@ -2483,6 +2515,7 @@ enum ERROR {
|
|||
E_PENTAGRAM,
|
||||
E_SWIMMING,
|
||||
E_DANGEROUS,
|
||||
E_INJURED,
|
||||
};
|
||||
|
||||
|
||||
|
|
9
flag.c
9
flag.c
|
@ -216,7 +216,7 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
|
||||
ob = findobbyid(f->pile->owner->pack, f->obfrom);
|
||||
if (ob) {
|
||||
flag_t *f2;
|
||||
flag_t *f2 = NULL;
|
||||
switch (f->lifetime) {
|
||||
case FROMOBEQUIP:
|
||||
f2 = hasflagval(ob->flags, F_EQUIPCONFER, f->id, NA, NA, NULL);
|
||||
|
@ -352,6 +352,8 @@ int countflags(flagpile_t *fp) {
|
|||
|
||||
int flagcausesloscalc(enum FLAG fid) {
|
||||
switch (fid) {
|
||||
case F_ASLEEP:
|
||||
case F_BLIND:
|
||||
case F_BLOCKSVIEW:
|
||||
case F_PRONE:
|
||||
return B_TRUE;
|
||||
|
@ -444,12 +446,13 @@ flag_t *hasflagknown(flagpile_t *fp, int id) {
|
|||
flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception) {
|
||||
flag_t *f,*foundflag = NULL, *searchfrom = NULL;
|
||||
lifeform_t *owner;
|
||||
owner = fp->owner;
|
||||
int pos;
|
||||
int l,r;
|
||||
int iter = 0,subiter = 0;
|
||||
int db = B_FALSE;
|
||||
|
||||
owner = fp->owner;
|
||||
|
||||
if (flagdb) db = B_TRUE;
|
||||
|
||||
if (db) dblog("hasflag %d in flagpile with %d entries", id, fp->nitems);
|
||||
|
@ -558,11 +561,11 @@ int getcounter(flagpile_t *fp) {
|
|||
flag_t *hasflagval_real(flagpile_t *fp, int id, int val1, int val2, int val3, char *text, int wantknown) {
|
||||
flag_t *f,*foundflag = NULL, *searchfrom = NULL;
|
||||
lifeform_t *owner;
|
||||
owner = fp->owner;
|
||||
int pos;
|
||||
int l,r;
|
||||
int iter = 0;
|
||||
int db = B_FALSE;
|
||||
owner = fp->owner;
|
||||
|
||||
if (flagdb) db = B_TRUE;
|
||||
|
||||
|
|
19
flag.h
19
flag.h
|
@ -2,11 +2,11 @@
|
|||
|
||||
|
||||
// functions
|
||||
altflagval_t *addaltval(flag_t *f, enum FLAG id, int val1, int val2, int val3, char *text);
|
||||
altflagval_t *addaltval(flag_t *f, enum FLAG id, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
void addcondition(flag_t *f, enum FLAGCONDITION fc, int chance);
|
||||
flag_t *addflag(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, char *text);
|
||||
flag_t *addtempflag(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, char *text, int timeleft);
|
||||
flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, char *text, int lifetime, int known, long obfromid);
|
||||
flag_t *addflag(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
flag_t *addtempflag(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, /*@null@*/ char *text, int timeleft);
|
||||
flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, /*@null@*/ char *text, int lifetime, int known, long obfromid);
|
||||
flagpile_t *addflagpile(lifeform_t *owner, object_t *o);
|
||||
void changeflagtext(flag_t *f, char *newtext);
|
||||
void copyflag(flagpile_t *dst, flagpile_t *src, enum FLAG id);
|
||||
|
@ -18,22 +18,21 @@ int flagcausesstatredraw(lifeform_t *lf, enum FLAG fid);
|
|||
int flagstacks(enum FLAG fid);
|
||||
cell_t *getflagpilelocation(flagpile_t *fp);
|
||||
int getflags(flagpile_t *fp, flag_t **retflag, int *nretflags, ... );
|
||||
int modcounter(flagpile_t *fp, int amt);
|
||||
flag_t *hasflag(flagpile_t *fp, int id);
|
||||
flag_t *hasflagknown(flagpile_t *fp, int id);
|
||||
flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception);
|
||||
flag_t *hasflagval(flagpile_t *fp, int id, int val1, int val2, int val3, char *text);
|
||||
flag_t *hasflagvalknown(flagpile_t *fp, int id, int val1, int val2, int val3, char *text);
|
||||
flag_t *hasflagval_real(flagpile_t *fp, int id, int val1, int val2, int val3, char *text, int wantknown);
|
||||
flag_t *hasflagval(flagpile_t *fp, int id, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
flag_t *hasflagvalknown(flagpile_t *fp, int id, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
flag_t *hasflagval_real(flagpile_t *fp, int id, int val1, int val2, int val3, /*@null@*/ char *text, int wantknown);
|
||||
int istransitoryflag(flag_t *f);
|
||||
int killflagsofid(flagpile_t *fp, enum FLAG fid);
|
||||
void killflag(flag_t *f);
|
||||
void killflagpile(flagpile_t *fp);
|
||||
int killtransitoryflags(flagpile_t *fp, enum FLAG fid);
|
||||
int killtransitoryflagvals(flagpile_t *fp, enum FLAG fid, int val1, int val2, int val3, char *text);
|
||||
int killtransitoryflagvals(flagpile_t *fp, enum FLAG fid, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
void makeflagknown(flagpile_t *fp);
|
||||
int modcounter(flagpile_t *fp, int amt);
|
||||
flag_t *modflag(flagpile_t *fp, enum FLAG fid, int val1, int val2, int val3, char *text);
|
||||
flag_t *modflag(flagpile_t *fp, enum FLAG fid, int val1, int val2, int val3, /*@null@*/ char *text);
|
||||
void sumflags(flagpile_t *fp, int id, int *val0, int *val1, int *val2);
|
||||
void timeeffectsflag(flag_t *f, int howlong);
|
||||
void timeeffectsflags(flagpile_t *fp);
|
||||
|
|
36
god.c
36
god.c
|
@ -382,13 +382,13 @@ int godgiftmaybe(enum RACE rid) {
|
|||
rollagain = B_FALSE;
|
||||
switch (rnd(1,6)) {
|
||||
case 1:
|
||||
sprintf(obtogive, "2-4 blessed potions of water");
|
||||
snprintf(obtogive, BUFLEN, "2-4 blessed potions of water");
|
||||
break;
|
||||
case 2:
|
||||
sprintf(obtogive, "blessed great weapon");
|
||||
snprintf(obtogive, BUFLEN, "blessed great weapon");
|
||||
break;
|
||||
case 3:
|
||||
sprintf(obtogive, "wand of turn undead");
|
||||
snprintf(obtogive, BUFLEN, "wand of turn undead");
|
||||
break;
|
||||
case 4: // bless your weapon
|
||||
wep = getweapon(player);
|
||||
|
@ -435,10 +435,10 @@ int godgiftmaybe(enum RACE rid) {
|
|||
rollagain = B_FALSE;
|
||||
switch (rnd(1,5)) {
|
||||
case 1:
|
||||
sprintf(obtogive, "3-5 cursed potions of water");
|
||||
snprintf(obtogive, BUFLEN, "3-5 cursed potions of water");
|
||||
break;
|
||||
case 2:
|
||||
sprintf(obtogive, "cursed branded weapon");
|
||||
snprintf(obtogive, BUFLEN, "cursed branded weapon");
|
||||
break;
|
||||
case 3: // poison your weapon
|
||||
wep = getweapon(player);
|
||||
|
@ -475,32 +475,32 @@ int godgiftmaybe(enum RACE rid) {
|
|||
switch (rnd(1,7)) {
|
||||
case 1:
|
||||
if (getskill(player, SK_TECHUSAGE) >= gettechlevel(OT_LOCKHACKER)) {
|
||||
sprintf(obtogive, "lock hacker");
|
||||
snprintf(obtogive, BUFLEN, "lock hacker");
|
||||
} else {
|
||||
sprintf(obtogive, "3-6 blessed lockpicks");
|
||||
snprintf(obtogive, BUFLEN, "3-6 blessed lockpicks");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (onein(6)) {
|
||||
sprintf(obtogive, "large bag of holding");
|
||||
snprintf(obtogive, BUFLEN, "large bag of holding");
|
||||
} else {
|
||||
sprintf(obtogive, "bag of holding");
|
||||
snprintf(obtogive, BUFLEN, "bag of holding");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
sprintf(obtogive, "safebox");
|
||||
snprintf(obtogive, BUFLEN, "safebox");
|
||||
break;
|
||||
case 4:
|
||||
sprintf(obtogive, "wand of opening");
|
||||
snprintf(obtogive, BUFLEN, "wand of opening");
|
||||
break;
|
||||
case 5:
|
||||
sprintf(obtogive, "wand of invisibility");
|
||||
snprintf(obtogive, BUFLEN, "wand of invisibility");
|
||||
break;
|
||||
case 6:
|
||||
sprintf(obtogive, "3-6 potions of invisibility");
|
||||
snprintf(obtogive, BUFLEN, "3-6 potions of invisibility");
|
||||
break;
|
||||
case 7:
|
||||
sprintf(obtogive, "leather boots of stealth");
|
||||
snprintf(obtogive, BUFLEN, "leather boots of stealth");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -511,13 +511,13 @@ int godgiftmaybe(enum RACE rid) {
|
|||
rollagain = B_FALSE;
|
||||
switch (rnd(1,4)) {
|
||||
case 1:
|
||||
sprintf(obtogive, "3 vials of ambrosia");
|
||||
snprintf(obtogive, BUFLEN, "3 vials of ambrosia");
|
||||
break;
|
||||
case 2:
|
||||
sprintf(obtogive, "ring of regeneration");
|
||||
snprintf(obtogive, BUFLEN, "ring of regeneration");
|
||||
break;
|
||||
case 3:
|
||||
sprintf(obtogive, "ring of miracles");
|
||||
snprintf(obtogive, BUFLEN, "ring of miracles");
|
||||
break;
|
||||
case 4: // immune to disease / poison
|
||||
if (lfhasflag(player, F_DISEASEIMMUNE)) {
|
||||
|
@ -575,7 +575,7 @@ void godsay(enum RACE rid, char *format, ...) {
|
|||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf( buf, format, args );
|
||||
vsnprintf( buf, BUFLEN, format, args );
|
||||
va_end(args);
|
||||
|
||||
god = findgod(rid);
|
||||
|
|
1
io.h
1
io.h
|
@ -117,3 +117,4 @@ void textwithcol(WINDOW *win, char *buf);
|
|||
void tombstone(lifeform_t *lf);
|
||||
void updatestatus(void);
|
||||
int updateviewfor(cell_t *cell);
|
||||
void wrapprint(WINDOW *win, int *y, int *x, char *format, ... );
|
||||
|
|
6
lf.h
6
lf.h
|
@ -103,7 +103,7 @@ int getarmourrating(lifeform_t *lf, object_t **hitob, int *hitchance, int *narms
|
|||
int getattackspeed(lifeform_t *lf);
|
||||
int getattpoints(lifeform_t *lf);
|
||||
int getattr(lifeform_t *lf, enum ATTRIB attr);
|
||||
enum ATTRBRACKET getattrbracket(int attrval, enum ATTRIB whichatt, char *buf);
|
||||
enum ATTRBRACKET getattrbracket(int attrval, enum ATTRIB whichatt, /*@null@*/char *buf);
|
||||
int real_getattr(lifeform_t *lf, enum ATTRIB attr, int ignoreattrset);
|
||||
int getavgdam(lifeform_t *lf, int forxp);
|
||||
float getequippedweight(lifeform_t *lf);
|
||||
|
@ -213,9 +213,9 @@ job_t *hasjob(lifeform_t *lf, enum JOB job);
|
|||
int injure(lifeform_t *lf, enum BODYPART where, enum DAMTYPE damtype);
|
||||
int lfcanbestoned(lifeform_t *lf);
|
||||
flag_t *lfhasflag(lifeform_t *lf, enum FLAG fid);
|
||||
flag_t *lfhasflagval(lifeform_t *lf, enum FLAG fid, int val0, int val1, int val2, char *text);
|
||||
flag_t *lfhasflagval(lifeform_t *lf, enum FLAG fid, int val0, int val1, int val2, /*@null@*/ char *text);
|
||||
flag_t *lfhasknownflag(lifeform_t *lf, enum FLAG fid);
|
||||
flag_t *lfhasknownflagval(lifeform_t *lf, enum FLAG fid, int val0, int val1, int val2, char *text);
|
||||
flag_t *lfhasknownflagval(lifeform_t *lf, enum FLAG fid, int val0, int val1, int val2, /*@null@*/ char *text);
|
||||
int lfproduceslight(lifeform_t *lf);
|
||||
int lockpick(lifeform_t *lf, object_t *target, object_t *device);
|
||||
void loseobflags(lifeform_t *lf, object_t *o, int kind);
|
||||
|
|
54
map.c
54
map.c
|
@ -198,7 +198,7 @@ lifeform_t *addmonster(cell_t *c, enum RACE rid, char *racename, int jobok, int
|
|||
|
||||
if (db) {
|
||||
char buf[BUFLEN];
|
||||
sprintf(buf, "addmonster for '%s'->%s",racename, r->name);
|
||||
snprintf(buf, BUFLEN, "addmonster for '%s'->%s",racename, r->name);
|
||||
dbtimestart(buf);
|
||||
}
|
||||
|
||||
|
@ -2286,7 +2286,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex
|
|||
|
||||
// we now have the map name!
|
||||
getregionname(buf2, map, B_TRUE);
|
||||
sprintf(buf, "%s (id #%d)",buf2, map->id);
|
||||
snprintf(buf, BUFLEN, "%s (id #%d)",buf2, map->id);
|
||||
map->name = strdup(buf);
|
||||
|
||||
// get a list of what things are here based on the region's outline
|
||||
|
@ -2971,7 +2971,7 @@ int linkexits(map_t *m, int roomid) {
|
|||
vault_t *v;
|
||||
c = getrandomroomcell(m, roomid);
|
||||
v = getcellvault(c);
|
||||
sprintf(buf, "*** linkexits for roomid %d (%s) [%d,%d-%d,%d]", roomid,
|
||||
snprintf(buf, BUFLEN, "*** linkexits for roomid %d (%s) [%d,%d-%d,%d]", roomid,
|
||||
v ? v->id : "novault",
|
||||
minx,miny,maxx,maxy);
|
||||
dblog("%s", buf);
|
||||
|
@ -3244,9 +3244,9 @@ void dumpoutlines(void) {
|
|||
char loctext[BUFLEN];
|
||||
rt = &r->outline->thing[i];
|
||||
if (rt->depth == NA) {
|
||||
sprintf(loctext, "%d,%d",rt->x, rt->y);
|
||||
snprintf(loctext, BUFLEN, "%d,%d",rt->x, rt->y);
|
||||
} else {
|
||||
sprintf(loctext, "depth %d",rt->depth);
|
||||
snprintf(loctext, BUFLEN, "depth %d",rt->depth);
|
||||
}
|
||||
if (rt->whatkind == RT_REGIONLINK) {
|
||||
regiontype_t *rtype;
|
||||
|
@ -3330,9 +3330,9 @@ void explodesinglecell(cell_t *c, int dam, int killwalls, object_t *o, cell_t *c
|
|||
char buf[BUFLEN];
|
||||
if (o) {
|
||||
getobname(o, obname, 1);
|
||||
sprintf(buf, "an exploding %s",strchr(obname, ' ')+1);
|
||||
snprintf(buf, BUFLEN, "an exploding %s",strchr(obname, ' ')+1);
|
||||
} else {
|
||||
sprintf(buf, "an explosion");
|
||||
snprintf(buf, BUFLEN, "an explosion");
|
||||
}
|
||||
|
||||
// take damage
|
||||
|
@ -3439,6 +3439,10 @@ cell_t *findmapentrypoint(map_t *m, int side, lifeform_t *lf) {
|
|||
yinc = 1;
|
||||
bestcell = getcellat(m, 0, lf->cell->y);
|
||||
break;
|
||||
default:
|
||||
dblog("error: invalid side given to mapentrypoint.");
|
||||
msg("error: invalid side given to mapentrypoint.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (;(x < m->w) && (y < m->h);) {
|
||||
|
@ -3783,16 +3787,16 @@ char *getregionname(char *buf, map_t *m, int withlevel) {
|
|||
}
|
||||
switch (r->rtype->id) {
|
||||
case RG_WORLDMAP:
|
||||
sprintf(buf, "the surface(%d,%d)",x,y);
|
||||
snprintf(buf, BUFLEN, "the surface(%d,%d)",x,y);
|
||||
break;
|
||||
case RG_FIRSTDUNGEON:
|
||||
sprintf(buf, "dungeon L%d", m->depth);
|
||||
snprintf(buf, BUFLEN, "dungeon L%d", m->depth);
|
||||
break;
|
||||
case RG_HEAVEN:
|
||||
sprintf(buf, "the realm of gods");
|
||||
snprintf(buf, BUFLEN, "the realm of gods");
|
||||
break;
|
||||
case RG_PIT:
|
||||
sprintf(buf, "a pit L%d", m->depth);
|
||||
snprintf(buf, BUFLEN, "a pit L%d", m->depth);
|
||||
break;
|
||||
default:
|
||||
strcpy(buf, "?unknownregiontype??");
|
||||
|
@ -3807,10 +3811,10 @@ char *getregionname(char *buf, map_t *m, int withlevel) {
|
|||
strcpy(buf, "a dungeon");
|
||||
break;
|
||||
case RG_HEAVEN:
|
||||
sprintf(buf, "the realm of gods");
|
||||
snprintf(buf, BUFLEN, "the realm of gods");
|
||||
break;
|
||||
case RG_PIT:
|
||||
sprintf(buf, "a pit");
|
||||
snprintf(buf, BUFLEN, "a pit");
|
||||
break;
|
||||
default:
|
||||
strcpy(buf, "?unknownregiontype??");
|
||||
|
@ -4263,7 +4267,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) {
|
|||
if (desc) {
|
||||
char *p;
|
||||
p = getsizetext(getlfsize(c->lf));
|
||||
sprintf(desc, "%s %s monster", isvowel(*p) ? "an" : "a", p);
|
||||
snprintf(desc, BUFLEN, "%s %s monster", isvowel(*p) ? "an" : "a", p);
|
||||
}
|
||||
if (glyph) {
|
||||
// select glyph based on size
|
||||
|
@ -4284,7 +4288,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) {
|
|||
glyph->ch = '*';
|
||||
glyph->colour = C_GREY;
|
||||
}
|
||||
if (desc) sprintf(desc, "something metallic");
|
||||
if (desc) snprintf(desc, BUFLEN, "something metallic");
|
||||
return TT_MONSTER;
|
||||
} else {
|
||||
object_t *o;
|
||||
|
@ -4295,7 +4299,7 @@ int isinscanrange(cell_t *c, void **thing, char *desc, glyph_t *glyph) {
|
|||
glyph->ch = '*';
|
||||
glyph->colour = C_GREY;
|
||||
}
|
||||
if (desc) sprintf(desc, "something metallic");
|
||||
if (desc) snprintf(desc, BUFLEN, "something metallic");
|
||||
return TT_OBJECT;
|
||||
}
|
||||
}
|
||||
|
@ -4382,15 +4386,15 @@ int isloopdirok(cell_t *cell, int dir) {
|
|||
|
||||
int isnewcellok(cell_t *cell, char *err) {
|
||||
if ( !cell) { // can't go that way
|
||||
if (err) sprintf(err,"goes off the map.");
|
||||
if (err) snprintf(err, BUFLEN,"goes off the map.");
|
||||
return B_FALSE;
|
||||
} else if ( !cell->type->solid) { // already an empty space there
|
||||
if (err) sprintf(err,"goes to an empty space (%d,%d)",cell->x,cell->y);
|
||||
if (err) snprintf(err, BUFLEN,"goes to an empty space (%d,%d)",cell->x,cell->y);
|
||||
return B_FALSE;
|
||||
}
|
||||
|
||||
// ok!
|
||||
if (err) sprintf(err, "OK!");
|
||||
if (err) snprintf(err, BUFLEN, "OK!");
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
|
@ -4576,10 +4580,10 @@ int linkstairs(object_t *o, object_t *o2) {
|
|||
if (o2) {
|
||||
char obid[BUFLEN];
|
||||
// link it to here!
|
||||
sprintf(obid, "%ld", o->id);
|
||||
snprintf(obid, BUFLEN, "%ld", o->id);
|
||||
addflag(o2->flags, F_MAPLINK, stairmap->id, NA, NA, obid);
|
||||
// link me to there
|
||||
sprintf(obid, "%ld", o2->id);
|
||||
snprintf(obid, BUFLEN, "%ld", o2->id);
|
||||
addflag(o->flags, F_MAPLINK, othermap->id, NA, NA, obid);
|
||||
// now mark that we are not a new staircase to a new region anymore
|
||||
f = hasflag(o->flags, F_CLIMBABLE);
|
||||
|
@ -4756,7 +4760,7 @@ enum RACE parserace(char *name, flagpile_t *wantflags, enum JOB *wantjob) {
|
|||
for (j = firstjob ; j ; j = j->next) {
|
||||
char *ep;
|
||||
char jobname[BUFLEN];
|
||||
sprintf(jobname, " %s", j->name);
|
||||
snprintf(jobname, BUFLEN, " %s", j->name);
|
||||
jobname[1] = tolower(jobname[1]);
|
||||
ep = strends(name, jobname);
|
||||
if (ep) {
|
||||
|
@ -4904,12 +4908,12 @@ int shattercell(cell_t *c, lifeform_t *fromlf, char *damstring) {
|
|||
if (c->type->material->id == MT_GLASS) {
|
||||
int numshards;
|
||||
numshards = rnd(50,100);
|
||||
sprintf(buf, "%d pieces of broken glass",numshards);
|
||||
snprintf(buf, BUFLEN, "%d pieces of broken glass",numshards);
|
||||
addob(c->obpile, buf);
|
||||
} else if (c->type->material->id == MT_ICE) {
|
||||
int numshards;
|
||||
numshards = rnd(50,100);
|
||||
sprintf(buf, "%d chunks of ice",numshards);
|
||||
snprintf(buf, BUFLEN, "%d chunks of ice",numshards);
|
||||
addob(c->obpile, buf);
|
||||
}
|
||||
}
|
||||
|
@ -5019,6 +5023,8 @@ int wallstoleftright(cell_t *c, int dir) {
|
|||
case D_E:
|
||||
case D_W:
|
||||
d1 = D_N; d2 = D_S; break;
|
||||
default:
|
||||
return B_FALSE;
|
||||
}
|
||||
if (iswallindir(c,d1) && iswallindir(c,d2)) {
|
||||
return B_TRUE;
|
||||
|
|
30
move.c
30
move.c
|
@ -733,7 +733,7 @@ int knockback(lifeform_t *lf, int dir, int howfar, lifeform_t *pusher, int fallc
|
|||
getobname(rdata, thing, 1);
|
||||
}
|
||||
if (seen) msg("%s slam%s into %s!",lfname,isplayer(lf) ? "" : "s", thing);
|
||||
sprintf(buf, "slamming into %s", thing);
|
||||
snprintf(buf, BUFLEN, "slamming into %s", thing);
|
||||
losehp(lf, rnd(1,6), DT_BASH, pusher, buf);
|
||||
// stop moving
|
||||
i = howfar;
|
||||
|
@ -883,7 +883,7 @@ int moveeffects(lifeform_t *lf) {
|
|||
int didmsg = B_FALSE;
|
||||
|
||||
if (isbleeding(lf)) {
|
||||
if (lfhasflagval(lf, F_INJURY, BP_LEGS, DT_SLASH, NA, NULL)) {
|
||||
if (lfhasflagval(lf, F_INJURY, NA, BP_LEGS, DT_SLASH, NULL)) {
|
||||
bleed(lf);
|
||||
losehp(lf, 1, DT_DIRECT, NULL, "blood loss");
|
||||
} else {
|
||||
|
@ -1112,7 +1112,7 @@ int movelf(lifeform_t *lf, cell_t *newcell) {
|
|||
msg("%s steps on %s!",lfname, obname);
|
||||
didmsg = B_TRUE;
|
||||
}
|
||||
sprintf(buf, "stepping on %s", obname);
|
||||
snprintf(buf, BUFLEN, "stepping on %s", obname);
|
||||
losehp(lf, rnd(f->val[0],f->val[1]), DT_SLASH, NULL, buf);
|
||||
}
|
||||
}
|
||||
|
@ -1502,7 +1502,7 @@ int opendoor(lifeform_t *lf, object_t *o) {
|
|||
if (hasflagval(o->flags, F_TRAPPED, NA, NA, B_TRUE, NULL)) {
|
||||
if (getattrbracket(getattr(lf, A_WIS), A_WIS, NULL) >= AT_AVERAGE) {
|
||||
char ch;
|
||||
sprintf(buf,"Really open %s?", obname);
|
||||
snprintf(buf, BUFLEN,"Really open %s?", obname);
|
||||
ch = askchar(buf,"yn","n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
msg("Cancelled.");
|
||||
|
@ -1519,7 +1519,7 @@ int opendoor(lifeform_t *lf, object_t *o) {
|
|||
if (pastdoorcell && getcellwaterdepth(pastdoorcell, NULL)) {
|
||||
if (getattrbracket(getattr(lf, A_WIS), A_WIS, NULL) >= AT_AVERAGE) {
|
||||
char ch;
|
||||
sprintf(buf,"Your hear running water behind %s. Really open it?", obname);
|
||||
snprintf(buf, BUFLEN,"Your hear running water behind %s. Really open it?", obname);
|
||||
ch = askchar(buf,"yn","n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
msg("Cancelled.");
|
||||
|
@ -1741,7 +1741,7 @@ int trysneak(lifeform_t *lf, int dir) {
|
|||
if (isplayer(lf)) {
|
||||
char ques[BUFLEN];
|
||||
char ch;
|
||||
sprintf(ques, "Carefully %s in which direction (- to cancel)", getmoveverb(lf));
|
||||
snprintf(ques, BUFLEN, "Carefully %s in which direction (- to cancel)", getmoveverb(lf));
|
||||
ch = askchar(ques, "yuhjklbn.-","-", B_FALSE);
|
||||
dir = chartodir(ch);
|
||||
if (dir == D_NONE) return B_TRUE;
|
||||
|
@ -1979,7 +1979,7 @@ int initiatemove(lifeform_t *lf, cell_t *cell, int *didmsg) {
|
|||
taketime(lf, getmovespeed(lf));
|
||||
reason = E_OK;
|
||||
// avoid this object in future
|
||||
sprintf(buf, "%ld",o->id);
|
||||
snprintf(buf, BUFLEN, "%ld",o->id);
|
||||
addflag(lf->flags, F_AVOIDOB, B_CURSED, NA, NA, buf);
|
||||
return B_TRUE;
|
||||
} else if (lfhasflagval(lf, F_AVOIDOBTYPE, o->type->id, NA, NA, NULL)) {
|
||||
|
@ -1994,7 +1994,7 @@ int initiatemove(lifeform_t *lf, cell_t *cell, int *didmsg) {
|
|||
taketime(lf, getmovespeed(lf));
|
||||
reason = E_OK;
|
||||
// avoid this object in future
|
||||
sprintf(buf, "%ld",o->id);
|
||||
snprintf(buf, BUFLEN, "%ld",o->id);
|
||||
addflag(lf->flags, F_AVOIDOB, NA, NA, NA, buf);
|
||||
return B_TRUE;
|
||||
}
|
||||
|
@ -2132,9 +2132,9 @@ int trymove(lifeform_t *lf, int dir, int onpurpose) {
|
|||
object_t *avoidob;
|
||||
avoidob = (object_t *)rdata;
|
||||
getobname(avoidob, obname, avoidob->amt);
|
||||
sprintf(ques, "Really %s into %s?", getmoveverb(lf), obname);
|
||||
snprintf(ques, BUFLEN, "Really %s into %s?", getmoveverb(lf), obname);
|
||||
} else {
|
||||
sprintf(ques, "Really %s there?", getmoveverb(lf));
|
||||
snprintf(ques, BUFLEN, "Really %s there?", getmoveverb(lf));
|
||||
}
|
||||
ch = askchar(ques, "yn","n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
|
@ -2280,7 +2280,7 @@ int trymove(lifeform_t *lf, int dir, int onpurpose) {
|
|||
if (isplayer(lf)) {
|
||||
// only take damage if we didn't know about this
|
||||
if ((cell && !cell->known) || isdrunk(lf)) {
|
||||
sprintf(buf, "%sing into a %s", getmoveverb(lf),
|
||||
snprintf(buf, BUFLEN, "%sing into a %s", getmoveverb(lf),
|
||||
cell ? cell->type->name : "wall");
|
||||
losehp(lf, 1, DT_BASH, NULL, buf);
|
||||
if (cell) {
|
||||
|
@ -2291,7 +2291,7 @@ int trymove(lifeform_t *lf, int dir, int onpurpose) {
|
|||
if (onpurpose) taketime(lf, getmovespeed(lf));
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "%sing into a %s", getmoveverb(lf),
|
||||
snprintf(buf, BUFLEN, "%sing into a %s", getmoveverb(lf),
|
||||
cell ? cell->type->name : "wall");
|
||||
losehp(lf, 1, DT_BASH, NULL, buf);
|
||||
if (onpurpose) taketime(lf, getmovespeed(lf));
|
||||
|
@ -2311,7 +2311,7 @@ int trymove(lifeform_t *lf, int dir, int onpurpose) {
|
|||
} else {
|
||||
msg("Ouch! You %s into a door.", getmoveverb(lf));
|
||||
setcellknown(cell, B_FALSE);
|
||||
sprintf(buf, "%sing into a door", getmoveverb(lf));
|
||||
snprintf(buf, BUFLEN, "%sing into a door", getmoveverb(lf));
|
||||
losehp(lf, 1, DT_BASH, NULL, buf);
|
||||
if (onpurpose) taketime(lf, getmovespeed(lf));
|
||||
}
|
||||
|
@ -2320,7 +2320,7 @@ int trymove(lifeform_t *lf, int dir, int onpurpose) {
|
|||
getlfname(lf, buf);
|
||||
msg("%s %ss into a door.", buf, getmoveverb(lf));
|
||||
}
|
||||
sprintf(buf, "%sing into a door", getmoveverb(lf));
|
||||
snprintf(buf, BUFLEN, "%sing into a door", getmoveverb(lf));
|
||||
losehp(lf, 1, DT_BASH, NULL, buf);
|
||||
if (onpurpose) taketime(lf, getmovespeed(lf));
|
||||
}
|
||||
|
@ -2658,7 +2658,7 @@ int willmove(lifeform_t *lf, int dir, enum ERROR *error) {
|
|||
// look for avoided objects (because they are cursed).
|
||||
for (o = cell->obpile->first ; o ; o = o->next) {
|
||||
flag_t *f;
|
||||
sprintf(buf, "%ld",o->id);
|
||||
snprintf(buf, BUFLEN, "%ld",o->id);
|
||||
f = lfhasflagval(lf, F_AVOIDOB, NA, NA, NA, buf);
|
||||
if (f) {
|
||||
// still cursed?
|
||||
|
|
15
nexus.c
15
nexus.c
|
@ -159,6 +159,7 @@ int main(int argc, char **argv) {
|
|||
cell_t *where;
|
||||
int dir;
|
||||
flag_t *f;
|
||||
region_t *wregion, *dregion,*hregion;
|
||||
map_t *dmap;
|
||||
|
||||
// populate scroll, potion, etc names
|
||||
|
@ -195,10 +196,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
// if no maps (ie. ALWAYS now that maps aren't persistent),
|
||||
// make the initial level
|
||||
if (!firstmap) {
|
||||
region_t *wregion, *dregion,*hregion;
|
||||
newworld = B_TRUE;
|
||||
// create world map.
|
||||
wregion = addregion(RG_WORLDMAP, NULL, -1);
|
||||
|
@ -215,7 +213,6 @@ int main(int argc, char **argv) {
|
|||
assert(hregion);
|
||||
heaven = addmap();
|
||||
createmap(heaven, 1, hregion, NULL, D_NONE, NULL);
|
||||
}
|
||||
|
||||
// find staircase
|
||||
where = findobinmap(dmap, OT_STAIRSUP);
|
||||
|
@ -307,12 +304,12 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
getplayernamefull(pname);
|
||||
sprintf(welcomemsg, "Greetings %s, welcome to %snexus!", pname, newworld ? "the new " : "");
|
||||
snprintf(welcomemsg, BUFLEN, "Greetings %s, welcome to %snexus!", pname, newworld ? "the new " : "");
|
||||
// 00:00 - 23:59
|
||||
curtime = rnd(0,DAYSECS-1);
|
||||
|
||||
} else {
|
||||
sprintf(welcomemsg, "Welcome back!");
|
||||
snprintf(welcomemsg, BUFLEN, "Welcome back!");
|
||||
}
|
||||
|
||||
// start game - this will cause debug messages to now
|
||||
|
@ -599,7 +596,7 @@ void donextturn(map_t *map) {
|
|||
long obid;
|
||||
lifeform_t *targlf;
|
||||
object_t *targob;
|
||||
cell_t *targcell;
|
||||
cell_t *targcell = NULL;
|
||||
map_t *targmap;
|
||||
enum OBTYPE sid;
|
||||
|
||||
|
@ -727,7 +724,7 @@ void donextturn(map_t *map) {
|
|||
//char buf[BUFLEN];
|
||||
// do ai move
|
||||
//real_getlfname(who, lfname, B_FALSE);
|
||||
//sprintf(buf, "aimove %s",lfname);
|
||||
//snprintf(buf, BUFLEN, "aimove %s",lfname);
|
||||
//dbtimestart(buf);
|
||||
aiturn(who);
|
||||
//dbtimeend(buf);
|
||||
|
@ -840,7 +837,7 @@ void getrarityrange(int depth, int *min, int *max, int range, int oodok) {
|
|||
|
||||
mid = 100 - (depth * 3);
|
||||
*min = mid - range; if (*min < 0) *min = 0;
|
||||
//*max = mid + range; if (*max > 100) *max = 100;
|
||||
// *max = mid + range; if (*max > 100) *max = 100;
|
||||
*max = 100;
|
||||
|
||||
//if (*min > 85) *min = 85;
|
||||
|
|
278
objects.c
278
objects.c
|
@ -236,7 +236,7 @@ brand_t *addbrand(enum BRAND id, char *suffix, enum BODYPART bp) {
|
|||
// props
|
||||
a->id = id;
|
||||
a->bp = bp;
|
||||
sprintf(buf, " %s",suffix);
|
||||
snprintf(buf, BUFLEN, " %s",suffix);
|
||||
a->suffix = strdup(buf);
|
||||
|
||||
a->flags = addflagpile(NULL, NULL);
|
||||
|
@ -572,7 +572,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int wantlinkholes
|
|||
// water flags
|
||||
for (n = DP_MAX; n >= DP_FIRST; n--) {
|
||||
char wpre[BUFLEN];
|
||||
sprintf(wpre, "%s ", getwaterdepthname(n));
|
||||
snprintf(wpre, BUFLEN, "%s ", getwaterdepthname(n));
|
||||
if (strstarts(p, wpre)) {
|
||||
wantdepth = n;
|
||||
p += strlen(wpre);
|
||||
|
@ -694,7 +694,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int wantlinkholes
|
|||
for (;*p2 != ' ';p2++);
|
||||
p2++;
|
||||
// now at start of name
|
||||
sprintf(racename, "%s",p2);
|
||||
snprintf(racename, BUFLEN, "%s",p2);
|
||||
|
||||
corpserace = findracebyname(racename);
|
||||
ot = findot(OT_STATUE);
|
||||
|
@ -790,7 +790,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int wantlinkholes
|
|||
int i;
|
||||
int matched = B_FALSE;
|
||||
for (i = 0; i < oc->nnouns; i++) {
|
||||
sprintf(tempname, "random %s", oc->noun[i]);
|
||||
snprintf(tempname, BUFLEN, "random %s", oc->noun[i]);
|
||||
if (strstarts(p, tempname) || streq(p, oc->noun[i])) {
|
||||
matched = B_TRUE;
|
||||
}
|
||||
|
@ -1052,6 +1052,7 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int wantlinkholes
|
|||
int n;
|
||||
for (n = 0; n < ndoorflags; n++) {
|
||||
int val[3];
|
||||
int ok = B_FALSE;
|
||||
if (obloc) {
|
||||
// fill in flag vals
|
||||
switch (doorflag[n]) {
|
||||
|
@ -1059,23 +1060,29 @@ object_t *addobject(obpile_t *where, char *name, int canstack, int wantlinkholes
|
|||
val[0] = B_TRUE;
|
||||
val[1] = getdoorlockdiff(obloc->map->depth);
|
||||
val[2] = NA;
|
||||
ok = B_TRUE;
|
||||
break;
|
||||
case F_JAMMED:
|
||||
val[0] = rnd(1,obloc->map->depth+3);
|
||||
val[1] = NA;
|
||||
val[2] = NA;
|
||||
ok = B_TRUE;
|
||||
break;
|
||||
case F_SECRET:
|
||||
val[0] = getdoorsecretdiff(obloc->map->depth);
|
||||
val[1] = NA;
|
||||
val[2] = NA;
|
||||
ok = B_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (ok) {
|
||||
addflag(o->flags, doorflag[n], val[0], val[1], val[2], NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// foundtain flags
|
||||
if (o && (o->type->id == OT_FOUNTAIN)) {
|
||||
|
@ -1622,7 +1629,7 @@ obmod_t *addobmod(enum OBMOD id, char *prefix) {
|
|||
|
||||
// props
|
||||
a->id = id;
|
||||
sprintf(buf, "%s ",prefix);
|
||||
snprintf(buf, BUFLEN, "%s ",prefix);
|
||||
a->prefix = strdup(buf);
|
||||
|
||||
a->flags = addflagpile(NULL, NULL);
|
||||
|
@ -2318,16 +2325,16 @@ int changemat(object_t *o, enum MATERIAL mat) {
|
|||
return B_FALSE;
|
||||
}
|
||||
|
||||
objecttype_t *checkobnames(char *haystack, char *needle) {
|
||||
objecttype_t *ot;
|
||||
int checkobnames(char *haystack, char *needle) {
|
||||
char *pluralname;
|
||||
int db = B_FALSE;
|
||||
|
||||
|
||||
// search for exact match
|
||||
if (!strcmp(haystack, needle)) {
|
||||
// found it!
|
||||
if (db) dblog("checkobnames(): got exact match: '%s'",haystack);
|
||||
return ot;
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
// search for words ending in "s" (eg. "swords")
|
||||
|
@ -2340,7 +2347,7 @@ objecttype_t *checkobnames(char *haystack, char *needle) {
|
|||
if (!strcmp(haystack, pluralname)) {
|
||||
if (db) dblog("checkobnames(): got match after stripping 's': '%s' -> '%s'",pluralname, needle);
|
||||
free(pluralname);
|
||||
return ot;
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
// search for words ending in "es" (eg. tomatoes)
|
||||
|
@ -2355,13 +2362,13 @@ objecttype_t *checkobnames(char *haystack, char *needle) {
|
|||
if (!strcmp(haystack, pluralname)) {
|
||||
if (db) dblog("checkobnames(): got match after stripping 'es': '%s' -> '%s'",pluralname, needle);
|
||||
free(pluralname);
|
||||
return ot;
|
||||
return B_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(pluralname);
|
||||
|
||||
return NULL;
|
||||
return B_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3117,7 +3124,7 @@ int getobaccuracy(object_t *wep, lifeform_t *weilder) {
|
|||
int getobbonus(object_t *o) {
|
||||
int bonus = 0,i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
getflags(o->flags, retflag, &nretflags, F_BONUS, F_NONE);
|
||||
for (i = 0; i < nretflags; i++) {
|
||||
|
@ -3190,7 +3197,7 @@ int getobvalue(object_t *o) {
|
|||
int rarity = 0,i;
|
||||
enum RARITY rr = RR_COMMON;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (o->type->id == OT_GOLD) {
|
||||
return o->amt;
|
||||
|
@ -3443,7 +3450,7 @@ object_t *getrandomammo(lifeform_t *lf) {
|
|||
flag_t *f;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
gun = getfirearm(lf);
|
||||
if (!gun) {
|
||||
return NULL;
|
||||
|
@ -3883,10 +3890,10 @@ char *getobdesc(object_t *o, char *buf) {
|
|||
if (f) {
|
||||
race_t *corpserace;
|
||||
corpserace = findrace(f->val[0]);
|
||||
sprintf(buf, "The dead body of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
snprintf(buf, BUFLEN, "The dead body of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
corpserace->name);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else if (o->type->id == OT_HEAD) {
|
||||
flag_t *f;
|
||||
|
@ -3894,10 +3901,10 @@ char *getobdesc(object_t *o, char *buf) {
|
|||
if (f) {
|
||||
race_t *corpserace;
|
||||
corpserace = findrace(f->val[0]);
|
||||
sprintf(buf, "The decapitated head of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
snprintf(buf, BUFLEN, "The decapitated head of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
corpserace->name);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else if (o->type->id == OT_STATUE) {
|
||||
flag_t *f;
|
||||
|
@ -3905,10 +3912,10 @@ char *getobdesc(object_t *o, char *buf) {
|
|||
if (f) {
|
||||
race_t *corpserace;
|
||||
corpserace = findrace(f->val[0]);
|
||||
sprintf(buf, "A stone statue of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
snprintf(buf, BUFLEN, "A stone statue of %s %s.", isvowel(corpserace->name[0]) ? "an" : "a",
|
||||
corpserace->name);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else if (o->type->id == OC_SCROLL) {
|
||||
flag_t *f;
|
||||
|
@ -3917,18 +3924,18 @@ char *getobdesc(object_t *o, char *buf) {
|
|||
objecttype_t *spelltype;
|
||||
spelltype = findot(f->val[0]);
|
||||
if (spelltype) {
|
||||
sprintf(buf, "%s", spelltype->desc);
|
||||
snprintf(buf, BUFLEN, "%s", spelltype->desc);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else if (o->type->id == OT_WATERDEEP) {
|
||||
sprintf(buf, "%s water.", getwaterdepthname(getobdepth(o, player)));
|
||||
snprintf(buf, BUFLEN, "%s water.", getwaterdepthname(getobdepth(o, player)));
|
||||
capitalise(buf);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->desc);
|
||||
}
|
||||
} else {
|
||||
objecttype_t *ot = NULL;
|
||||
|
@ -3939,9 +3946,9 @@ char *getobdesc(object_t *o, char *buf) {
|
|||
}
|
||||
|
||||
if (ot) {
|
||||
sprintf(buf, "%s", ot->desc);
|
||||
snprintf(buf, BUFLEN, "%s", ot->desc);
|
||||
} else {
|
||||
sprintf(buf, "%s", o->type->obclass->desc);
|
||||
snprintf(buf, BUFLEN, "%s", o->type->obclass->desc);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
@ -4011,15 +4018,15 @@ char *getobextrainfo(object_t *o, char *buf) {
|
|||
char chargestr[BUFLEN];
|
||||
if (o->type->obclass->id == OC_GODSTONE) {
|
||||
if (f->val[0] == f->val[1]) {
|
||||
sprintf(chargestr, " (charged)");
|
||||
snprintf(chargestr, BUFLEN, " (charged)");
|
||||
} else {
|
||||
sprintf(chargestr, " (depleted)");
|
||||
snprintf(chargestr, BUFLEN, " (depleted)");
|
||||
}
|
||||
} else {
|
||||
if (f->val[0] > 0) {
|
||||
sprintf(chargestr, " (%d charges left)",f->val[0]);
|
||||
snprintf(chargestr, BUFLEN, " (%d charges left)",f->val[0]);
|
||||
} else {
|
||||
sprintf(chargestr, " (empty)");
|
||||
snprintf(chargestr, BUFLEN, " (empty)");
|
||||
}
|
||||
}
|
||||
strcat(buf, chargestr);
|
||||
|
@ -4099,7 +4106,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
cell_t *where;
|
||||
int no_a = B_FALSE;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
// default to normal name
|
||||
if (hasflag(o->flags, F_VENDITEM)) {
|
||||
|
@ -4144,14 +4151,14 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (who) {
|
||||
char lfname[BUFLEN];
|
||||
real_getlfname(who, lfname, B_FALSE);
|
||||
sprintf(buf, "%s%s %sscent",lfname,getpossessive(lfname), adjective);
|
||||
snprintf(buf, BUFLEN, "%s%s %sscent",lfname,getpossessive(lfname), adjective);
|
||||
} else {
|
||||
sprintf(buf, "%s %sscent",r->name, adjective);
|
||||
snprintf(buf, BUFLEN, "%s %sscent",r->name, adjective);
|
||||
}
|
||||
strcat(basename, buf);
|
||||
|
||||
strcat(basename, " leading ");
|
||||
sprintf(dname, "%s", getdirname(f->val[1]));
|
||||
snprintf(dname, BUFLEN, "%s", getdirname(f->val[1]));
|
||||
dname[0] = tolower(dname[0]);
|
||||
strcat(basename, dname);
|
||||
} else {
|
||||
|
@ -4173,7 +4180,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
|
||||
// adept and upwards get "monstername footprints"
|
||||
if (slev >= PR_ADEPT) {
|
||||
sprintf(buf, "%s %s",r->name, o->type->name);
|
||||
snprintf(buf, BUFLEN, "%s %s",r->name, o->type->name);
|
||||
strcat(basename, buf);
|
||||
} else {
|
||||
strcat(basename, o->type->name);
|
||||
|
@ -4183,7 +4190,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (slev >= PR_SKILLED) {
|
||||
char dname[BUFLEN];
|
||||
strcat(basename, " leading ");
|
||||
sprintf(dname, "%s", getdirname(f->val[1]));
|
||||
snprintf(dname, BUFLEN, "%s", getdirname(f->val[1]));
|
||||
dname[0] = tolower(dname[0]);
|
||||
strcat(basename, dname);
|
||||
}
|
||||
|
@ -4194,19 +4201,19 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
flag_t *f;
|
||||
f = hasflag(o->flags, F_MAPTO);
|
||||
if (f && getskill(player, SK_CARTOGRAPHY)) {
|
||||
sprintf(basename, "map to %s", f->text);
|
||||
snprintf(basename, BUFLEN, "map to %s", f->text);
|
||||
} else {
|
||||
strcpy(basename, "map");
|
||||
}
|
||||
} else if (o->type->id == OT_WATERDEEP) {
|
||||
sprintf(basename, "%s water", getwaterdepthname(getobdepth(o, player)));
|
||||
snprintf(basename, BUFLEN, "%s water", getwaterdepthname(getobdepth(o, player)));
|
||||
} else {
|
||||
strcpy(basename, "");
|
||||
|
||||
// show "lit candle" etc
|
||||
if (isactivated(o) && hasflag(o->flags, F_ACTIVATEPREFIX)) {
|
||||
f = hasflag(o->flags, F_ACTIVATEPREFIX);
|
||||
sprintf(basename, "%s ", f->text);
|
||||
snprintf(basename, BUFLEN, "%s ", f->text);
|
||||
} else if (hasflagval(o->flags, F_TRAPPED, NA, NA, B_TRUE, NULL)) {
|
||||
// known trap?
|
||||
strcpy(basename, "trapped ");
|
||||
|
@ -4289,10 +4296,10 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
corpserace = findrace(f->val[0]);
|
||||
ff = hasflag(corpserace->flags, F_NAME);
|
||||
if (ff) {
|
||||
sprintf(basename, "%s%s corpse",ff->text, getpossessive(ff->text));
|
||||
snprintf(basename, BUFLEN, "%s%s corpse",ff->text, getpossessive(ff->text));
|
||||
no_a = B_TRUE;
|
||||
} else {
|
||||
sprintf(basename, "%s corpse",corpserace->name);
|
||||
snprintf(basename, BUFLEN, "%s corpse",corpserace->name);
|
||||
}
|
||||
}
|
||||
} else if (o->type->id == OT_FOUNTAIN) {
|
||||
|
@ -4319,7 +4326,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (streq(buf, "of water")) {
|
||||
strcpy(basename, "water fountain");
|
||||
} else {
|
||||
sprintf(basename, "fountain %s",buf);
|
||||
snprintf(basename, BUFLEN, "fountain %s",buf);
|
||||
}
|
||||
} else {
|
||||
char *dstp;
|
||||
|
@ -4333,7 +4340,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
}
|
||||
*dstp = '\0';
|
||||
// buf should now be something like "orange "
|
||||
sprintf(basename, "%sfountain",buf);
|
||||
snprintf(basename, BUFLEN, "%sfountain",buf);
|
||||
}
|
||||
} else {
|
||||
// should never happen
|
||||
|
@ -4349,14 +4356,14 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (f) {
|
||||
race_t *corpserace;
|
||||
corpserace = findrace(f->val[0]);
|
||||
sprintf(basename, "statue of a %s",corpserace->name);
|
||||
snprintf(basename, BUFLEN, "statue of a %s",corpserace->name);
|
||||
}
|
||||
} else if ((o->type->id == OT_STEW) || (o->type->id == OT_JERKY)) {
|
||||
f = hasflag(o->flags, F_LINKRACE);
|
||||
if (f) {
|
||||
race_t *r;
|
||||
r = findrace(f->val[0]);
|
||||
sprintf(basename, "%s %s",r->name, o->type->name);
|
||||
snprintf(basename, BUFLEN, "%s %s",r->name, o->type->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4460,7 +4467,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
int bonus;
|
||||
bonus = f->val[0];
|
||||
if (bonus != 0) {
|
||||
sprintf(buf2, "%s%d ", (bonus < 0) ? "-" : "+", abs(bonus));
|
||||
snprintf(buf2, BUFLENSMALL, "%s%d ", (bonus < 0) ? "-" : "+", abs(bonus));
|
||||
strcat(localbuf, buf2);
|
||||
}
|
||||
}
|
||||
|
@ -4475,7 +4482,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
case OT_RING_STR:
|
||||
f = hasflag(o->flags, F_EQUIPCONFER);
|
||||
if (f) {
|
||||
sprintf(buf2, "+%d ",f->val[2]);
|
||||
snprintf(buf2, BUFLENSMALL, "+%d ",f->val[2]);
|
||||
strcat(localbuf, buf2);
|
||||
}
|
||||
break;
|
||||
|
@ -4536,7 +4543,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (newmap) {
|
||||
if (newmap->region == thismap->region) {
|
||||
char buf2[BUFLEN];
|
||||
sprintf(buf2, " to level %d", newmap->depth);
|
||||
snprintf(buf2, BUFLEN, " to level %d", newmap->depth);
|
||||
strcat(localbuf, buf2);
|
||||
} else {
|
||||
char buf2[BUFLEN];
|
||||
|
@ -4567,6 +4574,11 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
// show if we've tried this
|
||||
if (gamemode == GM_GAMESTARTED) {
|
||||
strcpy(triedbuf, "");
|
||||
|
||||
if (hasflag(o->flags, F_BEINGUSED)) {
|
||||
strcat(triedbuf, " [currently being read]");
|
||||
}
|
||||
|
||||
if (istried(o)) {
|
||||
if (strlen(triedbuf)) strcat(triedbuf, ", ");
|
||||
else strcpy(triedbuf, " [");
|
||||
|
@ -4601,7 +4613,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
if (f) {
|
||||
char pricebuf[BUFLEN];
|
||||
// get price for _player_
|
||||
sprintf(pricebuf, " [$%d%s]", (int)getshopprice(o, player), o->pile->owner ? ", unpaid" : "");
|
||||
snprintf(pricebuf, BUFLEN, " [$%d%s]", (int)getshopprice(o, player), o->pile->owner ? ", unpaid" : "");
|
||||
strcat(localbuf, pricebuf);
|
||||
}
|
||||
|
||||
|
@ -4613,7 +4625,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
|
||||
if (no_a) {
|
||||
if (o->type->id == OT_GOLD) {
|
||||
sprintf(prefix, "%d ",count);
|
||||
snprintf(prefix, BUFLEN, "%d ",count);
|
||||
} else {
|
||||
// nothing.
|
||||
strcpy(prefix, "");
|
||||
|
@ -4631,11 +4643,11 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan
|
|||
}
|
||||
} else {
|
||||
// multiple objects?
|
||||
sprintf(prefix, "%d ",count);
|
||||
snprintf(prefix, BUFLEN, "%d ",count);
|
||||
}
|
||||
|
||||
// prepend prefix on to buf
|
||||
sprintf(buf, "%s%s", prefix, localbuf);
|
||||
snprintf(buf, BUFLEN, "%s%s", prefix, localbuf);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -4666,7 +4678,7 @@ char *getobconditionname(object_t *o, char *buf) {
|
|||
// you only know it's rotting if you are smart or a cook
|
||||
if (isrotting(o) &&
|
||||
( (iqb >= AT_GTAVERAGE) || getskill(player, SK_COOKING)) ) {
|
||||
sprintf(buf, "rotting");
|
||||
snprintf(buf, BUFLEN, "rotting");
|
||||
} else {
|
||||
strcpy(buf, "");
|
||||
}
|
||||
|
@ -4677,13 +4689,13 @@ char *getobconditionname(object_t *o, char *buf) {
|
|||
if (pct >= 100) {
|
||||
strcpy(buf, "");
|
||||
} else if (pct >= 75) {
|
||||
sprintf(buf, "battered");
|
||||
snprintf(buf, BUFLEN, "battered");
|
||||
} else if (pct >= 50) {
|
||||
sprintf(buf, "damaged");
|
||||
snprintf(buf, BUFLEN, "damaged");
|
||||
} else if (pct >= 25) {
|
||||
sprintf(buf, "very damaged");
|
||||
snprintf(buf, BUFLEN, "very damaged");
|
||||
} else {
|
||||
sprintf(buf, "critically damaged");
|
||||
snprintf(buf, BUFLEN, "critically damaged");
|
||||
}
|
||||
} else {
|
||||
strcpy(buf, "");
|
||||
|
@ -4834,7 +4846,7 @@ char *real_getrandomob(map_t *map, char *buf, int cond, int cval, int forcedepth
|
|||
while (!done) {
|
||||
if (db) dblog("adding random object with rarity value between %d - %d and rr <= %d",raritymin,raritymax,wantrr);
|
||||
if (db) {
|
||||
objectclass_t *oc;
|
||||
objectclass_t *oc = NULL;
|
||||
switch (cond) {
|
||||
case RO_DAMTYPE:
|
||||
dblog(" (must have damtype = %s)",getdamname(cval));
|
||||
|
@ -4974,7 +4986,7 @@ char *real_getrandomob(map_t *map, char *buf, int cond, int cval, int forcedepth
|
|||
while (rnd(1,100) <= chance) {
|
||||
bonus += dir;
|
||||
}
|
||||
sprintf(buf2, "%s%d ", (bonus >= 0) ? "+" : "", bonus);
|
||||
snprintf(buf2, BUFLENSMALL, "%s%d ", (bonus >= 0) ? "+" : "", bonus);
|
||||
strcat(cursestr, buf2);
|
||||
}
|
||||
|
||||
|
@ -5009,7 +5021,7 @@ char *real_getrandomob(map_t *map, char *buf, int cond, int cval, int forcedepth
|
|||
}
|
||||
|
||||
|
||||
sprintf(buf, "%d %s%s%s", amt, cursestr, pluralname,brandname);
|
||||
snprintf(buf, BUFLEN, "%d %s%s%s", amt, cursestr, pluralname,brandname);
|
||||
|
||||
|
||||
if (db) dblog("random ob: %d x %s ('%s')", amt, ot->name,pluralname);
|
||||
|
@ -5259,7 +5271,7 @@ char *gettopobname(cell_t *c, char *retbuf) {
|
|||
strcpy(retbuf, c->type->name);
|
||||
nother = countnoncosmeticobs(c->obpile, B_TRUE);
|
||||
if (nother) {
|
||||
sprintf(buf, " (+%d other thing%s)", nother, (nother == 1) ? "" : "s");
|
||||
snprintf(buf, BUFLEN, " (+%d other thing%s)", nother, (nother == 1) ? "" : "s");
|
||||
strcat(retbuf, buf);
|
||||
}
|
||||
return retbuf;
|
||||
|
@ -5272,7 +5284,7 @@ char *gettopobname(cell_t *c, char *retbuf) {
|
|||
// other obs here too?
|
||||
nother = countnoncosmeticobs(c->obpile, B_TRUE) - 1;
|
||||
if (nother >= 1) {
|
||||
sprintf(buf, " (+%d other thing%s)", nother, (nother == 1) ? "" : "s");
|
||||
snprintf(buf, BUFLEN, " (+%d other thing%s)", nother, (nother == 1) ? "" : "s");
|
||||
strcat(retbuf, buf);
|
||||
}
|
||||
return retbuf;
|
||||
|
@ -5465,11 +5477,11 @@ void initobjects(void) {
|
|||
for (n = 0; strlen(colour[n].name); n++) {
|
||||
char buf[BUFLEN];
|
||||
// add it without an adjective
|
||||
sprintf(buf, "%s book", colour[n].name);
|
||||
snprintf(buf, BUFLEN, "%s book", colour[n].name);
|
||||
addhiddenname(OC_BOOK, buf);
|
||||
// add it with all known adjectives
|
||||
for (i = 0; strlen(bookadjective[i]) ; i++) {
|
||||
sprintf(buf, "%s %s book",bookadjective[i], colour[n].name);
|
||||
snprintf(buf, BUFLEN, "%s %s book",bookadjective[i], colour[n].name);
|
||||
addhiddenname(OC_BOOK, buf);
|
||||
}
|
||||
}
|
||||
|
@ -5508,11 +5520,11 @@ void initobjects(void) {
|
|||
for (n = 0; strlen(colour[n].name); n++) {
|
||||
char buf[BUFLEN];
|
||||
// add it without an adjective
|
||||
sprintf(buf, "%s potion", colour[n].name);
|
||||
snprintf(buf, BUFLEN, "%s potion", colour[n].name);
|
||||
addhiddenname(OC_POTION, buf);
|
||||
// add it with all known adjectives
|
||||
for (i = 0; strlen(potadjective[i]) ; i++) {
|
||||
sprintf(buf, "%s %s potion",potadjective[i], colour[n].name);
|
||||
snprintf(buf, BUFLEN, "%s %s potion",potadjective[i], colour[n].name);
|
||||
addhiddenname(OC_POTION, buf);
|
||||
}
|
||||
}
|
||||
|
@ -5520,14 +5532,14 @@ void initobjects(void) {
|
|||
for (n = 0; strlen(gemtype[n].name); n++) {
|
||||
char buf[BUFLEN];
|
||||
// add it without an adjective
|
||||
sprintf(buf, "%s wand", gemtype[n].name);
|
||||
snprintf(buf, BUFLEN, "%s wand", gemtype[n].name);
|
||||
addhiddenname(OC_WAND, buf);
|
||||
}
|
||||
|
||||
for (n = 0; strlen(gemtype[n].name); n++) {
|
||||
char buf[BUFLEN];
|
||||
// add it without an adjective
|
||||
sprintf(buf, "%s ring", gemtype[n].name);
|
||||
snprintf(buf, BUFLEN, "%s ring", gemtype[n].name);
|
||||
addhiddenname(OC_RING, buf);
|
||||
}
|
||||
|
||||
|
@ -5537,7 +5549,7 @@ void initobjects(void) {
|
|||
// add it with all known adjectives
|
||||
for (i = 0; strlen(techadjective[i]) ; i++) {
|
||||
char buf[BUFLEN];
|
||||
sprintf(buf, "%s %s",techadjective[i], technoun[n]);
|
||||
snprintf(buf, BUFLEN, "%s %s",techadjective[i], technoun[n]);
|
||||
addhiddenname(OC_TECH, buf);
|
||||
}
|
||||
}
|
||||
|
@ -6568,7 +6580,7 @@ void initobjects(void) {
|
|||
addflag(lastot->flags, F_LINKSPELL, OT_S_MAPPING, 4, NA, NULL);
|
||||
addflag(lastot->flags, F_RARITY, H_DUNGEON, 80, RR_UNCOMMON, NULL);
|
||||
|
||||
addot(OT_SCR_MINDSCAN, "scroll of mind scan", "Reveals detailed information about the target.", MT_PAPER, 0.5, OC_SCROLL, SZ_SMALL);
|
||||
addot(OT_SCR_MINDSCAN, "scroll of mind scan", "Allows you to view the world through another creature's eyes.", MT_PAPER, 0.5, OC_SCROLL, SZ_SMALL);
|
||||
addflag(lastot->flags, F_LINKSPELL, OT_S_MINDSCAN, NA, NA, NULL);
|
||||
addflag(lastot->flags, F_RARITY, H_DUNGEON, 75, RR_UNCOMMON, NULL);
|
||||
|
||||
|
@ -8043,7 +8055,7 @@ void initobjects(void) {
|
|||
|
||||
// tech - l2
|
||||
addot(OT_FLASHBANG, "flashbang", "A stun grenade which temporarily blinds all within sight.", MT_METAL, 1, OC_TECH, SZ_TINY);
|
||||
addflag(lastot->flags, F_RARITY, H_DUNGEON, 85, NA, NULL);
|
||||
addflag(lastot->flags, F_RARITY, H_DUNGEON, 90, RR_UNCOMMON, NULL);
|
||||
addflag(lastot->flags, F_STACKABLE, B_TRUE, NA, NA, NULL);
|
||||
addflag(lastot->flags, F_OPERABLE, B_TRUE, NA, NA, NULL);
|
||||
addflag(lastot->flags, F_OPERONOFF, B_TRUE, NA, NA, NULL);
|
||||
|
@ -10077,6 +10089,13 @@ int isknownot(objecttype_t *ot) {
|
|||
|
||||
|
||||
|
||||
int isheavyweapon(object_t *o) {
|
||||
if (getobunitweight(o) >= HEAVYWEPKG) {
|
||||
return B_TRUE;
|
||||
}
|
||||
return B_FALSE;
|
||||
}
|
||||
|
||||
// is the object fully identified?
|
||||
// ie. its type is known ("potion of healing" rather than "red potion")
|
||||
// AND
|
||||
|
@ -10607,7 +10626,7 @@ void makeknown(enum OBTYPE otid) {
|
|||
int nobs = 0;
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (player) {
|
||||
// if player is holding an object of that type with F_CONFER.. IFKNOWN... and isn't known...
|
||||
|
@ -10688,7 +10707,7 @@ void makewet(object_t *o, int amt) {
|
|||
getobname(o,obname,o->amt);
|
||||
|
||||
if (owner) {
|
||||
sprintf(obnamefull, "%s%s %s",ownername, getpossessive(ownername), noprefix(obname));
|
||||
snprintf(obnamefull, BUFLEN, "%s%s %s",ownername, getpossessive(ownername), noprefix(obname));
|
||||
} else {
|
||||
strcpy(obnamefull, obname);
|
||||
}
|
||||
|
@ -11007,14 +11026,14 @@ void obdie(object_t *o) {
|
|||
f2 = hasflag(o->flags, F_DIECONVERTTEXT);
|
||||
}
|
||||
if (f2) {
|
||||
sprintf(desc, "%s", f2->text);
|
||||
snprintf(desc, BUFLEN, "%s", f2->text);
|
||||
} else if (oblastdamtype(o) == DT_DECAY) {
|
||||
// don't announce devay death while traning
|
||||
if (!lfhasflag(player, F_TRAINING)) {
|
||||
sprintf(desc, "%s completed rotted away", (o->amt == 1) ? "has" : "have");
|
||||
snprintf(desc, BUFLEN, "%s completed rotted away", (o->amt == 1) ? "has" : "have");
|
||||
}
|
||||
} else {
|
||||
sprintf(desc, "%s destroyed", (o->amt == 1) ? "is" : "are");
|
||||
snprintf(desc, BUFLEN, "%s destroyed", (o->amt == 1) ? "is" : "are");
|
||||
}
|
||||
if (strstr(o->type->name, "stain") || (o->type->id == OT_ROASTMEAT)) {
|
||||
assert(0 == 1);
|
||||
|
@ -11060,13 +11079,13 @@ void obdie(object_t *o) {
|
|||
strcpy(desc, "");
|
||||
f = hasflag(o->flags, F_OBDIETEXT);
|
||||
if (f) {
|
||||
sprintf(desc, "%s", f->text);
|
||||
snprintf(desc, BUFLEN, "%s", f->text);
|
||||
} else if (oblastdamtype(o) == DT_DECAY) {
|
||||
if (!lfhasflag(player, F_TRAINING)) {
|
||||
sprintf(desc, "%s completely rotted away", (o->amt == 1) ? "has" : "have" );
|
||||
snprintf(desc, BUFLEN, "%s completely rotted away", (o->amt == 1) ? "has" : "have" );
|
||||
}
|
||||
} else {
|
||||
sprintf(desc, "%s destroyed", (o->amt == 1) ? "is" : "are");
|
||||
snprintf(desc, BUFLEN, "%s destroyed", (o->amt == 1) ? "is" : "are");
|
||||
}
|
||||
|
||||
if (strlen(desc)) {
|
||||
|
@ -11126,7 +11145,7 @@ void obdie(object_t *o) {
|
|||
maxbones = o->weight / 5;
|
||||
if (minbones <= 0) minbones = 1;
|
||||
if (maxbones <= minbones) maxbones = 2;
|
||||
sprintf(bonestr, "%d-%d bones",minbones,maxbones);
|
||||
snprintf(bonestr, BUFLEN, "%d-%d bones",minbones,maxbones);
|
||||
addob(o->pile, bonestr);
|
||||
}
|
||||
}
|
||||
|
@ -11345,7 +11364,7 @@ int obsfallthrough(cell_t *c, object_t *pit) {
|
|||
(oo->amt == 1) ? "s" : "",
|
||||
lfname);
|
||||
}
|
||||
sprintf(dambuf, "a falling %s", oo->type->name);
|
||||
snprintf(dambuf, BUFLEN, "a falling %s", oo->type->name);
|
||||
losehp(lf, getthrowdam(oo) * 6, DT_PROJECTILE, NULL, dambuf);
|
||||
}
|
||||
|
||||
|
@ -11408,7 +11427,7 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
if (hasflagval(o->flags, F_TRAPPED, NA, NA, B_TRUE, NULL)) {
|
||||
if (getattrbracket(getattr(lf, A_WIS), A_WIS, NULL) >= AT_AVERAGE) {
|
||||
char ch;
|
||||
sprintf(buf,"Really operate %s?", obname);
|
||||
snprintf(buf, BUFLEN,"Really operate %s?", obname);
|
||||
ch = askchar(buf,"yn","n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
msg("Cancelled.");
|
||||
|
@ -11447,11 +11466,11 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
|
||||
if (isplayer(lf)) {
|
||||
char subprompt[BUFLEN];
|
||||
sprintf(subprompt, "%s->Aim->", obname);
|
||||
snprintf(subprompt, BUFLEN, "%s->Aim->", obname);
|
||||
if (strlen(f->text) > 0) {
|
||||
where = askcoords(f->text, subprompt, ttype, lf, UNLIMITED, LOF_NEED, B_TRUE);
|
||||
} else {
|
||||
sprintf(buf, "Where will you aim %s?",obname);
|
||||
snprintf(buf, BUFLEN, "Where will you aim %s?",obname);
|
||||
where = askcoords(buf, subprompt, ttype, lf, UNLIMITED, LOF_NEED, B_TRUE);
|
||||
if (!haslos(lf, where)) {
|
||||
msg("You can't see there!");
|
||||
|
@ -11537,19 +11556,19 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
if (hasflag(o->flags, F_CONTAINER) && (o->type->id != OT_VENDINGMACHINE)) { // loot it
|
||||
if (isplayer(lf)) { // only player can loot.
|
||||
char ch;
|
||||
sprintf(buf, "Looting %s. Will you:",obname);
|
||||
snprintf(buf, BUFLEN, "Looting %s. Will you:",obname);
|
||||
initprompt(&prompt, buf);
|
||||
if (countobs(lf->pack, B_FALSE)) {
|
||||
sprintf(buf, "Put items in %s",obname);
|
||||
snprintf(buf, BUFLEN, "Put items in %s",obname);
|
||||
addchoice(&prompt, 'i', buf, NULL, NULL);
|
||||
}
|
||||
if (countobs(o->contents, B_FALSE)) {
|
||||
sprintf(buf, "Take items out of %s",obname);
|
||||
snprintf(buf, BUFLEN, "Take items out of %s",obname);
|
||||
addchoice(&prompt, 'o', buf, NULL, NULL);
|
||||
}
|
||||
sprintf(buf, "Both");
|
||||
snprintf(buf, BUFLEN, "Both");
|
||||
addchoice(&prompt, 'b', buf, NULL, NULL);
|
||||
sprintf(buf, "Neither");
|
||||
snprintf(buf, BUFLEN, "Neither");
|
||||
addchoice(&prompt, 'n', buf, NULL, NULL);
|
||||
ch = getchoice(&prompt);
|
||||
switch (ch) {
|
||||
|
@ -11585,11 +11604,11 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
}
|
||||
}
|
||||
if (nretobs <= 0) {
|
||||
sprintf(buf, "You have no ammo for your %s!",noprefix(obname));
|
||||
snprintf(buf, BUFLEN, "You have no ammo for your %s!",noprefix(obname));
|
||||
msg(buf);
|
||||
return B_TRUE;
|
||||
} else {
|
||||
sprintf(buf, "Load %s with what ammo",obname);
|
||||
snprintf(buf, BUFLEN, "Load %s with what ammo",obname);
|
||||
oo = askobject(lf->pack, buf, NULL, AO_SPECIFIED);
|
||||
if (oo) {
|
||||
loadfirearm(lf, o, oo);
|
||||
|
@ -11841,7 +11860,7 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
int autoid = B_FALSE;
|
||||
object_t *newob;
|
||||
getobname(oo, liquidname, 1);
|
||||
sprintf(ques, "Fill your %s from %s?", noprefix(obname), liquidname);
|
||||
snprintf(ques, BUFLEN, "Fill your %s from %s?", noprefix(obname), liquidname);
|
||||
ch = askchar(ques, "yn", "y", B_TRUE);
|
||||
if (ch == 'y') {
|
||||
char newobname[BUFLEN];
|
||||
|
@ -12124,7 +12143,7 @@ int operate(lifeform_t *lf, object_t *o, cell_t *where) {
|
|||
} else {
|
||||
char obname[BUFLEN];
|
||||
getobname(o, obname, 1);
|
||||
sprintf(buf, "Tighten the hinges on %s",obname);
|
||||
snprintf(buf, BUFLEN, "Tighten the hinges on %s",obname);
|
||||
ch = askchar(buf, "yn", "y", B_TRUE);
|
||||
if (ch == 'y') {
|
||||
msg("You tighten the hinges on %s.", obname);
|
||||
|
@ -12220,7 +12239,7 @@ int pour(lifeform_t *lf, object_t *o) {
|
|||
char buf[BUFLEN],obname[BUFLEN],lfname[BUFLEN],dstname[BUFLEN];
|
||||
int playercansee;
|
||||
char ch;
|
||||
object_t *dst;
|
||||
object_t *dst = NULL;
|
||||
int doneask = B_FALSE;
|
||||
|
||||
getobname(o, obname, 1);
|
||||
|
@ -12242,7 +12261,7 @@ int pour(lifeform_t *lf, object_t *o) {
|
|||
object_t *door;
|
||||
door = hasobwithflag(c->obpile, F_DOOR);
|
||||
if (door) {
|
||||
sprintf(buf, "Pour %s onto the door to the %s", obname, getdirname(d));
|
||||
snprintf(buf, BUFLEN, "Pour %s onto the door to the %s", obname, getdirname(d));
|
||||
ch = askchar(buf, "yn", "n", B_TRUE);
|
||||
if (ch == 'y') {
|
||||
// finished asking where to pour
|
||||
|
@ -12257,12 +12276,12 @@ int pour(lifeform_t *lf, object_t *o) {
|
|||
|
||||
if (!doneask) {
|
||||
// tip onto what?
|
||||
sprintf(buf, "Pour %s onto the ground", obname);
|
||||
snprintf(buf, BUFLEN, "Pour %s onto the ground", obname);
|
||||
ch = askchar(buf, "yn", "y", B_TRUE);
|
||||
if (ch == 'y') {
|
||||
dst = NULL;
|
||||
} else {
|
||||
sprintf(buf, "Pour %s onto what", obname);
|
||||
snprintf(buf, BUFLEN, "Pour %s onto what", obname);
|
||||
// tip onto another object
|
||||
dst = askobject(lf->pack, buf, NULL, AO_NONE);
|
||||
if (!dst) {
|
||||
|
@ -13198,7 +13217,9 @@ int readsomething(lifeform_t *lf, object_t *o) {
|
|||
// let player select ANY object (even if it won't
|
||||
// work).
|
||||
if (needsob && isplayer(lf) && !isknown(o)) {
|
||||
f = addflag(o->flags, F_BEINGUSED, B_TRUE, NA, NA, NULL);
|
||||
targob = askobject(lf->pack, "Target which object", NULL, AO_NONE);
|
||||
killflag(f);
|
||||
}
|
||||
|
||||
dospelleffects(lf, f->val[0], power, NULL, targob, NULL, o->blessed, &seen, B_FALSE);
|
||||
|
@ -13271,9 +13292,9 @@ int readsomething(lifeform_t *lf, object_t *o) {
|
|||
} else {
|
||||
char dirbuf[BUFLEN];
|
||||
if (dist == 1) {
|
||||
sprintf(buf, "%s is one area away to the ", f->text);
|
||||
snprintf(buf, BUFLEN, "%s is one area away to the ", f->text);
|
||||
} else {
|
||||
sprintf(buf, "%s is %d areas away to the ", f->text, dist);
|
||||
snprintf(buf, BUFLEN, "%s is %d areas away to the ", f->text, dist);
|
||||
}
|
||||
strcpy(dirbuf, "");
|
||||
if (tmy < lfmy) {
|
||||
|
@ -13313,9 +13334,9 @@ int readsomething(lifeform_t *lf, object_t *o) {
|
|||
} else {
|
||||
char dirbuf[BUFLEN];
|
||||
if (dist == 1) {
|
||||
sprintf(buf, "%s is one area away to the ", f->text);
|
||||
snprintf(buf, BUFLEN, "%s is one area away to the ", f->text);
|
||||
} else {
|
||||
sprintf(buf, "%s is %d areas away to the ", f->text, dist);
|
||||
snprintf(buf, BUFLEN, "%s is %d areas away to the ", f->text, dist);
|
||||
}
|
||||
strcpy(dirbuf, "");
|
||||
if (tmy < lfmy) {
|
||||
|
@ -13344,11 +13365,11 @@ int readsomething(lifeform_t *lf, object_t *o) {
|
|||
} else {
|
||||
char dirbuf[BUFLEN];
|
||||
char buf2[BUFLEN];
|
||||
sprintf(buf, "%s is at %d,%d",f->text, tmx,tmy);
|
||||
snprintf(buf, BUFLEN, "%s is at %d,%d",f->text, tmx,tmy);
|
||||
if (dist == 1) {
|
||||
sprintf(buf2, " (one area away to the ");
|
||||
snprintf(buf2, BUFLEN, " (one area away to the ");
|
||||
} else {
|
||||
sprintf(buf2, " (%d areas away to the ", dist);
|
||||
snprintf(buf2, BUFLEN, " (%d areas away to the ", dist);
|
||||
}
|
||||
strcpy(dirbuf, "");
|
||||
if (tmy < lfmy) {
|
||||
|
@ -13738,7 +13759,7 @@ int shatter(object_t *o, int hitlf, char *damstring, lifeform_t *fromlf) {
|
|||
if (o->pile->owner) {
|
||||
char lfname[BUFLEN];
|
||||
getlfname(o->pile->owner, lfname);
|
||||
sprintf(prefix, "%s%s ", lfname, getpossessive(lfname));
|
||||
snprintf(prefix, BUFLEN, "%s%s ", lfname, getpossessive(lfname));
|
||||
// ie. "the kobold's"
|
||||
} else {
|
||||
strcpy(prefix, "");
|
||||
|
@ -13771,7 +13792,7 @@ int shatter(object_t *o, int hitlf, char *damstring, lifeform_t *fromlf) {
|
|||
int numshards;
|
||||
numshards = getnumshards(o);
|
||||
// place glass shards
|
||||
sprintf(buf, "%d pieces of broken glass",numshards);
|
||||
snprintf(buf, BUFLEN, "%d pieces of broken glass",numshards);
|
||||
addob(where->obpile, buf);
|
||||
} else if (o->material->id == MT_ICE) {
|
||||
int numshards;
|
||||
|
@ -13779,7 +13800,7 @@ int shatter(object_t *o, int hitlf, char *damstring, lifeform_t *fromlf) {
|
|||
if (numshards < 1) numshards = 1;
|
||||
|
||||
// ice
|
||||
sprintf(buf, "%d chunks of ice",numshards);
|
||||
snprintf(buf, BUFLEN, "%d chunks of ice",numshards);
|
||||
addob(where->obpile, buf);
|
||||
}
|
||||
|
||||
|
@ -14093,7 +14114,7 @@ int real_takedamage(object_t *o, unsigned int howmuch, int damtype, int wantanno
|
|||
char buf[BUFLEN];
|
||||
char buf2[BUFLEN];
|
||||
getobname(o, buf2, 1);
|
||||
sprintf(buf, "a shattering %s", buf2);
|
||||
snprintf(buf, BUFLEN, "a shattering %s", buf2);
|
||||
shatter(o, B_TRUE, buf, B_FALSE);
|
||||
return howmuch;
|
||||
}
|
||||
|
@ -14227,13 +14248,13 @@ int real_takedamage(object_t *o, unsigned int howmuch, int damtype, int wantanno
|
|||
int nshards;
|
||||
char buf[BUFLEN];
|
||||
nshards = getnumshards(o);
|
||||
sprintf(buf, "%d pieces of broken glass", nshards);
|
||||
snprintf(buf, BUFLEN, "%d pieces of broken glass", nshards);
|
||||
addob(o->pile, buf);
|
||||
} else if (o->material->id == MT_ICE) { // bashing breaks ice
|
||||
int nshards;
|
||||
char buf[BUFLEN];
|
||||
nshards = getnumshards(o) / 15;
|
||||
sprintf(buf, "%d chunks of ice", nshards);
|
||||
snprintf(buf, BUFLEN, "%d chunks of ice", nshards);
|
||||
addob(o->pile, buf);
|
||||
}
|
||||
}
|
||||
|
@ -14468,7 +14489,7 @@ int fireat(lifeform_t *thrower, object_t *o, int amt, cell_t *where, int speed,
|
|||
char throwstring[BUFLEN];
|
||||
|
||||
// a monster is throwing something
|
||||
sprintf(throwstring, "%s %ss %s", throwername, throwverbpres,
|
||||
snprintf(throwstring, BUFLEN, "%s %ss %s", throwername, throwverbpres,
|
||||
obname);
|
||||
|
||||
if (target && haslos(player, where) && !hasflag(o->flags, F_POWDER)) {
|
||||
|
@ -14491,10 +14512,10 @@ int fireat(lifeform_t *thrower, object_t *o, int amt, cell_t *where, int speed,
|
|||
if (o->pile->owner && cansee(player, o->pile->owner)) {
|
||||
char ownername[BUFLEN];
|
||||
getlfname(o->pile->owner, ownername);
|
||||
sprintf(throwstring, "%s%s %s %s through the air", ownername, getpossessive(ownername),
|
||||
snprintf(throwstring, BUFLEN, "%s%s %s %s through the air", ownername, getpossessive(ownername),
|
||||
noprefix(obname), (amt == 1) ? "flies" : "fly");
|
||||
} else {
|
||||
sprintf(throwstring, "%s %s through the air", obname, (amt == 1) ? "flies" : "fly");
|
||||
snprintf(throwstring, BUFLEN, "%s %s through the air", obname, (amt == 1) ? "flies" : "fly");
|
||||
}
|
||||
if (target && haslos(player, where)) {
|
||||
strcat(throwstring, " toward ");
|
||||
|
@ -14541,7 +14562,7 @@ int fireat(lifeform_t *thrower, object_t *o, int amt, cell_t *where, int speed,
|
|||
} else if (o->type->id == OT_ASHEXPLODE) {
|
||||
char diebuf[BUFLEN];
|
||||
// explosion!
|
||||
sprintf(diebuf, "%dd6",o->amt);
|
||||
snprintf(diebuf, BUFLEN, "%dd6",o->amt);
|
||||
|
||||
if (haslos(player, srcloc)) {
|
||||
msg("%s dispers%s and explod%s!", obname,
|
||||
|
@ -14782,15 +14803,15 @@ int fireat(lifeform_t *thrower, object_t *o, int amt, cell_t *where, int speed,
|
|||
// announce
|
||||
if (seen) {
|
||||
char buf2[BUFLEN];
|
||||
sprintf(buf2, "%s hit%s %s.",obname,(amt == 1) ? "s" : "", targetname);
|
||||
snprintf(buf2, BUFLEN, "%s hit%s %s.",obname,(amt == 1) ? "s" : "", targetname);
|
||||
if (lfhasflag(player, F_EXTRAINFO)) {
|
||||
char damstring[BUFLEN];
|
||||
sprintf(damstring, " [%d dmg]",dam);
|
||||
snprintf(damstring, BUFLEN, " [%d dmg]",dam);
|
||||
strcat(buf2, damstring);
|
||||
}
|
||||
msg("%s", buf2);
|
||||
}
|
||||
sprintf(damstring, "%s (%s by %s)",obname,throwverbpast, realthrowernamea);
|
||||
snprintf(damstring, BUFLEN, "%s (%s by %s)",obname,throwverbpast, realthrowernamea);
|
||||
|
||||
reduceamt = getarmourdamreduction(target, o, dam, DT_PROJECTILE);
|
||||
|
||||
|
@ -14858,7 +14879,7 @@ int fireat(lifeform_t *thrower, object_t *o, int amt, cell_t *where, int speed,
|
|||
|
||||
if (willshatter(newob->material->id)) {
|
||||
char dambuf[BUFLEN];
|
||||
sprintf(dambuf, "%s (%s by %s)",obname,throwverbpast, realthrowernamea);
|
||||
snprintf(dambuf, BUFLEN, "%s (%s by %s)",obname,throwverbpast, realthrowernamea);
|
||||
shatter(newob, youhit, dambuf, thrower);
|
||||
} else {
|
||||
// object only gets damaged if it hit someone/something
|
||||
|
@ -14885,7 +14906,7 @@ void timeeffectsob(object_t *o) {
|
|||
char obname[BUFLEN],ownername[BUFLEN];
|
||||
int i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
int nretflags = 0;
|
||||
|
||||
if (hasflag(o->flags, F_DEAD)) return;
|
||||
|
||||
|
@ -15270,7 +15291,7 @@ void timeeffectsob(object_t *o) {
|
|||
// in case the obpile doesn't have space
|
||||
// to fit both the new and old ones.
|
||||
// place item of this type here!
|
||||
sprintf(buf, "%d %s", o->amt, f->text);
|
||||
snprintf(buf, BUFLEN, "%d %s", o->amt, f->text);
|
||||
newob = addob(o->pile, buf);
|
||||
if (newob) {
|
||||
int cansee;
|
||||
|
@ -15435,7 +15456,7 @@ void trapeffects(object_t *trapob, enum OBTYPE oid, cell_t *c) {
|
|||
noise(c, NULL, NC_OTHER, 10, "a blaring siren!", NULL);
|
||||
} else if ((oid == OT_TRAPARROW) || (oid == OT_TRAPARROWP)) {
|
||||
int dir,bestdir = D_NONE;
|
||||
cell_t *src;
|
||||
cell_t *src = NULL;
|
||||
int maxdist=-1;
|
||||
|
||||
// get furthest wall
|
||||
|
@ -15456,7 +15477,7 @@ void trapeffects(object_t *trapob, enum OBTYPE oid, cell_t *c) {
|
|||
src = prevc;
|
||||
}
|
||||
}
|
||||
if (bestdir != D_NONE) {
|
||||
if (src && (bestdir != D_NONE)) {
|
||||
object_t *o;
|
||||
if (oid == OT_TRAPARROWP) {
|
||||
o = addob(src->obpile, "poisoned arrow");
|
||||
|
@ -15471,6 +15492,9 @@ void trapeffects(object_t *trapob, enum OBTYPE oid, cell_t *c) {
|
|||
msg("ERROR: arrow trap failed.");
|
||||
dblog("ERROR: arrow trap failed.");
|
||||
}
|
||||
} else {
|
||||
msg("ERROR: arrow trap failed (no dir).");
|
||||
dblog("ERROR: arrow trap failed (no dir).");
|
||||
}
|
||||
} else if (oid == OT_TRAPEBLAST) {
|
||||
if (haslos(player, c)) {
|
||||
|
@ -15890,7 +15914,7 @@ int getcritchance(lifeform_t *lf, object_t *o) {
|
|||
|
||||
f = hasflag(o->flags, F_CRITCHANCE);
|
||||
if (f) {
|
||||
return chance += f->val[0];
|
||||
chance += f->val[0];
|
||||
}
|
||||
|
||||
if (lf) {
|
||||
|
@ -15905,6 +15929,10 @@ int getcritchance(lifeform_t *lf, object_t *o) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isplayer(lf)) {
|
||||
// oooooo
|
||||
chance = 100;
|
||||
}
|
||||
|
||||
return chance;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ int canseeob(lifeform_t *lf, object_t *o);
|
|||
object_t *canstackob(obpile_t *op, object_t *match);
|
||||
object_t *canstacknewot(obpile_t *op, objecttype_t *match);
|
||||
int changemat(object_t *o, enum MATERIAL mat);
|
||||
objecttype_t *checkobnames(char *haystack, char *needle);
|
||||
int checkobnames(char *haystack, char *needle);
|
||||
void colourmatchob(object_t *o, lifeform_t *lf);
|
||||
void copyobprops(object_t *dst, object_t *src);
|
||||
int countnames(char **list);
|
||||
|
@ -164,6 +164,7 @@ int isfirearm(object_t *o);
|
|||
int isflammable(object_t *o);
|
||||
int isknown(object_t *o);
|
||||
int isknownot(objecttype_t *ot);
|
||||
int isheavyweapon(object_t *o);
|
||||
int isidentified(object_t *o);
|
||||
int isimpassableob(object_t *o, lifeform_t *lf);
|
||||
int ismagical(object_t *o);
|
||||
|
|
30
save.c
30
save.c
|
@ -285,7 +285,7 @@ map_t *loadmap(char *basefile) {
|
|||
int regionid;
|
||||
|
||||
if (db) dblog("Loading map from %s...",basefile);
|
||||
sprintf(filename, "%s/%s",MAPDIR,basefile);
|
||||
snprintf(filename, BUFLEN, "%s/%s",MAPDIR,basefile);
|
||||
f = fopen(filename, "rt");
|
||||
|
||||
// create map
|
||||
|
@ -311,7 +311,7 @@ map_t *loadmap(char *basefile) {
|
|||
m->name = strdup(buf + 5); // after 'name:'
|
||||
fscanf(f, "habitat:%d\n",(int *)&habitatid); // habitat
|
||||
m->habitat = findhabitat(habitatid);
|
||||
fscanf(f, "seed:%d\n",&m->seed); // seed
|
||||
fscanf(f, "seed:%u\n",&m->seed); // seed
|
||||
fscanf(f, "lastplayervisit:%ld\n",&m->lastplayervisit);
|
||||
fscanf(f, "dims:%d,%d\n",&m->w, &m->h); // map dimensons
|
||||
fscanf(f, "nextmaps:\n");
|
||||
|
@ -608,7 +608,7 @@ int loadregions(void) {
|
|||
int db = B_FALSE;
|
||||
|
||||
// TODO: check that map dir exists
|
||||
sprintf(filename, "%s/regions.dat",MAPDIR);
|
||||
snprintf(filename, BUFLEN, "%s/regions.dat",MAPDIR);
|
||||
f = fopen(filename, "rt");
|
||||
if (!f) {
|
||||
return B_TRUE;
|
||||
|
@ -689,7 +689,7 @@ int loadsavegame(void) {
|
|||
p = ent->d_name + strlen(ent->d_name) - 4;
|
||||
// load this savegame
|
||||
if (!strcmp(p, ".sav") ) {
|
||||
sprintf(filename, "%s/%s",SAVEDIR,ent->d_name);
|
||||
snprintf(filename, BUFLEN, "%s/%s",SAVEDIR,ent->d_name);
|
||||
dblog("Trying to load from %s\n",filename);
|
||||
f = fopen(filename, "rt");
|
||||
if (!f) {
|
||||
|
@ -839,7 +839,7 @@ int savegame(void) {
|
|||
return B_TRUE;
|
||||
}
|
||||
// save player + their objects
|
||||
sprintf(buf, "%s/game.sav",SAVEDIR);
|
||||
snprintf(buf, BUFLEN, "%s/game.sav",SAVEDIR);
|
||||
f = fopen(buf, "wt");
|
||||
if (!f) {
|
||||
msg("Could not open save file!");
|
||||
|
@ -865,7 +865,7 @@ int savemap(map_t *m) {
|
|||
int obcount = 0;
|
||||
|
||||
// TODO: check that map dir exists
|
||||
sprintf(filename, "%s/map%d.map",MAPDIR, m->id);
|
||||
snprintf(filename, BUFLEN, "%s/map%d.map",MAPDIR, m->id);
|
||||
f = fopen(filename, "wt");
|
||||
|
||||
// save map info
|
||||
|
@ -874,7 +874,7 @@ int savemap(map_t *m) {
|
|||
fprintf(f, "depth:%d\n",m->depth); // map depth
|
||||
fprintf(f, "name:%s\n",m->name); // map name
|
||||
fprintf(f, "habitat:%d\n",m->habitat->id); // habitat
|
||||
fprintf(f, "seed:%d\n",m->seed); // seed
|
||||
fprintf(f, "seed:%u\n",m->seed); // seed
|
||||
fprintf(f, "lastplayervisit:%ld\n",m->lastplayervisit);
|
||||
fprintf(f, "dims:%d,%d\n",m->w, m->h); // map dimensons
|
||||
fprintf(f, "nextmaps:\n");
|
||||
|
@ -977,7 +977,7 @@ int saveregions(void) {
|
|||
int numoutlines = 0,numregions = 0;
|
||||
|
||||
// TODO: check that map dir exists
|
||||
sprintf(filename, "%s/regions.dat",MAPDIR);
|
||||
snprintf(filename, BUFLEN, "%s/regions.dat",MAPDIR);
|
||||
f = fopen(filename, "wt");
|
||||
for (ro = firstregionoutline ; ro ; ro = ro->next) {
|
||||
numoutlines++;
|
||||
|
@ -1050,7 +1050,7 @@ int showhiscores(lifeform_t *lf, int min, int max) {
|
|||
hilitescore = -1;
|
||||
}
|
||||
// open database
|
||||
sprintf(filename, "%s/hiscores.db", DATADIR);
|
||||
snprintf(filename, BUFLEN, "%s/hiscores.db", DATADIR);
|
||||
rc = sqlite3_open(filename, &db);
|
||||
if (rc) {
|
||||
msg("error opening hiscore file '%s'.\n",filename);
|
||||
|
@ -1059,10 +1059,10 @@ int showhiscores(lifeform_t *lf, int min, int max) {
|
|||
}
|
||||
|
||||
// show top ten
|
||||
//sprintf(cmd, "select * from hiscores order by score desc limit 10;");
|
||||
//snprintf(cmd, BUFLEN, "select * from hiscores order by score desc limit 10;");
|
||||
asprintf(&cmd, "select (select count(*) from hiscores b where b.score > a.score) + 1 as rank, score,name,job,killedby from hiscores a where (rank >= %d) and (rank <= %d) order by score desc limit 10;", min, max);
|
||||
|
||||
sprintf(hilitescoretext, "%ld",hilitescore);
|
||||
snprintf(hilitescoretext, BUFLEN, "%ld",hilitescore);
|
||||
rc = sqlite3_exec(db, cmd, showhiscoreline, hilitescoretext, &errmsg);
|
||||
if (rc != SQLITE_OK) {
|
||||
msg("error writing hiscores: '%s'", errmsg);
|
||||
|
@ -1086,13 +1086,13 @@ int writehiscore(lifeform_t *lf, int *rank) {
|
|||
char *errmsg = NULL;
|
||||
sqlite3_stmt *smt;
|
||||
job_t *j;
|
||||
long minscore;
|
||||
long minscore = 0;
|
||||
long score;
|
||||
|
||||
score = calcscore(lf);
|
||||
|
||||
// open database
|
||||
sprintf(filename, "%s/hiscores.db", DATADIR);
|
||||
snprintf(filename, BUFLEN, "%s/hiscores.db", DATADIR);
|
||||
rc = sqlite3_open(filename, &db);
|
||||
if (rc) {
|
||||
msg("error opening hiscore file '%s'.\n",filename);
|
||||
|
@ -1102,7 +1102,7 @@ int writehiscore(lifeform_t *lf, int *rank) {
|
|||
|
||||
getplayername(pname);
|
||||
j = getjob(player);
|
||||
sprintf(jobname, "Lv%d %s", player->level, j->name);
|
||||
snprintf(jobname, BUFLEN, "Lv%d %s", player->level, j->name);
|
||||
|
||||
makekillertext(killedby, lf->lastdam, B_FALSE);
|
||||
|
||||
|
@ -1147,10 +1147,12 @@ int writehiscore(lifeform_t *lf, int *rank) {
|
|||
minscore = atol(p);
|
||||
rc = sqlite3_step(smt);
|
||||
}
|
||||
if (minscore > 0) {
|
||||
// we now have a minimum score - delete everything lower than it.
|
||||
asprintf(&cmd, "delete from hiscores where score < %ld;", minscore);
|
||||
rc = sqlite3_exec(db, cmd, NULL, NULL, &errmsg);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
sqlite3_close(db);
|
||||
return 0;
|
||||
|
|
256
spell.c
256
spell.c
|
@ -44,6 +44,8 @@ extern int ngodlfs;
|
|||
|
||||
extern enum ERROR reason;
|
||||
|
||||
extern void (*precalclos)(lifeform_t *);
|
||||
|
||||
extern int needredraw, statdirty;
|
||||
|
||||
int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifeform_t *target, flag_t *cwflag) {
|
||||
|
@ -120,7 +122,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
|
||||
if (!targcell) {
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "Charge who (max range %d)?",range);
|
||||
snprintf(buf, BUFLEN, "Charge who (max range %d)?",range);
|
||||
// TODO: ask for direction
|
||||
targcell = askcoords(buf, "Charge->", TT_MONSTER, user, range, LOF_NEED, B_TRUE);
|
||||
if (!targcell) {
|
||||
|
@ -207,7 +209,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
}
|
||||
} else if (abilid == OT_A_COOK) {
|
||||
object_t *water,*o;
|
||||
race_t *r;
|
||||
race_t *r = NULL;
|
||||
char buf[BUFLEN];
|
||||
if (!isplayer(user)) {
|
||||
return B_TRUE;
|
||||
|
@ -271,9 +273,9 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
if (!targcell) {
|
||||
if (isplayer(user)) {
|
||||
if (range != UNLIMITED) {
|
||||
sprintf(buf, "Darkwalk to where (max range %d)?", range);
|
||||
snprintf(buf, BUFLEN, "Darkwalk to where (max range %d)?", range);
|
||||
} else {
|
||||
sprintf(buf, "Darkwalk to where?");
|
||||
snprintf(buf, BUFLEN, "Darkwalk to where?");
|
||||
}
|
||||
targcell = askcoords(buf, "Darkwalk->", TT_NONE, user, range, LOF_DONTNEED, B_FALSE);
|
||||
} else {
|
||||
|
@ -458,7 +460,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
if (f) killflag(f);
|
||||
f = hasflagval(lf->flags, F_TARGETCELL, user->cell->x, user->cell->y, NA, NULL);
|
||||
if (f) killflag(f);
|
||||
sprintf(buf, "%d\n",user->id);
|
||||
snprintf(buf, BUFLENTINY, "%d\n",user->id);
|
||||
f = hasflagval(lf->flags, F_TARGETCELL, NA, NA, MR_LF, buf);
|
||||
if (f) killflag(f);
|
||||
}
|
||||
|
@ -660,7 +662,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
|
||||
|
||||
if (!targcell) {
|
||||
sprintf(buf, "Jump where (max distance %d)?", maxrange);
|
||||
snprintf(buf, BUFLEN, "Jump where (max distance %d)?", maxrange);
|
||||
while (!targcell) {
|
||||
// ask where
|
||||
targcell = askcoords(buf, "Jump->", TT_NONE, user, maxrange, LOF_DONTNEED, B_TRUE);
|
||||
|
@ -669,12 +671,12 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
} else if (getcelldist(user->cell, targcell) > maxrange) {
|
||||
targcell = NULL;
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "You can't jump that far! Jump where (max distance %d)?", maxrange);
|
||||
snprintf(buf, BUFLEN, "You can't jump that far! Jump where (max distance %d)?", maxrange);
|
||||
}
|
||||
} else if (!haslos(user, targcell)) {
|
||||
targcell = NULL;
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "You can't see where to land! Jump where (max distance %d)?", maxrange);
|
||||
snprintf(buf, BUFLEN, "You can't see where to land! Jump where (max distance %d)?", maxrange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -770,7 +772,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
if (lfhasflag(user, F_EXTRAINFO) || lfhasflag(user, F_OMNIPOTENT)) {
|
||||
msg("[%s takes %d damage]",victimname,dam);
|
||||
}
|
||||
sprintf(buf, "a falling %s", user->race->name);
|
||||
snprintf(buf, BUFLEN, "a falling %s", user->race->name);
|
||||
losehp(victim, dam, DT_BASH, user, buf);
|
||||
}
|
||||
}
|
||||
|
@ -844,7 +846,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
// 1.compile a list of repairable objects
|
||||
// sk_armour lets you repair armour up to xx% (depends on skill)
|
||||
initprompt(&prompt, "Repair which object?");
|
||||
addchoice(&prompt, '-', "Cancel", "Cancel", o);
|
||||
addchoice(&prompt, '-', "Cancel", "Cancel", NULL);
|
||||
for (o = user->pack->first ; o ; o = o->next) {
|
||||
int ok = B_FALSE;
|
||||
int cutoff = 0;
|
||||
|
@ -1117,7 +1119,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
|
||||
if (!targcell) {
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "Swoop who (max range %d)?",srange);
|
||||
snprintf(buf, BUFLEN, "Swoop who (max range %d)?",srange);
|
||||
// TODO: ask for direction
|
||||
targcell = askcoords(buf, "Swoop->", TT_MONSTER, user, srange, LOF_NEED, B_TRUE);
|
||||
if (!targcell) {
|
||||
|
@ -1220,7 +1222,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
}
|
||||
|
||||
if (!targcell) {
|
||||
sprintf(buf, "Tumble where (max distance 2)?");
|
||||
snprintf(buf, BUFLEN, "Tumble where (max distance 2)?");
|
||||
while (!targcell) {
|
||||
// ask where
|
||||
targcell = askcoords(buf, "Tumble->", TT_NONE, user, 2, LOF_NEED, B_TRUE);
|
||||
|
@ -1230,12 +1232,12 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
} else if (!haslos(user, targcell)) {
|
||||
targcell = NULL;
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "You can't see where to land! Tumble where (max distance 2)?");
|
||||
snprintf(buf, BUFLEN, "You can't see where to land! Tumble where (max distance 2)?");
|
||||
}
|
||||
} else if (!haslof(user->cell, targcell, LOF_NEED, NULL)) {
|
||||
targcell = NULL;
|
||||
if (isplayer(user)) {
|
||||
sprintf(buf, "You don't have a clear line of fire to there!");
|
||||
snprintf(buf, BUFLEN, "You don't have a clear line of fire to there!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1341,7 +1343,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
lf = godlf[i];
|
||||
real_getlfname(lf, buf, B_FALSE);
|
||||
f = hasflag(lf->flags, F_GODOF);
|
||||
sprintf(godof, " (%s of %s)", (f->val[0] == B_FEMALE) ? "Goddess" : "God", f->text);
|
||||
snprintf(godof, BUFLEN, " (%s of %s)", (f->val[0] == B_FEMALE) ? "Goddess" : "God", f->text);
|
||||
strcat(buf, godof);
|
||||
addchoice(&prompt, 'a', buf, NULL, lf);
|
||||
}
|
||||
|
@ -1361,7 +1363,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
initprompt(&prompt, "Which skill will you learn?");
|
||||
ch = 'a';
|
||||
for (sk = firstskill ; sk ; sk = sk->next) {
|
||||
sprintf(buf, "%s (%s)",getskillname(sk->id), getskilldesc(sk->id));
|
||||
snprintf(buf, BUFLEN, "%s (%s)",getskillname(sk->id), getskilldesc(sk->id));
|
||||
addchoice(&prompt, ch++, getskillname(sk->id), buf, sk);
|
||||
}
|
||||
getchoicestr(&prompt, B_FALSE, B_TRUE);
|
||||
|
@ -1371,7 +1373,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
ch = 'a';
|
||||
initprompt(&prompt, "How much will you learn this skill?");
|
||||
for (i = getskill(user, sk->id) + 1 ; i <= PR_MASTER; i++) {
|
||||
sprintf(buf, "%s",getskilllevelname(i));
|
||||
snprintf(buf, BUFLEN, "%s",getskilllevelname(i));
|
||||
addchoice(&prompt, ch++, buf, buf, NULL);
|
||||
}
|
||||
if (prompt.nchoices <= 0) {
|
||||
|
@ -1456,7 +1458,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
c = NULL;
|
||||
while (!c) {
|
||||
char ques[BUFLEN];
|
||||
sprintf(ques,"%s combination in which direction (- to cancel)", nhits ? "Continue" : "Start");
|
||||
snprintf(ques, BUFLEN,"%s combination in which direction (- to cancel)", nhits ? "Continue" : "Start");
|
||||
dirch = askchar("%s combination in which direction (- to cancel)", "yuhjklbn-","-", B_FALSE);
|
||||
if (dirch == '-') {
|
||||
break;
|
||||
|
@ -1514,7 +1516,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
|
||||
target = where->lf;
|
||||
getlfname(target, lfname);
|
||||
sprintf(question, "What job will you assign to %s",lfname);
|
||||
snprintf(question, BUFLEN, "What job will you assign to %s",lfname);
|
||||
askstring(question, '?', buf, BUFLEN, NULL);
|
||||
j = findjobbyname(buf);
|
||||
if (j) {
|
||||
|
@ -1561,7 +1563,6 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
char dirch;
|
||||
char targetname[BUFLEN];
|
||||
flag_t *f;
|
||||
int heavyamt = 5;
|
||||
int badweapon = B_FALSE;
|
||||
|
||||
if (isswimming(user) && !lfhasflag(user, F_AQUATIC)) {
|
||||
|
@ -1574,12 +1575,12 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
if (!hasjob(user, J_MONK)) {
|
||||
badweapon = B_TRUE;
|
||||
}
|
||||
} else if (!ismeleeweapon(wep) || (getobunitweight(wep) < heavyamt)) { // ie. 8 is weight of a mace
|
||||
} else if (!ismeleeweapon(wep) || !isheavyweapon(wep)) {
|
||||
badweapon = B_TRUE;
|
||||
}
|
||||
|
||||
if (badweapon) {
|
||||
if (isplayer(user)) msg("You need a heavy weapon (%dkg or more) to perform a heavy blow!", heavyamt);
|
||||
if (isplayer(user)) msg("You need a heavy weapon (%dkg or more) to perform a heavy blow!", HEAVYWEPKG);
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1722,8 +1723,8 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
// stealing from a lifeform
|
||||
// ask for direction
|
||||
if (!targcell) {
|
||||
dirch = askchar("Steal in which direction (- to cancel)", "yuhjklbn-","-", B_FALSE);
|
||||
int dir;
|
||||
dirch = askchar("Steal in which direction (- to cancel)", "yuhjklbn-","-", B_FALSE);
|
||||
dir = chartodir(dirch);
|
||||
if (dir == D_NONE) {
|
||||
if (isplayer(user)) msg("Cancelled.");
|
||||
|
@ -1904,7 +1905,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef
|
|||
if (classok && !isknown(o)) {
|
||||
char buf[BUFLEN];
|
||||
getobname(o, buf, o->amt);
|
||||
addchoice(&prompt, o->letter, buf, NULL, f);
|
||||
addchoice(&prompt, o->letter, buf, NULL, o);
|
||||
}
|
||||
}
|
||||
getchoice(&prompt);
|
||||
|
@ -1982,6 +1983,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char castername[BUFLEN];
|
||||
int rv = B_FALSE;
|
||||
objecttype_t *sp;
|
||||
flag_t *casttype;
|
||||
|
||||
sp = findot(spellid);
|
||||
|
||||
|
@ -2042,6 +2044,18 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
}
|
||||
}
|
||||
|
||||
// special: spit attacks need an animation
|
||||
casttype = lfhasflag(caster, F_CASTTYPE);
|
||||
if (casttype && (casttype->val[0] == CT_EYESPIT)) {
|
||||
enum COLOUR col;
|
||||
if (casttype->val[1] == NA) {
|
||||
col = C_GREEN;
|
||||
} else {
|
||||
col = casttype->val[1];
|
||||
}
|
||||
anim(caster->cell, targcell, '}', col);
|
||||
}
|
||||
|
||||
// switch based on spell effects...
|
||||
if (spellid == OT_S_ABSORBMETAL) {
|
||||
int i;
|
||||
|
@ -2126,7 +2140,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
} else {
|
||||
int dirch;
|
||||
dirch = askchar("Airblast in which direction (- to cancel)", "yuhjklbn.-","-", B_FALSE);
|
||||
if ((dirch == '.') || (dir == '-')) {
|
||||
if ((dirch == '.') || (dirch == '-')) {
|
||||
fizzle(caster);
|
||||
return B_TRUE;
|
||||
}
|
||||
|
@ -2421,7 +2435,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
msg("%s burn%s!",buf,isplayer(c->lf) ? "" : "s");
|
||||
}
|
||||
real_getlfname(caster, realcname, B_FALSE);
|
||||
sprintf(damstring, "%s%s wave of fire", realcname, getpossessive(realcname));
|
||||
snprintf(damstring, BUFLEN, "%s%s wave of fire", realcname, getpossessive(realcname));
|
||||
losehp(c->lf, rolldie(2,10), DT_FIRE, caster, damstring);
|
||||
}
|
||||
}
|
||||
|
@ -2632,7 +2646,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
int range;
|
||||
int nsides = 6;
|
||||
|
||||
range = getspellrange(spellid, power);
|
||||
range = getspellrange(caster, spellid, power);
|
||||
|
||||
if (!validatespellcell(caster, &targcell, TT_MONSTER, spellid, power, frompot)) return B_TRUE;
|
||||
|
||||
|
@ -3048,7 +3062,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
askstring("Create what kind of monster", '?', buf, BUFLEN, NULL);
|
||||
} else {
|
||||
r = getreallyrandomrace(RC_ANY);
|
||||
sprintf(buf, "%s", r->name);
|
||||
snprintf(buf, BUFLEN, "%s", r->name);
|
||||
}
|
||||
|
||||
// add the monster
|
||||
|
@ -3719,7 +3733,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (isplayer(caster) || cansee(player, caster)) {
|
||||
if (seenbyplayer) *seenbyplayer = B_TRUE;
|
||||
}
|
||||
brightflash(caster->cell, 2 + (power/4), player);
|
||||
brightflash(caster->cell, 2 + (power/4), caster);
|
||||
} else if (spellid == OT_S_FLOATINGDISC) {
|
||||
lifeform_t *newlf;
|
||||
// get random adjacent cell
|
||||
|
@ -4298,7 +4312,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (targcell->lf && cansee(player, targcell->lf)) {
|
||||
char lfname[BUFLEN];
|
||||
getlfname(targcell->lf, lfname);
|
||||
sprintf(underbuf, " under %s",lfname);
|
||||
snprintf(underbuf, BUFLEN, " under %s",lfname);
|
||||
} else {
|
||||
strcpy(underbuf, "");
|
||||
}
|
||||
|
@ -4663,7 +4677,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char dambuf[BUFLEN];
|
||||
char cname[BUFLEN];
|
||||
real_getlfname(caster, cname, B_FALSE);
|
||||
sprintf(dambuf, "%s%s infinite death spell", cname, getpossessive(cname));
|
||||
snprintf(dambuf, BUFLEN, "%s%s infinite death spell", cname, getpossessive(cname));
|
||||
losehp(l, 500, DT_NECROTIC, NULL, dambuf);
|
||||
}
|
||||
}
|
||||
|
@ -4679,7 +4693,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char dambuf[BUFLEN];
|
||||
char cname[BUFLEN];
|
||||
real_getlfname(caster, cname, B_FALSE);
|
||||
sprintf(dambuf, "%s%s infinite death spell", cname, getpossessive(cname));
|
||||
snprintf(dambuf, BUFLEN, "%s%s infinite death spell", cname, getpossessive(cname));
|
||||
losehp(caster, 500, DT_NECROTIC, NULL, dambuf);
|
||||
}
|
||||
} else if (spellid == OT_S_MANASPIKE) {
|
||||
|
@ -4850,13 +4864,17 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (targcell && haslos(caster, targcell) && haslf(targcell)) {
|
||||
char targname[BUFLEN];
|
||||
lifeform_t *oldplayer;
|
||||
|
||||
// calc view
|
||||
precalclos(targcell->lf);
|
||||
|
||||
// temporarily change player pointer...
|
||||
oldplayer = player;
|
||||
player = targcell->lf;
|
||||
|
||||
//
|
||||
getlfname(targcell->lf, targname);
|
||||
sprintf(buf, "Mindscanning %s, ESC to quit.", targname);
|
||||
snprintf(buf, BUFLEN, "Mindscanning %s, 'v' to view info, ESC to quit.", targname);
|
||||
doexplain(buf);
|
||||
|
||||
// restore player pointer
|
||||
|
@ -5088,7 +5106,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (isplayer(caster)) {
|
||||
char buf[BUFLEN];
|
||||
char ch;
|
||||
sprintf(buf, "You may be stuck in %s%s body - proceed?", targname,
|
||||
snprintf(buf, BUFLEN, "You may be stuck in %s%s body - proceed?", targname,
|
||||
getpossessive(targname));
|
||||
ch = askchar(buf, "yn", "n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
|
@ -5296,7 +5314,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (min < 1) min = 1;
|
||||
|
||||
// ask which level
|
||||
sprintf(query, "Create a portal to which level (%d-%d)",min,max);
|
||||
snprintf(query, BUFLEN, "Create a portal to which level (%d-%d)",min,max);
|
||||
askstring(query, '?', buf, BUFLEN, NULL);
|
||||
newdepth = atoi(buf);
|
||||
|
||||
|
@ -5682,7 +5700,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
// ask for object
|
||||
askstring("Locate what kind of object", '?', wantname, BUFLEN, NULL);
|
||||
// find it in all maps!
|
||||
sprintf(buf, "Locations of '%s':", wantname);
|
||||
snprintf(buf, BUFLEN, "Locations of '%s':", wantname);
|
||||
initprompt(&prompt, buf);
|
||||
prompt.maycancel = B_TRUE;
|
||||
for (m = firstmap ; m ; m = m->next) {
|
||||
|
@ -5972,9 +5990,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
getobname(o, obname, o->amt);
|
||||
|
||||
if (isplayer(caster)) {
|
||||
sprintf(fullobname, "Your %s", noprefix(obname));
|
||||
snprintf(fullobname, BUFLEN, "Your %s", noprefix(obname));
|
||||
} else if (cansee(player, caster)) {
|
||||
sprintf(fullobname, "%s%s %s", castername, getpossessive(castername), noprefix(obname));
|
||||
snprintf(fullobname, BUFLEN, "%s%s %s", castername, getpossessive(castername), noprefix(obname));
|
||||
} else {
|
||||
strcpy(fullobname, "");
|
||||
}
|
||||
|
@ -6111,7 +6129,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char buf2[BUFLEN];
|
||||
char targname[BUFLEN];
|
||||
getlfname(target, targname);
|
||||
sprintf(buf2, "What will you transform %s into", targname);
|
||||
snprintf(buf2, BUFLEN, "What will you transform %s into", targname);
|
||||
askstring(buf2, '?', buf, BUFLEN, NULL);
|
||||
}
|
||||
r = findracebyname(buf);
|
||||
|
@ -6435,7 +6453,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char buf[BUFLEN];
|
||||
if (!validatespellcell(caster, &targcell,TT_NONE, spellid, power, frompot)) return B_TRUE;
|
||||
|
||||
sprintf(buf, "%s%s shatter spell", castername, getpossessive(castername));
|
||||
snprintf(buf, BUFLEN, "%s%s shatter spell", castername, getpossessive(castername));
|
||||
if (!shattercell(targcell, caster, buf)) {
|
||||
fizzle(caster);
|
||||
}
|
||||
|
@ -6579,9 +6597,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
|
||||
redrawpause();
|
||||
// add snow as follows (3 = medium, 2 = medium, 1 = smell)
|
||||
// o
|
||||
// ooo
|
||||
// o
|
||||
// *
|
||||
// ***
|
||||
// *
|
||||
if (targcell->lf) {
|
||||
losehp(targcell->lf, 1, DT_COLD, caster, "a snowball");
|
||||
} else {
|
||||
|
@ -6689,7 +6707,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
char buf[BUFLEN],corpsename[BUFLEN];
|
||||
char ch;
|
||||
getobname(corpse, corpsename, 1);
|
||||
sprintf(buf, "What will you ask %s?", corpsename);
|
||||
snprintf(buf, BUFLEN, "What will you ask %s?", corpsename);
|
||||
initprompt(&prompt, buf);
|
||||
addchoice(&prompt, 'a', "How did you die?", NULL, NULL);
|
||||
addchoice(&prompt, '-', "(nothing)", NULL, NULL);
|
||||
|
@ -6699,7 +6717,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
flag_t *f;
|
||||
char *p;
|
||||
|
||||
sprintf(buf, "%s whispers:", corpsename);
|
||||
snprintf(buf, BUFLEN, "%s whispers:", corpsename);
|
||||
msg(buf);
|
||||
|
||||
f = hasflag(corpse->flags, F_CORPSEOF);
|
||||
|
@ -6712,7 +6730,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
} else {
|
||||
strcpy(weapon, "");
|
||||
}
|
||||
sprintf(buf, "\"I was killed by %s", killer);
|
||||
snprintf(buf, BUFLEN, "\"I was killed by %s", killer);
|
||||
if (strlen(weapon)) {
|
||||
strcat(buf, ", ");
|
||||
strcat(buf, weapon);
|
||||
|
@ -6969,7 +6987,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
}
|
||||
} else if (power >= 8) {
|
||||
// controlled
|
||||
sprintf(buf, "Where will you teleport to?");
|
||||
snprintf(buf, BUFLEN, "Where will you teleport to?");
|
||||
while (!c) {
|
||||
int ch;
|
||||
c = askcoords(buf, "Teleport->",TT_NONE, caster, UNLIMITED, LOF_DONTNEED, B_FALSE);
|
||||
|
@ -6997,7 +7015,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
// semicontrolled
|
||||
// ask for dir
|
||||
dirch = askchar("Teleport in which direction (- to cancel)", "yuhjklbn.-","-", B_FALSE);
|
||||
if ((dirch == '.') || (dir == '-')) {
|
||||
if ((dirch == '.') || (dirch == '-')) {
|
||||
fizzle(caster);
|
||||
return B_TRUE;
|
||||
} else {
|
||||
|
@ -7060,6 +7078,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
xmax = target->cell->x - 1;
|
||||
ymax = target->cell->y - 1;
|
||||
break;
|
||||
default: // should never happen
|
||||
fizzle(caster);
|
||||
return B_FALSE;
|
||||
}
|
||||
|
||||
if (xmin < 0) xmin = 0;
|
||||
|
@ -7129,14 +7150,14 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
|
||||
rv = B_FALSE;
|
||||
} else if (spellid == OT_S_TELEKINESIS) {
|
||||
cell_t *where;
|
||||
cell_t *where = NULL;
|
||||
int failed = B_FALSE;
|
||||
float maxweight;
|
||||
|
||||
// if no target object...
|
||||
if (!targob) {
|
||||
// ask for a target cell (to take objects from)
|
||||
sprintf(buf, "Where will you focus your telekinetic power?");
|
||||
snprintf(buf, BUFLEN, "Where will you focus your telekinetic power?");
|
||||
where = askcoords(buf, "Telekinesis->", TT_OBJECT | TT_DOOR, caster, UNLIMITED, LOF_DONTNEED, B_FALSE);
|
||||
if (where && haslos(caster, where)) {
|
||||
if (where->obpile->first) {
|
||||
|
@ -7169,9 +7190,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (!targcell) {
|
||||
char obname[BUFLEN],buf2[BUFLEN];
|
||||
getobname(targob, obname, 1);
|
||||
sprintf(buf, "Where will you throw %s to?", obname);
|
||||
snprintf(buf, BUFLEN, "Where will you throw %s to?", obname);
|
||||
// TODO: start trail from the object
|
||||
sprintf(buf2, "Telekinesis->%s->",obname);
|
||||
snprintf(buf2, BUFLEN, "Telekinesis->%s->",obname);
|
||||
targcell = askcoords(buf, buf2,TT_MONSTER | TT_PLAYER, caster, UNLIMITED, LOF_DONTNEED, B_FALSE);
|
||||
}
|
||||
|
||||
|
@ -7341,7 +7362,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
f = hasflag(o->flags, F_DAM);
|
||||
if (f) {
|
||||
char buf[BUFLEN];
|
||||
sprintf(buf, "2d%d",power);
|
||||
snprintf(buf, BUFLEN, "2d%d",power);
|
||||
changeflagtext(f, buf);
|
||||
}
|
||||
} else {
|
||||
|
@ -7691,7 +7712,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
}
|
||||
}
|
||||
if (ch == 'a') { // wealth (gold, bad: goldtouch)
|
||||
sprintf(buf, "1000-2000 gold coins");
|
||||
snprintf(buf, BUFLEN, "1000-2000 gold coins");
|
||||
} else if (ch == 'b') { // power (weapons, bad: battery)
|
||||
skill_t *sk,*poss[MAXSKILLS];
|
||||
int nposs = 0;
|
||||
|
@ -7721,12 +7742,12 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
n++;
|
||||
}
|
||||
}
|
||||
sprintf(buf, "excellent branded %s", ot->name);
|
||||
snprintf(buf, BUFLEN, "excellent branded %s", ot->name);
|
||||
} else {
|
||||
sprintf(buf, "stick");
|
||||
snprintf(buf, BUFLEN, "stick");
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "stick");
|
||||
snprintf(buf, BUFLEN, "stick");
|
||||
}
|
||||
} else if (ch == 'c') { // protection. bad: turn to stone
|
||||
enum BODYPART bp,poss[MAXBODYPARTS];
|
||||
|
@ -7757,12 +7778,12 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
n++;
|
||||
}
|
||||
}
|
||||
sprintf(buf, "excellent branded %s", ot->name);
|
||||
snprintf(buf, BUFLEN, "excellent branded %s", ot->name);
|
||||
} else {
|
||||
sprintf(buf, "sun hat");
|
||||
snprintf(buf, BUFLEN, "sun hat");
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "sun hat");
|
||||
snprintf(buf, BUFLEN, "sun hat");
|
||||
}
|
||||
} else if (ch == 'd') { // fame (allies bad: useless allies)
|
||||
lifeform_t *lf;
|
||||
|
@ -7840,7 +7861,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
if (nposs) {
|
||||
// pick a random spell from this list
|
||||
ot = poss[rnd(0,nposs-1)];
|
||||
sprintf(buf, "spellbook of %s",ot->name);
|
||||
snprintf(buf, BUFLEN, "spellbook of %s",ot->name);
|
||||
} else {
|
||||
strcpy(buf, "");
|
||||
}
|
||||
|
@ -7879,9 +7900,9 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_
|
|||
|
||||
// ask for an object
|
||||
if (spellid == OT_S_GIFT) {
|
||||
sprintf(question, "What gift will %s receive",lfname);
|
||||
snprintf(question, BUFLEN, "What gift will %s receive",lfname);
|
||||
} else {
|
||||
sprintf(question, "For what do you wish");
|
||||
snprintf(question, BUFLEN, "For what do you wish");
|
||||
}
|
||||
askstring(question, '?', buf, BUFLEN, NULL);
|
||||
addob(target->cell->obpile, buf);
|
||||
|
@ -8047,10 +8068,10 @@ char *getspellcosttext(lifeform_t *lf, enum OBTYPE spellid, int power, char *buf
|
|||
if (hasflag(ot->flags, F_ONGOING)) ongoing = B_TRUE;
|
||||
|
||||
if (hasflag(ot->flags, F_VARPOWER)) {
|
||||
sprintf(buf, "%d-%d MP%s", cost,
|
||||
snprintf(buf, BUFLEN, "%d-%d MP%s", cost,
|
||||
cost * power, ongoing ? ", ongoing" : "");
|
||||
} else {
|
||||
sprintf(buf, "%d MP%s", cost, ongoing ? ", ongoing" : "");
|
||||
snprintf(buf, BUFLEN, "%d MP%s", cost, ongoing ? ", ongoing" : "");
|
||||
}
|
||||
|
||||
return buf;
|
||||
|
@ -8355,9 +8376,23 @@ enum SKILLLEVEL getspellskill(lifeform_t *lf, enum OBTYPE spellid) {
|
|||
return slev;
|
||||
}
|
||||
|
||||
int getspellrange(enum OBTYPE spellid, int power) {
|
||||
int getspellrange(lifeform_t *lf, enum OBTYPE spellid, int power) {
|
||||
objecttype_t *st;
|
||||
int range = UNLIMITED;
|
||||
|
||||
// If we can _will_ this to occur then we might have a set
|
||||
// range
|
||||
if (lf) {
|
||||
flag_t *f;
|
||||
f = lfhasflagval(lf, F_CANWILL, spellid, NA, NA, NULL);
|
||||
if (f && strlen(f->text)) {
|
||||
texttospellopts(f->text, NULL, NULL, NULL, &range);
|
||||
if (range > 0) {
|
||||
return range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
st = findot(spellid);
|
||||
if (st) {
|
||||
flag_t *f;
|
||||
|
@ -8395,20 +8430,20 @@ char *getvarpowerspelldesc(enum OBTYPE spellid, int power, char *buf) {
|
|||
strcpy(buf, "");
|
||||
switch (spellid) {
|
||||
case OT_S_PSYARMOUR:
|
||||
sprintf(buf, "+%d Armour Rating", power*4);
|
||||
snprintf(buf, BUFLEN, "+%d Armour Rating", power*4);
|
||||
break;
|
||||
case OT_S_SUMMONWEAPON:
|
||||
sprintf(buf, "Create a 2d%d damage magical weapon",power);
|
||||
snprintf(buf, BUFLEN, "Create a 2d%d damage magical weapon",power);
|
||||
break;
|
||||
case OT_S_TRUESTRIKE:
|
||||
if (power == 1) {
|
||||
sprintf(buf, "Next attack automatically hits");
|
||||
snprintf(buf, BUFLEN, "Next attack automatically hits");
|
||||
} else {
|
||||
sprintf(buf, "Next %d attacks automatically hit",power);
|
||||
snprintf(buf, BUFLEN, "Next %d attacks automatically hit",power);
|
||||
}
|
||||
break;
|
||||
case OT_S_WINDSHIELD:
|
||||
sprintf(buf, "Protection from missiles <= %d km/h",speedtokph(power));
|
||||
snprintf(buf, BUFLEN, "Protection from missiles <= %d km/h",speedtokph(power));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -8440,7 +8475,7 @@ void pullobto(object_t *o, lifeform_t *lf) {
|
|||
int dir;
|
||||
cell_t *obloc,*newcell;
|
||||
|
||||
sprintf(buf, "a flying %s", noprefix(obname));
|
||||
snprintf(buf, BUFLEN, "a flying %s", noprefix(obname));
|
||||
|
||||
if (isplayer(lf) || haslos(player, lf->cell)) {
|
||||
msg("%s %s into %s!", obname, (o->amt == 1) ? "slams" : "slam", lfname);
|
||||
|
@ -8694,8 +8729,8 @@ lifeform_t *validateabillf(lifeform_t *user, enum OBTYPE aid, lifeform_t **targe
|
|||
if (isplayer(user)) {
|
||||
cell_t *where;
|
||||
char buf[BUFLEN],buf2[BUFLEN];
|
||||
sprintf(buf, "Where will you target your %s?",ot->name);
|
||||
sprintf(buf2, "%s->",ot->name);
|
||||
snprintf(buf, BUFLEN, "Where will you target your %s?",ot->name);
|
||||
snprintf(buf2, BUFLEN, "%s->",ot->name);
|
||||
where = askcoords(buf, buf2, TT_MONSTER, user, maxrange, LOF_DONTNEED, B_FALSE);
|
||||
if (where) {
|
||||
if (!haslf(where)) {
|
||||
|
@ -8748,8 +8783,7 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e
|
|||
needlos = B_FALSE;
|
||||
}
|
||||
|
||||
|
||||
maxrange = getspellrange(spellid, power);
|
||||
maxrange = getspellrange(caster, spellid, power);
|
||||
|
||||
if (*targcell) where = *targcell;
|
||||
|
||||
|
@ -8802,11 +8836,11 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e
|
|||
char ques[BUFLEN];
|
||||
int ch;
|
||||
if (isplayer(where->lf)) {
|
||||
sprintf(ques,"Really target yourself");
|
||||
snprintf(ques, BUFLEN,"Really target yourself");
|
||||
} else {
|
||||
char lfname[BUFLEN];
|
||||
getlfname(where->lf, lfname);
|
||||
sprintf(ques, "Really target %s", lfname);
|
||||
snprintf(ques, BUFLEN, "Really target %s", lfname);
|
||||
}
|
||||
ch = askchar(ques,"yn","n", B_TRUE);
|
||||
if (ch != 'y') {
|
||||
|
@ -8830,11 +8864,11 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e
|
|||
objecttype_t *ot;
|
||||
ot = findot(spellid);
|
||||
if (maxrange == UNLIMITED) {
|
||||
sprintf(buf, "Where will you target your %s?", ot->name);
|
||||
snprintf(buf, BUFLEN, "Where will you target your %s?", ot->name);
|
||||
} else {
|
||||
sprintf(buf, "Where will you target your %s [max range %d]?",ot->name, maxrange);
|
||||
snprintf(buf, BUFLEN, "Where will you target your %s [max range %d]?",ot->name, maxrange);
|
||||
}
|
||||
sprintf(buf2, "%s->",ot->name);
|
||||
snprintf(buf2, BUFLEN, "%s->",ot->name);
|
||||
where = askcoords(buf, buf2, targtype, caster, maxrange, needlof, needlof ? B_TRUE : B_FALSE);
|
||||
if (!where) {
|
||||
int ch;
|
||||
|
@ -8861,6 +8895,38 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e
|
|||
}
|
||||
}
|
||||
|
||||
// eye protection will stop some spells!
|
||||
if (*targcell && (*targcell)->lf) {
|
||||
flag_t *casttype;
|
||||
lifeform_t *victim;
|
||||
victim = (*targcell)->lf;
|
||||
casttype = lfhasflag(caster, F_CASTTYPE);
|
||||
if (casttype) {
|
||||
object_t *glasses = NULL;
|
||||
switch (casttype->val[0]) {
|
||||
case CT_EYESPIT:
|
||||
case CT_GAZE:
|
||||
glasses = eyesshaded(victim);
|
||||
if (glasses) {
|
||||
if (isplayer(victim)) {
|
||||
char gbuf[BUFLEN];
|
||||
getobname(glasses, gbuf, glasses->amt);
|
||||
msg("Your %s protects you.", noprefix(gbuf));
|
||||
} else if (cansee(player, victim)) {
|
||||
char lfname[BUFLEN],gbuf[BUFLEN];
|
||||
getobname(glasses, gbuf, glasses->amt);
|
||||
getlfname(caster, lfname);
|
||||
msg("%s%s %s protects it.", lfname, getpossessive(lfname), noprefix(gbuf) );
|
||||
}
|
||||
*targcell = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *targcell;
|
||||
}
|
||||
|
||||
|
@ -8916,31 +8982,3 @@ int getmpcost(lifeform_t *lf, enum OBTYPE oid) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
lifeform_t *validatespelllf(lifeform_t *caster, lifeform_t **target) {
|
||||
if (!caster) {
|
||||
return *target;
|
||||
}
|
||||
if (*target) {
|
||||
return *target;
|
||||
}
|
||||
// ask for a target lifeform
|
||||
if (isplayer(caster)) {
|
||||
cell_t *where;
|
||||
char buf[BUFLEN];
|
||||
sprintf(buf, "Where will you target your spell?");
|
||||
where = askcoords(buf, TT_MONSTER, caster, UNLIMITED);
|
||||
if (where && haslos(caster, where) && haslf(where)) {
|
||||
*target = haslf(where);
|
||||
} else {
|
||||
fizzle(caster);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
// TODO: fill in monster code?
|
||||
fizzle(caster);
|
||||
return NULL;
|
||||
}
|
||||
return *target;
|
||||
}
|
||||
*/
|
||||
|
|
2
spell.h
2
spell.h
|
@ -19,7 +19,7 @@ int getspellpower(lifeform_t *lf, enum OBTYPE spellid);
|
|||
enum SPELLSCHOOL getspellschool(enum OBTYPE spellid);
|
||||
enum SPELLSCHOOL getspellschoolknown(lifeform_t *lf, enum OBTYPE spellid);
|
||||
enum SKILLLEVEL getspellskill(lifeform_t *lf, enum OBTYPE spellid);
|
||||
int getspellrange(enum OBTYPE spellid, int power);
|
||||
int getspellrange(lifeform_t *lf, enum OBTYPE spellid, int power);
|
||||
char *getvarpowerspelldesc(enum OBTYPE spellid, int power, char *buf);
|
||||
void pullobto(object_t *o, lifeform_t *lf);
|
||||
int schoolappearsinbooks(enum SPELLSCHOOL ss);
|
||||
|
|
58
text.c
58
text.c
|
@ -97,22 +97,22 @@ char *dicetotext(int ndice, int nsides, int bonus, int *min, int *max, char *dic
|
|||
|
||||
if (dicebuf) {
|
||||
if ((ndice == 0) || (nsides == 0)) {
|
||||
sprintf(dicebuf, "%d", bonus);
|
||||
snprintf(dicebuf, BUFLEN, "%d", bonus);
|
||||
} else {
|
||||
if (bonus) {
|
||||
sprintf(dicebuf, "%dd%d%c%d", ndice, nsides,
|
||||
snprintf(dicebuf, BUFLEN, "%dd%d%c%d", ndice, nsides,
|
||||
(bonus > 0) ? '+' : '-',
|
||||
abs(bonus));
|
||||
} else {
|
||||
sprintf(dicebuf, "%dd%d", ndice, nsides);
|
||||
snprintf(dicebuf, BUFLEN, "%dd%d", ndice, nsides);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (minmaxbuf) {
|
||||
if (localmin == localmax) {
|
||||
sprintf(minmaxbuf, "%d", localmin);
|
||||
snprintf(minmaxbuf, BUFLEN, "%d", localmin);
|
||||
} else {
|
||||
sprintf(minmaxbuf, "%d-%d", localmin, localmax);
|
||||
snprintf(minmaxbuf, BUFLEN, "%d-%d", localmin, localmax);
|
||||
}
|
||||
}
|
||||
return dicebuf;
|
||||
|
@ -193,7 +193,7 @@ char *getattrname(enum ATTRIB att) {
|
|||
|
||||
int gethitconferlifetime(char *text, int *min, int *max) {
|
||||
int howlong;
|
||||
int localmin,localmax;
|
||||
int localmin = -1,localmax = -1;
|
||||
if (text) {
|
||||
char loctext[BUFLEN];
|
||||
char *word, *dummy;
|
||||
|
@ -332,7 +332,7 @@ char *gettimetext(char *retbuf) {
|
|||
int hours,mins,secs;
|
||||
splittime(&hours, &mins, &secs);
|
||||
|
||||
sprintf(retbuf, "%02d:%02d:%02d",hours,mins,secs);
|
||||
snprintf(retbuf, BUFLEN, "%02d:%02d:%02d",hours,mins,secs);
|
||||
return retbuf;
|
||||
}
|
||||
|
||||
|
@ -347,17 +347,17 @@ char *gettimetextfuzzy(char *retbuf, int wantpm) {
|
|||
}
|
||||
|
||||
if (mins == 0) {
|
||||
sprintf(retbuf, "exactly %d o'clock", hours);
|
||||
snprintf(retbuf, BUFLEN, "exactly %d o'clock", hours);
|
||||
} else if (mins <= 15) {
|
||||
sprintf(retbuf, "a little after %d o'clock", hours);
|
||||
snprintf(retbuf, BUFLEN, "a little after %d o'clock", hours);
|
||||
} else if (mins <= 25) {
|
||||
sprintf(retbuf, "nearly half past %d", hours);
|
||||
snprintf(retbuf, BUFLEN, "nearly half past %d", hours);
|
||||
} else if (mins <= 35) {
|
||||
sprintf(retbuf, "around half past %d", hours);
|
||||
snprintf(retbuf, BUFLEN, "around half past %d", hours);
|
||||
} else if (mins <= 45) {
|
||||
sprintf(retbuf, "coming up to %d o'clock", (hours == 12) ? 1 : (hours+1));
|
||||
snprintf(retbuf, BUFLEN, "coming up to %d o'clock", (hours == 12) ? 1 : (hours+1));
|
||||
} else {
|
||||
sprintf(retbuf, "nearly %d o'clock", (hours == 12) ? 1 : (hours+1));
|
||||
snprintf(retbuf, BUFLEN, "nearly %d o'clock", (hours == 12) ? 1 : (hours+1));
|
||||
}
|
||||
|
||||
if (wantpm) {
|
||||
|
@ -404,15 +404,15 @@ char *getwaterdepthname(enum DEPTH d) {
|
|||
|
||||
char *getweighttext(float weight, char *buf) {
|
||||
if (weight == 0) {
|
||||
sprintf(buf, "nothing");
|
||||
snprintf(buf, BUFLEN, "nothing");
|
||||
} else if (weight >= 1) {
|
||||
if ((int)weight == weight) { // ie. is weight an integer?
|
||||
sprintf(buf, "%0.0f kg",weight);
|
||||
snprintf(buf, BUFLEN, "%0.0f kg",weight);
|
||||
} else {
|
||||
sprintf(buf, "%0.1f kg",weight);
|
||||
snprintf(buf, BUFLEN, "%0.1f kg",weight);
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "%0.0f grams", weight * 1000);
|
||||
snprintf(buf, BUFLEN, "%0.0f grams", weight * 1000);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ char *makekillertext(char *retbuf, char *lastdam, int wantextra) {
|
|||
if (!strcmp(p, "you")) {
|
||||
strcpy(retbuf, "Committed suicide.");
|
||||
} else {
|
||||
sprintf(retbuf, "Killed by %s.",p);
|
||||
snprintf(retbuf, BUFLEN, "Killed by %s.",p);
|
||||
}
|
||||
if (wantextra) {
|
||||
p = strtok_r(NULL, "^", &dummy);
|
||||
|
@ -579,37 +579,37 @@ char *noprefix(char *obname) {
|
|||
char *numtotext(int num, char *buf) {
|
||||
switch (num) {
|
||||
case 1:
|
||||
sprintf(buf, "a");
|
||||
snprintf(buf, BUFLEN, "a");
|
||||
break;
|
||||
case 2:
|
||||
sprintf(buf, "two");
|
||||
snprintf(buf, BUFLEN, "two");
|
||||
break;
|
||||
case 3:
|
||||
sprintf(buf, "three");
|
||||
snprintf(buf, BUFLEN, "three");
|
||||
break;
|
||||
case 4:
|
||||
sprintf(buf, "four");
|
||||
snprintf(buf, BUFLEN, "four");
|
||||
break;
|
||||
case 5:
|
||||
sprintf(buf, "five");
|
||||
snprintf(buf, BUFLEN, "five");
|
||||
break;
|
||||
case 6:
|
||||
sprintf(buf, "six");
|
||||
snprintf(buf, BUFLEN, "six");
|
||||
break;
|
||||
case 7:
|
||||
sprintf(buf, "seven");
|
||||
snprintf(buf, BUFLEN, "seven");
|
||||
break;
|
||||
case 8:
|
||||
sprintf(buf, "eight");
|
||||
snprintf(buf, BUFLEN, "eight");
|
||||
break;
|
||||
case 9:
|
||||
sprintf(buf, "nine");
|
||||
snprintf(buf, BUFLEN, "nine");
|
||||
break;
|
||||
case 10:
|
||||
sprintf(buf, "ten");
|
||||
snprintf(buf, BUFLEN, "ten");
|
||||
break;
|
||||
default:
|
||||
sprintf(buf, "%d",num);
|
||||
snprintf(buf, BUFLEN, "%d",num);
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
|
|
Loading…
Reference in New Issue