Author Topic: [D2NT] Potions  (Read 3638 times)

mythosis

  • Guest
[D2NT] Potions
« on: October 05, 2010, 11:37:06 AM »
Contents:
A) Potion-buying fix, to make sure bot buys highest level potion available.
B) Options to choose not to buy potions under certain circumstances. (bot level, difficulty, etc)
C) (coming) Mod to make bot go to another act to buy potions (for higher level pots)
D) (coming) Create Juvs (full) if needed.
E) (coming) Potion-Usage Delays

Want any other potion-mods? Say it!


A) Potion-Buying Fix
Issue: Checks each item 1 at a time, comparing it for the potions (starting from super). This is bad because it can return true if any potion is found, which may not be the best potion available. Switching the for loops makes it check every item for super, then every item for greater and so down the list.
ntTown.ntl
at the top, add:
Code: [Select]
/////////////////////////////////////////////////////////////////////////
//Potions
var NTT_maxPotionLevel = 5;
var NTT_minPotionLevel = 1;
//1: Minor, 2: Lesser, 3: Normal, 4: Greater, 5: Super
/////////////////////////////////////////////////////////////////////////
then,
find: function NTT_GetPotionAtNPCInt(type, npc)
Replace the function with this:
Code: [Select]
function NTT_GetPotionAtNPCInt(type, npc)
{
var _items;

if(!type)
return null;

if(type == "hp" || type == "mp")
{
_items = npc.GetItems();

if(_items)
{
var n;

for(n = NTT_maxPotionLevel ; n >= NTT_minPotionLevel ; n--)
{
for(var i = 0 ; i < _items.length ; i++)
{
if(_items[i].code == (type+n) )
return _items[i];
}
}
}
}
else
{
if(type == "rv")
return null;

_items = npc.GetItems(type);

if(_items && _items.length > 0)
return _items[0];
}

return null;
}
« Last Edit: November 05, 2010, 04:28:18 AM by mythosis »

swiftboy36

  • Guest
Re: [D2NT] Potions
« Reply #1 on: November 03, 2010, 06:57:04 PM »
This is amazing, however when im fighting a boss such as andriel or meph for example, I will use my mana belt to get me to the location , however when im fighting it wont fully utilize all my MP pots or HP pots, instead it will just stand still and not replenish my mana/hp in turn dieing or chickening out.

mythosis

  • Guest
Re: [D2NT] Potions
« Reply #2 on: November 05, 2010, 04:27:20 AM »
I think what you mean is the delay between using potions. The bot has a delay between using potions to prevent guzzeling all your potions. In the case of rejuvs, I think this needs to be edited to a much much much lower delay, but health and mana are regenerated over time, which makes deciding a good delay a bit harder.

swiftboy36

  • Guest
Re: [D2NT] Potions
« Reply #3 on: November 05, 2010, 06:08:25 AM »
where could i locate these delays for potions and mana etc?


mythosis

  • Guest
Re: [D2NT] Potions
« Reply #4 on: November 05, 2010, 06:20:37 AM »
I think this is what your looking for:
NTTown
Code: [Select]
function NTT_CheckBelt()
{
var _needpotions = false;

for(var i = 0 ; i < 4 ; i++)
{
_NTT_BeltColNeeded[i] = NTT_GetNeededPotionsColInt(NTConfig_BeltColType[i], i);

if(_NTT_BeltColNeeded[i] > 0 && NTConfig_BeltColType[i] != "rv")
_needpotions = true;
}

return _needpotions;
}

swiftboy36

  • Guest
Re: [D2NT] Potions
« Reply #5 on: November 05, 2010, 06:32:45 AM »
hmm perhaps i can be more clear as to what i'm trying to fix..



when my mana/Health is at or below an x% I want to be able to use the pot from my belt ( both rows (mp/hp)).


