GERI_KHAN'S PROFILE

Search

Filter

[SCRIPTING] [RMMV] Selectable windows and databases

Heads up, just discovered that code I gave you will crash in battle.

Quick fix:

// prevents various things happening while the new window is open,
  // such as the player moving
  Game_Message.prototype.isBusy = function() {
    if (SceneManager._scene._myWindow && SceneManager._scene._myWindow.isOpen()) {
      return true;
    }
    return _Game_Message_isBusy.call(this);
  };

[SCRIPTING] [RMMV] Selectable windows and databases

Yeah, it's hanging because you've not told it to do anything. Looking at these two functions...

Compendium_Window.prototype.processOk = function() {
      if (this.isCurrentItemEnabled()) {
          this.playOkSound();
          this.updateInputData();
          this.deactivate();
          this.callOkHandler();
      } else {
          this.playBuzzerSound();
      }
  };

  Compendium_Window.prototype.processCancel = function() {
    SoundManager.playCancel();
    this.updateInputData();
    this.deactivate();
    this.callCancelHandler();
  };

Both deactivate the window without doing anything. They do call the OK/Cancel handlers, but nothing happens because you haven't defined what they are.

Two ways you could go about this:

1) Put the commands to close the window and execute whatever needs to happen in the functions themselves.

Compendium_Window.prototype.processOk = function() {
      if (this.isCurrentItemEnabled()) {
          this.playOkSound();
          this.updateInputData();
          this.deactivate();
          //
          // I've added the next two lines to close the window and output
          // the index of the selected item to the console
          //
          this.close();
          console.log('OK triggered, index = '+this.index());
          this.callOkHandler();
      } else {
          this.playBuzzerSound();
      }
  };

  Compendium_Window.prototype.processCancel = function() {
    SoundManager.playCancel();
    this.updateInputData();
    this.deactivate();
    //
    // same here
    //
    this.close();
    console.log('Cancel triggered');
    this.callCancelHandler();
  };

If you do this, you will need to edit the isOkEnabled and isCancelEnabled functions to get them to work. Just have them always return true.

or 2) Create and bind the handler functions. The relevant parts would be

// set the handlers in the initialise function
  Compendium_Window.prototype.initialize = function(x, y, width, height) {
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.setHandler('ok',     this.onOk.bind(this));
    this.setHandler('cancel', this.onCancel.bind(this));
  };

  // create the function to run when the OK handler is called
  Compendium_Window.prototype.onOk = function() {
    this.close();
    console.log('OK triggered, index = '+this.index());
  };

  // create the function to run when the Cancel handler is called
  Compendium_Window.prototype.onCancel = function() {
    this.close();
    console.log('Cancel triggered');
  };

Obviously substitute those console.logs for what you actually want to happen. Now when processOk and ProcessCancel use callOkHandler and callCancelHandler, it'll run those bound functions.

The former way is probably simpler, the latter way is probably tidier.

[SCRIPTING] [RMMV] Selectable windows and databases

I don't have time to look into it today but have a look at how handlers are set and called. That determines what the window does when you press OK or Cancel.

You can probably put what happens next in the same script. I don't know what you're planning, but if it's to be a different scene maybe start by getting it opening Scene_Status for the character?


... also I made the Compendium_Window inherit Window_Command in the example above. In hindsight that should probably be Window_Selectable.

[SCRIPTING] [RMMV] Selectable windows and databases

Just noticed that I left this testing code in, you should probably remove it

for (n = 1; n<=40; n++) {

$gameParty.addActor(n);
}


The cursor code could probably be changed too to make it less recursive.

   // Modifying the cursor code means the cursor can't stop on it

Compendium_Window.prototype.cursorDown = function(wrap) {
Window_Selectable.prototype.cursorDown.call(this,wrap);
if (this.index() == 0) {
Window_Selectable.prototype.cursorDown.call(this,wrap);
}

};



