スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

web拍手 by FC2   

[RGSS]ウォンテッドシステム

使い方は → こちら

[RGSS]ウォンテッドシステム
クエストのようなシステムを作成できます。 設定項目がやや大変なため後々変更する可能性があります。

スクリーンショット サムネイルクリックで拡大画像が見られます。
rgss_wanted.jpg

プログラムは続きにあります。

=begin
===============================================================================
  ☆★☆★☆★☆★ ウォンテッドシステム ★☆★☆★☆★☆
=============================================================================== 

 製作・開発:STERS
  アイデア:ルルベル様

  Page::http://stersblog.blog15.fc2.com/

導入方法------------------------------------------------------------------

    このスクリプトを Scene_Debug より下 Main より上に
   新しく作ったセクションにコピペして入れてください。
    
--------------------------------------------------------------------------

これを導入することで
ウォンテッドシステム
ができるようになります。

※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
アイテムの指定ができないバージョンのウォンテッドシステムと
微妙にセーブする中身が異なるため、以前のセーブデータは使えない可能性があります。
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※

使い方--------------------------------------------------------------------
1.まずはこのスクリプトを導入してください。

2.設定項目を編集してください。

3.ウォンテッドアイテムを作成してください。
    このときの説明文が右側にでる説明になります。| で改行が可能です。
     (アイテム名はウォンテッド名と同じにしてください。)

4.「ショップの処理」で先ほど作成した、
     ウォンテッドアイテムを指定します。
     ( すぐ前に「スクリプト」で「$wanted = true」を記述してください。) 
     
5.ウォンテッドイベントは、設定項目で指定した
    「選択するとONになるスイッチID」を利用して、
     「ページの条件分岐」を使い指定してください。
     
     イベント終了後は、「クリアするとONになるスイッチID」の
     スイッチをONにしておいてください。
     
6.ウォンテッドニュースを指定するには
     「スクリプト」で「$wanted_news = "内容"」のようにしてください。
     「内容」の部分は任意の文字列にしてください。

--------------------------------------------------------------------------

終了したウォンテッドをメニューなどで見れるようにするには、
掲示板へとご連絡をください。

--------------------------------------------------------------------------
=end
#--------------------------------------------------------------------------
# ☆ 設定項目
#--------------------------------------------------------------------------
#==============================================================================
#   文字色の設定
#                通常はこのままでいいです
#==============================================================================
class Color
  def self.text_color(n)
    case n
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      return self.normal_color
    end
  end
  def self.normal_color
    return Color.new(255, 255, 255, 255)
  end
  def self.disabled_color
    return Color.new(255, 255, 255, 128)
  end
  def self.system_color
    return Color.new(192, 224, 255, 255)
  end
