Show stamina cost in weapon description.

This commit is contained in:
Rob Pearce 2016-06-06 20:55:53 +10:00
parent 0bc557f2f5
commit 5bcf36fdce
4 changed files with 26 additions and 10 deletions

View File

@ -834,8 +834,10 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) {
dostamloss = B_FALSE; dostamloss = B_FALSE;
} }
if (dostamloss) { if (dostamloss) {
object_t *priwep;
priwep = getweapon(lf);
// lose a bit of stamina // lose a bit of stamina
modstamina(lf, -getattackstamloss(lf)); modstamina(lf, -getattackstamloss(priwep));
} }
//} //}

21
io.c
View File

@ -6421,6 +6421,7 @@ char *makedesc_ob(object_t *o, char *retbuf) {
strncat(retbuf, buf, HUGEBUFLEN); strncat(retbuf, buf, HUGEBUFLEN);
} else if (isweapon(o) && isknown(o)) { } else if (isweapon(o) && isknown(o)) {
flag_t *damflag,*twohandf; flag_t *damflag,*twohandf;
float stamcost = STAMTOATTACK;
int delay; int delay;
int critchance; int critchance;
@ -6587,7 +6588,7 @@ char *makedesc_ob(object_t *o, char *retbuf) {
strcat(buf, " (=)"); strcat(buf, " (=)");
} else { } else {
// higher crit chance is better // 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)); (diff > 0) ? '+' : '-', abs(diff));
strcat(buf, buf2); strcat(buf, buf2);
} }
@ -6610,12 +6611,28 @@ char *makedesc_ob(object_t *o, char *retbuf) {
strcat(buf, " (=)"); strcat(buf, " (=)");
} else { } else {
// lower attack delay is better // 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)); (diff > 0) ? '+' : '-', abs(diff));
strcat(buf, buf2); 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"); strcat(buf, ".\n");
strncat(retbuf, buf, HUGEBUFLEN); strncat(retbuf, buf, HUGEBUFLEN);
} }

8
lf.c
View File

@ -7800,15 +7800,13 @@ int getattackspeed(lifeform_t *lf) {
return (int)speed; return (int)speed;
} }
float getattackstamloss(lifeform_t *lf) { float getattackstamloss(object_t *wep) {
object_t *w;
float loss; float loss;
loss = STAMTOATTACK; loss = STAMTOATTACK;
w = getweapon(lf); if (wep) {
if (w) {
int pctmod; 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 pctmod -= 100; // ie. -50 is fast, 0 is normal, 50 is slow
// ie. normal attack stamina cost, plus twice the weapon's "attack delay" // ie. normal attack stamina cost, plus twice the weapon's "attack delay"

3
lf.h
View File

@ -168,8 +168,7 @@ int getarmourevpenalty(lifeform_t *lf);
int getarmournoise(lifeform_t *lf); int getarmournoise(lifeform_t *lf);
int getarmourrating(lifeform_t *lf, object_t **hitob, int *hitchance, enum BODYPART *hitbp, int *narms); int getarmourrating(lifeform_t *lf, object_t **hitob, int *hitchance, enum BODYPART *hitbp, int *narms);
int getattackspeed(lifeform_t *lf); int getattackspeed(lifeform_t *lf);
float getattackstamloss(lifeform_t *lf); float getattackstamloss(object_t *wep);
float getattackstamloss(lifeform_t *lf);
int getattpoints(lifeform_t *lf); int getattpoints(lifeform_t *lf);
int getattr(lifeform_t *lf, enum ATTRIB attr); int getattr(lifeform_t *lf, enum ATTRIB attr);
enum ATTRBRACKET getattrbracket(int attrval, enum ATTRIB whichatt, /*@null@*/char *buf); enum ATTRBRACKET getattrbracket(int attrval, enum ATTRIB whichatt, /*@null@*/char *buf);