Jump to content

AeroCows - First Script


aerodude30

Recommended Posts

1 hour ago, aerodude30 said:

Hey everyone,

heres my first script. There was no combat script I could find which fought cows and banked their hides so I made one. Lemme know your thoughts I'd like to get this on the SDN

https://github.com/cbartram/AeroCows

Excellent job, love seeing professionalism especially in regard to scripting - open source (check), readme.md file (check) and the license (check) :D 

  • Like 2
Link to comment
Share on other sites

Looking good!

In your AttackCow code, you're finding a suitable cow on the activate method and on the execute method. Perhaps create a cow variable up top and reuse the same cow? Also, you could filter out any cows that are being attacked by other players:

private boolean isCow(NPC npc) {
	return npc.getName().equals("Cow")
		&& npc.getAnimation() != Cow.DYING.getAnimation()
		&& (ctx.myPlayer().equals(npc.getInteracting()) || npc.getInteracting() == null); // So either we're the dude the cow's focused on OR the cow's not focused on anybody right now
}

NPC cow = ctx.getNpcs().singleFilter(ctx.getNpcs().getAll(), (Filter<NPC>) this::isCow);

Also, you could make your Task a little easier to use by having it extend MethodProvider and then exchanging the context. You can find it under the MethodProvider section here:

 

Edited by liverare
  • Like 1
Link to comment
Share on other sites

I looked quickly but just 2 quick comments:

Your task class could extend methodProvider instead of passing the reference throughout all the sub-classes. 

Your util to grab the cost of an item is probably costly (guessing a second or so). There's a json api that lets you grab the costs - https://osbot.org/forum/topic/146793-ge-data/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...