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.

Sp changes

Ok basiclly what i would like would be so that within a script you can change what SP is called for different classes, but what i would also like is that items which heal SP can only be used on certain classes.
E.g.
A mage has Sp as his stat, an ether can be used to heal his Sp but the ether cant be used on a soldier.
A soldier has fury as his stat and that can be cured with a (lack of idea here) Annoying toy object resembling pikachu that annoys everyone but that item cant cure a Mages stat.
Ok you should be following me here. What i would like is that how the item is set to work on different classes is set withing the script so that you have the ID of the item there and then it has like after that the numbers of the class ID. OK well thats it tell me if you dont understand and i hope someone can help me with this. I'll make sure to crdit you
 
Here you go:
Code:
class Game_Battler
  
  def can_sp_item_be_used?(id)
    if @enemy_id != nil
      return true
    end
    
    case @actor_id
    when 1 #First character
      
      case id
      when 4, 5, 6
        return true
      else
        return false
      end
      
    when 2 #Second character
      
      case id
      when 5
        return true
      else
        return false
      end
      
    end
    return true
  end
  
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  def item_effect(item)
    # Clear critical flag
    self.critical = false
    # If item scope is for ally with 1 or more HP, and your own HP = 0,
    # or item scope is for ally with 0 HP, and your own HP = 1 or more
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= item.common_event_id > 0
    # Determine hit
    hit_result = (rand(100) < item.hit)
    # Set effective flag is skill is uncertain
    effective |= item.hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate amount of recovery
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      if can_sp_item_be_used?(item.id)
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      else
      recover_sp = 0
      end
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # Element correction
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # Dispersion
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # If recovery code is negative
      if recover_hp < 0
        # Guard correction
        if self.guarding?
          recover_hp /= 2
        end
      end
      # Set damage value and reverse HP recovery amount
      self.damage = -recover_hp
      # HP and SP recovery
      last_hp = self.hp
      last_sp = self.sp
      self.hp += recover_hp
      self.sp += recover_sp
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # State change
      @state_changed = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # If parameter value increase is effective
      if item.parameter_type > 0 and item.parameter_points != 0
        # Branch by parameter
        case item.parameter_type
        when 1  # Max HP
          @maxhp_plus += item.parameter_points
        when 2  # Max SP
          @maxsp_plus += item.parameter_points
        when 3  # Strength
          @str_plus += item.parameter_points
        when 4  # Dexterity
          @dex_plus += item.parameter_points
        when 5  # Agility
          @agi_plus += item.parameter_points
        when 6  # Intelligence
          @int_plus += item.parameter_points
        end
        # Set to effective flag
        effective = true
      end
      # If HP recovery rate and recovery amount are 0
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # Set damage to empty string
        self.damage = ""
        # If SP recovery rate / recovery amount are 0, and parameter increase
        # value is ineffective.
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # If state is unchanged
          unless @state_changed
            # Set damage to "Miss"
            self.damage = "Miss"
          end
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end

end
Kind of reminds me of kinetic cipher in a way.
I'll just explain what you need to do, the first bit determines if it effects them by default all sp recovers will affect the person and enemy.
To stop it affecting a character just make them a when like i did with the first to and copy the code with it, in the second case you just put all the items they are allowed to use which restore sp otherwise they won't work on that character.
That was an awful explanation I know but hopefully you followed it, any questions just ask.
 
Oh sorry about that.
Code:
class Window_Base < Window
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    case actor.id
    when 1, 2, 3
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    when 4, 5, 6
    self.contents.draw_text(x, y, 32, 32, 'FP')
    when 7,8
    self.contents.draw_text(x, y, 32, 32, 'TP')
    end
    # Calculate if there is draw space for MaxSP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
end
Just change the case statement and the string that is written.
(Remember this has to be below window_base)
 
thank you so much
ok namnig is perfect but i dont understand your explanation of the item one sorry
Edit: oh whilst in here would someone be able to make a script i can just paste over main which changes what skill is called for each actor kind of like the Sp naming script here
 
Ok well,
Code:
    case @actor_id
    when 1 #First character
      
      case id
      when 4, 5, 6
        return true
      else
        return false
      end
      
    when 2 #Second character
      
      case id
      when 5
        return true
      else
        return false
      end
      
    end
The main whens (when 1 #First character and when 2 #Second character) are where that characters usable items are recorded.
The inner when is the items that are allowed to be used by that character.

Did that help?

I'll do the other request in a bit.
 
That's a very good idea, wish i'd thought of it.
Yeah if you make it:
Code:
    case @actor_id
    when 1 #First character
      
      case id
      when 4, 5, 6
        return false
      else
        return true
      end
      
    when 2 #Second character
      
      case id
      when 5
        return false
      else
        return true
      end
      
    end

Then you specify what items that affect sp they can't use.
The script works by checking if the item they try to use is allowed to affect the character's sp if so then it acts like it would without this script otherwise it just say no sp change basically.

Oh and here is your other request, Skill will named differantly based on the actor.
Code:
class Game_Actor < Game_Battler
  
  def skill_set_name
    case @actor_id
    when 1
      return 'Sword Skills'
    when 2
      return 'Lance Skills'
    else
      return 'Skills'
    end
  end
  
  
end





class Scene_Battle
  alias old_main main
  def main
    old_main
    make_command_window
  end
  
  alias phase3_setup_command_window_old phase3_setup_command_window
  def phase3_setup_command_window
    @actor_command_window.dispose
    make_command_window(@actor_index)
    phase3_setup_command_window_old
  end
  
  
  def make_command_window(pos = 0)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $game_party.actors[pos].skill_set_name
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
  end
  
end
I'm pretty sure you know what to do by now.
In the case in game_actor add the character and then return the name of their skill set.
 

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