Script calls for turning stepping animation on/off for a specific actor?

Discussion in 'RGSS3 Script Requests' started by Cuddlebuns, Jun 1, 2019.

Thread Status:
Not open for further replies.
  1. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    The title is self-explanatory. I've searched everywhere but can't find a script call for this. I am aware of how to do this with Move Route, but after experiencing inconsistent and unreliable results with it, I wish to use a script call instead. Perhaps a script call would prove to be more efficacious than a Move Route.

    Any help is appreciated!
     
    #1
  2. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,273
    Likes Received:
    527
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Could you elaborate a bit more what you are trying to accomplish and what happens when you trigger the walking/stepping animation on/off for actors using move route? It might sound weird but what the move route does is just changing the value of @walk_anime and @step_anime. Both are used to update characters sprites.

    Since changing those values is exactly what you would do with a script call, I think the problem lies elsewhere. Knowing more of what you are trying to achieve might help us finding a solution.
     
    #2
  3. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,455
    Likes Received:
    5,048
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    What do you mean by "specific actor" though? Do you mean followers? or events?
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,815
    Likes Received:
    11,522
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If you mean followers, I have this for MV:
    https://forums.rpgmakerweb.com/index.php?threads/actor-stepping-animation.46740/

    It's a very short plugin, and would be quite easy to convert to Ace. Anyone is welcome to do so.

    Although it's set by a note tag in the Actor's tab. You don't turn it on and off during the game. So if you want stepping animation sometimes but not others, this would not be suitable.
     
    #4
  5. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Basically, I have this common event:
    RPGVXAce_40opN7pp64.png RPGVXAce_40opN7pp642.png
    I want the stepping animation to always be ON when Flight = ON. However, if I enter and then exit the pause menu, the stepping animation stops for some reason. I have no idea how or why the pause menu has anything to do with stepping animations. I want the stepping animation to continue after exiting the pause screen.

    (Ignore the cursor, it's not pointing at anything specifically. I accidentally got it in the screenshot.)
     
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,815
    Likes Received:
    11,522
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Is it JUST the party leader? Or do you have followers, and do you sometimes want it to be the leader, but sometimes one (or more) of the followers?

    Do you want stepping animation ONLY when that switch is on? Or do you want it to be independent of the switch sometimes as well?


    Okay - try not to do it through a move route. When you change maps I know a move route on the player will be cancelled/undone (took me a while to figure out why my character who was swimming, suddenly started walking on water when they transferred to a new map). Just try a script call:
    $game_player.step_anime = true
    $game_player.step_anime = false
     
    #6
  7. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    It's JUST Actor 2. Actor 2 should have step animation on if and only if:
    - Actor 2 is the leader and the switch is on
    - Actor 2 is a follower and the switch is off

    Basically, Actor 2 walks on the ground when leading the party, flies when the switch is on, but is still shown flying by default if Actor 2 is a follower. I figured I could use a script call and a conditional branch to turn the step animation on and off when necessary because it doesn't always work with a move route.

    Also, I'm getting this error from the game interpreter when attempting to run $game_player.step_anime = true:
    Game_uj0U94ApDj.png
    I tried to make it not read-only using a similar method from another thread I posted, but it's still not working.
     

    Attached Files:

    Last edited: Jun 1, 2019
    #7
  8. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,273
    Likes Received:
    527
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Unfortunately you cannot do that as both are read-only attributes. You have to use this:
    Code:
    $game_player.instance_variable_set(:@step_anime, true) # or false
    $game_player.instance_variable_set(:@move_anime, true) # or false
    However, opening the menu should still reset that value.

    @Cuddlebuns One thing you could do is adding this to your scripts:
    Code:
    class Game_Player < Game_Character
      alias hrk_update_old_fly_anime update
      def update
        @step_anime = ($game_switches[7] && (actor == $game_actors[2]))
        hrk_update_old_fly_anime
      end
    end
    
    This sets the stepping animation to true when flight is on. You can set it to true for any vehicle as well, just use "in_boat?", "in_ship?" or "in_airship?" instead of "$game_switches[7]" (I cannot say if that flight switch is related to the airship vehicle so I listed that possibility as well).

    EDIT: as a side note, keep in mind that within the Game_CharacterBase class there is no call to step_anime as a method, it is always used as an instance variable. This makes things more annoying to deal with because a simple alias to the step_anime getter method does not work.

    This is the main reason why I changed its value before calling the update method, even so, if you change any of the methods called in the original update method so that they change that value, that one is not guaranteed to work either.

    If none of those methods has access to that variable, this one should do the trick.

    I completely missed this part. Followers automatically copy the stepping animation of the first party member ($game_player). On top of it, the update method for followers does that before calling the update method of the parent class. This means that you cannot solve that with just the code above when actor 2 is not the leader. You need something different.
    Code:
    class Game_Follower < Game_Character
      def update
        @move_speed     = $game_player.real_move_speed
        @transparent    = $game_player.transparent
        @walk_anime     = $game_player.walk_anime
        if $game_switches[7]
          @step_anime     = $game_player.step_anime
        else
          @step_anime = (actor == $game_actors[2])
        end
        @direction_fix  = $game_player.direction_fix
        @opacity        = $game_player.opacity
        @blend_type     = $game_player.blend_type
        super
      end
    end
    
    This might cause compatibility issues if you have other methods that change how the follower update method works. Be sure to place this last one above any other script that changes that.
     
    Last edited: Jun 2, 2019
    #8
    Shaz likes this.
  9. Shaz

    Shaz Veteran Veteran

    Messages:
    37,815
    Likes Received:
    11,522
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I completely missed that! Getting rusty with Ace :(
     
    #9
  10. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,273
    Likes Received:
    527
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    @Shaz well, as far as I know it has been quite a few years since you moved to MV, nobody would remember every little detail about Ace after not using it for such a long time, no need to worry.

    @Cuddlebuns I take this chance to notify you that I made a small change in the code I provided. It is hardly noticeable, but it is there. If you already copied it, be sure to use the new one instead.
     
    #10
  11. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,687
    Likes Received:
    4,162
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #11
Thread Status:
Not open for further replies.

Share This Page