Help with swapping bitmaps

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
So I have no Idea at all how the game engine goes about something

Basically, how it goes about loading images is a whole batch of functions that vary little between eachother.

Here is the function that controls how events and all that are loaded in graphics wise;
JavaScript:
ImageManager.loadCharacter = function(filename, hue) {
    return this.loadBitmap('img/characters/', filename, hue, false);
};
I havent been able to figure out how the engine gets to this point, i have gotten so far as here;

JavaScript:
Sprite_Character.prototype.setCharacterBitmap = function() {
    this.bitmap = ImageManager.loadCharacter(this._characterName);
    this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};
what i need is to find the function that first sets ._characterName, where Sprite_Character gets this information from so i can copy down some variables so i can swap the bitmap its trying to load with the one i am trying to load. simply put, i need the event that the instance of Sprite_Character is from so i can get some information about it. (and also with followers, party leader, and vehicles.)

But i have hit a brick wall in this search as i havent found it and honestly it's far different than how things like icons and whatnot are handled.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
710
Reaction score
241
First Language
Javascript
Primarily Uses
RMMV
like maybe one of these?

In "rpg_objects.js"
Starting Line 6660:
Code:
Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
};
Starting Line 3515:
Code:
Game_Actor.prototype.initImages = function() {
    var actor = this.actor();
    this._characterName = actor.characterName;
    this._characterIndex = actor.characterIndex;
    this._faceName = actor.faceName;
    this._faceIndex = actor.faceIndex;
    this._battlerName = actor.battlerName;
};
Starting Line 3981:
Code:
Game_Actor.prototype.setCharacterImage = function(characterName, characterIndex) {
    this._characterName = characterName;
    this._characterIndex = characterIndex;
};
Starting Line 8678:
Code:
Game_Event.prototype.setupPageSettings = function() {
    var page = this.page();
    var image = page.image;
    if (image.tileId > 0) {
        this.setTileImage(image.tileId);
    } else {
        this.setImage(image.characterName, image.characterIndex);
    }
    if (this._originalDirection !== image.direction) {
        this._originalDirection = image.direction;
        this._prelockDirection = 0;
        this.setDirectionFix(false);
        this.setDirection(image.direction);
    }
    if (this._originalPattern !== image.pattern) {
        this._originalPattern = image.pattern;
        this.setPattern(image.pattern);
    }
    this.setMoveSpeed(page.moveSpeed);
    this.setMoveFrequency(page.moveFrequency);
    this.setPriorityType(page.priorityType);
    this.setWalkAnime(page.walkAnime);
    this.setStepAnime(page.stepAnime);
    this.setDirectionFix(page.directionFix);
    this.setThrough(page.through);
    this.setMoveRoute(page.moveRoute);
    this._moveType = page.moveType;
    this._trigger = page.trigger;
    if (this._trigger === 4) {
        this._interpreter = new Game_Interpreter();
    } else {
        this._interpreter = null;
    }
};
Starting Line 8256:
Code:
Game_Vehicle.prototype.loadSystemSettings = function() {
    var vehicle = this.vehicle();
    this._mapId = vehicle.startMapId;
    this.setPosition(vehicle.startX, vehicle.startY);
    this.setImage(vehicle.characterName, vehicle.characterIndex);
};
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
Sorry, I don't quite understand what you are looking for? Are you looking for where the characters on the map are initialized? If so, almost all of the sprites on the map are handled by the Spriteset_Map object (easier to control stuff across all sprites, like zoom for instance):

Code:
Spriteset_Map.prototype.createCharacters = function() {
    this._characterSprites = [];
    $gameMap.events().forEach(function(event) {
        this._characterSprites.push(new Sprite_Character(event));
    }, this);
    $gameMap.vehicles().forEach(function(vehicle) {
        this._characterSprites.push(new Sprite_Character(vehicle));
    }, this);
    $gamePlayer.followers().reverseEach(function(follower) {
        this._characterSprites.push(new Sprite_Character(follower));
    }, this);
    this._characterSprites.push(new Sprite_Character($gamePlayer));
    for (var i = 0; i < this._characterSprites.length; i++) {
        this._tilemap.addChild(this._characterSprites[i]);
    }
};
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
like maybe one of these?

