Project1
标题:
请问有没有类似这个物品分类的技能分类脚本
[打印本页]
作者:
苍穹之罚
时间:
2015-2-22 23:38
标题:
请问有没有类似这个物品分类的技能分类脚本
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
module RPG
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
end
class Harts_Window_ItemTitle < Window_Base
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, Vocab::item, 1)
end
end
class Harts_Window_ItemCommand < Window_Selectable
attr_accessor :commands
def initialize
super(0, 64, 160, 296)
self.index = 0
refresh
end
def addcommand
@commands = []
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0
push = true
for com in @commands
if com == $data_items[i].desc
push = false
end
end
if push == true
@commands.push($data_items[i].desc)
end
end
end
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0
push = true
for com in @commands
if com == $data_weapons[i].desc
push = false
end
end
if push == true
@commands.push($data_weapons[i].desc)
end
end
end
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0
push = true
for com in @commands
if com == $data_armors[i].desc
push = false
end
end
if push == true
@commands.push($data_armors[i].desc)
end
end
end
if @commands == []
@commands.push("普通物品")
end
@item_max = @commands.size
end
def refresh
addcommand
create_contents
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
y = index * WLH
self.contents.font.color = color
if @commands[index] != nil
self.contents.draw_text(4,y, 172, WLH, @commands[index])
end
end
def update_help
@help_window.set_text(@commands[self.index])
end
end
class Harts_Window_ItemList < Window_Selectable
def initialize
super(160, 0, 384, 360)
self.index = 0
refresh
end
def item
return @data[self.index]
end
def refresh
@data = []
end
def set_item(command)
refresh
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0 and $data_items[i].desc == command
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0 and $data_weapons[i].desc == command
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0 and $data_armors[i].desc == command
@data.push($data_armors[i])
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
def item_number
return @item_max
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = $game_party.item_can_use?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Harts_Window_Help < Window_Base
def initialize
super(0, 360, 544, WLH + 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, WLH , text, align)
@text = text
@align = align
end
end
end
class Harts_Window_MenuStatus < Window_Selectable
def initialize(x, y)
super(x, y, 288, 416)
refresh
self.active = false
self.index = -1
end
def refresh
self.contents.clear
@item_max = $game_party.members.size
for actor in $game_party.members
x = 8
y = actor.index * 96 + WLH / 2
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 120, y)
draw_actor_level(actor, x, y + WLH * 1)
draw_actor_state(actor, x, y + WLH * 2)
draw_actor_hp(actor, x + 120, y + WLH * 1)
draw_actor_mp(actor, x + 120, y + WLH * 2)
end
end
def update_cursor
if @index < 0
self.cursor_rect.empty
elsif @index < @item_max
self.cursor_rect.set(0, @index * 96, contents.width, 96)
elsif @index >= 100
self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
else
self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
end
end
end
class Scene_Item < Scene_Base
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@itemtitle_window = Harts_Window_ItemTitle.new
@itemcommand_window = Harts_Window_ItemCommand.new
@command_index = @itemcommand_window.index
@itemcommand_window.refresh
@itemlist_window = Harts_Window_ItemList.new
@itemlist_window.active = false
@help_window = Harts_Window_Help.new
@help_window.viewport = @viewport
@target_window = Harts_Window_MenuStatus.new(96, 0)
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
hide_target_window
end
def terminate
super
dispose_menu_background
@viewport.dispose
@itemtitle_window.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@help_window.dispose
@target_window.dispose
end
def return_scene
$scene = Scene_Menu.new(0)
end
def update
super
update_menu_background
@help_window.update
@itemlist_window.update
@itemcommand_window.update
@target_window.update
@itemcommand_window.refresh
if @command_index != @itemcommand_window.index
@itemlist_window.index = 0
@command_index = @itemcommand_window.index
@itemcommand_window.update_help
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
if @itemcommand_window.active
@itemcommand_window.update_help
update_itemcommand
elsif @itemlist_window.active
update_itemlist
elsif @target_window.active
update_target_selection
end
end
def update_itemcommand
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
return
end
if Input.trigger?(Input::C)
if @itemlist_window.item_number == 0
Sound.play_buzzer
return
end
Sound.play_decision
@itemcommand_window.active = false
@itemlist_window.index = 0
@itemlist_window.active = true
return
end
end
def update_itemlist
if Input.trigger?(Input::B)
Sound.play_cancel
@itemcommand_window.active = true
@itemlist_window.active = false
@itemcommand_window.index = @command_index
elsif Input.trigger?(Input::C)
@item = @itemlist_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
end
end
def determine_item
if @item.for_friend?
show_target_window(@itemlist_window.index % 2 == 0)
if @item.for_all?
@target_window.index = 99
else
if $game_party.last_target_index < @target_window.item_max
@target_window.index = $game_party.last_target_index
else
@target_window.index = 0
end
end
else
use_item_nontarget
end
end
def update_target_selection
if Input.trigger?(Input::B)
Sound.play_cancel
if $game_party.item_number(@item) == 0
@itemlist_window.refresh
end
@itemlist_window.active = true
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
hide_target_window
@itemlist_window.active = true
elsif Input.trigger?(Input::C)
if not $game_party.item_can_use?(@item)
Sound.play_buzzer
else
determine_target
end
end
end
def determine_target
used = false
if @item.for_all?
for target in $game_party.members
target.item_effect(target, @item)
used = true unless target.skipped
end
else
$game_party.last_target_index = @target_window.index
target = $game_party.members[@target_window.index]
target.item_effect(target, @item)
used = true unless target.skipped
end
if used
use_item_nontarget
else
Sound.play_buzzer
end
end
def show_target_window(right)
@itemlist_window.active = false
width_remain = 544 - @target_window.width
@target_window.x = right ? width_remain : 0
@target_window.visible = true
@target_window.active = true
if right
@viewport.rect.set(0, 0, width_remain, 416)
@viewport.ox = 0
else
@viewport.rect.set(@target_window.width, 0, width_remain, 416)
@viewport.ox = @target_window.width
end
end
def hide_target_window
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
@viewport.rect.set(0, 0, 544, 416)
@viewport.ox = 0
end
def use_item_nontarget
Sound.play_use_item
$game_party.consume_item(@item)
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
elsif @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
ヾ(´ε`ヾ)
作者:
苍穹之罚
时间:
2015-2-23 15:31
゚(つд`゚)
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1