More unpolyable unifying

... and fix the potion dipping case.
This commit is contained in:
Pasi Kallinen
2020-11-17 18:00:43 +02:00
parent 03d1eed0b5
commit e100d1a137
3 changed files with 13 additions and 6 deletions
+1
View File
@@ -3154,6 +3154,7 @@ E int FDECL(unturn_dead, (struct monst *));
E void NDECL(unturn_you); E void NDECL(unturn_you);
E void FDECL(cancel_item, (struct obj *)); E void FDECL(cancel_item, (struct obj *));
E boolean FDECL(drain_item, (struct obj *, BOOLEAN_P)); E boolean FDECL(drain_item, (struct obj *, BOOLEAN_P));
E boolean FDECL(obj_unpolyable, (struct obj *));
E struct obj *FDECL(poly_obj, (struct obj *, int)); E struct obj *FDECL(poly_obj, (struct obj *, int));
E boolean FDECL(obj_resists, (struct obj *, int, int)); E boolean FDECL(obj_resists, (struct obj *, int, int));
E boolean FDECL(obj_shudders, (struct obj *)); E boolean FDECL(obj_shudders, (struct obj *));
+1 -5
View File
@@ -1977,11 +1977,7 @@ dodip()
goto poof; goto poof;
} else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) { } else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) {
/* some objects can't be polymorphed */ /* some objects can't be polymorphed */
if (obj->otyp == potion->otyp /* both POT_POLY */ if (obj_unpolyable(obj->otyp == POT_POLYMORPH ? potion : obj)) {
|| unpolyable(obj)
|| obj == uball || obj == uskin
|| obj_resists(obj->otyp == POT_POLYMORPH ? potion : obj,
5, 95)) {
pline1(nothing_happens); pline1(nothing_happens);
} else { } else {
short save_otyp = obj->otyp; short save_otyp = obj->otyp;
+11 -1
View File
@@ -1476,6 +1476,16 @@ struct obj *obj;
delobj(obj); delobj(obj);
} }
/* Returns TRUE if obj resists polymorphing */
boolean
obj_unpolyable(obj)
struct obj *obj;
{
return (unpolyable(obj)
|| obj == uball || obj == uskin
|| obj_resists(obj, 5, 95));
}
/* classes of items whose current charge count carries over across polymorph /* classes of items whose current charge count carries over across polymorph
*/ */
static const char charged_objs[] = { WAND_CLASS, WEAPON_CLASS, ARMOR_CLASS, static const char charged_objs[] = { WAND_CLASS, WEAPON_CLASS, ARMOR_CLASS,
@@ -1964,7 +1974,7 @@ struct obj *obj, *otmp;
switch (otmp->otyp) { switch (otmp->otyp) {
case WAN_POLYMORPH: case WAN_POLYMORPH:
case SPE_POLYMORPH: case SPE_POLYMORPH:
if (unpolyable(obj) || obj_resists(obj, 5, 95)) { if (obj_unpolyable(obj)) {
res = 0; res = 0;
break; break;
} }