Changing the default Substitute

Hi!

Where do i change the default substitiute behavior?

(I want too change the default percentage of hp where substitution occurs)

Thanks!
Put this scriptlet after Materials with whatever new value you want:

Code:
class Scene_Battle < Scene_Base  #--------------------------------------------------------------------------  # * Check Substitute Condition  #--------------------------------------------------------------------------  def check_substitute(target, item)    # default value is 25%, change it to whatever you want    target.hp < target.mhp / 4 && (!item || !item.certain?)  endend
I was hoping to piggyback off of this topic rather than start a new one. I want to modify the substitute feature to ignore the target's HP, and only substitute when it's a physical attack. I've attempted to accomplish this with the code below. The target HP is now ignored, but the substitution still occurs for both physical and magical attacks. Can anybody help me correct this snippet?

Code:
class Scene_Battle < Scene_Base  #--------------------------------------------------------------------------  # * Check Substitute Condition  #--------------------------------------------------------------------------  def check_substitute(target, item)    # default value is 25%, change it to whatever you want    !item || !item.certain? || !item.magical?  endend
|| is an "or".  So in the example above, since an item can't be both Certain Hit and Magical, I think the method will always return "true", which is why you're seeing the behavior that you are.

Try using: !item || item.physical?

Or try using: !item || (!item.certain? && !item.magical?)

I haven't tested these, but based on the way I'm following the method, I think either one should probably solve your problem.

Also, every time I type ||, I see it appear as purple text instead of black, until I put my eyes directly next to the screen.  Maybe some form of synesthesia?  EDIT: Just blew up a screenshot and did a point-sample in Photoshop... they really are purple!!  How bizarre.
JFace, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


Please don't piggyback off old support topics - better to make your own new one (as you clearly are not after the same thing or need extra help), even if you provide a link to the old one.


Also, now that it's been brought back from the dead, this belongs in Script Support. So I'll move it.
|| is an "or".  So in the example above, since an item can't be both Certain Hit and Magical, I think the method will always return "true", which is why you're seeing the behavior that you are.

Try using: !item || item.physical?

Or try using: !item || (!item.certain? && !item.magical?)

I haven't tested these, but based on the way I'm following the method, I think either one should probably solve your problem.

Also, every time I type ||, I see it appear as purple text instead of black, until I put my eyes directly next to the screen.  Maybe some form of synesthesia?  EDIT: Just blew up a screenshot and did a point-sample in Photoshop... they really are purple!!  How bizarre.
 !item || (!item.certain? && !item.magical?) 

This worked perfectly, thank you.

JFace, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Please don't piggyback off old support topics - better to make your own new one (as you clearly are not after the same thing or need extra help), even if you provide a link to the old one.

Also, now that it's been brought back from the dead, this belongs in Script Support. So I'll move it.
Apologies, I thought I was doing the forum a favor by doing a search and not starting a new thread. I have read the rules and my lesson is learned.

👍

Original thread: https://forums.rpgmakerweb.com/threads/changing-the-default-substitute.18353/