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

[Plugin][Example] Simple farm mobs

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!
Code:
   //Use Insulating Lens
   if (buffTime("Insulating Lens (Rank 3)") == 0)
     {
        UseSkill("Insulating Lens");
        while (me.isCasting)
        Thread.Sleep(100);
      }
 
Last edited:
Code:
   //Usу Insulating Lens
   if (buffTime("Insulating Lens (Rank 3)") == 0)
     {
        UseSkill("Insulating Lens");
        while (me.isCasting)
        Thread.Sleep(100);
      }
It works! Thank you very much!!
 
Last edited:
How can I ADD mobsCountThatAttackUs In the Script?
As it read "The name 'mobsCountThatAttackUs' does not exist in the current context"
Sorry for asking silly question
but I am a real noob in such code :(
Is there any basic & simple tutorial for people who definitely newbie?
 
Last edited:
How can I ADD mobsCountThatAttackUs In the Script?
As it read "The name 'mobsCountThatAttackUs' does not exist in the current context"
Sorry for asking silly question
but I am a real noob in such code :(
Is there any basic & simple tutorial for people who definitely newbie?


try to use getAggroMobs Method

getAggroMobs().Count

It should do the trick.
 
How can I get it to use an item in my inventory?

use: getAllInvItems()
iterate through the Item list and find the item you are looking for and Item.UseItem(true)

Here is an example:

Code:
public void useItemByName(String name){
	foreach(var itm in getAllInvItems()){
		if(itm.name == name){
			itm.UseItem(true);
		}
	}
}

//EDIT - look at Out's approach, its even easier than expected ;) - no need to browse through the items - there is already a function for it which does everything i described. :)
 
Last edited:
ArcheBuddy - Table of Content
Code:
UseItem("Mana Bottle");

Awesome.

What if I wanted to target only certain creatures but still be able to attack anyone that attacked me? I know I would change this code but I am not sure what

Code:
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;
        }
 
I added the "play dead" script written by Out
It really used the skill "play dead" when my mp below 20
but the character hit the feet immediately and cancel the buff at the same time
and I stand without any mp regeneration buff till my mp full...

Is that anyway to prevent the character hit the feet immediately??
Or i just placed the script at the wrong position??

Code
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  = 45;
            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 2)") == 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() > 20 && hpp() > 45) || 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 {}      
                        
                              //Usу Insulating Lens
   if (buffTime("Insulating Lens (Rank 3)") == 0)
     {
        UseSkill("Insulating Lens");
        while (me.isCasting)
        Thread.Sleep(100);
      }                
  if (mpp() < 20) 
{
    UseSkill("Play Dead");  
    //skill used, we on the ground
  while ((mpp() < 99) && getAggroMobs().Count() == 0 && GetGroupStatus("autoexp") && isAlive())   
      Thread.Sleep(100); //just waiting, while condition true. mpp() 99 - becouse ArcheBuddy can calculate hp\mp inaccuracy
}  
                    }
                }                     
                //Small delay, do not load the processor
            }               
        }
    }     
    
}
 
how do you get this script to work ? I use it as plugin and run it but nothing happen
 
if someone can finish the code for all the things combine in this thread that would be great :o
 
When i try to compile i have this error: error CS0101: The namespace 'YourNamespace' already contains a definition for 'YourClass'.

I compiled the code in the first post ...
 
When i try to compile i have this error: error CS0101: The namespace 'YourNamespace' already contains a definition for 'YourClass'.
Create separate folder and move .cs file to this folder for each plugin.
 
I am having some issues. I have compiled it through the AB editor and I can see it on my plugin manager. I hit play and it just sits there. I do not receive any errors.
 
Interesting thing with this plugin that is causing issues.

I target a ranged mob, move through another ranged mob to attack it. Kill mob 1, loot, then my character will sometimes find another mob within 20 then swap back and forth between mobs 2 and 3. Sometimes mid flamebolt.

Any idea what is causing this?
 
Hey 2face.. im still new to coding.. or what ever :P i released a basic archery script 1-10.. . but i am trying to figure out how to learn to "if my hp or mana is Below 50.. then it would use vegetable soup/bread when not in combat.. to heal up before the next fight.. im trying to commit it with the simple farming plugin.. any idea and guidelines would be appreciated..


AFTER COMBAT
if HP < 70 then eat food "NAME"
if mana < 70 then drink "NAME"

then > back to the simple farming script thanks!

under api documentation i looked up "EAT" "FOOD" didnt find anything though.. except about an auction house..


if (skillCooldown("Adventurer's Vegetable Bread") != 0 && hpp(me) > 75)
{
for (int i=0;i<2;i++)
UseSkillAndWait("Adventurer's Vegetable Bread");
 
Hey 2face.. im still new to coding.. or what ever :P i released a basic archery script 1-10.. . but i am trying to figure out how to learn to "if my hp or mana is Below 50.. then it would use vegetable soup/bread when not in combat.. to heal up before the next fight.. im trying to commit it with the simple farming plugin.. any idea and guidelines would be appreciated..


AFTER COMBAT
if HP < 70 then eat food "NAME"
if mana < 70 then drink "NAME"

then > back to the simple farming script thanks!

under api documentation i looked up "EAT" "FOOD" didnt find anything though.. except about an auction house..


if (skillCooldown("Adventurer's Vegetable Bread") != 0 && hpp(me) > 75)
{
for (int i=0;i<2;i++)
UseSkillAndWait("Adventurer's Vegetable Bread");

Hey!

You can check the API documentation and find that there's a method handling exactly that, using items.

I've located it for you:
UseItem Method (UInt32, Boolean)

There is also an overload for using a String instead of the ID of the item, although it is suggested to use ID's.
 
Hey!

You can check the API documentation and find that there's a method handling exactly that, using items.

I've located it for you:
UseItem Method (UInt32, Boolean)

There is also an overload for using a String instead of the ID of the item, although it is suggested to use ID's.


would you mind giving me an example im better at learning from "written" then to write it myself.. i kinda look at how it works.. and i remember from then.. and type it out.. i apprecaite it..

public bool UseItem(
uint itemId,
bool autoCome
)
 
would you mind giving me an example im better at learning from "written" then to write it myself.. i kinda look at how it works.. and i remember from then.. and type it out.. i apprecaite it..

public bool UseItem(
uint itemId,
bool autoCome
)
UseItem("youritem");
 
Back
Top