Potion Power

Discuss anything about the original Dungeon Master on any of the original platforms (Amiga, Atari, etc.).
This forum may contain spoilers.

Moderator: Ameena

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Kensai
Neophyte
Posts: 3
Joined: Thu Jul 15, 2010 9:38 pm

Potion Power

Post by Kensai »

Hello,

how do I calculate the "power" of a potion. For example the number of hit points restored when a VI potion is used or the strength bonus added when a KU potion is used. Is there a table or maybe a formula?

Edit:
I think it has to do with the secret "Heal" skill. Wuuf's Poitions restore 6 HP (LO) and 8 HP (UM) on "Novice". But after a Level Up, her potions restore 8 HP (LO) and 12 (UM) on "Apprentice"...
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Potion Power

Post by Rasmus »

Welcome to our forum :)

I wish I could give you a good answar, but it has been a while since I extracted the code from CSBWin, and I don't know if it is reliable. But I can say this, Vi potions for example gets its power from the wisdom and runelevel from its caster, and later on when consuming it the increasing health dependes on the champions max hp. So it is abit tricky calculating it, maybe Sophia could help you with this..
Strength or KU potions increases the attribute depending on how high it already is.
For example, lets say that the strength potion increases the strength 4 points. If your champion that are consuming it have a higher strength than 120, then the strength will only be increased with half of that value plus 1, if he has a strength higher than 150, then the strength will only be increased with a fourth of that value + 1.
A quick code:
if char.strength <= 120 then add.strength = potion.strength
if char.strength > 120 and char.strength <= 150 then add.strength = int(potion.strength / 2) + 1
if char.strength > 150 then add.strength = int(potion.strength / 4) + 1

Dexterity/vitality/wisdom potions on the other hand doesn't get affected by the champions attribute value..

Correct me if I am wrong, because I am not sure this is completly accurate :)
User avatar
Kensai
Neophyte
Posts: 3
Joined: Thu Jul 15, 2010 9:38 pm

Re: Potion Power

Post by Kensai »

Thank you for your answer. How do developers of Dungeon Master clones handle this problem? Do they extract the code from CSBWin as well? Or do they use their own (invented) formulas? Did YOU use the original formulas for DMT? Which programming language is the code written in? I hope not Assembly... :) How difficult is it to find such information in the code?

Edit: I've just downloaded the CSBWin source code. And it even in C++. But, unfortunately, the documentation is quite sketchy. So if anyone has the other formulas, please tell me.
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Potion Power

Post by Rasmus »

I used the code from CSBWin, but it wasn't easy to extract it. Paul Stevens that created CSBWin, have left some notes inside the sourcecode that could help you search it..
I use c++ and created DMT from scratch. As I wanted it to be as simular as posible to the original DM I imported the code from CSBWin to DMT, I have disscovered that my translation isn't all accurate, but I think I have gotten most of it right..
Here are my sourcecode for giving the potions its power:

Code: Select all

	float d_Wis = float(sCharacter[onchar].sStats.wisdom);
	if (d_Wis<30) d_Wis=30; else if (d_Wis>255) d_Wis=255;
	d_Wis = pow(d_Wis, 0.6f) - 2.89f;
	float d_Lv = float(sCharacter[onchar].sStats.Skills[sRuneFormula[spellID].skill]);
	if (d_Lv<0) d_Lv=0; else if (d_Lv>32) d_Lv=32;
	d_Lv = pow(d_Lv, 0.8f) - 1.9f;
	float d_Multi = sqrt((d_Wis * d_Wis) + (d_Lv * d_Lv));
	float d_Pow = float(iRuneLevel + 2);
	int PotionPower = int(d_Pow * d_Multi * 2.0f);
And here are the code when consuming it:

