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"...
Potion Power
Moderator: Ameena
Forum rules
Please read the Forum rules and policies before posting.
Please read the Forum rules and policies before posting.
Re: Potion Power
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
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
Website: http://dwelvers.com/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
Re: Potion Power
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.
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.
Re: Potion Power
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:
And here are the code when consuming it:
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..
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);
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);
}
}
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..
Website: http://dwelvers.com/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
Re: Potion Power
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!
Website: http://dwelvers.com/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Potion Power
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.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?
Re: Potion Power
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
But then on the other hand, I can say that I still prioritate DMT and will not have the time to fix this now
Website: http://dwelvers.com/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/
YouTube: http://www.youtube.com/Dwelvers
Twitter: https://twitter.com/dwelvers
Facebook: https://www.facebook.com/Dwelvers
Forum: http://www.dungeondwellers.net/forum/