You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ycrpg/js/rpg_sprites.js

2709 lines
77 KiB
JavaScript

3 years ago
//=============================================================================
// rpg_sprites.js v1.6.2
//=============================================================================
//-----------------------------------------------------------------------------
// Sprite_Base
//
// The sprite class with a feature which displays animations.
function Sprite_Base() {
this.initialize.apply(this, arguments);
}
Sprite_Base.prototype = Object.create(Sprite.prototype);
Sprite_Base.prototype.constructor = Sprite_Base;
Sprite_Base.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this._animationSprites = [];
this._effectTarget = this;
this._hiding = false;
};
Sprite_Base.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateVisibility();
this.updateAnimationSprites();
};
Sprite_Base.prototype.hide = function () {
3 years ago
this._hiding = true;
this.updateVisibility();
};
Sprite_Base.prototype.show = function () {
3 years ago
this._hiding = false;
this.updateVisibility();
};
Sprite_Base.prototype.updateVisibility = function () {
3 years ago
this.visible = !this._hiding;
};
Sprite_Base.prototype.updateAnimationSprites = function () {
3 years ago
if (this._animationSprites.length > 0) {
var sprites = this._animationSprites.clone();
this._animationSprites = [];
for (var i = 0; i < sprites.length; i++) {
var sprite = sprites[i];
if (sprite.isPlaying()) {
this._animationSprites.push(sprite);
} else {
sprite.remove();
}
}
}
};
Sprite_Base.prototype.startAnimation = function (animation, mirror, delay) {
3 years ago
var sprite = new Sprite_Animation();
sprite.setup(this._effectTarget, animation, mirror, delay);
this.parent.addChild(sprite);
this._animationSprites.push(sprite);
};
Sprite_Base.prototype.isAnimationPlaying = function () {
3 years ago
return this._animationSprites.length > 0;
};
//-----------------------------------------------------------------------------
// Sprite_Button
//
// The sprite for displaying a button.
function Sprite_Button() {
this.initialize.apply(this, arguments);
}
Sprite_Button.prototype = Object.create(Sprite.prototype);
Sprite_Button.prototype.constructor = Sprite_Button;
Sprite_Button.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this._touching = false;
this._coldFrame = null;
this._hotFrame = null;
this._clickHandler = null;
};
Sprite_Button.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateFrame();
this.processTouch();
};
Sprite_Button.prototype.updateFrame = function () {
3 years ago
var frame;
if (this._touching) {
frame = this._hotFrame;
} else {
frame = this._coldFrame;
}
if (frame) {
this.setFrame(frame.x, frame.y, frame.width, frame.height);
}
};
Sprite_Button.prototype.setColdFrame = function (x, y, width, height) {
3 years ago
this._coldFrame = new Rectangle(x, y, width, height);
};
Sprite_Button.prototype.setHotFrame = function (x, y, width, height) {
3 years ago
this._hotFrame = new Rectangle(x, y, width, height);
};
Sprite_Button.prototype.setClickHandler = function (method) {
3 years ago
this._clickHandler = method;
};
Sprite_Button.prototype.callClickHandler = function () {
3 years ago
if (this._clickHandler) {
this._clickHandler();
}
};
Sprite_Button.prototype.processTouch = function () {
3 years ago
if (this.isActive()) {
if (TouchInput.isTriggered() && this.isButtonTouched()) {
this._touching = true;
}
if (this._touching) {
if (TouchInput.isReleased() || !this.isButtonTouched()) {
this._touching = false;
if (TouchInput.isReleased()) {
this.callClickHandler();
}
}
}
} else {
this._touching = false;
}
};
Sprite_Button.prototype.isActive = function () {
3 years ago
var node = this;
while (node) {
if (!node.visible) {
return false;
}
node = node.parent;
}
return true;
};
Sprite_Button.prototype.isButtonTouched = function () {
3 years ago
var x = this.canvasToLocalX(TouchInput.x);
var y = this.canvasToLocalY(TouchInput.y);
return x >= 0 && y >= 0 && x < this.width && y < this.height;
};
Sprite_Button.prototype.canvasToLocalX = function (x) {
3 years ago
var node = this;
while (node) {
x -= node.x;
node = node.parent;
}
return x;
};
Sprite_Button.prototype.canvasToLocalY = function (y) {
3 years ago
var node = this;
while (node) {
y -= node.y;
node = node.parent;
}
return y;
};
//-----------------------------------------------------------------------------
// Sprite_Character
//
// The sprite for displaying a character.
function Sprite_Character() {
this.initialize.apply(this, arguments);
}
Sprite_Character.prototype = Object.create(Sprite_Base.prototype);
Sprite_Character.prototype.constructor = Sprite_Character;
Sprite_Character.prototype.initialize = function (character) {
3 years ago
Sprite_Base.prototype.initialize.call(this);
this.initMembers();
this.setCharacter(character);
};
Sprite_Character.prototype.initMembers = function () {
3 years ago
this.anchor.x = 0.5;
this.anchor.y = 1;
this._character = null;
this._balloonDuration = 0;
this._tilesetId = 0;
this._upperBody = null;
this._lowerBody = null;
};
Sprite_Character.prototype.setCharacter = function (character) {
3 years ago
this._character = character;
};
Sprite_Character.prototype.update = function () {
3 years ago
Sprite_Base.prototype.update.call(this);
this.updateBitmap();
this.updateFrame();
this.updatePosition();
this.updateAnimation();
this.updateBalloon();
this.updateOther();
};
Sprite_Character.prototype.updateVisibility = function () {
3 years ago
Sprite_Base.prototype.updateVisibility.call(this);
if (this._character.isTransparent()) {
this.visible = false;
}
};
Sprite_Character.prototype.isTile = function () {
3 years ago
return this._character.tileId > 0;
};
Sprite_Character.prototype.tilesetBitmap = function (tileId) {
3 years ago
var tileset = $gameMap.tileset();
var setNumber = 5 + Math.floor(tileId / 256);
return ImageManager.loadTileset(tileset.tilesetNames[setNumber]);
};
Sprite_Character.prototype.updateBitmap = function () {
3 years ago
if (this.isImageChanged()) {
this._tilesetId = $gameMap.tilesetId();
this._tileId = this._character.tileId();
this._characterName = this._character.characterName();
this._characterIndex = this._character.characterIndex();
if (this._tileId > 0) {
this.setTileBitmap();
} else {
this.setCharacterBitmap();
}
}
};
Sprite_Character.prototype.isImageChanged = function () {
return (
this._tilesetId !== $gameMap.tilesetId() ||
this._tileId !== this._character.tileId() ||
this._characterName !== this._character.characterName() ||
this._characterIndex !== this._character.characterIndex()
);
3 years ago
};
Sprite_Character.prototype.setTileBitmap = function () {
3 years ago
this.bitmap = this.tilesetBitmap(this._tileId);
};
Sprite_Character.prototype.setCharacterBitmap = function () {
3 years ago
this.bitmap = ImageManager.loadCharacter(this._characterName);
this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};
Sprite_Character.prototype.updateFrame = function () {
3 years ago
if (this._tileId > 0) {
this.updateTileFrame();
} else {
this.updateCharacterFrame();
}
};
Sprite_Character.prototype.updateTileFrame = function () {
3 years ago
var pw = this.patternWidth();
var ph = this.patternHeight();
var sx = ((Math.floor(this._tileId / 128) % 2) * 8 + (this._tileId % 8)) * pw;
var sy = (Math.floor((this._tileId % 256) / 8) % 16) * ph;
3 years ago
this.setFrame(sx, sy, pw, ph);
};
Sprite_Character.prototype.updateCharacterFrame = function () {
3 years ago
var pw = this.patternWidth();
var ph = this.patternHeight();
var sx = (this.characterBlockX() + this.characterPatternX()) * pw;
var sy = (this.characterBlockY() + this.characterPatternY()) * ph;
this.updateHalfBodySprites();
if (this._bushDepth > 0) {
var d = this._bushDepth;
this._upperBody.setFrame(sx, sy, pw, ph - d);
this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
this.setFrame(sx, sy, 0, ph);
} else {
this.setFrame(sx, sy, pw, ph);
}
};
Sprite_Character.prototype.characterBlockX = function () {
3 years ago
if (this._isBigCharacter) {
return 0;
} else {
var index = this._character.characterIndex();
return (index % 4) * 3;
3 years ago
}
};
Sprite_Character.prototype.characterBlockY = function () {
3 years ago
if (this._isBigCharacter) {
return 0;
} else {
var index = this._character.characterIndex();
return Math.floor(index / 4) * 4;
}
};
Sprite_Character.prototype.characterPatternX = function () {
3 years ago
return this._character.pattern();
};
Sprite_Character.prototype.characterPatternY = function () {
3 years ago
return (this._character.direction() - 2) / 2;
};
Sprite_Character.prototype.patternWidth = function () {
3 years ago
if (this._tileId > 0) {
return $gameMap.tileWidth();
} else if (this._isBigCharacter) {
return this.bitmap.width / 3;
} else {
return this.bitmap.width / 12;
}
};
Sprite_Character.prototype.patternHeight = function () {
3 years ago
if (this._tileId > 0) {
return $gameMap.tileHeight();
} else if (this._isBigCharacter) {
return this.bitmap.height / 4;
} else {
return this.bitmap.height / 8;
}
};
Sprite_Character.prototype.updateHalfBodySprites = function () {
3 years ago
if (this._bushDepth > 0) {
this.createHalfBodySprites();
this._upperBody.bitmap = this.bitmap;
this._upperBody.visible = true;
this._upperBody.y = -this._bushDepth;
3 years ago
this._lowerBody.bitmap = this.bitmap;
this._lowerBody.visible = true;
this._upperBody.setBlendColor(this.getBlendColor());
this._lowerBody.setBlendColor(this.getBlendColor());
this._upperBody.setColorTone(this.getColorTone());
this._lowerBody.setColorTone(this.getColorTone());
} else if (this._upperBody) {
this._upperBody.visible = false;
this._lowerBody.visible = false;
}
};
Sprite_Character.prototype.createHalfBodySprites = function () {
3 years ago
if (!this._upperBody) {
this._upperBody = new Sprite();
this._upperBody.anchor.x = 0.5;
this._upperBody.anchor.y = 1;
this.addChild(this._upperBody);
}
if (!this._lowerBody) {
this._lowerBody = new Sprite();
this._lowerBody.anchor.x = 0.5;
this._lowerBody.anchor.y = 1;
this._lowerBody.opacity = 128;
this.addChild(this._lowerBody);
}
};
Sprite_Character.prototype.updatePosition = function () {
3 years ago
this.x = this._character.screenX();
this.y = this._character.screenY();
this.z = this._character.screenZ();
};
Sprite_Character.prototype.updateAnimation = function () {
3 years ago
this.setupAnimation();
if (!this.isAnimationPlaying()) {
this._character.endAnimation();
}
if (!this.isBalloonPlaying()) {
this._character.endBalloon();
}
};
Sprite_Character.prototype.updateOther = function () {
3 years ago
this.opacity = this._character.opacity();
this.blendMode = this._character.blendMode();
this._bushDepth = this._character.bushDepth();
};
Sprite_Character.prototype.setupAnimation = function () {
3 years ago
if (this._character.animationId() > 0) {
var animation = $dataAnimations[this._character.animationId()];
this.startAnimation(animation, false, 0);
this._character.startAnimation();
}
};
Sprite_Character.prototype.setupBalloon = function () {
3 years ago
if (this._character.balloonId() > 0) {
this.startBalloon();
this._character.startBalloon();
}
};
Sprite_Character.prototype.startBalloon = function () {
3 years ago
if (!this._balloonSprite) {
this._balloonSprite = new Sprite_Balloon();
}
this._balloonSprite.setup(this._character.balloonId());
this.parent.addChild(this._balloonSprite);
};
Sprite_Character.prototype.updateBalloon = function () {
3 years ago
this.setupBalloon();
if (this._balloonSprite) {
this._balloonSprite.x = this.x;
this._balloonSprite.y = this.y - this.height;
if (!this._balloonSprite.isPlaying()) {
this.endBalloon();
}
}
};
Sprite_Character.prototype.endBalloon = function () {
3 years ago
if (this._balloonSprite) {
this.parent.removeChild(this._balloonSprite);
this._balloonSprite = null;
}
};
Sprite_Character.prototype.isBalloonPlaying = function () {
3 years ago
return !!this._balloonSprite;
};
//-----------------------------------------------------------------------------
// Sprite_Battler
//
// The superclass of Sprite_Actor and Sprite_Enemy.
function Sprite_Battler() {
this.initialize.apply(this, arguments);
}
Sprite_Battler.prototype = Object.create(Sprite_Base.prototype);
Sprite_Battler.prototype.constructor = Sprite_Battler;
Sprite_Battler.prototype.initialize = function (battler) {
3 years ago
Sprite_Base.prototype.initialize.call(this);
this.initMembers();
this.setBattler(battler);
};
Sprite_Battler.prototype.initMembers = function () {
3 years ago
this.anchor.x = 0.5;
this.anchor.y = 1;
this._battler = null;
this._damages = [];
this._homeX = 0;
this._homeY = 0;
this._offsetX = 0;
this._offsetY = 0;
this._targetOffsetX = NaN;
this._targetOffsetY = NaN;
this._movementDuration = 0;
this._selectionEffectCount = 0;
};
Sprite_Battler.prototype.setBattler = function (battler) {
3 years ago
this._battler = battler;
};
Sprite_Battler.prototype.setHome = function (x, y) {
3 years ago
this._homeX = x;
this._homeY = y;
this.updatePosition();
};
Sprite_Battler.prototype.update = function () {
3 years ago
Sprite_Base.prototype.update.call(this);
if (this._battler) {
this.updateMain();
this.updateAnimation();
this.updateDamagePopup();
this.updateSelectionEffect();
} else {
this.bitmap = null;
}
};
Sprite_Battler.prototype.updateVisibility = function () {
3 years ago
Sprite_Base.prototype.updateVisibility.call(this);
if (!this._battler || !this._battler.isSpriteVisible()) {
this.visible = false;
}
};
Sprite_Battler.prototype.updateMain = function () {
3 years ago
if (this._battler.isSpriteVisible()) {
this.updateBitmap();
this.updateFrame();
}
this.updateMove();
this.updatePosition();
};
Sprite_Battler.prototype.updateBitmap = function () {};
3 years ago
Sprite_Battler.prototype.updateFrame = function () {};
3 years ago
Sprite_Battler.prototype.updateMove = function () {
3 years ago
if (this._movementDuration > 0) {
var d = this._movementDuration;
this._offsetX = (this._offsetX * (d - 1) + this._targetOffsetX) / d;
this._offsetY = (this._offsetY * (d - 1) + this._targetOffsetY) / d;
this._movementDuration--;
if (this._movementDuration === 0) {
this.onMoveEnd();
}
}
};
Sprite_Battler.prototype.updatePosition = function () {
3 years ago
this.x = this._homeX + this._offsetX;
this.y = this._homeY + this._offsetY;
};
Sprite_Battler.prototype.updateAnimation = function () {
3 years ago
this.setupAnimation();
};
Sprite_Battler.prototype.updateDamagePopup = function () {
3 years ago
this.setupDamagePopup();
if (this._damages.length > 0) {
for (var i = 0; i < this._damages.length; i++) {
this._damages[i].update();
}
if (!this._damages[0].isPlaying()) {
this.parent.removeChild(this._damages[0]);
this._damages.shift();
}
}
};
Sprite_Battler.prototype.updateSelectionEffect = function () {
3 years ago
var target = this._effectTarget;
if (this._battler.isSelected()) {
this._selectionEffectCount++;
if (this._selectionEffectCount % 30 < 15) {
target.setBlendColor([255, 255, 255, 64]);
} else {
target.setBlendColor([0, 0, 0, 0]);
}
} else if (this._selectionEffectCount > 0) {
this._selectionEffectCount = 0;
target.setBlendColor([0, 0, 0, 0]);
}
};
Sprite_Battler.prototype.setupAnimation = function () {
3 years ago
while (this._battler.isAnimationRequested()) {
var data = this._battler.shiftAnimation();
var animation = $dataAnimations[data.animationId];
var mirror = data.mirror;
var delay = animation.position === 3 ? 0 : data.delay;
this.startAnimation(animation, mirror, delay);
for (var i = 0; i < this._animationSprites.length; i++) {
var sprite = this._animationSprites[i];
sprite.visible = this._battler.isSpriteVisible();
}
}
};
Sprite_Battler.prototype.setupDamagePopup = function () {
3 years ago
if (this._battler.isDamagePopupRequested()) {
if (this._battler.isSpriteVisible()) {
var sprite = new Sprite_Damage();
sprite.x = this.x + this.damageOffsetX();
sprite.y = this.y + this.damageOffsetY();
sprite.setup(this._battler);
this._damages.push(sprite);
this.parent.addChild(sprite);
}
this._battler.clearDamagePopup();
this._battler.clearResult();
}
};
Sprite_Battler.prototype.damageOffsetX = function () {
3 years ago
return 0;
};
Sprite_Battler.prototype.damageOffsetY = function () {
3 years ago
return 0;
};
Sprite_Battler.prototype.startMove = function (x, y, duration) {
3 years ago
if (this._targetOffsetX !== x || this._targetOffsetY !== y) {
this._targetOffsetX = x;
this._targetOffsetY = y;
this._movementDuration = duration;
if (duration === 0) {
this._offsetX = x;
this._offsetY = y;
}
}
};
Sprite_Battler.prototype.onMoveEnd = function () {};
3 years ago
Sprite_Battler.prototype.isEffecting = function () {
3 years ago
return false;
};
Sprite_Battler.prototype.isMoving = function () {
3 years ago
return this._movementDuration > 0;
};
Sprite_Battler.prototype.inHomePosition = function () {
3 years ago
return this._offsetX === 0 && this._offsetY === 0;
};
//-----------------------------------------------------------------------------
// Sprite_Actor
//
// The sprite for displaying an actor.
function Sprite_Actor() {
this.initialize.apply(this, arguments);
}
Sprite_Actor.prototype = Object.create(Sprite_Battler.prototype);
Sprite_Actor.prototype.constructor = Sprite_Actor;
Sprite_Actor.MOTIONS = {
walk: { index: 0, loop: true },
wait: { index: 1, loop: true },
chant: { index: 2, loop: true },
guard: { index: 3, loop: true },
damage: { index: 4, loop: false },
evade: { index: 5, loop: false },
thrust: { index: 6, loop: false },
swing: { index: 7, loop: false },
missile: { index: 8, loop: false },
skill: { index: 9, loop: false },
spell: { index: 10, loop: false },
item: { index: 11, loop: false },
escape: { index: 12, loop: true },
victory: { index: 13, loop: true },
dying: { index: 14, loop: true },
abnormal: { index: 15, loop: true },
sleep: { index: 16, loop: true },
dead: { index: 17, loop: true },
};
Sprite_Actor.prototype.initialize = function (battler) {
3 years ago
Sprite_Battler.prototype.initialize.call(this, battler);
this.moveToStartPosition();
};
Sprite_Actor.prototype.initMembers = function () {
3 years ago
Sprite_Battler.prototype.initMembers.call(this);
this._battlerName = "";
3 years ago
this._motion = null;
this._motionCount = 0;
this._pattern = 0;
this.createShadowSprite();
this.createWeaponSprite();
this.createMainSprite();
this.createStateSprite();
};
Sprite_Actor.prototype.createMainSprite = function () {
3 years ago
this._mainSprite = new Sprite_Base();
this._mainSprite.anchor.x = 0.5;
this._mainSprite.anchor.y = 1;
this.addChild(this._mainSprite);
this._effectTarget = this._mainSprite;
};
Sprite_Actor.prototype.createShadowSprite = function () {
3 years ago
this._shadowSprite = new Sprite();
this._shadowSprite.bitmap = ImageManager.loadSystem("Shadow2");
3 years ago
this._shadowSprite.anchor.x = 0.5;
this._shadowSprite.anchor.y = 0.5;
this._shadowSprite.y = -2;
this.addChild(this._shadowSprite);
};
Sprite_Actor.prototype.createWeaponSprite = function () {
3 years ago
this._weaponSprite = new Sprite_Weapon();
this.addChild(this._weaponSprite);
};
Sprite_Actor.prototype.createStateSprite = function () {
3 years ago
this._stateSprite = new Sprite_StateOverlay();
this.addChild(this._stateSprite);
};
Sprite_Actor.prototype.setBattler = function (battler) {
3 years ago
Sprite_Battler.prototype.setBattler.call(this, battler);
var changed = battler !== this._actor;
3 years ago
if (changed) {
this._actor = battler;
if (battler) {
this.setActorHome(battler.index());
}
this.startEntryMotion();
this._stateSprite.setup(battler);
}
};
Sprite_Actor.prototype.moveToStartPosition = function () {
3 years ago
this.startMove(300, 0, 0);
};
Sprite_Actor.prototype.setActorHome = function (index) {
3 years ago
this.setHome(600 + index * 32, 280 + index * 48);
};
Sprite_Actor.prototype.update = function () {
3 years ago
Sprite_Battler.prototype.update.call(this);
this.updateShadow();
if (this._actor) {
this.updateMotion();
}
};
Sprite_Actor.prototype.updateShadow = function () {
3 years ago
this._shadowSprite.visible = !!this._actor;
};
Sprite_Actor.prototype.updateMain = function () {
3 years ago
Sprite_Battler.prototype.updateMain.call(this);
if (this._actor.isSpriteVisible() && !this.isMoving()) {
this.updateTargetPosition();
}
};
Sprite_Actor.prototype.setupMotion = function () {
3 years ago
if (this._actor.isMotionRequested()) {
this.startMotion(this._actor.motionType());
this._actor.clearMotion();
}
};
Sprite_Actor.prototype.setupWeaponAnimation = function () {
3 years ago
if (this._actor.isWeaponAnimationRequested()) {
this._weaponSprite.setup(this._actor.weaponImageId());
this._actor.clearWeaponAnimation();
}
};
Sprite_Actor.prototype.startMotion = function (motionType) {
3 years ago
var newMotion = Sprite_Actor.MOTIONS[motionType];
if (this._motion !== newMotion) {
this._motion = newMotion;
this._motionCount = 0;
this._pattern = 0;
}
};
Sprite_Actor.prototype.updateTargetPosition = function () {
3 years ago
if (this._actor.isInputting() || this._actor.isActing()) {
this.stepForward();
} else if (this._actor.canMove() && BattleManager.isEscaped()) {
this.retreat();
} else if (!this.inHomePosition()) {
this.stepBack();
}
};
Sprite_Actor.prototype.updateBitmap = function () {
3 years ago
Sprite_Battler.prototype.updateBitmap.call(this);
var name = this._actor.battlerName();
if (this._battlerName !== name) {
this._battlerName = name;
this._mainSprite.bitmap = ImageManager.loadSvActor(name);
}
};
Sprite_Actor.prototype.updateFrame = function () {
3 years ago
Sprite_Battler.prototype.updateFrame.call(this);
var bitmap = this._mainSprite.bitmap;
if (bitmap) {
var motionIndex = this._motion ? this._motion.index : 0;
var pattern = this._pattern < 3 ? this._pattern : 1;
var cw = bitmap.width / 9;
var ch = bitmap.height / 6;
var cx = Math.floor(motionIndex / 6) * 3 + pattern;
var cy = motionIndex % 6;
this._mainSprite.setFrame(cx * cw, cy * ch, cw, ch);
}
};
Sprite_Actor.prototype.updateMove = function () {
3 years ago
var bitmap = this._mainSprite.bitmap;
if (!bitmap || bitmap.isReady()) {
Sprite_Battler.prototype.updateMove.call(this);
}
};
Sprite_Actor.prototype.updateMotion = function () {
3 years ago
this.setupMotion();
this.setupWeaponAnimation();
if (this._actor.isMotionRefreshRequested()) {
this.refreshMotion();
this._actor.clearMotion();
}
this.updateMotionCount();
};
Sprite_Actor.prototype.updateMotionCount = function () {
3 years ago
if (this._motion && ++this._motionCount >= this.motionSpeed()) {
if (this._motion.loop) {
this._pattern = (this._pattern + 1) % 4;
} else if (this._pattern < 2) {
this._pattern++;
} else {
this.refreshMotion();
}
this._motionCount = 0;
}
};
Sprite_Actor.prototype.motionSpeed = function () {
3 years ago
return 12;
};
Sprite_Actor.prototype.refreshMotion = function () {
3 years ago
var actor = this._actor;
var motionGuard = Sprite_Actor.MOTIONS["guard"];
3 years ago
if (actor) {
if (this._motion === motionGuard && !BattleManager.isInputting()) {
return;
3 years ago
}
var stateMotion = actor.stateMotionIndex();
if (actor.isInputting() || actor.isActing()) {
this.startMotion("walk");
3 years ago
} else if (stateMotion === 3) {
this.startMotion("dead");
3 years ago
} else if (stateMotion === 2) {
this.startMotion("sleep");
3 years ago
} else if (actor.isChanting()) {
this.startMotion("chant");
3 years ago
} else if (actor.isGuard() || actor.isGuardWaiting()) {
this.startMotion("guard");
3 years ago
} else if (stateMotion === 1) {
this.startMotion("abnormal");
3 years ago
} else if (actor.isDying()) {
this.startMotion("dying");
3 years ago
} else if (actor.isUndecided()) {
this.startMotion("walk");
3 years ago
} else {
this.startMotion("wait");
3 years ago
}
}
};
Sprite_Actor.prototype.startEntryMotion = function () {
3 years ago
if (this._actor && this._actor.canMove()) {
this.startMotion("walk");
3 years ago
this.startMove(0, 0, 30);
} else if (!this.isMoving()) {
this.refreshMotion();
this.startMove(0, 0, 0);
}
};
Sprite_Actor.prototype.stepForward = function () {
3 years ago
this.startMove(-48, 0, 12);
};
Sprite_Actor.prototype.stepBack = function () {
3 years ago
this.startMove(0, 0, 12);
};
Sprite_Actor.prototype.retreat = function () {
3 years ago
this.startMove(300, 0, 30);
};
Sprite_Actor.prototype.onMoveEnd = function () {
3 years ago
Sprite_Battler.prototype.onMoveEnd.call(this);
if (!BattleManager.isBattleEnd()) {
this.refreshMotion();
}
};
Sprite_Actor.prototype.damageOffsetX = function () {
3 years ago
return -32;
};
Sprite_Actor.prototype.damageOffsetY = function () {
3 years ago
return 0;
};
//-----------------------------------------------------------------------------
// Sprite_Enemy
//
// The sprite for displaying an enemy.
function Sprite_Enemy() {
this.initialize.apply(this, arguments);
}
Sprite_Enemy.prototype = Object.create(Sprite_Battler.prototype);
Sprite_Enemy.prototype.constructor = Sprite_Enemy;
Sprite_Enemy.prototype.initialize = function (battler) {
3 years ago
Sprite_Battler.prototype.initialize.call(this, battler);
};
Sprite_Enemy.prototype.initMembers = function () {
3 years ago
Sprite_Battler.prototype.initMembers.call(this);
this._enemy = null;
this._appeared = false;
this._battlerName = "";
3 years ago
this._battlerHue = 0;
this._effectType = null;
this._effectDuration = 0;
this._shake = 0;
this.createStateIconSprite();
};
Sprite_Enemy.prototype.createStateIconSprite = function () {
3 years ago
this._stateIconSprite = new Sprite_StateIcon();
this.addChild(this._stateIconSprite);
};
Sprite_Enemy.prototype.setBattler = function (battler) {
3 years ago
Sprite_Battler.prototype.setBattler.call(this, battler);
this._enemy = battler;
this.setHome(battler.screenX(), battler.screenY());
this._stateIconSprite.setup(battler);
};
Sprite_Enemy.prototype.update = function () {
3 years ago
Sprite_Battler.prototype.update.call(this);
if (this._enemy) {
this.updateEffect();
this.updateStateSprite();
}
};
Sprite_Enemy.prototype.updateBitmap = function () {
3 years ago
Sprite_Battler.prototype.updateBitmap.call(this);
var name = this._enemy.battlerName();
var hue = this._enemy.battlerHue();
if (this._battlerName !== name || this._battlerHue !== hue) {
this._battlerName = name;
this._battlerHue = hue;
this.loadBitmap(name, hue);
this.initVisibility();
}
};
Sprite_Enemy.prototype.loadBitmap = function (name, hue) {
3 years ago
if ($gameSystem.isSideView()) {
this.bitmap = ImageManager.loadSvEnemy(name, hue);
} else {
this.bitmap = ImageManager.loadEnemy(name, hue);
}
};
Sprite_Enemy.prototype.updateFrame = function () {
3 years ago
Sprite_Battler.prototype.updateFrame.call(this);
var frameHeight = this.bitmap.height;
if (this._effectType === "bossCollapse") {
3 years ago
frameHeight = this._effectDuration;
}
this.setFrame(0, 0, this.bitmap.width, frameHeight);
};
Sprite_Enemy.prototype.updatePosition = function () {
3 years ago
Sprite_Battler.prototype.updatePosition.call(this);
this.x += this._shake;
};
Sprite_Enemy.prototype.updateStateSprite = function () {
3 years ago
this._stateIconSprite.y = -Math.round((this.bitmap.height + 40) * 0.9);
if (this._stateIconSprite.y < 20 - this.y) {
this._stateIconSprite.y = 20 - this.y;
}
};
Sprite_Enemy.prototype.initVisibility = function () {
3 years ago
this._appeared = this._enemy.isAlive();
if (!this._appeared) {
this.opacity = 0;
}
};
Sprite_Enemy.prototype.setupEffect = function () {
3 years ago
if (this._appeared && this._enemy.isEffectRequested()) {
this.startEffect(this._enemy.effectType());
this._enemy.clearEffect();
}
if (!this._appeared && this._enemy.isAlive()) {
this.startEffect("appear");
3 years ago
} else if (this._appeared && this._enemy.isHidden()) {
this.startEffect("disappear");
3 years ago
}
};
Sprite_Enemy.prototype.startEffect = function (effectType) {
3 years ago
this._effectType = effectType;
switch (this._effectType) {
case "appear":
this.startAppear();
break;
case "disappear":
this.startDisappear();
break;
case "whiten":
this.startWhiten();
break;
case "blink":
this.startBlink();
break;
case "collapse":
this.startCollapse();
break;
case "bossCollapse":
this.startBossCollapse();
break;
case "instantCollapse":
this.startInstantCollapse();
break;
3 years ago
}
this.revertToNormal();
};
Sprite_Enemy.prototype.startAppear = function () {
3 years ago
this._effectDuration = 16;
this._appeared = true;
};
Sprite_Enemy.prototype.startDisappear = function () {
3 years ago
this._effectDuration = 32;
this._appeared = false;
};
Sprite_Enemy.prototype.startWhiten = function () {
3 years ago
this._effectDuration = 16;
};
Sprite_Enemy.prototype.startBlink = function () {
3 years ago
this._effectDuration = 20;
};
Sprite_Enemy.prototype.startCollapse = function () {
3 years ago
this._effectDuration = 32;
this._appeared = false;
};
Sprite_Enemy.prototype.startBossCollapse = function () {
3 years ago
this._effectDuration = this.bitmap.height;
this._appeared = false;
};
Sprite_Enemy.prototype.startInstantCollapse = function () {
3 years ago
this._effectDuration = 16;
this._appeared = false;
};
Sprite_Enemy.prototype.updateEffect = function () {
3 years ago
this.setupEffect();
if (this._effectDuration > 0) {
this._effectDuration--;
switch (this._effectType) {
case "whiten":
this.updateWhiten();
break;
case "blink":
this.updateBlink();
break;
case "appear":
this.updateAppear();
break;
case "disappear":
this.updateDisappear();
break;
case "collapse":
this.updateCollapse();
break;
case "bossCollapse":
this.updateBossCollapse();
break;
case "instantCollapse":
this.updateInstantCollapse();
break;
3 years ago
}
if (this._effectDuration === 0) {
this._effectType = null;
}
}
};
Sprite_Enemy.prototype.isEffecting = function () {
3 years ago
return this._effectType !== null;
};
Sprite_Enemy.prototype.revertToNormal = function () {
3 years ago
this._shake = 0;
this.blendMode = 0;
this.opacity = 255;
this.setBlendColor([0, 0, 0, 0]);
};
Sprite_Enemy.prototype.updateWhiten = function () {
3 years ago
var alpha = 128 - (16 - this._effectDuration) * 10;
this.setBlendColor([255, 255, 255, alpha]);
};
Sprite_Enemy.prototype.updateBlink = function () {
this.opacity = this._effectDuration % 10 < 5 ? 255 : 0;
3 years ago
};
Sprite_Enemy.prototype.updateAppear = function () {
3 years ago
this.opacity = (16 - this._effectDuration) * 16;
};
Sprite_Enemy.prototype.updateDisappear = function () {
3 years ago
this.opacity = 256 - (32 - this._effectDuration) * 10;
};
Sprite_Enemy.prototype.updateCollapse = function () {
3 years ago
this.blendMode = Graphics.BLEND_ADD;
this.setBlendColor([255, 128, 128, 128]);
this.opacity *= this._effectDuration / (this._effectDuration + 1);
};
Sprite_Enemy.prototype.updateBossCollapse = function () {
this._shake = (this._effectDuration % 2) * 4 - 2;
3 years ago
this.blendMode = Graphics.BLEND_ADD;
this.opacity *= this._effectDuration / (this._effectDuration + 1);
this.setBlendColor([255, 255, 255, 255 - this.opacity]);
if (this._effectDuration % 20 === 19) {
SoundManager.playBossCollapse2();
}
};
Sprite_Enemy.prototype.updateInstantCollapse = function () {
3 years ago
this.opacity = 0;
};
Sprite_Enemy.prototype.damageOffsetX = function () {
3 years ago
return 0;
};
Sprite_Enemy.prototype.damageOffsetY = function () {
3 years ago
return -8;
};
//-----------------------------------------------------------------------------
// Sprite_Animation
//
// The sprite for displaying an animation.
function Sprite_Animation() {
this.initialize.apply(this, arguments);
}
Sprite_Animation.prototype = Object.create(Sprite.prototype);
Sprite_Animation.prototype.constructor = Sprite_Animation;
Sprite_Animation._checker1 = {};
Sprite_Animation._checker2 = {};
Sprite_Animation.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this._reduceArtifacts = true;
this.initMembers();
};
Sprite_Animation.prototype.initMembers = function () {
3 years ago
this._target = null;
this._animation = null;
this._mirror = false;
this._delay = 0;
this._rate = 4;
this._duration = 0;
this._flashColor = [0, 0, 0, 0];
this._flashDuration = 0;
this._screenFlashDuration = 0;
this._hidingDuration = 0;
this._bitmap1 = null;
this._bitmap2 = null;
this._cellSprites = [];
this._screenFlashSprite = null;
this._duplicated = false;
this.z = 8;
};
Sprite_Animation.prototype.setup = function (target, animation, mirror, delay) {
3 years ago
this._target = target;
this._animation = animation;
this._mirror = mirror;
this._delay = delay;
if (this._animation) {
this.remove();
this.setupRate();
this.setupDuration();
this.loadBitmaps();
this.createSprites();
}
};
Sprite_Animation.prototype.remove = function () {
3 years ago
if (this.parent && this.parent.removeChild(this)) {
this._target.setBlendColor([0, 0, 0, 0]);
this._target.show();
}
};
Sprite_Animation.prototype.setupRate = function () {
3 years ago
this._rate = 4;
};
Sprite_Animation.prototype.setupDuration = function () {
3 years ago
this._duration = this._animation.frames.length * this._rate + 1;
};
Sprite_Animation.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateMain();
this.updateFlash();
this.updateScreenFlash();
this.updateHiding();
Sprite_Animation._checker1 = {};
Sprite_Animation._checker2 = {};
};
Sprite_Animation.prototype.updateFlash = function () {
3 years ago
if (this._flashDuration > 0) {
var d = this._flashDuration--;
this._flashColor[3] *= (d - 1) / d;
this._target.setBlendColor(this._flashColor);
}
};
Sprite_Animation.prototype.updateScreenFlash = function () {
3 years ago
if (this._screenFlashDuration > 0) {
var d = this._screenFlashDuration--;
if (this._screenFlashSprite) {
this._screenFlashSprite.x = -this.absoluteX();
this._screenFlashSprite.y = -this.absoluteY();
this._screenFlashSprite.opacity *= (d - 1) / d;
this._screenFlashSprite.visible = this._screenFlashDuration > 0;
3 years ago
}
}
};
Sprite_Animation.prototype.absoluteX = function () {
3 years ago
var x = 0;
var object = this;
while (object) {
x += object.x;
object = object.parent;
}
return x;
};
Sprite_Animation.prototype.absoluteY = function () {
3 years ago
var y = 0;
var object = this;
while (object) {
y += object.y;
object = object.parent;
}
return y;
};
Sprite_Animation.prototype.updateHiding = function () {
3 years ago
if (this._hidingDuration > 0) {
this._hidingDuration--;
if (this._hidingDuration === 0) {
this._target.show();
}
}
};
Sprite_Animation.prototype.isPlaying = function () {
3 years ago
return this._duration > 0;
};
Sprite_Animation.prototype.loadBitmaps = function () {
3 years ago
var name1 = this._animation.animation1Name;
var name2 = this._animation.animation2Name;
var hue1 = this._animation.animation1Hue;
var hue2 = this._animation.animation2Hue;
this._bitmap1 = ImageManager.loadAnimation(name1, hue1);
this._bitmap2 = ImageManager.loadAnimation(name2, hue2);
};
Sprite_Animation.prototype.isReady = function () {
3 years ago
return this._bitmap1 && this._bitmap1.isReady() && this._bitmap2 && this._bitmap2.isReady();
};
Sprite_Animation.prototype.createSprites = function () {
3 years ago
if (!Sprite_Animation._checker2[this._animation]) {
this.createCellSprites();
if (this._animation.position === 3) {
Sprite_Animation._checker2[this._animation] = true;
}
this.createScreenFlashSprite();
}
if (Sprite_Animation._checker1[this._animation]) {
this._duplicated = true;
} else {
this._duplicated = false;
if (this._animation.position === 3) {
Sprite_Animation._checker1[this._animation] = true;
}
}
};
Sprite_Animation.prototype.createCellSprites = function () {
3 years ago
this._cellSprites = [];
for (var i = 0; i < 16; i++) {
var sprite = new Sprite();
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
this._cellSprites.push(sprite);
this.addChild(sprite);
}
};
Sprite_Animation.prototype.createScreenFlashSprite = function () {
3 years ago
this._screenFlashSprite = new ScreenSprite();
this.addChild(this._screenFlashSprite);
};
Sprite_Animation.prototype.updateMain = function () {
3 years ago
if (this.isPlaying() && this.isReady()) {
if (this._delay > 0) {
this._delay--;
} else {
this._duration--;
this.updatePosition();
if (this._duration % this._rate === 0) {
this.updateFrame();
}
}
}
};
Sprite_Animation.prototype.updatePosition = function () {
3 years ago
if (this._animation.position === 3) {
this.x = this.parent.width / 2;
this.y = this.parent.height / 2;
} else {
var parent = this._target.parent;
var grandparent = parent ? parent.parent : null;
this.x = this._target.x;
this.y = this._target.y;
if (this.parent === grandparent) {
this.x += parent.x;
this.y += parent.y;
}
if (this._animation.position === 0) {
this.y -= this._target.height;
} else if (this._animation.position === 1) {
this.y -= this._target.height / 2;
}
}
};
Sprite_Animation.prototype.updateFrame = function () {
3 years ago
if (this._duration > 0) {
var frameIndex = this.currentFrameIndex();
this.updateAllCellSprites(this._animation.frames[frameIndex]);
this._animation.timings.forEach(function (timing) {
3 years ago
if (timing.frame === frameIndex) {
this.processTimingData(timing);
}
}, this);
}
};
Sprite_Animation.prototype.currentFrameIndex = function () {
return this._animation.frames.length - Math.floor((this._duration + this._rate - 1) / this._rate);
3 years ago
};
Sprite_Animation.prototype.updateAllCellSprites = function (frame) {
3 years ago
for (var i = 0; i < this._cellSprites.length; i++) {
var sprite = this._cellSprites[i];
if (i < frame.length) {
this.updateCellSprite(sprite, frame[i]);
} else {
sprite.visible = false;
}
}
};
Sprite_Animation.prototype.updateCellSprite = function (sprite, cell) {
3 years ago
var pattern = cell[0];
if (pattern >= 0) {
var sx = (pattern % 5) * 192;
var sy = Math.floor((pattern % 100) / 5) * 192;
3 years ago
var mirror = this._mirror;
sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2;
sprite.setFrame(sx, sy, 192, 192);
sprite.x = cell[1];
sprite.y = cell[2];
sprite.rotation = (cell[4] * Math.PI) / 180;
3 years ago
sprite.scale.x = cell[3] / 100;
if (cell[5]) {
3 years ago
sprite.scale.x *= -1;
}
if (mirror) {
3 years ago
sprite.x *= -1;
sprite.rotation *= -1;
sprite.scale.x *= -1;
}
sprite.scale.y = cell[3] / 100;
sprite.opacity = cell[6];
sprite.blendMode = cell[7];
sprite.visible = true;
} else {
sprite.visible = false;
}
};
Sprite_Animation.prototype.processTimingData = function (timing) {
3 years ago
var duration = timing.flashDuration * this._rate;
switch (timing.flashScope) {
case 1:
this.startFlash(timing.flashColor, duration);
break;
case 2:
this.startScreenFlash(timing.flashColor, duration);
break;
case 3:
this.startHiding(duration);
break;
3 years ago
}
if (!this._duplicated && timing.se) {
AudioManager.playSe(timing.se);
}
};
Sprite_Animation.prototype.startFlash = function (color, duration) {
3 years ago
this._flashColor = color.clone();
this._flashDuration = duration;
};
Sprite_Animation.prototype.startScreenFlash = function (color, duration) {
3 years ago
this._screenFlashDuration = duration;
if (this._screenFlashSprite) {
this._screenFlashSprite.setColor(color[0], color[1], color[2]);
this._screenFlashSprite.opacity = color[3];
}
};
Sprite_Animation.prototype.startHiding = function (duration) {
3 years ago
this._hidingDuration = duration;
this._target.hide();
};
//-----------------------------------------------------------------------------
// Sprite_Damage
//
// The sprite for displaying a popup damage.
function Sprite_Damage() {
this.initialize.apply(this, arguments);
}
Sprite_Damage.prototype = Object.create(Sprite.prototype);
Sprite_Damage.prototype.constructor = Sprite_Damage;
Sprite_Damage.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this._duration = 90;
this._flashColor = [0, 0, 0, 0];
this._flashDuration = 0;
this._damageBitmap = ImageManager.loadSystem("Damage");
3 years ago
};
Sprite_Damage.prototype.setup = function (target) {
3 years ago
var result = target.result();
if (result.missed || result.evaded) {
this.createMiss();
} else if (result.hpAffected) {
this.createDigits(0, result.hpDamage);
} else if (target.isAlive() && result.mpDamage !== 0) {
this.createDigits(2, result.mpDamage);
}
if (result.critical) {
this.setupCriticalEffect();
}
};
Sprite_Damage.prototype.setupCriticalEffect = function () {
3 years ago
this._flashColor = [255, 0, 0, 160];
this._flashDuration = 60;
};
Sprite_Damage.prototype.digitWidth = function () {
3 years ago
return this._damageBitmap ? this._damageBitmap.width / 10 : 0;
};
Sprite_Damage.prototype.digitHeight = function () {
3 years ago
return this._damageBitmap ? this._damageBitmap.height / 5 : 0;
};
Sprite_Damage.prototype.createMiss = function () {
3 years ago
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 4 * h, 4 * w, h);
sprite.dy = 0;
};
Sprite_Damage.prototype.createDigits = function (baseRow, value) {
3 years ago
var string = Math.abs(value).toString();
var row = baseRow + (value < 0 ? 1 : 0);
var w = this.digitWidth();
var h = this.digitHeight();
for (var i = 0; i < string.length; i++) {
var sprite = this.createChildSprite();
var n = Number(string[i]);
sprite.setFrame(n * w, row * h, w, h);
sprite.x = (i - (string.length - 1) / 2) * w;
sprite.dy = -i;
}
};
Sprite_Damage.prototype.createChildSprite = function () {
3 years ago
var sprite = new Sprite();
sprite.bitmap = this._damageBitmap;
sprite.anchor.x = 0.5;
sprite.anchor.y = 1;
sprite.y = -40;
sprite.ry = sprite.y;
this.addChild(sprite);
return sprite;
};
Sprite_Damage.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
if (this._duration > 0) {
this._duration--;
for (var i = 0; i < this.children.length; i++) {
this.updateChild(this.children[i]);
}
}
this.updateFlash();
this.updateOpacity();
};
Sprite_Damage.prototype.updateChild = function (sprite) {
3 years ago
sprite.dy += 0.5;
sprite.ry += sprite.dy;
if (sprite.ry >= 0) {
sprite.ry = 0;
sprite.dy *= -0.6;
}
sprite.y = Math.round(sprite.ry);
sprite.setBlendColor(this._flashColor);
};
Sprite_Damage.prototype.updateFlash = function () {
3 years ago
if (this._flashDuration > 0) {
var d = this._flashDuration--;
this._flashColor[3] *= (d - 1) / d;
}
};
Sprite_Damage.prototype.updateOpacity = function () {
3 years ago
if (this._duration < 10) {
this.opacity = (255 * this._duration) / 10;
3 years ago
}
};
Sprite_Damage.prototype.isPlaying = function () {
3 years ago
return this._duration > 0;
};
//-----------------------------------------------------------------------------
// Sprite_StateIcon
//
// The sprite for displaying state icons.
function Sprite_StateIcon() {
this.initialize.apply(this, arguments);
}
Sprite_StateIcon.prototype = Object.create(Sprite.prototype);
Sprite_StateIcon.prototype.constructor = Sprite_StateIcon;
Sprite_StateIcon.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
Sprite_StateIcon._iconWidth = 32;
3 years ago
Sprite_StateIcon._iconHeight = 32;
Sprite_StateIcon.prototype.initMembers = function () {
3 years ago
this._battler = null;
this._iconIndex = 0;
this._animationCount = 0;
this._animationIndex = 0;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
};
Sprite_StateIcon.prototype.loadBitmap = function () {
this.bitmap = ImageManager.loadSystem("IconSet");
3 years ago
this.setFrame(0, 0, 0, 0);
};
Sprite_StateIcon.prototype.setup = function (battler) {
3 years ago
this._battler = battler;
};
Sprite_StateIcon.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updateIcon();
this.updateFrame();
this._animationCount = 0;
}
};
Sprite_StateIcon.prototype.animationWait = function () {
3 years ago
return 40;
};
Sprite_StateIcon.prototype.updateIcon = function () {
3 years ago
var icons = [];
if (this._battler && this._battler.isAlive()) {
icons = this._battler.allIcons();
}
if (icons.length > 0) {
this._animationIndex++;
if (this._animationIndex >= icons.length) {
this._animationIndex = 0;
}
this._iconIndex = icons[this._animationIndex];
} else {
this._animationIndex = 0;
this._iconIndex = 0;
}
};
Sprite_StateIcon.prototype.updateFrame = function () {
3 years ago
var pw = Sprite_StateIcon._iconWidth;
var ph = Sprite_StateIcon._iconHeight;
var sx = (this._iconIndex % 16) * pw;
3 years ago
var sy = Math.floor(this._iconIndex / 16) * ph;
this.setFrame(sx, sy, pw, ph);
};
//-----------------------------------------------------------------------------
// Sprite_StateOverlay
//
// The sprite for displaying an overlay image for a state.
function Sprite_StateOverlay() {
this.initialize.apply(this, arguments);
}
Sprite_StateOverlay.prototype = Object.create(Sprite_Base.prototype);
Sprite_StateOverlay.prototype.constructor = Sprite_StateOverlay;
Sprite_StateOverlay.prototype.initialize = function () {
3 years ago
Sprite_Base.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
Sprite_StateOverlay.prototype.initMembers = function () {
3 years ago
this._battler = null;
this._overlayIndex = 0;
this._animationCount = 0;
this._pattern = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
};
Sprite_StateOverlay.prototype.loadBitmap = function () {
this.bitmap = ImageManager.loadSystem("States");
3 years ago
this.setFrame(0, 0, 0, 0);
};
Sprite_StateOverlay.prototype.setup = function (battler) {
3 years ago
this._battler = battler;
};
Sprite_StateOverlay.prototype.update = function () {
3 years ago
Sprite_Base.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updatePattern();
this.updateFrame();
this._animationCount = 0;
}
};
Sprite_StateOverlay.prototype.animationWait = function () {
3 years ago
return 8;
};
Sprite_StateOverlay.prototype.updatePattern = function () {
3 years ago
this._pattern++;
this._pattern %= 8;
if (this._battler) {
this._overlayIndex = this._battler.stateOverlayIndex();
}
};
Sprite_StateOverlay.prototype.updateFrame = function () {
3 years ago
if (this._overlayIndex > 0) {
var w = 96;
var h = 96;
var sx = this._pattern * w;
var sy = (this._overlayIndex - 1) * h;
this.setFrame(sx, sy, w, h);
} else {
this.setFrame(0, 0, 0, 0);
}
};
//-----------------------------------------------------------------------------
// Sprite_Weapon
//
// The sprite for displaying a weapon image for attacking.
function Sprite_Weapon() {
this.initialize.apply(this, arguments);
}
Sprite_Weapon.prototype = Object.create(Sprite_Base.prototype);
Sprite_Weapon.prototype.constructor = Sprite_Weapon;
Sprite_Weapon.prototype.initialize = function () {
3 years ago
Sprite_Base.prototype.initialize.call(this);
this.initMembers();
};
Sprite_Weapon.prototype.initMembers = function () {
3 years ago
this._weaponImageId = 0;
this._animationCount = 0;
this._pattern = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
this.x = -16;
};
Sprite_Weapon.prototype.setup = function (weaponImageId) {
3 years ago
this._weaponImageId = weaponImageId;
this._animationCount = 0;
this._pattern = 0;
this.loadBitmap();
this.updateFrame();
};
Sprite_Weapon.prototype.update = function () {
3 years ago
Sprite_Base.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updatePattern();
this.updateFrame();
this._animationCount = 0;
}
};
Sprite_Weapon.prototype.animationWait = function () {
3 years ago
return 12;
};
Sprite_Weapon.prototype.updatePattern = function () {
3 years ago
this._pattern++;
if (this._pattern >= 3) {
this._weaponImageId = 0;
}
};
Sprite_Weapon.prototype.loadBitmap = function () {
3 years ago
var pageId = Math.floor((this._weaponImageId - 1) / 12) + 1;
if (pageId >= 1) {
this.bitmap = ImageManager.loadSystem("Weapons" + pageId);
3 years ago
} else {
this.bitmap = ImageManager.loadSystem("");
3 years ago
}
};
Sprite_Weapon.prototype.updateFrame = function () {
3 years ago
if (this._weaponImageId > 0) {
var index = (this._weaponImageId - 1) % 12;
var w = 96;
var h = 64;
var sx = (Math.floor(index / 6) * 3 + this._pattern) * w;
var sy = Math.floor(index % 6) * h;
this.setFrame(sx, sy, w, h);
} else {
this.setFrame(0, 0, 0, 0);
}
};
Sprite_Weapon.prototype.isPlaying = function () {
3 years ago
return this._weaponImageId > 0;
};
//-----------------------------------------------------------------------------
// Sprite_Balloon
//
// The sprite for displaying a balloon icon.
function Sprite_Balloon() {
this.initialize.apply(this, arguments);
}
Sprite_Balloon.prototype = Object.create(Sprite_Base.prototype);
Sprite_Balloon.prototype.constructor = Sprite_Balloon;
Sprite_Balloon.prototype.initialize = function () {
3 years ago
Sprite_Base.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
Sprite_Balloon.prototype.initMembers = function () {
3 years ago
this._balloonId = 0;
this._duration = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
this.z = 7;
};
Sprite_Balloon.prototype.loadBitmap = function () {
this.bitmap = ImageManager.loadSystem("Balloon");
3 years ago
this.setFrame(0, 0, 0, 0);
};
Sprite_Balloon.prototype.setup = function (balloonId) {
3 years ago
this._balloonId = balloonId;
this._duration = 8 * this.speed() + this.waitTime();
};
Sprite_Balloon.prototype.update = function () {
3 years ago
Sprite_Base.prototype.update.call(this);
if (this._duration > 0) {
this._duration--;
if (this._duration > 0) {
this.updateFrame();
}
}
};
Sprite_Balloon.prototype.updateFrame = function () {
3 years ago
var w = 48;
var h = 48;
var sx = this.frameIndex() * w;
var sy = (this._balloonId - 1) * h;
this.setFrame(sx, sy, w, h);
};
Sprite_Balloon.prototype.speed = function () {
3 years ago
return 8;
};
Sprite_Balloon.prototype.waitTime = function () {
3 years ago
return 12;
};
Sprite_Balloon.prototype.frameIndex = function () {
3 years ago
var index = (this._duration - this.waitTime()) / this.speed();
return 7 - Math.max(Math.floor(index), 0);
};
Sprite_Balloon.prototype.isPlaying = function () {
3 years ago
return this._duration > 0;
};
//-----------------------------------------------------------------------------
// Sprite_Picture
//
// The sprite for displaying a picture.
function Sprite_Picture() {
this.initialize.apply(this, arguments);
}
Sprite_Picture.prototype = Object.create(Sprite.prototype);
Sprite_Picture.prototype.constructor = Sprite_Picture;
Sprite_Picture.prototype.initialize = function (pictureId) {
3 years ago
Sprite.prototype.initialize.call(this);
this._pictureId = pictureId;
this._pictureName = "";
3 years ago
this._isPicture = true;
this.update();
};
Sprite_Picture.prototype.picture = function () {
3 years ago
return $gameScreen.picture(this._pictureId);
};
Sprite_Picture.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateBitmap();
if (this.visible) {
this.updateOrigin();
this.updatePosition();
this.updateScale();
this.updateTone();
this.updateOther();
}
};
Sprite_Picture.prototype.updateBitmap = function () {
3 years ago
var picture = this.picture();
if (picture) {
var pictureName = picture.name();
if (this._pictureName !== pictureName) {
this._pictureName = pictureName;
this.loadBitmap();
}
this.visible = true;
} else {
this._pictureName = "";
3 years ago
this.bitmap = null;
this.visible = false;
}
};
Sprite_Picture.prototype.updateOrigin = function () {
3 years ago
var picture = this.picture();
if (picture.origin() === 0) {
this.anchor.x = 0;
this.anchor.y = 0;
} else {
this.anchor.x = 0.5;
this.anchor.y = 0.5;
}
};
Sprite_Picture.prototype.updatePosition = function () {
3 years ago
var picture = this.picture();
this.x = Math.floor(picture.x());
this.y = Math.floor(picture.y());
};
Sprite_Picture.prototype.updateScale = function () {
3 years ago
var picture = this.picture();
this.scale.x = picture.scaleX() / 100;
this.scale.y = picture.scaleY() / 100;
};
Sprite_Picture.prototype.updateTone = function () {
3 years ago
var picture = this.picture();
if (picture.tone()) {
this.setColorTone(picture.tone());
} else {
this.setColorTone([0, 0, 0, 0]);
}
};
Sprite_Picture.prototype.updateOther = function () {
3 years ago
var picture = this.picture();
this.opacity = picture.opacity();
this.blendMode = picture.blendMode();
this.rotation = (picture.angle() * Math.PI) / 180;
3 years ago
};
Sprite_Picture.prototype.loadBitmap = function () {
3 years ago
this.bitmap = ImageManager.loadPicture(this._pictureName);
};
//-----------------------------------------------------------------------------
// Sprite_Timer
//
// The sprite for displaying the timer.
function Sprite_Timer() {
this.initialize.apply(this, arguments);
}
Sprite_Timer.prototype = Object.create(Sprite.prototype);
Sprite_Timer.prototype.constructor = Sprite_Timer;
Sprite_Timer.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this._seconds = 0;
this.createBitmap();
this.update();
};
Sprite_Timer.prototype.createBitmap = function () {
3 years ago
this.bitmap = new Bitmap(96, 48);
this.bitmap.fontSize = 32;
};
Sprite_Timer.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateBitmap();
this.updatePosition();
this.updateVisibility();
};
Sprite_Timer.prototype.updateBitmap = function () {
3 years ago
if (this._seconds !== $gameTimer.seconds()) {
this._seconds = $gameTimer.seconds();
this.redraw();
}
};
Sprite_Timer.prototype.redraw = function () {
3 years ago
var text = this.timerText();
var width = this.bitmap.width;
var height = this.bitmap.height;
this.bitmap.clear();
this.bitmap.drawText(text, 0, 0, width, height, "center");
3 years ago
};
Sprite_Timer.prototype.timerText = function () {
3 years ago
var min = Math.floor(this._seconds / 60) % 60;
var sec = this._seconds % 60;
return min.padZero(2) + ":" + sec.padZero(2);
3 years ago
};
Sprite_Timer.prototype.updatePosition = function () {
3 years ago
this.x = Graphics.width - this.bitmap.width;
this.y = 0;
};
Sprite_Timer.prototype.updateVisibility = function () {
3 years ago
this.visible = $gameTimer.isWorking();
};
//-----------------------------------------------------------------------------
// Sprite_Destination
//
// The sprite for displaying the destination place of the touch input.
function Sprite_Destination() {
this.initialize.apply(this, arguments);
}
Sprite_Destination.prototype = Object.create(Sprite.prototype);
Sprite_Destination.prototype.constructor = Sprite_Destination;
Sprite_Destination.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this.createBitmap();
this._frameCount = 0;
};
Sprite_Destination.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
if ($gameTemp.isDestinationValid()) {
3 years ago
this.updatePosition();
this.updateAnimation();
this.visible = true;
} else {
this._frameCount = 0;
this.visible = false;
}
};
Sprite_Destination.prototype.createBitmap = function () {
3 years ago
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
this.bitmap = new Bitmap(tileWidth, tileHeight);
this.bitmap.fillAll("white");
3 years ago
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.blendMode = Graphics.BLEND_ADD;
};
Sprite_Destination.prototype.updatePosition = function () {
3 years ago
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
this.x = ($gameMap.adjustX(x) + 0.5) * tileWidth;
this.y = ($gameMap.adjustY(y) + 0.5) * tileHeight;
};
Sprite_Destination.prototype.updateAnimation = function () {
3 years ago
this._frameCount++;
this._frameCount %= 20;
this.opacity = (20 - this._frameCount) * 6;
this.scale.x = 1 + this._frameCount / 20;
this.scale.y = this.scale.x;
};
//-----------------------------------------------------------------------------
// Spriteset_Base
//
// The superclass of Spriteset_Map and Spriteset_Battle.
function Spriteset_Base() {
this.initialize.apply(this, arguments);
}
Spriteset_Base.prototype = Object.create(Sprite.prototype);
Spriteset_Base.prototype.constructor = Spriteset_Base;
Spriteset_Base.prototype.initialize = function () {
3 years ago
Sprite.prototype.initialize.call(this);
this.setFrame(0, 0, Graphics.width, Graphics.height);
this._tone = [0, 0, 0, 0];
this.opaque = true;
this.createLowerLayer();
this.createToneChanger();
this.createUpperLayer();
this.update();
};
Spriteset_Base.prototype.createLowerLayer = function () {
3 years ago
this.createBaseSprite();
};
Spriteset_Base.prototype.createUpperLayer = function () {
3 years ago
this.createPictures();
this.createTimer();
this.createScreenSprites();
};
Spriteset_Base.prototype.update = function () {
3 years ago
Sprite.prototype.update.call(this);
this.updateScreenSprites();
this.updateToneChanger();
this.updatePosition();
};
Spriteset_Base.prototype.createBaseSprite = function () {
3 years ago
this._baseSprite = new Sprite();
this._baseSprite.setFrame(0, 0, this.width, this.height);
this._blackScreen = new ScreenSprite();
this._blackScreen.opacity = 255;
this.addChild(this._baseSprite);
this._baseSprite.addChild(this._blackScreen);
};
Spriteset_Base.prototype.createToneChanger = function () {
3 years ago
if (Graphics.isWebGL()) {
this.createWebGLToneChanger();
} else {
this.createCanvasToneChanger();
}
};
Spriteset_Base.prototype.createWebGLToneChanger = function () {
3 years ago
var margin = 48;
var width = Graphics.width + margin * 2;
var height = Graphics.height + margin * 2;
this._toneFilter = new ToneFilter();
this._baseSprite.filters = [this._toneFilter];
this._baseSprite.filterArea = new Rectangle(-margin, -margin, width, height);
};
Spriteset_Base.prototype.createCanvasToneChanger = function () {
3 years ago
this._toneSprite = new ToneSprite();
this.addChild(this._toneSprite);
};
Spriteset_Base.prototype.createPictures = function () {
3 years ago
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var x = (Graphics.width - width) / 2;
var y = (Graphics.height - height) / 2;
this._pictureContainer = new Sprite();
this._pictureContainer.setFrame(x, y, width, height);
for (var i = 1; i <= $gameScreen.maxPictures(); i++) {
this._pictureContainer.addChild(new Sprite_Picture(i));
}
this.addChild(this._pictureContainer);
};
Spriteset_Base.prototype.createTimer = function () {
3 years ago
this._timerSprite = new Sprite_Timer();
this.addChild(this._timerSprite);
};
Spriteset_Base.prototype.createScreenSprites = function () {
3 years ago
this._flashSprite = new ScreenSprite();
this._fadeSprite = new ScreenSprite();
this.addChild(this._flashSprite);
this.addChild(this._fadeSprite);
};
Spriteset_Base.prototype.updateScreenSprites = function () {
3 years ago
var color = $gameScreen.flashColor();
this._flashSprite.setColor(color[0], color[1], color[2]);
this._flashSprite.opacity = color[3];
this._fadeSprite.opacity = 255 - $gameScreen.brightness();
};
Spriteset_Base.prototype.updateToneChanger = function () {
3 years ago
var tone = $gameScreen.tone();
if (!this._tone.equals(tone)) {
this._tone = tone.clone();
if (Graphics.isWebGL()) {
this.updateWebGLToneChanger();
} else {
this.updateCanvasToneChanger();
}
}
};
Spriteset_Base.prototype.updateWebGLToneChanger = function () {
3 years ago
var tone = this._tone;
this._toneFilter.reset();
this._toneFilter.adjustTone(tone[0], tone[1], tone[2]);
this._toneFilter.adjustSaturation(-tone[3]);
};
Spriteset_Base.prototype.updateCanvasToneChanger = function () {
3 years ago
var tone = this._tone;
this._toneSprite.setTone(tone[0], tone[1], tone[2], tone[3]);
};
Spriteset_Base.prototype.updatePosition = function () {
3 years ago
var screen = $gameScreen;
var scale = screen.zoomScale();
this.scale.x = scale;
this.scale.y = scale;
this.x = Math.round(-screen.zoomX() * (scale - 1));
this.y = Math.round(-screen.zoomY() * (scale - 1));
this.x += Math.round(screen.shake());
};
//-----------------------------------------------------------------------------
// Spriteset_Map
//
// The set of sprites on the map screen.
function Spriteset_Map() {
this.initialize.apply(this, arguments);
}
Spriteset_Map.prototype = Object.create(Spriteset_Base.prototype);
Spriteset_Map.prototype.constructor = Spriteset_Map;
Spriteset_Map.prototype.initialize = function () {
3 years ago
Spriteset_Base.prototype.initialize.call(this);
};
Spriteset_Map.prototype.createLowerLayer = function () {
3 years ago
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createParallax();
this.createTilemap();
this.createCharacters();
this.createShadow();
this.createDestination();
this.createWeather();
};
Spriteset_Map.prototype.update = function () {
3 years ago
Spriteset_Base.prototype.update.call(this);
this.updateTileset();
this.updateParallax();
this.updateTilemap();
this.updateShadow();
this.updateWeather();
};
Spriteset_Map.prototype.hideCharacters = function () {
3 years ago
for (var i = 0; i < this._characterSprites.length; i++) {
var sprite = this._characterSprites[i];
if (!sprite.isTile()) {
sprite.hide();
}
}
};
Spriteset_Map.prototype.createParallax = function () {
3 years ago
this._parallax = new TilingSprite();
this._parallax.move(0, 0, Graphics.width, Graphics.height);
this._baseSprite.addChild(this._parallax);
};
Spriteset_Map.prototype.createTilemap = function () {
3 years ago
if (Graphics.isWebGL()) {
this._tilemap = new ShaderTilemap();
} else {
this._tilemap = new Tilemap();
}
this._tilemap.tileWidth = $gameMap.tileWidth();
this._tilemap.tileHeight = $gameMap.tileHeight();
this._tilemap.setData($gameMap.width(), $gameMap.height(), $gameMap.data());
this._tilemap.horizontalWrap = $gameMap.isLoopHorizontal();
this._tilemap.verticalWrap = $gameMap.isLoopVertical();
this.loadTileset();
this._baseSprite.addChild(this._tilemap);
};
Spriteset_Map.prototype.loadTileset = function () {
3 years ago
this._tileset = $gameMap.tileset();
if (this._tileset) {
var tilesetNames = this._tileset.tilesetNames;
for (var i = 0; i < tilesetNames.length; i++) {
this._tilemap.bitmaps[i] = ImageManager.loadTileset(tilesetNames[i]);
}
var newTilesetFlags = $gameMap.tilesetFlags();
this._tilemap.refreshTileset();
if (!this._tilemap.flags.equals(newTilesetFlags)) {
this._tilemap.refresh();
}
this._tilemap.flags = newTilesetFlags;
}
};
Spriteset_Map.prototype.createCharacters = function () {
3 years ago
this._characterSprites = [];
$gameMap.events().forEach(function (event) {
3 years ago
this._characterSprites.push(new Sprite_Character(event));
}, this);
$gameMap.vehicles().forEach(function (vehicle) {
3 years ago
this._characterSprites.push(new Sprite_Character(vehicle));
}, this);
$gamePlayer.followers().reverseEach(function (follower) {
3 years ago
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]);
}
};
Spriteset_Map.prototype.createShadow = function () {
3 years ago
this._shadowSprite = new Sprite();
this._shadowSprite.bitmap = ImageManager.loadSystem("Shadow1");
3 years ago
this._shadowSprite.anchor.x = 0.5;
this._shadowSprite.anchor.y = 1;
this._shadowSprite.z = 6;
this._tilemap.addChild(this._shadowSprite);
};
Spriteset_Map.prototype.createDestination = function () {
3 years ago
this._destinationSprite = new Sprite_Destination();
this._destinationSprite.z = 9;
this._tilemap.addChild(this._destinationSprite);
};
Spriteset_Map.prototype.createWeather = function () {
3 years ago
this._weather = new Weather();
this.addChild(this._weather);
};
Spriteset_Map.prototype.updateTileset = function () {
3 years ago
if (this._tileset !== $gameMap.tileset()) {
this.loadTileset();
}
};
/*
* Simple fix for canvas parallax issue, destroy old parallax and readd to the tree.
*/
Spriteset_Map.prototype._canvasReAddParallax = function () {
3 years ago
var index = this._baseSprite.children.indexOf(this._parallax);
this._baseSprite.removeChild(this._parallax);
this._parallax = new TilingSprite();
this._parallax.move(0, 0, Graphics.width, Graphics.height);
this._parallax.bitmap = ImageManager.loadParallax(this._parallaxName);
this._baseSprite.addChildAt(this._parallax, index);
3 years ago
};
Spriteset_Map.prototype.updateParallax = function () {
3 years ago
if (this._parallaxName !== $gameMap.parallaxName()) {
this._parallaxName = $gameMap.parallaxName();
if (this._parallax.bitmap && Graphics.isWebGL() != true) {
this._canvasReAddParallax();
} else {
this._parallax.bitmap = ImageManager.loadParallax(this._parallaxName);
}
}
if (this._parallax.bitmap) {
this._parallax.origin.x = $gameMap.parallaxOx();
this._parallax.origin.y = $gameMap.parallaxOy();
}
};
Spriteset_Map.prototype.updateTilemap = function () {
3 years ago
this._tilemap.origin.x = $gameMap.displayX() * $gameMap.tileWidth();
this._tilemap.origin.y = $gameMap.displayY() * $gameMap.tileHeight();
};
Spriteset_Map.prototype.updateShadow = function () {
3 years ago
var airship = $gameMap.airship();
this._shadowSprite.x = airship.shadowX();
this._shadowSprite.y = airship.shadowY();
this._shadowSprite.opacity = airship.shadowOpacity();
};
Spriteset_Map.prototype.updateWeather = function () {
3 years ago
this._weather.type = $gameScreen.weatherType();
this._weather.power = $gameScreen.weatherPower();
this._weather.origin.x = $gameMap.displayX() * $gameMap.tileWidth();
this._weather.origin.y = $gameMap.displayY() * $gameMap.tileHeight();
};
//-----------------------------------------------------------------------------
// Spriteset_Battle
//
// The set of sprites on the battle screen.
function Spriteset_Battle() {
this.initialize.apply(this, arguments);
}
Spriteset_Battle.prototype = Object.create(Spriteset_Base.prototype);
Spriteset_Battle.prototype.constructor = Spriteset_Battle;
Spriteset_Battle.prototype.initialize = function () {
3 years ago
Spriteset_Base.prototype.initialize.call(this);
this._battlebackLocated = false;
};
Spriteset_Battle.prototype.createLowerLayer = function () {
3 years ago
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createBackground();
this.createBattleField();
this.createBattleback();
this.createEnemies();
this.createActors();
};
Spriteset_Battle.prototype.createBackground = function () {
3 years ago
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
this._baseSprite.addChild(this._backgroundSprite);
};
Spriteset_Battle.prototype.update = function () {
3 years ago
Spriteset_Base.prototype.update.call(this);
this.updateActors();
this.updateBattleback();
};
Spriteset_Battle.prototype.createBattleField = function () {
3 years ago
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var x = (Graphics.width - width) / 2;
var y = (Graphics.height - height) / 2;
this._battleField = new Sprite();
this._battleField.setFrame(x, y, width, height);
this._battleField.x = x;
this._battleField.y = y;
this._baseSprite.addChild(this._battleField);
};
Spriteset_Battle.prototype.createBattleback = function () {
3 years ago
var margin = 32;
var x = -this._battleField.x - margin;
var y = -this._battleField.y - margin;
var width = Graphics.width + margin * 2;
var height = Graphics.height + margin * 2;
this._back1Sprite = new TilingSprite();
this._back2Sprite = new TilingSprite();
this._back1Sprite.bitmap = this.battleback1Bitmap();
this._back2Sprite.bitmap = this.battleback2Bitmap();
this._back1Sprite.move(x, y, width, height);
this._back2Sprite.move(x, y, width, height);
this._battleField.addChild(this._back1Sprite);
this._battleField.addChild(this._back2Sprite);
};
Spriteset_Battle.prototype.updateBattleback = function () {
3 years ago
if (!this._battlebackLocated) {
this.locateBattleback();
this._battlebackLocated = true;
}
};
Spriteset_Battle.prototype.locateBattleback = function () {
3 years ago
var width = this._battleField.width;
var height = this._battleField.height;
var sprite1 = this._back1Sprite;
var sprite2 = this._back2Sprite;
sprite1.origin.x = sprite1.x + (sprite1.bitmap.width - width) / 2;
sprite2.origin.x = sprite1.y + (sprite2.bitmap.width - width) / 2;
if ($gameSystem.isSideView()) {
sprite1.origin.y = sprite1.x + sprite1.bitmap.height - height;
sprite2.origin.y = sprite1.y + sprite2.bitmap.height - height;
}
};
Spriteset_Battle.prototype.battleback1Bitmap = function () {
3 years ago
return ImageManager.loadBattleback1(this.battleback1Name());
};
Spriteset_Battle.prototype.battleback2Bitmap = function () {
3 years ago
return ImageManager.loadBattleback2(this.battleback2Name());
};
Spriteset_Battle.prototype.battleback1Name = function () {
3 years ago
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback1Name;
} else if ($gameMap.battleback1Name()) {
return $gameMap.battleback1Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback1Name();
} else {
return "";
3 years ago
}
};
Spriteset_Battle.prototype.battleback2Name = function () {
3 years ago
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback2Name;
} else if ($gameMap.battleback2Name()) {
return $gameMap.battleback2Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback2Name();
} else {
return "";
3 years ago
}
};
Spriteset_Battle.prototype.overworldBattleback1Name = function () {
if ($gameMap.battleback1Name() === "") return "";
3 years ago
if ($gamePlayer.isInVehicle()) {
return this.shipBattleback1Name();
} else {
return this.normalBattleback1Name();
}
};
Spriteset_Battle.prototype.overworldBattleback2Name = function () {
if ($gameMap.battleback2Name() === "") return "";
3 years ago
if ($gamePlayer.isInVehicle()) {
return this.shipBattleback2Name();
} else {
return this.normalBattleback2Name();
}
};
Spriteset_Battle.prototype.normalBattleback1Name = function () {
return (
this.terrainBattleback1Name(this.autotileType(1)) ||
this.terrainBattleback1Name(this.autotileType(0)) ||
this.defaultBattleback1Name()
);
3 years ago
};
Spriteset_Battle.prototype.normalBattleback2Name = function () {
return (
this.terrainBattleback2Name(this.autotileType(1)) ||
this.terrainBattleback2Name(this.autotileType(0)) ||
this.defaultBattleback2Name()
);
3 years ago
};
Spriteset_Battle.prototype.terrainBattleback1Name = function (type) {
3 years ago
switch (type) {
case 24:
case 25:
return "Wasteland";
case 26:
case 27:
return "DirtField";
case 32:
case 33:
return "Desert";
case 34:
return "Lava1";
case 35:
return "Lava2";
case 40:
case 41:
return "Snowfield";
case 42:
return "Clouds";
case 4:
case 5:
return "PoisonSwamp";
default:
return null;
}
};
Spriteset_Battle.prototype.terrainBattleback2Name = function (type) {
3 years ago
switch (type) {
case 20:
case 21:
return "Forest";
case 22:
case 30:
case 38:
return "Cliff";
case 24:
case 25:
case 26:
case 27:
return "Wasteland";
case 32:
case 33:
return "Desert";
case 34:
case 35:
return "Lava";
case 40:
case 41:
return "Snowfield";
case 42:
return "Clouds";
case 4:
case 5:
return "PoisonSwamp";
3 years ago
}
};
Spriteset_Battle.prototype.defaultBattleback1Name = function () {
return "Grassland";
3 years ago
};
Spriteset_Battle.prototype.defaultBattleback2Name = function () {
return "Grassland";
3 years ago
};
Spriteset_Battle.prototype.shipBattleback1Name = function () {
return "Ship";
3 years ago
};
Spriteset_Battle.prototype.shipBattleback2Name = function () {
return "Ship";
3 years ago
};
Spriteset_Battle.prototype.autotileType = function (z) {
3 years ago
return $gameMap.autotileType($gamePlayer.x, $gamePlayer.y, z);
};
Spriteset_Battle.prototype.createEnemies = function () {
3 years ago
var enemies = $gameTroop.members();
var sprites = [];
for (var i = 0; i < enemies.length; i++) {
sprites[i] = new Sprite_Enemy(enemies[i]);
}
sprites.sort(this.compareEnemySprite.bind(this));
for (var j = 0; j < sprites.length; j++) {
this._battleField.addChild(sprites[j]);
}
this._enemySprites = sprites;
};
Spriteset_Battle.prototype.compareEnemySprite = function (a, b) {
3 years ago
if (a.y !== b.y) {
return a.y - b.y;
} else {
return b.spriteId - a.spriteId;
}
};
Spriteset_Battle.prototype.createActors = function () {
3 years ago
this._actorSprites = [];
for (var i = 0; i < $gameParty.maxBattleMembers(); i++) {
this._actorSprites[i] = new Sprite_Actor();
this._battleField.addChild(this._actorSprites[i]);
}
};
Spriteset_Battle.prototype.updateActors = function () {
3 years ago
var members = $gameParty.battleMembers();
for (var i = 0; i < this._actorSprites.length; i++) {
this._actorSprites[i].setBattler(members[i]);
}
};
Spriteset_Battle.prototype.battlerSprites = function () {
3 years ago
return this._enemySprites.concat(this._actorSprites);
};
Spriteset_Battle.prototype.isAnimationPlaying = function () {
return this.battlerSprites().some(function (sprite) {
3 years ago
return sprite.isAnimationPlaying();
});
};
Spriteset_Battle.prototype.isEffecting = function () {
return this.battlerSprites().some(function (sprite) {
3 years ago
return sprite.isEffecting();
});
};
Spriteset_Battle.prototype.isAnyoneMoving = function () {
return this.battlerSprites().some(function (sprite) {
3 years ago
return sprite.isMoving();
});
};
Spriteset_Battle.prototype.isBusy = function () {
3 years ago
return this.isAnimationPlaying() || this.isAnyoneMoving();
};