Character sheet anchoring issue.

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
Hi, I am struggling to find out a solution with anchoring a unique character graphic template.
I am looking in how to plan out how a larger character physically occupies more grid space but I wanted to also address the issue with the graphic itself first.
The graphic in question is a futuristic hover car (sedan model) Now each sprite dimension for this plan template is 144 x 144 pixels, the intended central space is the middle obviously- but when the sprite itself is facing vertically (up/down) the sprite
anchors awkwardly, from the horizontal positions (left/right) the vehicle positions as intended with the cab in the center and the bonnet and boot on adjacent sides.

Here is an image demonstrating the issue.
F43CKH5a.jpg


Note: This is also intended for the player vehicles AND events.

Now according to the documentation

Characters (img/characters)​


Images shown for the characters on the map.
The size for a character image can be changed freely (normally 48x48 pixels), and consist of 4 directions (up, down, left, right) and 3 patterns for a total of 12 patterns that will be arranged in the provided order. A file for 1 character will be arranged into 2 rows and 4 columns, totaling 8 images. The size of the character will be calculated using 1/12 of the width and 1/8 of the height of this file. Moreover, characters will be shown 1/8 above a tile so they appear more natural when on top of buildings.
  • It is possible to treat 1 character as 1 file by including "$" at the beginning of the file name.
  • Including a "!" at the beginning of the file name will prevent the image from being shifted 1/8 up, and bush elements will no longer make it appear half-transparent. This is primarily used for map objects such as doors and treasure chests.
  • It is also possible to use the "$" and "!" special characters together.

So I've tried all image formatting and I've come to the realization that there is no apparent way to get around this without making additional events (I absolutely do not want to resort to this) -though I could be wrong somewhere, I figured I ask this in the support forum before fully concluding I need to somehow get this done via a plugin or something.
Does anyone here know a way to fix this?
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,360
Reaction score
2,553
First Language
Spanish
Primarily Uses
RMVXA
the only way to fix it directly with no scripting, would be to calculate the space it needs, since all character sprites anchor to the center of the event, and the 144p size is calculated around that.
then, make a sprite sheet specifically for this, regardless of standard limitations.
the square will still load, it won't be cropped or anything.

with scripting, you have options:
-make a small override through the move route by having IT load it's own character image and adjust it.
-use a note tag to declare the override, although you'll need a plugin to read that tag, but that would make the override global, and you only need to define it once.
-spawn the event dynamically and configure it on the fly via another event, although this spawned event would have no interactivity.

there are alternatives before you'd need a heavy plugin dedicated to handling character sprites.
take your pick.
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
the only way to fix it directly with no scripting, would be to calculate the space it needs, since all character sprites anchor to the center of the event, and the 144p size is calculated around that.
then, make a sprite sheet specifically for this, regardless of standard limitations.
the square will still load, it won't be cropped or anything.
I may have to point out that it the image anchors on the bottom of the sprite direction, automatically which offsets the image, using the ! character in the sheet only prevents the offset from going 1/8th upward and removes the bush transparency, technically I can extend the sheet to offset the sprite into the right spot but that also displaces the visuals.

By the way my tests and research are going it seems I have no choice but to resort to a plugin for this instance, some kind of automatic parameters for player vehicles and event types, physical presence is another factor to be added after but visuals are essential to make this work.
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,360
Reaction score
2,553
First Language
Spanish
Primarily Uses
RMVXA
the image anchors on the bottom of the sprite direction, automatically which offsets the image
yes.
but you *can* offset the image once it's loaded.
and, you don't need a whole plugin for a one-line override.
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
I've had the same problem with oversized boats and the solution was to patch the shiftY for vehicles. Since in this case your vehicle is not, errr..., a vehicle according to rpgmaker, you'll have to be more creative (or, as mentioned, resort to the monster plugins out there that do this amongst many other things).

The offset is "6" by default (rmmz_objects):

JavaScript:
Game_CharacterBase.prototype.shiftY = function() {
    return this.isObjectCharacter() ? 0 : 6;
};

The "isObjectCharacter" is the "!" that you put in front of filenames if you do not want the offset (defined in rmmz_managers).

JavaScript:
ImageManager.isObjectCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[!$]+/);
    return sign && sign[0].includes("!");
};

ImageManager.isBigCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[!$]+/);
    return sign && sign[0].includes("$");
};

