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

[Plugin][Example] Simple farm mobs

Out

Active Member
Joined
Jun 2, 2012
Messages
2,972
Reaction score
13
This is simple example, how you can make farm routines.
This example using: Sorcery (Flamebolt, Freezing arrow), Songcraft(Hummingbird Ditty), Occultism (Hell spear)
Compile this plugin with Visual Studio or build-in editor, place dll somewhere in subfolders of AB Plugins folder and start it.
Dont forget to enable checkbox in your character widget.

Code:
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace
{
    public class YourClass : Core
    {
        public static string GetPluginAuthor()
        {
            return "ArcheBuddy";
        }

        public static string GetPluginVersion()
        {
            return "1.0";
        }

        public static string GetPluginDescription()
        {
            return "Simple mobs farm";
        }
        
        //Try to find best mob in farm zone.
        public Creature GetBestNearestMob(Zone zone)
        {
            Creature mob = null;
            double dist = 999999;
            foreach (var obj in getCreatures())
            {      
                //If creature Npc and we can attack him and creature alive and distance to this creature less than other and creature have 100% hp or creature want to kill out character.
                if (obj.type == BotTypes.Npc && isAttackable(obj) && (obj.firstHitter == null || obj.firstHitter == me) && isAlive(obj) && me.dist(obj) < dist && zone.ObjInZone(obj)
                    && (hpp(obj) == 100 || obj.aggroTarget == me))
                {
                    mob = obj;
                    dist = me.dist(obj);
                }
            }
            return mob;
        }
        
        //Cancel skill if mob which we want to kill already attacked by another player.
        public void CancelAttacksOnAnothersMobs()
        {
            while (true)
            {
                if (me.isCasting && me.target != null && me.target.firstHitter != null && me.target.firstHitter != me)
                    CancelSkill();
                Thread.Sleep(100);
            }
        }  
        
        //Check our buffs
        public void CheckBuffs()
        {  
            if (buffTime("Hummingbird Ditty (Rank 1)") == 0 && skillCooldown("Hummingbird Ditty") == 0)
                UseSkillAndWait("Hummingbird Ditty", true);
        }
        
        public void UseSkillAndWait(string skillName, bool selfTarget = false)
        {
            //wait cooldowns first, before we try to cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
            if (!UseSkill(skillName, true, selfTarget))
            {
                if (me.target != null && GetLastError() == LastError.NoLineOfSight)
                {
                    //No line of sight, try come to target.
                    if (dist(me.target) <= 5)
                        ComeTo(me.target, 2);
                    else if (dist(me.target) <= 10)
                        ComeTo(me.target, 3);
                    else if (dist(me.target) < 20)
                        ComeTo(me.target, 8);
                    else
                        ComeTo(me.target, 8);
                }
            }      
            //wait cooldown again, after we start cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
        }


        public void PluginRun()
        {   
            new Task(() => { CancelAttacksOnAnothersMobs(); }).Start(); //Starting new thread
            RoundZone zone = new RoundZone(me.X, me.Y, 80); //Make new zone where we will farm. Its circle with center where your character stand at this moment with 80m radius.
            SetGroupStatus("autoexp", false); //Add checkbox to our character widget
            while (true)
            {   
                //If autoexp checkbox enabled in widget and our character alive
                if (GetGroupStatus("autoexp") && me.isAlive())
                {
                    CheckBuffs();
                    Creature bestMob = null;
                    //if we have enouth mp and hp, or mobs want to kill us - try to find bestMob.
                    if ((mpp() > 40 && hpp() > 75) || getAggroMobs().Count > 0)
                        bestMob = GetBestNearestMob(zone);    
                    //if mob exists
                    if (bestMob != null) 
                    {
                        try
                        {
                            //while this mob alive and our character alive and checkbox in widget enabled
                            while (bestMob != null && isAlive(bestMob) && isExists(bestMob) && GetGroupStatus("autoexp") && isAlive())
                            {      
                                //if another player attack this mob before our character.
                                if (bestMob.aggroTarget != me && bestMob.firstHitter != null && bestMob.firstHitter != me)
                                {
                                    bestMob = null;
                                    break;
                                }    
                                
                                //if we still dont attack our best mob, but another mob want to kill us
                                if (bestMob.firstHitter == null && getAggroMobs().Count > 0 && bestMob != GetBestNearestMob(zone)) 
                                    bestMob = GetBestNearestMob(zone);
                                
                                //Target our mob, if necessary
                                if (me.target != bestMob)
                                    SetTarget(bestMob);  
                                //Turn to our mob, if necessary
                                if (angle(bestMob, me) > 45 && angle(bestMob, me) < 315)
                                        TurnDirectly(bestMob);
                                
                                if (me.dist(bestMob) < 4 && isAlive(bestMob))
                                    UseSkillAndWait("Hell Spear");
                                UseSkillAndWait("Freezing Arrow");
                                for (int i=0;i<2;i++)
                                    UseSkillAndWait("Flamebolt");
                                   
                                //Small delay, do not load the processor
                                Thread.Sleep(10); 
                            }
                        
                            //Try to pickup drop from mob, if drop available
                            while (bestMob != null && !isAlive(bestMob) && isExists(bestMob) && bestMob.type == BotTypes.Npc && ((Npc)bestMob).dropAvailable && GetGroupStatus("autoexp") && isAlive())
                            {
                                if (me.dist(bestMob) > 3)
                                   ComeTo(bestMob, 1);
                                PickupAllDrop(bestMob);     
                            }
                        } 
                        catch {}
                        
                    }
                }
                //Small delay, do not load the processor
                Thread.Sleep(10);
            }
        }
    }
}
 
