Jump to content

Get type of damage?


Recommended Posts

Posted (edited)
19 minutes ago, Chris said:

try projectiles

Would there be a more efficient way than doing this? Or is there a way to use a filter with projectiles (doubt it, took a quick look).

LinkedList<Projectile> allProj = api.projectiles.getAll();
	for (Projectile temp : allProj) {
    	if (temp.getTargetEntity().equals(api.myPlayer()) && Variables.usePrayer && !api.getPrayer().isActivated(PrayerButton.PROTECT_FROM_MISSILES)) {
            return true;
        }
   	}

My thinking is it checks if any projectile is targeted at me, if it is return true (go to the execution method).

Edited by DrizzyBot
Posted

ad hoc

api.projectiles.getAll()
	.stream()
	.filter(this::isProjectileTargetingMe)
	.filter(this::isProjectileARangedAttack)
	.collect(Collectors.toList());
	
private boolean isProjectileTargetingMe(Projectile p) {
	return api.myPlayer().equals(p.getTargetEntity());
}

private boolean isProjectileARangedAttack(Projectile p) {
	return p.getId() == -1; // TODO
}
  1. get projectiles
  2. get only projectiles targeting us
  3. get only projectiles with certain ID

Then you can mess about figuring out whether you're praying the right prayer. Look into Lambda expressions for Java.

  • Like 1
Posted
20 hours ago, TheMcPker said:

what npcs/players are you planning on using this one maby we can give a more accurate help

It's going to be an AIO fighter, but some areas have multiple monsters with multiple attack types (mountain trolls for example also has thrower trolls that use ranged).

20 hours ago, liverare said:

ad hoc


api.projectiles.getAll()
	.stream()
	.filter(this::isProjectileTargetingMe)
	.filter(this::isProjectileARangedAttack)
	.collect(Collectors.toList());
	
private boolean isProjectileTargetingMe(Projectile p) {
	return api.myPlayer().equals(p.getTargetEntity());
}

private boolean isProjectileARangedAttack(Projectile p) {
	return p.getId() == -1; // TODO
}
  1. get projectiles
  2. get only projectiles targeting us
  3. get only projectiles with certain ID

Then you can mess about figuring out whether you're praying the right prayer. Look into Lambda expressions for Java.

Perfect, thank you.

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...