In a similar fashion I suppose you could create a "isCarCharacter" that looks for a "#" at the start of the filename. I thought it would be fun to try and make a mini-plugin that does just this as an exercise, but have not succeeded yet I'm afraid.
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
yes.
but you *can* offset the image once it's loaded.
and, you don't need a whole plugin for a one-line override.
I'll try and see what I can do, I am making correspondence with various other RPG devs about the various possibilities and oversights.

I've had the same problem with oversized boats and the solution was to patch the shiftY for vehicles. Since in this case your vehicle is not, errr..., a vehicle according to rpgmaker, you'll have to be more creative (or, as mentioned, resort to the monster plugins out there that do this amongst many other things).

The offset is "6" by default (rmmz_objects):

JavaScript:
Game_CharacterBase.prototype.shiftY = function() {
    return this.isObjectCharacter() ? 0 : 6;
};

The "isObjectCharacter" is the "!" that you put in front of filenames if you do not want the offset (defined in rmmz_managers).

JavaScript:
ImageManager.isObjectCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[!$]+/);
    return sign && sign[0].includes("!");
};

ImageManager.isBigCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[!$]+/);
    return sign && sign[0].includes("$");
};

In a similar fashion I suppose you could create a "isCarCharacter" that looks for a "#" at the start of the filename. I thought it would be fun to try and make a mini-plugin that does just this as an exercise, but have not succeeded yet I'm afraid.
Are you saying with this method you basically set up your own defined file names that follow a different set of char graphic offsets?
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
Are you saying with this method you basically set up your own defined file names that follow a different set of char graphic offsets?
Yes, that was the idea, but the code is taking a middle step that I don't fully understand yet. Now everything behaves as a car object...

JavaScript:
(function() {
    'use strict';
ImageManager.isCarCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("#");
};
ImageManager.isObjectCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("!");
};
ImageManager.isBigCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("$");
};
Game_CharacterBase.prototype.shiftY = function() {
    return this.isObjectCharacter() ? 0 : (this.isCarCharacter ? -42 : 6);
};
Game_CharacterBase.prototype.setImage = function(
    characterName,
    characterIndex
) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
    this._isCarCharacter = ImageManager.isCarCharacter(characterName);
};
Game_CharacterBase.prototype.isCarCharacter = function() {
    return this._isCarCharacter;
};
})();
 
Last edited:

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,360
Reaction score
2,553
First Language
Spanish
Primarily Uses
RMVXA
getting the first character alone is not going to make the difference, because you want the fix only for when the car is facing up or down.
try accessing the sprite through the move route with a script call.
all properties should be local and accessible there.
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
because you want the fix only for when the car is facing up or down.
Although I'm sure this would work, I think it's cleaner if the car is centered on the 144x144 grid. It's an academic interest at this point I suppose, so I have opened a thread in "Learning Javascript"
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,360
Reaction score
2,553
First Language
Spanish
Primarily Uses
RMVXA
@werzaque but for that you'd have to move the event proper.
not a terrible solution, but it would screw up any interaction, if any is required.
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
Anyway, quick tests show that the below will work for the offset. Thanks to @ATT_Turan for pointing out the silly typo:kaoswt:. As @gstv87 points out, the interaction will only be with the CENTER of the vehicle.

JavaScript:
/*:
 * @target MZ
 * @plugindesc Offsets Y of sprites 42 pixels.
 * @author Werzaque / Canned_Dinosaur
 * @url https://forums.rpgmakerweb.com/threads/161479/
 * @help Free to use and/or modify for any project, no credit required.
 * Intended for use with 144*144px sprites for which the anchor
 * needs to be in the center of the image (sedans, UFOs, etc...)
 * Simply add a "#" to the filename for it to work.
 */
(function() {
    'use strict';
ImageManager.isCarCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("#");
};
ImageManager.isObjectCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("!");
};
ImageManager.isBigCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("$");
};
Game_CharacterBase.prototype.shiftY = function() {
    return this.isObjectCharacter() ? 0 : (this.isCarCharacter() ? -42 : 6);
};
Game_CharacterBase.prototype.setImage = function(
    characterName,
    characterIndex
) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
    this._isCarCharacter = ImageManager.isCarCharacter(characterName);
};
Game_CharacterBase.prototype.isCarCharacter = function() {
    return this._isCarCharacter;
};
})();

void (alias => {
    Game_CharacterBase.prototype.initMembers = function() {
        alias.apply(this, arguments);
        this._isCarCharacter = false;
    };
})(Game_CharacterBase.prototype.initMembers);
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
Sorry I have been working and hadn't had much opportunity to check the forums.

