DeejayKai

Warper
Member
Joined
Mar 31, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello all, I'm currently using Yanfly Instant Cast (http://yanfly.moe/2015/10/30/yep-22-instant-cast-2/) Sorry if i didn't link it correctly.

So I'm trying to let the user instant cast an item(not a specific item, any item), then have the item command disabled, then the user can choose their attack/skill, then it'll re-enable their item command when their turn comes around again.
..Then so on and so on for each actor in the party. So basically each actor can use items once and do one action per turn.
Currently, the user can just instant cast items endlessly until they attack, and then it'll go to the next person..Trying to find a fix..

I think I'd need a plugin that turns the command on/off on switch. But then to check if an item was used, and then re enabling when they're done their attack, not too sure how to go about that. Not too good in that area.;_;
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
696
Reaction score
622
First Language
German
Primarily Uses
RMMV
So you want to limit the usage of items to 1 for each actor each round?

Copy-paste this code into a new .js file and import it as a plugin. Place it at the bottom.
Code:
(function() {
  var _Game_Battler_initMembers = Game_Battler.prototype.initMembers;
  Game_Battler.prototype.initMembers = function() {
    _Game_Battler_initMembers.call(this);
    // Add variable to each actor, that determines wheter they used an item already
    this._alreadyUsedItem = false;
  };

  Window_ActorCommand.prototype.addItemCommand = function() {
    // Last parameter of this function determines, whether the command is
    // enabled or not. So it's enabled when the actor did not use an item
    this.addCommand(TextManager.item, "item", !this._actor._alreadyUsedItem);
  };

  var _Scene_Battle_onItemOk = Scene_Battle.prototype.onItemOk;
  Scene_Battle.prototype.onItemOk = function() {
    _Scene_Battle_onItemOk.call(this);
    // When they use an item, set the alreadyUsedItem variable to true
    var actor = BattleManager.actor();
    if (actor) {
      actor._alreadyUsedItem = true;
    }
  };
})();
 
Last edited:

DeejayKai

Warper
Member
Joined
Mar 31, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
So you want to limit the usage of items to 1 for each actor each round?

Copy-paste this code into a new .js file and import it as a plugin. Place it at the bottom.
Code:
(function() {
  var _Game_Battler_initMembers = Game_Battler.prototype.initMembers;
  Game_Battler.prototype.initMembers = function() {
    _Game_Battler_initMembers.call(this);
    // Add variable to each actor, that determines wheter they used an item already
    this._alreadyUsedItem = false;
  };

  Window_ActorCommand.prototype.addItemCommand = function() {
    // Last parameter of this function determines, whether the command is
    // enabled or not. So it's enabled when the actor did not use an item
    this.addCommand(TextManager.item, "item", !this._actor._alreadyUsedItem);
  };

  var _Scene_Battle_onItemOk = Scene_Battle.prototype.onItemOk;
  Scene_Battle.prototype.onItemOk = function() {
    _Scene_Battle_onItemOk.call(this);
    // When they use an item, set the alreadyUsedItem variable to true
    var actor = BattleManager.actor();
    if (actor) {
      actor._alreadyUsedItem = true;
    }
  };
})();
Okay, so it disables the item, which is fine, but it doesn't re-enable the item when their turn comes back around :/ Thanks for the code by
the way!
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
696
Reaction score
622
First Language
German
Primarily Uses
RMMV
@DeejayKai
Oh right! I totally forgot about that.

Code:
(function() {
  var _Game_Battler_initMembers = Game_Battler.prototype.initMembers;
  Game_Battler.prototype.initMembers = function() {
    _Game_Battler_initMembers.call(this);
    // Add variable to each actor, that determines wheter they used an item already
    this._alreadyUsedItem = false;
  };

  Window_ActorCommand.prototype.addItemCommand = function() {
    // Last parameter of this function determines, whether the command is
    // enabled or not. So it's enabled when the actor did not use an item
    this.addCommand(TextManager.item, "item", !this._actor._alreadyUsedItem);
  };

  var _Scene_Battle_onItemOk = Scene_Battle.prototype.onItemOk;
  Scene_Battle.prototype.onItemOk = function() {
    _Scene_Battle_onItemOk.call(this);
    // When they use an item, set the alreadyUsedItem variable to true
    var actor = BattleManager.actor();
    if (actor) {
      actor._alreadyUsedItem = true;
    }
  };

  var _BattleManager_startTurn = BattleManager.startTurn;
  BattleManager.startTurn = function() {
    _BattleManager_startTurn.call(this);
    // At the beginning of the turn, reset the used item flag
    $gameParty.battleMembers().forEach(function(actor) {
      actor._alreadyUsedItem = false;
    });
  };
})();

Now, it should work as expected. :)

Just a side note: Instead of quoting peoples posts, just use the @ followed by the username.
 

DeejayKai

Warper
Member
Joined
Mar 31, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
@waynee95
Ah sorry! Just made a forum account today :guffaw:
But yessssss, THANK YOU! It's working properly now!
I appreciate it!:D
 

Latest Threads

Latest Profile Posts

Continuing working on abs. So far I have done the workout twice. I am excited to see the results after a couple of weeks. How is everyone doing? :)
MZ: oh boy imma work today
Me, excited: Really?
MZ, doesn't do what I tell It too
Me: I Thought-
MZ: I am Working!
Oof, this "side project" of mine is starting to get as complex as a VS plugin, at least as far as plugin parameters are concerned. I think I now understand why a plugin like this doesn't already exist(that I know of). Learning a lot while trying to make it work though!
Had apparently not checked Itch for 3 months, kind of forgot I had an account rofl.
One side of me is: "lineart is so awful", the other side is just: "huh, decent" :kaoswt2:
Uehu8tg.jpg

Forum statistics

Threads
112,211
Messages
1,066,590
Members
145,816
Latest member
hasiltogelhk
Top