Changing the default Substitute

Leah Prime

Intermediate Eventomancer
Veteran
Joined
Sep 14, 2013
Messages
54
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hi!

Where do i change the default substitiute behavior?

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

Thanks!
 

DuncanS

Veteran
Veteran
Joined
Sep 18, 2013
Messages
160
Reaction score
96
First Language
English
Primarily Uses
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
 

JFace

Villager
Member
Joined
Feb 15, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
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
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
|| 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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

JFace

Villager
Member
Joined
Feb 15, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
|| 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.

:thumbsup-left:
 

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

Latest Threads

Latest Posts

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,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top