I just want to ask in which way can I determine which skill is selected by the actor. I am making a variable change whenever I select a skill and I don't know how to determine each and everyone of them. Note that I am using a note tag
<variable: x>in each of the skills. So, when I select Cleave for example and cleave has <variable: 10>, it should read the variable and equate it to the variable. Of course, I already have the script for reading the note tag, so what I directly want to know is I want to equate this right before the skill is used.
Do you mean when the skill is selected, or when the skill is used? You've said both, and they happen at different times.
What do you want to do - increment the variable each time it's used? But you don't want to just do that in the damage formula?
When you say "it should read the variable and equate it to the variable" what do you mean? Do you just have a single variable, and you want to put whatever number is in the skill's note tag into that variable? Or do you have multiple variables (indicated by a different number in each note tag) and you want to change that variable?
What you have to do, and where you have to do it, depends on the answers to those questions.
When I am in the actor command and select the skill. I want to add a value to the variable everytime I select the skill before even using it. Because if its on the time I use it, the effect of the variable happens is one turn late (via item_apply).
I edited my post. Can you please explain what you want to do? Put the value that's in the note tag into a variable (using the same variable for all skills), or increment the variable that's listed in the note tag?
Have you considered what would happen if the player selected one skill for an actor and moved onto the next, then used Esc to undo that action and selected a different skill? If you're just setting a single variable to whatever is in the note tag, that'd be fine, as it'd be overwritten. But if you're incrementing a variable, you'd actually increment both of them. The same would happen if you're changing stats or something - they select one thing, you change stats, they Esc from the next actor and go back to the last one and select a different skill, and something different happens.
If you leave it until all selections have been made and the action is about to start and THEN apply your logic, you could just loop through each actor and determine what they're doing and update the variable (or whatever else you want to do) at that point. So after the action has been committed, but before it's executed.
Oh - I thought you were talking about $game_variables.
You could do that in 2 lines:
$game_system.variable_add = $1.to_iinstead of putting it into an instance variable (which doesn't need the @ unless you want it to be available elsewhere in the class as well and don't want to use $game_system.variable_add for some reason. If you're just having it for the conversion and then you're not going to do anything else with it, you don't need the @.
Anyway ...
You could do it there, but that's when the skill is actually used. Also, if an enemy used the same skill it would happen as well.
If you want to use it immediately after selecting the skill, put it in Scene_Battle.on_skill_ok
HOWEVER, if you have 4 actors all select skills in a row, $game_system.variable_add will have whatever was in the note for the skill used by the LAST actor. If you want this to do something for each actor, you would have to add the logic in there to actually process what you want to do at that time. But then you get the same issue of "what happens if they select a skill, you apply whatever effects you want, and then they back up and select a different skill?"
I don't know that I can help you further without an explanation of what you're trying to do - what are you doing with variable_add?
Ohhh, on_skill_ok seems like a part I missed. What I am trying to do with the variable add is like I will use the variable as an extra damage when I am at a certain state. That is another problem I am thinking of, since I have like 4 actors, and the others you have pointed out, sadly, is away from my scripting skill. I don't know how to solve that either.
No probs. It might need tweaking, as I'm still only guessing what you're trying to do with it.
I have another question and seemingly the last problem 😮
def on_skill_ok milena_on_skill_ok if $data_skills[@skill.id].note =~ /<variable:\s?(\d+)>/i $game_system.variable_add[BattleManager.actor.id] = $1.to_i end end but after that, whenever I finish commanding my party, a new problem occurs. So I use this on another method:
state_power = $game_system.variable_add[]How can I determine which variable I should apply depending on which actor was that of?
BattleManager.actor.id has the current actor's id.
Other than that, I don't really know. I don't know what battle_wait_var is or why it's an array. You'd really need to explain the whole thing that you're trying to do, otherwise I'm just grasping at bits and pieces and guessing at a lot of things. It could be that everything I've told you is wrong because I'm making assumptions based on the little bits of information you're giving me.
Why not just say what you're trying to do, post the whole script you've done, and let people help you based on known information rather than guesses?
Oh sorry, it seems I have been doing something wrong. So basically, this is what I am trying to do.
Whenever I select a skill from an actor, it adds a value through the variable_add on Game_System. Now, I just want those variables to affect something. In this case, here's the script:
class Game_System alias milena_initialize initialize def initialize @variable_add = [] for i in 0..$data_actors.size @variable_add = 0 end milena_initialize endendclass Scene_Battle < Scene_Base alias milena_on_skill_ok on_skill_ok alias milena_start_actor_command_selection start_actor_command_selection alias milena_turn_end turn_end def on_skill_ok milena_on_skill_ok if $data_skills[@skill.id].note =~ /<variable:\s?(\d+)>/i game_system.variable_add[BattleManager.actor.id] = $1.to_i end end def start_actor_command_selection milena_start_actor_command_selection $game_system.variable_add[BattleManager.actor.id] = 0 end def turn_end @state_power = $game_system.variable_add[BattleManager.actor.id] milena_turn_end endendMy problem is of how to determine which skill was used so I'd know what variable is the value of @state_power. This is because the state_power would be determined in turn end.
However, if we get passed on_skill_ok its not going to work.
affect what? What is @state_power? Again, you've got a single variable for the whole battle - if you want it to apply to individual actors, you can't use a single variable for the whole class.
You may not need to use Game_System at all, if everything you are trying to do is inside a battle. If only you would actually tell me the whole thing, instead of bits and pieces. I do understand if you don't want to, but I can't help anymore in that case. I don't like trying to give suggestions when I'm only getting little glimpses into what you're trying to do.
The best place to call this is in the 'apply_item_effects' method in Scene_Battle. You can access the user (called @subject in the method), the target and the item there, so you can do whatever you want with them BEFORE the original effects are happening. This means you can use your new variables within your damage formulas without any issue.
Whatever you want to reset at the end of the turn, you can do that in the 'turn_end' method in Scene_Battle. But you do NOT have access to any user or target by that time, so you will need to find another place to do your stuff with the reset thingy. Game_Battler's 'on_turn_end' method would probably be your best shot.
That wait thing, I don't understand...
You added the waiting amount and the variable_add together and left it as is in that method.
That will surely not work.
If you want to add the duration to the variable_add, you should do it like this:
$game_system.variable_add[BattleManager.actor.id] += durationBut I don't know if that will work during the execution of turns.If not, you can try this:
if BattleManager.in_turn? && @subject.is_a?(Game_Actor) $game_system.variable_add[@subject.id] += durationendNo idea if this will work or not.Another thing...
If you want this new variable to be tied with an actor always, why don't define it in Game_Battle instead of making an array in Game_System? Defining it in Game_Battler would make your scripting much easier, because you can call any method defined in Game_Battler easily and directly in your new method(s).