ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
979
Reaction score
576
First Language
Javascript
Primarily Uses
RMMZ
There's not really an easy way to force an item to be used from mainMenu/map correct?

Question:
What's the best way to force the player use an item (even if the player doesn't even have the inventory)?

Current Answer (formatted to fit in script box):
See demo :)

Edit:
Think this is about solved now just tweaking a few things:

Demo of it in action:
[RMMV] Combine Items (No Plugins) by ct_bolt
Download demo to see how it works.
 
Last edited:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,967
Reaction score
14,817
First Language
English
Primarily Uses
RMVXA
Use the use key item command. It will store the item they select in a variable, then you have to check that the ID in the variable matches what you want them to use.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
979
Reaction score
576
First Language
Javascript
Primarily Uses
RMMZ
Use the use key item command. It will store the item they select in a variable, then you have to check that the ID in the variable matches what you want them to use.
Thanks for the reply but I don't think that's what i need... I know how to check and store the item Id (and whole item data object for that matter)

Sorry I should have been more clear... I the programmer want to use any item's effects/damage formula/animation/etc. at any given time using the a selected item from the menu screen (map too maybe would be nice). (Then if and usable of party member I can pull up the actor window and store that to be used also. Already have this part)

...but ...then how will it use it?

My ultimate goal is this to help with this:
..With no plugins being used...
...My current solution is to use a 'dummy' item to run a common event...
that would use a choice ["use", "combine", "cancel"] ...and then link it to another real item...

...LOL there is probably a much easier way...
 
Last edited:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,502
Reaction score
413
First Language
German
Primarily Uses
RMMV
In VX-Ace you could use the following Code in the Eventcommand Script to use an Item from the Key Item Menu like an Item from the real Menu.
Control Var1 = 0
Eventcommand Key Item List. Store Choice in Var1.
Conditional Branch if Var1 is above 0 (else the following code would crash the game if its 0 because no item id0 exists. And its 0 if you cancel the selection, thats why we do this conditional branch)
Here the Script Snippet:
Code:
hero = $game_party.members[0]#<- User ; i believe you needed to  change the 0 to a 1, not sure.
item = $data_items[0]  #[]<-Item_Id ; exchange with var1 $data_items[$game_variables[1]]
hero.use_item(item)
targets = if !item.for_friend?
[]
elsif item.for_all?
$game_party.members
else
[hero]
end
targets.each do |target|
item.repeats.times{target.item_apply(hero,item)}
end
This sadly does not exist for MV, but for MV exists a smal Plugin to atleast show Item description in the Key Item Menu.

Maybe this helps somehow.

Edit: I cant remember who exactly wrote this Code, but it was for free usage in a Forums help Thread.
 
Last edited:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
979
Reaction score
576
First Language
Javascript
Primarily Uses
RMMZ
In VX-Ace you could use he following Code in the Eventcommand Script to use an Item from the Key Item Menu like an Item from the real Menu.
Control Var1 = 0
Eventcommand Key Item List. Store Choice in Var1.
Conditional Branch if Var1 is above 0 (else the following code would crash the game if its 0 because no item id0 exists. And its 0 if you cancel the selection, thats why we do this conditional branch)
Here the Script Snippet:
Code:
hero = $game_party.members[0]#<- User ; i believe you needed to  change the 0 to a 1, not sure.
item = $data_items[0]  #[]<-Item_Id ; exchange with var1 $data_items[$game_variables[1]]
hero.use_item(item)
targets = if !item.for_friend?
[]
elsif item.for_all?
$game_party.members
else
[hero]
end
targets.each do |target|
item.repeats.times{target.item_apply(hero,item)}
end
This sadly does not exist for MV, but for MV exists a smal Plugin to atleast show Item description in the Key Item Menu.

Maybe this helps somehow.

Edit: I cant remember who exactly wrote this Code, but it was for free usage in a Forums help Thread.
Actually yes i think that did kind of help, trigger a thought at the very least. Made me remember about "Game_Action"
Code:
Game_Action.prototype.apply = function(target) {
    var result = target.result();
    this.subject().clearResult();
    result.clear();
    result.used = this.testApply(target);
    result.missed = (result.used && Math.random() >= this.itemHit(target));
    result.evaded = (!result.missed && Math.random() < this.itemEva(target));
    result.physical = this.isPhysical();
    result.drain = this.isDrain();
    if (result.isHit()) {
        if (this.item().damage.type > 0) {
            result.critical = (Math.random() < this.itemCri(target));
            var value = this.makeDamageValue(target, result.critical);
            this.executeDamage(target, value);
        }
        this.item().effects.forEach(function(effect) {
            this.applyItemEffect(target, effect);
        }, this);
        this.applyItemUserEffect(target);
    }
};
this might save me a bunch a extra steps... If I can utilize it properly that is...

Thank you both for any and all replies :) Any help is appreciated :)

Edit:
Tesing this now...
Code:
(function(v,i,t,a,c,u) {
  if (i = $dataItems[+v || 0]) {
    u = $gameParty.members()[0];
    a = new Game_Action(u);
    a.setItemObject(i);
    t = i.scope === 7 ? [u] : a.makeTargets();
    for (n in t) c = c || a.testApply(t[n]);
    if (u.canUse(i) && (i.scope === 0 || c)) {
      u.useItem(i);
      for (n in t) for (var m = a.numRepeats(); m--;) a.apply(t[n]);
      a.applyGlobal();
}}})(YOUR_ITEM_ID_HERE);

Edit:
yup yup, working pretty great now :)
Thanks for all the info :)

Solution so far (Animation not working on map yet though):
Code:
var itemId = 11, memberId = 0; $gameParty.gainItem($dataItems[itemId], 1);
(function(v,i,t,a,c,u) {
if (i = $dataItems[+v || 0]) {
u = $gameParty.members()[memberId];
a = new Game_Action(u);a.setItemObject(i);
t = i.scope === 7 ? [u] : a.makeTargets();
for (n in t) c = c || a.testApply(t[n]);
if (u.canUse(i) && (i.scope === 0 || c)) {u.useItem(i);
  for (n in t) for (var m = a.numRepeats(); m--;) if ($gameParty.inBattle() && i.animationId) {t[n].startAnimation(i.animationId);} a.apply(t[n]);
  a.applyGlobal();
}}})(itemId); $gameParty.loseItem($dataItems[itemId], 1);
 
Last edited:
  • Like
Reactions: Bex

Latest Threads

Latest Posts

Latest Profile Posts

Sizzle sizzle sizzle...
zbf1dCZ.gif
Sharing my past was a mistake. Will delete the post when I get access to a working internet connection again.
TFW you get a plugin working correctly with your other plugins ♡\( ̄▽ ̄)/♡

(CW for minor gore - Einar's Y incision is gone for his test portrait)

Cs5kAbZ.png
Doing some winter related edits for a cozy cottage!
I think it's the third time I am changing my skill info plugin, but as I get better at programming, I want to fix the trash I made earlier :p

Streaming while I am programming the plugin. Join in if you wish :)

Forum statistics

Threads
116,981
Messages
1,103,496
Members
152,845
Latest member
Zynarith2
Top