Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hi Guys

Is there a way to increase balloon icons in MV? I saw self.balloon_id = 11 in VX ace. I wonder if someone figured out how to do in MV

Thanks guys
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
If you go into the img/system directory, there's a Balloon.png file. By default, there are 10 balloons, in rows that are 48 pixels high and 384 pixels wide (so 8 "icons" that are 48x48 that are shown in succession).

You can use the Game_CharacterBase.prototype.requestBalloon function to pass in the Id of a balloon and it will simply multiply the Id by 48 to get the y coordinate to determine where in that file to draw sprites from. The actual file has no maximum height to it, you can make it as large as you want, the code just takes your Id to figure out what "row" to draw.

So, as an example, I copy/pasted the first row and added it just below the last row, then did some hue change to turn the exclamation mark blue instead of red, then called:
Code:
$gamePlayer.requestBalloon(11);

And got the following:
balloon-example.PNG
 

Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
If you go into the img/system directory, there's a Balloon.png file. By default, there are 10 balloons, in rows that are 48 pixels high and 384 pixels wide (so 8 "icons" that are 48x48 that are shown in succession).

You can use the Game_CharacterBase.prototype.requestBalloon function to pass in the Id of a balloon and it will simply multiply the Id by 48 to get the y coordinate to determine where in that file to draw sprites from. The actual file has no maximum height to it, you can make it as large as you want, the code just takes your Id to figure out what "row" to draw.

So, as an example, I copy/pasted the first row and added it just below the last row, then did some hue change to turn the exclamation mark blue instead of red, then called:
Code:
$gamePlayer.requestBalloon(11);

And got the following:
View attachment 192955

Thank you. Few things.

Can we use script calls to control the time of display ? (e.g., I want to display 360 sec)

How can I call balloon with event ID ? (not player)
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
To call a Balloon with an Event ID, you can use:
Code:
$gameMap._events[eventId].requestBalloon(balloonId);

// example: $gameMap._events[1].requestBalloon(11);

Time might be a little trickier. The speed that a balloon loops through each frame and the duration of the total animation is hardcoded, in rpg_sprites.js, lines 1858 - 1887:
Code:
Sprite_Balloon.prototype.setup = function(balloonId) {
    this._balloonId = balloonId;
    this._duration = 8 * this.speed() + this.waitTime();
};

Sprite_Balloon.prototype.update = function() {
    Sprite_Base.prototype.update.call(this);
    if (this._duration > 0) {
        this._duration--;
        if (this._duration > 0) {
            this.updateFrame();
        }
    }
};

Sprite_Balloon.prototype.updateFrame = function() {
    var w = 48;
    var h = 48;
    var sx = this.frameIndex() * w;
    var sy = (this._balloonId - 1) * h;
    this.setFrame(sx, sy, w, h);
};

Sprite_Balloon.prototype.speed = function() {
    return 8;
};

Sprite_Balloon.prototype.waitTime = function() {
    return 12;
};

Notice that speed and waitTime are just set to 8 and 12 for every balloon, then those values are referenced while processing the event loop updates for balloons.

There are a handful of ways to go about modifying that value. Without knowing exactly what you're doing, one idea would be to change them to be variables instead. So you could add this small Plugin that would overwrite the speed and waitTime functions, replacing x and y with some game variable that you set aside specifically for this purpose:
Code:
(function() {
    Sprite_Balloon.prototype.speed = function() {
        return $gameVariables.value(x) || 8;
    };
    
    Sprite_Balloon.prototype.waitTime = function() {
        return $gameVariables.value(y) || 12;
    };
})();

Since the default value of a variable is 0, if you haven't set one, then the original value of 8 will be used for speed and 12 for waitTime. However, if I said that variable 1 is speed and variable 2 is waitTime, then I could do something like:

Common Event: Reset Balloon Times
  • Control Variables: #0001 speed = 0
  • Control Variables: #0002 waitTime = 0
Some Controller Event On Some Map
  • Control Variables: #0001 speed = 16
  • Control Variables: #0002 waitTime = 36
  • Script: $gameMap._events[1].requestBalloon(11)
  • Common Event: Reset Balloon Times
