Project1
标题:
大佬们,Ace有没有装备镶嵌打孔脚本啊!
[打印本页]
作者:
qq1114905982
时间:
2021-12-18 03:04
标题:
大佬们,Ace有没有装备镶嵌打孔脚本啊!
大哥们,全部身家求能用的装备打孔镶嵌脚本啊!
作者:
骷髅岛遗老
时间:
2021-12-18 03:04
#==============================================================================#
# #*****************# #
# #*** By Falcao ***# * Falcao 宝石镶嵌系统 1.6 #
# #*****************# This script allows you to enchants, weapons and#
# armors in order to increa se the actor stats. #
# RMVXACE #
# Date: October 22 2012 #
# #
# Falcao RGSS site: http://falcaorgss.wordpress.com #
# Falcao Forum site: http://makerpalace.com #
#==============================================================================#
# 1.6 change log
# - Fixed crash when mana stones are destroyed before the socketing process
#
# 1.5 change log
# - Added new stand alone GUI
# - Fixed bug when you set the DefaultSockets to cero and unequipp a weapon/armo
# - Mana stones container expanded on more line
#-------------------------------------------------------------------------------
# * 安装
# 复制本脚本到main之上,没有对任何方法重命名,所宜兼容性是极好的。
#-------------------------------------------------------------------------------
# * 特点
# - 支持武器、防具镶嵌
# - 镶嵌槽数量任意设置
# - 通过镶嵌提升角色属性,已镶嵌的宝石可以被摘除
# - 在物品栏添加备注来设定其为可镶嵌的宝石
# - 有几率镶嵌失败
# - 镶嵌失败时宝石会被摧毁
# - 使用者友好的UI.
#
# 注释: 武器和防具默认是独一无二的。所以当有多个武器和防具使用同一个id且被镶嵌时,
# 宝石会全部镶嵌在它们上。
#-------------------------------------------------------------------------------
# * 使用方法
#
# 在装备窗口中按下A键来呼出镶嵌窗口,只有装备在角色身上的武器和防具才能进行镶嵌。
#
# 武器和防具备注栏:
# <镶嵌孔:x> - x为其镶嵌孔数量
#
# 物品备注栏: (带有以下备注的物品都会被视为可镶嵌的宝石)
# <提升体力:x>
# <提升魔力:x>
# <提升物攻:x>
# <提升物防:x> => x为提升数值
# <提升魔攻:x>
# <提升魔防:x>
# <提升敏捷:x>
# <提升幸运:x>
#
# <镶嵌几率:x> x为镶嵌成功的几率,设定范围为"0~100"(即代表0%~100%)
# 无此备注的镶嵌宝石则视为100%会被镶嵌成功
#-------------------------------------------------------------------------------
# * 使用执照
# 仅可用于非商业游戏, 对于商业游戏请联系我:
#
[email protected]
#-------------------------------------------------------------------------------
module FalMana
# 默认武器和防具的镶嵌孔数
DefaultSockets = 0
# 默认镶嵌成功几率
DefaultChance = 100
# 镶嵌中播放的音效
SoketingSe = "Heal6"
# 镶嵌成功时播放的音效
SocketSuccessSe = "Decision2"
# 镶嵌失败时播放的音效
SocketFailSe = "Down1"
# 摘除宝石时播放的音效
ClearSocketSe = "Equip3"
#-------------------------------------------------------------------------------
def self.stones(actor)
@actor = actor
SceneManager.call(Scene_ManaStones)
end
def self.actor ; @actor ; end
def self.socket_manastone(item, index, value, actor)
item.manaslots[index] = value
actor.add_param(value.manastone_param[0], value.manastone_param[1])
end
def self.remove_manastone(item, index, value, actor)
item.manaslots[index] = nil
actor.add_param(value.manastone_param[0], - value.manastone_param[1])
end
def self.clear_manastones(item, actor)
item.manaslots.each {|m| actor.add_param(m.manastone_param[0],
- m.manastone_param[1]) unless m.nil?}
item.manaslots.size.times {|i| item.manaslots[i] = nil}
end
def self.add_param(actor, item, sub=false)
return if item.nil?
return if item.manaslots.nil?
item.manaslots.each {|m| actor.add_param(m.manastone_param[0],
sub ? - m.manastone_param[1] : m.manastone_param[1]) unless m.nil?}
end
end
# Game system: Register mana stones values
class Game_System
attr_reader :weapon_slots, :armor_slots
alias falcaomana_slots_ini initialize
def initialize
@weapon_slots = {}
@armor_slots = {}
dataslots_ini(@weapon_slots, $data_weapons)
dataslots_ini(@armor_slots, $data_armors)
falcaomana_slots_ini
end
def dataslots_ini(operand, item)
for kind in item
next if kind.nil?
if kind.given_sl != nil
data = []
kind.given_sl.times {|i| data.push(nil)}
operand[kind.id] = data
end
end
end
end
# Scene_Equip: main mana stones socketing system
class Scene_Equip < Scene_MenuBase
def update
super
update_manacalling
end
def update_manacalling
update_enchant_help
if Input.trigger?(:X)
FalMana.stones(@actor)
Sound.play_ok
end
end
def update_enchant_help
@help_window.contents.font.size = Font.default_size
@help_window.refresh
@help_window.contents.font.size = 18
@help_window.draw_text(-22,22,@help_window.width,32, '按下 A 来进行镶嵌',2)
end
end
# RPG::EquipItem: get slots data for each weapon and armor
class RPG::EquipItem < RPG::BaseItem
def given_sl
@note =~ /<镶嵌孔:(.*)>/i ? n = $1.to_i : n = nil
n = FalMana::DefaultSockets if n.nil? and FalMana::DefaultSockets > 0
return n
end
def manaslots
self.is_a?(RPG::Weapon) ? i = $game_system.weapon_slots[self.id] :
i = $game_system.armor_slots[self.id]
return i
end
end
# RPG::Item: Mana stones item definition
class RPG::Item < RPG::UsableItem
def socket_chance
@note =~ /<镶嵌几率:(.*)>/i ? n = $1.to_i : n = FalMana::DefaultChance
return n
end
def manastone_param
param = [0, $1.to_i] if @note =~ /<提升体力:(.*)>/i
param = [1, $1.to_i] if @note =~ /<提升魔力:(.*)>/i
param = [2, $1.to_i] if @note =~ /<提升物攻:(.*)>/i
param = [3, $1.to_i] if @note =~ /<提升物防:(.*)>/i
param = [4, $1.to_i] if @note =~ /<提升魔攻:(.*)>/i
param = [5, $1.to_i] if @note =~ /<提升魔防:(.*)>/i
param = [6, $1.to_i] if @note =~ /<提升敏捷:(.*)>/i
param = [7, $1.to_i] if @note =~ /<提升幸运:(.*)>/i
return param
end
end
#-------------------------------------------------------------------------------
# Window mana slots
class Window_ItemSlots < Window_Selectable
def initialize(x=0, y=0, w=280, h=124)
super(x, y, w, h)
unselect
end
def item() return @data[self.index] end
def line_height() return 24 end
def spacing() return 6 end
def col_max() return 2 end
def refresh(object)
self.contents.clear if self.contents != nil
@data = []
return if object.manaslots.nil? rescue return
object.manaslots.each {|i| @data.push(i)}
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 26)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
x, y = index % col_max * (129), index / col_max * 24
self.contents.font.size = 18
self.contents.draw_text(x + 2, y - 2, 212, 32, '无', 0)
draw_icon(item.icon_index, x, y) rescue nil
param = Vocab.param(item.manastone_param[0]) rescue nil
value = item.manastone_param[1] rescue nil
self.contents.draw_text(x + 24,y,212,32, param + " +#{value}") rescue nil
end
def item_max
return @item_max.nil? ? 0 : @item_max
end
end
#-------------------------------------------------------------------------------
# Window mana stones
class Window_ManaStones < Window_Selectable
def initialize(x=0, y=124, w=280, h=148)
super(x, y, w, h)
refresh ; unselect
end
def item() return @data[self.index] end
def refresh
self.contents.clear if self.contents != nil
@data = []
for it in $data_items
next if it.nil?
@data.push(it) if $game_party.has_item?(it) and !it.manastone_param.nil?
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 26)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
x, y = index % col_max * (90), index / col_max * 24
self.contents.font.size = 18
draw_icon(item.icon_index, x, y)
param = Vocab.param(item.manastone_param[0])
value = item.manastone_param[1]
number = $game_party.item_number(item)
contents.draw_text(x + 24,y,212,32, item.name + " #{param} +#{value}")
contents.draw_text(x -30, y, self.width, 32, ':' + number.to_s, 2)
end
def item_max
return @item_max.nil? ? 0 : @item_max
end
end
class Game_Actor < Game_Battler
alias falcaomanastones_change change_equip
def change_equip(slot_id, item)
FalMana.add_param(self, @equips[slot_id].object, true)
FalMana.add_param(self, item)
falcaomanastones_change(slot_id, item)
end
end
#-------------------------------------------------------------------------------
# Window actor equipped
class Window_Equippedwa < Window_Selectable
def initialize(x=0, y=124)
super(x, y, 190, 148)
refresh(FalMana.actor) ; activate ; select(0)
end
def item() return @data[self.index] end
def refresh(actor)
self.contents.clear if self.contents != nil
@data = []
actor.equips.each {|equips| @data.push(equips) if !equips.nil?}
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 26)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
x, y = index % col_max * (90), index / col_max * 24
self.contents.font.size = 18
draw_icon(item.icon_index, x, y)
contents.draw_text(x + 24,y,212,32, item.name)
end
def item_max
return @item_max.nil? ? 0 : @item_max
end
end
# Scene mana stones
class Scene_ManaStones < Scene_MenuBase
def start
super
w = Graphics.width ; h = Graphics.height ; @actor = FalMana.actor
@slot_window = Window_Equippedwa.new(w/2 - 190/2 - 137, h/2 - 148/2 - 106)
@param_window = Window_Base.new(@slot_window.x,@slot_window.y + 148,190,214)
refresh_param
@socket_window = Window_Base.new(w/2 - 280/2 + 97,h/2 - 90/2 - 136, 280, 90)
@col = [Color.new(180, 225, 245), Color.new(20, 160, 225), Color.new(0,0,0)]
@itemslots = Window_ItemSlots.new(@socket_window.x, @socket_window.y + 90)
@manastones = Window_ManaStones.new(@itemslots.x, @itemslots.y + 124)
@result = '' ; @meter = 0
update_indexes
end
def refresh_param
@param_window.contents.clear
@param_window.contents.font.size = 18
@param_window.contents.font.color = @param_window.normal_color
@param_window.contents.fill_rect(0, 0, 190, 44, Color.new(0, 0, 0, 60))
@param_window.draw_character(@actor.character_name,
@actor.character_index, 20, 42)
@param_window.draw_text(50, -6, 190, 32, @actor.name)
@param_window.draw_text(50, 18, 190, 32, '装备')
y = 0
for i in 0...8
y += 17
@param_window.contents.font.color = @param_window.normal_color
@param_window.draw_text(0, y + 28, 190, 32, Vocab.param(i))
@param_window.contents.font.color = @param_window.system_color
@param_window.draw_text(70, y + 28, 190, 32, "=> #{@actor.param(i)}")
end
end
def refresh_socketing
@socket_window.contents.clear
@socket_window.contents.font.size = 18
if @slot_window.item.nil? || @slot_window.item.manaslots.nil?
@socket_window.draw_text(-16, 0, 280, 32, '无镶嵌孔', 1)
return
end
@socket_window.draw_icon(@slot_window.item.icon_index, 0, 0)
@socket_window.draw_text(26, 0, @socket_window.width, 32,
@slot_window.item.name + "的镶嵌孔数: #{@slot_window.item.manaslots.size}")
@socket_window.draw_text(-20, 44, 280, 32, 'S键 = 摘除宝石', 2)
if @meter > 0 and @meter < 100
x, y = 78, 34
@socket_window.draw_text(0, 22, 212, 32, '镶嵌:')
@socket_window.contents.fill_rect(x, y, 152, 12, @col[2])
@socket_window.contents.fill_rect(x+1, y+1, 150 *@meter / 100, 5, @col[0])
@socket_window.contents.fill_rect(x+1, y+6, 150 *@meter / 100, 5, @col[1])
elsif @meter > 100
@socket_window.draw_text(0, 22, @socket_window.width, 32, @result)
elsif @meter == 0
@itemslots.item.nil? ? @result = '准备镶嵌' : @result = '无法镶嵌'
@socket_window.draw_text(0, 22, @socket_window.width, 32, @result)
end
end
def terminate
super
@itemslots.dispose
@manastones.dispose
@socket_window.dispose
@slot_window.dispose
@param_window.dispose
end
def update
super
update_selection if Input.trigger?(:C)
update_cancel if Input.trigger?(:B)
update_clear_socket if Input.trigger?(:Y)
start_socketing
update_indexes
end
def update_indexes
if @equipp_slot != @slot_window.index
@itemslots.refresh(@slot_window.item)
refresh_socketing
@equipp_slot = @slot_window.index
elsif @slots_index != @itemslots.index and @itemslots.visible
@slots_index = @itemslots.index
refresh_socketing
end
end
def start_socketing
return if @soketing.nil?
@meter += 1 ; refresh_socketing
if @meter == 100
r = rand(101)
r <= @manastones.item.socket_chance ? success_socketing : fail_socketing
elsif @meter == 200
@soketing = nil ; @meter = 0 ; @manastones.activate
refresh_socketing
end
end
def update_selection
return if @meter > 0 ||
[email protected]
if
[email protected]
? || @slot_window.item.nil? ||
@slot_window.item.manaslots.nil?
if !@slot_window.active
Sound.play_buzzer; return
elsif @slot_window.active and @slot_window.item.nil?
Sound.play_buzzer; return
elsif @slot_window.item.manaslots.nil?
Sound.play_buzzer; return
end
end
if @slot_window.active and
[email protected]
@itemslots.select(0)
@itemslots.activate
@slot_window.deactivate ; Sound.play_ok
elsif @itemslots.active and
[email protected]
@itemslots.deactivate
@manastones.activate ; @manastones.select(0)
Sound.play_ok
elsif @manastones.active and
[email protected]
?
@manastones.deactivate
RPG::SE.new(FalMana::SoketingSe, 80,).play
@soketing = true
end
end
def fail_socketing
FalMana.clear_manastones(@slot_window.item, @actor)
@itemslots.refresh(@slot_window.item)
refresh_param
@result = '宝石已损坏!'
RPG::SE.new(FalMana::SocketFailSe, 80,).play
destroy_manastone
end
def success_socketing
FalMana.socket_manastone(@slot_window.item, @itemslots.index,
@manastones.item, @actor)
@itemslots.refresh(@slot_window.item)
refresh_param
@result = '镶嵌成功!!'
RPG::SE.new(FalMana::SocketSuccessSe, 80,).play
destroy_manastone
end
def destroy_manastone
$game_party.lose_item(@manastones.item, 1)
@manastones.refresh
end
def update_cancel
return if @meter > 0
Sound.play_cancel
if @slot_window.active
SceneManager.return
elsif @itemslots.active
@slot_window.activate
@itemslots.unselect
@itemslots.deactivate
elsif @manastones.active
@manastones.unselect ; @manastones.deactivate
@itemslots.activate
end
end
def update_clear_socket
return if @itemslots.item.nil? ||
[email protected]
RPG::SE.new(FalMana::ClearSocketSe, 80,).play
FalMana.remove_manastone(@slot_window.item, @itemslots.index,
@itemslots.item, @actor)
@itemslots.refresh(@slot_window.item)
refresh_param
refresh_socketing
end
end
复制代码
作者:
任小雪
时间:
2021-12-18 19:56
我的理解是,每一次镶嵌强化都是生成新的装备。
然后,装备的注释有所变动。
state的读取和赋值也是需要的。
作者:
黑夜守望者
时间:
2021-12-19 19:51
XP有看到这种脚本
作者:
djs789783
时间:
昨天 12:38
这脚本要怎么使用?填写哪句?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1