RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Strafe Script Snippet

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
Strafe Script Snippet
Author: Xzygon
Release Date: 12/20/10




Introduction
Hey, I'm Xzygon, and this is my first released Script Snippet. Basically, what this does, is, while you're holding down a certain
key, you "strafe", or move without changing directions. It was made mainly for ABS systems, so you could move back and forth around
a certain monster or run away while attacking.


Features
-Strafe.


Script
Code: [Select]
#===============================================================================
# [VX] Strafing Script Snippet
# Plug & Play
#-------------------------------------------------------------------------------
# by Xzygon [hisserdelema@hotmail.com]
# Credit: Vladislaus, for his VTP script, which I based this off of,
# and for his weapon strafing which will eventually be released.
#-------------------------------------------------------------------------------
# Basically, what this snippet does, is if you hold down a specific button,
# You can "strafe", or move without changing directions.
# Used best with ABS systems and ranged skills or weapons.
#-------------------------------------------------------------------------------
# This is practically my first snippet, so sorry if it's not compatible
# with other scripts. (It should be compatible with most)
#-------------------------------------------------------------------------------
# If you're going to use this, credit is not necessary, but it'd be nice.
# And yes, I know this section is longer than the actual snippet, but it's
# not actually used in gameplay, so it's fine.
#===============================================================================


Strafe_Key = Input::Z #Change this to whatever button you want to strafe.


class Game_Player < Game_Character
 
  alias xzy_move move_by_input
  def move_by_input
      if @actor != nil and (Input.press?(Strafe_Key))
      @old_dir_fix = @direction_fix if @old_dir_fix == nil
      @direction_fix = true
      else
      @direction_fix = @old_dir_fix if @old_dir_fix != nil
      @old_dir_fix = nil
    end
    xzy_move
  end
end


Customization
Change the button on line 22 to what button you want to press to strafe.


Compatibility
Should be compatible with most scripts.


Screenshot
Can't exactly take a screenshot of this.


Installation
Just Plug & Play. If you have an ABS system, such as VTP, put this script above.
Also, if you're planning


FAQ
Q: ZOMG IZ NOT WORKING!!@!?!
A: I can't exactly help you if you don't call down and give me more info.


Q: I'm using it with VTP or another battle system, but it's not working!
A: Put this script above VTP or other battle system, but below the Kernal/Keyboard. If that doesn't work, I don't know at this time.


Q: Wait, I have another question!
A: Just ask me below, or PM me.

Q: Can't you just event this?
A: Probably.


Terms and Conditions
Credits would be nice, but are not necessary.

Credits
-Xzygon
-Vladislaus, for his VTP script, which I based this off of.
« Last Edit: December 22, 2010, 03:48:51 PM by Xzygon »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Not bad, but you should probably link to the Keyboard script you are using, as your default setting for the key is: Keys::SPACE and that will not work without whatever script you are relying on. I would suggest changing it to something like Input::SHIFT as a default, and linking to a Keyboard script if they want to use other keys not normally accessible.

Secondly, why do you check if @actor is nil?

Thirdly, I'm not sure that the @old_dir_fix variable is doing what you want it to do. What it does is save the direction fix the very first time that the player moves (which will almost always be true unless the very first cutscene of the game turns it OFF). However, because you reset it back to that every time the player is not pressing the Strafe Key, it will mean that the user can never actually turn direction fix off for the player anymore. It would be rare, of course, that they would ever want to though.

Anyway, those are all minor; great job on this script! :)

**
Rep:
Level 82
I changed the first problem, originally, since I wasn't thinking hard on it, I used the Keyboard script because all of the keys that are originally used were used up in VTP, and didn't realize I could just change it back to the regular Input::Key in the script.

Second, originally, it wouldn't work for whatever reason if I didn't have that it. It works fine without it in now, but myeh.

And third, in some of my events (I'm not sure specifically which, since a lot of my events are parallel, it wouldn't work without it.) I've now removed it above, but if anyone needs it, they can just ask me.

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
2014 Queen of RMRKProject of the Year 20142014 Best RPG Maker User - Story2011 Best Newbie2014 Kindest Member2014 Best RPG Maker User - Creativity2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
Congrats on your first script :) it looks pretty good.
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, well, it's good to have it - it just wasn't good to freeze it.

I haven't looked at move_by_input, so I am relying on your original structure, but something like the following would be good:

Code: [Select]
  alias xzy_move move_by_input
  def move_by_input
   if Input.press? (Strafe_Key)
      @old_dir_fix = @direction_fix if !@old_dir_fix
      @direction_fix = true
    elsif @old_dir_fix
      @direction_fix = @old_dir_fix
      @old_dir_fix = nil
   end
   xzy_move
  end

I only disliked the original because it never reset @old_dir_fix to nil, which meant that once it was defined, it was never redefined. Because of that, @direction_fix was set to @old_dir_fix everytime move_by_input was called and not pressing Strafe, which meant the user could never effectively change the direction fix of the player under any circumstances when relying on player input.

The idea itself, to reset @direction_fix to normal everytime not pressing strafing, is good.

**
Rep:
Level 82
Oh, okay, I see what you mean now. I'll fix it now, thanks :)