H&H Groovy bot

Forum for alternative clients, mods & discussions on the same.

Moderator: Phades

Re: H&H Groovy bot

Postby burgingham » Fri Aug 12, 2011 9:18 am

Ok, this is definitely starting to be a derail. So let's get back on topic, thanks :)
User avatar
burgingham
 
Posts: 8486
Joined: Fri Aug 14, 2009 10:58 pm

Re: H&H Groovy bot

Postby Fiyero » Sat Aug 13, 2011 9:48 pm

Fiyero wrote:
There are some gobs that do not display their name, like dragonflies, carts, plows or toads, is there a way to dynamically "find them"?

Im assuming the getName() function returns null or empty on these and thus the find function which uses indexOf on the getName method wont work.


I found why these Gobs didnt have a resName, they have animations on them. So to find the name of the object, you need to go into the Layered class each Gob has.

With this, your bot can even "see" other things like boars, bears and even heartlings. (So they can stop what they are doing and teleport away)

Here is the code Im developing to "see" and detect stuff around your bot. (Working on a forager bot)

Code: Select all
void detectObjects(){

     synchronized (ark_bot.glob.oc) {
          for (Gob gob : ark_bot.glob.oc) {
         String[] parts = gob.GetResName().split("/");
            if(gob.GetResName().indexOf("herbs/")>=0){
                print("Found a "+parts[parts.size()-1]);
                println(" to the "+findAdvancedGeneralDirection(gob.getc()));
            }
            else if(parts[parts.size()-1].equals("")){
                String unknownGob = "something..."
                if(MapView.tilify(gob.getc())==MapView.tilify(ark_bot.MyCoord())){continue;}//its me...
                unknownGob = getLayeredName(gob);

                println("["+gob.id+"]   I see a "+unknownGob+" nearby..."+findAdvancedGeneralDirection(gob.getc()));
            }
                }
          }
        }



    public String getLayeredName(Gob gob){
     for (GAttrib a : gob.attr.values()){
         println(a.toString());
         if(a instanceof Layered){
             Layered gh = (Layered)gob.getattr(Layered.class);
             for(Map.Entry entry : gh.sprites.entrySet()){
                 String type = entry.getKey().toString().split("/")[1];
                 if(type.equals("kritter"))
                    return entry.getKey().toString().split("/")[2];
                 else if(type.equals("borka"))
                    return "someone";
                 break;
             }
         }
     }
     return "something..";
   }

 String findAdvancedGeneralDirection(Coord destCoord){
        String dir = "";
        Coord dest = MapView.tilify(destCoord);
        Coord myPos = MapView.tilify(ark_bot.MyCoord());
      //North = +Y, South = -Y; West = -X, East = +X

            if(dest.y > myPos.y)
                dir += "S";
            else
                dir += "N";

            if(dest.x > myPos.x)
                dir += "E";
            else
                dir += "W";

            return dir;
    }
User avatar
Fiyero
 
Posts: 32
Joined: Wed Jul 20, 2011 10:12 pm

Re: H&H Groovy bot

Postby BruThoL » Sat Aug 13, 2011 11:53 pm

Wow, looks good! Keep up the good work.
BruThoL
 
Posts: 392
Joined: Tue Feb 15, 2011 11:01 pm

Re: H&H Groovy bot

Postby Fiyero » Sun Aug 14, 2011 3:09 am

Fiyero wrote:With this, your bot can even "see" other things like boars, bears and even heartlings. (So they can stop what they are doing and teleport away)


Still needs work, today while testing, my detector was thinking some chickens were heartlings out to get him.
hehe.. Ill release a better version later.

For now, the problem is that some animals have borka in their first sprite, previously I thought only heartlings had it.

but for now Im working on the perfect harvester, since my village needs to make several stone mansions and straw doesnt grow on trees.
(although it would be harder if it did, lol)
User avatar
Fiyero
 
Posts: 32
Joined: Wed Jul 20, 2011 10:12 pm