Compendium_Window.prototype.cursorUp = function(wrap) {
Window_Selectable.prototype.cursorUp.call(this,wrap);
if (this.index() == 0) {
Window_Selectable.prototype.cursorUp.call(this,wrap);
}
};

[SCRIPTING] [RMMV] Selectable windows and databases

I took the liberty of trying this out. There are a few shortcuts, such as with the header text and cursor hack, that I could do better with more time, but it's after midnight here.

Is this more or less what you were thinking of? Bring up the window by using the plugin command "actorlist"

//=============================================================================

// actorlist.js
//=============================================================================

/*:
* @plugindesc Display a list of actors
* @author Geri Khan
*
* @param none
* @desc none
* @default false
*
* @help
*
* Plugin Command:
*
* actorlist - displays the actor list
*
*/

(function() {

var _Scene_Map_createallwindows = Scene_Map.prototype.createAllWindows;
var _Game_Message_isBusy = Game_Message.prototype.isBusy;
var _Actor_List = Window_Selectable.prototype.start; //addition
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;


// adds the 'actorlist' plugin command
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'actorlist') {
for (n = 1; n<=40; n++) {
$gameParty.addActor(n);
}
if (!$gameParty.inBattle()) {
SceneManager._scene._myWindow.refresh();
SceneManager._scene._myWindow.show();
SceneManager._scene._myWindow.open();
SceneManager._scene._myWindow.activate();
SceneManager._scene._myWindow.select(1);
};
}
};

// prevents various things happening while the new window is open,
// such as the player moving
Game_Message.prototype.isBusy = function() {
if (SceneManager._scene._myWindow.isOpen()) { return true; }
return _Game_Message_isBusy.call(this);
};

// create the compendium window while starting the map
Scene_Map.prototype.createAllWindows = function() {
_Scene_Map_createallwindows.call(this);
this._myWindow = new Compendium_Window(0, 0);
this.addWindow(this._myWindow);
this._myWindow.close();
};

// define the compendum window class
function Compendium_Window() {
this.initialize.apply(this, arguments);
}

Compendium_Window.prototype = Object.create(Window_Command.prototype);
Compendium_Window.prototype.constructor = Compendium_Window;

// set the width of the window
Compendium_Window.prototype.windowWidth = function() {
return 816;
};

// set the number of items in the list. Could use different values here,
// such as $gameParty.members() or $gameParty.battleMembers()
Compendium_Window.prototype.maxItems = function() {
return $gameActors._data.length;
};

// the number of visible rows in the window. Without this the height of the
// window could be too tall for the screen with large numbers of actors
Compendium_Window.prototype.numVisibleRows = function() {
return Math.min(10,this.maxItems());
};

// draw each line of the window. Its width is evenly divided into three
Compendium_Window.prototype.drawItem = function(index) {
if (index == 0) {
this.drawHeader();
return;
}
var actor = $gameActors.actor(index);
var rect = this.itemRectForText(index);
var segmentWidth = rect.width/3;
if (actor) {
this.drawActorClass(actor, rect.x, rect.y, segmentWidth);
this.drawActorName(actor, rect.x+segmentWidth, rect.y, segmentWidth);
this.drawActorLevel(actor, rect.x+(segmentWidth*2), rect.y, segmentWidth);
}
};

// refresh the window, including moving it into position
Compendium_Window.prototype.refresh = function() {
this.move(0,0,this.windowWidth(),this.fittingHeight(this.numVisibleRows()));
this.createContents();
this.drawAllItems();
};

// draw the header text for each column
Compendium_Window.prototype.drawHeader = function() {
var rect = this.itemRectForText(0);
var segmentWidth = rect.width/3;
this.drawText('Class', rect.x, rect.y, segmentWidth);
this.drawText('Name', rect.x+segmentWidth, rect.y, segmentWidth);
this.drawText('Level', rect.x+(segmentWidth*2), rect.y, segmentWidth);
};

// the header text is on line 0, which is selectable but shouldn't be.
// Modifying the cursor code means the cursor can't stop on it
Compendium_Window.prototype.cursorDown = function(wrap) {
Window_Selectable.prototype.cursorDown.call(this,wrap);
if (this.index() == 0) {
this.cursorDown(wrap);
}
};

