幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1782|回复: 1

[RM2K&2K3] 求rmxp仿仙剑练蛊皿脚本

[复制链接]

1

主题

3

帖子

26

积分

②入门

积分
26
QQ
发表于 2009-4-3 14:47:02 | 显示全部楼层 |阅读模式
RT   
回复

使用道具 举报

0

主题

2

帖子

15

积分

②入门

积分
15
发表于 2009-4-5 11:16:55 | 显示全部楼层
#=============================================================================
    # ■ 仿练蛊皿系统
    #    v 0.01
    #    by enghao_lim
    #    email:enghao_lim@hotmail.com
    #-----------------------------------------------------------------------------
    #    次腳本的功能就有如名字一样,就是模仿仙剑的练蛊皿。
    #    练蛊皿里只能放入物品而已,武器与防具,一概不行。
    #    为了配合游戏,某些物品是不能放入练蛊皿的,
    #    所以只要将不能放入器皿里的物品的编号加入 $lgm_except_item 里就行了。
    #    默认里有三个物品,分别是 30,31,32编号的物品。
    #    $界面标题 就是界面的标题,可以更改为自己需要的名字,默认为『"练蛊皿"』。
    #    这个脚本采用了一个运算方式,让不管什么物品,部分先后,
    #    都能够拿到成果。所以这脚本为每个物品都设置了一个“练蛊皿值”,
    #    先后放入两个的物品的练蛊皿值相加后,总值就会得到相应的物品。
    #    练蛊皿值的设置方法:在物品名字后面添加@,然后后面填写其练蛊皿值。
    #    方便理解的格式:『物品名@练蛊皿值』。例子:回复药@5。
    #    这样回复药的练蛊皿值就为5。补充一点,如果没有设置,
    #    物品编号将自动成为改物品的练蛊皿值。接下来就是为总值设定得到的物品,
    #    设置敌方在下面,两个物品的练蛊皿值相加数 => 得到的物品编号。
    #    就用回之前的例子好了,回复药有5点,如果放入两个,相加起来就是10点,
    #    而根据下列表显示,『10 => 6』,也就是说我们能够获得编号为6的物品。
    #    为了防止出现合成不到的情况,所以必须填入所有可能性的最大数量,
    #    比如说,默认是40,怎要拿的呢?就在以下的列表,从0开始,到39,
    #    总共有40个,所以Max_lgm_value必须填入40,相对的,如果删除掉其中一个,
    #    记得把Max_lgm_value必须填入39,否则可能会出现问题。
    #    还有,从0到39,当中的号数不能中断,必须是连号才行。
    #    最后,调用的方法:$scene = Scene_LGM.new
    #-----------------------------------------------------------------------------
         $界面标题 = "练蛊皿"
         $lgm_except_item = [32,31,30]
    #=============================================================================

    module LGM
      #所有可能性的最大数量
      Max_lgm_value = 40
      Output = []
      Output = {
      #两个物品的练蛊皿值相加数 => 得到的物品编号
      0 => 1,
      1 => 1,
      2 => 2,
      3 => 2,
      4 => 3,
      5 => 3,
      6 => 4,
      7 => 4,
      8 => 5,
      9 => 5,
      10 => 6,
      11 => 6,
      12 => 7,
      13 => 7,
      14 => 8,
      15 => 8,
      16 => 9,
      17 => 10,
      18 => 11,
      19 => 12,
      20 => 13,
      21 => 14,
      22 => 15,
      23 => 16,
      24 => 17,
      25 => 18,
      26 => 19,
      27 => 20,
      28 => 21,
      29 => 22,
      30 => 23,
      31 => 24,
      32 => 25,
      33 => 26,
      34 => 27,
      35 => 28,
      36 => 29,
      37 => 30,
      38 => 31,
      39 => 32,
      }
    end

    class Window_LGM_Title < Window_Base
      def initialize
        super(0,0,640,96)
        self.contents = Bitmap.new(width - 32,height - 32)
        refresh
      end
      def refresh
        self.contents.clear
        self.contents.font.color = crisis_color
        self.contents.font.size = 48
        self.contents.draw_text(0,0,self.width - 32,64,$界面标题,1)
      end
    end

    class Window_LGM_Item < Window_Selectable
      def initialize
        super(320,96,320,320)
        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 i in 1...$data_items.size
          if $game_party.item_number(i) > 0 and !$lgm_except_item.include?(i)
            @data.push($data_items)
          end
        end
        @item_max = @data.size
        if @item_max > 0
          self.contents = Bitmap.new(width - 32,row_max * 32)
          for i in 0...@item_max
            draw_item(i)
          end
        end
      end
      def draw_item(index)
        item = @data[index]
        number = $game_party.item_number(item.id)
        self.contents.font.color = normal_color
        x = 4
        y = index * 32
        rect = Rect.new(x,y,self.width - 32,32)
        self.contents.fill_rect(rect, Color.new(0,0,0,0))
        bitmap = RPG::Cache.icon(item.icon_name)
        opacity = self.contents.font.color == normal_color ? 255 : 128
        self.contents.blt(x, y + 4, bitmap, Rect.new(0,0,24,24),opacity)
        self.contents.draw_text(x + 28,y,212,32,item.name,0)
        self.contents.draw_text(x + 240,y,16,32,":",1)
        self.contents.draw_text(x + 256,y,24,32,number.to_s, 2)
      end
      def update_help
        @help_window.set_text(self.item == nil ? "" : self.item.description)
      end
    end

    class Window_LGM_Help < Window_Base
      def initialize
        super(0, 416, 640, 64)
        self.contents = Bitmap.new(width - 32,height - 32)
      end
      def set_text(text, align = 0)
        if text != @text or align != @align
          self.contents.clear
          self.contents.font.color = normal_color
          self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
          @text = text
          @align = align
          @actor = nil
        end
        self.visible = true
      end
    end

    class Window_LGM_Command < Window_Selectable
      def initialize
        super(0,96,320,352)
        @w1 = Window_Base.new(0,96,320,96)
        @w2 = Window_Base.new(0,192,320,96)
        @w3 = Window_Base.new(0,288,320,64)
        @w4 = Window_Base.new(0,352,320,64)
        self.contents = Bitmap.new(width - 32,height - 32)
        self.opacity = 0
        self.back_opacity = 0
        @commands = [$lgm_input_item[0],$lgm_input_item[1],"取消重來","蠱物練化"]
        @item_max = 4
        refresh
        self.index = -1
        self.active = false
      end
      def dispose
        super
        @w1.dispose
        @w2.dispose
        @w3.dispose
        @w4.dispose
      end
      def refresh
        self.contents.clear
        rect = Rect.new(4,0,280,64)
        self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
        self.contents.draw_text(4,0,280,32,"蛊物㈠:")
        self.contents.draw_text(4,32,280,32,$lgm_input_item[0],2)
        rect = Rect.new(4,96,280,64)
        self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
        self.contents.draw_text(4,96,280,32,"蛊物㈡:")
        self.contents.draw_text(4,128,280,32,$lgm_input_item[1],2)
        rect = Rect.new(4,192,280,32)
        self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
        self.contents.draw_text(rect,@commands[3],1)
        rect = Rect.new(4,256,280,32)
        self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
        self.contents.draw_text(rect,@commands[2],1)
      end
      def update_cursor_rect
        case self.index
        when 0
          self.cursor_rect.set(0,0,288,64)
        when 1
          self.cursor_rect.set(0,96,288,64)
        when 2
          self.cursor_rect.set(0,192,288,32)
        when 3
          self.cursor_rect.set(0,256,288,32)
        end
      end
    end

    class Window_LGM_Output < Window_Base
      def initialize
        super(160,160,320,160)
        self.contents = Bitmap.new(width - 32,height - 32)
        refresh
      end
      def refresh
        self.contents.clear
        self.contents.font.size = 20
        self.contents.font.color = normal_color
        self.contents.draw_text(0,0,self.width - 32,32,"物品練化:",1)
        self.contents.font.size = 40
        self.contents.font.color = crisis_color
        self.contents.draw_text(0,32,self.width - 32,96,$lgm_output_item,1)
      end
    end

    module RPG
      class Item
        def name
          name = @name.split(/@/)[0]
          return name != nil ? name : ""
        end
        def lgm_value
          lgm_value = @name.split(/@/)[1]
          return lgm_value != nil ? lgm_value.to_i : @id
        end
      end
    end

    class Scene_LGM
      def main
        @lgm_input_item = [0,0]
        @lgm_output_item = 0
        $lgm_input_item = ["没有蛊物","没有蛊物"]
        $lgm_output_item = "沒有練化"
        @tw = Window_LGM_Title.new
        @hw = Window_LGM_Help.new
        @iw = Window_LGM_Item.new
        @iw.active = false
        @iw.index = -1
        @iw.help_window = @hw
        @cw = Window_LGM_Command.new
        @cw.active = true
        @cw.index = 0
        @ow = Window_LGM_Output.new
        @ow.visible = false
        @ow.z = 2000
        Graphics.transition
        loop do
          Graphics.update
          Input.update
          update
          break if $scene != self
        end
        Graphics.freeze
        @tw.dispose
        @hw.dispose
        @iw.dispose
        @cw.dispose
        @ow.dispose
      end
      def update
        @tw.update
        @hw.update
        @iw.update
        @cw.update
        @ow.update
        return update_cw if @cw.active
        return update_iw if @iw.active
        return update_ow if @ow.visible
      end
      def update_cw
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          $game_party.gain_item(@lgm_input_item[0],1) if @lgm_input_item[0] != 0
          $game_party.gain_item(@lgm_input_item[1],1) if @lgm_input_item[1] != 0
          @lgm_input_item = [0,0]
          $lgm_input_item = ["沒有蠱物","没有蛊物"]
          $scene = Scene_Map.new
          return
        end
        if Input.trigger?(Input::C)
          case @cw.index
          when 0,1
            $game_system.se_play($data_system.decision_se)
            @cw.active = false
            @iw.index = 0
            @iw.active = true
          when 2
            if @lgm_input_item[0] == 0 or @lgm_input_item[1] == 0
              $game_system.se_play($data_system.cancel_se)
              return
            end
            Audio.se_play("Audio/SE/056-Right02")
            a = $data_items[@lgm_input_item[0]].lgm_value
            b = $data_items[@lgm_input_item[1]].lgm_value
            c = (a + b) % LGM::Max_lgm_value
            @lgm_output_item = LGM::Output[c]
            $lgm_output_item = $data_items[@lgm_output_item].name
            $game_party.gain_item(@lgm_output_item,1)
            @lgm_input_item = [0,0]
            $lgm_input_item = ["沒有蠱物","没有蛊物"]
            @ow.refresh
            @ow.visible = true
            @cw.active = false
          when 3
            if @lgm_input_item[0] == 0 and @lgm_input_item[1] == 0
              $game_system.se_play($data_system.cancel_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $game_party.gain_item(@lgm_input_item[0],1) if @lgm_input_item[0] != 0
            $game_party.gain_item(@lgm_input_item[1],1) if @lgm_input_item[1] != 0
            @lgm_input_item = [0,0]
            $lgm_input_item = ["沒有蠱物","没有蛊物"]
            @cw.refresh
            @iw.refresh
          end
        end
      end
      def update_iw
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          @iw.active = false
          @iw.index = -1
          @cw.active = true
        end
        if Input.trigger?(Input::C)
          @item = @iw.item
          return $game_system.se_play($data_system.cancel_se) if @item == nil
          $game_system.se_play($data_system.decision_se)
          case @cw.index
          when 0
            $game_party.gain_item(@lgm_input_item[0],1) if @lgm_input_item[0] !=0
            $game_party.gain_item(@item.id,-1)
            @lgm_input_item[0] = @item.id
            $lgm_input_item[0] = @item.name
            if @lgm_input_item[1] != 0
              @cw.index = 2
              @cw.active = true
              @iw.active = false
              @iw.index = -1
            else
              @cw.index = 1
              @cw.active = true
              @iw.active = false
              @iw.index = -1
            end
          when 1
            $game_party.gain_item(@lgm_input_item[1],1) if @lgm_input_item[1] !=0
            $game_party.gain_item(@item.id,-1)
            @lgm_input_item[1] = @item.id
            $lgm_input_item[1] = @item.name
            if @lgm_input_item[0] == 0
              @cw.index = 0
              @cw.active = true
              @iw.active = false
              @iw.index = -1
            else
              @cw.index = 2
              @cw.active = true
              @iw.active = false
              @iw.index = -1
            end
          end
          @cw.refresh
          @iw.refresh
        end
      end
      def update_ow
        if Input.trigger?(Input::C) or Input.trigger?(Input::B)
          @ow.visible = false
          @cw.index = 0
          @cw.active = true
          @iw.refresh
          @cw.refresh
        end
      end
    end
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-5-19 10:20 , Processed in 0.026675 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表