Jump to content
DrizzyBot

Get type of damage?

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

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.

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