Compendium_Window.prototype.cursorUp = function(wrap) {
Window_Selectable.prototype.cursorUp.call(this,wrap);
if (this.index() == 0) {
this.cursorUp(wrap);
}
};

})();

[RMMV] Transfer to map instead of going to title

Very late seeing this so maybe you fixed it, but I believe this does what you need it to. Feel free to edit as you see fit.

//=============================================================================
// title.js
//=============================================================================

/*:
* @plugindesc Go to a map instead of going to title
* @author Redd
*
* @param none
* @desc none
* @default false
*
* @help
*
* Plugin Command:
*
*/

(function() {

Scene_GameEnd.prototype.commandToTitle = function() {
$gamePlayer.reserveTransfer(2, 0, 1, 2, 0);
SceneManager.goto(Scene_Map);
};

})();

You had 90% of it, but it was just hanging out in Scene_GameEnd forever because you need to tell it to go to Scene_Map.

Transferring Hero back to where they were after a cut scene. RMVX ACE

This strikes me as a moment where a plugin would make more sense. I could try making one for you.

Can you show me part of that list of commands where it's more clear what you're trying to do?

EDIT in fact looking closer, it might not even need a plugin, but can you show something clearer anyway?

EDIT of EDIT: oh wait ACE. I have it, but rusty with ruby.


FURTHER EDIT: OK if I am understanding this right, no scripts required, but first I need to know if you're using a common event to send the player to the cutscene.

Whatchu Workin' On? Tell us!

Yeah, but it's also about things like not having the AI use healing spells when nobody is injured, or buffs on targets that already have them. That kind of thing annoys me. I don't like them making entirely random choices and would like their choices to be weighted a little more to good ones. Naturally I agree that the AI shouldn't be taking the optimal choice all the time, and in fact if the enemy's intelligence is less than 100 the best choices will be unavailable.

Definitely trying to give the player opportunities to be smart and manipulate/screw the enemies out of making good choices, like with my Moods thread outline.

Whatchu Workin' On? Tell us!

Trying to code some smarter enemy AI for RMMV. It's going pretty well, got it creating evaluation objects for each possible skill and target combination, applying the basic rating as the evaluation score for now and then choosing a skill+target based on those scores.

But need to figure out how it chooses skill targets so I can overwrite that. Then it'll be all about adjusting those scores based on how much damage it does, if it kills, if it applies status etc... and balancing all of them against each other.

Yeah I know I can probably just DL an existing plugin, but I like doing it for myself!

Also, must be careful not to make it TOO smart, nobody likes that.

Making game overs engaging

This is a bit of a crutch for if a player is struggling, but some King of Fighters games allowed the player to choose a temporary bonus after losing a match to the AI and continuing. More attack, more defence, enemy starts with less life... these advantages aren't so strong that winning is certain but they do give a small leg-up, and of course the player can choose "no bonus" if they want to do it with no help.

I found it nice to be given the option of a small advantage to help you get past a tricky spot. I can see it working in a game that lets you restart battles if you die.

City of Heroes didn't take anything away from you for dying, but it did give EXP Debt, where half the XP you earned was put towards paying off the debt and you got to keep the other half. It sounds like it sucked but it wasn't that bad given how easily XP could flow in that game.

Hm, perhaps a game could be made where dying was the only way to proceed - say you need to travel between the nine circles of hell, and dying is the only way to get to the next circle. You'd want to gain as many levels and items as you could in your current circle, so you'd be ready to face the next circle after you deliberately die. Dying too early would make levelling in the next circle more challenging or just too difficult, making you completely unable to handle further circles or the final boss. So there would need to be some way to go back to circles you left accidentally, and you pay a penalty for travelling back there when you get there.

But this all sounds rather grindy and I don't know what kind of penalty for returning to a previous circle would be good... hm...
Pages: first 123 next last