| 赞 | 59 |
| VIP | |
| 好人卡 | |
| 积分 | 88 |
| 经验 | |
| 最后登录 | 2024-2-2 |
| 在线时间 | 501 小时 |
- 梦石
- 2
- 星屑
- 6767
- 在线时间
- 501 小时
- 注册时间
- 2018-3-23
- 回帖
- 487

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 MCCF 于 2020-6-4 22:06 编辑
这个脚本的功能?字面意思(狗头
此脚本使用无需署名(但是最好还是署名啦……
[fold=脚本][pre lang="ruby"]#==============================================================================
# 根据状态更改脸图 V2.0
# By MCCF
#==============================================================================
# - [简要概述]本脚本允许根据状态改变角色的脸图。脸图的优先级取决于状态的优先级。
#------------------------------------------------------------------------------
# - [使用规约]可在当地法律允许范围内自由使用。但是希望您能署名MCCF。
#==============================================================================
# - [使用说明]
#------------------------------------------------------------------------------
# - 在状态-备注中写入<state_face = id>则该状态附着后会修改角色的脸图为ID号。
# - 不同角色的第ID号脸图有所不同。这需要在配置模块中设置。ID为0则恢复正常脸图。
#------------------------------------------------------------------------------
# - 2.0版本可以设置多种脸图叠加时,替换成新的第三种脸图等。
# - 注意多种脸图的优先级高于单个脸图的优先级。可以把单个脸图伪装成多种脸图来解决。
#==============================================================================
# - [兼容性]
#------------------------------------------------------------------------------
# - 本脚本可以兼容大部分修改状态方面的脚本,但改动过大的脚本可能不会兼容。
#==============================================================================
# 通用配置模块
#==============================================================================
module StateFace_Config
# 指定不同角色的所有脸图
ACTOR_FACES = {
# 数据库中1号角色
1 => {
# 1号脸图为"Actor4"的第一行第一个
1 => ["Actor4",0],
# 2号脸图为"Evil"的第二行第三个
2 => ["Evil",6],
# 1, 2号脸图相结合时,脸图为"Evil"的第二行第四个
[1, 2] => ["Evil",7]
},
# 数据库中2号角色
2 => {
# 2号脸图为"Evil"的第一行第四个
2 => ["Evil",3],
},
} # 可在本行之前按照格式继续添加
end
#==============================================================================
# 配置模块结束
#==============================================================================
#==============================================================================
# ■ RPG::State
#------------------------------------------------------------------------------
# 状态的数据类。
#==============================================================================
class RPG::State < RPG::BaseItem
#--------------------------------------------------------------------------
# ● 获取脸图ID
#--------------------------------------------------------------------------
def face_id
return /<state_face\s*=\s*(\d+)>/i =~ @note ? $1.to_i : nil
end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 管理角色的类。
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 设置
#--------------------------------------------------------------------------
alias state_face_setup setup
def setup(actor_id)
@actor_id = actor_id
@normal_face_name = actor.face_name
@normal_face_index = actor.face_index
state_face_setup(actor_id)
update_face_states
end
#--------------------------------------------------------------------------
# ● 附加状态
#--------------------------------------------------------------------------
alias state_face_add_new_state add_new_state
def add_new_state(state_id)
state_face_add_new_state(state_id)
update_face_states
end
#--------------------------------------------------------------------------
# ● 消除状态
#--------------------------------------------------------------------------
alias state_face_erase_state erase_state
def erase_state(state_id)
state_face_erase_state(state_id)
if sort_face_states.empty?
@face_name = @normal_face_name
@face_index = @normal_face_index
else
update_face_states
end
end
#--------------------------------------------------------------------------
# ● 清除状态信息
#--------------------------------------------------------------------------
alias state_face_clear_states clear_states
def clear_states
state_face_clear_states
@face_name = @normal_face_name
@face_index = @normal_face_index
end
#--------------------------------------------------------------------------
# ● 更改图像
#--------------------------------------------------------------------------
alias state_face_set_graphic set_graphic
def set_graphic(character_name, character_index, face_name, face_index)
@normal_face_name = face_name
@normal_face_index = face_index
fname = sort_face_states.empty? ? face_name : @face_name
findex = sort_face_states.empty? ? face_index : @face_index
state_face_set_graphic(character_name, character_index, fname, findex)
end
#--------------------------------------------------------------------------
# ● 排序当前脸图状态
#--------------------------------------------------------------------------
def sort_face_states
face_states = self.states.select { |state| state.face_id }
face_states = face_states.sort_by { |state| [0 - state.priority, id] }
face_states.collect {|state| state.id }
end
#--------------------------------------------------------------------------
# ● 更新状态脸图
#--------------------------------------------------------------------------
def update_face_states
unless sort_face_states.empty?
face_states = sort_face_states
if setting = StateFace_Config::ACTOR_FACES[@actor_id]
if $data_states[face_states[0]].face_id == 0
@face_name = @normal_face_name
@face_index = @normal_face_index
return
end
face_ids = []
face_states.each do |id|
unless face_ids.include?($data_states[id].face_id)
face_ids.push($data_states[id].face_id)
end
end
result = setting.select do |key|
key.is_a?(Array) && key.all? {|id| face_ids.include?(id) }
end
result = result.max_by do |key, value|
key.collect {|id| face_ids.index(id) || -1 }
end
if result
result = result[1]
else
result = setting[$data_states[face_states[0]].face_id]
return unless result
end
@face_name = result[0]
@face_index = result[1]
end
end
end
end[/pre][/fold][fold=范例工程]
根据状态改变脸图.zip
(1.43 MB, 下载次数: 79, 售价: 1 星屑)
[/fold] |
|