Ready to Rumble: A Plugin for Controller Vibration

Discussion in 'JS Plugin Releases (RMMV)' started by BreakerZero, Jul 20, 2019.

  1. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Ready to Rumble version 1.0
    Created by BreakerZero with consultation from OS87
    Free for both commercial and non-commercial use, with credit.

    About the plugin
    A lot of games these days offer a rumble mode that activates in response to certain game events (an explosion set off during a major plot twist, getting knocked out during a fight, or simply taking a hard fall to the ground) and this plugin has been designed to bring that experience to RPG Maker MV.

    A few special requirements before we begin: There's no guarantee the launcher that ships with MV will have the necessary functions that allow the plugin to work, so as a precaution on this you'll want to download the latest version of NWJS, back up the default launcher that ships with MV and patch it over with the NWJS packages. The SDK version should go in your MV install, the redistributable goes in your exported game package. Again, there's no guarantee that the NWJS package shipped with MV has the necessary functions that allow the plugin to work, not to mention that MV ships with the x86 version which is functionally inadequate by modern game development standards. (Don't worry about the prospect of problems - as long as your install and project are 1.6.x or newer the official NWJS redistributable and the MV launcher are completely interchangeable. But again, you should back up the default launcher files in case something else happens.)

    Instructions for patching the MV launcher:
    http://bit.ly/2Zaahxb
    Download the latest NWJS redistributable:
    http://bit.ly/2XNqNGu

    Using the plugin
    To activate the rumble feature in a given event or scene, use the following script call:

    Code:
    Rumble(strong,weak,time)
    Strong is the maximum velocity of the effect's magnitude.
    Weak is the exact opposite: the weak end of the effect.
    Time is defined in milliseconds, so 1000::1 and 5000 is 5 seconds. (Get it?)
    Note that neither weak nor strong can go over 1.0, and that magnitude values of 0.1 are completely ignored (and for obvious reasons). Also, the values for weak and strong can be reversed and still work properly.

    For example:
    Code:
    Rumble(1,1,1000)
    Rumble(0.4,0.2,500)
    Rumble(0.3,0.6,5000)
    Release history:
    v1.0: Initial RTM
    v1.0.1: Unanticipated bugfix
    v1.0.2: Added control switch assignment to change rumble mode status
    v1.0.3: Small change to accommodate the possibility of a crash when a gamepad is disconnected. Also set the maximum supported values to eliminate possibility of the effect not working if set too high or too low.
    v1.0.4: Replaces control switch with option menu function, and directs the effect to the most recenty-used gamepad. A very special thanks to YoraeRasante for this update.
    v1.0.5: Added verification to detect the availability of a supported gamepad. As of this update, the functions will not be available if gamepad detection fails.

    Download Now

    Or use the attached version.
     

    Attached Files:

    Last edited: Aug 4, 2019
    #1
  2. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,379
    Likes Received:
    3,654
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Looks like a really cool feature!

    Do you want designers who use this to credit both yourself and OS87 in their credits?
     
    #2
  3. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Unfair not to.
     
    #3
  4. JohnOminae

    JohnOminae Villager Member

    Messages:
    28
    Likes Received:
    15
    Location:
    [Redacted]
    First Language:
    English
    Primarily Uses:
    RMMV
    THANK YOU BreakerZero! I was literally trying to get this commissioned for the longest time.
    Seriously, thank you very much!
     
    #4
  5. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    v1.0.1 out, please update if you're having issues. I encountered a few undetected irregularities that require a bugfix release.
     
    #5
  6. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,183
    Likes Received:
    254
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Can I make a suggestion?
    Adding the option for the player to turn it on or off in the options menu.
    Because some people may not want it activated at some times.
     
    #6
  7. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Already on the roadmap. Thing is that this is literally my first submission of this kind, so anything that involved is something I'll have to properly analyze first.

    EDIT: I now have a baseline set for the switch function. It's a bit bare for now and you'll have to do some extra work to make a persistent status out of it (file system entries combined with a simple yes/no are the easiest option, and I'm adding a parameter to read the state off a control switch) but I have started to build this out in version 1.0.2 which is set for release later today. EDIT 2: it's up!

    EDIT 3: Obviously a global switch plugin may also work for this if you set the same switch for both purposes. Forgot to mention that earlier in case the file system method is not viable or functional.
     
    Last edited: Jul 25, 2019
    #7
    JohnOminae likes this.
  8. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    1.0.3 is out. I was recently alerted to the possibility of a crash if a gamepad is disconnected during or prior to gameplay which I have addressed in addition to refinements that should hopefully prevent the use of values outside accepted range (such that any excess defaults to supported values instead of being ignored completely).
     
    #8
  9. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,183
    Likes Received:
    254
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Hey BreakerZero, I don't understand, why is 0.1 the minimum? I mean, I understand it having to be higher than 0, but why 0.05 isn't acceptable for example?
     
    #9
  10. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Actually, the minimum is 0.2 as 0.1 doesn't do anything. I'm also enforcing a maximum time limit of 5000 milliseconds for the same reason.
     
    #10
  11. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,183
    Likes Received:
    254
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    @BreakerZero I hope you don't mind, I made an edit of your code... Your actual code is almost intact, though.

    I mainly did two things: one, I aded the option of rumble in the Options menu, so I removed your switch.
    It just makes more sense, and as you said you just didn't add it because you didn't know how...

    And two, I added a check to see which gamepad was the last one used, save its index, and that is the one that will rumble.
    I had to do it because... in your original code the gamepad to rumble is gamepad index 0. I use Switch Joycons as a gamepad through vjoy and a driver by fosse. That means my controller, the actual one with rumble working, is usually, but not always, index 3.
    With my change the gamepad will be detected and saved every time a button is pressed or an analog stick moved, its index will be saved, and it is that index that will be used for the rumble.

    Hope you don't mind. I added a few comments in case you want to see how I did it, but to be honest the options thing I learned from a couple Yanfly plugins anyway :p

    https://www.dropbox.com/s/oczgocibg75mtwk/ReadyToRumble.js?dl=0

    [EDIT] Oh by the way, I removed the bZero.PlayTime object. I have no idea why it is there in your code, since it is never used...
     
    #11
  12. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    @Waterguy that was for development purposes which I ended up not having to use. As for the contribution, I will patch over to a new release later this morning.

    EDIT: It's up! The option access change has been patched to official release bringing the version to 1.0.4. If you were using the control switch method from before it has been removed to allow for the updated control mechanism so update your projects accordingly.

    EDIT 2: Change of plans. Temporary rollback initiated due to an unanticipated technical issue with the update.

    EDIT 3: Reuploaded with a change to access detection so that it doesn't trigger when entering the options menu pending further analysis. In the event that detection is resolved this will be restored in a future version.
     
    Last edited: Jul 29, 2019
    #12
  13. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,183
    Likes Received:
    254
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Sorry, I forgot to add a function on the plugin. It didn't give an error to me because I already had it in another one.
    Sorry for the mistake, hopefully it'll work fine now

    The link I posted earlier should already point to a fixed version. You removed the problem function calls from yours so it's no problem anyway, but just to explain to people it was a function that is in the GamepadConfig plugin that is for free in the rpg makers dlc folder. It is just there to only shows the option if there is a gamepad connected.
     
    Last edited: Jul 31, 2019
    #13
  14. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Didn't have a chance to mention earlier, but 1.0.5 is up. This release includes the auto-detection mechanism and the latest contributions to the plugin structure.
     
    #14
  15. BreakerZero

    BreakerZero Veteran Veteran

    Messages:
    568
    Likes Received:
    242
    First Language:
    English (USA)
    Primarily Uses:
    RMMV
    Small update. I've added the plugin as an attachment in the event that issues should ever arise from the mirror download.
     
    #15

Share This Page