Random Diagonal Movement For Event [Yep_MoveRouteCore]

Discussion in 'Javascript/Plugin Support' started by Kike, May 12, 2019.

  1. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    I'm asking for a support, but, my post can be used as an idea for you :LZSlol:

    Since I did not find a plugin or a way of not using parallel event to put random motion in the events with diagonal movement, I used the script this.moveRepeat(direction, times) from the YEP_MoveRouteCore.js, that sets a "direction" number for the event to move (according to NumPad) a certain amount of "times" (steps). So, I thought a way to use this to do a diagonal movement for NPCs inserting a script to randomize the direction for each step the NPC does.

    this.moveRepeat((Math.randomInt(9) + 1), 1);
    upload_2019-5-12_0-2-20.png

    But . . .

    1.gif 2.gif 3.gif

    So...

    If I disable the option to repeat move, the NPCs just moves one step, as defined in the "times" in the script

    If I enable the option to repeat move, the NPCs just ignores the "times" number and starts to move in one direction without change to a new direction (as showed in the gifs)

    I tried to use a script to change one event self variables (1 to 9) and other script to move the NPC to the direction of its self variable, but no work (maybe I did something wrong)

    :LZScheeze: Some help?
     

    Attached Files:

    #1
  2. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike If you just use this command one time without a refresh or looping back to set a new value for the Math.randomInt() function, then it's doing exactly what Yanfly said...moving in a randomly chosen direction 1 time when repeat is not chosen, or moving in (the 1 direction which was randomly chosen) repeatedly when repeat is chosen. I think you need to either loop back to this command to calculate a new Math.randomInt() output after each 1 move, or somehow otherwise refresh to get a new direction value. You may want to include a wait of some arbitrary number of frames in the process, to avoid getting the same output as well since random generation functions are not truly random and often get their results from timing references such as, for example, the system clock. Hope it helps. :smile:
     
    #2
    Kike likes this.
  3. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Yes... I realized this repeat mark just repeat the results already obtained in the first time, instead of "re-read" then.

    ;-; It's what I want... but now I have some ideas of what to search for, after discover how repeat mark works :p

    Got it, but, this was not the case, because the time of steps alread was counting for the random generation script. I tested your idea, the character waited 60 frames and continued in the same direction :v

    Even so, thank You very much for your answers!
     
    #3
    mathmaster74 likes this.
  4. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike You're very welcome! :cutesmile:

    In response to this:

    my suggestion would be to set a label and call it something like Restart just before the plugin command you're using, then set a condition with an Else branch just after the plugin command (if needed to break out of the loop). If the condition is met, then continue with the rest of the event (no code needed for this case of the condition), else Jump to Label: Restart. If you don't want to break out of the loop for any reason, then just put the Jump to Label: Restart immediately after the plugin command by itself without using a condition, and that should do it. Best! :hhappy:
     
    #4
    Kike likes this.
  5. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    I want to create it at the event movement panel, to use the event for other things (for this cause I don't use the movement as parallel event (~and for don't make the game heavy~).

    upload_2019-5-13_17-28-39.png

    I searched for a script to use label, or a loop in this panel, but it appears to be too complex for me :LZSlol:
     
    #5
  6. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike What if you put the Label: Restart right before the script call, the rest after the script call, and then set the script to only one move? :unsure:
     
    #6
  7. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    :( But there's no label option or another kind of loop in the movement panel
     
    #7
  8. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike I'm not sure what you mean by "the movement panel", so let's not think about being inside a movement panel. In RPG Maker, you make Events do what you want one line at a time using Event Commands. Label is an available Event Command, so in RPG Maker set this Event Command before you call your script. Likewise, in RPG Maker on the line after the script call line in the event, do the rest as said before. If done properly, all should be fixed. If not, I'm really getting to be at a loss. :(
     
    #8
  9. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    ^^ Maybe I can use your idea for some events! :LZSsad: But . . . :LZSsad:if I need the event to do things by click, and use Event Commands to make movements, then the event will be running this movement, and not the things I wanted to make it to do.

    Another idea I may use is to make random diagonal movements by a parallel event, where I can set a variable to be generated per time and a common movement route set according to the variable. :LZSsad: But . . . :LZSsad: parallel events like this generate another problems for the game...

    I wanted to create in the panel (
    upload_2019-5-14_22-17-17.png

    (I had no name for it, so I called "panel" :LZSjoy:)
    ) 'cause I thought of doing it in a more practical way :p

    :LZSgrin: Anyway, thank you very very much! sorry to bother u :LZSyum: I'll use these common methods ^^
     
    #9
    mathmaster74 likes this.
  10. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike You were no bother at all. I enjoy helping and trying to help and...guess what? I got it! I think... My problem was I didn't have the plugin set up in my own project in front of me to properly help you. Now I do. I had to try quite a few ideas myself. Here's what finally worked:
    2019-05-14 (1).png
    So...in the Note: field, I typed <Always Update Movement> because this was in the plugin instructions. That alone wasn't enough. I used Direction Fix OFF because that could have been the problem. Didn't fix it yet, either. I turned Walking Animation ON because the sliding movement was getting to me. Still didn't fix the direction problem, of course. I put in Script: Pattern Unlock because it was a command that didn't make sense to me in Yanfly's instructions, but I thought...give it a try. Still nada. I put a wait of 3 frames after the script call because sometimes randoms feed off a timer and maybe the same timer was getting hit. I think we went over that, so...you can guess that didn't do it. What finally worked was using the Turn at Random and Move at Random commands after the script call. Why? My guess is that since they require the random function to work again they "snap it out of" the one value it was locked in. Presto! Give it a shot and let me know if you got it. I think you will this time because I finally did my due dilligence. :biggrin:

    EDIT: Oh, yeah...and keep Repeat Movements checked! Lol!
     
    Last edited: May 15, 2019
    #10
  11. Kike

    Kike Paladin Veteran

    Messages:
    36
    Likes Received:
    19
    Location:
    Brasil
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Hi, thanks again! :D
    I used your sequence, and... yeah... in the first view it appeared amasing! but I realized the random movement the character was doing was basicaly the random movement option you put in final line, 'cause the script still move the event to the same direction.

    upload_2019-5-16_19-16-9.png

    1.gif 2.gif 3.gif 4.gif

    How was the movement you tested in the event? it was working like this or different? :p
     
    #11
  12. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kike Yeah...:frown: It ended up the same. I tried ditching the script for the plugin and just using route commands turn at random and move forward 1, but that only does 4 directional movement at random. I really don't know how you get it to randomly face or move in a diagonal direction on occasion without the script call and I don't know how to make the script call refresh its random calculation, so... maybe someone like @Andar or @MushroomCake28 or @Shaz can help with this? Hopefully the @s will get you some better eyes on this. I doubt I will come up with anything else any time soon as I have a 3 day work weekend starting tomorrow with 12 hour days and my own project has suddenly decided it doesn't want the 2 main plugins to play nice after agreeing with each other for like a solid week of playtesting. :LZSteary::LZYugh:

    @Kike EDIT: Couldn't sleep. Had an "inspiration". It didn't work. Tried looking up solutions and found some plugins you may want to try as alternatives to the movement panel: QMovement (or Quasi Movement by Quxios), or possibly this by xilefian: https://forums.rpgmakerweb.com/index.php?threads/altimit-pixel-movement-0-50β.85408/page-6#post-811471 which does some additional cool things. They also recommend using Victor Engine Diagonal Movement with Altimit here:
    Best!

    @Kike EDIT 2: Okay. I went back to my original advice about just using event commands after thinking about it. Here's what I was able to do:


    and here are the event commands I used...

    ◆Label:NextMove
    ◆Control Variables:#0180 Random = Random 1..9
    ◆If:Random = 1
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Lower Left

    :End
    ◆If:Random = 2
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Down

    :End
    ◆If:Random = 3
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Lower Right

    :End
    ◆If:Random = 4
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Left

    :End
    ◆If:Random = 6
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Right

    :End
    ◆If:Random = 7
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Upper Left

    :End
    ◆If:Random = 8
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Up

    :End
    ◆If:Random = 9
    ◆Set Movement Route:This Event (Wait)
    : :◇Move Upper Right

    :End
    ◆Jump to Label:NextMove

    A bit of a pain to set up, though straightforward enough. You can see the event actually animates smoother than my character. Not sure why the glitch there, but...it's an animated 8-directional randomly moving event, so...it should give you what you want/need. You mentioned wanting it to be able to have a trigger to start this behavior. Since event commands get entered on event pages, you can set the conditions to run the event page with this code on it once your trigger happens. No plugin, no script, hopefully no fuss. Try it and let me know if we have a winner. :popcorn:
     
    Last edited: May 18, 2019
    #12
    Kike likes this.

Share This Page