//-----------------------------------------------------------------------------
// Game_Follower
//
// The game object class for a follower. A follower is an allied character,
// other than the front character, displayed in the party.
/**
* The game object class for a follower. A follower is an allied character, other than the front character, displayed in the party.
*
* @class
* @extends Game_Character
*/
function Game_Follower() {
this.initialize(...arguments);
}
Game_Follower.prototype = Object.create(Game_Character.prototype);
Game_Follower.prototype.constructor = Game_Follower;
Game_Follower.prototype.initialize = function(memberIndex) {
Game_Character.prototype.initialize.call(this);
this._memberIndex = memberIndex;
this.setTransparent($dataSystem.optTransparent);
this.setThrough(true);
};
/**
* Refresh the follower
*/
Game_Follower.prototype.refresh = function() {
const characterName = this.isVisible() ? this.actor().characterName() : "";
const characterIndex = this.isVisible() ? this.actor().characterIndex() : 0;
this.setImage(characterName, characterIndex);
};
/**
* Get the game actor the follower represents
*
* @return {Game_Actor} The actor the follower represents
*/
Game_Follower.prototype.actor = function() {
return $gameParty.battleMembers()[this._memberIndex];
};
/**
* Check if the follower is visible
*
* @return {boolean} True if visible
*/
Game_Follower.prototype.isVisible = function() {
return this.actor() && $gamePlayer.followers().isVisible();
};
/**
* Check if the follower is gathered
*
* @return {boolean} True if gathered
*/
Game_Follower.prototype.isGathered = function() {
return !this.isMoving() && this.pos($gamePlayer.x, $gamePlayer.y);
};
Game_Follower.prototype.update = function() {
Game_Character.prototype.update.call(this);
this.setMoveSpeed($gamePlayer.realMoveSpeed());
this.setOpacity($gamePlayer.opacity());
this.setBlendMode($gamePlayer.blendMode());
this.setWalkAnime($gamePlayer.hasWalkAnime());
this.setStepAnime($gamePlayer.hasStepAnime());
this.setDirectionFix($gamePlayer.isDirectionFixed());
this.setTransparent($gamePlayer.isTransparent());
};
/**
* Chase another character object
*
* @param {Game_Character} The character to chase
*/
Game_Follower.prototype.chaseCharacter = function(character) {
const sx = this.deltaXFrom(character.x);
const sy = this.deltaYFrom(character.y);
if (sx !== 0 && sy !== 0) {
this.moveDiagonally(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2);
} else if (sx !== 0) {
this.moveStraight(sx > 0 ? 4 : 6);
} else if (sy !== 0) {
this.moveStraight(sy > 0 ? 8 : 2);
}
this.setMoveSpeed($gamePlayer.realMoveSpeed());
};