Espaço Maker
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Script de Hospital

Ir para baixo

Script de Hospital Empty Script de Hospital

Mensagem por Neon Knight Sex 25 Jun 2010, 12:28 pm

Hospital Fees - Shanghai

Introdução

Estou aqui para disponibilizar um ótimo script feito por um
scripter não muito famoso: Shanghai.


<------------------------------------------------------------------------->

O que o script faz

Como diz o nome, ele é um menu onde você pode curar os personagens por uma taxa.

<------------------------------------------------------------------------->

Instruções

Para iniciar a cena do hospital, uma chama o script em um evento com
Código:
$scene = Scene_Hospital.new
Para alterar o custo de curar certos status, colocar isso em historico do status com x como a taxa.
Código:
<hospital fee: X>

<------------------------------------------------------------------------->

Imagem.

Script de Hospital HospitalFees

script

Código:
#===============================================================================
#
# Shanghai Simple script - Hospital Fees
# Last Date Updated: 2010.05.13
# Level: Normal
#
# Not every hero lives in Europe. Hospitals have fees, too, you know.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# To launch the hospital scene, have a script call in an event with
#    $scene = Scene_Hospital.new
#
# <hospital fee: x>
# To change the cost of healing certain states, put this in the state's notebox
# with x as the fee.
#===============================================================================
 
$imported = {} if $imported == nil
$imported["HospitalFees"] = true
 
module SSS
  # This is how much gold the hospital charges for each HP and MP lost per
  # party member.
  HOSPITAL_HP_COST = 1
  HOSPITAL_MP_COST = 3
  # This is the default state removal hospital fee. However, the death state
  # costs slightly more than usual.
  HOSPITAL_STATE_REMOVAL = 100
  HOSPITAL_STATE_REVIVAL = 1000
  # This is the text that appears at the very top in the help window.
  HOSPITAL_HELP_TEXT = "Heal all party members for %sG."
  HOSPITAL_HELP_HEALTHY = "All members are healthy."
  # This sets the commands for the command window.
  HOSPITAL_HEAL_ONE  = "Heal One"
  HOSPITAL_HEAL_ALL  = "Heal All"
  HOSPITAL_EXIT      = "Exit"
  # This sets the categories for the hospital columns.
  HOSPITAL_NAME_COL  = "Name"
  HOSPITAL_COST_COL  = "Cost"
end
 
#==============================================================================
# ** RPG::State
#==============================================================================
 
class RPG::State
  #--------------------------------------------------------------------------
  # hospital_fee
  #--------------------------------------------------------------------------
  def hospital_fee
    return @hospital_fee if @hospital_fee != nil
    @hospital_fee = SSS::HOSPITAL_STATE_REMOVAL
    @hospital_fee = SSS::HOSPITAL_STATE_REVIVAL if self.id == 1
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:HOSPITAL_FEE|hospital fee):[ ]*(\d+)>/i
        @hospital_fee = $1.to_i
      end
    }
    return @hospital_fee
  end
end
 
#==============================================================================
# ** Game_Actor
#==============================================================================
 
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Heal Cost
  #--------------------------------------------------------------------------
  def heal_cost
    cost = 0
    cost += (self.maxhp-self.hp)*SSS::HOSPITAL_HP_COST
    cost += (self.maxmp-self.mp)*SSS::HOSPITAL_MP_COST
    for state in states
      next if state.nil?
      cost += state.hospital_fee
    end
    return cost
  end
end
#==============================================================================
# ** Game_Party
#==============================================================================
 
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Heal Cost
  #--------------------------------------------------------------------------
  def heal_cost
    cost = 0
    for i in @actors
      next if $game_actors[i].nil?
      cost += $game_actors[i].heal_cost
    end
    return cost
  end
end
 
#==============================================================================
# ** Window_Hospital
#==============================================================================
 
