What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

[Plugin] Auto Health Potion

jmac

New Member
Joined
Jun 17, 2012
Messages
25
Reaction score
0
Hello all, this is the first version of Auto Health Potion, currently it will use a Mythic Health Potion at 50% life.

Most people are using Belphegor combat routine, and it does not provide a potion function.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Zeta;
using Zeta.Common;
using Zeta.Common.Helpers;
using Zeta.CommonBot;
using Zeta.Common.Plugins;
using Zeta.Internals;
using Zeta.Internals.Actors;
using Zeta.Internals.Service;

//Created by: jmac
//Credit to w3eZle for his Sarkoth wait plugin
//Credit to eax (http://www.thebuddyforum.com/members/144149-eax.html) No1KnowsY (http://www.thebuddyforum.com/members/11607-no1knowsy.html)
//Based script on these guys work
//Created Date: 24June2012

namespace HealthPotion
{
    public class HealthPotion : IPlugin
    {
        private bool IsRestarting { get; set; }
        public Version Version { get { return new Version(0, 4); } }
        public string Author { get { return "jmac"; } }
        public string Description { get { return "Uses health potion if under 50% HP"; } }
        public string Name { get { return "Health Potion v" + Version; } }

        
        public Window DisplayWindow
        {
            get
            {
                return null;
            }
        }

        private void Log(string message)
        {
            Logging.Write(string.Format("[{0}] {1}", Name, message));
        }


        public void OnInitialize()
        {
            IsRestarting = false;
        }

        

        public void OnPulse()
        {

               if (ZetaDia.Actors.Me.HitpointsCurrentPct < [COLOR=#FF0000]0.50[/COLOR])
            {
                Log("Using Healh Potion");
                var i = ZetaDia.Actors.Me.Inventory.Backpack.Where(item => item.Name == "Mythic Health Potion"); 
                ZetaDia.Me.Inventory.UseItem(((ACDItem)i).DynamicId);
                return;
            }
    
            

        }

        public void OnShutdown()
        {
        }

        public void OnEnabled()
        {
            Log("Enabled.");
        }

        public void OnDisabled()
        {
            Log("Disabled.");
        }

        public bool Equals(IPlugin other)
        {
            return (other.Name == Name) && (other.Version == Version);
        }
    }

}

Change the number in red to whatever % you want, (0.40 for 40% etc...)

I realize it does not have a wait timer built into the on pulse, it is because UseItem has one itself, or at least I think since it does not spam.

Anyways please post any bugs if you encounter any.


Also, check out my Item Rules Builder GUI http://www.thebuddyforum.com/demonbuddy-forum/plugins/57304-exe-itemrules-gui.html

If you like my work, feel free to donate
 

Attachments

Last edited:
var i = ZetaDia.Actors.Me.Inventory.Backpack.Where(item => item.Name == "Mythic Health Potion");

Wouldn't it be better to do something like:

Code:
item.Name.Contains("Health Potion");

So it supports any health potion?
 
sure no doubt, I did not know item.Name contained a .Contains(string)

but now I do. thanks!
 
sure no doubt, I did not know item.Name contained a .Contains(string)

but now I do. thanks!

Yep. it's just standard C# stuff. strings have a lot of helper methods that you can use.
 
Code:
ZetaDia.Me.Inventory.Backpack.Where(i => i.IsPotion && i.RequiredLevel <= ZetaDia.Me.Level).OrderByDescending(p => p.HitpointsGranted).FirstOrDefault()
From Belphegor.
 
Is there a way to make a plugin or setting that autorefill discipline with dh as well? (preparation)
 
anyone can fix this plugin ?

currently its

if (ZetaDia.Actors.Me.HitpointsCurrentPct < 0.50)
{
Log("Using Healh Potion");
var i = ZetaDia.Actors.Me.Inventory.Backpack.Where(item => item.Name.Contains("Health Potion"));
ZetaDia.Me.Inventory.UseItem(((ACDItem)i).DynamicId);
return;
}
 
Back
Top