end
#┌───────────────┐
#│      ウォンテッドの設定      │
#└───────────────┘
module Wanted
  # ウォンテッドの設定は2パターンあります。
  #--------------------------------------------------------------------
  # [ウォンテッド名,ボス名,[報酬...],詳細情報,
  #  受注でONになるスイッチID, ONでクリアになるスイッチID,
  #  [出現条件(スイッチID)...]]
  #--------------------------------------------------------------------
  # [ウォンテッド名,ボス名,[報酬...],詳細情報,
  #  受注でONになるスイッチID, [納品アイテム...],
  #  [出現条件(スイッチID)...]]
  #--------------------------------------------------------------------
  #
  # それぞれ順番が乱れないように気を付けてください。
  #
  # 受注でONになるスイッチID と ONでクリアになるスイッチID
  #  を同じにすると受注した瞬間にクリアとなりますw
  #
  # 出現条件には
  #        いくつでも指定できます
  #
  # 詳細情報には | が使えます(改行)
  # 詳細情報を nil (または"") にすると詳細情報を見れません。
  #
  #
  # 報酬は数字ならすべての合計が賞金。
  #       変数の値を使いたいときは $game_variables[id] でできます。
  # 例) [1000 * $game_variables[1]]
  #     1000×変数1番の計算結果が賞金
  #
  #       文字列なら下記に示すとおりです。(小文字でも可能)
  #       I○:△  アイテム○番を△個
  #       W○:△  武器○番を△個
  #       A○:△  防具○番を△個
  #
  # 納品アイテムは報酬のアイテムと同じ形式で指定してください。
  #       I○:△  アイテム○番を△個
  #       W○:△  武器○番を△個
  #       A○:△  防具○番を△個
  #
  
  ITEM = [["討伐","エンシェントドラゴン",[1000000],
           "[北の山脈]にて目撃情報|"+
           "いまだに被害はないものの、放っておいてはいけない||"+
           "至急、討伐を。",
           10,11,[]],
          ["討伐2","グランドドラゴン",[1000000],
           "[東の海岸]にて目撃されている。|"+
           "このままでは漁ができずに食糧不足になりかねない。||"+
           "ドラゴンの類においては比較的強い方なので|"+
           "準備を忘れずにしてほしい。",
           12,13,[]],
          ["2匹の復讐","エンシェント&グランド",[100000000],
           "≪エンシェントドラゴン≫と≪グランドドラゴン≫の目撃情報。|"+
           "[南の平原]に住み着いている模様。||"+
           "ドラゴン2体を同時に相手するのは手ごわいだろう。|"+
           "Aランクの2人を同行させよう。",
           14,15,[11,13]],
          ["アイテム配布中","",["I1:10","I2:10","I3:10","I4:10","I5:10"],
           "ギルマスの俺がアイテム配布中|"+
           "早いもん勝ちだぜ☆|||||||||早くしないとなくなるよ^^",
           16,16,[]],
          ["ポーションが盗まれた","",[10000],
           "王国騎士団に常備されているはずのポーションが|"+
           "何者かに盗まれた!!||"+
           "ポーションを早く送らねば騎士団は全滅するだろう。|"+
           "君の協力に期待する。",
           17,["I1:10"],[]],
          ["アイテムが欲しい","",["W4:1","A4:1"],
           "いろんなアイテムが欲しいでしゅ|"+
           "報酬は期待するでしゅ|",
           18,["I1:1","i2:1","W1:1","w2:1","A1:1","a1:1"],[]],
          ]
  
  #
  # ウォンテッドニュース の文字
  #
  WANTED_NEWS_STR = "ニュース! "
  
  # 情報の詳細を見るキー
  WANTED_REPORT_KEY = Input::F5
  
  #┌───────────────┐
  #│    いろんなところの文字色  │
  #└───────────────┘
  #
  # Color.normal_color:普通の文字色(白)
  #
  # Color.system_color:システム文字色(水色っぽい色)
  #
  # Color.disabled_color:選択できないような色(灰色っぽい色)
  #
  # Color.text_color(n):"文章の表示"の"\C[n]"とおなじ
  #
  # Color.new(R,G,B[,A]):"R","G","B"をを合成した色
  #                       "A"は省略可能で、アルファ値を示す
  #                                        (色がうすくなる)
  #
  
  # ニュースでの通常文字色
  NEWS_NORMAL_COLOR = Color.normal_color
  
  # ニュースでの特殊文字色
  NEWS_SPECIAL_COLOR = Color.system_color
  
  # 選択での文字色
  TOP_COLOR = Color.normal_color
  
  # 右での情報の通常文字色
  RIGHT_NORMAL_COLOR = Color.normal_color
  
  # 右での情報の特殊文字色
  RIGHT_REPORT_COLOR = Color.text_color(2)

  # 右でのウォンテッド終了文字色
  RIGHT_END_COLOR = Color.disabled_color
  
  # 右での進行状況の文字色
  RIGHT_SUTATUS_COLOR = Color.system_color
  
  # 左での通常文字色
  LEFT_COLOR = Color.normal_color
  
  # 左でのウォンテッド終了文字色
  LEFT_END_COLOR = Color.disabled_color
  
  # 確認での通常文字色
  YORN_NORMAL_COLOR = Color.normal_color
  
  # 確認での特殊文字色
  YORN_SPECIAL_COLOR = Color.text_color(1)
#==============================================================================
#                          設定ここまで
#==============================================================================
  def self.get_item(a)
    s = a.split(":")
    if s[0] =~/i/i
      s[0].sub!(/i/i,"")
      return [$data_items[s[0].to_i],s[1].to_i]
    elsif s[0] =~/w/i
      s[0].sub!(/w/i,"")
      return [$data_weapons[s[0].to_i],s[1].to_i]
    elsif s[0] =~/a/i
      s[0].sub!(/a/i,"")
      return [$data_armors[s[0].to_i],s[1].to_i]
    end
    return [nil,nil]
  end
