"Line Of Sight" plugin

Discussion in 'JS Plugin Releases (RMMV)' started by bomblord, Oct 1, 2016.

  1. bomblord

    bomblord Veteran Veteran

    Messages:
    87
    Likes Received:
    11
    First Language:
    English
    After some googling I couldn't find an existing one of these for my project so I built one myself. After getting a lot of help on this forum I decided to share it. It's a fairly simple plugin but it works.

    I've attached the plugin and will provide some basic instructions on use. I'm hoping to fix any bugs that crop up as I use it more extensively.



    What it does


    Allows any event to react if the player walks with their "line of sight" this also is obscured by impassable objects making it possible to do stealth sections.

    [​IMG]

    The line of sight is 1 block wide and extends in all 4 directions around the set event. I allow you to set a limit on length and direction (ex you only want it be able to see 5 tiles out to the right you can do that)

    How to use

    To use simply load the file in the plugin manager and then put the following line of code in your event (and set the event to parallel process). To attach the code use the "script" button on the bottom right of the third page.


    lineOfSight(5, this._eventId, this._mapId, "auto");


    The first variable is the number of tiles away you want the event to be able to see the player (I arbitrarily have it set to 5) any positive number will work though.
    The second variable is the event Id. this._eventId will automatically set it to the event it is being called from.
    The third variable is the mapId of the event this._mapId will auto set it to the correct map
    Last is the direction you want the line of sight to work in possibilities are "up" "down" "left" "right", "all", and "auto"


    Auto will set it to whatever direction the event is currently facing


    All will set to check every direction.

    When the player is seen it sets event self switch A to on. So create your logic around that.

    To Do
    Potentially fix bugs

    Terms Of Use


    I'm not fond of legal mumbo jumbo if you want to use this in any project be it free, commercial, or anything else I don't require anything in return in any capacity. No need to credit either (but if you want to that is fine as well).

    If you use it please let me know how it works!
     


    View attachment lineofsight.js
     
    Last edited by a moderator: Oct 1, 2016
    #1
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,801
    Likes Received:
    7,617
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Seeing as you have a finished version, I'm going to move this to Plugin Releases. You can still continue to improve/debug it there.
     
    #2
  3. bomblord

    bomblord Veteran Veteran

    Messages:
    87
    Likes Received:
    11
    First Language:
    English

    Thanks, guess I should add a terms of use.
     
    #3
  4. icomefordl

    icomefordl Villager Member

    Messages:
    5
    Likes Received:
    0
    it didnt work to me , i am not sure what problem is . feel sad  ;_;
     
    #4
  5. bomblord

    bomblord Veteran Veteran

    Messages:
    87
    Likes Received:
    11
    First Language:
    English
    Sure just a few things to help you troubleshoot



    How are you calling it?
    What is happening?
    What did you expect to happen?

    Screenshots of the event screen would help.
     
    Last edited by a moderator: Oct 11, 2016
    #5
  6. Tio Sadan

    Tio Sadan Tio Sadan Veteran

    Messages:
    33
    Likes Received:
    1
    Location:
    Minas Gerais (Brasil)
    First Language:
    portugues
    tt works fine, but once the enemy event "see" the player it wont stop chasing, and because of that they get stuck in map. and if you could make the line of sight more of a cone it would be awesome.


    but then again i've been using RMMV just for a week so my knowhow is limited at best and i may be doing it all wrong
     
    #6
  7. Marillmau5

    Marillmau5 Veteran Veteran

    Messages:
    79
    Likes Received:
    9
    First Language:
    English
    how can i put a timer so after the enemy wants to chase me will stop after 10 seconds
     
    #7
  8. Rebellare

    Rebellare Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    everything works great but I have a new problem that I would love if someone here how to handle.
    I set the line of sight as lineOfSight(3, this._eventId, this._mapId, "auto"); and it works perfectly but after the event walks up to me and teleports me (everything works as intended), I set a script call to bring him back that looks like this: $gameMap._events[12].moveStraight($gameMap._events[12].findDirectionTo(18, 15))
    BUT, here's the problem. When the event goes back to that position, he only goes back by 1 tile, 1TILE! If anyone knows how to expand the amount of tiles I would be so grateful.
    I know this is probably necro, but not sure where else to post.
     
    #8
  9. Rebellare

    Rebellare Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    ALREADY FOUND THE ANSWER I'M AN IDIOT THERE'S A SET EVENT LOCATION OPTION...
     
    #9
  10. Alastor01

    Alastor01 Veteran Veteran

    Messages:
    220
    Likes Received:
    255
    First Language:
    Russian
    Primarily Uses:
    N/A
    Oh gosh, there is a plugin for every thing I might need in my game!
    Thank you :)
     
    #10
  11. J-G

    J-G Villager Member

    Messages:
    25
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    I've tried it but nothing is happening for mine. Not usre what I did wrong. I have it set like it is in the example. Except instead of 5 I did 6 and I'm using the script to call upon it. Using Parallel process too.
     
    #11

Share This Page