Jump to content

Sleeping Crab Detection


creationx

Recommended Posts

I am creating my own private script for Rock Crabs (may be released after it's perfected, for a price of course). 

 

 

Is there anyway to detect whether or not the crab is aggressive? My first thought would be to walk near the crab and check for combat, and if no they are non aggressive, however there could be the exception that someone else is simply fighting the rock crab. 

 

So here are the questions:

How do I detect the crab when it's not an active NPC?

How do I detect the crab when it's in a fight with ANOTHER player? (or any NPC for that matter)

Is there a way to detect the crab based off of it's model? (not ID, but model)

 

Thank you everyone for your help in my journey to create quality scripts for the community.

It may take awhile to get the hang of it, but when I've got it, I'll be releasing the most human like scripts seen. 

 

-CX

 

Link to comment
Share on other sites

Welllll

 

Firstly, we already have 3 rock crabs scripts (lol), but I guess we'll all welcome new competition

 

The way I check in my script is much the same to how a human would check:

  • Walk up to crab
  • Check if there is a rock crab in the nearest 3x3 square around the player which is fresh
  • Attack said crab
  • Check if under attack & rock crab still exists

If no rock crab (NPC) spawns, then refresh :)

ofcourse there would be timers going on throughout. The only problem with this method is sometimes it refreshes when it doesnt need to if the world lags by over 5 seconds or so, but this rarely happens, so it's not too much of a problemo in my script.

 

Apaec

  • Like 1
Link to comment
Share on other sites

Please do not consider my contributions to the community as competition towards other scripters, but rather advancements towards the community.

 

Thank you for your response, however I believe my original question was not necessarily answered; this may have been an error on my part.

 

So the question rephrased would be: How are non-aggressive crabs classified in game? Are they objects or NPCS? Secondly, How do I go about gathering the information that they have changed to be nonaggressive? This way I can relay the information to a new part of the script that will then do what needs to be done in order to re-aggravate the crabs. 

Link to comment
Share on other sites

I'm going to assume that with "non-aggressive" you mean "sleeping" and not "not automatically attacking the player". If I'm assuming wrongly then there's no way to find out if a monster is aggressive (in the API at least, that I'm aware of) but crabs in the "awake" state are ALWAYS NPCs. 

 

So the question rephrased would be: How are non-aggressive crabs classified in game? Are they objects or NPCS? 

 

"Sleeping" crabs are classified as Object (I'm pretty sure they are at least).

You can verify yourself with this debugger:

18501d32613167e97f3b3717f7887243.png

 

How do I detect the crab when it's in a fight with ANOTHER player?

NPC crab = //GET AWAKE CRAB HERE.
if (crab.getInteracting() != null) {
if (getInteracting().equals(myPlayer()) {
 // CRAB IS INTERACTING WITH ME
}
else {
// CRAB IS INTERACTING WITH OTHER PLAYER (OR NPC)
}
}

Hope this helped.

 

Edit: like APA  said, not sure if there's room for another RC script on the market tbh :p

Edited by Botre
  • Like 1
Link to comment
Share on other sites

I'm going to assume that with "non-aggressive" you mean "sleeping" and not "not automatically attacking the player". If I'm assuming wrongly then there's no way to find out if a monster is aggressive (in the API at least, that I'm aware of) but crabs in the "awake" state are ALWAYS NPCs.

"Sleeping" crabs are classified as Object (I'm pretty sure they are at least).

You can verify yourself with this debugger:

18501d32613167e97f3b3717f7887243.png

NPC crab = //GET AWAKE CRAB HERE.if (crab.getInteracting() != null) {if (getInteracting().equals(myPlayer()) { // CRAB IS INTERACTING WITH ME}else {// CRAB IS INTERACTING WITH OTHER PLAYER (OR NPC)}}
Hope this helped.

Edit: like APA said, not sure if there's room for another RC script on the market tbh :p

Make sure you store your instances of getInteracting, and everything else, then operate on those instances. That code can throw an npe.

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