In "rpg_objects.js"
Starting Line 6660:
Code:
Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
};
Starting Line 3515:
Code:
Game_Actor.prototype.initImages = function() {
    var actor = this.actor();
    this._characterName = actor.characterName;
    this._characterIndex = actor.characterIndex;
    this._faceName = actor.faceName;
    this._faceIndex = actor.faceIndex;
    this._battlerName = actor.battlerName;
};
Starting Line 3981:
Code:
Game_Actor.prototype.setCharacterImage = function(characterName, characterIndex) {
    this._characterName = characterName;
    this._characterIndex = characterIndex;
};
Starting Line 8678:
Code:
Game_Event.prototype.setupPageSettings = function() {
    var page = this.page();
    var image = page.image;
    if (image.tileId > 0) {
        this.setTileImage(image.tileId);
    } else {
        this.setImage(image.characterName, image.characterIndex);
    }
    if (this._originalDirection !== image.direction) {
        this._originalDirection = image.direction;
        this._prelockDirection = 0;
        this.setDirectionFix(false);
        this.setDirection(image.direction);
    }
    if (this._originalPattern !== image.pattern) {
        this._originalPattern = image.pattern;
        this.setPattern(image.pattern);
    }
    this.setMoveSpeed(page.moveSpeed);
    this.setMoveFrequency(page.moveFrequency);
    this.setPriorityType(page.priorityType);
    this.setWalkAnime(page.walkAnime);
    this.setStepAnime(page.stepAnime);
    this.setDirectionFix(page.directionFix);
    this.setThrough(page.through);
    this.setMoveRoute(page.moveRoute);
    this._moveType = page.moveType;
    this._trigger = page.trigger;
    if (this._trigger === 4) {
        this._interpreter = new Game_Interpreter();
    } else {
        this._interpreter = null;
    }
};
Starting Line 8256:
Code:
Game_Vehicle.prototype.loadSystemSettings = function() {
    var vehicle = this.vehicle();
    this._mapId = vehicle.startMapId;
    this.setPosition(vehicle.startX, vehicle.startY);
    this.setImage(vehicle.characterName, vehicle.characterIndex);
};
I saw a few of those, but my brain died on me trying to wrap my head around them and most of them didnt directly connect to anything i could use to gain access to what objects they were related too
Sorry, I don't quite understand what you are looking for? Are you looking for where the characters on the map are initialized? If so, almost all of the sprites on the map are handled by the Spriteset_Map object (easier to control stuff across all sprites, like zoom for instance):

Code:
Spriteset_Map.prototype.createCharacters = function() {
    this._characterSprites = [];
    $gameMap.events().forEach(function(event) {
        this._characterSprites.push(new Sprite_Character(event));
    }, this);
    $gameMap.vehicles().forEach(function(vehicle) {
        this._characterSprites.push(new Sprite_Character(vehicle));
    }, this);
    $gamePlayer.followers().reverseEach(function(follower) {
        this._characterSprites.push(new Sprite_Character(follower));
    }, this);
    this._characterSprites.push(new Sprite_Character($gamePlayer));
    for (var i = 0; i < this._characterSprites.length; i++) {
        this._tilemap.addChild(this._characterSprites[i]);
    }
};
I have tried gathering information from those sorces having gotten there via different means. however, when trying to get information out of those all i get back is;

But i havent been able to find anything in the version of this array that coorilates to the actual object.
each object that gets sent through this is;
Game_Event
Game_Vehicle
Game_Follwer
Game_Player