And then when I call requestBalloon, the speed and waitTime will be what I've set in my variables, after which I reset them back to their defaults.
 

Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
To call a Balloon with an Event ID, you can use:
Code:
$gameMap._events[eventId].requestBalloon(balloonId);

// example: $gameMap._events[1].requestBalloon(11);

Time might be a little trickier. The speed that a balloon loops through each frame and the duration of the total animation is hardcoded, in rpg_sprites.js, lines 1858 - 1887:
Code:
Sprite_Balloon.prototype.setup = function(balloonId) {
    this._balloonId = balloonId;
    this._duration = 8 * this.speed() + this.waitTime();
};

Sprite_Balloon.prototype.update = function() {
    Sprite_Base.prototype.update.call(this);
    if (this._duration > 0) {
        this._duration--;
        if (this._duration > 0) {
            this.updateFrame();
        }
    }
};

Sprite_Balloon.prototype.updateFrame = function() {
    var w = 48;
    var h = 48;
    var sx = this.frameIndex() * w;
    var sy = (this._balloonId - 1) * h;
    this.setFrame(sx, sy, w, h);
};

Sprite_Balloon.prototype.speed = function() {
    return 8;
};

Sprite_Balloon.prototype.waitTime = function() {
    return 12;
};

Notice that speed and waitTime are just set to 8 and 12 for every balloon, then those values are referenced while processing the event loop updates for balloons.

There are a handful of ways to go about modifying that value. Without knowing exactly what you're doing, one idea would be to change them to be variables instead. So you could add this small Plugin that would overwrite the speed and waitTime functions, replacing x and y with some game variable that you set aside specifically for this purpose:
Code:
(function() {
    Sprite_Balloon.prototype.speed = function() {
        return $gameVariables.value(x) || 8;
    };
  
    Sprite_Balloon.prototype.waitTime = function() {
        return $gameVariables.value(y) || 12;
    };
})();

Since the default value of a variable is 0, if you haven't set one, then the original value of 8 will be used for speed and 12 for waitTime. However, if I said that variable 1 is speed and variable 2 is waitTime, then I could do something like:

Common Event: Reset Balloon Times
  • Control Variables: #0001 speed = 0
  • Control Variables: #0002 waitTime = 0
Some Controller Event On Some Map
  • Control Variables: #0001 speed = 16
  • Control Variables: #0002 waitTime = 36
  • Script: $gameMap._events[1].requestBalloon(11)
  • Common Event: Reset Balloon Times
And then when I call requestBalloon, the speed and waitTime will be what I've set in my variables, after which I reset them back to their defaults.

How about make a balloon wait until completion with a script call?​


I saw this script for VX ACE. Fiber.yield while $game_map.events[$game_variables[571]].balloon_id > 0

How can we call wait til completion in MV?
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
I suppose you could make a loop that breaks along the same lines:

Loop:
Conditional Branch: Script: !$gameMap._events[eventId].balloonId
Break Loop
End
Wait 60 frames
End

What that will do is enter a loop that executes every second and checks if the character for that event has a balloonId or not (or if the balloonId is 0). If it doesn't, it'll break the loop. If it does, it'll run the loop again.

I'm not at my home computer to open it up and try it myself, though. It might be _balloonId instead of balloonId or there may be some slight change in syntax necessary. I can check later.
 

Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
Loop does not seem to work. Would be great if you could help me once you get a chance
I suppose you could make a loop that breaks along the same lines:

Loop:
Conditional Branch: Script: !$gameMap._events[eventId].balloonId
Break Loop
End
Wait 60 frames
End

What that will do is enter a loop that executes every second and checks if the character for that event has a balloonId or not (or if the balloonId is 0). If it doesn't, it'll break the loop. If it does, it'll run the loop again.

I'm not at my home computer to open it up and try it myself, though. It might be _balloonId instead of balloonId or there may be some slight change in syntax necessary. I can check later.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
It might be easier to just directly call the function that Show Balloon ultimately calls, setting up the parameters beforehand, calling something like the following in a Script call in your event:
Code:
$gameMap._interpreter._params = [eventId, balloonId, true];
$gameMap._interpreter.command213();

