Heya, all y'all.
Part of my game involves a custom plugin that creates a field of view. Events that are outside of this field of view fade out until they're invisible, while events that are inside fade in until fully opaque. Because of this, it's very useful QoL-wise to have a plugin such as
Hime_LockFacingDirection.js
The important code for this plugin is very simple:
JavaScript:
(function ($) {
$.params = PluginManager.parameters("HIME_LockFacingDirection");
$.button = $.params["Lock Button"].toLowerCase().trim();
var TH_GameCharacterBase_isDirectionFixed = Game_CharacterBase.prototype.isDirectionFixed;
Game_CharacterBase.prototype.isDirectionFixed = function() {
return TH_GameCharacterBase_isDirectionFixed.call(this) || this.isdirectionFixButtonPressed();
};
Game_CharacterBase.prototype.isdirectionFixButtonPressed = function() {
return Input.isPressed($.button);
};
})(TH.LockFaceDirection);
However, it's pretty clear that when you hold the button in question (default 'control'), not only does the player character fix its direction, but every single other event does as well. I've come up with a messy fix for this already just today by adding a conditional to isDirectionFixed which compares the coordinates to the player character's own:
JavaScript:
Game_CharacterBase.prototype.isDirectionFixed = function() {
return TH_GameCharacterBase_isDirectionFixed.call(this) || this.isdirectionFixButtonPressed();
};
becomes:
JavaScript:
Game_CharacterBase.prototype.isDirectionFixed = function() {
let character = $gamePlayer || ''
if (character != '' && this._realX == character._realX && this._realY == character._realY ){
return TH_GameCharacterBase_isDirectionFixed.call(this) || this.isdirectionFixButtonPressed();
} else {
return TH_GameCharacterBase_isDirectionFixed.call(this)
}
};
This seems to work fine, and I also have an alternative that compares spritenames instead via the _characterName properties if I encounter any major bugs with this.
But I still feel like I should ask: Is there a better (or cleaner) way to do this? The fix in general, that is, not just my solution.