Last edited:
that part in GetbestNearestMob has some issues:

Code:
obj.firstHitter == null || obj.firstHitter == me

I'm still targeting mobs other people already engaged
 
Last edited:
Out, you are the awesomest. i am moved to tears. Thanks :)

edit: it is also quite good! from the code i'd say its better than the other (specially don't attack other's mobs)
 
Last edited:
sorry im a bit of a noob. how would i use this scrip as a daggerspell?
 
sorry im a bit of a noob. how would i use this scrip as a daggerspell?
This is not for using it as is but for retouching.
It will only work out of the box, as Out said, only for Sorcerers with Occultism for attacking and Songcraft for buff.

What you need to do is find out YOUR 3 most useful (aka potent, fast, combinable, whatever) skills and YOUR buff ... search for the skill names and write yours DONT SCREWUP THE SPELLING and the same with the buff.

So open up notepad++ new document, copy and paste the code section above, and edit away:

This one does the paralyzing arrow (occ), plus one frost arrow (Sor) and 2 fireballs (sor) to have the slow combo and the damage combo. so any skills you replace them with will fire in the same order .... skil 1, skill 2, skill 3, skill 3 (repeat)

Everything you need to start retouching is here read it carefully and test it.

Put the buff skill in this section
Code:
            public void CheckBuffs()
            {
                if (buffTime("Hummingbird Ditty (Rank 1)") == 0 && skillCooldown("Hummingbird Ditty") == 0)
                    UseSkillAndWait("Hummingbird Ditty", true);
            }

Your 3 skills would go in this part (look for this and replace yours)
Code:
                                UseSkillAndWait("Hell Spear");
                                UseSkillAndWait("Freezing Arrow");
                                for (int i = 0; i < 2; i++)
                                    UseSkillAndWait("Flamebolt");

Save it as WiderG99.cs

place it in the plugins folder ... it will compile it for you on bootup.
 
Last edited:
Hello I am a new user and i found it useful, thanks
But I wonder that how can i add multi buff checking?
and can i use skill to heal myself in the script?(like using healing hymn)
I have edited it by myself but it seems didn't work
Can you please help me to modified it again? thanks a lot!

