Sonar Focus

Discussion in 'Archived: Plugin Requests' started by rayblon, May 8, 2014.

  1. Offline

    rayblon

    Plugin category: Mechanic, Fun

    Suggested name: SonarFocus

    What I want: When a player enters /sonar, they're inflicted with blindness and slowness:9 until they enter /sonar again. While in sonar mode, they can see any entities' locations(within 100 blocks) relative to the player symbolized by a torch flame particle every half second(Like a 3D compass), but only when the entities are moving. As well as being able to see the movement of different entities, they hear lava.ogg looping at .2 pitch, .1 volume, and hear every footstep as if it were a block away. By default, it is attuned to players, but can be attuned to any mob using /sonar <mobname>. When any 'monster' class(dangerous) mob is within ten blocks, the player sees redstone particles surrounding them as a warning. If you take damage in sonar, you are forced out of sonar mode.

    Config:
    Sonar-Range: 100
    Warning-Rannge: 10
    Warning-Mobs: zombie, skeleton, zombiepig, spider, cavespider, Spider
    SonarSound: lava
    Sonarsoundvolume: .1
    Sonarsoundpitch: .2
    Sonarparticle: Flame
    Sonarwarning: reddust


    Ideas for commands:
    /sonar - Toggle sonar
    /sonar <mobname> - Attune sonar to a specific mob

    Ideas for permissions:
    sonar.radar - Allows use of the /sonar command
    sonar.mobs - Allows a user to change the attunement of the sonar.

    When I'd like it by: May 29th
     
  2. Offline

    Mathias Eklund

    I'm confused on how this would be working.
     
  3. Offline

    rayblon

    Basically... If your head is at X 10 y 70 and z 30, and an entity you want to track is at X 10 y 70 and z -50, the person using sonar would see a torch flame particle at X 10 y 70 z 29. I'm working on an equation that would allow this, so... yeah. Be back in a couple hours.

    I have, currently, only half the solution. You have to essentially form two sides of a pyramid with triangles that lie on the x and y axis and share the Z and Y coordinate of x2, respectively. Then, after performing law of cosine and law of sin to complete the angles of x1 to x2, you have to take the tangents of both and use them somehow to find the angle from x1 to x2. Dunno how though.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. Offline

    DotDash

    rayblon The Blindness effect wouldn't work, as it blocks out everything not within ~2-3 blocks.
     
  5. Offline

    Gamecube762

    Interesting idea, I can see how this would work, It would take some math to create. Main problem I see is that I don't think you can see particles while blinded. Actually, this may work better than I thought with how DotDash mentioned you can only see within 2-3 blocks.

    What I'd do is get all entities withing X blocks, get the distance between them, divide that distance till its only within 2-3 blocks, place a torch effect there.
     
    rayblon likes this.
  6. Offline

    timtower Moderator Moderator

    Also note that some people have their particles on decreased or just plain off ( like me )
     
    rayblon likes this.
  7. Offline

    rayblon

    Gamecube762
    Just tested it, luckily that's not the case. They're rendered just like everything else. :)

    timtower
    It's not a terrible inconvenience to click a button in the video options menu a couple times when you want to use it, though.
     
  8. Offline

    DotDash

    timtower I thought the only settings were Maximum, Decreased, and Minimal?
     
  9. Offline

    rayblon

  10. Offline

    timtower Moderator Moderator

    True that
    Minimal is pretty much none
     
    rayblon likes this.
  11. Offline

    DotDash

    @rayblon Not to be rude but:

    Off: so as to be removed or separated.

    Minimal: of a minimum amount, quantity, or degree; negligible.
     
  12. Offline

    rayblon

    DotDash
    They call it minimal because of explosions. Explosions aren't particle effects themselves, per se, but they are technically considered particle effects by some so using that term was the most equitable solution. I was referring to minimal in context of the topic at hand, not the semantics. Gg, though. :p
     
  13. Offline

    Crud41

    I'm not sure what you are requesting is *completely* possible. I know Nodus (Hacked Client) offers entity maps and threads... But to re-create that effect in game without adding any custom graphics or libraries is seemingly impossible. (Also allows to see entities through walls)

    I don't support the use of any hacked clients, nor am I promoting them. Just thinking of things you might be referring to/want.
     
  14. Offline

    Gamecube762

    Crud41 It is possible, the blindness only lets you see 2-3 blocks away, that allows us to spawn a flame particle there. With some math, we can find all entities and place a flame within 2-3 blocks to represent an entity.
     
    rayblon likes this.
  15. Offline

    rayblon

    Crud41
    Yeah, gamecube explained it, but basically we're not offering an actual entity scanning capability here. Here's an example of how this would work in minecraft if we could do it a simple way.

    So you have the blindness, and every time a player moves one block, they cast an invisible 'ray' to a sonar mode player. Imagine sonar mode as a 1 meter radius sphere around a player's head that captures these invisible rays and shows a flame on the surface where the ray hits the sphere. The only thing the client sees is the flame particle which is completely possible. The math is the only problem.

    This plugin isn't supposed to be something you use to mercilessly hunt down AFK players, it's used to show latent locations only when other entities move. It's not some all powerful thing.
     
  16. Offline

    Onlineids

    You really had to go get the definitions to prove a point -_- Come on now
     
    rayblon likes this.
  17. Offline

    Gamecube762

    Later today, if I have time available, I can start working on this. If anyone wants to help out in making this, just tell me and I can set it up on GitHub(knowing me, I might forget about the project half way through).
     
  18. Offline

    rayblon







    @Gamecube762​

    I managed to get this, but I'm not sure how useful it is. I can't verify it either




    If you have a point in a 3D coordinate plane at the coordinate X:b Y:n and Z: t, and another point at the coordinates X:s Y:l and Z:m, how do you find where a line spanning from point 1 to point 2 intersects the surface of a sphere that surrounds point 1 with a radius of 1 unit?

    "What I would do (if I had the time) is look up how to write the equations of the line and the sphere and solve them as a simultaneous pair."

    "Come to think of it, using pythagoras,
    (x-b)^2 +(y-n)^2+(z-t)^2 = 1
    is the equation of the sphere.

    and (x-b)/s=(y-n)/l =(z-t)/m
    gives equations for the line."



     
  19. Offline

    Rojet601

    Gamecube762 rayblon You guys are overcomplicating the maths. You need the difference vector between the head position and the entity, normalize that and add it to the head position. Voila, you have the flame particle position :D
     
  20. Offline

    rayblon

    My god. Rojet601 is right. I think. From what I can tell without a calculator, that should give us exactly the coordinates we need. I feel dumb now...
     
  21. Offline

    Gamecube762

    No worries rayblon you aren't the only one who takes the hard path to find the easy one afterwards XD

    Well I was able to cook up some math code that should get us what we need:
    Code:java
    1. /*
    2.   * center ~ Center location of circle(where sonar was activated)
    3.   * point ~ Location of entity
    4.   * initialSize ~ Size of circle search range
    5.   * newSize ~ Size of new circle (view range)
    6.   *
    7.   * is = initalSize
    8.   * Ns = Newsize
    9.   * x = center.x
    10.   * ox = point.x
    11.   *
    12.   * iS/Ns = s
    13.   * x - ox = dist
    14.   * dist / s = a
    15.   * x + a = nx
    16.   *
    17.   * 30/3 = 10
    18.   * 0 - 20 = 20
    19.   * 20 / 10 = 2
    20.   * 0 + 2 = 2
    21.   */
    22. public Location rescale(Location center, Location point, Double initialSize, Double newSize) {
    23. double
    24. distanceX = center.getX() - point.getX(),
    25. distanceY = center.getY() - point.getY(),
    26. distanceZ = center.getZ() - point.getZ(),
    27. SizeScale = initialSize/newSize,
    28.  
    29. newX = center.getX() + (distanceX / SizeScale),
    30. newY = center.getY() + (distanceY / SizeScale),
    31. newZ = center.getZ() + (distanceZ / SizeScale)
    32. ;
    33. return new Location(center.getWorld(), newX, newY, newZ);
    34. }

    Assuming that the distance was 30 and the center pos was at 0(which should work if the numbers increase/deccrease); I was able to divide the SearchDistance by the VeiwDistance and use that to divide the distances of the center and the entity so I can add it to the center's location.

    Currently its untested(this is currently the whole plugin, so it wont run to be tested). Now to create the code that makes the plugin run.
     
    rayblon likes this.
  22. Offline

    Rojet601

    Gamecube762 You wanna setup a GitHub repository? I could help with the plugin if you need assistance.
     
  23. Offline

    Gamecube762

    Rojet601 I'm close to getting the plugin running now, once I finish the scanning for entities and get it to compile, I can post the code.

    Edit: Github is live at https://github.com/Gamecube762/Sonar/

    Just started a quick test and its working well, currently there is no blindness/slowness and needs some cleaning up with how the flames look. It actually looks a bit cool, I'll post a video later when I get time. If you want to see if for yourself, try /sonar on my test server(theminepitt.no-ip.org:28868(Not trying to advertise)) or get the .jar from the github(still buggy, don't use on your main server.)
     
    Rojet601 likes this.
  24. Offline

    rayblon

    Gamecube762
    I checked it out, it looks AMAZING. I like how you can only figure out a general direction with the sonar, and how it's practically blinding when you have alot of mobs nearby, as it would be if this was irl. The realism factor is huge. :)

    I guess this is kind of a weird request, but can you create a permission that is something like Sonar.precise? It would swap out that person's sonar particle with the note particle, a great VIP feature. :)
     
  25. Offline

    Gamecube762

    Ya, I can do that, thing is, the note particle is one of the ones not in the BukkitAPI, I would have to tap into MC's NBT code causing that feature to be version sensitive with MC's version. I could try to use reflection to make it less version sensitive, but it could have some side effects if MC ever changed it.
     
  26. Offline

    rayblon

    Gamecube762

    Ouch. Maybe just a smaller flame(Torch sized?) particle then, if possible? If not, I guess some runes, footsteps(footsteps don't despawn quickly though), or witch particles could suffice. I can't find any information about particles so pardon me if I seem a bit uninformed(Because I am). Just to be sure, this detects players too, right?

    If all else fails, the node could just expand the radar sphere, but it would be difficult to use in close quarters.

    I just checked out the plugin again on the test server and -- Let me make this known that i've never gotten giddy about a plugin before. This is an exception. It was incredible, being immersed in darkness, yet more aware of the enemies around me than ever before. I can't wait to see the completed product! :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  27. Offline

    Gamecube762

    Just a little update:
    We have fixed the bug where others can see your sonar and also added a warning system for if a monster is withing range of your sonar. I'm also going to work on making it so other plugins can hook into this so it can be used for gamemodes/minigames.

    Currently the latest Sonar.jar is on the Github(can still have bugs and is not recommended for use on main server) and is on the test server(theminepitt.no-ip.org:28868).

    Quick Links:
    Sonar on Github
    Sonar.jar

    Tell us what you think and what we should add/change.
     
  28. Offline

    rayblon

    Gamecube762
    Sorry for the delayed response; It seems like a fairly well rounded plugin. So long as it can weather high usage effectively it seems to be finished.

    EDIT: Bumping the slowness up to IV would be appreciated as well.

    EDIT 2: Leaving the server with Sonar enabled seems to generate an exception, but it doesn't appear to affect the way the plugin functions.
     
  29. Offline

    Desle

    rayblon

    They have added a new permission to bypass the blindness effect. Sonar.nodarkness. Therefor I am guessing it's not blinding because you are OP.
     
  30. Offline

    Gamecube762

    rayblon I'll look into them. Honestly I forgot completely about this plugin. XD

    Desle Actually its probably from the low levels of it when I was first testing it. The .noDarkenss perm is defaulted to where no one has it, not even OPs unless defined by a Perms plugin.

    Edit:
    So I have made the requested changes/fixes and a few more:
    • Entering and leaving Sonar should be more faster
    • Slowness was increased and Jumping disabled to prevent players from jumping to bypass Slowness
    • Exception on player leaving with Sonar on was fixed
    Download: Sonar.Jar
    Github Repo for anyone interested
     

Share This Page