end
$wanted_news = ""
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
  attr_accessor :wanted_item
  attr_accessor :play_wanted
  attr_accessor :play_wanted_name
  attr_accessor :play_wanted_item
  alias wanted_initialize initialize unless $@
  def initialize
    @wanted_item = {}
    @play_wanted = false
    @play_wanted_name = ""
    @play_wanted_item = {}
    wanted_initialize
  end
end
#==============================================================================
# ■ Window_WantedCommand
#==============================================================================
class Window_WantedCommand < Window_Selectable
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 3
    @column_max = 3
    @commands = ["引き受ける", "報酬をもらう", "キャンセル"]
    refresh
    self.index = 0
  end
  def refresh
    self.contents.clear
    self.contents.font.color = Wanted::TOP_COLOR
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def draw_item(index)
    x = 4 + index * 160
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end

#==============================================================================
# ■ Window_WantedStatus
#==============================================================================
class Window_WantedStatus < Window_Base
  attr_accessor :sell
  def initialize(goods)
    super(368, 128, 272, 352)
    @item = nil
    @sell = false
    @contents = {}
    for go in goods
      itt = $data_items[go[1]].name
      @contents[itt] = Bitmap.new(width-32, height-32)
      for it in Wanted::ITEM
        if it[0] == itt
          switch_id2 = it[4]
          switch_id = it[5]
          boss = it[1]
          text = $data_items[go[1]].description
          raise("報酬が配列形式ではありません") unless it[2].is_a?(Array)
          if it[2][0].is_a?(Numeric)
            price = 0
            it[2].each{|s| price += s }
          else
            price = it[2]
          end
          break
        end
      end
      draw(text, itt, boss, price)
      if $game_switches[switch_id2] != true
        @contents[itt].font.color = Wanted::RIGHT_SUTATUS_COLOR
        @contents[itt].draw_text(0, 0, 220, 32, "このウォンテッドは")
        @contents[itt].draw_text(0, 30, 220, 32, "まだやっていない")
      elsif $game_system.wanted_item[itt] == nil
        @contents[itt].font.color = Wanted::RIGHT_SUTATUS_COLOR
        @contents[itt].draw_text(0, 0, 220, 32, "このウォンテッドは")
        @contents[itt].font.color = disabled_color
        @contents[itt].draw_text(0, 30, 220, 32, "実行中・・・・・")
      else
        @contents[itt].font.color = Wanted::RIGHT_SUTATUS_COLOR
        @contents[itt].draw_text(0, 0, 220, 32, "このウォンテッドの報酬は")
        if $game_system.wanted_item[itt] == false
          @contents[itt].draw_text(0, 30, 220, 32, "まだ受け取ってない")
        else
          @contents[itt].font.color = Wanted::RIGHT_END_COLOR
          @contents[itt].draw_text(0, 30, 220, 32, "すでに受け取ってる")
        end
      end
    end
    refresh
  end
  def dispose
    @contents.each_value{|a|a.dispose}
  end
  def get_item
    return @item
  end
  def item=(it)
    return if it == nil
    if @item != it.name
      @item = it.name
      refresh
    end
  end
  def refresh
    return if @item == nil
    self.contents = @contents[@item]
  end
  def draw(str, itt, boss, price)
    kaigyo = "|"
    x = 0
    y = 0
    yy = 0
    if str != ""
      @contents[itt].font.color = Wanted::RIGHT_SUTATUS_COLOR
      @contents[itt].draw_text(4, 70, 300, 32, "情報")
      @contents[itt].font.color = Wanted::RIGHT_NORMAL_COLOR
      str.scan(/\G./){|c|
        if c == kaigyo
          y += 1
          x = 0
          next
        end
        @contents[itt].draw_text(0 + x, 100 + 32 * y, 32, 32, c)
        x += @contents[itt].text_size(c).width
      }
      y += 1
    end
    if boss != ""
      @contents[itt].font.color = Wanted::RIGHT_REPORT_COLOR
      @contents[itt].draw_text(0, 100+32*y, 300, 32, "標的:#{boss}")
      y += 1
    end
    if price.is_a?(Numeric)
      @contents[itt].font.color = Wanted::RIGHT_REPORT_COLOR
      @contents[itt].draw_text(0, 100+32*y, 300, 32, "報酬:#{price}")
      y += 1
    else
      @contents[itt].font.color = Wanted::RIGHT_REPORT_COLOR
      @contents[itt].draw_text(0, 100+32*y, 300, 32, "報酬:")
      yy = @contents[itt].text_size("報酬:").height
      price.each{|a|
        s = Wanted.get_item(a)
        @contents[itt].draw_text(0, 100+32*y+yy, 300, 32, "#{s[0].name}#{s[1]}個")
        yy += @contents[itt].text_size("#{s[0]}#{s[1]}個").height
      }
    end
  end