using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace
{
public class YourClass : Core
{
public static string GetPluginAuthor()
{
return "ArcheBuddy";
}

public static string GetPluginVersion()
{
return "1.0";
}

public static string GetPluginDescription()
{
return "Simple mobs farm";
}

//Try to find best mob in farm zone.
public Creature GetBestNearestMob(Zone zone)
{
Creature mob = null;
double dist = 999999;
foreach (var obj in getCreatures())
{
//If creature Npc and we can attack him and creature alive and distance to this creature less than other and creature have 100% hp or creature want to kill out character.
if (obj.type == BotTypes.Npc && isAttackable(obj) && (obj.firstHitter == null || obj.firstHitter == me) && isAlive(obj) && me.dist(obj) < dist && zone.ObjInZone(obj)
&& (hpp(obj) == 100 || obj.aggroTarget == me))
{
mob = obj;
dist = me.dist(obj);
}
}
return mob;
}

//Cancel skill if mob which we want to kill already attacked by another player.
public void CancelAttacksOnAnothersMobs()
{
while (true)
{
if (me.isCasting && me.target != null && me.target.firstHitter != null && me.target.firstHitter != me)
CancelSkill();
Thread.Sleep(100);
}
}

//Check our buffs
public void CheckBuffs()
{
if (buffTime("Hummingbird Ditty (Rank 1)") == 0 && skillCooldown("Hummingbird Ditty") == 0)
UseSkillAndWait("Hummingbird Ditty", true);
}

public void CheckBuffs2()
{
if (buffTime("Insulating Lens (Rank 2)") == 0 && skillCooldown("Insulating Lens") == 0)
UseSkillAndWait("Insulating Lens", true);
}

public void UseSkillAndWait(string skillName, bool selfTarget = false)
{
//wait cooldowns first, before we try to cast skill
while (me.isCasting || me.isGlobalCooldown)
Thread.Sleep(50);
if (!UseSkill(skillName, true, selfTarget))
{
if (me.target != null && GetLastError() == LastError.NoLineOfSight)
{
//No line of sight, try come to target.
if (dist(me.target) <= 5)
ComeTo(me.target, 2);
else if (dist(me.target) <= 10)
ComeTo(me.target, 3);
else if (dist(me.target) < 20)
ComeTo(me.target, 8);
else
ComeTo(me.target, 8);
}
}
//wait cooldown again, after we start cast skill
while (me.isCasting || me.isGlobalCooldown)
Thread.Sleep(50);
}


public void PluginRun()
{
new Task(() => { CancelAttacksOnAnothersMobs(); }).Start(); //Starting new thread
RoundZone zone = new RoundZone(me.X, me.Y, 80); //Make new zone where we will farm. Its circle with center where your character stand at this moment with 80m radius.
SetGroupStatus("autoexp2", false); //Add checkbox to our character widget
while (true)
{
//If autoexp checkbox enabled in widget and our character alive
if (GetGroupStatus("autoexp2") && me.isAlive())
{
CheckBuffs();
Creature bestMob = null;
//if we have enouth mp and hp, or mobs want to kill us - try to find bestMob.
if ((mpp() > 40 && hpp() > 75) || getAggroMobs().Count > 0)
bestMob = GetBestNearestMob(zone);
//if mob exists
if (bestMob != null)
{
try
{
//while this mob alive and our character alive and checkbox in widget enabled
while (bestMob != null && isAlive(bestMob) && isExists(bestMob) && GetGroupStatus("autoexp") && isAlive())
{
//if another player attack this mob before our character.
if (bestMob.aggroTarget != me && bestMob.firstHitter != null && bestMob.firstHitter != me)
{
bestMob = null;
break;
}

//if we still dont attack our best mob, but another mob want to kill us
if (bestMob.firstHitter == null && getAggroMobs().Count > 0 && bestMob != GetBestNearestMob(zone))
bestMob = GetBestNearestMob(zone);

//Target our mob, if necessary
if (me.target != bestMob)
SetTarget(bestMob);
//Turn to our mob, if necessary
if (angle(bestMob, me) > 45 && angle(bestMob, me) < 315)
TurnDirectly(bestMob);

if (me.dist(bestMob) < 4 && isAlive(bestMob))
UseSkillAndWait("Freezing Earth");
UseSkillAndWait("Freezing Arrow");
UseSkillAndWait("Enervate");
UseSkillAndWait("Earthen Grip");
for (int i=0;i<2;i++)
UseSkillAndWait("Flamebolt");

//Small delay, do not load the processor
Thread.Sleep(10);
}

//Try to pickup drop from mob, if drop available
while (bestMob != null && !isAlive(bestMob) && isExists(bestMob) && bestMob.type == BotTypes.Npc && ((Npc)bestMob).dropAvailable && GetGroupStatus("autoexp") && isAlive())
{
if (me.dist(bestMob) > 3)
ComeTo(bestMob, 1);
PickupAllDrop(bestMob);
}
}
catch {}

}
}
//Small delay, do not load the processor
Thread.Sleep(10);
}
}
}
}
 
