MZ Creating a variation to IsObjectCharacter

This is something that started in a thread in RMMZ Support.

Characters with "isObjectCharacter" set to true will have a offset of 0 (shiftY is 0), as opposed to the default offset of -6 (shiftY is 6) for, errr, normal characters.

The question in the thread was to have a offset for a large car sprite, which would mean that the anchor would have to be more to the middle of the image. So I thought of just creating a "isCarCharacter" that is true when the filename starts with a "#". Downstream, I assign a shiftY of -42 when isCarCharacter is true. Upon testing, this plugin results in all characters to be offset as if isCarCharacter is true... and i can't figure out why this is... please help.

Spoiler: Don Quixote and the Windmill
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;
};
})();
The problem is here:
Game_CharacterBase.prototype.shiftY = function() {
return this.isObjectCharacter() ? 0 : (this.isCarCharacter ? -42 : 6);

The syntax is incorrect... I believe what you intended is this:

Game_CharacterBase.prototype.shiftY = function() { if (this.isObjectCharacter()) return 0 else if (this.isCarCharacter()) return -42 else return 6 };
The syntax is incorrect... I believe what you intended is this:
You're right, but the rest of your post seems misleading to me.

It reads like you're saying the nested ternary statements are incorrect syntax, and they're not.

The error is that isCarCharacter is missing the parentheses to be identified as a function call. Otherwise it's simply checking for the existence of the function, and that's always true.

(also, the parentheses around that second ternary statement are unnecessary)
The error is that isCarCharacter is missing the parentheses to be identified as a function call.
The mother of all mothers! I kept combing through rmmz_managers.js to see if there's a step I was missing! Thank you!

(also, the parentheses around that second ternary statement are unnecessary)
I figured, but this was me grabbing at straws lol. Also tried to add a patch for the initMembers. Not sure if needed since apparently it defaults to false anyway...

Spoiler: Windmill Conquered!
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;
};
})();

void (alias => {
    Game_CharacterBase.prototype.initMembers = function() {
        alias.apply(this, arguments);
        this._isCarCharacter = false;
    };
})(Game_CharacterBase.prototype.initMembers);
This thread is being closed due to being solved. If you need it later, report it to let us know why. Thank you~!

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-variation-to-isobjectcharacter.161479/