end

#==============================================================================
# ■ Window_WantedFullStatus
#==============================================================================
class Window_WantedFullStatus < Window_Base
  def initialize
    super(0, 128, 640, 352)
    self.contents = Bitmap.new(1, 1)
  end
  def refresh(i)
    self.oy = 0
      kaigyo = "|"
      item = i
      h = 0
      for it in Wanted::ITEM
        next unless it[0] == item
        switch_id2 = it[4]
        switch_id = it[5]
        boss = it[1]
        text = it[3]
        h = 100 + 32 * text.split(kaigyo).size
        raise("報酬が配列形式ではありません") unless it[2].is_a?(Array)
        if it[2][0].is_a?(Numeric)
          price = 0
          it[2].each{|s| price += s }
          h += 32
        else
          price = it[2]
          h += 32 * price.size
        end
        break
      end
      self.contents.dispose
      self.contents = Bitmap.new(width-32, h+64)
      x = 0
      y = 0
      if text != ""
        self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
        self.contents.draw_text(4, 70+64, 300, 32, "詳細情報")
        self.contents.font.color = Wanted::RIGHT_NORMAL_COLOR
        text.scan(/\G./){|c|
          if c == kaigyo
            y += 1
           x = 0
           next
         end
         self.contents.draw_text(0 + x, 100 + 32 * y+64, 32, 32, c)
         x += self.contents.text_size(c).width
        }
        y += 1
      end
      if boss != ""
        self.contents.font.color = Wanted::RIGHT_REPORT_COLOR
        self.contents.draw_text(0, 100+32*y+64, 300, 32, "標的:#{boss}")
        y += 1
      end
      if price.is_a?(Numeric)
        self.contents.font.color = Wanted::RIGHT_REPORT_COLOR
        self.contents.draw_text(0, 100+32*y+64, 300, 32, "報酬:#{price}")
      else
        self.contents.font.color = Wanted::RIGHT_REPORT_COLOR
        self.contents.draw_text(0, 100+32*y+64, 300, 32, "報酬:")
        y += 1
        price.each{|a|
          s = Wanted.get_item(a)
          self.contents.draw_text(0, 100+32*y+64, 300, 32, "#{s[0].name}#{s[1]}個")
          y += 1
        }
      end
      self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
      self.contents.font.size = Font.default_size + 4
      self.contents.draw_text(0, 0, 250, 32, item)
      self.contents.font.size = Font.default_size
      if $game_switches[switch_id2] != true
        self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
        self.contents.draw_text(0, 64, 250, 32, "このウォンテッドは")
        self.contents.draw_text(0, 30+64, 250, 32, "まだやっていない")
      elsif $game_system.wanted_item[item] == nil
        self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
        self.contents.draw_text(0, 64, 250, 32, "このウォンテッドは")
        self.contents.font.color = disabled_color
        self.contents.draw_text(0, 30+64, 250, 32, "実行中・・・・・")
      else
        self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
        self.contents.draw_text(0, 64, 250, 32, "このウォンテッドは")
        self.contents.font.color = disabled_color
        self.contents.draw_text(0, 30+64, 250, 32, "終了済み")
      end
      self.contents.font.color = Wanted::RIGHT_SUTATUS_COLOR
      self.contents.draw_text(self.contents.width/2, 64, 250, 32, "このウォンテッドの報酬は")
      if $game_system.wanted_item[item] != true
        self.contents.draw_text(self.contents.width/2, 30+64, 250, 32, "まだ受け取ってない")
      elsif $game_system.wanted_item[item] == true
        self.contents.font.color = Wanted::RIGHT_END_COLOR
        self.contents.draw_text(self.contents.width/2, 30+64, 250, 32, "すでに受け取ってる")
      end
  end
  def update
    super
    return if self.visible == false
    if Input.press?(Input::UP)
      if self.oy < self.contents.height - self.height + 32
        self.oy += 32
          $game_system.se_play($data_system.cursor_se)
      end
    elsif Input.press?(Input::DOWN)
      if self.oy > 0
        self.oy -= 32
          $game_system.se_play($data_system.cursor_se)
      end
    end
  end
