that would involve you modifying the selection methods
Ruby/RGSSx questions that don't deserve their own thread
RGSSx Script SupportSo I found this:
#-------------------------------------------------------------------------- # * Skill [OK] #-------------------------------------------------------------------------- def on_skill_ok @skill = @skill_window.item BattleManager.actor.input.set_skill(@skill.id) BattleManager.actor.last_skill.object = @skill if [email protected]_selection? @skill_window.hide next_command elsif @skill.for_opponent? select_enemy_selection else select_actor_selection end endYou can put the id directly there with a conditional branching, but the problem is, what about the other actor?
#-------------------------------------------------------------------------- # * Skill [OK] #-------------------------------------------------------------------------- def on_skill_ok @skill = @skill_window.item BattleManager.actor.input.set_skill(@skill.id) BattleManager.actor.last_skill.object = @skill if [email protected]_selection? @skill_window.hide next_command elsif @skill.for_opponent? select_enemy_selection else select_actor_selection end endYou can put the id directly there with a conditional branching, but the problem is, what about the other actor?
Well, first when do you want the forced action to be triggered? I mean, right after the player select the skill? or after the player select the enemy target? or after turn start and it's the said actor turn to perform action?
I believe after the turn started and it's the time for the said actor to make moves, so when he/she ready to makes his/her move, instead using the said skill/item, the said actor will forced to use another skill that already set to be used(maybe in common event or else). Am I right? Sorry if not, I don't really understand. If I'm right, perhaps you need to modify this method :
(I remember I had writo a similar code about somthing like this in another topic yesterday, but the problem is not same like this)
class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # * Use Skill/Item #-------------------------------------------------------------------------- alias my_use_item_alias use_item def use_item my_item = @subject.current_action.item my_use_method(my_item) return if @use_my_use_method == true # do not do the rest of the code if this variable true my_use_item_alias # original method, do this if forced action is not triggered. enddef my_use_method(my_item) @use_my_use_method = false return if @subject.is_a?(Game_Enemy)# skip this method if the subject is enemy return unless @subject.id == 1 # actor_id for example : Eric is 1, so skip if it's not Eric return if my_item.is_a?(RPG::Item) # skip this method if this action is using an item if my_item.id == 80 # your wanted skill id to be altered with forced skill, 80 is Strong Attack skill = $data_skills[10] # in this case 10 is Shock @log_window.display_use_item(@subject, skill) @subject.use_item(skill) refresh_status targets = @subject.current_action.make_targets.compact show_animation(targets, skill .animation_id) targets.each {|target| skill .repeats.times { invoke_item(target, skill ) } } @use_my_use_method = true # This needed to check if forced action is triggered or not. end end endPerhaps the code above is something that you want? Sorry if not 🙂 .
EDIT : Why I keep doing typo2 means 80
I believe after the turn started and it's the time for the said actor to make moves, so when he/she ready to makes his/her move, instead using the said skill/item, the said actor will forced to use another skill that already set to be used(maybe in common event or else). Am I right? Sorry if not, I don't really understand. If I'm right, perhaps you need to modify this method :
(I remember I had writo a similar code about somthing like this in another topic yesterday, but the problem is not same like this)
class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # * Use Skill/Item #-------------------------------------------------------------------------- alias my_use_item_alias use_item def use_item my_item = @subject.current_action.item my_use_method(my_item) return if @use_my_use_method == true # do not do the rest of the code if this variable true my_use_item_alias # original method, do this if forced action is not triggered. enddef my_use_method(my_item) @use_my_use_method = false return if @subject.is_a?(Game_Enemy)# skip this method if the subject is enemy return unless @subject.id == 1 # actor_id for example : Eric is 1, so skip if it's not Eric return if my_item.is_a?(RPG::Item) # skip this method if this action is using an item if my_item.id == 80 # your wanted skill id to be altered with forced skill, 80 is Strong Attack skill = $data_skills[10] # in this case 10 is Shock @log_window.display_use_item(@subject, skill) @subject.use_item(skill) refresh_status targets = @subject.current_action.make_targets.compact show_animation(targets, skill .animation_id) targets.each {|target| skill .repeats.times { invoke_item(target, skill ) } } @use_my_use_method = true # This needed to check if forced action is triggered or not. end end endPerhaps the code above is something that you want? Sorry if not 🙂 .
EDIT : Why I keep doing typo
This is exactly what I wanted. I would tweak this a little bit to produce what I wanted to do. Another question, is it possible to boot out some of your party members in battle and replace it with a new one when a certain condition is met?
Are you saying that for example the initial party is Eric, Natalie, and Terence, then in the middle of battle we kick out Natalie, and replace her with Ryoma or else? That is actually something that I never tried, to be honest I just thought of that now after you say it 😛 . Right now, I don't know the exact answer, I just can't find out how is that can be done, so I'm sorry, I can't help you, perhaps somebody can give the answer about this matter, I will follow this topic too I'm curiouse too 🙂 .
EDIT : Well it turns out that my Battle Engine is not letting me change actor in the middle of battle, but when I tried in new project(just now), yes it can be changed, but now your question is can be changed in a certain condition, hmm.. Yes I believe it can be done, I(or we) just need to do some research.. Oh yeah thanks for asking that question 🙂
EDIT2 : Ah now all is clear, the answer is Yes we can, and to do that it's actually really easy, but it depends on what you want to accomplish, if it's just to change actor in certain battle then it's simple, just go to the troop event page, and make a conditional branch, move to tab 2 which there is Actor, then there are several conditions there except HP(because we can check conditional HP via the page condition itself), Now you can choose a condition to be met, for example death state,
If Natalie is Death inflicted
> Change Party Member: Remove Natalie
> Change Party Member: Add Ryoma
else
>
end
And for the Condition Page we can change it to "When the end of turn"
I have tried it and it works well 🙂
Thanks, that works just fine.
Quick question guys! A bit confused about the difference between Input.press, Input.trigger and Input.repeat.
Input.press activates on being pressed, and continues activating as long as the button is held down.
Input.trigger activates on being pressed, and does not repeat when held down continuously.
Input.repeat does more or less the same thing as Input.press?
The manual says for Input.repeat?(sym):
---
Determines whether the button corresponding to the symbol sym is currently being pressed again.
"Pressed again" is seen as time having passed between the button being not pressed and being pressed.
Unlike trigger?, takes into account the repeated input of a button being held down continuously.
---
How is that different from just using Input.press?
Edit: Nevermind, I figured out the answer to my own question less than a minute later.
Input.press activates continuously, once per frame, whereas Input.repeat doesn't repeat immediately, and has longer pauses between activations, which is key for handling menu cursors.
That is VERY interesting! Now I know what I need to change in my mouse script to stop the menus scrolling so blindingly fast! Thank you for sharing your discovery 🙂
Hey guys.
I have a custom script with a method in it:
class Mech_Combine_Items def combine_items $game_party.gain_item('Potion', 1) endendIs there a way that I can call this method from inside an event?
I have a custom script with a method in it:
class Mech_Combine_Items def combine_items $game_party.gain_item('Potion', 1) endendIs there a way that I can call this method from inside an event?
Actually to call a method inside an event we will use a call Script in the last tab of event command menu.
But first we need to define that method in Game_Interpreter class.
Basically all methods in Game_Interpreter class can be called via Script in event command menu.
So you want to define that method in class Game_Interpreter like this :
class Game_Interpreter def combine_items $game_party.gain_item('Potion', 1) endend # End of Game_InterpreterThen try to make an event and make a command script call this method in the script box
combine_items
Then it will call the method combine_items when you trigger this event.
However as I can see, that code inside the method, it will produce an error, why ? Because in here: $game_party.gain_item('Potion', 1)
You passing a wrong argument, the first argument for gain_item method isactual actually a RPG::Item object, and the second is the amount you want the item to be added in your party inventory. In this case you should know why it will produce an error right? Yes, the first argument you pass is a string.
You can find the global variable that storing all of RPGVXAce data in module DataManager
#-------------------------------------------------------------------------- # * Load Normal Database #-------------------------------------------------------------------------- def self.load_normal_database $data_actors = load_data("Data/Actors.rvdata2") $data_classes = load_data("Data/Classes.rvdata2") $data_skills = load_data("Data/Skills.rvdata2") $data_items = load_data("Data/Items.rvdata2") $data_weapons = load_data("Data/Weapons.rvdata2") $data_armors = load_data("Data/Armors.rvdata2") $data_enemies = load_data("Data/Enemies.rvdata2") $data_troops = load_data("Data/Troops.rvdata2") $data_states = load_data("Data/States.rvdata2") $data_animations = load_data("Data/Animations.rvdata2") $data_tilesets = load_data("Data/Tilesets.rvdata2") $data_common_events = load_data("Data/CommonEvents.rvdata2") $data_system = load_data("Data/System.rvdata2") $data_mapinfos = load_data("Data/MapInfos.rvdata2") end
Now what we want is the RPG::Item object, so we use $data_items[1], why 1? because in the items database potion is at index 1.And yes $data_items is an array, same with the others, and the value in each element of them(the global variable) is a RPG data which you can see in the database. So $data_actors is for actors database, $data_classes is for classes database, and so on.
Okay I can'e explain it all right now, but I hope you get the grasp. 🙂
So the code inside your code must be changed to be like this : $game_party.gain_item($data_items[1], 1)
Well, hopefully that gives you more clarity.
But first we need to define that method in Game_Interpreter class.
Basically all methods in Game_Interpreter class can be called via Script in event command menu.
So you want to define that method in class Game_Interpreter like this :
class Game_Interpreter def combine_items $game_party.gain_item('Potion', 1) endend # End of Game_InterpreterThen try to make an event and make a command script call this method in the script box
combine_items
Then it will call the method combine_items when you trigger this event.
However as I can see, that code inside the method, it will produce an error, why ? Because in here: $game_party.gain_item('Potion', 1)
You passing a wrong argument, the first argument for gain_item method is
You can find the global variable that storing all of RPGVXAce data in module DataManager
#-------------------------------------------------------------------------- # * Load Normal Database #-------------------------------------------------------------------------- def self.load_normal_database $data_actors = load_data("Data/Actors.rvdata2") $data_classes = load_data("Data/Classes.rvdata2") $data_skills = load_data("Data/Skills.rvdata2") $data_items = load_data("Data/Items.rvdata2") $data_weapons = load_data("Data/Weapons.rvdata2") $data_armors = load_data("Data/Armors.rvdata2") $data_enemies = load_data("Data/Enemies.rvdata2") $data_troops = load_data("Data/Troops.rvdata2") $data_states = load_data("Data/States.rvdata2") $data_animations = load_data("Data/Animations.rvdata2") $data_tilesets = load_data("Data/Tilesets.rvdata2") $data_common_events = load_data("Data/CommonEvents.rvdata2") $data_system = load_data("Data/System.rvdata2") $data_mapinfos = load_data("Data/MapInfos.rvdata2") end
Now what we want is the RPG::Item object, so we use $data_items[1], why 1? because in the items database potion is at index 1.And yes $data_items is an array, same with the others, and the value in each element of them(the global variable) is a RPG data which you can see in the database. So $data_actors is for actors database, $data_classes is for classes database, and so on.
Okay I can'e explain it all right now, but I hope you get the grasp. 🙂
So the code inside your code must be changed to be like this : $game_party.gain_item($data_items[1], 1)
Well, hopefully that gives you more clarity.
class Game_Interpreter def combine_items $game_party.gain_item('Potion', 1) endend # End of Game_Interpreter
Code:
#-------------------------------------------------------------------------- # * Load Normal Database #-------------------------------------------------------------------------- def self.load_normal_database $data_actors = load_data("Data/Actors.rvdata2") $data_classes = load_data("Data/Classes.rvdata2") $data_skills = load_data("Data/Skills.rvdata2") $data_items = load_data("Data/Items.rvdata2") $data_weapons = load_data("Data/Weapons.rvdata2") $data_armors = load_data("Data/Armors.rvdata2") $data_enemies = load_data("Data/Enemies.rvdata2") $data_troops = load_data("Data/Troops.rvdata2") $data_states = load_data("Data/States.rvdata2") $data_animations = load_data("Data/Animations.rvdata2") $data_tilesets = load_data("Data/Tilesets.rvdata2") $data_common_events = load_data("Data/CommonEvents.rvdata2") $data_system = load_data("Data/System.rvdata2") $data_mapinfos = load_data("Data/MapInfos.rvdata2") end
Okay I can'e explain it all right now, but I hope you get the grasp. 🙂
So the code inside your code must be changed to be like this : $game_party.gain_item($data_items[1], 1)
Well, hopefully that gives you more clarity.
Thanks BoluBolu. I've got it working now thanks to you. I also moved the code out of the interpreter into my class just to tidy things up.
The code in the interpreter:
def combine_items Mechanics_Combine_Items.combineendThe code inside the Mechanics_Combine_Items class:
Code:
def self.combine $game_party.gain_item($data_items[1], 1) end
Does your script overwrite the Game_Party.gain_item method to allow you to pass in an item name?
Not at the moment no. I'm trying to work around the platform's code for now.
then calling $game_party.add_item('Potion', 1) will result in an error. You have to pass the object through to that method, not the description. Unless you're overwriting the method.
It would be $game_party.add_item($data_items[5], 1) - assuming Potion is item 5 in the database.
It would be $game_party.add_item($data_items[5], 1) - assuming Potion is item 5 in the database.
Yeah, In my last message with code you can see me using the data items array.
lol. Yeah, I missed that one 🙂
Yeah no problem, I'm curious about what you want to accomplish/or make by that, I mean there's change item command right? But anyway good luk with your goal. 🙂
Another question:
How can I make a skill not usable when some condition is not met? For example, I only want the skill to be usable when a certain actor is existent on my party. I am guessing it should be inside item_apply. I want the skill to be greyed out on the Skill List even if such TP or MP is met.
How can I make a skill not usable when some condition is not met? For example, I only want the skill to be usable when a certain actor is existent on my party. I am guessing it should be inside item_apply. I want the skill to be greyed out on the Skill List even if such TP or MP is met.
@Milena - you should look into the Game_BattlerBase's 'enable?' method. That is what determines if item and skill conditions are met 🙂
There's no enable? method from Game_BattlerBase?
It's in Window_ItemList. You could also look at the include? method (which would allow you to not show it at all if it can't be used)
Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/