Re: H&H Groovy bot

Postby burgingham » Sun Aug 14, 2011 6:02 am

Fiyero wrote:Still needs work, today while testing, my detector was thinking some chickens were heartlings out to get him.


Been there. Got some of us scared to deah while foraging, thinking the whole RUA was some tiles away ;)
User avatar
burgingham
 
Posts: 8486
Joined: Fri Aug 14, 2009 10:58 pm

Re: H&H Groovy bot

Postby Myzreal » Sun Aug 14, 2011 12:23 pm

Does anyone know how to access the Study Widget? I want to make the bot create cone cows while chopping down trees and putting them in his Study. I found the CharWnd and the variable which holds the Study Widget, but don't know whether it's accessible (no public nor private modifier). It also has a Label which shows the attention used, is that accessible somehow?

Generally, I would like to know how to either open the Study Widget, so I can use ark_bot.item_click("transfer") or some other way to insert the given item into the Study interface. Additionally, if it is possible to access a Label in a Widget and that Label's text variable.

Any help appreciated :)
Paste me to get hacked: http://a/%%30%30
Myzreal
 
Posts: 69
Joined: Sun Jul 03, 2011 5:32 pm

Re: H&H Groovy bot

Postby Fiyero » Sun Aug 14, 2011 2:59 pm

Myzreal wrote:Generally, I would like to know how to either open the Study Widget, so I can use ark_bot.item_click("transfer") or some other way to insert the given item into the Study interface. Additionally, if it is possible to access a Label in a Widget and that Label's text variable.



If I was interested in this, I would start analyzing ender's source code. Find what its attached to the "study" button he made and how he accomplished opening that new little window he has.
User avatar
Fiyero
 
Posts: 32
Joined: Wed Jul 20, 2011 10:12 pm

Re: H&H Groovy bot

Postby Myzreal » Mon Aug 15, 2011 12:24 pm

Yeh still can't find how to do it :(
Paste me to get hacked: http://a/%%30%30
Myzreal
 
Posts: 69
Joined: Sun Jul 03, 2011 5:32 pm

Re: H&H Groovy bot

Postby boshaw » Tue Aug 16, 2011 4:05 pm

Myzreal wrote:Does anyone know how to access the Study Widget? I want to make the bot create cone cows while chopping down trees and putting them in his Study. I found the CharWnd and the variable which holds the Study Widget, but don't know whether it's accessible (no public nor private modifier). It also has a Label which shows the attention used, is that accessible somehow?

Generally, I would like to know how to either open the Study Widget, so I can use ark_bot.item_click("transfer") or some other way to insert the given item into the Study interface. Additionally, if it is possible to access a Label in a Widget and that Label's text variable.

Any help appreciated :)



When character info window is created the study window inventory is created after it.

so if you know your char window id (x) then study window inventory will be (x+1)

access the inventory via ui.widgets.get(x+1) (inv)

then do inv.setfocus(inv) to focus on itself.

then for your item you wish to transfer widget (item)

do: item.wdgmsg("transfer", new Coord(1,1);

that should work, also i assume your arkbot thing lets you access the ui widgets raw
User avatar
boshaw
 
Posts: 1590
Joined: Tue Jun 01, 2010 10:22 pm

Re: H&H Groovy bot

Postby Myzreal » Tue Aug 16, 2011 4:08 pm

Yeh that sounds like a nice idea, I'm gonna try it as soon as I find out my char window id. Thanks!

Btw, as lately in my village someone has been picking up other ppl's chests and hiding them behind objects like mansions or palisades, I've decided to write a Log Bot, who would just basically stand and log whether someone picks up an object and who that was. Is that even possible to do with Groovy Bot? I mean, to recognize whether someone picked up an object and who that was?
Paste me to get hacked: http://a/%%30%30
Myzreal
 
Posts: 69
Joined: Sun Jul 03, 2011 5:32 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot], Google [Bot] and 2 guests