Page 1 of 1

Disenchant resist should block charge draining

Posted: Thu 14.11.2013, 15:46
by Avenger
...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.

Re: Disenchant resist should block charge draining

Posted: Fri 15.11.2013, 13:01
by PowerWyrm
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.

Re: Disenchant resist should block charge draining

Posted: Fri 15.11.2013, 16:00
by Avenger
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.

Re: Disenchant resist should block charge draining

Posted: Fri 15.11.2013, 22:11
by Warrior
I'm happy to see code in forum posts. Keep it coming Avenger!