I have a question over hash values and array values as the values of Hash. First of all, here's the code I come to question:
module RMW Pairs = { 1 => [1, 2], 2 => [3, 4], 3 => [5, 6] } Pairs_Function = { 1 => 7, 2 => 8, 3 => 9 }endclass Game_Battler < Game_BattlerBase alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) if user.is_a?(Game_Actor) puts "More Activation Process Here" end endendIn this code, I haven't obviously used the module. My question goes like this:
I want to check if the user is any of the Pairs hash. As far as I know, I can only check whether one from the values are existent in the Pairs hash. Is there a way to check if ANY of those hash values to return the skill's effect?
My idea is like this:
When any of the actors listed in the Pairs module used the skill, they would gain an item from the Pairs_Function, which, the item_id should be similar to the key of who used the skill.
So for example, if:
1 => Eric and Natalie
and Natalie uses the Skill, then, they would gain Potion, since on the Pairs_Function:
1 => 7
since Eric and Natalie belongs to Key 1.
Is this possible? What is the possibility of this happening?
You need to explain what your numbers mean a little more.
You haven't got 1 => 1 anywhere in your code - I'm assuming it's a typo and you either should have had 1 => 1 instead of 1 => 7 in the code, or 1 => 7 in the example instead of 1 => 1?
So I'm guessing the key to both hashes is the skill id? And the values in the first hash are arrays containing actor ids, and the values in the second array are item ids?
I think something like this might work:
Code:
class Game_Battler < Game_BattlerBase alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) if user.actor? and item.is_a?(RPG::Skill) and RMW::Pairs.has_key?(item.id) and RMW::Pairs[item.id].include?(user.id) puts "More Activation Process Here" end endend
You need to explain what your numbers mean a little more.
You haven't got 1 => 1 anywhere in your code - I'm assuming it's a typo and you either should have had 1 => 1 instead of 1 => 7 in the code, or 1 => 7 in the example instead of 1 => 1?
So I'm guessing the key to both hashes is the skill id? And the values in the first hash are arrays containing actor ids, and the values in the second array are item ids?
I think something like this might work:
class Game_Battler < Game_BattlerBase alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) if user.actor? and item.is_a?(RPG::Skill) and RMW:airs.has_key?(item.id) and RMW:airs[item.id].include?(user.id) puts "More Activation Process Here" end endend
Thanks Shaz! I tweaked it a bit so I can make some party actions and messages along when the user does that Sorry, it was a typo, so I edited my post back. Here's another question though, does this apply to arrays too?
You could do something similar to arrays, where your skill id is the index of the array, and the array elements are themselves arrays. In that case it'd look something like this:
Code:
module RMW Pairs = [[1,2],[3,4],[5,6]] Pairs_Function = [7, 8, 9]endclass Game_Battler < Game_BattlerBase alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) if user.actor? and item.is_a?(RPG::Skill) and !RMW::Pairs[item.id].nil? and RMW::Pairs[item.id].include?(user.id) puts "More Activation Process Here" end endend
Note - you would need to put nil in if there was no skill with that id (if you leave spaces in your database), or define them like this:
Thank you for explaining. I've read the answer on the other thread and since it should still be included here, then I might as well post it here, so if anyone is interested to answer it, then they'll just reply here.
---
Second Problem:
But how does it exactly return whether a list of skill can be enabled regardless of their nature requirements through the script?
Here's the full script in question:
module RMW Pairs = { 1 => [1, 2], 2 => [3, 4], 3 => [5, 6] } Pairs_Function = { 1 => 7, 2 => 8, 3 => 9 }endclass Game_Battler < Game_BattlerBase alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) if user.actor? and item.is_a?(RPG::Skill) and RMW:airs.has_key?(item.id) and RMW:airs[item.id].include?(user.id) puts "More Activation Process Here" end endendthe thing is, I wanted to make the skill greyed out when an game actor's id is not in any of the RMW:airs hash key value. So say for example the party members are:
Eric, Natalie and Terence...
and as Eric uses the skill, it should be greyed out when the required condition is that if any actor listed in
1 => [1, 2],
2 => [3, 4],
3 => [5, 6]
}
does not exist currently in battle. Say for example, since Actors 4, 5, and 6 does not exist in battle, the skill should be still greyed out. If any of them is in battle can only be the skills used.
-- this is the exact words, so I just made a copy and paste of it. Hope someone can answer the question
Game_Battler.item_apply happens AFTER you use the item. It has nothing to do with making it available or unavailable. As I said in that thread, Window_ItemList has the enable? method. This is what determines if it's selectable or greyed out. If you look at the logic and follow it back, you'll see that it goes all the way back to Game_BattlerBase.skill_conditions_met?(skill)
Since you don't want this to apply to enemies, you could create a Game_Actor version of that method which will call super to do the normal processing, and then do your check to see if the actor is in the list for the skill id. This way, you can get rid of the user.actor? test because it will only run for actors. And since it is only called for skills, you can also get rid of the skill test.
So you'd end up with something like this:
class Game_Actor < Game_Battler def skill_conditions_met?(item) super(item) and !RMW:airs[item.id].nil? and RMW:airs[item.id].include?(actor.id) endendHowever, that would only let the actor use the skill if they were in the list. If you want ANYONE to be able to use skills that are NOT in the list, you could change it to this:
Code:
class Game_Actor < Game_Battler def skill_conditions_met?(item) super(item) and (RMW::Pairs[item.id].nil? or RMW::Pairs[item.id].include?(actor.id)) endend
I haven't tested these, so you might need to tweak them a bit.
There seems to be two problems appearing right now... the first script suggestion you gave allowed me to use the skill, but closes my attack and guard skill, while the second script suggestion you gave allowed me not to use the skill, my attack and my guard.
To be clear, the particular set of skills, probably in an array should only show if they are inside any values of they keys in Pairs hash.
So in function, 128, 129, 130 id of skills would be greyed out if the party members don't have the member ids of the values inside Pairs module. Is this possible?
First I want to make a spoiler for this, because it's rather long
This is not good :Look at the original method below:
I don't really know what you want, but that is not a healthy alias, because the original method will always executed before your code, I mean it may produce something that you didn't want, (err.. How can I explain this?)
Instead, you should do it like this :
But to give return in your code, we(you) should know what should happen, I mean if this condition is true, do we need to call the original method or not? If yes, then we don't need to give the return. But that's not only it, take a look again at the original method of item_apply
It also got so some conditional checks and this is the most important :
As you can see, things can become complicated, if by any chance your code also involving execute an action or else, the actor may do two actions in a row and we don't want that to be happened unless that is your purpose, that's why we put return in your additional code. But if we put return in the last line of your additional code, you also need to write a code for the actor to do an execute action or something like that, so he/she didn't end without doing nothing.
But all of that is you who know what happen actually(how can we know right? ) In fact, I got confused ? So ignore this post if this is all a wrong suggestion, and I'm sorry about that..
alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) heartfire_rmw(user, item) <= This can be dangerous! if user.actor? and item.is_a?(RPG::Skill) and RMW:airs.has_key?(item.id) and RMW:airs[item.id].include?(user.id) puts "More Activation Process Here" end endend
Code:
#-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) if @result.hit? # What happen if this is true? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end end
Code:
alias :heartfire_rmw :item_apply #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) if user.actor? and item.is_a?(RPG::Skill) and RMW::Pairs.has_key?(item.id) and RMW::Pairs[item.id].include?(user.id) puts "More Activation Process Here" return <= this ensure that if the code here is done, we don't need to do the original method end heartfire_rmw(user, item) <= This can be dangerous! endend
Code:
if @result.hit? # What happen if this is true? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) <= this thing end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item)
Okay now this : it should be greyed out and this : whether a list of skill can be enabled regardless of their nature requirements through the script?
Is a two different thing. To simply greying out an item/skill in window,
As I said in that thread, Window_ItemList has the enable? method. This is what determines if it's selectable or greyed out.
That was Shaz telling at you, and yes enable? method in Window_ItemList is the actual code to determine if the item is greyed out or not, it got nothing to do with if the item is ACTUALLY CAN be used or not, it just simply makes you cannot access it. If you want an example, just overwrite this :
#-------------------------------------------------------------------------- # * Display in Enabled State? #-------------------------------------------------------------------------- def enable?(item) # $game_party.usable?(item) <= comment it for now true # <= put true here endNow even logically the item cannot be used, it will not greyed out and if you try to press 'confirm' it won't play buzzer, though the functionality of that item is vague and usually things will get uncontrollable/messy(what is the word), That's why items_conditions_met? method is needed, and $game_party.usable?(item) actualy calling this method
def usable?(item) return skill_conditions_met?(item) if item.is_a?(RPG::Skill) # <= this for skills return item_conditions_met?(item) if item.is_a?(RPG::Item) # <= this for items return false endYou can ignore this, it just a little explanation about enable? method
Now thing that you should know again, is
enable? method in Window_ItemList and Window_SkillList is not same, but it's similar. Take a look at the enable? method code they has, the different is, if for item basically it will check if there's an actor or not in the party, then it will check wether the item is usable or not, but for skill, it not just checking wether there's an actor or not in the party, it will check if CERTAIN actor is exist or not, if we talk about certain I mean he/she that has the skill, right after that it will check wether the skill is usable or not(involving MP needed and etc).
Let's get to the point..
What you want is greying out the skill in Window_SkillList if certain actor is not exist in battle(or possibly dead?)
Is this some kind like Party Skill/or Combination Skill, so if actor X is not exist or dead, then actor Y can't cast the skill?
Okay the fact is I don't really know what you want(I'm sorry ), But I think the logic is quite simple, just greying out that skill if the actors that is needed were not exist, or dead, because if that skill is greyed out, the player would cannot access that skill regardless anything, so you don't need to worry about the natural requirement condition met or anything like that..
It probably will something like this(If I'm not wrong, because I don't test this)
alias milena_enable? enable?def enable?(item) if item.id == # your skill id(party combination skill id) return false if $game_party.battle_members[1].state?(death_state_id) # just who is in the index 1 milena_enable?(item) # check the natural requirement condition of that skill(you know, the skills_condition_met? method) else return milena_enable?(item) # return original method if the skill is not your err.. Party Combination skill endend Even after $game_party.battle_members[1].state?(death_state_id) is not true, means the skill is not greyed out, we still need to check the nature requirement of that skill, hence call the original method milena_enable?(item), we don't want the skill is executed even the actor MP is Zero(the player will yell Hey Bro, I Found A Bug oh yeah great, and blah blah.. ).
That code above is just an overview about this matter, you may(actually must) tweak it into your liking. Big sorry if all I had post in here is something a wrong..
Hope this can help you a bit. )
ah, so there's an extra test that's needed that you didn't actually tell us about? That information might have been helpful at the start
Yes, I suggested the first solution might be more restricting than you're after. (and I'd actually put super at the end of the test, to save going through all the other checks first)
Try this:
Code:
class Game_Actor < Game_Battler def skill_conditions_met?(item) (!RMW::Set_of_Skills_To_Deact.include?(item.id) or RMW::Pairs[item.id].nil? or RMW::Pairs[item.id].include?(actor.id)) and super(item) endend
so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most.
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.