Disenchant resist should block charge draining

New ideas, features you wish were in the game.
Post Reply
Avenger
Skeleton 2-Headed Troll
Posts: 191
Joined: Wed 04.12.2002, 21:42
Location: Wisconsin
Contact:

Disenchant resist should block charge draining

Post by Avenger » Thu 14.11.2013, 15:46

...because seriously, dying to something because your teleport(or destruct, or banish, or what have you) staff got drained is not ok.

The message "Energy drains from your pack" is very easy to overlook in a realtime variant where new messages constantly flow in during combat, and often, you'll only notice it when you're trying to use the staff and failing.

Code: Select all

/* Allow disenchant resist to block charge draining */
					if (!p_ptr->resist_disen)
					{
						/* Find an item */
						for (k = 0; k < 10; k++)
						{
							/* Pick an item */
							i = rand_int(INVEN_PACK);

							/* Obtain the item */
							o_ptr = &p_ptr->inventory[i];

							/* Drain charged wands/staffs */
							if (((o_ptr->tval == TV_STAFF) ||
						     	(o_ptr->tval == TV_WAND)) &&
						    	(o_ptr->pval))
							{
								/* Message */
								msg_print(Ind, "Energy drains from your pack!");

								/* Obvious */
								obvious = TRUE;

								/* Heal */
								j = rlev;
								m_ptr->hp += j * o_ptr->pval * o_ptr->number;
								if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;

								/* Redraw (later) if needed */
								update_health(m_idx);

								/* Uncharge */
								o_ptr->pval = 0;

								/* Combine / Reorder the pack */
								p_ptr->notice |= (PN_COMBINE | PN_REORDER);

								/* Window stuff */
								p_ptr->window |= (PW_INVEN | PW_EQUIP);

								/* Done */
								break;
							}
						}
So, let's get that into melee1.c.

Yes, my coding knowledge Is atrocious, and I copied the disenchant clause from the previous entry(unbonus) and tried to apply it to unpower too.

Just... make it so I no longer die for reasons I won't be aware of until it's too late, please.
Image

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Disenchant resist should block charge draining

Post by PowerWyrm » Fri 15.11.2013, 13:01

At your level, you should have scrolls, not staves. Using a simple staff of teleportation as your only means of escape is sucidal.

However, the current code (which is based on an outdated V version) is flawed. Pack drain is applied to everything at once, when it should only be applied once. In current V, "foo touches you - energy drains from your pack" only drains one charge of one item. This is the fix that should be applied.

This is the same with elemental destruction. Yesterday, when I played my priest and killed Carcharoth, I was using double resist fire. At the end of the fight, the only items I had left in my inventory were the last 5 books: all 5 copies of the first 4, all scrolls and staves were all destroyed. This is stupid... In latest V, resist (and even more double resist) gives some protection to items, which is not the case in pre-V3 versions of Angband. This should also be ported.

Avenger
Skeleton 2-Headed Troll
Posts: 191
Joined: Wed 04.12.2002, 21:42
Location: Wisconsin
Contact:

Re: Disenchant resist should block charge draining

Post by Avenger » Fri 15.11.2013, 16:00

I didn't realize teleport scrolls were an option - just yesterday Durin told me that 7 occasionally stocks 10 or so of them, so now I am using those.

Your proposed fixes would indeed be welcome.
Image

User avatar
Warrior
Evil Iggy
Posts: 667
Joined: Sat 26.10.2002, 15:00
Location: Norway
Contact:

Re: Disenchant resist should block charge draining

Post by Warrior » Fri 15.11.2013, 22:11

I'm happy to see code in forum posts. Keep it coming Avenger!
-- Mangband Project Team Member

Post Reply