- [+] 's' = slowwalk(lf, dir). ask which dir if not given and player.

- [+] adds F_SNEAKING 
    - [+] calls trymove
    - [+] removes F_SNEAKING
    - [+] effects:
        - [+] move slowly (2 times normal)
        - [+] never slip
        - [+] bonus on stealth check
This commit is contained in:
Rob Pearce 2011-05-27 02:50:59 +00:00
parent aaf48355eb
commit af0d8f244d
8 changed files with 73 additions and 29 deletions

13
ai.c
View File

@ -385,7 +385,7 @@ flag_t *aigoto(lifeform_t *lf, cell_t *c, enum MOVEREASON why, void *data, int t
if (lfhasflagval(lf, F_IGNORECELL, c->x, c->y, NA, NULL)) {
char lfname[BUFLEN];
getlfname(lf, lfname);
dblog(".oO { %s cannot go to targecell %d,%d due to f_ignorecell flag }", lfname, c->x, c->y);
if (db) dblog(".oO { %s cannot go to targecell %d,%d due to f_ignorecell flag }", lfname, c->x, c->y);
return NULL;
}
@ -1492,16 +1492,17 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG
flag_t *willflag;
flag_t *srflag;
int srange = 5;
srflag = lfhasflag(lf, F_SWOOPRANGE);
if (srflag) {
srange = srflag->val[0];
}
willflag = lfhasflagval(lf, F_CANWILL, ot->id, NA, NA, NULL);
if (willflag) {
texttospellopts(f->text, NULL, NULL, NULL, &srange);
if (!srange) srange = 5;
}
// override...
srflag = lfhasflag(lf, F_SWOOPRANGE);
if (srflag) {
srange = srflag->val[0];
}
if (!haslof(lf->cell, victim->cell, LOF_NEED,NULL)) {
@ -1538,7 +1539,7 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG
}
}
if (!specificcheckok) {
dblog(".oO { cant cast %s - specific spell check failed }", ot ? ot->name : "?unkownspell?");
if (db) dblog(".oO { cant cast %s - specific spell check failed }", ot ? ot->name : "?unkownspell?");
return B_FALSE;
}

1
defs.h
View File