If used and the potion gets below that x% again, repeat process. However when I have one potion left be it either mana or hp i want to go to town to refill my belt even if it's in the middle of a boss fight ( this is to stop death ( a cautious pre-chicken precaution )) * hope that made sense lol

it's hard to explain.   


with team viewer are you able to view my d2 while i show you what i mean?

it's really hard to explain, youll know exactly what i mean when you see it for yourself though, all you'd have to do is view the mana and hp bubbles and belt when bots in game.

mythosis

  • Guest
Re: [D2NT] Potions
« Reply #6 on: November 05, 2010, 04:12:21 PM »
A quote from your local char file
Quote
   NTConfig_LifeThresh = 60;      // Drink a normal potion if under this percent of life.
   NTConfig_LifeRejuvThresh = 40;   // Drink a rejuvenation potion if under this percent of life.
   NTConfig_ManaThresh = 30;      // Drink a normal potion if under this percent of mana.
   NTConfig_ManaRejuvThresh = 10;   // Drink a rejuvenation potion if under this percent of mana.
   NTConfig_LifeChicken = 30;      // This is your chicken life percent. If you go below this life total, exit game.
   NTConfig_ManaChicken = 0;      // This is your chicken mana percent. If you go below this mana total, exit game.

Drinks hp pot at 60% hp
Drinks mp pot at 30% mp
drinks rejuv at 40% hp or 10% mp
chickens at 30% hp

The delays I mentioned apply to these drinking potion lines. (chicken uneffected by delay)
The drinking code can be found in NTToolsThread.ntl (Tools folder)

swiftboy36

  • Guest
Re: [D2NT] Potions
« Reply #7 on: November 05, 2010, 05:26:30 PM »
I'm familiar with the %'s in the char config file.

what I'm interested in are the timings.

I've timed it while in game have the bot run itself, and it generally needs to pot about every 3-4 seconds, so as a safety net, I'd want to mess with it any where between 5-8 seconds and see where that gets me.

Ill have a gander at the NTToolsThread.ntl and post if I need more help :)

edit:

is this the line I'm looking for?
Code: [Select]
for(var i = 0 ; i < 5 ; i++)
_NTLW_timerLastDrink[i] = 0;
« Last Edit: November 05, 2010, 05:38:03 PM by swiftboy36 »

mythosis

  • Guest
Re: [D2NT] Potions
« Reply #8 on: November 05, 2010, 06:18:39 PM »
I think this is what you mean:
Code: [Select]
// Timer Delays Between Drinking
if(type == 2 || type == 4) // rejuv
{
if(_NTLW_timerLastDrink[type] && (_tNow-_NTLW_timerLastDrink[type] < 600))
return false;
}
else // hp & mp
{
if(_NTLW_timerLastDrink[type] && (_tNow-_NTLW_timerLastDrink[type] < 3000))
return false;
}
I just went through my file and added commentary. ;)
Now I think thats either   
(1000) = 1 second   or  (600) = 1 second    so....
(3000) = 3 second   or  (3000) = 5 second



You can do this...
At the top, add:
Code: [Select]
var potDelay = 3000; // HP & MP
var potDelayRejuv = 600; // Rejuv

Then at the bottom where that code is make it
Code: [Select]
// Timer Delays Between Drinking
if(type == 2 || type == 4) // rejuv
{
if(_NTLW_timerLastDrink[type] && (_tNow-_NTLW_timerLastDrink[type] < potDelayRejuv))
return false;
}
else // hp & mp
{
if(_NTLW_timerLastDrink[type] && (_tNow-_NTLW_timerLastDrink[type] < potDelay))
return false;
}
and now its a painlessly quick edit. just go to the top to change delays.

swiftboy36

  • Guest
Re: [D2NT] Potions
« Reply #9 on: November 05, 2010, 06:27:40 PM »
wow if 3000 is roughly 5 seconds, then i need to shorten it..


i'm testing at 1500, I'll post and see what happens xD