class Window_Hospital < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, Graphics.width, Graphics.height - y)
    refresh
    self.active = false
    self.back_opacity = 0
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Actor
  #--------------------------------------------------------------------------
  def actor
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @data = $game_party.members
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    actor = @data[index]
    if actor != nil
      rect.width -= 4
      draw_actor_name(actor, rect.x+4, rect.y)
      draw_actor_state(actor, rect.x+108, rect.y, 48)
      draw_actor_hp(actor, rect.x+156, rect.y, 120)
      draw_actor_mp(actor, rect.x+280, rect.y, 120)
      draw_actor_heal_cost(actor, rect.x+404, rect.y)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Heal Cost
  #--------------------------------------------------------------------------
  def draw_actor_heal_cost(actor, x, y)
    if actor != nil
      text = sprintf("%d%s", actor.heal_cost, Vocab.gold)
      align = 2
      if text == sprintf("%d%s", 0, Vocab.gold)
        text = "-----"
        align = 1
      end
      enabled = $game_party.gold >= actor.heal_cost
      self.contents.font.color.alpha = enabled ? 255 : 128
      self.contents.draw_text(x, y, 104, WLH, text, align)
    end
  end
end
 
#==============================================================================
# ** Window_HospitalBack
#==============================================================================
 
class Window_HospitalBack < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, Graphics.width, Graphics.height - y)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 152, WLH, SSS::HOSPITAL_NAME_COL, 1)
    self.contents.draw_text(156, 0, 124, WLH, Vocab.hp, 1)
    self.contents.draw_text(280, 0, 124, WLH, Vocab.mp, 1)
    self.contents.draw_text(404, 0, 104, WLH, SSS::HOSPITAL_COST_COL, 1)
  end
end
 
#==============================================================================
# ** Scene_Hospital
#==============================================================================
 
class Scene_Hospital < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @help_window = Window_Help.new
    text = sprintf(SSS::HOSPITAL_HELP_TEXT, $game_party.heal_cost)
    text = SSS::HOSPITAL_HELP_HEALTHY if $game_party.heal_cost == 0
    @help_window.set_text(text, 1)
    create_command_window
    @gold_window = Window_Gold.new(Graphics.width - 160, @help_window.height)
    @back_window = Window_HospitalBack.new(0, @help_window.height + 56)
    @hospital_window = Window_Hospital.new(0, @help_window.height + 80)
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @back_window.dispose
    @hospital_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = SSS::HOSPITAL_HEAL_ONE
    s2 = SSS::HOSPITAL_HEAL_ALL
    s3 = SSS::HOSPITAL_EXIT
    @command_window = Window_Command.new(Graphics.width - 160, [s1, s2, s3], 3)
    @command_window.y = @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    if @command_window.active
      update_command_selection
    elsif @hospital_window.active
      update_hospital_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection
  #--------------------------------------------------------------------------
  def update_command_selection
    @command_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        Sound.play_decision
        @command_window.active = false
        @hospital_window.active = true
        @hospital_window.index = 0 if @hospital_window.index < 0
      when 1
        if $game_party.gold < $game_party.heal_cost or $game_party.heal_cost == 0
          Sound.play_buzzer
        else
          Sound.play_recovery
          $game_party.lose_gold($game_party.heal_cost)
          @gold_window.refresh
          for actor in $game_party.members
            for state in actor.states
              actor.remove_state(state.id)
            end
            actor.hp = actor.maxhp
            actor.mp = actor.maxmp
          end
          @hospital_window.refresh
          text = sprintf(SSS::HOSPITAL_HELP_TEXT, $game_party.heal_cost)
          text = SSS::HOSPITAL_HELP_HEALTHY if $game_party.heal_cost == 0
          @help_window.set_text(text, 1)
        end
      when 2
        Sound.play_decision
        $scene = Scene_Map.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Hospital Selection
  #--------------------------------------------------------------------------
  def update_hospital_selection
    @hospital_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @hospital_window.active = false
    elsif Input.trigger?(Input::C)
      actor = @hospital_window.actor
      if $game_party.gold < actor.heal_cost or actor.heal_cost == 0
        Sound.play_buzzer
      else
        Sound.play_recovery
        $game_party.lose_gold(actor.heal_cost)
        @gold_window.refresh
        for state in actor.states
          actor.remove_state(state.id)
        end
        actor.hp = actor.maxhp
        actor.mp = actor.maxmp
        @hospital_window.draw_item(@hospital_window.index)
        text = sprintf(SSS::HOSPITAL_HELP_TEXT, $game_party.heal_cost)
        text = SSS::HOSPITAL_HELP_HEALTHY if $game_party.heal_cost == 0
        @help_window.set_text(text, 1)
      end
    end
  end
end
 
#===============================================================================
#
# END OF FILE
#
#===============================================================================

Creditos

- Shanghai script - por criar o script.
- Neon Knight - por ter disponibilizado no forum
Neon Knight
Neon Knight


Mensagens : 15

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos