How Can I Recreate Zidane's 'Protect Girls' Ability?

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Yeah that's probably the last title you expected to read today.

As mentioned in another topic, my game features lots of random cameos as playable characters and I'm priding myself in recreating them as faithfully as possible and one of the new ones I'm adding is Zidane Tribal from Final Fantasy IX. I've been giving him a few abilities that look snazzy but I also wanted to give him his noble yet humorous 'Protect Girls' ability but I have zero idea how to make this work.

Just in case anyone's unfamiliar: Zidane has a passive ability that will cause him to protect female party members if they are below 50% health. Essentially it's the RPG Maker Substitute ability, but only applies to female characters.

What I've got so far is just the state; 'Protect Girls' which is a clone of Substitute but is applied automatically at the start of battle, and lasts the entire battle (and remove after), so it functions as a great passive ability. Naturally though, he'll protect ANYONE with low health. What I need is for him to only substitute for specific characters, but I worry this won't be possible without scripting, which if that's the case then I might not bother since my game's already got a lot of those and I don't want to keep adding entire scripts for single abilities, lol.

I had considered an alternate method where I create an event in every enemy troop: "If X actor has less than 50% HP then increase Zidane Target Rate by 100" but I don't think that'd work too well and I already have another character who can draw enemy attention.

Any ideas? I'm likely to just scrap this concept 'cause it's not necessary, it'd just be a nice homage to the character and add a bit more authenticity :) I figured I'd give it a little shot though if I can find a solution that's simple enough.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,635
Reaction score
5,116
First Language
English
Primarily Uses
RMVXA
You'll need to do a bit of scripting. This is the method in Scene_Battle you'll want to overwrite (or simply replace):

Code:
  #--------------------------------------------------------------------------
  # * Check Substitute Condition
  #--------------------------------------------------------------------------
  def check_substitute(target, item)
    target.hp < target.mhp / 4 && (!item || !item.certain?)
  end
I think that the easiest solution would be to check for the existence of the "Protect Girls" state, and if it's there, run an alternate evaluation to determine whether or not to activate the Substitute. Something like the following. If this doesn't work, say so because it means I've made some kind of error in my class/object referencing and maybe someone can catch it for us.

Code:
  #--------------------------------------------------------------------------
  # * Check Substitute Condition
  #--------------------------------------------------------------------------
  def check_substitute(target, item)
    if state?(X)
      protect = (target.actor_id == N1 or target.actor_id == N2 or target.actor_id == N3) && (!item || !item.certain?)
    else
      protect = target.hp < target.mhp / 4 && (!item || !item.certain?)
    end
    return protect
  end
Replace X with the State ID of Protect Girls. Replace N1, N2, and N3 with the Actor ID (in the database) of your female party members, and extend the statement with more "or" connectors as necessary for however many females are in your party.

Leave the "Substitute" property on the Protect Girls state; don't remove it.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Thanks for helping here too. I was about ready to quit on this, lol.

I replaced the script and put in the IDs but now whenever an enemy attacks, this error occurs:
"Script 'Scene_Battle' line 645: NoMethodError occurred. undefined method 'state?' for #<Scene_Battle:0xacc85a8>"

At first I thought I'd been dumb enough to not put the state ID or put the incorrect one, but it's correct and Zidane had it. I got the error when the enemy attacked a male party member AND a female, so it doesn't discriminate apparently, lol.

I noticed in the edited script though that it doesn't have a 'if low hp' type condition. When functioning, wouldn't that mean that he protects all females even if they have full HP?

EDIT: Ok so I just tried a few more times and noticed the number is actually different. "<Scene_Battle:0xa867a18>" is another one I got. Don't know if that helps.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,675
Reaction score
566
First Language
English
Primarily Uses
RMVXA
I see under Game_BattlerBase this
@states.include?(state_id)

So maybe use that for

if @states.include?(X)
 

GGZiron

Veteran
Veteran
Joined
Nov 6, 2016
Messages
90
Reaction score
34
First Language
Bulgarian
Primarily Uses
RMVXA
You can instead add that special state to the girls in your party, and then alter the script so it requares for the state to exist.
Then, you edit the cover ability to call common event, which will check each party member's ID. If the ID is of a girl, then add the state to that party member. If you want the cover ability to work normally for other users, you can make alternative cover ability skill, that adds the new state to all party members, without discrimination. But if you use my snippet, no cover ability will work anymore, if the target doesn't have the state.
Surely this is not the best aproach, but the best I can think of atm.
You will need the snippet bellow, if you try my aproach. And if you need help how to make the common event, that add the state, you can ask me to make you one.
In the snippet I give, it still requares the party member to be with low hp, because reading above posts, I remained with the impression you want it so.
Code:
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # overwrite : Check Substitute Condition
  #--------------------------------------------------------------------------
  def check_substitute(target, item)
   (!item || !item.certain?) and target.state?(x) and target.hp < target.mhp / 4
  end