Last edited:
Code:
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace Ashtag
{
    public class YourClass : Core
    {
        public static string GetPluginAuthor()
        {
            return "ArcheBuddy";
        }

        public static string GetPluginVersion()
        {
            return "1.0";
        }

        public static string GetPluginDescription()
        {
            return "Simple mobs farm";
        }
        
        //Try to find best mob in farm zone.
        public Creature GetBestNearestMob(Zone zone)
        {
            Creature mob = null;
            double dist = 999999;
            foreach (var obj in getCreatures())
            {      
                //If creature Npc and we can attack him and creature alive and distance to this creature less than other and creature have 100% hp or creature want to kill out character.
                if (obj.type == BotTypes.Npc && isAttackable(obj) && (obj.firstHitter == null || obj.firstHitter == me) && isAlive(obj) && me.dist(obj) < dist && zone.ObjInZone(obj)
                    && (hpp(obj) == 100 || obj.aggroTarget == me))
                {
                    mob = obj;
                    dist = me.dist(obj);
                }
            }
            return mob;
        }
        
        //Cancel skill if mob which we want to kill already attacked by another player.
        public void CancelAttacksOnAnothersMobs()
        {
            while (true)
            {
                if (me.isCasting && me.target != null && me.target.firstHitter != null && me.target.firstHitter != me)
                    CancelSkill();
                Thread.Sleep(100);
            }
        }  
        
        //Check our buffs
        public void CheckBuffs()
        {  
            if (buffTime("Double Recurve (Rank 1)") == 0 && skillCooldown("Double Recurve") == 0)
                UseSkillAndWait("Double Recurve", true);
        }
        
        public void UseSkillAndWait(string skillName, bool selfTarget = false)
        {
            //wait cooldowns first, before we try to cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
            if (!UseSkill(skillName, true, selfTarget))
            {
                if (me.target != null && GetLastError() == LastError.NoLineOfSight)
                {
                    //No line of sight, try come to target.
                    if (dist(me.target) <= 5)
                        ComeTo(me.target, 2);
                    else if (dist(me.target) <= 10)
                        ComeTo(me.target, 3);
                    else if (dist(me.target) < 20)
                        ComeTo(me.target, 8);
                    else
                        ComeTo(me.target, 8);
                }
            }      
            //wait cooldown again, after we start cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
        }


        public void PluginRun()
        {   
            new Task(() => { CancelAttacksOnAnothersMobs(); }).Start(); //Starting new thread
            RoundZone zone = new RoundZone(me.X, me.Y, 80); //Make new zone where we will farm. Its circle with center where your character stand at this moment with 80m radius.
            SetGroupStatus("autoexp", false); //Add checkbox to our character widget
            while (true)
            {   
                //If autoexp checkbox enabled in widget and our character alive
                if (GetGroupStatus("autoexp") && me.isAlive())
                {
                    CheckBuffs();
                    Creature bestMob = null;
                    //if we have enouth mp and hp, or mobs want to kill us - try to find bestMob.
                    if ((mpp() > 40 && hpp() > 75) || getAggroMobs().Count > 0)
                        bestMob = GetBestNearestMob(zone);    
                    //if mob exists
                    if (bestMob != null) 
                    {
                        try
                        {
                            //while this mob alive and our character alive and checkbox in widget enabled
                            while (bestMob != null && isAlive(bestMob) && isExists(bestMob) && GetGroupStatus("autoexp") && isAlive())
                            {      
                                //if another player attack this mob before our character.
                                if (bestMob.aggroTarget != me && bestMob.firstHitter != null && bestMob.firstHitter != me)
                                {
                                    bestMob = null;
                                    break;
                                }    
                                
                                //if we still dont attack our best mob, but another mob want to kill us
                                if (bestMob.firstHitter == null && getAggroMobs().Count > 0 && bestMob != GetBestNearestMob(zone)) 
                                    bestMob = GetBestNearestMob(zone);
                                
                                //Target our mob, if necessary
                                if (me.target != bestMob)
                                    SetTarget(bestMob);  
                                //Turn to our mob, if necessary
                                if (angle(bestMob, me) > 45 && angle(bestMob, me) < 315)
                                        TurnDirectly(bestMob);
                                
                                if (me.dist(bestMob) < 4 && isAlive(bestMob))
                                    UseSkillAndWait("Charged Bolt");
                                UseSkillAndWait("Piercing Shot");
                                for (int i=0;i<2;i++)
                                    UseSkillAndWait("Endless Arrows");
                                   
                                //Small delay, do not load the processor
                                Thread.Sleep(10); 
                            }
                        
                            //Try to pickup drop from mob, if drop available
                            while (bestMob != null && !isAlive(bestMob) && isExists(bestMob) && bestMob.type == BotTypes.Npc && ((Npc)bestMob).dropAvailable && GetGroupStatus("autoexp") && isAlive())
                            {
                                if (me.dist(bestMob) > 3)
                                   ComeTo(bestMob, 1);
                                PickupAllDrop(bestMob);     
                            }
                        } 
                        catch {}
                        
                    }
                }
                //Small delay, do not load the processor
                Thread.Sleep(10);
            }
        }
    }
}

