Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RPG VX Script Request- FFVI Esper-Like Object-Details inside SOLVED

Could anyone make a script that allows characters with a certain armor equipped to get, say, +30% to their stat gain (not of their total stat) when they level up, kind of like equipped Espers in FFVI? So, not someone with 100 hp and a normal +10 hp on their next level up having 140 hp after leveling. They would have 113 if they have the armor (say, Health Helm) equipped. Thanks in advance if you can make it!
 

poccil

Sponsor

Here's a script I made that does what you want.  Put it after all other scripts in the Materials section of the script editor.  For each armor capable of adding stat gains, add any combination of the following tags to that armor's notes.

[EsperGain_MaxHP: X]
[EsperGain_MaxMP: X]
[EsperGain_Atk: X]
[EsperGain_Def: X]
[EsperGain_Spi: X]
[EsperGain_Agi: X]

In all cases, X can be a number or a percentage representing the stat gain upon level up.  Examples: [EsperGain_Def: 20] (stat gain is increased by 20 Defense) or [EsperGain_MaxMP: 30%] (Max MP gain is increased by 30%).

The script is below.

Code:
class Game_Actor
  %w[
      maxhp maxmp atk def spi agi
  ].each_with_index do |s, i|
      eval <<-__END__
        alias :petero_esper_base_#{s} :base_#{s}
        def base_#{s}
          @esperbonuses=[0,0,0,0,0,0] if !@esperbonuses
          return petero_esper_base_#{s} + @esperbonuses[#{i}]
        end
      __END__
  end
  def parseEsperNote(note,tag,refValue)
   value=0
   note.scan(/\[#{tag}\:\s*(\d+)(\%?)\]/i){
    value=$1.to_i
    if $2=="%"
     value=refValue*value/100
    end
    break
   }
   return value
  end
  alias :petero_esper_level_up level_up
  def level_up
    oldlevel=@level
    petero_esper_level_up
    @esperbonuses=[0,0,0,0,0,0] if !@esperbonuses
    for armor in self.armors
     next if !armor
     params=actor.parameters
     note=armor.note
     stattags=[
      "EsperGain_MaxHP",
      "EsperGain_MaxMP",
      "EsperGain_Atk",
      "EsperGain_Def",
      "EsperGain_Spi",
      "EsperGain_Agi"]
     for i in 0...6
       paramDiff=(params[i,@level]-params[i,oldlevel]).abs
       @esperbonuses[i]+=parseEsperNote(armor.note,
          stattags[i],paramDiff)
     end
    end
  end
end
 
Thank you so much! You are always my savior with scripts. Is there any way that you could also make me a Reraise script? Details here:

Reraise is a skill that can be cast on a character to place the Reraise state on them. When a character with the Reraise state is defeated, they are instantly revived with 25% hp, but the state is removed.

I'd be eternally grateful for your help!

-Shadow Lord

-P.S.-Your name will be in my credits a lot of times in various colors. No one will miss it!

-P.P.S.-Do you take script requests by PM? I would just like to know so that I can get help more quickly if I discover I need it.

-P.P.P.S.-Do you know any RGSS2 scripting tutorials out there that are any good? I'd like to be able to write my own scripts instead of taking up your time.
 

poccil

Sponsor

The script below implements the "reraise" state.  Put it after all other scripts in the Materials section of the script editor.  For each state with this ability, add the tag [Reraise: X%] to the state's notes, where X is
the percentage of HP to recover.  Example: [Reraise: 25%]

Code:
class Game_Battler
  alias :petero_reraise_add_state :add_state
  @@_ReraiseStates=nil
  def ensureReraise
   if @@_ReraiseStates==nil
    @@_ReraiseStates={}
    for dataState in $data_states
     next if !dataState
     dataState.note.gsub!(/\[Reraise\:\s*(\d+)%\]/i){
      @@_ReraiseStates[dataState.id]=$1.to_i; next ""
     }
    end
   end    
  end
  def reraiseAmount
   ensureReraise
   for state in self.states
    if @@_ReraiseStates[state.id]
     return self.maxhp*@@_ReraiseStates[state.id]/100
    end
   end
   return nil
  end
  def removeReraiseStates
   ensureReraise
   for state in @@_ReraiseStates.keys
    remove_state(state)
   end
  end
  attr_accessor :reraise
  def add_state(id)
    if id==1 # If Incapacitated
      # Must be here because the reraise state may
      # be removed when Incapacitated is added
      @reraise=reraiseAmount
    end
    petero_reraise_add_state(id)
  end
end

class Scene_Battle
  alias :petero_reraise_display_state_changes :display_state_changes
  def display_state_changes(target, obj = nil)
   petero_reraise_display_state_changes(target,obj)
   # If target is collapsed
   if target.added_states.include?($data_states[1])
     if target.reraise
       target.hp=[target.reraise,1].max
       target.removeReraiseStates
       target.reraise=nil
       # Display "X was revived"
       if $data_states[1].message4
         text = target.name + $data_states[1].message4
         @message_window.replace_instant_text(text)
         wait(35)
       end
     end
   end
  end
end

To respond to your points:

I don't like to "take script requests".  I would rather fulfill requests as they come
when I am not so forced to do so.

Essentially, RGSS 2 is the same as the original RGSS.  See the tutorials on scripting
in the Tutorials forum.  However, I am not aware of any specific tutorials.
 

Kafei

Member

Hey, I was looking at this because I was also interested in having a reraise state, but it seems I get a syntax error on line 39, which from what I can tell, is simply "end".

My guess is that it's conflicting with another of my other custom scripts (probably the takentai side-view battle script). Any thoughts or suggestions?
 
Maybe you can just erase that line. I had no problem running the script, myself, but when I have script conflicts I sometimes just delete the offending line. Not the most scientific method, I'm sure, but it works. Someday I'll probably be negatively affected by it, but until then, who knows?

-Shadow Lord
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top