H&H Groovy bot
Moderator: Phades
-
burgingham
- Posts: 8486
- Joined: Fri Aug 14, 2009 10:58 pm
Re: H&H Groovy bot
Ok, this is definitely starting to be a derail. So let's get back on topic, thanks 
-
Fiyero
- Posts: 32
- Joined: Wed Jul 20, 2011 10:12 pm
Re: H&H Groovy bot
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.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.
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;
}
-
BruThoL
- Posts: 392
- Joined: Tue Feb 15, 2011 11:01 pm
Re: H&H Groovy bot
Wow, looks good! Keep up the good work.
-
Fiyero
- Posts: 32
- Joined: Wed Jul 20, 2011 10:12 pm
Re: H&H Groovy bot
Still needs work, today while testing, my detector was thinking some chickens were heartlings out to get him.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)
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)
-
burgingham
- Posts: 8486
- Joined: Fri Aug 14, 2009 10:58 pm
Re: H&H Groovy bot
Been there. Got some of us scared to deah while foraging, thinking the whole RUA was some tiles awayFiyero wrote:Still needs work, today while testing, my detector was thinking some chickens were heartlings out to get him.
-
Myzreal
- Posts: 69
- Joined: Sun Jul 03, 2011 5:32 pm
Re: H&H Groovy bot
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
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
-
Fiyero
- Posts: 32
- Joined: Wed Jul 20, 2011 10:12 pm
Re: H&H Groovy bot
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.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.
-
Myzreal
- Posts: 69
- Joined: Sun Jul 03, 2011 5:32 pm
-
boshaw
- Posts: 1612
- Joined: Tue Jun 01, 2010 10:22 pm
Re: H&H Groovy bot
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
-
Myzreal
- Posts: 69
- Joined: Sun Jul 03, 2011 5:32 pm
Re: H&H Groovy bot
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?
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