[RPG MAKER MV] Mario Brothers Super Star Plug-in | dismal_science__

dismal_science__

following the development of my first game, using rpg maker mv.

 

 

One of the most exhilarating feelings I remember having as a child picking up a controller, running through the first level of Super Mario, hitting a brick block that releases a hidden Super Star, and using the shit out of that star far as I can go before the invincibility effect runs out.

 

The game that I am currently working on abandons RPG Maker MV's turn-based battle system in favor of an ABS.

 

Because everything basically happens on-map, it is important for me to consider different mechanics that I can implement to enhance the gameplay ... and imitating the Super Stars seems like a good place to start.

 

Using the knowledge that was kicked to me by Caethyril during the creation of zHUD, I embarked on writing a second plug-in myself.

 

At it's very basic, the Super Star gives the Player a 10-second burst where:

  • the Sprite Image flashes rapidly
  • the Player moves quicker
  • the Player is invincible
  • Anything the Player touches is killed
 
Animation
Originally, I thought about having a separate sprite sheet of the character, glowing psychedelically in Super Star mode, which the plug-in would switch to while the Super Star effect was in use.
 
Unfortunately, because the ABS plug-in I am using the filename of the character sprite to extend the animations and display different images for attacking, damage, etc. This first method would probably throw an error.
 
While working on a faux collision handler which I implemented early in the project,  I came across RMMV's Show Animation command. 
 
Show animation is particularly powerful because it allows you to automatically link where the animation will be played on the screen on an event, or in my case, the players themselves.
 
Using the RMMV Script Calls spreadsheet , I was able to find that JavaScript equivalent of Show Animation is $gamePlayer.requestAnimation().
 
I just created a 10 frame animation, with a flash of different color occurring on every odd frame.
 
After that was done, I added the first function to my script:
 
    $ .fANI = function () {
        $ gamePlayer.requestAnimation ($. xAnimation);
    };
 
$ .xAnimation is a parameter that can be set from the plug-in settings that specify the animation to be used during Super Star mode.
 
This function will call that specific animation and play it at the same position that the player sprite is located.
 
 
Speed
With Animation taken care of, it was time to work on getting player speed to increase during Super Star mode.
 
The RMMV Script Calls Spreadsheet does not seem to have an equivalent for Set Movement Route: Player / Speed command listed, so I take it to RPG Maker Web Forums and asked for help.
 
Traverse from the RPG Maker Web Forum pointed me in the direction of  $gamePlayer.setMoveSpeed(). Which provided me with the information to write a second function.
 
    $.fSPEED = function() {

        if ($.xNormalSpeed ​​=== undefined) $.xNormalSpeed ​​= $gamePlayer._moveSpeed;

        if ($gameSwitches.value($.xSwitch) == true) {            
        
            var xSPEED = Math.floor( ($.xNormalSpeed) * 1.5);        
            if (xSPEED> = 8) xSPEED = 8;                    
        
        } else {
        
            var xSPEED = $.xNormalSpeed;    
        };        
        
        $gamePlayer.setMoveSpeed(xSPEED);
    };
 
$.fSPEED() knows what to perform based on a Game Switch specified in the plug-in settings ($.xSwitch). The function remembers the "normal" speed by storing it in the $.xNormalSpeed variable, and then determine the Super Star speed by multiply said normal speed by 1.5- the speed is capped at 8, the highest value.
 
Now that I had both my Animation and Speed ​​functions, it was time to put them into a routine that would apply to the player for a set amount of time.
 
I employed an old trick that I used in zHUD for the beeping low HP indicator, which is creating an Interval Timer.
 
    $.fSTAR = function() {
        
        $gameSwitches.setValue($.xSwitch, true);
        $.fSPEED();
        
        if ($.starInterval === undefined) {
            $.starInterval = setInterval(function() {
                $.fANI();
            }, $.xStarPulse);
        };
    };
 
There are several things going on in this function- the first, is $.xSwitch being set to true, to give an indication to the external procedures that Super Star mode is enabled.
 
I put these two commands outside of the timer because the timer executes specified commands at an interval set by the user again and again until commanded to stop. The interval here is a variable $.xStarPulse, which I set at the beginning of the script. The only command that needs to be executed again and again is the animation function because it should repeat until Super Star mode is turned off.
 
To do this, I created another function that stops and deletes the interval timer:
 
    $.fSTOP = function () {
        if ($.starInterval ! = undefined) {

            clearInterval (this.starInterval);
            delete this.starInterval;

            $gameSwitches.setValue($.xSwitch, false);
            
            $ .fSPEED();
        };
    };
 
Before the stop function executes, it runs a check to see that the timer it is a mean to stop and delete actually exists (to avoid any errors)- if so, the timer is deleted, $.xSwitch is turned off, and the speed is restored to normal.
 
Both these functions get executed in a main function, which will be the one that is called during gameplay to begin the Super Star effect:
 
    $.simula = function() {
        if ($.starInterval === undefined) {
            $.fSTAR ();
            setTimeout (function(){$.fSTOP();}, $.xDuration);
        };
    };
 
Here, it is another variable ($.xDuration) from the parameters in the plugin settings. The $.fSTOP function is put into a second timer, this is a Timeout that will execute after a specified amount of time.
 
Invincibility
In the first few iterations of the script, I MacGyver'ed a function to "freeze" the player's HP that was being called by the interval timer:
 
    $.fRHP = function() {
        if ($.xHPFreeze != undefined) {
            var cActorHP = $gameActors.actor($.xActorID);
            if (cActorHP.hp < $.xHPFreeze) {
                var xHP = ($.xHPFreeze - cActorHP.hp);
                cActorHP.gainHp (xHP);
            };
        };    
    };
 
When this function was being used, $.xHPFreeze was set in the $.fSTAR function to equal $ gameActors.actor ($.xActorID) .hp (the Player's HP at the time when Super Star effect was enabled).  $.fRHP continuously checks the Player's current HP against $.xHPFreeze and gives them back any HP that they might lose while Super Star is in effect.
 
It was working by curing the player when they lost HP, but it would be more efficient to just turn off all damage for them at the source.
 
Wavelength (also of the RPG Maker Web forum) identified this source to be Game_Action.prototype.executeHpDamage(), and suggested:
 
Have it checked for when the fighter's HP should be frozen (you could do with a database state, or by adding a new property to battles in code), and if so, either, the method early or have it skip the "target. gainHp (-value); "line.
 
Taking his guidance, I was able to mash out:
 
    var execHpDamage = Game_Action.prototype.executeHpDamage;

    Game_Action.prototype.executeHpDamage = function (target, value) {
        
        // if (target._HpFrozen = false) {
         if (! ($gameSwitches.value ($.xSwitch) === true && target === $gameActors.actor($.xActorID)) {
            execHpDamage.call (this, target, value);
            //};
        };
    
    };
 
This is a modification to the function, allows the damage to occur only if the two conditions are met- $.xSwitch is false (meaning Super Star effect is off), and the target is not the player using the Super Star effect.
 
I will try and implement a database state or add a new property to battles in code, but I may try to implement this suggestion when I have a better explanation of isStateAffected() and Game_Battler.prototype.initMembers.
 

 

"Anything I touch, I bruise"
Another thing that I have failed to implement is the player's ability to cause damage just but touching an enemy.
 
I will have to examine the ABS and see how it treats contact between the players and events, and perhaps extend the plug-in in a later update.
 
For now, here's bituin.js, named after the Tagalog word for star.