end

#==============================================================================
# ■ Window_WantedBuy
#==============================================================================
class Window_WantedBuy < Window_Selectable
  def initialize(goods, sell=false)
    super(0, 128, 368, 352)
    @shop_goods = goods
    @sell = sell
    refresh
    self.index = 0
  end
  def item
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for item in @shop_goods
      flag = true
      for it in Wanted::ITEM
        next if it[0] != $data_items[item[1]].name
        break if it[6] == nil
        for it2 in it[6]
          if $game_switches[it2] == false
            flag = false
            break
          end
        end
        break
      end
      next if flag == false
      @data.push $data_items[item[1]]
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(self.width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  def draw_item(index)
    item = @data[index]
    for it in Wanted::ITEM
      if it[0] == item.name
        switch_id = it[5]
        switch_id2 = it[4]
        price = it[2]
        break
      end
    end
    if @sell
      if $game_system.wanted_item[item.name] == false
        self.contents.font.color = Wanted::LEFT_COLOR
      else
        self.contents.font.color = Wanted::LEFT_END_COLOR
      end
    else
      if $game_switches[switch_id2] != true
        if $game_system.play_wanted == false
          self.contents.font.color = Wanted::LEFT_COLOR
        end
      else
        self.contents.font.color = Wanted::LEFT_END_COLOR
      end
    end
    self.contents.font.color = Wanted::LEFT_END_COLOR if $game_system.play_wanted == true and !@sell
    x = 4
    y = index * 32
    self.contents.draw_text(x, y, 368, 32, item.name)
  end
  def update_help
  end
end

#==============================================================================
# ■ Window_WantedHelp
#==============================================================================
class Window_WantedHelp < Window_Base
  attr_reader   :text_width
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @text_width = 0
  end
  def set_text(text)
    if text == ""
      text = $wanted_news
    end
    if text != @text
      @text = text
      x = 640
      self.contents.clear
      if @text == $wanted_news
        self.contents.font.color = Wanted::NEWS_SPECIAL_COLOR
        self.contents.draw_text(x, 0, 640, 32, Wanted::WANTED_NEWS_STR)
        @cx = self.contents.text_size(Wanted::WANTED_NEWS_STR).width
      else
        @cx = 0
      end
      self.contents.font.color = Wanted::NEWS_NORMAL_COLOR
      self.contents.draw_text(x+@cx+2, 0, 640, 32, @text)
      @text_width = @cx + self.contents.text_size(@text).width + 4
    end
    self.visible = true
  end
  def refresh(x)
    self.contents.clear
    self.contents.font.color = Wanted::NEWS_SPECIAL_COLOR
    self.contents.draw_text(x, 0, 640, 32, Wanted::WANTED_NEWS_STR)
    return if @text == "" or @cx.is_a?(Numeric) != true
    self.contents.font.color = Wanted::NEWS_NORMAL_COLOR
    self.contents.draw_text(x+@cx+2, 0, 640, 32, @text)
  end
end

#==============================================================================
# ■ Window_WantedYorN
#==============================================================================
class Window_WantedYorN < Window_Selectable
  def initialize
    super(0, 0, 300, 100)
    @item_max = 2
    @commands = ["受ける","やめる"]
    self.contents = Bitmap.new(300 - 32, 100-32)
    self.index = 0
  end
  def refresh(item)
    self.contents.clear
    return if item == nil
    self.contents.font.color = Wanted::YORN_NORMAL_COLOR
    rect = Rect.new(4, 4, (300-32)/2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[0])
    self.contents.font.color = Wanted::YORN_NORMAL_COLOR
    rect = Rect.new((300-32)/2 + 4, 4, (300-32)/2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[1])
    self.contents.font.color = Wanted::YORN_SPECIAL_COLOR
    self.contents.draw_text(0,40,300-64,32,"報酬:#{price_get(item.name)}",1)
  end
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  def update_cursor_rect
    self.cursor_rect.set(@index * (300-32)/2, 0, (300-32)/2, 36)
  end
  def update
    return if Input.press?(Input::UP) or Input.press?(Input::DOWN)
    super
    if self.active
      if Input.repeat?(Input::RIGHT) and @index == 0
        $game_system.se_play($data_system.cursor_se)
        @index += 1
      end
      if Input.repeat?(Input::LEFT) and @index == 1
        $game_system.se_play($data_system.cursor_se)
        @index -= 1
      end
    end
  end
  def price_get(i)
    for it in Wanted::ITEM
      next unless it[0] == i
      raise("報酬が配列形式ではありません") unless it[2].is_a?(Array)
      if it[2][0].is_a?(Numeric)
        p = 0
        it[2].each{|s| p += s }
        return p
      else
        return "アイテム"
      end
    end
  end
end
#==============================================================================
# ■ Window_WantedNouhin
#==============================================================================
class Window_WantedNouhin < Window_Selectable
  def initialize
    super(0, 0, 300, 100)
    @item_max = 2
    @commands = ["納品する","キャンセル"]
    self.contents = Bitmap.new(1, 1)
    self.index = 0
    @ii = nil
  end
  def item
    @ii
  end
  def refresh(ite)
    self.contents.clear
    @ii = ite
    return if ite == nil
    s = []
    for it in Wanted::ITEM
      ite.each{|item|
      next unless it[0] == item[0]
      s.push([item[1][0].name,$game_system.play_wanted_item[item[1][0].name],item[1][1]])
      }
    end
    self.height = s.size * 32 + 40 + 36
    self.contents.dispose unless self.contents.disposed?
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    self.contents.font.color = Wanted::YORN_SPECIAL_COLOR
    for i in 0...s.size
      self.contents.draw_text(0,40+i*32,self.contents.width,32,"#{s[i][0]}:#{s[i][1]}/#{s[i][2]}",1)
    end
    self.contents.font.color = Wanted::YORN_NORMAL_COLOR
    rect = Rect.new(4, 4, self.contents.width/2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[0])
    self.contents.font.color = Wanted::YORN_NORMAL_COLOR
    rect = Rect.new(self.contents.width/2 + 4, 4, self.contents.width/2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[1])
  end
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  def update_cursor_rect
    self.cursor_rect.set(@index * (300-32)/2, 0, (300-32)/2, 36)
  end
  def update
    return if Input.press?(Input::UP) or Input.press?(Input::DOWN)
    super
    if self.active
      if Input.repeat?(Input::RIGHT) and @index == 0
        $game_system.se_play($data_system.cursor_se)
        @index += 1
      end
      if Input.repeat?(Input::LEFT) and @index == 1
        $game_system.se_play($data_system.cursor_se)
        @index -= 1
      end
    end
  end
end

#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop
  alias wanted_main main unless $@
  def main
    if $wanted
      $scene = Scene_WantedShop.new
      return
    end
    wanted_main
  end
end

#==============================================================================
# ■ Scene_WantedShop
#==============================================================================
class Scene_WantedShop
  def main
    return if $wanted != true
    @nohin_item = []
    if $game_system.play_wanted == true
      for it in Wanted::ITEM
        next unless it[0] == $game_system.play_wanted_name
        if it[5].is_a?(Numeric)
          if $game_switches[it[5]]
            $game_system.play_wanted = false
            $game_system.wanted_item[it[0]] = false
          end
        else
          it[5].each{|a|
            s = Wanted.get_item(a)
            if s[0].is_a?(RPG::Item)
              if $game_party.item_number(s[0].id) != 0 and $game_system.play_wanted_item.include?(s[0].name)
                if $game_system.play_wanted_item[s[0].name] < s[1]
                  @nohin_item.push([it[0],s])
                end
              end
            elsif s[0].is_a?(RPG::Weapon)
              if $game_party.weapon_number(s[0].id) != 0 and $game_system.play_wanted_item.include?(s[0].name)
                if $game_system.play_wanted_item[s[0].name] < s[1]
                  @nohin_item.push([it[0],s])
                end
              end
            elsif s[0].is_a?(RPG::Armor)
              if $game_party.armor_number(s[0].id) != 0 and $game_system.play_wanted_item.include?(s[0].name)
                if $game_system.play_wanted_item[s[0].name] < s[1]
                  @nohin_item.push([it[0],s])
                end
              end
            end
          }
        end
        break
      end
    end
    @help_window =Window_WantedHelp.new
    @help_window.set_text("")
    @command_window = Window_WantedCommand.new
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    @x = 640
    ffg = false
    if @nohin_item.size != 0
      ffg = true
      @nohin = Window_WantedNouhin.new
      @nohin.visible = false
      @nohin.active = false
      @nohin.x = 320 - @nohin.width / 2
      @nohin.z = 9999
      Graphics.transition
      while @nohin_item.size != 0
        Graphics.update
        Input.update
        @help_window.update
        @gold_window.update
        @dummy_window.update
        @x -= 2
        @x = 640 if @x <= -(@help_window.text_width)
        @help_window.refresh(@x)
        nohin_update
        break if $scene != self
      end
      Graphics.freeze
      @nohin.dispose
    end
    @buy_window = Window_WantedBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @sell_window = Window_WantedBuy.new($game_temp.shop_goods, true)
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    @yorn_win = Window_WantedYorN.new
    @yorn_win.x = 368 / 2 - @yorn_win.width / 2
    @yorn_win.y = 352 / 2 - @yorn_win.height / 2 + 128
    @yorn_win.active = false
    @yorn_win.visible = false
    @yorn_win.z = 9999
    @status_window = Window_WantedStatus.new($game_temp.shop_goods)
    @status_window.visible = false
    @full_status_window = Window_WantedFullStatus.new
    @full_status_window.visible = false
    @full_status_window.z = @status_window.z + 10
    Graphics.frame_reset
    Graphics.transition(ffg == true ? 0 : 8)
    loop do
      Graphics.update
      Input.update
      update_wanted
      if $scene != self
        break
      end
    end
    $wanted = false
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
    @yorn_win.dispose
    $game_map.refresh
  end
  def update_wanted
    @help_window.update
    @gold_window.update
    @dummy_window.update
    @status_window.update
    @full_status_window.update
    @command_window.update
    @x -= 2
    @x = 640 if @x <= -(@help_window.text_width)
    @help_window.refresh(@x)
    if @command_window.active
      update_command_wanted
      return
    end
    if @full_status_window.visible
      update_full_status
      return
    elsif Input.trigger?(Wanted::WANTED_REPORT_KEY)
      @full_status_window.refresh(@status_window.get_item)
      @full_status_window.visible = true
      return
    end
    @buy_window.update
    @sell_window.update
    @yorn_win.update
    if @sell_window.active
      @status_window.item = @sell_window.item
      update_sell_wanted
      return
    end
    if @yorn_win.active
      update_yorn
      return
    end
    if @buy_window.active
      update_buy_wanted
      return
    end
  end
  def update_command_wanted
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
        @status_window.visible = true
        @status_window.sell = true
        @sell_flag = true
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
  def update_buy_wanted
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or $game_system.wanted_item.include?(@item.name) or
        $game_system.play_wanted != false
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      for it in Wanted::ITEM
        next unless it[0] == @item.name
        switch_id = it[4]
        name = it[0]
        nohin = it[5]
        break
      end
      if $game_switches[switch_id] != false
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @switch_id = switch_id
      @name = name
      @g_nohin = nohin
      @yorn_win.refresh(@item)
      @yorn_win.active = true
      @yorn_win.visible = true
      @buy_window.active = false
      return
    end
  end
  def update_sell_wanted
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @status_window.sell = false
      @help_window.set_text("")
      all_refresh
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      for it in Wanted::ITEM
        switch_id = it[5]  if it[0] == @item.name
      end
      if switch_id.is_a?(Numeric)
        if $game_switches[switch_id] != true
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      end
      if $game_system.wanted_item[@item.name] != nil
        return if $game_system.wanted_item[@item.name] == true
        $game_system.se_play($data_system.decision_se)
        for it in Wanted::ITEM
          next unless it[0] == @item.name
          if it[2][0].is_a?(Numeric)
            price = 0
            it[2].each{|s| price += s }
          else
            price = it[2]
          end
          if price.is_a?(Numeric)
            $game_party.gain_gold(price)
          else
            price.each{|a|
              s = Wanted.get_item(a)
              if s[0].is_a?(RPG::Item)
                $game_party.gain_item(s[0].id, s[1])
              elsif s[0].is_a?(RPG::Weapon)
                $game_party.gain_weapon(s[0].id, s[1])
              elsif s[0].is_a?(RPG::Armor)
                $game_party.gain_armor(s[0].id, s[1])
              end
            }
          end
          break
        end
        @gold_window.refresh
        $game_system.wanted_item[@item.name] = true
        @status_window.refresh
      else
        $game_system.se_play($data_system.buzzer_se)
      end
      all_refresh
      return
    end
  end
  def update_yorn
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @yorn_win.active = false
      @yorn_win.visible = false
      @buy_window.active = true
      @yorn_win.index = 0
      all_refresh
      return
    end
    if Input.trigger?(Input::C)
      if @yorn_win.index == 1
        $game_system.se_play($data_system.cancel_se)
        @yorn_win.active = false
        @yorn_win.visible = false
        @buy_window.active = true
        return
      end
      $game_system.se_play($data_system.decision_se)
      $game_switches[@switch_id] = true
      @status_window.refresh
      @yorn_win.active = false
      @yorn_win.visible = false
      @buy_window.active = true
      @yorn_win.index = 0
      $game_system.play_wanted = true
      $game_system.play_wanted_name = @name
      if @g_nohin.is_a?(Array)
        @g_nohin.each{|a|
          s = Wanted.get_item(a)
          $game_system.play_wanted_item[s[0].name] = 0
        }
      end
      all_refresh
      return
    end
  end
  def update_full_status
    if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
       Input.trigger?(Wanted::WANTED_REPORT_KEY)
      @full_status_window.visible = false
      return
    end
  end
  def nohin_update
    @nohin.update
    if @nohin.active != true
      @command_window.active = false
      @nohin.visible = true
      @nohin.active = true
      @nohin.refresh(@nohin_item)
      @nohin.y = 240 - @nohin.height / 2
      return
    end
    if Input.trigger?(Input::B)
      @command_window.active = false
      @nohin.visible = false
      @nohin.active = false
      @nohin_item = []
      $game_system.se_play($data_system.cancel_se)
      return
    end
    if Input.trigger?(Input::C)
      if @nohin.index == 1
        @command_window.active = true
        @nohin.visible = false
        @nohin.active = false
        @nohin_item = []
        $game_system.se_play($data_system.cancel_se)
        return
      end
      x = 0
      fg = 0
      @nohin_item.each{|s|
        if s[1][0].is_a?(RPG::Item)
          x = $game_party.item_number(s[1][0].id)
          x = s[1][1] - $game_system.play_wanted_item[s[1][0].name] if $game_system.play_wanted_item[s[1][0].name] + x > s[1][1]
          $game_system.play_wanted_item[s[1][0].name] += x
          $game_party.lose_item(s[1][0].id, x)
        elsif s[1][0].is_a?(RPG::Weapon)
          x = $game_party.weapon_number(s[1][0].id)
          x = s[1][1] - $game_system.play_wanted_item[s[1][0].name] if $game_system.play_wanted_item[s[1][0].name] + x > s[1][1]
          $game_system.play_wanted_item[s[1][0].name] += x
          $game_party.lose_weapon(s[1][0].id, x)
        elsif s[1][0].is_a?(RPG::Armor)
          x = $game_party.armor_number(s[1][0].id)
          x = s[1][1] - $game_system.play_wanted_item[s[1][0].name] if $game_system.play_wanted_item[s[1][0].name] + x > s[1][1]
          $game_system.play_wanted_item[s[1][0].name] += x
          $game_party.lose_armor(s[1][0].id, x)
        end
        fg += 1 if $game_system.play_wanted_item[s[1][0].name] == s[1][1]
      }
      if fg == @nohin_item.size
        $game_system.play_wanted = false
        $game_system.wanted_item[$game_system.play_wanted_name] = false
      end
      @command_window.active = true
      @nohin.visible = false
      @nohin.active = false
      @nohin_item = []
      $game_system.se_play($data_system.decision_se)
    end
  end
  def all_refresh
    @buy_window.refresh
    @sell_window.refresh
    @yorn_win.refresh(@item)
    @status_window.refresh
    @gold_window.refresh
    @buy_window.update
    @sell_window.update
    @yorn_win.update
    @status_window.update
    @gold_window.update
  end
end

web拍手 by FC2   

コメントの投稿


非公開コメント

コメント

STERS's Development Room

STERSの開発室っぽい何か。


プロフィール

Name:STERS
Unity3D/C#/PHP/js/C++/VB
などを勉強中です

[STERS's Room]
[ファイル置き場]

カテゴリー
最近の記事
最近のコメント
カレンダー
08 ≪│2017/09│≫ 10
- - - - - 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
RSSリンクの表示
ブログ内Google検索
Google
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。