[RGSS3] Help skill does different things with different state

Discussion in 'Learning Ruby and RGSSx' started by Alyon93, Aug 18, 2015.

  1. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Hi guys. :)  

    I'm new to rgss3 script making even if I know a couple of scripting languages.

    In my project I use a lot of script made by others, but since I'd like to make something on my own I started to write this should-be-easy script just to learn the basics.

    Basically it works like this:
    I have this skill called "Help" which is usable only when at least a member of the party is unmovable(I'm using Yanfly Skill Restriction to do this).
    When it's used it removes "trapped" state(basically the paralyze one), it removes "stunned" state, it removes "asleep" state and then starts this common event "help" which only has to call a method I've implemented in Game_Actor.
    And I already have troubles doing this and I don't know how to call the method correctly.

    Here's the error:

    [​IMG]
    Here's the call:

    Game_Actor.help($game_action) 
    And here is the method I implemented:

    #==============================================================================# ** Game_Actor#==============================================================================class Game_Actor < Game_Battler def help(action) if action == $data_skills[134] if subject.death_state? if subject.state?(2) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end elsif subject.state?(4) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end else subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end end end end endend 
    Now, I know it's not the most beautiful script, I just started understanding how RGSS3 works, of course I'll add comments in the next part and I'll try to make it more generic.

    For now I want to understand what's wrong with my script call from the common event.
    If you can tell me how it should be done and why, I'd be grateful!

    Basically once the method starts, it checks if the action used is the skill "Help" (probably it's useless since it's "Help" that calls the method) and then checks if the target(subject) is dead (if not it simply ends here). If the character is dead it checks if other states are applied(in my game death state doesn't remove every other state. Achieved using "Stop State Removal on Death" by Gamesfreak13563)

    and then removes them only if the party has some items or not(which are used in the end). 

    As I said the script should be very easy that's why I'm posting it here and not in "Script Request" since I'd like to make it on my own of course using your help, tips and teachings.

    Thanks a lot for reading through this and thanks in advance to all those who are going to spend some time with me  :D
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,695
    Likes Received:
    6,600
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    1)

    The game interpreter is basically a sandbox inside the engine to protect the engine scripts from being damaged by irregular script commands.

    As a result there is no direct access to other parts of the engine, any command that should be available inside the game interpreter (event script command) either needs to be written for it or registered for access to it (no, I can't tell you how, I haven't learned RGSS to that point)

    2)

    common events called by scripts are processed out of sequence at the end of a battle turn.

    You'll need a way to store the info on who the skill was targeted on to select and change its options.
     
    #2
  3. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,518
    Likes Received:
    3,771
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    It's because you need to call the method with an INSTANCE of Game_Actor (such as $game_party.actors[1].help(Game_Action)  ).  Game_Actor is a class, not an object that can be used to call a method.
     
    Last edited by a moderator: Aug 18, 2015
    #3
  4. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    I know you just provide an example but:

    [​IMG]
    Even like this it doesn't seem to execute.

    Also, shouldn't a class be an object made of attributes(public or private) and methods? I remember studying this in one of my courses. 
    Of course I'm not saying you're wrong, is just that it seems really strange to me.
    And if objects and classes mean two really different things in RGSS3 how can you understand wich one is the one you have to use?
    I've seen script calls like:

    SceneManager.call(MrTS_Scene_Crafting) 
    Taken from Mr. Trivel Simple Crafting Script.

    What is the important difference between this and mine which completely change the result from working to not working?

    Thanks for your answers mates!
     
    #4
  5. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    Let's analyze a bit this part of code.

    Game_Actor.help($game_action)1) You must know the difference between an instance and singleton method.Instance method is a method that can be called just within an instance of an object.

    Instance of an object is usually returned by calling Your_Class.new

    .new is a singleton method (at least I think so) and it can be called whenever you want.

    Let's look at an example

    (Method puts() is used to log something into the console)

    class Your_Object def instance_method # This method can only be called from an instance puts "A" end def self.singleton_method # This method can be called whenever you want puts "B" endendobject = Your_Object.new # Here, you initialize an instance of a classYour_Object.instance_method # => Gives an errorYour_Object.singleton_method # => "B"object.instance_method # => "A"object.singleton_method # => "B"2) You must define the $game_action.Variables with nothing in front of them are usually private variables.

    They stay in memory until their scope (a method or a block) is executed.

    Variables with @ in front of them are

    instance variables.

    That means that all methods in one class can use them, and they stay in memory as long their respective class is in memory.

    The variables with $ in front of them are global variables.

    They can be accessed from every method and class.

    However, it's best to use them a few, because they stay in memory until program has finished executing, and that means if you have lots of them your game will bug a bit more (not very much more, but they are still unwanted)

    class Your_Object def initialize # This method is called upon initializing a class, that means, upon using the .new $public_variable = 1 @instance_variable = 2 private_variable = 3 end def log_variables puts $public_variable puts @instance_variable puts private_variable endendobject = Your_Object.newobject.log_variables # => 1 2 Errorputs $public_variable # => 1puts @instance_variable # => Errorputs private_variable # => ErrorThere is another way of defing class variables, and that is when you define then with "self" before the name, but it's not commonly used in custom scripts (but it's used in hidden classes like Sprite).So, what you may want is to use some public variable to access the respective actor.

    There are 2 ways of doing this.

    1) If you know the actor's iD in the database, you can use $game_actors[iD] where iD is an Actor's database iD.

    2) If you know the actor's place in the party you can use $game_party.members[his_place] where his_place is Actor's place in the party. Remember that $game_actors[0] is nil, and that $game_party.members starts counting places from 0.

    So, when calling this from Scene_Battle you'll most likely need actor's place in the party, and not in the database, so try using the example 2.

    From this point I can't help you much, because I'm writing this on my phone.

    If you don't mind, I need to go to sleep soon, and maybe tomorrow finish my answer

    Correct me if I'm wrong.
     
    Last edited by a moderator: Aug 18, 2015
    #5
    Alyon93 likes this.
  6. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Thanks for your answer KockaAdmiralac! 

    Of course you can take all the time you need.
    I'm not in a hurry. 
    I want to learn and it's probably better if it proceeds with small steps so I can understand everything.

    I'm going now to try to fix it using your tips. 
    The only thing that is bugging me is:

    Isn't there a way to generalize that? I mean isn't possible to istance the user of said skill? Because if not I would have to create the script call for every actor in the party which ok is only 4 but it doesn't seem the most efficient way and I must state that I never saw that kind of stuff in script calls.
    In the meantime looking at Andar's answer it completely make sense:

     If the common event starts after the battle turn it makes sense that you can't istance the user of the skill simply because it doesn't exist anymore.

    So yeah I've made up my mind, I'll try to store somehow the reference to the user so I can instance him again or I'll try with a "case" condition with the hope they can be used in a script call, in common events(but I guess yes).

    Thanks guys, I'll update the post after I tried!
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,695
    Likes Received:
    6,600
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    There are several ways to do this without scripts, each requiring conditional branches to check the skill target.
    1) use the damage formula to store the target ID in a variable


    2) apply an invisible and empty state "target of skill XY" and have the common event check where that state is inflicted (needs to have a duration >1 and be removed by the CE due to turn count sequence)
     
    #7
  8. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    Hello,

    I'm having 1% of battery now, and this is a quick answer.

    You do not need to instantiate actors when accessing them from $game_something, they are already instatiated in DataManager -> load_database

    Also, Andar's answer is very useful.
     
    Last edited by a moderator: Aug 18, 2015
    #8
  9. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Okay now I was able to enter the method at last.
    Probably I didn't understand a thing but "hey, at least I tried"

    Here's the script call:

    $game_party.members[1].help($game_variables.[](15)) 
    In variable 15 I stored the action subject(the target basically) as you can see here(damage formula);

    $game_variables.[]=(15, action.subject)  
    I wasn't able to store the user instead I'll have to check it out better and then I'll change that $game_party.members[1] with $game_party.members[$game_variables.[](16)] (since variable 16 is the one I think i'll use to store the user reference).

    Of course the method isn't working at all, resulting in this error:

    [​IMG]
    In another post KockaAdmiralac said:

    Refering to:

    class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * alias: initializes back variable #-------------------------------------------------------------------------- alias cdr_rows_initialize initialize def initialize(actor_id) cdr_rows_initialize(actor_id) if actor.back_row? @back = true else @back = false end end end 
     I'm pretty sure it's the same error as back there only that this time around his solution can't work because there I had this initialize that actually declared actor too somehow(didn't understand it completely though).

    Now the situation is much different since here:

    #==============================================================================# ** Game_Actor#==============================================================================class Game_Actor < Game_Battler def help(subject) if subject.death_state? if subject.state?(2) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end elsif subject.state?(4) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end else subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end end end endend 
    subject is the content of variable 15 which is probably much different from an actor.

    I don't know...

    Thanks anyway guys. Hope that spending time with me is not boring you. I'm really doing my best to understand how RGSS3 works.
     
    Last edited by a moderator: Aug 18, 2015
    #9
  10. Another Fen

    Another Fen Veteran Veteran

    Messages:
    536
    Likes Received:
    248
    First Language:
    German
    Are you sure the damage formula was actually executed when you used the skill?

    For example when the skill misses, no damage is calculated for that specific target.

    According to the error message, you passed the integer  0  instead of an actor object, which means that  $game_variables[15]  probably wasn't changed.

    Instead of using the damage formula, you could extend the method  use_item  from the Game_Battler class, which is called whenever a battler is going to use an item or a skill, regardless of its scope.

    Since Game_Battler is a superclass of Game_Actor and Game_Enemy, methods defined here are available for actors and enemies alike.
     
    Last edited by a moderator: Aug 18, 2015
    #10
  11. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    But doing so would mean to store the user and the target every time right? What will it happen if the common event starts at the end of the turn like Andar said? Isn't it possible that other values overwrite those I need?
     
    #11
  12. Another Fen

    Another Fen Veteran Veteran

    Messages:
    536
    Likes Received:
    248
    First Language:
    German
    Something I've overlooked before:
    The reason your damage formula does not work is because  action  is not defined in the scope the formula is executed in. You can refer to the user of a skill by using  a  instead of  action.subject.

    I think I got you wrong here, so forget what I said about the use_item  method. It is useful to store the user of a skill, but targets are not yet decided at that point, sorry.

    If you are going to store the final targets of that skill as well, you probably should go with either the damage formula or (if you don't want to abuse the damage formula for that) extend the  item_apply  method of Game_Battler which is called whenever a target is hit by a skill or item.

    Problems can occur depending on the battle system you are using. When using the standard battle system where actions are processed one after another, it doesn't really matter when you store the user as long as you do it during their action performance.

    Other battle systems that feature simultaneous actions for example might be more problematic for either solution (like some ATBs).
     
    Last edited by a moderator: Aug 18, 2015
    #12
  13. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Actually I used both of your ideas since I needed both user and target.

    This is what I've done until now:

    #==============================================================================# ** Game_Battler#==============================================================================class Game_Battler #-------------------------------------------------------------------------- # * overwrites use_item metod #-------------------------------------------------------------------------- alias_method:)use_item_alias_storeUser, :use_item) def use_item(item) use_item_alias_storeUser(item) $game_variables[16] = self end #-------------------------------------------------------------------------- # * overwrites item_apply metod #-------------------------------------------------------------------------- alias_method:)item_apply_storeTarget, :item_apply) def item_apply(user, item) item_apply_storeTarget(user, item) $game_variables[15] = user endend#==============================================================================# ** Game_Actor#==============================================================================class Game_Actor < Game_Battler def help(subject) if subject.death_state? if subject.state?(2) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end elsif subject.state?(4) && $game_party.has_item?(6) $game_party.consume_item(6) subject.remove_state(2) subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end else subject.remove_state(1) if $game_party.has_item?(18) subject.hp_rate += 0.25 $game_party.consume_item(18) elsif $game_party.has_item?(3) subject.hp_rate += 1.00 $game_party.consume_item(3) end end end endend 
    And this is the script call:

    $game_variables[16].help($game_variables[15]) 
    Right now is not returning any error but it's not working as intended. 

    Basically even if I choose  the target as you can see here:

    [​IMG]
    It simply uses the skill on the first actor available(I wasn't able to take a screen of that), I guess that there's a sort of operation wich assign the first correct available target if no target was assigned(or else I don't know).

    I must state that the skill don't heal death state as an effect as you can see here:

    [​IMG]
    Sorry for the Italian interface basically the 4 effects are:

    remove asleep state

    remove trapped state

    remove stunned state

    common event help

    The scope is: "One Ally" and the condition is: "In Battle"

    So in my opinion not removing death state cause the target to be invalid and thus he takes another one. I think I'll have to overwrite the method that does this, but I don't know which one it is.

    Or maybe it's simply not storing the target in variable 15.

    However I'm really learning a lot of things now.

    Thanks guys  :)
     
    #13
  14. Another Fen

    Another Fen Veteran Veteran

    Messages:
    536
    Likes Received:
    248
    First Language:
    German
    Unlike the use_item method, item_apply  is called upon each target battler, so you can refer to the target by using self within that method. user refers to the user of the skill, which you already stored at that point.

    Depending on the scope of your skill it is possible that item_apply is not called a single time of course (for example if you are trying to revive a friend that isn't dead anymore) or multiple times (in which case you would only store the last target) or with attacker and target switched when the original action got countered (if you actually use that feature).
     
    Last edited by a moderator: Aug 19, 2015
    #14
  15. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Dude it isn't working even with self.

    If I choose a dead character it simply targets the first living actor in the party. 

    Thanks anyway :)


    EDIT:
    I've managed to find this smooth_target(index) metod in Game_Unit class:

    def smooth_target(index) member = members[index] (member && member.alive?) ? member : alive_members[0] end 
    Apparently when ever you use an item/skill with "an ally" scope, this method is called. 
    It checks if the member you're targeting is alive and if not it changes the target to alive_members[0] wich is the first party member in the alive array.
    It seems to be my problem.
    The point is that any attempt to modify it, doesn't work.

    For example I've commentend the entire condition:

    #(member && member.alive?) ? member : alive_members[0] 
    so member remains exactly member[index], but the action is completely skipped this way. 
    It provides the message "actor used Help" but it doesn't provide any animation and you can't understand what actor did it really target.

    I also tried to change "alive_members[0]" with "member" so that whether the target was alive it wouldn't have changed the target.

    But the result was the same.

    Maybe there's another method that in this way receives an invalid target and simply doesn't execute the action..

    Correct me if I'm wrong.

    In the meantime I'll check for some other methods which might produce this result.

    Thanks :)
     
    Last edited by a moderator: Aug 20, 2015
    #15
  16. Another Fen

    Another Fen Veteran Veteran

    Messages:
    536
    Likes Received:
    248
    First Language:
    German
    That's because you can't target a dead friend unless it's explicitely mentioned in the items scope.

    Items that target a living battler will automatically switch to the first alive battler when used on an invalid target.

    You should be fine when using "One Ally (Dead)" as your skills scope.

    In your script, you can also use  <target>.result.hit?  to check whether the last action on the target was a success (valid target and not missed/evaded).

    Target decision depending on the index the player chose is done by the make_targets method in the Game_Action class, if you wanted to change the behavior above.

    You'd also have to change the method item_test from the Game_Battler class then, which decides whether or not a battler is a valid target for an item (if it is not, the items effects are not applied and the target is skipped in the battle log).

    Two little issues regarding your help method:

    - $game_party.has_item?  and  $game_party.consume_item  take the actual item as an argument, not just its id. This behavior has changed during the rpgmaker generations. You can refer to an item by writing  $data_items[id]

    - In order to use

    subject.hp_rate += 0.25

    you have to define a  hp_rate=  method that sets the hp rate to a new value. By default you can only read that "property", but not write it.

    To recover a percentage of a battlers HP, you can always use

    subject.hp += (0.25 * subject.mhp).round

    instead (rounding is required to avoid fractured HP values)

    Hope that helps making it work. :)

    Edit: Confused Game_ActionResult#success with Game_ActionResult#hit?
     
    Last edited by a moderator: Sep 7, 2015
    #16
  17. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Thanks Another Fen  :)

    It sure does.
    I didn't know actually the correct syntax to recover a character hp_rate.

    But I don't fully  understand how I should use $data_items[id].
    Is it like this?

    $game_party.has_item?($data_items[6]) 

    The point is that this skill should be used also on alive allies. In the first post I mentioned that you can use it to "heal" trapped, stunned and asleep allies. 
    If I put the "One Ally (Dead)" scope I won't be able to heal those other states and I really don't want to create two different skills.

    Actually in another post I asked about changing the scopes. What I really would like would be "One Ally (unmovable)" or something like this in order to be also unable to use it on movable characters, like with the one ally(dead) scope.
    But I really don't have idea what class describes the scopes and how you can add a completely new scope.

    For example in RPG::UsableItem :

    Code:
    class RPG::UsableItem < RPG::BaseItem  def initialize    super    @scope = 0    @occasion = 0    @speed = 0    @success_rate = 100    @repeats = 1    @tp_gain = 0    @hit_type = 0    @animation_id = 0    @damage = RPG::UsableItem::Damage.new    @effects = []  end  def for_opponent?    [1, 2, 3, 4, 5, 6].include?(@scope)  end  def for_friend?    [7, 8, 9, 10, 11].include?(@scope)  end  def for_dead_friend?    [9, 10].include?(@scope)  end  def for_user?    @scope == 11  end  def for_one?    [1, 3, 7, 9, 11].include?(@scope)  end  def for_random?    [3, 4, 5, 6].include?(@scope)  end  def number_of_targets    for_random? ? @scope - 2 : 0  end  def for_all?    [2, 8, 10].include?(@scope)  end  def need_selection?    [1, 7, 9].include?(@scope)  end  def battle_ok?    [0, 1].include?(@occasion)  end  def menu_ok?    [0, 2].include?(@occasion)  end  def certain?    @hit_type == 0  end  def physical?    @hit_type == 1  end  def magical?    @hit_type == 2  end  attr_accessor :scope  attr_accessor :occasion  attr_accessor :speed  attr_accessor :animation_id  attr_accessor :success_rate  attr_accessor :repeats  attr_accessor :tp_gain  attr_accessor :hit_type  attr_accessor :damage  attr_accessor :effectsend 
    You have the possibility to create another method like for_unmovable_friend? but the actual scopes would be a combination of the 11 scopes in the array. I don't know if it's possible to add for example a 12 one and how and where declare it.

    Hope you understand the issue.

    Thanks a lot :)
     
    #17
  18. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
  19. Another Fen

    Another Fen Veteran Veteran

    Messages:
    536
    Likes Received:
    248
    First Language:
    German
    Yes, exactly. :)

    ---

    The RPG::UsableItem is used as a supertype for RPG::Item and RPG::Skill, which are used to store the contents of your item/skill database entries. For example, the @scope variable holds the index of the scope you selected for that item/skill in the editor.

    In the database, you can only choose between 12 different scopes, so if you want to add another one you'd have to make up a way to determine which items use it. A prominent way to do such things in the VXAce would be using the items notebox, so if you want items that are only usable on immovable targets for instance, you could use a notetag to mark them:

    class RPG::UsableItem   # This new method returns true if the items notebox  # contains the sequence '<target immovable>'  def for_immovable?    note.include?("<target immovable>")  endendAs mentioned in the previous post, you may have to modify the item_test method of the Game_Battler class. This method decides whether a battler is an eligible target for an item. If you hit an invalid target, the hit is considered as a failure and will also not show up in the battle log (which is probably what happened in the case you described above).

    During combat, the only restriction is that the target has to be alive when the item is meant to be used on living targets or dead when the item is for dead allies (-> first line of the method). So for instance, if you use "Dual Strike" on an enemy and the target dies from the first hit, the second hit is skipped.

    class Game_Battler   #--------------------------------------------------------------------------  # * Test Skill/Item Application  #    Used to determine, for example, if a character is already fully healed  #   and so cannot recover anymore.  #--------------------------------------------------------------------------  def item_test(user, item)    return false if item.for_dead_friend? != dead?    return true if $game_party.in_battle    return true if item.for_opponent?    return true if item.damage.recover? && item.damage.to_hp? && hp < mhp    return true if item.damage.recover? && item.damage.to_mp? && mp < mmp    return true if item_has_any_valid_effects?(user, item)    return false  endendYou'll probably also have to redo parts of the target selection. By default if the original target is not eligible, another target is chosen to reduce the amount of skipped hits. However, the target selection does not refer to the item_test method, so you have to apply custom restrictions there too.

    Removing the line

    (member && member.alive?) ? member : alive_members[0]

    from the smooth_target method should work, but it removes the "smoothness" of your targeting too. So if you accidently select a target that is dead by the time you can act, the attack will be a miss.
     
    Last edited by a moderator: Aug 27, 2015
    #19
  20. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    I'm ok with that since the interactions between party members will be minimal in my game. So apart from this Help command other moves will be mostly based on self or the enemy.

    But I wonder. What other situations might be good for having smoothness? 

    Also what about adding a control on the skill id? If it's equal to this "Help" one it'll skip that line otherwise it will act like always. This way I shouldn't modify too much the original scripts  and behavior.

    I don't understand here.

    Adding this will prevent the user from using the item/skill on movable targets?

    And what I should put in the scope box of the skill in the database?

    If I put "One Ally" which one of "One Ally" and "One Ally(unmovable)" will have the priority over the other?

    Do you think that adding here return true if item.for_immovable? will solve the issue?

    Thanks Another Fen I think I'm close to understand it. :)  
     
    #20

Share This Page