I mean if you can help me figure out how to get $dataActors[n] or what event the thing orionates from it would be great! i havent been able to figure out how to grab it from this data that gets passed around the RPG_Sprites.js file a decent bit
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
@Poppie360 So what you are trying to accomplish is getting the information needed in $gameActors to load the correct sprite associated with that actor (it's in the screenshot you just sent btw)? I'm sorry I still don't understand what your question is. What are you looking for specifically?
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
@Poppie360 So what you are trying to accomplish is getting the information needed in $gameActors to load the correct sprite associated with that actor (it's in the screenshot you just sent btw)? I'm sorry I still don't understand what your question is. What are you looking for specifically?
Basically what i am trying to do is be able to get (in the case of party members) the sprites associated with the actor so i can get the metadata so i can simply swap what bitmap the function that loads characters returns based on what is defined in the notebox. (and for just normal events) be able to get the notebox from the event the sprite is assoicated with so i can do the same as with the party members. (and with the vehicles just switch it based on some otherwise determined paramiters.)

something like this (but with actual code of course;
Code:
ImageManager.loadCharacter = function(filename, hue) {
    if(thingusescustomgraphic){
        return this.loadBitmap(CustomPath, filename, hue, false);
    } else {
        return this.loadBitmap('img/characters/', filename, hue, false);
    }
};
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
If you're looking for the object of those sprites on the map, then it is exactly like in my first post. All sprites on the map (except some hud stuff) is stored inside Spriteset_Map, which is the stored in the Scene_Map.

So when you're in the code of Scene_Map, here's how you can access those sprite objects:
Code:
Scene_Map.prototype.somethingFunction = function() {
    this._spriteset._characterSprites;
}
Is that what you are looking for?
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
If you're looking for the object of those sprites on the map, then it is exactly like in my first post. All sprites on the map (except some hud stuff) is stored inside Spriteset_Map, which is the stored in the Scene_Map.

So when you're in the code of Scene_Map, here's how you can access those sprite objects:
Code:
Scene_Map.prototype.somethingFunction = function() {
    this._spriteset._characterSprites;
}
Is that what you are looking for?
I have looked at this information before;


How do i get the actual $dataMap.events[id] from each of these?
and for the party members, how do i get $dataActors[id] from this?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
The object listed in your screenshot is from the Game_Event object. To get the eventId of an object created with Game_Event is really simple: theGameEventObject.eventId()

As for getting the $dataActor's id, there's no pre-existing method to get that since Game_Event doesn't store an actorId. Game_Event only stores the characterIndex and the characterName, which are the only 2 variables needed to load a character image into memory. I suppose you could create a method that loops through all the actors in $dataActors and check if they have the same characterIndex and characterName as the event and return the actorId if it does.

EDIT: Also what you shown in your previous screenshot isn't from the line of code I gave, since what I gave you would list a Sprite_Character object and not a Game_Event object, although both can access the characterIndex and the characterName.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
The object listed in your screenshot is from the Game_Event object. To get the eventId of an object created with Game_Event is really simple: theGameEventObject.eventId()

As for getting the $dataActor's id, there's no pre-existing method to get that since Game_Event doesn't store an actorId. Game_Event only stores the characterIndex and the characterName, which are the only 2 variables needed to load a character image into memory. I suppose you could create a method that loops through all the actors in $dataActors and check if they have the same characterIndex and characterName as the event and return the actorId if it does.

EDIT: Also what you shown in your previous screenshot isn't from the line of code I gave, since what I gave you would list a Sprite_Character object and not a Game_Event object, although both can access the characterIndex and the characterName.
Okay so thank you for the help with the first one, i really appreciate that.

but another thing i can think of is to edit Game_Followers and whatever the leader is stored in to include that in it, however, that would require knowing where it sets this information.

do you know where in the script it takes an actor and makes a Game_Follower/leaderthing out of it?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
Good question. I haven't touched much to game followers and leader since I never really changed leaders in my games and always deactivated game followers, but I believe the code for the game leader is here:

Code:
Game_Party.prototype.leader = function() {
    return this.battleMembers()[0];
};
As for followers, I think it's this:

Code:
Game_Player.prototype.followers = function() {
    return this._followers;
};
EDIT: Since those two classes are used as global objects, you can easily use:
Code:
$gameParty.leader();
$gamePlayer.followers();
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Good question. I haven't touched much to game followers and leader since I never really changed leaders in my games and always deactivated game followers, but I believe the code for the game leader is here:

Code:
Game_Party.prototype.leader = function() {
    return this.battleMembers()[0];
};
As for followers, I think it's this:

Code:
Game_Player.prototype.followers = function() {
    return this._followers;
};
EDIT: Since those two classes are used as global objects, you can easily use:
Code:
$gameParty.leader();
$gamePlayer.followers();
alright that is good to know, but how do we get from Spriteset_Map to $gameParty?

or, where does $gameParty become Spriteset_Map? i can do easily what i did with items and their icons (copying the data from a higher up function and then using it when it tried to load the bitmap.)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,787
Reaction score
12,216
First Language
English
Primarily Uses
RMMV
I have not read through this entire thread.

There is no link from the event object to the sprite object. The link goes the other way - from the sprite object back to the event object.

This code was already provided above:
Code:
Spriteset_Map.prototype.createCharacters = function() {
    this._characterSprites = [];
    $gameMap.events().forEach(function(event) {
        this._characterSprites.push(new Sprite_Character(event));
    }, this);
    $gameMap.vehicles().forEach(function(vehicle) {
        this._characterSprites.push(new Sprite_Character(vehicle));
    }, this);
    $gamePlayer.followers().reverseEach(function(follower) {
        this._characterSprites.push(new Sprite_Character(follower));
    }, this);
    this._characterSprites.push(new Sprite_Character($gamePlayer));
    for (var i = 0; i < this._characterSprites.length; i++) {
        this._tilemap.addChild(this._characterSprites[i]);
    }
};
This is where Spriteset_Map gets individual sprites created for events (from $gameMap.events()), vehicles (from $gameMap.vehicles()) and the party (followers come from $gamePlayer.followers() and the leader from $gamePlayer). Nothing comes directly from $gameParty, because that's not where the sprite names are.

It is a lot of investigating to figure out how all these things hang together, but eventually you'll get it :)
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
So here's the process:
  • Spriteset_Map gets the information for the leader's graphics and the followers from $gamePlayer.
  • $gamePlayer gets the information for the leader from $gameParty.
  • $gamePlayer gets the information for the followers from Game_Followers.
  • Game_Followers gets the information for the followers from $gameParty.
@Shaz Yes, I've already pointed OP to that function. It seems that OP is trying to understand the process of getting the information to get the character images and where that information is stored in Scene_Map, although I have yet to understand the goal of his inquiry.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,787
Reaction score
12,216
First Language
English
Primarily Uses
RMMV
Yes. It's not in Scene_Map. It's in Game_CharacterBase, which is inherited by Game_Event, Game_Player, and Game_Follower (I think - don't have MV with me now).
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
@Shaz OP asked me where that information is stored in the hierarchy of objects from Scene_Map, sorry I wasn't clear enough. Like: Scene_Map -> Spriteset_map -> Game_Event / Sprite_Character
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
I have not read through this entire thread.

There is no link from the event object to the sprite object. The link goes the other way - from the sprite object back to the event object.

This code was already provided above:
Code:
Spriteset_Map.prototype.createCharacters = function() {
    this._characterSprites = [];
    $gameMap.events().forEach(function(event) {
        this._characterSprites.push(new Sprite_Character(event));
    }, this);
    $gameMap.vehicles().forEach(function(vehicle) {
        this._characterSprites.push(new Sprite_Character(vehicle));
    }, this);
    $gamePlayer.followers().reverseEach(function(follower) {
        this._characterSprites.push(new Sprite_Character(follower));
    }, this);
    this._characterSprites.push(new Sprite_Character($gamePlayer));
    for (var i = 0; i < this._characterSprites.length; i++) {
        this._tilemap.addChild(this._characterSprites[i]);
    }
};
This is where Spriteset_Map gets individual sprites created for events (from $gameMap.events()), vehicles (from $gameMap.vehicles()) and the party (followers come from $gamePlayer.followers() and the leader from $gamePlayer). Nothing comes directly from $gameParty, because that's not where the sprite names are.

It is a lot of investigating to figure out how all these things hang together, but eventually you'll get it :)
So here's the process:
  • Spriteset_Map gets the information for the leader's graphics and the followers from $gamePlayer.
  • $gamePlayer gets the information for the leader from $gameParty.
  • $gamePlayer gets the information for the followers from Game_Followers.
  • Game_Followers gets the information for the followers from $gameParty.
@Shaz Yes, I've already pointed OP to that function. It seems that OP is trying to understand the process of getting the information to get the character images and where that information is stored in Scene_Map, although I have yet to understand the goal of his inquiry.
basically i am just trying to get the events and whatnot to load from a defined path based on things about what it is getting the things from.

I am not the best at wording things i will admit, but i am trying to do something similar to this;
Code:
    //New graphic loader
    ImageManager.loadImageThing = function(Path, filename, hue) {
        return this.loadBitmap(Path, filename, hue, true);
    };

    //Overwrite old functions
    ImageManager.loadSystem = function(filename, hue) {
        if ($gameVariables.value(2) != 0) {
            return this.loadImageThing($gameVariables.value(3), $gameVariables.value(4), hue, false);
        } else {
            return this.loadBitmap('img/system/', filename, hue, false);
        }
    };

    Window_Base.prototype.drawItemName = function(item, x, y, width) {
        width = width || 312;
        if (item) {
            var iconBoxWidth = Window_Base._iconWidth + 4;
            this.resetTextColor();
            if (item.meta.UsesCustomGraphic != "false"){
                $gameVariables.setValue(2, 1);
                $gameVariables.setValue(3, ("Mods/Mod Data/" + item.meta.ModID + item.meta.GraphicPath));
                $gameVariables.setValue(4, item.meta.GraphicName);
                this.drawIcon(Number(item.meta.GraphicCalcVariable), x + 2, y + 2);
                $gameVariables.setValue(2, 0);
            } else {
                this.drawIcon(item.iconIndex, x + 2, y + 2);
                $gameVariables.setValue(2, 0);
            }

            this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
        }
    };
but with events and whatnot instead of items.

I will try out the things you two have suggested real quick.

Edit;

Code:
        $gamePlayer.followers().reverseEach(function(follower) {
            console.log(follower);
            this._characterSprites.push(new Sprite_Character(follower));
        }, this);
just returns Game_follower and i dont think i can use that, also how is the character you play as defined in this?
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
@Poppie360 If you want the event's graphics to load from a different there are a couple things you need to change:
  • You need to add a method to ImageManager to load assets from a different path.
  • Since events's graphics are created through Sprite_Character which is used for actors and not only events, you need to be able to differentiate between actor and events. You could add another parameter when initializing the object, which is done in the Spriteset_map: Spriteset_Map.prototype.createCharacters.
  • Then you need to modify the Sprite_Character to make it load assets with your new method in Image_Manager if it's an event (hence the previous step). This is the method that loads the graphics in Sprite_Character: Sprite_Character.prototype.setCharacterBitmap. Basically just change the ImageManager.loadCharacter method to your new loading method.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
@Poppie360 If you want the event's graphics to load from a different there are a couple things you need to change:
  • You need to add a method to ImageManager to load assets from a different path.
  • Since events's graphics are created through Sprite_Character which is used for actors and not only events, you need to be able to differentiate between actor and events. You could add another parameter when initializing the object, which is done in the Spriteset_map: Spriteset_Map.prototype.createCharacters.
  • Then you need to modify the Sprite_Character to make it load assets with your new method in Image_Manager if it's an event (hence the previous step). This is the method that loads the graphics in Sprite_Character: Sprite_Character.prototype.setCharacterBitmap. Basically just change the ImageManager.loadCharacter method to your new loading method.
Yeah i figured as much, i have managed to change how items, weapons, states, armors, and skills load their graphics so i can easily just specify a file for them to load and they load it as i wish.

But this is different and i have pretty much no idea how to do it!
and yes, i had noticed that, but i can't change what bitmap

Code:
ImageManager.loadCharacter = function(filename, hue) {
    return this.loadBitmap('img/characters/', filename, hue, false);
};
returns if i cant access the information right. that's why i provided my example of how to make image icons load from a custom file path.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,590
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
The filename is the information you need to load the image. You just need to change the path.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

:/ nope...today is canceled.
"...and I hope you like jammin' too."
This guy makes so many good hip hop tracks!
can't use certain things with SRDude's Battle Status Customizer? make the gauges show it lol. I got the gauges to show Olivia's Boost Points and other stuff.
Seeing people still using Kaus tiles with stolen contents makes me sad.

Forum statistics

Threads
95,545
Messages
929,974
Members
125,829
Latest member
Endruler
Top