would someone mind improving this for me? its running to mobs, but it isn't using any skills as of now, im trying to use it as a "Primeval"..
 
Last edited:
Code:
//Turn to our mob, if necessary
                                if (angle(bestMob, me) > 45 && angle(bestMob, me) < 315)
                                        TurnDirectly(bestMob);
                                
                                if (me.dist(bestMob) < 4 && isAlive(bestMob))
                                    UseSkillAndWait("Hell Spear");
                                UseSkillAndWait("Freezing Arrow");
                                for (int i=0;i<2;i++)
                                    UseSkillAndWait("Flamebolt");
                                   
                                //Small delay, do not load the processor
                                Thread.Sleep(10);

Add more skills here, below TurnDirectly
 
How would we alter this to keep the player a few steps from the mob at all times?
 
How would we alter this to keep the player a few steps from the mob at all times?
Make another Task(Thread), that will control distance, and if you dont casting - call MovBackward, for example.
 
Code:
//Turn to our mob, if necessary
                                if (angle(bestMob, me) > 45 && angle(bestMob, me) < 315)
                                        TurnDirectly(bestMob);
                                
                                if (me.dist(bestMob) < 4 && isAlive(bestMob))
                                    UseSkillAndWait("Hell Spear");
                                UseSkillAndWait("Freezing Arrow");
                                for (int i=0;i<2;i++)
                                    UseSkillAndWait("Flamebolt");
                                   
                                //Small delay, do not load the processor
                                Thread.Sleep(10);

Add more skills here, below TurnDirectly
Got it, thanks very much!
hope you could make more good sample for us!
and is it possible to go back at the farm zone point if dead?
 
and is it possible to go back at the farm zone point if dead?
Yep. You should just check isAlive(), and if you die - then use MoveTo or Gps system to back to spot
Code:
if(!isAlive())
{       
    Log(DateTime.Now + " I`m die");
    while(me.resurrectionWaitingTime>0)
        Thread.Sleep(100);
    Thread.Sleep(3000);
    ResToRespoint();
    Thread.Sleep(10000);
    RestoreExp();
    Thread.Sleep(2000);;
    MoveTo();
    MoveTo();
    MoveTo();
    MoveTo();
    MoveTo();
    Thread.Sleep(1000);
}
 
Please, guys, I need your help. In the thread Vichkraft there is a skill "Play Dead", when I am trying to use it, the character uses it and immediately gets to his feet, thus ceasing the use of this skill. What am I doing wrong?
Code:
                               if (mpp() < 50) 
                                { 
                                    while ((mpp() < 100) && mobsCountThatAttackUs() == 0 && GetGroupStatus("autoexp") && isAlive())   
                                       { 
                                        UseSkill("Play Dead");  
                                        Thread.Sleep(1000);                         
                                       }
                                }
 
Describe conditions when you want to use "Play Dead", and when your character should hets to his feet.
 
When mana < 50% I use a skill "Play Dead". When mana = 100%, I stop the regeneration and continue the farming.
 
Try
Code:
if (mpp() < 50) 
{
	UseSkill("Play Dead");  
	//skill used, we on the ground
  while ((mpp() < 99) && mobsCountThatAttackUs() == 0 && GetGroupStatus("autoexp") && isAlive())   
	  Thread.Sleep(100); //just waiting, while condition true. mpp() 99 - becouse ArcheBuddy can calculate hp\mp inaccuracy
}
 
It is work, thanks very much! But the character uses "Play Dead" and waiting for all of 60 seconds before the time runs. And only then character should hets to his feet, ignoring 90-95-99%(mp).
Персонаж использует умение "Play Dead", но лежит все 60 секунд, и только по прошествии этого времени продолжает фармить. Не хочет прерывать умение, когда мана восстанавливается на 90-99%.
 
Try
Code:
if (mpp() < 50) 
{
	UseSkill("Play Dead");  
	//skill used, we on the ground
  while ((mpp() < 99) && mobsCountThatAttackUs() == 0 && GetGroupStatus("autoexp") && isAlive())   
	  Thread.Sleep(100); //just waiting, while condition true. mpp() 99 - becouse ArcheBuddy can calculate hp\mp inaccuracy
}
Hello, and I have a question again?
How can i use insulating lens regularly coz it seems didn't work in buff time checking

Thanks!
 
Back
Top