Jump to content

AeroCows - First Script


Recommended Posts

Posted
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
Posted (edited)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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