@ -1792,6 +1792,7 @@ enum FLAG {
F_HOMELEVOB, // when this monster is auto generated on a level, place
// between v0 and v1 objects of type 'text' somewhere on
// the level.
F_SNEAK, // moving slowly on purpose to avoid slipping.
F_AUTOCMD, // val0 = how many times to repeat this
F_LASTCMD, // text[0] = last command performed, v0/1 = x/y of cell, v2=various
F_CANLEARN, // lf is able to learn skill val0

17
flag.c
View File

@ -27,6 +27,8 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
lifeform_t *lf;
flag_t *f;
map_t *redolight = NULL;
int redrawscreenatend = B_FALSE;
int redrawstatatend = B_FALSE;
int i;
// identified things mean all new flags are autmaticlaly known.
@ -170,8 +172,8 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
}
}
// player flags which cause a redraw
if (flagcausesredraw(f->pile->owner, f->id)) needredraw = B_TRUE;
if (flagcausesstatredraw(f->pile->owner, f->id)) statdirty = B_TRUE;
if (flagcausesredraw(f->pile->owner, f->id)) redrawscreenatend = B_TRUE;
if (flagcausesstatredraw(f->pile->owner, f->id)) redrawstatatend = B_TRUE;
} else if (f->pile->ob) {
if (announceobflaggain(f->pile->ob, f)) {
f->known = B_TRUE;
@ -201,14 +203,17 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
}
}
if ((gamemode == GM_GAMESTARTED) && (needredraw || statdirty || redolight)) {
if ((gamemode == GM_GAMESTARTED) && (redrawscreenatend || redrawstatatend || redolight)) {
if (redolight) {
dblog("CALCINGLIGHT from flag\n");
needredraw = B_TRUE;
redrawscreenatend = B_TRUE;
calclight(redolight);
precalclos(player);
}
dblog("DRAWINGSCREEN from flag\n");
if (redrawscreenatend) needredraw = B_TRUE;
if (redrawstatatend) statdirty = B_TRUE;
drawscreen();
}
return f;
@ -426,10 +431,6 @@ void killflag(flag_t *f) {
int redostat = B_FALSE;
int redoscreen = B_FALSE;
if (f->id == F_SIZE) {
dblog("xxx");
}
lf = f->pile->owner;
if (gamemode == GM_GAMESTARTED) {

8
io.c
View File

@ -5064,7 +5064,7 @@ void drawlevelfor(lifeform_t *lf) {
return;
}
dbtimestart("drawscreen");
//dbtimestart("drawscreen");
map = lf->cell->map;
needredraw = B_FALSE;
@ -5114,7 +5114,7 @@ void drawlevelfor(lifeform_t *lf) {
if (db) dblog("ending DRAWLEVEL");
sprintf(buf, "end. ndrawn was %d",ndrawn);
dbtimeend(buf);
//dbtimeend(buf);
// move cursor to the player's position and blit
if (ndrawn) {
drawcursor();
@ -5815,6 +5815,7 @@ void handleinput(void) {
case 'n':
trymove(player, chartodir(ch), B_TRUE);
break;
// running
case 'H':
case 'J':
case 'K':
@ -5825,6 +5826,9 @@ void handleinput(void) {
case 'N':
tryrun(player, chartodir(ch));
break;
case 's': // slowwalk
trysneak(player, D_NONE);
break;
case '.': // wait
addflag(player->flags, F_LASTCMD, NA, NA, NA, temp);
if (count > 1) {

11
lf.c
View File

@ -4207,10 +4207,16 @@ int getmovespeed(lifeform_t *lf) {
break;
}
if (lfhasflag(lf, F_SNEAK)) {
speed *= 2;
}
if (speed < 1) speed = 1;
adjustspeedforwater(lf, &speed);
return speed;
}
@ -12048,6 +12054,11 @@ int real_skillcheck(lifeform_t *lf, enum CHECKTYPE ct, int diff, int mod, int *r
sumflags(lf->flags, F_ENHANCESEARCH, &bonus, NULL, NULL);
othermod += bonus;
} else if (ct == SC_STEALTH) {
if (attrib > 0) {
if (lfhasflag(lf, F_SNEAK)) {
othermod += 3;
}
}
if (isairborne(lf)) {
othermod += 5;
}

45
move.c
View File

@ -1179,9 +1179,11 @@ int moveto(lifeform_t *lf, cell_t *newcell, int onpurpose, int dontclearmsg) {
object_t *o,*nexto;
object_t *slipob;
slip = getslipperyness(newcell, &slipob);
if (slip && !skillcheck(lf, SC_SLIP, slip, 0)) {
slipon(lf, slipob);
if (!lfhasflag(lf, F_SNEAK)) {
slip = getslipperyness(newcell, &slipob);
if (slip && !skillcheck(lf, SC_SLIP, slip, 0)) {
slipon(lf, slipob);
}
}
// activate traps
@ -1476,6 +1478,26 @@ int tryrun(lifeform_t *lf, int dir) {
return B_FALSE;
}
int trysneak(lifeform_t *lf, int dir) {
if (dir == D_NONE) {
if (isplayer(lf)) {
char ques[BUFLEN];
char ch;
sprintf(ques, "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;
} else {
return B_TRUE;
}
}
addflag(lf->flags, F_SNEAK, NA, NA, NA, NULL);
trymove(lf, dir, B_TRUE);
killflagsofid(lf->flags, F_SNEAK);
return B_FALSE;
}
// try to pull lifeform towards cell c (or next to it)
int pullnextto(lifeform_t *lf, cell_t *c) {
int dir;
@ -1660,13 +1682,16 @@ int initiatemove(lifeform_t *lf, cell_t *cell, int *didmsg) {
if (!isairborne(lf)) {
int slip;
object_t *slipob;
slip = getslipperyness(lf->cell, &slipob);
if (slip && !skillcheck(lf, SC_SLIP, slip, 0)) {
slipon(lf, slipob);
if (didmsg) *didmsg = B_TRUE;
// don't move
reason = E_OK;
return B_TRUE;
if (!lfhasflag(lf, F_SNEAK)) {
slip = getslipperyness(lf->cell, &slipob);
if (slip && !skillcheck(lf, SC_SLIP, slip, 0)) {
slipon(lf, slipob);
if (didmsg) *didmsg = B_TRUE;
// don't move
reason = E_OK;
return B_TRUE;
}
}
}

1
move.h
View File

@ -27,5 +27,6 @@ void swapplaces(lifeform_t *lf1, lifeform_t *lf2, int onpurpose);
int teleportto(lifeform_t *lf, cell_t *c, int wantsmoke);
int trymove(lifeform_t *lf, int dir, int onpurpose);
int tryrun(lifeform_t *lf, int dir);
int trysneak(lifeform_t *lf, int dir);
int walkoffmap(lifeform_t *lf, int dir, int onpurpose);
int willmove(lifeform_t *lf, int dir, enum ERROR *error);

View File

@ -983,7 +983,7 @@ int rollhitdice(lifeform_t *lf) {
int roll = 0;
int i;
float mod;
int db = B_TRUE;
int db = B_FALSE;
f = hasflag(lf->flags, F_HITDICE);
if (f) {