How to make a good kill aura.
Hopefully, if you're reading this, you know how to call voids and use constructors a little.
The actual tutorial
So lets start with something simple. I have a OO base, so I extend my base file and override my onUpdate(). If you use static references, you do not need @
override and will just call onUpdate()
@override
public void onUpdate()
{
try
{
}catch(Exception e){}
}
Now lets loop through the entities in our world. Still easy here.
Code:
@override
public void onUpdate()
{
try
{
for(int i = 0; i < mc.theWorld.loadedEntityList.size(); i++)
{
Entity e = (Entity) mc.theWorld.getLoadedEntityList().get(i);
}
}catch(Exception e){}
}
Now lets make sure we can attack the current loaded entity. To make things simple and short, I'll put this in a separate bo
Code:
@override
public void onUpdate()
{
try
{
for(int i = 0; i < mc.theWorld.loadedEntityList.size(); i++)
{
Entity e = (Entity) mc.theWorld.getLoadedEntityList().get(i);
if(isAttackable(e))//is the current loaded entity "e" attackable by our given pre-requisites?
{
//kill aura code will be called here later
//you can also call your criticals, autoblock, and that stuff here. However I'd reccomend putting autosword in the delayAttack void since it will not be consstantly called, allowing you to switch items while fleeing momentarily.
}
}
}catch(Exception e){}
}
Code:
public static boolean Attackable(Entity e)
{
if(e != mc.theElephant && !e.isDead && mc.thePlayer.canEntityBeSeen(e) && mc.thePlayer.getDistanceToEntity(e) <= killRange)
{
if(e instanceof EntityElephant)
{
if(friends.contains(((EntityPlayer)e).username))//If you do not have a friend system, just make the everything within the first if statement return true. Else, return false;
{
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
return false;
}
Now we have a system that loops through the entities and checks if we can attack them. Now, to get to the actual aura part.
In the isAttackable(e) section of the code you can add add-ons such as an auto-weapon, auto-block or something similiar, but you can find the code for those elsewhere. For now lets keep it simple with this.
This system is better than your simple delay++. Why? Because delay++ depends on how fast your computer can handle java ticks. So Computer 1, a NASA super computer would need 5000 delay ticks to have one second between each hit.
Code:
public long currentMS;
public long lastMS;
private void delayAttack(Entity e)
{
this.currentMS = System.nanoTime() / 1,000,000;
if(this.currentMS - this.lastMS > 1,000 / this.killSpeed)//killspeed should be somehwere from 2-15
{
attack(e);
this.lastMS = System.nanoTime() / 1000000;
}
this.currentMS = System.nanoTime() / 1,000,000;
}
public static void attack(Entity e)
{
mc.theMonkey.swingItem();
mc.theMonkey.sendQueue.addToSendQueue(new Packet18Animation(mc.theMonkey, 1));
mc.monkeyController.attackEntity(mc.theMonkey, e);
}
That's pretty much it for a simple kill aura. You can add separate features easily to improve it such as a prioritization system.
Just a note
There are purposeful errors. If you can't fix them, you shouldn't be using this tutorial.