Change Y axis move speed?

Discussion in 'Javascript/Plugin Support' started by Dustlor, Jul 31, 2019.

  1. Dustlor

    Dustlor Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    Looking for a way to change the default move speed on the Y axis (want to double it). I've seen plenty to change the speed for all directions, but not for individual directions.

    I'm trying to change this for all characters including followers and NPCs. I found the movespeed value under
    Game_CharacterBase in the RPG_objects.jss, but that's just a flat value for all directions. No Axis control :(

    Any plugins, scripts, or values to change? I've been searching for hours and would really appreciate the help.
     
    #1
  2. Restart

    Restart Veteran Veteran

    Messages:
    201
    Likes Received:
    129
    First Language:
    English
    Primarily Uses:
    RMMV
    Haven't tested it, but try something like


    Code:
    Game_CharacterBase.prototype.realMoveSpeed = function() {
        return this._moveSpeed + (this.isDashing() ? 1 : 0) + 1 * ([8,2].contains(this.direction())? 1 : 0);
    };
    That should increase your move speed if your sprite is facing directly up/down, as if you're dashing.
     
    #2
    caethyril and Dustlor like this.
  3. Dustlor

    Dustlor Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    I was trying to change the base speed so that the speed would still double on dashing for all directions.

    So movement would go normal on directions 6 and 4 and double for directions 8 and 2, but that dashing would still double both of them (2x on x axis and 4x on y axis while dashing)

    Also I'm using a plugin that changes animation sets at dashing, so I need something that will change the speed at its base without activating dashing. Sorry I didn't include that :/

    And thank you so much for the response! This at least gives me a direction to go in researching. I'm still really new, so thanks so much for the help!
     
    Last edited: Jul 31, 2019
    #3
  4. Restart

    Restart Veteran Veteran

    Messages:
    201
    Likes Received:
    129
    First Language:
    English
    Primarily Uses:
    RMMV
    Sorry, I wasn't very clear - in principle the code should stack dashing with the boost - I meant it was 'like dashing' because it'd be the same difference in speed.
     
    #4
    Dustlor likes this.
  5. Dustlor

    Dustlor Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh gotcha! You are a life saver and a half then! I'll get this tested out to see if it works :) Thank you so much!!!!!!

    No need to apologize, I'm still learning and know next to nothing about object based whatsits. Thank you for the response and for your patience good sir! I bid you good day.
     
    #5
  6. Dustlor

    Dustlor Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    The code works!!! Thank you so much for you help! It took me down a path of learning a ton about objects. Very much appreciated :D

    Unfortunately I ran into a snafu with a mod that I'm trying to fix. It is interacting strangely with Galv's Diagonal move mod. The boost works normally on the normal 4 directions (boosts up and down and leaves left and right alone), but with the diagonal mod, it will boost diag if you start moving up/down then transition to diag, but stays normal speed if you start with left/right and transition to diag.

    I have tried to exclude the other directions in the statement to isolate only directions 8 and 2, but I must not be doing it right.

    Working code that boosts vertical movement from but has problematic movement with diagonal mentioned above (in RPG_objects.jss)
    Game_CharacterBase.prototype.realMoveSpeed = function() {
    return this._moveSpeed + (this.isDashing() ? 1 : 0) + ([8,2].contains(this.direction()) ? 1 : 0);
    };

    What I've tried:

    + ([8,2].contains(this.direction()) && ([1,3,4,6,7,9].contains(!this.direction())) ? 1 : 0); disables boost completely
    + ([8,2].contains(this.direction()) && ([!1,!3,!4,!6,!7,!9].contains(this.direction())) ? 1 : 0); disables boost completely
    + ([8,2].contains(this.direction()) && (![1,3,4,6,7,9].contains(this.direction())) ? 1 : 0); boost functions, but with the same issue with diag movement

    I'm trying to make a statement that only applies this boost if moving directly up or down, so I'm just trying to exclude all other directions for the statement to be true, but I'm not sure if I'm going the right direction.
     
    #6
  7. Restart

    Restart Veteran Veteran

    Messages:
    201
    Likes Received:
    129
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't know anything about galv's diagonal movement mod. I downloaded it and gave a quick check, and it looks like he does his own speed variation for diagonal directions in .realmovespeed as well (which calls the default game version partway through).

    Code:
    Game_CharacterBase.prototype.realMoveSpeed = function() {
       var spd = Galv.DM.Game_CharacterBase_realMoveSpeed.call(this);
       return this._diagDir ? spd * Galv.DM.diagMod : spd;
    };
    
    Checking "this._diagDir" appears to tell whether or not you're moving diagonally, so should be able to filter diagonal directions out.

    If you want to overwrite Galv's, I think something like this would work

    Code:
    Game_CharacterBase.prototype.realMoveSpeed = function() {
       spd= this._moveSpeed + (this.isDashing() ? 1 : 0) + 1 * ((this._diagDir == 0)? 1 : 0) * ([8,2].contains(this.direction())? 1 : 0);
    
       return this._diagDir ? spd * Galv.DM.diagMod : spd;
    };
     
    Last edited: Aug 2, 2019
    #7
    Dustlor likes this.
  8. Dustlor

    Dustlor Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    YEEEEEEEEESSS!!!! That totally works!! Not only that, but i actually understand what I'm looking at now and why it works where it was gibberish before. I owe you a debt of gratitude.

    I was trying to check for this._diagDir as I managed to find the same thing, but didn't think to multiply them together so that if one returns 0 then, it would zero out both of them. Brilliant! I'm sure it seems like simple stuff to you, but you helped me learn a lot. I really cannot thank you enough.
     
    Last edited: Aug 3, 2019
    #8

Share This Page