Project1
标题:
[微小创新]物品分类+自定义颜色+自定义品质
[打印本页]
作者:
恐惧剑刃
时间:
2013-9-20 01:31
标题:
[微小创新]物品分类+自定义颜色+自定义品质
本帖最后由 恐惧剑刃 于 2014-10-12 19:15 编辑
新人脚本极不推荐!!!!!差不多可以删贴了
# -----------------------------------------------------------------------------
# Item_Menu
# -----------------------------------------------------------------------------
# 1.物品分类(菜单、战斗双项分类。在名称后使用“,”直接追加分类)
# 2.物品颜色(在说明后用“@”定义,使用的是text_color所以@后的数字不要超过7)
# 3.物品品质(在物品颜色后用“@”定义,低、中或高。)
# 4.简洁说明(附加、解除状态,恢复HP、SP等,直接在window中简单显示。)
# 5.DEBUG (满物品、满装备)
# 6.冲突可能:未知
# -----------------------------------------------------------------------------
# PS 此脚本重定义了N多方法,注意要修改相关内容的话,请从这里修改,
# 请按说明,给全部物品定义分类、颜色和品质,如果不这样可能要出错!
# -----------只要按上方说明的做,脚本不会报错(除冲突)!
#==============================================================================
# Window_Base
class Window_Base < Window
alias initialize_old_blkk_old initialize
def initialize(x, y, width, height)
initialize_old_blkk_old(x, y, width, height)
if $scene.is_a?(Scene_Item)
self.opacity = 200
end
end
end
#==============================================================================
# Scene_Item
class Scene_Item
alias main_main_old_blkk main
def main
map_spriteset = Spriteset_Map.new
main_main_old_blkk
map_spriteset.dispose
end
end
#==============================================================================
# Scene_Title
class Scene_Title
alias command_new_game_blkk_old command_new_game
def command_new_game
command_new_game_blkk_old
#——DEBUG is true?
debug_true = true# false ?
#———DEBUG
if $-d and debug_true
for i in 1...$data_items.size
$game_party.gain_item(i,i * 2)
end
for i in 1...$data_weapons.size
$game_party.gain_weapon(i,i * 2)
end
for i in 1...$data_armors.size
$game_party.gain_armor(i,i * 2)
end
end
end
end
#==============================================================================
# Scene_Battle
class Scene_Battle
alias main_blkk_old_main main
#--------------------------------------------------------------------------
# main
def main
main_blkk_old_main
if @item_window != nil
@item_window.dispose
end
end
#--------------------------------------------------------------------------
# update_phase3
def update_phase3
if @enemy_arrow != nil
update_phase3_enemy_select
elsif @actor_arrow != nil
update_phase3_actor_select
elsif @skill_window != nil
update_phase3_skill_select
elsif @item_window != nil and @command_item != nil
update_phase3_item_select
elsif @actor_command_window.active
update_phase3_basic_command
end
end
#--------------------------------------------------------------------------
# start_item_select
def start_item_select
@data = ["全部物品"]
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and $data_items[i].name_plus != "" and
$data_items[i].occasion != 3 and $data_items[i].occasion != 2
kind = $data_items[i].name_plus
@data.push($data_items[i].name_plus) unless @data.include?(kind)
end
end
@data.push("战斗中")
@command_item = Window_Command.new(132, @data)
@command_item.opacity = 160
@item_window = Window_Item.new
@item_window.active = false
@item_window.index = -1
@item_window.help_window = @help_window
@command_item.help_window = @help_window
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# update_phase3_item_select
def update_phase3_item_select
if @old_index != @command_item.index
$data_name_battle = @data[@command_item.index] if @command_item.index >= 0
@item_window.refresh
@old_index = @command_item.index
end
@item_window.visible = true
@command_item.visible = true
@item_window.update
@command_item.update
if @command_item.active
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_item.visible = false
end_item_select
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@item_window.index = 0
@item_window.active = true
@command_item.active = false
end
elsif @item_window.active
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@item_window.active = false
@item_window.index = -1
@command_item.active = true
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.item_id = @item.id
@item_window.visible = false
@command_item.visible = false
if @item.scope == 1
start_enemy_select
elsif @item.scope == 3 or @item.scope == 5
start_actor_select
else
end_item_select
phase3_next_actor
end
return
end
end
end
#--------------------------------------------------------------------------
# update_phase3_actor_select
def update_phase3_actor_select
@actor_arrow.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
end_actor_select
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.target_index = @actor_arrow.index
end_actor_select
if @skill_window != nil
end_skill_select
end
if @item_window != nil and @command_item != nil
end_item_select
end
phase3_next_actor
end
end
#--------------------------------------------------------------------------
# end_item_select
alias end_item_select_old_blkk end_item_select
def end_item_select
@command_item.dispose
end_item_select_old_blkk
@command_item = nil
end
end
#==============================================================================
# Window_Item
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# initialize
def initialize
super(0, 64, 640, 416)
@column_max = 1
refresh
self.index = 0
if $game_temp.in_battle
self.x = 132
self.y = 64
self.height = 256
self.width = 640 - 132
self.opacity = 160
end
end
#--------------------------------------------------------------------------
# refresh
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if $game_temp.in_battle and $data_name_battle != "全部物品"
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].occasion != 3 and $data_items[i].occasion != 2 and
$data_name_battle == $data_items[i].name_plus
@data.push($data_items[i])
end
end
elsif $data_name == "全部物品" and $game_temp.in_battle == false
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
elsif $data_name_battle == "全部物品" and $game_temp.in_battle
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].occasion != 3 and $data_items[i].occasion != 2
@data.push($data_items[i])
end
end
end
unless $data_name == "全部物品" and $game_temp.in_battle
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i]) if $data_name == $data_items[i].name_plus
end
end
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i]) if $data_name == $data_weapons[i].name_plus
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i]) if $data_name == $data_armors[i].name_plus
end
end
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
#--------------------------------------------------------------------------
# draw_item
def draw_item(index)
item = @data[index]
$item = item
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
self.contents.font.color = normal_color
x = 4 + index % 1 * (225 + 32)
ax = x
y = index / @column_max * 32
rect = Rect.new(x, y, self.width / @column_max - 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.font.size = 15
cx = contents.text_size("持有数 ×").width
self.contents.draw_text(x + 126, y, cx, 32, "持有数 ×", 1)
case number
when 1 .. 5
self.contents.font.color = text_color(2)
when 6 .. 10
self.contents.font.color = text_color(5)
when 11 .. 30
self.contents.font.color = text_color(6)
when 30 .. 99
self.contents.font.color = text_color(3)
end
self.contents.draw_text(x + 126 + cx, y, 24, 32, number.to_s, 2)
if item.description_plus != "" and item.description_plus.to_i <= 7 and
item.description_plus.to_i >= 0
self.contents.font.color = text_color(item.description_plus.to_i)
else
self.contents.font.color = text_color(0)
end
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
if item.is_a?(RPG::Item)
self.contents.font.color = text_color(3)
re_hp = item.recover_hp
re_hp_rate = item.recover_hp_rate
re_sp = item.recover_sp
re_sp_rate = item.recover_sp_rate
if re_hp > 0 or re_hp_rate > 0 or re_sp > 0 or re_sp_rate > 0 and
item.minus_state_set != []
self.contents.draw_text(x + 266, y, width - 8, 32, "[复活]")
elsif re_hp > 0 or re_hp_rate > 0 or re_sp > 0 or re_sp_rate > 0
self.contents.draw_text(x + 266, y, width - 8, 32, "[恢复]")
recover =
[re_hp, re_hp_rate, re_sp, re_hp_rate].max
case recover
when 0 .. 100
self.contents.font.color = text_color(2)
when 101 .. 500
self.contents.font.color = text_color(5)
when 501 .. 1000
self.contents.font.color = text_color(6)
when 1001 .. 3000
self.contents.font.color = text_color(4)
when 3001 .. 9999
self.contents.font.color = text_color(3)
end
self.contents.draw_text(x + 326, y, width - 8, 32, recover.to_s)
elsif re_hp < 0 or re_hp_rate < 0
self.contents.draw_text(x + 266, y, width - 8, 32, "[暗器]")
recover = re_hp.abs
case recover
when 0 .. 100
self.contents.font.color = text_color(2)
when 101 .. 500
self.contents.font.color = text_color(5)
when 501 .. 1000
self.contents.font.color = text_color(6)
when 1001 .. 3000
self.contents.font.color = text_color(4)
when 3001 .. 9999
self.contents.font.color = text_color(3)
end
self.contents.draw_text(x + 326, y, width - 8, 32, recover.to_s)
elsif item.minus_state_set != []
self.contents.draw_text(x + 266, y, width - 8, 32, "[状态-]")
elsif item.plus_state_set != []
self.contents.draw_text(x + 266, y, width - 8, 32, "[状态+]")
end
self.contents.font.color = text_color(3)
self.contents.draw_text(x+390, y, width-8, 32, "[品质]") if item.occasion != 3
case item.description_plus_2
when "低"
self.contents.font.color = text_color(2)
when "中"
self.contents.font.color = text_color(6)
when "高"
self.contents.font.color = text_color(4)
end
if item.occasion != 3
self.contents.draw_text(x + 450, y, width - 8, 32, item.description_plus_2)
end
end
if item.is_a?(RPG::Item) and item.parameter_points > 0
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 266, y, width - 8, 32, "[能力+]")
self.contents.font.color = text_color(4)
self.contents.draw_text(ax + 326, y, 182, 32, item.parameter_points.to_s)
end
if item.is_a?(RPG::Item) and
(item.plus_state_set != [] or item.minus_state_set != [])
for i in item.plus_state_set
if i > 0
txt = $data_states[i].name
self.contents.font.color = text_color(5)
self.contents.draw_text(x + 326, y, 182, 32, txt)
end
end
for i in item.minus_state_set
if i > 0
txt = $data_states[i].name
self.contents.font.color = text_color(3)
self.contents.draw_text(ax + 326, y, 182, 32, txt)
ax += 500
end
end
end
if item.is_a?(RPG::Weapon)
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 266, y, width - 8, 32, "[武器]")
self.contents.font.color = text_color(4)
self.contents.draw_text(ax + 326, y, 182, 32, "atk:" << item.atk.to_s)
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 390, y, width - 8, 32, "[品质]")
case item.description_plus_2
when "低"
self.contents.font.color = text_color(2)
when "中"
self.contents.font.color = text_color(6)
when "高"
self.contents.font.color = text_color(4)
end
self.contents.draw_text(x + 450, y, width - 8, 32, item.description_plus_2)
end
if item.is_a?(RPG::Armor)
self.contents.font.color = text_color(3)
unless item.pdef == 0 and item.mdef == 0
self.contents.draw_text(x + 266, y, width - 8, 32, "[护具]")
self.contents.font.color = text_color(4)
self.contents.draw_text(ax + 326, y, 182, 32, "pdef:" << item.pdef.to_s +
" " << "mdef:" << item.mdef.to_s)
else
self.contents.draw_text(x + 266, y, width - 8, 32, "[饰品]")
num1 = item.str_plus
num2 = item.dex_plus
num3 = item.agi_plus
num4 = item.int_plus
num_max = [num1, num2, num3, num4].max
self.contents.font.color = text_color(4)
self.contents.draw_text(ax + 326, y, 182, 32, num_max.to_s)
end
self.contents.font.color = text_color(3)
if item.is_a?(RPG::Armor) and item.pdef == 0 and item.mdef == 0
cx = x - 120
else
cx = x
end
self.contents.draw_text(cx + 480, y, width - 8, 32, "[品质]")
case item.description_plus_2
when "低"
self.contents.font.color = text_color(2)
when "中"
self.contents.font.color = text_color(6)
when "高"
self.contents.font.color = text_color(4)
end
self.contents.draw_text(cx + 540, y, width - 8, 32, item.description_plus_2)
end
if item.is_a?(RPG::Item) and item.occasion == 3
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 266, y, width - 8, 32, "[剧情任务]")
self.contents.font.color = text_color(4)
self.contents.draw_text(ax + 356, y, 182, 32, "这是" << item.name.to_s)
end
end
end
#==============================================================================
# Window_Command
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# initialize
def initialize(width, commands)
if commands.include?(nil)
super(0, 0, width, 6 * 32 + 32)
new_commands = commands.compact
else
if commands.include?("战斗中")
if commands.size * 32 + 32 > 256
super(0, 64, width, 256)
else
super(0, 64, width, (commands.size - 1) * 32 + 32)
end
new_commands = commands
$battle = new_commands
else
super(0, 0, width, commands.size * 32 + 32)
new_commands = commands
end
end
if new_commands.include?("战斗中")
@item_max = new_commands.size - 1
else
@item_max = new_commands.size
end
@commands = new_commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# update_help
def update_help
@help_window.set_text("[系统]" + @commands[self.index])
end
end
#==============================================================================
# module RPG
module RPG
class Item
def name
name = @name.split(/,/)[0]
return name != nil ? name : ""
end
def name_plus
name_plus = @name.split(/,/)[1]
return name_plus != nil ? name_plus : ""
end
def description
description = @description.split(/@/)[0]
return description != nil ? description : ""
end
def description_plus
description_plus = @description.split(/@/)[1]
return description_plus != nil ? description_plus : ""
end
def description_plus_2
description_plus_2 = @description.split(/@/)[2]
return description_plus_2 != nil ? description_plus_2 : "请定义品质"
end
end
class Weapon
def name
name = @name.split(/,/)[0]
return name != nil ? name : ""
end
def name_plus
name_plus = @name.split(/,/)[1]
return name_plus != nil ? name_plus : ""
end
def description
description = @description.split(/@/)[0]
return description != nil ? description : ""
end
def description_plus
description_plus = @description.split(/@/)[1]
return description_plus != nil ? description_plus : ""
end
def description_plus_2
description_plus_2 = @description.split(/@/)[2]
return description_plus_2 != nil ? description_plus_2 : "请定义品质"
end
end
class Armor
def name
name = @name.split(/,/)[0]
return name != nil ? name : ""
end
def name_plus
name_plus = @name.split(/,/)[1]
return name_plus != nil ? name_plus : ""
end
def description
description = @description.split(/@/)[0]
return description != nil ? description : ""
end
def description_plus
description_plus = @description.split(/@/)[1]
return description_plus != nil ? description_plus : ""
end
def description_plus_2
description_plus_2 = @description.split(/@/)[2]
return description_plus_2 != nil ? description_plus_2 : "请定义品质"
end
end
end
#==============================================================================
# Scene_Menu
class Scene_Menu
#--------------------------------------------------------------------------
# initialize
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# main
def main
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "存档"
s6 = "结束游戏"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
@data = ["全部物品"]
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and $data_items[i].name_plus != ""
kind = $data_items[i].name_plus
@data.push($data_items[i].name_plus) unless @data.include?(kind)
end
end
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and $data_weapons[i].name_plus != ""
kind = $data_weapons[i].name_plus
@data.push($data_weapons[i].name_plus) unless @data.include?(kind)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and $data_armors[i].name_plus != ""
kind = $data_armors[i].name_plus
@data.push($data_armors[i].name_plus) unless @data.include?(kind)
end
end
end
if @data.size > 6
@data.push(nil)
@data_2 = @data.compact
else
@data_2 = @data
end
if @data.size > 6 then @data_2 = @data.compact else @data_2 = @data end
@item_command = Window_Command.new(132, @data)
@item_command.x = 160;@item_command.z = 160
@item_command.opacity = 160
@item_command.active = false
@item_command.visible = false
@item_command.index = -1
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
if $game_system.save_disabled
@command_window.disable_item(4)
end
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
@item_command.dispose
end
#----------------------------------------------------------------------------
# update
def update
@item_command.update
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
if @item_command.active
item_command
return
end
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
#----------------------------------------------------------------------------
# item_command
def item_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@item_command.index = -1
@item_command.active = false
@item_command.visible = false
@command_window.active = true
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$data_name = @data_2[@item_command.index]
$scene = Scene_Item.new
end
end
#----------------------------------------------------------------------------
# update_command
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@item_command.index = 0
@item_command.active = true
@item_command.visible = true
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
end
return
end
end
end
复制代码
作者:
kuerlulu
时间:
2013-9-20 09:18
一看就是做大游戏(
眼花缭乱类
)的产物
作者:
罪恶ぺ殇痕
时间:
2014-2-17 10:49
你好楼主,我下载了你的测试工程,然后从脚本页复制到自己的游戏中,但是所有的物品分类的品质全都清空了。
请问要怎样设置品质和分类?
作者:
云岚宗口云屌
时间:
2014-10-11 13:29
罪恶ぺ殇痕 发表于 2014-2-17 10:49
你好楼主,我下载了你的测试工程,然后从脚本页复制到自己的游戏中,但是所有的物品分类的品质全都清空了。 ...
1.物品分类(菜单、战斗双项分类。在名称后使用“,”直接追加分类)
2.物品颜色(在说明后用“@”定义,使用的是text_color所以@后的数字不要超过7)
3.物品品质(在物品颜色后用“@”定义,低、中或高。)
4.简洁说明(附加、解除状态,恢复HP、SP等,直接在window中简单显示。)
以上是脚本里的原话。。那个,物品分类是直接在物品名称后面加的,不需要改动脚本( ゚ω゚)
希望对你有帮助吧,好吧其实我就是菜鸟。。
作者:
邪月长啸
时间:
2014-10-13 18:57
额,恋大的作风就是只发脚本不上图的。。。。
支持下,抱走试试啥效果
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1