I would be very much interested in trying out what you have uncovered, I had also been in correspondence with Eli a plugin developer who is looking further into his offset graphics plugin but there are some extra complications -still i am looking at my options here and wish to try all these out.

As for interactions only occurring in the center of the sprite sheet I am aware of this and will look into a plugin additionally down the track that will hopefully set up extended events + there directions. So far I haven't seen any MZ plugins around but I will do more research.
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
Anyway, quick tests show that the below will work for the offset. Thanks to @ATT_Turan for pointing out the silly typo:kaoswt:. As @gstv87 points out, the interaction will only be with the CENTER of the vehicle.

JavaScript:
/*:
 * @target MZ
 * @plugindesc Offsets Y of sprites 42 pixels.
 * @author Werzaque / Canned_Dinosaur
 * @url https://forums.rpgmakerweb.com/threads/161479/
 * @help Free to use and/or modify for any project, no credit required.
 * Intended for use with 144*144px sprites for which the anchor
 * needs to be in the center of the image (sedans, UFOs, etc...)
 * Simply add a "#" to the filename for it to work.
 */
(function() {
    'use strict';
ImageManager.isCarCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("#");
};
ImageManager.isObjectCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("!");
};
ImageManager.isBigCharacter = function(filename) {
    const sign = Utils.extractFileName(filename).match(/^[#!$]+/);
    return sign && sign[0].includes("$");
};
Game_CharacterBase.prototype.shiftY = function() {
    return this.isObjectCharacter() ? 0 : (this.isCarCharacter() ? -42 : 6);
};
Game_CharacterBase.prototype.setImage = function(
    characterName,
    characterIndex
) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
    this._isCarCharacter = ImageManager.isCarCharacter(characterName);
};
Game_CharacterBase.prototype.isCarCharacter = function() {
    return this._isCarCharacter;
};
})();

void (alias => {
    Game_CharacterBase.prototype.initMembers = function() {
        alias.apply(this, arguments);
        this._isCarCharacter = false;
    };
})(Game_CharacterBase.prototype.initMembers);
Terribly sorry, but I legitimately did not see your spoiler tag.
I tried this out and it looks like it's doing exactly what I needed! This is very good!
I will continue some tests to see if there are any potential bugs or other oversights I haven't experienced yet when encountering this problem.
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
Happy to have been of help! You are officially my first plugin-user lol :kaocry:

Since it's still a single tile character internally, there is an obvious issue with other characters/events appearing under the car when they are on the same y as the car, and appearing over the car when the y is higher than that of the car.
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
I ran a test with taller characters to see if there is an overlap or not, it definitely seems that sprites above the vehicle appear behind it -while events below are showing on top.
So perspective wise it seems to be accurate.

ezgif.com-video-to-gif.gif

What's this obvious issue you are referring to? I do not see any so far.
 

werzaque

Canned Dinosaur
Regular
Joined
May 30, 2023
Messages
419
Reaction score
256
First Language
EN/JP/NL
Primarily Uses
RMMZ
What's this obvious issue you are referring to? I do not see any so far.
The "crawling under the car" also happens if you are to the left or right of the car. Not sure though which is more acceptable: under or on top.
 

Skurge

Archtross Dev
Regular
Joined
Jul 12, 2015
Messages
1,383
Reaction score
332
First Language
English
Primarily Uses
N/A
Oh I see! Like when you are on the grid occupying just left or right of the center part.
Well...considering I plan to have the events solid in those areas with a plugin down the track it might not be a noticeable, but considering just now thinking about it when events or players are to walk into the center to enter the vehicle it may be a visual issue? Perhaps its best to have the actors take priority and show above on those areas?
 

Latest Threads

Latest Posts

Latest Profile Posts

So the concept for my Game Jam project is way more than I can complete before the deadline. But I think I found a way to get the core done and make the incomplete parts either not really noticeable or make them a part of the story for now. That sneaky, dastardly Krampus! Then I can complete the rest. Did I mention that this is fun?
I've been working on a game called "Eternal Sunset". Is there anywhere here i can "show it off" maybe? Wondering what others think.
What do you do when there are lots of offers online but you don't have even a slight chance of ever playing those myriads of games?
Ugh, mispelled my username.

Forum statistics

Threads
136,543
Messages
1,267,342
Members
180,215
Latest member
Itohera
Top