[VX Ace] Modifying substitute conditions

Status
Not open for further replies.

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
Hi. I'm trying to modify the substitute conditions in my project since some months ago and after trying some scripts (without success) I decided to check the default scripting to check where could I modify them. I found this part in Scene_Battle in 644 line

Code:
  #--------------------------------------------------------------------------
  # * Check Substitute Condition
  #--------------------------------------------------------------------------
  def check_substitute(target, item)
    target.hp < target.mhp / 4 && (!item || !item.certain?)
  end
I'd like to modify the cover system adding those conditions

1) This character will cover allies who are under 20% of Max HP
2) This character will cover allies only from physical attacks
3) This character will have a chance to cover healthy allies, this chance will be (user's luck / 192) (That means the higher this character's luck, he'll have a bigger chance to cover healthy allies)
4) This character won't be able to cover allies if he has the states 20 and 21
5) This character won't be able to cover allies if him/herself is under 20% of Max HP

Does someone know how to modify this part of the script to create what I want to implement? Thank you
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Not the best implementation. But I couldn't care much. Maybe someone could fix these in better implementation.
Code:
class Scene_Battle
  def check_substitute(target, item)
    return true
  end
 
  def apply_substitute(target, item)
    if check_substitute(target, item)
      substitute = target.friends_unit.substitute_battler
      if substitute && target != substitute
        if substitute == $game_actors[1] # <-- Change actor ID here
          final_target = custom_condition_substitute(substitute, target, item)
          @log_window.display_substitute(substitute, target) if final_target ==
            substitute
          return final_target
        end
        @log_window.display_substitute(substitute, target)
        return substitute
      end
    end
    target
  end
 
  def custom_condition_substitute(subs, target, item)
    return target if subs.state?(20) || subs.state?(21)
    return target if subs.hp < subs.mhp / 4
    return subs if target.hp < subs.mhp / 4 && item.physical?
    return subs if subs.luk / 192
    return target
  end
end
p.s: as many as other scripters do, it's untested.
You still need to check substitute flag in "features"

I assume you only have this one particular character that do the substitute. Because if there's another one to do the substitute. It may glitched.
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
Not the best implementation. But I couldn't care much. Maybe someone could fix these in better implementation.
Code:
class Scene_Battle
  def check_substitute(target, item)
    return true
  end
 
  def apply_substitute(target, item)
    if check_substitute(target, item)
      substitute = target.friends_unit.substitute_battler
      if substitute && target != substitute
        if substitute == $game_actors[1] # <-- Change actor ID here
          final_target = custom_condition_substitute(substitute, target, item)
          @log_window.display_substitute(substitute, target) if final_target ==
            substitute
          return final_target
        end
        @log_window.display_substitute(substitute, target)
        return substitute
      end
    end
    target
  end
 
  def custom_condition_substitute(subs, target, item)
    return target if subs.state?(20) || subs.state?(21)
    return target if subs.hp < subs.mhp / 4
    return subs if target.hp < subs.mhp / 4 && item.physical?
    return subs if subs.luk / 192
    return target
  end
end
p.s: as many as other scripters do, it's untested.
You still need to check substitute flag in "features"

I assume you only have this one particular character that do the substitute. Because if there's another one to do the substitute. It may glitched.
Thank you, for now I just need it for only one character, but it's not a bad idea to implement it for any other in case I need that in a future, so if soemone has a better implementation, it'll be well received

Now, there is something I think I'm understanting wrong in the custom_condition_substitute(subs, target, item) part but those two conditions in particular

Code:
    return target if subs.state?(20) || subs.state?(21)
    return target if subs.hp < subs.mhp / 4
Aren't those saying the one has the substitute flag should have the states 20 and 21 and that it'll cover the target if this character's HP is only below 25%? Because that'd be the opposite of what I'm looking for.

Also, would be possible to change this part

Code:
if substitute == $game_actors[1] # <-- Change actor ID here
So instead checking an actor, it checks the class ID this actor has?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Aren't those saying the one has the substitute flag should have the states 20 and 21
It's opposite. It should cancel any substitute function if the said character has state 20 or 21.
that it'll cover the target if this character's HP is only below 25%?
Guess I'm drunk bcz I just woke up. But you can change it by using / 5 for 20% instead of 25%. Something like
Code:
return target if subs.hp < subs.mhp / 5
The exact rundown gonna be like this. From the top that has highest condition
> If the said actor who is gonna do a substitute has state 20 or 21, cancel substitute
> If the said actor who is gonna do a substitute has certain hp rate (20%), cancel substitute
> If the said actor who is gonna do a substitute, the actor who's going to get substituted is below a certain hp rate (20%) and the attack delivered to them is physical, do subsitute
> If the said actor who is gonna do a substitute, managed to win a roll with formula "luck / 192", do substitute

Actually, while I was writing this, I just realized the 4th condition is flawed. Because "luk / 192" won't do anything. I guess this formula might serve you better
Code:
return subs if rand < subs.luk / 192.0
So instead checking an actor, it checks the class ID this actor has?
Sure
Code:
if substitute.actor? && substitute.class_id == 1
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
I'll implement it, but I noticed something, in this part

Code:
return subs if target.hp < subs.mhp / 5 && item.physical?
Is that dividing target's HP between the character with the substitute flag's MHP? If that's the case, should it be something more like this?

Code:
return subs if target.hp < target.mhp / 5 && item.physical?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Yes, change it that way. Again, I was partially controlled by other me after wake up that I have no idea what I was writing. But at least a bare bone of the script structure is present.
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
Well, I tested it, and when the characters or enemies attack or when actors use items nothing happens...
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
By nothing happen, no one deal damage/effect? or substitute not happening?
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
It doesn't deal any damage effect or action, they don't even move to realize an action (I'm using Yami Symphony scripts as well)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
... you should have said that you use Symphony Battle System right from the start. Since it already changed how substitute works, and I don't feel like to learn it.
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
It shouldn't be a problem at all, iirc, Yami Symphony scripts only modify the visual aspect, the only thing uses the
check_substitute(target, item) in my project is the Scene_Battle part, that means just the default
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
The problem is I don't want to test it with the whole engine of Battle Symphony to ensure if it will work (in fact I mostly hate working with other ppl's battle script except yanfly). If you believe it was the case, then I'll test it if it works in default battle, and pray it also works in symphony too.

That said, I will try to test these in default battle system.

EDIT:
@S.Court Tested all conditions and it seems to work fine in default battle system. You still need to put "substitute" in class features though.
Screenshot_261.png
Again I don't want to test it in whole engine of Symphony.
 
Last edited:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top