赞 | 1 |
VIP | 0 |
好人卡 | 10 |
积分 | 38 |
经验 | 28385 |
最后登录 | 2022-4-9 |
在线时间 | 723 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3841
- 在线时间
- 723 小时
- 注册时间
- 2014-3-29
- 帖子
- 509
|
3楼

楼主 |
发表于 2014-8-4 12:04:47
|
只看该作者
- module Advanced
-
- #为true则代表当等级满级并且持有i2号物品、武器、防具时可以进阶
- #为false则代表只需要持有i2号物品、武器、防具时可以进阶
- CONDITION = true
- ADVANCED_OBJ = /<advanced = (\d+) if (lv|i|w|a) = (\d+)>/i
-
- #获取进阶后的id,同时根据返回值的size来判定是否可以进阶
- def self.get_advanced_id(actor)
- ren = []
- return ren if actor == nil
- return ren if !actor.is_pet?
- $data_actors[actor.id].note.scan(ADVANCED_OBJ){|id1,type,id2|
- j = [];j.push(id1);j.push(type);j.push(id2);
- ren.push(j)
- }
- return ren
- end
- end
- #--------------------------------------------------------------------------
- # 主窗体
- #--------------------------------------------------------------------------
- class Scene_Advanced < Scene_MenuBase
- def start
- super
- create_select_window
- create_command_window
- end
-
- def create_select_window
- @select_window = Window_AdvancedSelect.new
- @select_window.viewport = @viewport
- @select_window.activate
- @select_window.set_handler(:ok, method(:select_advanced_ok))
- @select_window.set_handler(:cancel, method(:select_advanced_cancel))
- end
-
- def create_command_window
- @command_window = Window_AdvancedCommand.new
- @command_window.viewport = @viewport
- @command_window.deactivate
- @command_window.set_handler(:ok, method(:advanced))
- @command_window.set_handler(:cancel, method(:back_to_select))
- end
-
- #选人窗口按确定
- def select_advanced_ok
- @command_window.advanced_actor = @select_window.select_actor
- @select_window.deactivate
- @command_window.refresh
- @command_window.activate
- end
- #选人窗口按取消
- def select_advanced_cancel
- @command_window.advanced_actor = nil
- SceneManager.return
- end
- #进阶窗口按确定
- def advanced
- @command_window.do_advanced
- SceneManager.return
- end
- #进阶窗口按取消
- def back_to_select
- @command_window.del_test_advanced_actor if @command_window.test_advanced_actor
- @command_window.clear
- @command_window.deactivate
- @select_window.refresh
- @select_window.activate
- end
- end
- #--------------------------------------------------------------------------
- # 选择窗口
- #--------------------------------------------------------------------------
- class Window_AdvancedSelect < Window_HorzCommand
- def initialize
- super(0,0)
- @data = []
- @last_index ||= 0
- @animtime = 0
- [url=home.php?mod=space&uid=348285]@walk[/url] = 0
- refresh
- select_last
- end
-
- def window_width;Graphics.width;end
- def window_height;115;end
- def item_width;85;end
- def item_height; 85; end
- def spacing; return 1; end
- def col_max; return 6; end
- def item_max; @data ? @data.size : 1; end
- def select_actor; @data && index >= 0 ? @data[index] : nil; end
-
- def current_item_enabled?
- enable?(@data[index])
- end
- def enable?(actor)
- return false if !actor
- return true
- end
-
- def include?(actor)
- return false if actor.nil?
- return true
- end
-
- def make_item_list
- @data = $game_party.members.select {|actor| include?(actor) }
- @data.push(nil) if include?(nil)
- end
-
- def select_last
- select(@data.index($select_advanced) || 0)
- end
-
- def actor_rect(index)
- rect = Rect.new
- rect.width = item_width
- rect.height = item_height
- rect.x = index * (item_width + spacing)
- rect.y = 0
- rect
- end
-
- def draw_item(index)
- actor = @data[index]
- if actor
- rect = actor_rect(index)
- rect.width -= 4
- draw_actor_text(actor,rect.x + 2,rect.y, enable?(actor),
- rect.width)
- draw_character(actor.character_name, actor.character_index,
- rect.x + item_width / 1.6 - 1, rect.y + 38,
- enable?(actor),index)
- end
- end
-
- def draw_actor_text(actor, x, y, enabled = true, w)
- return unless actor
- change_color(normal_color, enabled)
- contents.font.size = 15
- draw_text(x + 4, y, w, 15, Vocab::level_a + actor.level.to_s,0)
- draw_text(x, y + 50, w, 15, actor.name,1)
- draw_text(x, y + 65, w, 15, actor.class.name,1)
- end
-
- def draw_character(character_name, character_index, x, y,enabled,i)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('这个是宠物进阶的脚本。。说实话,脚本好多啊
- )
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- step = 0
- step = @walk if enabled && i == index
- src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
- contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? 255 : 150)
- end
-
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
-
- def update
- super
- update_walk
- redraw_item(index)
- end
-
- def update_walk
- @animtime += 1
- if @animtime == 10
- case @walk
- when 1; @walk -= 1
- when -1; @walk += 1
- when 0
- if [url=home.php?mod=space&uid=2129346]@step[/url] == 1
- @walk = -1; @step = 0
- else
- @walk = 1; @step = 1
- end
- end
- @animtime = 0
- end
- end
-
- def cursor_down(wrap = false); super; cursor_move_extras; end
- def cursor_up(wrap = false); super; cursor_move_extras; end
- def cursor_left(wrap = false); super; cursor_move_extras; end
- def cursor_right(wrap = false); super; cursor_move_extras; end
-
- def cursor_move_extras
- @walk = 0
- @animtime = 0
- redraw_item(@last_index)
- @last_index = index
- end
-
- def process_ok
- if current_item_enabled?
- psound
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
-
- def psound
- if @psound.nil?
- Sound.play_ok
- else
- name,vol,pitch = @psound
- RPG::SE.new(name,vol,pitch).play
- @psound = nil
- end
- end
- end
- #--------------------------------------------------------------------------
- # 命令窗口
- #--------------------------------------------------------------------------
- class Window_AdvancedCommand < Window_Command
- attr_accessor :advanced_actor #进阶前的人物
- attr_accessor :test_advanced_actor #进阶后的人物
- attr_accessor :advanced_item #进阶所需物品
- def initialize
- super(0,115)
- @advanced_actor = nil
- @test_advanced_actor = nil
- @advanced_item = nil
- end
-
- def window_width;Graphics.width;end
- def window_height;Graphics.height - 115;end
- def item_width;120;end
- def row_max;return 4;end
-
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- clear
- clear_command_list
- make_command_list
- create_contents
- super
- draw_advanced_actor_status if @advanced_actor
- end
- def cursor_down(wrap = false); super;refresh;end
- def cursor_up(wrap = false); super;refresh;end
- def cursor_left(wrap = false); super;refresh;end
- def cursor_right(wrap = false); super;refresh;end
- #--------------------------------------------------------------------------
- # ● 生成指令列表
- #--------------------------------------------------------------------------
- def make_command_list
- return if @advanced_actor == nil
- add_command("取消",:cancel)
- Advanced.get_advanced_id(@advanced_actor).each {|i|
- text = "进阶成" + $data_actors[i[0].to_i].name
- handle = ":id"+i[0].to_s+"type"+i[1].to_s+"item"+i[2].to_s
- add_command(text,handle,check_enabled(i))
- }
- end
- #--------------------------------------------------------------------------
- # ● 是否可以确定命令
- #--------------------------------------------------------------------------
- def check_enabled(condition)
- return false if condition[0].to_i == 0
- return false if condition[0].to_i == @advanced_actor.id
- case condition[1]
- when "lv"
- return true if @advanced_actor.level >= condition[2].to_i
- when "w"
- if $game_party.weapons.include?($data_weapons[condition[2].to_i])
- if Advanced::CONDITION
- return true if @advanced_actor.level >= @advanced_actor.max_level
- else
- return true
- end
- end
- when "a"
- if $game_party.armors.include?($data_armors[condition[2].to_i])
- if Advanced::CONDITION
- return true if @advanced_actor.level >= @advanced_actor.max_level
- else
- return true
- end
- end
- when "i"
- if $game_party.items.include?($data_items[condition[2].to_i])
- if Advanced::CONDITION
- return true if @advanced_actor.level >= @advanced_actor.max_level
- else
- return true
- end
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 绘制命令框
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new
- rect.width = item_width
- rect.height = item_height
- rect.x = (window_width - item_width) / 2 - 22
- rect.y = item_height * index + 35
- return rect
- end
- #--------------------------------------------------------------------------
- # ● 绘制项目
- #--------------------------------------------------------------------------
- def draw_item(index)
- change_color(normal_color, command_enabled?(index))
- contents.font.size = 15
- draw_text(item_rect_for_text(index), command_name(index), 1)
- end
- #--------------------------------------------------------------------------
- # ● 清空
- #--------------------------------------------------------------------------
- def clear
- contents.clear
- end
- #--------------------------------------------------------------------------
- #寻找空位
- #--------------------------------------------------------------------------
- def get_nil_actorid
- for i in 1..$data_actors.size
- return i if $data_actors[i] == nil
- end
- end
- #--------------------------------------------------------------------------
- #模拟生成进阶后的人物
- #--------------------------------------------------------------------------
- def creat_test_advanced_actor
- case current_symbol
- when ":cancel"
- when /:id(\d+)type(lv|i|w|a)item(\d+)/i
- actor_id = $1.to_i
- new_id = get_nil_actorid
- $data_actors[new_id] = $data_actors[actor_id]
- $game_actors[new_id].setup(new_id)
- @test_advanced_actor = $game_actors[new_id]
- @test_advanced_actor.set_pet_by(false)
- @test_advanced_actor.set_pet_by(true) if @advanced_actor.is_pet_by?
- @test_advanced_actor.nickname = ""
- @test_advanced_actor.nickname = "变异" if @advanced_actor.is_pet_by?
- @test_advanced_actor.set_pet_up_param(get_newpet_up_param(@advanced_actor)) if @test_advanced_actor.is_pet?
- @advanced_actor.skills.each {|i| @test_advanced_actor.learn_skill(i.id)}
- case $2.to_s
- when "lv"
- @advanced_item = $3.to_i
- when "i"
- @advanced_item = $data_items[$3.to_i]
- when "w"
- @advanced_item = $data_weapons[$3.to_i]
- when "a"
- @advanced_item = $data_armors[$3.to_i]
- else
- end
- end
- end
- #计算进阶后的宠物的成长
- def get_newpet_up_param(pet)
- ren = [0] * 8
- newpetid = @test_advanced_actor.get_pet_id
- 8.times {|i|
- oldpi = pet.get_pet_oneup_param(i)
- oldpa = Tan_pet_set::Tan_pet_base_param[pet.get_pet_id][i] + Tan_pet_set::Tan_pet_rand_param[pet.get_pet_id][i]
- newpa = Tan_pet_set::Tan_pet_base_param[newpetid][i] + Tan_pet_set::Tan_pet_rand_param[newpetid][i]
- ren[i] = format("%.2f",oldpi / oldpa * newpa).to_f
- }
- return ren
- end
- #--------------------------------------------------------------------------
- #删除模拟生成的人物
- #--------------------------------------------------------------------------
- def del_test_advanced_actor
- $data_actors[@test_advanced_actor.id] = nil
- @test_advanced_actor = nil
- @advanced_item = nil
- end
- #--------------------------------------------------------------------------
- #绘制进阶人物信息
- #--------------------------------------------------------------------------
- def draw_advanced_actor_status
- del_test_advanced_actor if @test_advanced_actor
- draw_actor_number(@advanced_actor, 0, 0)
- creat_test_advanced_actor
- draw_actor_number(@test_advanced_actor, Graphics.width - 220, 0)
- if @advanced_item.is_a?(Integer)
- draw_text(190,0,140,15,"进阶条件:")
- draw_text(190,18,140,15,"lv#{@advanced_item}以上")
- elsif @advanced_item != nil
- if Advanced::CONDITION
- draw_text(190,0,140,15,"进阶条件:")
- draw_text(190,18,140,15,"满级且拥有#{@advanced_item.name}")
- else
- draw_text(190,0,140,15,"进阶条件:")
- draw_text(190,18,140,15,"拥有#{@advanced_item.name}")
- end
- else
- end
- end
- #--------------------------------------------------------------------------
- #绘制信息
- #--------------------------------------------------------------------------
- def draw_actor_number(actor, x, y)
- return if actor == nil
- draw_actor_face(actor, x, y)
- draw_actor_name(actor, x + 115, y)
- draw_actor_class(actor, x + 115, y + 20)
- draw_actor_nickname(actor, x + 115, y + 40)
- draw_actor_level(actor, x + 115, y + 60)
- contents.font.size = 18
- 8.times {|i|
- change_color(system_color)
- draw_text(x, y + 105 + 20 * i, 60, 18, Vocab::param(i))
- change_color(normal_color)
- draw_text(x + 25, y + 105 + 20 * i, 60, 18, actor.param(i), 2)
- draw_text(x + 95, y + 105 + 20 * i, 60, 18, actor.get_pet_oneup_param(i), 2) if actor.is_pet?
- draw_text(x + 155, y + 105 + 20 * i, 20,18,"↑") if actor.is_pet?
- }
- contents.font.size = 15
- end
- #--------------------------------------------------------------------------
- #确定进阶
- #--------------------------------------------------------------------------
- def do_advanced
- $game_party.tan_remove_actor(@advanced_actor.id)
- $game_party.tan_add_actor(@test_advanced_actor.id)
- $game_party.gain_item(@advanced_item, -1) if !@advanced_item.is_a?(Integer) && @advanced_item != nil
- end
- end
复制代码 这个是宠物进阶的脚本。。说实话,脚本好多啊
|
|