Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dzho_QuestionBattle
- // Interrogation Minigame
- // Includes Scene_Interrogate, InterrogationManager, and Misc Needed Items
- //-----------------------------------------------------------------------------
- // Scene_Interrogate
- //
- // The scene called when interring an interrogation.
- function Scene_Interrogate() {
- this.initialize.apply(this, arguments);
- }
- Scene_Interrogate.prototype = Object.create(Scene_Base.prototype);
- Scene_Interrogate.prototype.constructor = Scene_Interrogate;
- Scene_Interrogate.prototype.prepare = function(ai_id){
- this._sceneId = ai_id;
- };
- Scene_Interrogate.prototype.initialize = function() {
- Scene_Base.prototype.initialize.call(this);
- };
- Scene_Interrogate.prototype.create = function() {
- Scene_Base.prototype.create.call(this);
- this.createDisplayObjects();
- };
- Scene_Interrogate.prototype.start = function() {
- Scene_Base.prototype.start.call(this);
- this.getAiData();
- this.startFadeIn(this.fadeSpeed(), false);
- InterrogationManager.playInterrogateBgm();
- InterrogationManager.startInterrogation();
- };
- Scene_Interrogate.prototype.update = function() {
- var active = this.isActive();
- $gameTimer.update(active);
- $gameScreen.update();
- this.updateStatusWindow();
- this.updateWindowPositions();
- if (active && this.isBusy()) {
- this.updateBattleProcess();
- }
- Scene_Base.prototype.update.call(this);
- };
- Scene_Interrogate.prototype.updateBattleProcess = function() {
- if (!this.isAnyInputWindowActive() || InterrogationManager.isAborting() ||
- InterrogationManager.isInterrogationEnd()) {
- InterrogationManager.update();
- this.changeInputWindow();
- }
- };
- Scene_Interrogate.prototype.isAnyInputWindowActive = function() {
- return (this._questionWindow.active);
- };
- Scene_Interrogate.prototype.changeInputWindow = function() {
- if (InterrogationManager.isInputting())
- this.startQuestionSelection();
- else
- this.endQuestionSelection();
- };
- Scene_Interrogate.prototype.stop = function() {
- Scene_Base.prototype.stop.call(this);
- this.startFadeOut(this.fadeSpeed(), false);
- this._statusWindow.close();
- this._questionWindow.close();
- };
- Scene_Interrogate.prototype.terminate = function() {
- Scene_Base.prototype.terminate.call(this);
- $gameParty.onQuestionEnd();
- $gameTroop.onQuestionEnd();
- AudioManager.stopMe();
- ImageManager.clearRequest();
- };
- Scene_Interrogate.prototype.getAiData = function() {
- $gamePersona.getPersona(this._sceneId);
- };
- Scene_Interrogate.prototype.updateStatusWindow = function() {
- if ($gameMessage.isBusy()) {
- this._statusWindow.close();
- this._questionWindow.close();
- }
- else if (this.isActive() && !this._messageWindow.isClosing())
- this._statusWindow.open();
- };
- Scene_Interrogate.prototype.updateWindowPositions = function() {
- var statusX = 0;
- if (InterrogationManager.isInputting())
- statusX = this._questionWindow.width;
- else
- statusX = this._questionWindow.width / 2;
- if (this._statusWindow.x < statusX) {
- this._statusWindow.x += 16;
- if (this._statusWindow.x > statusX)
- this._statusWindow.x = statusX;
- }
- if (this._statusWindow.x > statusX){
- this._statusWindow.x -= 16;
- if (this._statusWindow.x < statusX)
- this._statusWindow.x = statusX;
- }
- };
- Scene_Interrogate.prototype.createDisplayObjects = function() {
- this.createSpriteset();
- this.createWindowLayer();
- this.createAllWindows();
- InterrogationManager.setLogWindow(this._logWindow);
- InterrogationManager.setStatusWindow(this._statusWindow);
- InterrogationManager.setSpriteset(this._spriteset);
- this._logWindow.setSpriteset(this._spriteset);
- };
- Scene_Interrogate.prototype.createSpriteset = function() {
- this._spriteset = new Spriteset_Interrogate();
- this.addChild(this._spriteset);
- };
- Scene_Interrogate.prototype.createAllWindows = function() {
- this.createLogWindow();
- this.createStatusWindow();
- this.createQuestionWindow();
- this.createHelpWindow();
- this.createMessageWindow();
- this.createScrollTextWindow();
- };
- Scene_Interrogate.prototype.createLogWindow = function() {
- this._logWindow = new Window_InterrogateLog();
- this.addWindow(this._logWindow);
- };
- Scene_Interrogate.prototype.createStatusWindow = function() {
- this._statusWindow = new Window_InterrogateStatus();
- this.addWindow(this._statusWindow);
- };
- Scene_Interrogate.prototype.createQuestionWindow = function() {
- this._questionWindow = new Window_InterrogationCommand();
- this._questionWindow.setHandler('who', this.commandWho.bind(this));
- this._questionWindow.setHandler('what', this.commandWhat.bind(this));
- this._questionWindow.setHandler('when', this.commandWhen.bind(this));
- this._questionWindow.setHandler('where', this.commandWhere.bind(this));
- this._questionWindow.setHandler('why', this.commandWhy.bind(this));
- this._questionWindow.setHandler('how', this.commandHow.bind(this));
- this.addWindow(this._questionWindow);
- };
- Scene_Interrogate.prototype.createHelpWindow = function() {
- this._helpWindow = new Window_Help();
- this._helpWindow.visible = false;
- this.addWindow(this._helpWindow);
- };
- Scene_Interrogate.prototype.createMessageWindow = function() {
- this._messageWindow = new Window_Message();
- this.addWindow(this._messageWindow);
- this._messageWindow.subWindows().forEach(function(window) {
- this.addWindow(window);
- }, this);
- };
- Scene_Interrogate.prototype.createScrollTextWindow = function() {
- this._scrollTextWindow = new Window_ScrollText();
- this.addWindow(this._scrollTextWindow);
- };
- Scene_Interrogate.prototype.refreshStatus = function() {
- this._statusWindow.refresh();
- };
- Scene_Interrogate.prototype.startQuestionSelection = function() {
- this.refreshStatus();
- this._statusWindow.deselect();
- this._statusWindow.open();
- this._questionWindow.setup();
- };
- /*
- Figure This Out Later
- Scene_Interrogate.prototype.commandWho = function() {
- }
- */
- // May Not Be Necessary
- Scene_Interrogate.prototype.selectNextCommand = function() {
- InterrogationManager.selectNextCommand();
- this.changeInputWindow();
- };
- Scene_Interrogate.prototype.selectPreviousCommand = function() {
- InterrogationManager.selectPreviousCommand();
- this.changeInputWindow();
- };
- Scene_Interrogate.prototype.endQuestionSelection = function() {
- this._questionWindow.close();
- this._statusWindow.deselect();
- };
- //-----------------------------------------------------------------------------
- // InterrogationManager
- //
- // Manager handling progression of the Scene_Interrogation.
- function InterrogationManager() {
- throw new Error('This is a static class');
- }
- InterrogationManager.setup = function(troopId, fileName) {
- this.initMembers();
- this._fileName = fileName;
- //Check
- $gameTroop.setup(troopId);
- $gameScreen.onQuestionStart();
- };
- InterrogationManager.initMembers = function() {
- this._phase = 'init';
- this._interrogationTest = false;
- this._eventCallback = null;
- this._mapBgm = null;
- this._mapBgs = null;
- this._questions = [];
- this._subject = null;
- this._action = null;
- this._logWindow = null;
- this._statusWindow = null;
- this._spriteset = null;
- this._answer = null;
- this._actorIndex = -1;
- };
- InterrogationManager.isInterrogationTest = function() {
- return this._interrogationTest;
- };
- InterrogationManager.setInterrogationTest = function(interrogationTest) {
- this._interrogationTest = interrogationTest;
- };
- InterrogationManager.setEventCallback = function(callback) {
- this._eventCallback = callback;
- };
- InterrogationManager.setLogWindow = function(logWindow) {
- this._logWindow = logWindow;
- };
- InterrogationManager.setStatusWindow = function(statusWindow) {
- this._statusWindow = statusWindow;
- };
- InterrogationManager.setSpriteset = function(spriteset) {
- this._spriteset = spriteset;
- };
- InterrogationManager.onEncounter = function() {
- };
- InterrogationManager.saveBgmAndBgs = function() {
- this._mapBgm = AudioManager.saveBgm();
- this._mapBgs = AudioManager.saveBgs();
- };
- InterrogationManager.playInterrogateBgm = function() {
- AudioManager.playBgm($gameSystem.interrogateBgm());
- AudioManager.stopBgs();
- };
- InterrogationManager.playSuccessMe = function() {
- AudioManager.playMe($gameSystem.successMe());
- };
- InterrogationManager.playFailureMe = function() {
- AudioManager.playMe($gameSystem.failureMe());
- };
- InterrogationManager.replayBgmAndBgs = function() {
- if (this._mapBgm)
- AudioManager.replayBgm(this._mapBgm);
- else
- AudioManager.stopBgm();
- if (this._mapBgs)
- AudioManager.replayBgs(this._mapBgs);
- };
- //Check
- InterrogationManager.update = function() {
- if (!this.isBusy() && !this.updateEvent()) {
- switch (this._phase) {
- case 'start':
- this.startInput();
- break;
- case 'turn':
- this.updateTurn();
- break;
- case 'action':
- this.updateAction();
- break;
- case 'turnEnd':
- this.updateTurnEnd();
- break;
- case 'interrogateEnd':
- this.updateInterrogateEnd();
- break;
- }
- }
- };
- //Check
- InterrogationManager.updateEvent = function() {
- switch(this._phase) {
- case 'start':
- case 'turn':
- case 'turnEnd':
- if (this.isActionForced()){
- this.processForcedAction();
- return true;
- }
- else
- return this.updateEventMain();
- }
- return this.checkAbort();
- };
- InterrogationManager.updateEventMain = function() {
- $gameTroop.updateInterpreter();
- $gameParty.requestMotionRefresh();
- if ($gameTroop.isEventRunning() || this.checkInterrogationEnd())
- return true;
- $gameTroop.setupInterrogationEvent();
- if ($gameTroop.isEventRunning() || SceneManager.isSceneChanging())
- return true;
- return false;
- };
- InterrogationManager.isBusy = function() {
- return ($gameMessage.isBusy() || this._spriteset.isBusy() ||
- this._logWindow.isBusy());
- };
- InterrogationManager.isInputting = function() {
- return this._phase === 'input';
- };
- InterrogationManager.isInTurn = function() {
- return this._phase === 'turn';
- };
- InterrogationManager.isTurnEnd = function() {
- return this._phase === 'turnEnd';
- };
- InterrogationManager.isAborting = function() {
- return this._phase === 'aborting';
- };
- InterrogationManager.isInterrogationEnd = function() {
- return this._phase === 'interrogateEnd';
- };
- InterrogationManager.actor = function() {
- return this._actorIndex >=0 ? $gameParty.members()[this._actorIndex] : null;
- };
- InterrogationManager.clearActor = function() {
- this.changeActor(-1, '');
- };
- //Check
- // I NEED FUNCTIONS FOR MESSAGE AND SUBJECT AND CHOOSING QUESTION
- InterrogationManager.startInterrogation = function() {
- this._phase = 'start';
- $gameSystem.onQuestionStart();
- $gameParty.onQuestionStart();
- $gameTroop.onQuestionStart();
- this.displayStartMessages();
- };
- //Check
- InterrogationManager.startInput = function() {
- this._phase = 'input';
- $gameParty.makeActions();
- $gameTroop.makeActions();
- this.clearActor();
- if (!$gameParty.canInput())
- this.startTurn();
- };
- InterrogationManager.inputtingAction = function() {
- return this.actor() ? this.actor().inputtingAction() : null;
- };
- InterrogationManager.selectNextCommand = function() {
- do {
- if (!this.actor() || !this.actor().selectNextCommand()){
- this.startTurn();
- break;
- }
- } while (!this.actor().canInput());
- };
- InterrogationManager.selectPreviousCommand = function() {
- do {
- if (!this.actor() || !this.actor().selectPreviousCommand()) {
- return;
- }
- } while (!this.actor().canInput());
- };
- InterrogationManager.refreshStatus = function() {
- this._statusWindow.refresh();
- };
- InterrogationManager.startTurn = function() {
- this._phase = 'turn';
- this.clearActor();
- $gameTroop.increaseTurn();
- this.makeActionOrders();
- $gameParty.requestMotionRefresh();
- this._logWindow.startTurn();
- };
- //Check
- InterrogationManager.updateTurn = function() {
- $gameParty.requestMotionRefresh();
- if (!this._subject)
- this._subject = this.getNextSubject();
- if (this._subject)
- this.processTurn();
- else
- this.endTurn();
- };
- //Check
- InterrogationManager.processTurn = function() {
- var subject = this._subject;
- var action = subject.currentAction();
- if (action) {
- action.prepare();
- if (action.isValid())
- this.startAction();
- subject.removeCurrentAction();
- }
- else {
- subject.onAllActionsEnd();
- this.refreshStatus();
- this._logWindow.displayAutoAffectedStatus(subject);
- this._logWindow.displayCurrentState(subject);
- this._logWindow.displayRegeneration(subject);
- this._subject = this.getNextSubject();
- }
- };
- //Check
- InterrogationManager.endTurn = function() {
- this._phase = 'turnEnd';
- battler = this.actor();
- battler.onTurnEnd();
- this.refreshStatus();
- this._logWindow.displayAutoAffectedStatus(battler);
- this._logWindow.displayRegeneration(battler);
- };
- InterrogationManager.updateTurnEnd = function() {
- this.startInput();
- };
- InterrogationManager.abort = function() {
- this._phase = 'aborting';
- };
- InterrogationManager.checkInterrogationEnd = function() {
- if (this._phase){
- if (this.checkAbort())
- return true;
- // SOME VARIABLE FOR CLUE OBTAINED?
- else if (this.obtainedClue){
- this.processVictory();
- return true;
- }
- // VARIABLE FOR DEAD END
- else if (this.deadEnd){
- this.processDefeat();
- return true;
- }
- }
- return false;
- };
- InterrogationManager.checkAbort = function() {
- if ($gameParty.isEmpty() || this.isAborting()){
- this.processAbort();
- }
- return false;
- };
- InterrogationManager.processVictory = function() {
- // SOME VICTORY ANIMATION
- $gameParty.removeBattleStates();
- this.playSuccessMe();
- this.replayBgmAndBgs();
- this.makeRewards();
- this.displayVictoryMessage();
- this.displayRewards();
- this.gainRewards();
- this.endInterrogation(0);
- };
- InterrogationManager.processAbort = function() {
- //Check
- $gameParty.removeBattleStates();
- this.replayBgmAndBgs();
- this.endInterrogation(1);
- };
- InterrogationManager.processDefeat = function() {
- // SOME DEFEAT ANIMATION
- this.displayDefeatMessage();
- this.playFailureMe();
- this.replayBgmAndBgs();
- this.endInterrogation(2);
- };
- InterrogationManager.endBattle = function(result) {
- this._phase = 'interrogateEnd';
- if (this._eventCallback)
- this._eventCallback(result);
- if (result === 0)
- $gameSystem.onQuestionEnd();
- };
- InterrogationManager.updateInterrogateEnd = function() {
- if (this.isInterrogationTest()) {
- AudioManager.stopBgm();
- SceneManager.exit();
- }
- else
- SceneManager.pop();
- this._phase = null;
- };
- InterrogationManager.makeRewards = function() {
- this._rewards = {};
- // THINKING EXP WILL WORK BASED ON YOUR STYLE
- // IF YOU MANIPULATE, MANIPULATION +10
- // IF YOU ARE KIND, KINDNESS +20
- // Etc...
- //Check WORK ON THIS LATER
- this._rewards.manipulationExp = 0;
- this._rewards.kindnessExp = 0;
- this._rewards.clue = null;
- };
- InterrogationManager.displayVictoryMessage = function() {
- $gameMessage.add(TextManager.victory.format($gameParty.name()));
- };
- InterrogationManager.displayDefeatMessage = function() {
- $gameMessage.add(TextManager.defeat.format($gameParty.name()));
- };
- InterrogationManager.displayRewards = function() {
- this.displayExp();
- this.displayClue();
- };
- InterrogationManager.displayExp = function() {
- var manipulationExp = this._rewards.manipulationExp;
- var kindnessExp = this._rewards.kindnessExp;
- if (manipulationExp > 0){
- var text = TextManager.obtainExp.format(manipulationExp, TextManager.exp);
- $gameMessage.add('\\.' + text);
- }
- if (kindnessExp > 0){
- var text = TextManager.obtainExp.format(kindnessExp, TextManager.exp);
- $gameMessage.add('\\.' + text);
- }
- };
- InterrogationManager.displayClue = function() {
- var clue = this._rewards.clue;
- if (clue){
- $gameMessage.newPage();
- $gameMessage.add(TextManager.obtainClue.format(clue.name));
- }
- };
- InterrogationManager.gainRewards = function() {
- this.gainExp();
- this.gainClue();
- };
- InterrogationManager.gainExp = function() {
- var manipulationExp = this._rewards.manipulationExp;
- var kindnessExp = this._rewards.kindnessExp;
- $gameParty.allMembers().forEach(function(actor) {
- actor.gainManipulationExp(manipulationExp);
- actor.gainKindnessExp(kindnessExp);
- });
- };
- InterrogationManager.gainClue = function() {
- var clue = this._rewards.clue;
- $gameParty.gainItem(clue, 1);
- };
- //-----------------------------------------------------------------------------
- // Spriteset_Interrogate
- //
- // The set of sprites for the interrogation screen.
- function Spriteset_Interrogate() {
- this.initialize.apply(this, arguments);
- }
- Spriteset_Interrogate.prototype = Object.create(Spriteset_Base.prototype);
- Spriteset_Interrogate.prototype.constructor = Spriteset_Interrogate;
- Spriteset_Interrogate.prototype.initialize = function() {
- Spriteset_Base.prototype.initialize.call(this);
- this._battlebackLocated = false;
- };
- Spriteset_Interrogate.prototype.createLowerLayer = function() {
- Spriteset_Base.prototype.createLowerLayer.call(this);
- this.createBackground();
- this.createBattleField();
- this.createBattleback();
- //Check READD WHEN DONE
- //this.createEnemy();
- };
- Spriteset_Interrogate.prototype.createBackground = function() {
- this._backgroundSprite = new Sprite();
- this. _backgroundSprite.bitmap = SceneManager.backgroundBitmap();
- this._baseSprite.addChild(this._backgroundSprite);
- };
- Spriteset_Interrogate.prototype.update = function() {
- Spriteset_Base.prototype.update.call(this);
- //Check
- //this.updateActors();
- this.updateBattleback();
- };
- Spriteset_Interrogate.prototype.createBattleField = function() {
- 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_Interrogate.prototype.createBattleback = function() {
- 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_Interrogate.prototype.updateBattleback = function() {
- if (!this._battlebackLocated){
- this.locateBattleback();
- this._battlebackLocated = true;
- }
- };
- Spriteset_Interrogate.prototype.locateBattleback = function() {
- 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;
- };
- Spriteset_Interrogate.prototype.battleback1Bitmap = function() {
- return ImageManager.loadBattleback1(this.battleback1Name());
- };
- Spriteset_Interrogate.prototype.battleback2Bitmap = function() {
- return ImageManager.loadBattleback2(this.battleback2Name());
- };
- Spriteset_Interrogate.prototype.battleback1Name = function() {
- if (InterrogationManager.isInterrogationTest())
- return $dataSystem.battleback1Name;
- else if ($gameMap.battleback1Name())
- return $gameMap.battleback1Name();
- else
- return '';
- };
- Spriteset_Interrogate.prototype.battleback2Name = function() {
- if (InterrogationManager.isInterrogationTest())
- return $dataSystem.battleback2Name;
- else if ($gameMap.battleback2Name())
- return $gameMap.battleback2Name();
- else
- return '';
- };
- //-----------------------------------------------------------------------------
- // Window_InterrogateLog
- //
- // The window for displaying interrogation progress. No frame is displayed, but it is
- // handled as a window for convenience.
- function Window_InterrogateLog() {
- this.initialize.apply(this,arguments);
- }
- Window_InterrogateLog.prototype = Object.create(Window_Selectable.prototype);
- Window_InterrogateLog.prototype.constructor = Window_InterrogateLog;
- Window_InterrogateLog.prototype.initialize = function() {
- var width = this.windowWidth();
- var height = this.windowHeight();
- Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
- this.opacity = 0;
- this._lines = [];
- this._methods = [];
- this._waitCount = 0;
- this._waitMode = '';
- this._baseLineStack = [];
- this._spriteset = null;
- this.createBackBitmap();
- this.createBackSprite();
- this.refresh();
- };
- //BEGIN FROM HERE
- //Window_BattleLog.prototype.setSpriteset
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement