From 5bcf36fdce3626c3fca0f4c1d164785d332d1809 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Mon, 6 Jun 2016 20:55:53 +1000 Subject: [PATCH] Show stamina cost in weapon description. --- attack.c | 4 +++- io.c | 21 +++++++++++++++++++-- lf.c | 8 +++----- lf.h | 3 +-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/attack.c b/attack.c index 2e3b800..7281ded 100644 --- a/attack.c +++ b/attack.c @@ -834,8 +834,10 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) { dostamloss = B_FALSE; } if (dostamloss) { + object_t *priwep; + priwep = getweapon(lf); // lose a bit of stamina - modstamina(lf, -getattackstamloss(lf)); + modstamina(lf, -getattackstamloss(priwep)); } //} diff --git a/io.c b/io.c index ae0ab64..c647e35 100644 --- a/io.c +++ b/io.c @@ -6421,6 +6421,7 @@ char *makedesc_ob(object_t *o, char *retbuf) { strncat(retbuf, buf, HUGEBUFLEN); } else if (isweapon(o) && isknown(o)) { flag_t *damflag,*twohandf; + float stamcost = STAMTOATTACK; int delay; int critchance; @@ -6587,7 +6588,7 @@ char *makedesc_ob(object_t *o, char *retbuf) { strcat(buf, " (=)"); } else { // higher crit chance is better - snprintf(buf2, BUFLEN, " %s(%c%d)^n", (diff < 0) ? "^B" : "^g", + snprintf(buf2, BUFLEN, " %s(%c%d%%)^n", (diff < 0) ? "^B" : "^g", (diff > 0) ? '+' : '-', abs(diff)); strcat(buf, buf2); } @@ -6610,12 +6611,28 @@ char *makedesc_ob(object_t *o, char *retbuf) { strcat(buf, " (=)"); } else { // lower attack delay is better - snprintf(buf2, BUFLEN, " %s(%c%d)^n", (diff > 0) ? "^B" : "^g", + snprintf(buf2, BUFLEN, " %s(%c%d%%)^n", (diff > 0) ? "^B" : "^g", (diff > 0) ? '+' : '-', abs(diff)); strcat(buf, buf2); } } + stamcost = getattackstamloss(o); + snprintf(buf2, BUFLEN, ", and Stamina cost is %0.1f",stamcost); + strcat(buf, buf2); + if (compareob) { + float cstamcost,diff; + cstamcost = getattackstamloss(compareob); + diff = stamcost - cstamcost; + if (diff == 0) { + strcat(buf, " (=)"); + } else { + // lower stamina loss is better + snprintf(buf2, BUFLEN, " %s(%c%0.1f)^n", (diff > 0) ? "^B" : "^g", + (diff > 0) ? '+' : '-', fabs(diff)); + strcat(buf, buf2); + } + } strcat(buf, ".\n"); strncat(retbuf, buf, HUGEBUFLEN); } diff --git a/lf.c b/lf.c index 10578a2..89aeedd 100644 --- a/lf.c +++ b/lf.c @@ -7800,15 +7800,13 @@ int getattackspeed(lifeform_t *lf) { return (int)speed; } -float getattackstamloss(lifeform_t *lf) { - object_t *w; +float getattackstamloss(object_t *wep) { float loss; loss = STAMTOATTACK; - w = getweapon(lf); - if (w) { + if (wep) { int pctmod; - pctmod = getobattackdelay(w); // ie. 50 is fast, 100 is normal, 150 is slow, etc. + pctmod = getobattackdelay(wep); // ie. 50 is fast, 100 is normal, 150 is slow, etc. pctmod -= 100; // ie. -50 is fast, 0 is normal, 50 is slow // ie. normal attack stamina cost, plus twice the weapon's "attack delay" diff --git a/lf.h b/lf.h index d812427..2c9e0e9 100644 --- a/lf.h +++ b/lf.h @@ -168,8 +168,7 @@ int getarmourevpenalty(lifeform_t *lf); int getarmournoise(lifeform_t *lf); int getarmourrating(lifeform_t *lf, object_t **hitob, int *hitchance, enum BODYPART *hitbp, int *narms); int getattackspeed(lifeform_t *lf); -float getattackstamloss(lifeform_t *lf); -float getattackstamloss(lifeform_t *lf); +float getattackstamloss(object_t *wep); int getattpoints(lifeform_t *lf); int getattr(lifeform_t *lf, enum ATTRIB attr); enum ATTRBRACKET getattrbracket(int attrval, enum ATTRIB whichatt, /*@null@*/char *buf);