end
Just replace the x with the state the party mates must have, for the cover ability to work.

Edit:
As for the comment event, it can contain this as script call.
Code:
party_size = $game_party.battle_members.size
  i=0
  while i < party_size
    case $game_party.battle_members[i].id
    when 2, 9  # write all the id numbers of female party members here.
    $game_party.battle_members[i].add_state(x) # replace x with the required state
    end
  i += 1
end
The values "2, 9" are only stand in, as in default database that are Isabelle and Natalie.
Replace them with your female members ID, and add more if you need.

Second edit: Actually there is script for cover ability by Tsukihime, which you can find here:
http://himeworks.com/2014/12/covering-allies-and-cover-conditions/
 
Last edited:

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Yeah I have another character who can do the standard 'covers all low health party members' thing so I can't really use anything that would disable all other cover effects.

I played around with Tsukihime's scripts and I thought they were gonna work out for a second until Zidane protected Tracer from her own Blink ability and gained the benefits himself (thieving little b****d) :guffaw:

I kept playing around with them but couldn't get the effect I wanted :(

From what I've seen around, if this was the only Cover skill I had, there'd be no issue with getting it to work how I want (such as the example given by Ziron) but the fact I want to keep the RPG Maker default Cover skill AND have a second one that functions so differently is the problem. Definitely turning out to be more trouble than it's worth for what was only supposed to be a quick fun cameo, lol.

Wavelength mentioned in my other thread that he might know how to fix his method so I'll wait on that and if it doesn't work then I'll probably give up on the idea. I already put way more time than intended into it.

It's always abilities that I think are gonna be easy to implement that end up being the hardest, and then things I think will be complicated I end up accomplishing on my first try. Go figure, lol.
 

GGZiron

Veteran
Veteran
Joined
Nov 6, 2016
Messages
90
Reaction score
34
First Language
Bulgarian
Primarily Uses
RMVXA
Edit: because of mistake, I deleted all the content in my original post.
Here is the script i worked out.
Code:
module Protect_girls_state
#===========================================================================
=begin
This scrip adds new special flag with id =4.
Also it add that new flag to a state, which id can be defined in the settings.
The original substitute state should work as before. There is no need
to set which actor have Zidane's ability. Any actor that have the state with
the new flag will have Zidane's ability.
=end


#=========================Settings=========================================
  GIRLS_ID = [2, 9] #replace with actual girl members id
  PROTECT_GIRLS_STATE_ID = 11 #replace with the state that will have the new feature
 
 
 
#=====Do not touch anything bellow unless you understand how it works======

 
  attr_reader :state_id
  attr_reader :girls_id

  def self.state_id
    return PROTECT_GIRLS_STATE_ID
    end
  def self.girls_id
    return GIRLS_ID
    end
end


class Scene_Battle < Scene_Base

#=====================New Method===========================================
  def target_is_girl?(target)
    if target.actor?
      if Protect_girls_state.girls_id.include?(target.id)
       return true
     else
       return false
        end  
      end
    end
   
  def protect_girls(target, item)
    target.hp < target.mhp / 4 && (!item || !item.certain?) && target_is_girl?(target)
  end
#==========================================================================
def apply_substitute(target, item)
    if protect_girls(target, item)
       protect = target.friends_unit.protect_girls
       if protect && target != protect
         @log_window.display_substitute(protect, target)
         return protect
         end
       end
    if check_substitute(target, item)
      substitute = target.friends_unit.substitute_battler
      if substitute && target != substitute
        @log_window.display_substitute(substitute, target)
        return substitute
      end
    end
    target
  end

end

module DataManager
 
  singleton_class.send(:alias_method, :load_normal_database_new, :load_normal_database)
 
  def self.load_normal_database
    load_normal_database_new
    feature_index = $data_states[Protect_girls_state::state_id].features.size - 1
    $data_states[Protect_girls_state::state_id].features[feature_index].code=62
    $data_states[Protect_girls_state::state_id].features[feature_index].data_id= 4
    end
 
  end

class Game_Battler < Game_BattlerBase

FLAG_ID_PROTECT_GIRLS = 4 #new flag

