Rewrite weild() to do all prompts to remove stuff in the way before actually removing anything.
This commit is contained in:
parent
d5254e25aa
commit
6610dfed88
2
io.c
2
io.c
|
@ -8214,7 +8214,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
||||||
break;
|
break;
|
||||||
case F_NOTAKECRITS: if (lorelev >= PR_NOVICE) sprintf(buf, "Immune to critical hits."); break;
|
case F_NOTAKECRITS: if (lorelev >= PR_NOVICE) sprintf(buf, "Immune to critical hits."); break;
|
||||||
case F_NOPRAY: if (lorelev >= PR_BEGINNER) sprintf(buf, "Cannot worship gods."); break;
|
case F_NOPRAY: if (lorelev >= PR_BEGINNER) sprintf(buf, "Cannot worship gods."); break;
|
||||||
case F_NORESTHEAL: if (lorelev >= PR_NOVICE) sprintf(buf, "Cannot restore gain HP by resting."); break;
|
case F_NORESTHEAL: if (lorelev >= PR_NOVICE) sprintf(buf, "Cannot restore HP by resting."); break;
|
||||||
case F_NOSMELL: if ((lorelev >= PR_NOVICE) ) sprintf(buf, "No sense of smell."); break;
|
case F_NOSMELL: if ((lorelev >= PR_NOVICE) ) sprintf(buf, "No sense of smell."); break;
|
||||||
case F_NOCTURNAL: if ((lorelev >= PR_BEGINNER) && !forplayersel) sprintf(buf, "Sleeps during the day."); break;
|
case F_NOCTURNAL: if ((lorelev >= PR_BEGINNER) && !forplayersel) sprintf(buf, "Sleeps during the day."); break;
|
||||||
case F_NOSPELLS: if (lorelev >= PR_NOVICE) sprintf(buf, "Cannot use magic."); break;
|
case F_NOSPELLS: if (lorelev >= PR_NOVICE) sprintf(buf, "Cannot use magic."); break;
|
||||||
|
|
56
lf.c
56
lf.c
|
@ -28018,10 +28018,15 @@ int wear(lifeform_t *lf, object_t *o) {
|
||||||
int weild(lifeform_t *lf, object_t *o) {
|
int weild(lifeform_t *lf, object_t *o) {
|
||||||
char buf[BUFLEN];
|
char buf[BUFLEN];
|
||||||
flag_t *f;
|
flag_t *f;
|
||||||
object_t *oo;
|
object_t *oo,*unweildob[MAXBODYPARTS],*takeoffob[MAXBODYPARTS];
|
||||||
int twohanded = B_FALSE;
|
int twohanded = B_FALSE,i,nunweild = 0,ntakeoff = 0;
|
||||||
enum BODYPART weildloc,otherloc;
|
enum BODYPART weildloc,otherloc;
|
||||||
|
|
||||||
|
for (i = 0; i < MAXBODYPARTS; i++) {
|
||||||
|
unweildob[i] = NULL;
|
||||||
|
takeoffob[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// this might impact your AR
|
// this might impact your AR
|
||||||
if (isplayer(lf)) {
|
if (isplayer(lf)) {
|
||||||
statdirty = B_TRUE;
|
statdirty = B_TRUE;
|
||||||
|
@ -28190,23 +28195,20 @@ int weild(lifeform_t *lf, object_t *o) {
|
||||||
return B_TRUE;
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// just unweild it
|
// don't unweild it yet, because we might still need
|
||||||
if (unweild(lf, oo)) {
|
// to ask if the player wants to unweild something in their
|
||||||
// if we can't unweild old weapon, stop
|
// other hand. If they say NO, then we shouldn't unweild the
|
||||||
return B_TRUE;
|
// primary weapon either.
|
||||||
}
|
unweildob[nunweild++] = oo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// new weapon is two handed? check other hand too.
|
// new weapon is two handed? check other hand too.
|
||||||
if (twohanded) {
|
if (twohanded) {
|
||||||
f = hasflagval(oo->flags, F_EQUIPPED, otherloc, -1, -1, NULL);
|
f = hasflagval(oo->flags, F_EQUIPPED, otherloc, -1, -1, NULL);
|
||||||
if (f) {
|
if (f) {
|
||||||
if (isweapon(oo)) {
|
if (isweapon(oo)) {
|
||||||
// just unweild it
|
unweildob[nunweild++] = oo;
|
||||||
if (unweild(lf, oo)) {
|
|
||||||
// if we can't unweild old weapon, stop
|
|
||||||
return B_TRUE;
|
|
||||||
}
|
|
||||||
} else { // armour
|
} else { // armour
|
||||||
char buf2[BUFLEN];
|
char buf2[BUFLEN];
|
||||||
char inwayname[BUFLEN];
|
char inwayname[BUFLEN];
|
||||||
|
@ -28226,15 +28228,9 @@ int weild(lifeform_t *lf, object_t *o) {
|
||||||
}
|
}
|
||||||
if (ch == 'y') {
|
if (ch == 'y') {
|
||||||
if (isarmour(oo)) {
|
if (isarmour(oo)) {
|
||||||
if (takeoff(lf, oo)) {
|
takeoffob[ntakeoff++] = oo;
|
||||||
// if we can't remove it, stop.
|
|
||||||
return B_TRUE;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (unweild(lf, oo)) {
|
unweildob[nunweild++] = oo;
|
||||||
// if we can't remove it, stop.
|
|
||||||
return B_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return B_TRUE;
|
return B_TRUE;
|
||||||
|
@ -28244,6 +28240,23 @@ int weild(lifeform_t *lf, object_t *o) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now unweild stuff if required.
|
||||||
|
if (nunweild) {
|
||||||
|
for (i = 0; i < nunweild; i++) {
|
||||||
|
if (unweild(lf, unweildob[i])) {
|
||||||
|
// if we can't unweild old weapon, stop
|
||||||
|
return B_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ntakeoff) {
|
||||||
|
for (i = 0; i < ntakeoff; i++) {
|
||||||
|
if (takeoff(lf, takeoffob[i])) {
|
||||||
|
// if we can't remove it, stop.
|
||||||
|
return B_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if we asked to just unweild our weapon, exit now
|
// if we asked to just unweild our weapon, exit now
|
||||||
// with no error.
|
// with no error.
|
||||||
|
@ -28259,12 +28272,13 @@ int weild(lifeform_t *lf, object_t *o) {
|
||||||
return B_FALSE;
|
return B_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// touching the new weapon caused us to drop it or similar.
|
||||||
if (touch(lf, o)) {
|
if (touch(lf, o)) {
|
||||||
taketime(lf, getactspeed(lf));
|
taketime(lf, getactspeed(lf));
|
||||||
return B_TRUE;
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now weild this
|
// now weild the new weapon.
|
||||||
addflag(o->flags, F_EQUIPPED, weildloc, -1, -1, NULL);
|
addflag(o->flags, F_EQUIPPED, weildloc, -1, -1, NULL);
|
||||||
if (istwohandedfor(o, lf)) {
|
if (istwohandedfor(o, lf)) {
|
||||||
addflag(o->flags, F_EQUIPPED, otherloc, -1, -1, NULL);
|
addflag(o->flags, F_EQUIPPED, otherloc, -1, -1, NULL);
|
||||||
|
|
Loading…
Reference in New Issue