Skip to content

Commit

Permalink
Merge branch 'upgrades' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
elunna committed Aug 2, 2023
2 parents 44408e2 + 0c2a9b8 commit 45956df
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 58 deletions.
1 change: 1 addition & 0 deletions hackem_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

Version 1.2.1 (unreleased)

Upgrade/tinker revisions.
Fix: Giant zombies appearing too early in mines.
Fix: weapon practice tech was granting too many skill points.
Rename sharpened pencil to just pencil - it's description depends on it's enchantment.
Expand Down
2 changes: 1 addition & 1 deletion include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ E void FDECL(mongrantswish, (struct monst **));
E void FDECL(djinni_from_bottle, (struct obj *));
E struct monst *FDECL(split_mon, (struct monst *, struct monst *));
E const char *NDECL(bottlename);
E int FDECL(upgrade_obj, (struct obj *));
E struct obj *FDECL(upgrade_obj, (struct obj *, int *));
E int FDECL(obj2upgrade, (int));
E void FDECL(speed_up, (long));
E short mixtype(struct obj *, struct obj *);
Expand Down
111 changes: 66 additions & 45 deletions src/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -3482,19 +3482,23 @@ dodip()
useup(potion);
return 1;
} else if (potion->otyp == POT_GAIN_LEVEL) {
int res = upgrade_obj(obj);
int res = 0;
obj = upgrade_obj(obj, &res);
if (res != 0) {
if (res == 1) {
/* The object was upgraded */
pline("Hmm! You don't recall dipping that into the potion.");
prinv((char *) 0, obj, 0L);

if (carried(obj))
prinv((char *) 0, obj, 0L);
/* Wisdom on successful upgrades */
exercise(A_WIS, TRUE);
} /* else potion exploded */
if (!objects[potion->otyp].oc_name_known
&& !objects[potion->otyp].oc_uname)
docall(potion);
useup(potion);
update_inventory();
exercise(A_WIS, TRUE);
return 1;
}
/* no return here, go for Interesting... message */
Expand Down Expand Up @@ -3923,54 +3927,57 @@ struct monst *mon, /* monster being split */
* potions, rings, and wands) should NOT be supported.
* Polearms are not currently implemented.
*/
int
upgrade_obj(obj)
register struct obj *obj;
/* returns 1 if something happened (potion should be used up)
* returns 0 if nothing happened
* returns -1 if object exploded (potion should be used up)
struct obj *
upgrade_obj(obj, res)
struct obj *obj;
int *res;
/* res = 1 if something happened (potion should be used up)
* res = 0 if nothing happened (default)
* res = -1 if object exploded (potion should be used up)
*/
{
short otyp = obj->otyp, otyp2;
xchar ox, oy;
long owornmask;
struct obj *otmp;
int newtyp;
boolean explodes;
boolean split1off;
boolean split1off, explodes = FALSE, dropped = FALSE;
*res = 0;

/* Check to see if object is valid */
if (!obj)
return 0;
return obj;

(void) snuff_lit(obj);
if (obj->oartifact)
/* WAC -- Could have some funky fx */
return 0;
return obj;

newtyp = obj2upgrade(obj->otyp);
if (!newtyp)
return 0;

if (obj->otyp == FLINT) {
split1off = (obj->quan > 1L);
if (split1off) {
obj = splitobj(obj, 1L);

if (carried(obj)) {
freeinv(obj);
if (inv_cnt(FALSE) >= 52) {
sellobj_state(SELL_DONTSELL);
dropy(obj);
sellobj_state(SELL_NORMAL);
} else {
obj->nomerge = 1; /* used to prevent merge */
obj = addinv(obj);
obj->nomerge = 0;
}
return obj;

/* Only one item can be upgraded at a time */
split1off = (obj->quan > 1L);
if (split1off) {
obj = splitobj(obj, 1L);

if (carried(obj)) {
freeinv(obj);
/* TODO: Use hold_another_object here */
if (inv_cnt(FALSE) >= 52) {
sellobj_state(SELL_DONTSELL);
dropy(obj);
sellobj_state(SELL_NORMAL);
dropped = TRUE;
} else {
obj->nomerge = 1; /* used to prevent merge */
obj = addinv(obj);
obj->nomerge = 0;
}
}
}

if (obj->otyp == LEASH && obj->leashmon)
o_unleash(obj);

Expand Down Expand Up @@ -4085,34 +4092,48 @@ register struct obj *obj;
/* puton_worn_item(obj); */
}

/* if (obj->otyp == BAG_OF_HOLDING && Has_contents(obj)) { */
if (Is_mbag(obj) && Has_contents(obj)) {
explodes = FALSE;

for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
if (mbag_explodes(otmp, 0)) {
explodes = TRUE;
break;

if ((obj->otyp == BAG_OF_HOLDING || Bad_bag(obj))
&& Has_contents(obj)) {

/* In the strange case that an upgraded sack has charged... */
if (Bad_bag(obj))
explodes = TRUE;
else {
for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
if (mbag_explodes(otmp, 0)) {
explodes = TRUE;
break;
}
}
}

if (explodes) {
pline("As you upgrade your bag, you are blasted by a magical explosion!");
delete_contents(obj);
You("are blasted by a magical explosion!");
do_boh_explosion(obj, (obj->where == OBJ_FLOOR));
if (carried(obj))
useup(obj);
else
useupf(obj, obj->quan);
losehp(d(6,6), "magical explosion", KILLED_BY_AN);
return -1;
livelog_printf(LL_ACHIEVE, "just blew up %s %s", uhis(),
"bag of holding");
losehp(Maybe_Half_Phys(d(8, 10)),
"exploding magical bag", KILLED_BY_AN);

*res = -1;
return (struct obj *) 0;
}
}
/* Check if the new object fits the old material.
* If not... */
if (!valid_obj_material(obj, obj->material)) {
init_obj_material(obj);
}

return 1;
if (dropped)
pline("You drop %s.", doname(obj));

*res = 1;
return obj;
}

int
Expand Down
5 changes: 3 additions & 2 deletions src/shk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4702,7 +4702,7 @@ struct monst *shkp;
{
register struct obj *obj; /* The object to identify */
int charge = 500; /* Cost to identify */
int res;
int res = 0;
/* Pick object */
if (!(obj = getobj(identify_types, "have tinkered")))
return 0;
Expand Down Expand Up @@ -4741,10 +4741,11 @@ struct monst *shkp;
return 1;
} else if (Confusion) {
pline("%s dunks the thing in some water and hands it back to you.", mon_nam(shkp));
(void) water_damage(obj, NULL, TRUE, shkp->mx, shkp->my);
return 1;
}

res = upgrade_obj(obj);
obj = upgrade_obj(obj, &res);
if (res != 0) {
if (res == 1) {
/* The object was upgraded */
Expand Down
27 changes: 17 additions & 10 deletions src/tech.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ charge_saber(VOID_ARGS)
STATIC_PTR int
tinker(VOID_ARGS)
{
int chance;
int res = 0;
struct obj *otmp = uwep;

if (delay) { /* not if (delay++), so at end delay == 0 */
Expand All @@ -1619,16 +1619,23 @@ tinker(VOID_ARGS)
return 0;

You("finish your tinkering.");
chance = 5;
/* chance += PSKILL(P_TINKER); */
if (rnl(10) < chance) {
upgrade_obj(otmp);
} else {
/* object downgrade - But for now, nothing :) */
}

setuwep(otmp);
You("now hold %s!", doname(otmp));
if (rnl(10) < 5) {
otmp = upgrade_obj(otmp, &res);
if (res != 0) {
if (res == 1) {
/* The object was upgraded */
if (carried(otmp)) {
setuwep(otmp);
You("now hold %s!", doname(otmp));
}

/* Wisdom on successful upgrades */
exercise(A_WIS, TRUE);
}
update_inventory();
}
}
return 0;
}

Expand Down

0 comments on commit 45956df

Please sign in to comment.