#=====================New Method===========================================
def protect_girls?
    special_flag(FLAG_ID_PROTECT_GIRLS) && movable?
  end
#==========================================================================
end

class Game_Unit
#=====================New Method===========================================  
 def protect_girls
    members.find {|member| member.protect_girls? }
  end
#==========================================================================
end

So, you need to set in the settings which state should be your "protect the girls" state.
Also you need to set which are the girls' id numbers.
In the state you choice, plus all wanted features, you should add in the end one random, which will be replaced by my newly added flag. The reason it works this way is because i didn't figured yet how to add new feature, only to replace existent. If i figure out, will update the script. If the State you choice to use have not even one feature, my script will give error.
 
Last edited:

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Ok I set up the State ID and the girls' IDs in the script, I wasn't quite sure what you meant by adding a 'random' feature but I made the state have the 'Substitute' flag twice and it seems to be working so I guess your flag overwrote the second substitute? Hopefully I did that right. Sorry I'm kinda dumb today, lol.

Initial testing seems to be working though. Zidane is protecting the correct characters, and he's not robbing them of any self-buffs like Tracer's Blink either which is great. I'll keep testing as much as I can today and see how it goes. Thank you so much! ^_^
 

GGZiron

Veteran
Veteran
Joined
Nov 6, 2016
Messages
90
Reaction score
34
First Language
Bulgarian
Primarily Uses
RMVXA
No, is my fault for not explaining well.
So, by random feature, i meant any feature. And, it should not have substitute feature above, because if it have it, it will be both girl protector and any party members protecor. So, the state that will make your actor protect only girls, should not have substitute flag(unless is the last feature, as then it gonna be replaced).
Edit: And that altered state, your alternative cover ability should add it to the user(the actor that is going to protect the girls).
New Edit: Ok, I managed to work out how to add new feature instead replacing the old one. Here is the script:
Code:
module Protect_girls_state
#===========================================================================
=begin

This script adds new special flag with id =4.
Also it add that new flag to a state, which id can be defined in the settings.
The original substitute state should work as before. There is no need
to set which actor have Zidane's ability. Any actor that have the state with
the new flag will have Zidane's ability.
=end


#=========================Settings=========================================
  GIRLS_ID = [2, 9] #replace with actual girl members id
  PROTECT_GIRLS_STATE_ID = 11 #replace with the state that will have the new feature
 
 
 
#=====Do not touch anything bellow unless you understand how it works======

 
  attr_reader :state_id
  attr_reader :girls_id

  def self.state_id
    return PROTECT_GIRLS_STATE_ID
    end
  def self.girls_id
    return GIRLS_ID
    end
end


class Scene_Battle < Scene_Base

#=====================New Method=========================================== 
  def target_is_girl?(target)
    if target.actor?
      if Protect_girls_state.girls_id.include?(target.id)
       return true
     else
       return false
        end   
      end
    end
    
  def protect_girls(target, item)
    target.hp < target.mhp / 4 && (!item || !item.certain?) && target_is_girl?(target)
  end
#==========================================================================
def apply_substitute(target, item)
    if protect_girls(target, item)
       protect = target.friends_unit.protect_girls
       if protect && target != protect
         @log_window.display_substitute(protect, target)
         return protect
         end
       end
    if check_substitute(target, item)
      substitute = target.friends_unit.substitute_battler
      if substitute && target != substitute
        @log_window.display_substitute(substitute, target)
        return substitute
      end
    end
    target
  end

end

module DataManager
 
  singleton_class.send(:alias_method, :load_normal_database_new, :load_normal_database)
 
  def self.load_normal_database
    load_normal_database_new
    state_id = Protect_girls_state::state_id
    feature_index = $data_states[state_id].features.size
    $data_states[state_id].features[feature_index] = RPG::BaseItem::Feature.new
    $data_states[state_id].features[feature_index].code=62
    $data_states[state_id].features[feature_index].data_id= 4
    end
 
  end

class Game_Battler < Game_BattlerBase

FLAG_ID_PROTECT_GIRLS = 4 #new flag 

#=====================New Method=========================================== 
def protect_girls?
    special_flag(FLAG_ID_PROTECT_GIRLS) && movable?
  end 
#==========================================================================
end 

class Game_Unit
#=====================New Method===========================================   
 def protect_girls
    members.find {|member| member.protect_girls? }
  end
#==========================================================================
end
So, with this edit of the script, you should not worry about picking state that has no initial features. The script now should give error only if you pick incorect state id (one that is not in the database). The latest feature won't be replaced anymore, as instead the wanted new flag will be just added bellow the other features.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top