If you want the balloon on the player, set eventId to -1.
balloonId would be which row on the balloon.png you want to show.
If you want to wait for the balloon animation to finish, the third parameter should be true. Otherwise, it should be false.
 

Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
It might be easier to just directly call the function that Show Balloon ultimately calls, setting up the parameters beforehand, calling something like the following in a Script call in your event:
Code:
$gameMap._interpreter._params = [eventId, balloonId, true];
$gameMap._interpreter.command213();

If you want the balloon on the player, set eventId to -1.
balloonId would be which row on the balloon.png you want to show.
If you want to wait for the balloon animation to finish, the third parameter should be true. Otherwise, it should be false.
Actually, after I called this script

$gameMap._interpreter._params = [24, 1, true];

$gameMap._interpreter.command213();

The system runs balloon animation once and cannot exit. I tried self switch but did not work. Is there a way to exit from this code/event? Ideally, I prefer balloon to run parallel
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
I didn't have that experience - but at this point, I think it's more important to ask what exactly you're trying to do. I'm giving solutions based on a sort of vague sense of what you're asking for and it sounds like this timing issue is a lot more specific.

So - what are you ultimately trying to accomplish, with as much detail as possible?
 

Charles2020

Veteran
Veteran
Joined
Feb 24, 2020
Messages
131
Reaction score
5
First Language
English
Primarily Uses
RMMV
I didn't have that experience - but at this point, I think it's more important to ask what exactly you're trying to do. I'm giving solutions based on a sort of vague sense of what you're asking for and it sounds like this timing issue is a lot more specific.

So - what are you ultimately trying to accomplish, with as much detail as possible?
SO basically I wanted to have a balloon icon on NPCs using pallarell process. so they can display on NPCs all the time.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
668
Reaction score
382
First Language
English
Primarily Uses
RMMV
If you want a balloon animation to continually run in a loop, you'll have to tap into the update event loop that the Sprite uses in some form or fashion.

The actual Sprite_Balloon that gets constructed has no knowledge of where it's being loaded, though. Its knowledge of its x and y coordinates comes from the parent Sprite_Character that's attached to an event on the map (or the player or follower).

So, you could add a small Plugin to modify the Sprite_Character.prototype.updateBalloon function (be aware that this overwrites the original function, so could have compatibility conflicts with other Plugins that try to modify the updateBalloon method):
Code:
(function() {
    Sprite_Character.prototype.updateBalloon = function() {
        this.setupBalloon();
        if (this._balloonSprite) {
            this._balloonSprite.x = this.x;
            this._balloonSprite.y = this.y - this.height;
            if (this._character._isInfiniteBalloon) {
                if (this._balloonSprite._duration === 1) {
                    this._character._balloonId = this._balloonSprite._balloonId;
                    this.setupBalloon();
                }
            } else if (!this._balloonSprite.isPlaying()) {
                this.endBalloon();
            }
        }
    };
})();

Then have an event with a script call like:
Code:
var character = $gameMap._events[1];
character._isInfiniteBalloon = true;
character.requestBalloon(1);

And when you want the balloon to stop looping its animation:
Code:
$gameMap._events[1]._isInfiniteBalloon = false;

What the Plugin does is uses the original updateBalloon method, but adds that new subsection of the conditional where this._character._isInfiniteBalloon is true. So, if you set a property called _isInfiniteBalloon on a Game_Character (an event or the player on the map) to true, then when the updateBalloon method is called every frame and its duration is decreased, when it gets to the end of its duration, instead of calling endBalloon (which would delete the sprite off the object), it sets up the balloon with the setupBalloon method again, using the same Id that it's already been using. The setup method will restart the duration and ultimately redraw the balloon sprite.
 

Latest Threads

Latest Posts

Latest Profile Posts

uglywolf wrote on Khulse's profile.
Hello.
The rules I makes pun about on your last thread is about "Verify Files" before anything else, if the stuff comes from STEAM. Which means, if it could be fixed with just that, there is no need to redownload the whole stuff.
But glad the reinstall worked, hope you enjoy it and your days too.
uh oh, I just tapped into a fresh, deep vein of nightmare fuel right here guys:
51F2AC5E-A605-446E-9439-D77AA6A0B0ED.pngAdded console to my content thread here
Sweet nostalgia. My fave Final Fantasy game.

Forum statistics

Threads
115,429
Messages
1,089,785
Members
150,185
Latest member
DarkPurplePrince
Top