Code: Select all

	float potionPwr = float(sItem.iCharges);
	if (potionPwr < 1.0f) potionPwr = 1.0f;
	if (potionPwr > 255.0f) potionPwr = 255.0f;
	float w_12 = float(potionPwr) / 2.0f;
	float w_30 = 32.0f + ((w_12 + 1.0f) / 8.0f);
	float w_14 = ((511.0f - w_12) / w_30) / 2.0f;
	w_12 = (w_12 / 25.0f) + 8.0f;

	if (sItemType[itType].itemType == ITEM_TYPE_POTION)
	{
		if (itType==47) sCharacter[onchar].sStats.health += sCharacter[onchar].sStats.basehealth * 2 / w_14;
		if (itType==44) sCharacter[onchar].sStats.stamina += sCharacter[onchar].sStats.basestamina * 2 / w_14;
		if (itType==46) sCharacter[onchar].sStats.mana += w_12 + w_12 - 8;
		if ((itType>=39)&&(itType<=42))
		{
			int iAttributeadd = 0;
			float fActiveAttribute = 0.0f;
			if (itType == 39) fActiveAttribute = sCharacter[onchar].sStats.dexterity;
			if (itType == 40) fActiveAttribute = sCharacter[onchar].sStats.strength;
			if (itType == 41) fActiveAttribute = sCharacter[onchar].sStats.wisdom;
			if (itType == 42) fActiveAttribute = sCharacter[onchar].sStats.vitality;
			if (fActiveAttribute>=151.0f)
			{
				if (itType != 40) iAttributeadd = ((5 + int(potionPwr / 25.0f)) / 4) + 1; else iAttributeadd = ((8 + int(potionPwr / 25.0f)) / 4) + 1; 
			}
			else
			{
				if (fActiveAttribute>=121.0f) 
				{
					if (itType != 40) iAttributeadd = ((5 + int(potionPwr / 25.0f)) / 2) + 1; else iAttributeadd = ((8 + int(potionPwr / 25.0f)) / 2) + 1; 
				}
				else
				{
					if (itType != 40) iAttributeadd = (5 + int(potionPwr / 25.0f)); else iAttributeadd = (8 + int(potionPwr / 25.0f)); 
				}
			}
			if (itType == 39) sCharacter[onchar].sStats.dexterity += float(iAttributeadd);
			if (itType == 40) sCharacter[onchar].sStats.strength += float(iAttributeadd);
			if (itType == 41) sCharacter[onchar].sStats.wisdom += float(iAttributeadd);
			if (itType == 42) sCharacter[onchar].sStats.vitality += float(iAttributeadd);
		}
	}
I hope it make sense..
And I have to correct myself by earlier writing that the "Dexterity/vitality/wisdom potions on the other hand doesn't get affected by the champions attribute value.." because they do, just not as much as the strength potion..
User avatar
Kensai
Neophyte
Posts: 3
Joined: Thu Jul 15, 2010 9:38 pm

Re: Potion Power

Post by Kensai »

That you very much, Rasmus! :D You have saved me a lot of time and trouble.
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Potion Power

Post by Rasmus »

Good to hear :) But I am not saying that it is completly correct.. It was over a year ago I programmed this, and it is posible that some stuff may differ from the original. But as I have played my own game several times since and not noticed any problem with it, I would say that it is okey!
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Potion Power

Post by Sophia »

Kensai wrote:How do developers of Dungeon Master clones handle this problem? Do they extract the code from CSBWin as well? Or do they use their own (invented) formulas?
It depends on the clone. As you can see, for his DMT Rasmus extracted the formulas from CSBwin. I did the same for my own clone, DSB. Hopefully the work done for clones like DSB and DMT can also help others interested in extracting the formulas. Other clones, like RTC and DMJ (DM Java) make an attempt to duplicate the "feel" of DM but use formulas that are basically made up from scratch.
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Potion Power

Post by Rasmus »

I have been thinking that it would be nice to have a cleaner code for everyone to use.. It shouldn't be that much problem creating a open sourcecode for everyone to use that only have functions that calculates damage, potionpower, spellpower, regeneration, etc.. And then only insert values like strength, defense, mana, etc. that the functions needs to be caluculated..

But then on the other hand, I can say that I still prioritate DMT and will not have the time to fix this now :(
Post Reply