Jump to content

How to detect how you are being attacked.


scriptersteve

Recommended Posts

I was wondering if there is a way to find out how i am being attacked.

For example, when being attacked by say a dragon, i want to be ranging it and praying mage.

How can i see whether my player is fighting it in melee range or ranging range, i looked at the API on Combat and couldn't see anything.

Currently, my only thought was to make a big array of 'safe' tiles and just force the bot to move to one of them.

However, if the player didn't need to move and it moved anyway, i feel that would look bot-like.

Anyway your feedback is appreciated.

Link to comment
Share on other sites

6 minutes ago, FrostBug said:

Players distance from the dragon?

I thought of that, was thinking about brutal blues/reds script and you can be 'safespotting' one whilst standing next to another. https://gyazo.com/0f6f6c62c23552d51b6a97c90fe0d089

4 minutes ago, Deceiver said:

configs?

not sure what you mean?

Edited by scriptersteve
Link to comment
Share on other sites

2 minutes ago, scriptersteve said:

I thought of that, was thinking about brutal blues/reds script and you can be 'safespotting' one whilst standing next to another. https://gyazo.com/0f6f6c62c23552d51b6a97c90fe0d089

not sure what you mean?

But the one next to you is not attacking you?
Then it's fine innit

Link to comment
Share on other sites

final Player me = myPlayer();
		
		// Get all green dragons that are 'locked' on me
		List<NPC> greenDragonsFocusingOnMe = npcs.getAll().stream()
				.filter(npc -> me.equals(npc.getInteracting()))
				.filter(npc -> npc.getName().equals("Green dragon"))
				.collect(Collectors.toList());
		
		// Get the green dragon I'm locked on
		NPC greenDragonsImFocusedOn = greenDragonsFocusingOnMe.stream()
				.filter(npc -> npc.equals(me.getInteracting()))
				.findFirst()
				.orElse(null);
		
		if (greenDragonsFocusingOnMe != null && !greenDragonsFocusingOnMe.isEmpty()) {
			if (greenDragonsImFocusedOn != null) {
				// wait for dragon to die
				// heal if low on health
			} else {
				// pick one of those dragons that are focused on you
				greenDragonsImFocusedOn = greenDragonsFocusingOnMe.get(0);
				if (greenDragonsImFocusedOn.interact("Attack")) {
					// ... do stuff
				}
			}
		}

One thing I haven't included is the sorting of the green dragons by distance to you. I won't spoon feed you everything. :)

  • Like 1
Link to comment
Share on other sites

6 minutes ago, liverare said:

One thing I haven't included is the sorting of the green dragons by distance to you. I won't spoon feed you everything. :)

 

List<NPC> greenDragonsFocusingOnMe = npcs.getAll().stream()
                .filter(npc -> myPlayer().equals(npc.getInteracting()))
                .filter(npc -> npc.getName().equals("Green dragon"))
                .sorted(Comparator.comparingInt(npc -> getMap().realDistance(npc)))
                .collect(Collectors.toList());

:doge:

  • Like 1
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...