=begin
================================================
称号震慑系统 版本 1.0 By 804173948 QQ:同上
================================================
更新:
2014-7-11
发布
注意:
本脚本编写时间仓促-、难免会有疏漏
简介:
顾名思义,本系统通过更换称号实现对敌人的震慑作用
同时敌人也可以对角色产生震慑作用
如果喜欢,你也可以使某角色一开始就拥有一定的震慑力
所谓震慑作用,是在a对b发起攻击时,若他们(a对b或b对a)之间有震慑力,
则会使对方在 发动攻击 或者 被攻击 的那一瞬间基本能力(mhp,mmp除外)降低一定百分比
同时,角色与敌人也有震慑抵抗力这个属性,能够减弱或无视对方的震慑
使用说明:
1、角色/敌人备注填写:
1、[SP 数值]
说明:震慑力,取值为 -100~100(为负数就是起不到震慑作用反而使对方能力上升)
默认为 0
如:[SP 30]
[SP -5]
2、[SD 数值]
说明:震慑抵抗力,取值为 -100~100(为负数就是起不到震慑抵抗作用反而使对方震慑力上升)
默认为 0
如:[SD 30]
[SD -5]
2、角色备注填写:
1、[IN 数值]
说明:角色的初始称号,后面数值表示 称号 id
默认为 -1 (即无称号)
如:[IN 0]
[IN 3]
3、其他(用于 事件-脚本 ):
获得称号:
$game_actors[id].add_nicknames(nickname_id)
id => 角色 id
nickname_id => 称号 id
强制放弃称号:
$game_actors[id].del_nicknames(nickname_id)
id => 角色 id
nickname_id => 称号 id
强制装备称号:
$game_actors[id].set_nickname(nickname_id)
id => 角色 id
nickname_id => 称号 id
强制卸下称号:
$game_actors[id].del_nickname
id => 角色 id
增加人物震慑力(理论上还可以在战斗中用此方法增加敌人震慑力,来营造士气上升的效果)
$game_actors[id].add_shock_point(value)
id => 角色 id
value => 增加数值(负值为减少)
PS:其实这里可以不用考虑震慑力范围的
增加人物震慑抵抗力(理论上还可以在战斗中用此方法增加敌人震慑抵抗力,来营造士气上升的效果)
$game_actors[id].add_shock_def(value)
id => 角色 id
value => 增加数值(负值为减少)
PS:其实这里可以不用考虑震慑力范围的
增加敌人震慑力(战斗中)
$game_troop.members[id].add_shock_point(value)
id => 群组中怪物 id
value => 增加数值(负值为减少)
PS:其实这里可以不用考虑震慑力范围的
增加敌人震慑抵抗力(战斗中)
$game_troop.members[id].add_shock_def(value)
id => 群组中怪物 id
value => 增加数值(负值为减少)
PS:其实这里可以不用考虑震慑力范围的
称号更换界面呼叫方法:
SceneManager.call(Scene_Nicknames)
冲突与BUG:
本脚本编写时间仓促-、难免会有冲突与BUG
=end
#==============================================================================
# ■ ShockSystem
#------------------------------------------------------------------------------
# 常量设置
#==============================================================================
module ShockSystem
# 人物称号设置
NickNames = {
# 称号名称
:name => ["预言之子","预言之孙子","国家炼金术师","海贼王","一米六","铠之巨人","忍术之神","七武海","八武海"],
# 称号描述
:description => ["预言的儿子",
"预言之子的儿子",
"也被称为军队的走狗",
"拥有世上一切财富、声望和权利的标志",
"人类最强兵器",
"不详",
"就是会很多忍术lo-、",
"王下七武海之一",
"没八武海这个称号",
],
# 称号颜色
:color => [Color.new(255,128,128),
Color.new(64,64,255),
Color.new(255,0,0),
Color.new(176,176,176),
Color.new(128,128,255),
Color.new(255,0,255),
Color.new(128,255,128),
Color.new(255,255,128),
Color.new(128,128,128)],
# 图标(ID)
:icon => [14,12,501,523,387,121,143,523,99],
# 震慑力(范围为 -100~100 )
:shock => [20,2,15,70,50,15,60,30,-50],
# 震慑抵抗力(范围为 -100~100 )
:shock_def => [50,100,15,100,30,25,100,60,-10]
}
# 敌人/角色震慑力标志
ShockPointFlag = "SP"
# 敌人/角色震慑抵抗力标志
ShockDefFlag = "SD"
# 角色初始称号标志
InitNickname = "IN"
end
#==============================================================================
# ■
#------------------------------------------------------------------------------
# 内部定义
#==============================================================================
class RPG::BaseItem
def shock_point
if /\[#{ShockSystem::ShockPointFlag} (\d+)\]/ =~ @note
return $1.to_i
elsif /\[#{ShockSystem::ShockPointFlag} (\d+)\]/ =~ @note
return -($1.to_i)
else
return 0
end
end
def shock_def
if /\[#{ShockSystem::ShockDefFlag} (\d+)\]/ =~ @note
return $1.to_i
elsif /\[#{ShockSystem::ShockDefFlag} -(\d+)\]/ =~ @note
return -($1.to_i)
else
return 0
end
end
end
class RPG::Actor < RPG::BaseItem
def nickname
if /\[#{ShockSystem::InitNickname} (\d+)\]/ =~ @note
return $1.to_i
else
return -1
end
end
end
class Game_BattlerBase
def shock_point # 震慑力
@shock_point = 0 unless @shock_point
return [[@shock_point,100].min,-100].max
end
def shock_def # 震慑抵抗力
@shock_def = 0 unless @shock_def
return [[@shock_def,100].min,-100].max
end
def add_shock_point(value)
@shock_point += value
end
def add_shock_def(value)
@shock_def += value
end
end
class Game_Battler
#--------------------------------------------------------------------------
# ● 计算最终震慑力
#--------------------------------------------------------------------------
def make_finally_shock_point(user)
usp = user.shock_point
usd = user.shock_def
ssp = self.shock_point
ssd = self.shock_def
if ssp > 0
ssp *= 1-(usd / 100.0)
end
if usp > 0
usp *= 1-(ssd / 100.0)
end
us = usp
ss = ssp
return ss,us
end
#--------------------------------------------------------------------------
# ● 更改能力值
#--------------------------------------------------------------------------
def change_param(user,shock_point,param_id)
if user.is_a?(Game_Actor)
user.class.params[param_id, user.level] *= 1-(shock_point / 100.0)
elsif user.is_a?(Game_Enemy)
user.enemy.params[param_id] *= 1-(shock_point / 100.0)
end
end
#--------------------------------------------------------------------------
# ● 重置能力值
#--------------------------------------------------------------------------
def reset_param(user,old_param,param_id)
if user.is_a?(Game_Actor)
user.class.params[param_id, user.level] = old_param
elsif user.is_a?(Game_Enemy)
user.enemy.params[param_id] = old_param
end
end
#--------------------------------------------------------------------------
# ● 计算伤害
#--------------------------------------------------------------------------
alias old_make_damage_value make_damage_value
def make_damage_value(user, item)
if !item.damage.recover?
# ss => 被攻击者对攻击者的震慑力
# us => 攻击者对被攻击者的震慑力
ss,us = make_finally_shock_point(user)
up = []
sp = []
6.times do |i|
up.push(user.param(i+2))
sp.push(self.param(i+2))
change_param(user,ss,i+2)
change_param(self,us,i+2)
end
end
old_make_damage_value(user, item)
if !item.damage.recover?
6.times do |i|
reset_param(user,up[i],i+2)
reset_param(self,sp[i],i+2)
end
end
end
end
class Game_Actor
attr_reader :nicknames # 获得的称号
#--------------------------------------------------------------------------
# ● 设置
#--------------------------------------------------------------------------
alias old_setup setup
def setup(actor_id)
old_setup(actor_id)
@nicknames = []
@shock_point = actor.shock_point
@shock_def = actor.shock_def
set_nickname(@nickname)
end
def add_nicknames(id)
@nicknames.push(id) if !@nicknames.include?(id)
end
def del_nicknames(id)
del_nickname if @nickname == id
@nicknames.delete(id) if @nicknames.include?(id)
end
def set_nickname(id)
return unless id >= 0
add_nicknames(id) unless @nicknames.include?(id)
@nickname = id
@shock_point += ShockSystem::NickNames[:shock][@nickname]
@shock_def += ShockSystem::NickNames[:shock_def][@nickname]
end
def del_nickname
return unless @nickname >= 0
@shock_point -= ShockSystem::NickNames[:shock][@nickname]
@shock_def -= ShockSystem::NickNames[:shock_def][@nickname]
@nickname = -1
end
end
class Game_Enemy
alias old_initialize initialize
def initialize(index, enemy_id)
old_initialize(index, enemy_id)
@shock_point = enemy.shock_point
@shock_def = enemy.shock_def
end
end
class Window_Base
#--------------------------------------------------------------------------
# ● 绘制称号
#--------------------------------------------------------------------------
def draw_actor_nickname(actor, x, y, width = 180)
return unless actor
draw_nickname(actor.nickname, x, y, width)
end
#--------------------------------------------------------------------------
# ● 绘制称号
#--------------------------------------------------------------------------
def draw_nickname(id, x, y, width = 180)
return unless id > -1
draw_icon(ShockSystem::NickNames[:icon][id], x, y)
change_color(ShockSystem::NickNames[:color][id])
draw_text(x + 24, y, width, line_height, ShockSystem::NickNames[:name][id])
end
#--------------------------------------------------------------------------
# ● 绘制填充矩形 (thick => Line 厚度)
#--------------------------------------------------------------------------
def draw_fill_rect(rect, fill_color, line_color = Color.new(255,255,255), thick = 1)
contents.fill_rect(rect, fill_color)
fill_out_line(rect,line_color, thick)
end
#--------------------------------------------------------------------------
# ● 描绘边框
#--------------------------------------------------------------------------
def fill_out_line(rect,color = Color.new(255,255,255), thick = 1)
x = rect.x
y = rect.y
width = rect.width
height= rect.height
for i in 1..thick
contents.draw_line(x-i,y-i,x-i,y+height, color)
contents.draw_line(x-i,y-i,x+width,y-i, color)
contents.draw_line(x+width,y-i,x+width,y+height, color)
contents.draw_line(x-i,y+height,x+width,y+height,color)
end
end
end
class Window_Status
#--------------------------------------------------------------------------
# ● 绘制区域 1
#--------------------------------------------------------------------------
def draw_block1(y)
draw_actor_name(@actor, 4, y)
draw_actor_class(@actor, 128, y)
draw_actor_nickname(@actor, 248, y)
end
end
class Window_MenuCommand
#--------------------------------------------------------------------------
# ● 向指令列表添加主要的指令
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
add_command("更换称号", :nicknames, main_commands_enabled)
end
end
class Scene_Menu
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
alias old_create_command_window create_command_window
def create_command_window
old_create_command_window
@command_window.set_handler(:nicknames, method(:command_nicknames))
end
#--------------------------------------------------------------------------
# ● 指令“更换称号”
#--------------------------------------------------------------------------
def command_nicknames
SceneManager.call(Scene_Nicknames)
end
end
#==============================================================================
# ■ Window_NicknameSelect
#------------------------------------------------------------------------------
# 称号选择窗口
#==============================================================================
class Window_NicknameSelect < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, width, height,actor)
super(x, y, width, height)
@actor = actor
@data = []
refresh
end
#--------------------------------------------------------------------------
# ● 设置角色
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 获取项目数
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
@data && index >= 0 ? @data[index] : nil
end
#--------------------------------------------------------------------------
# ● 生成物品列表
#--------------------------------------------------------------------------
def make_item_list
@data = @actor.nicknames
end
#--------------------------------------------------------------------------
# ● 返回上一个选择的位置
#--------------------------------------------------------------------------
def select_last
select(@data.index($game_party.last_item.object) || 0)
end
#--------------------------------------------------------------------------
# ● 绘制项目
#--------------------------------------------------------------------------
def draw_item(index)
id = @data[index]
if id
rect = item_rect(index)
rect.width -= 4
draw_nickname(id, rect.x, rect.y,156)
end
end
#--------------------------------------------------------------------------
# ● 更新帮助内容
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
@index = 0
end
end
#==============================================================================
# ■ Window_NicknameInfo
#------------------------------------------------------------------------------
# 显示称号信息窗口。
#==============================================================================
class Window_NicknameInfo < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x,y,width,height,actor)
super(x,y,width,height)
@actor = actor
refresh
activate
end
#--------------------------------------------------------------------------
# ● 设置角色
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 绘制水平线
#--------------------------------------------------------------------------
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
#--------------------------------------------------------------------------
# ● 获取水平线的颜色
#--------------------------------------------------------------------------
def line_color
color = normal_color
color.alpha = 48
color
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1(0)
draw_block2(2,line_height)
draw_horz_line(line_height * 3)
end
#--------------------------------------------------------------------------
# ● 绘制区域 1
#--------------------------------------------------------------------------
def draw_block1(y)
draw_actor_name(@actor, 4, y)
draw_actor_class(@actor, 128, y)
draw_actor_nickname(@actor, 248, y)
end
#--------------------------------------------------------------------------
# ● 绘制区域 2
#--------------------------------------------------------------------------
def draw_block2(x,y)
change_color(system_color)
draw_text(x, y, 160,line_height,"震慑力")
draw_text(x, y+line_height, 160,line_height,"震慑抵抗力")
change_color(normal_color)
draw_text(x+132, y, 128,line_height,@actor.shock_point)
draw_text(x+132, y+line_height, 128,line_height,@actor.shock_def)
rect = Rect.new(x+176,y+1,width - 222,line_height-2)
draw_fill_rect(rect, Color.new(0,0,0))
color1 = Color.new(0,255,0)
color2 = Color.new(0,0,255)
value = @actor.shock_point
if value < 0
value = -value
color1 = Color.new(255,0,0)
color2 = Color.new(255,255,0)
end
rect.width = (rect.width*(value / 100.0)).to_i
contents.gradient_fill_rect(rect,color1,color2)
rect = Rect.new(x+176,y+line_height+1,width - 222,line_height-2)
draw_fill_rect(rect, Color.new(0,0,0))
color1 = Color.new(0,255,0)
color2 = Color.new(128,128,128)
value = @actor.shock_def
if value < 0
value = -value
color1 = Color.new(255,0,0)
color2 = Color.new(128,128,128)
end
rect.width = (rect.width*(value / 100.0)).to_i
contents.gradient_fill_rect(rect,color1,color2)
end
#--------------------------------------------------------------------------
# ● 绘制能力
#--------------------------------------------------------------------------
def draw_parameters(x, y, id)
draw_nickname(id, x, y)
change_color(system_color)
draw_text(x, y+line_height, 160,line_height,"震慑力")
draw_text(x, y+line_height*2, 160,line_height,"震慑抵抗力")
change_color(normal_color)
draw_text(x+132, y+line_height, 128,line_height,ShockSystem::NickNames[:shock][id])
draw_text(x+132, y+line_height*2, 128,line_height,ShockSystem::NickNames[:shock_def][id])
rect = Rect.new(x+176,y+line_height+1,width - 222,line_height-2)
draw_fill_rect(rect, Color.new(0,0,0))
color1 = Color.new(0,255,0)
color2 = Color.new(0,0,255)
value = ShockSystem::NickNames[:shock][id]
if value < 0
value = -value
color1 = Color.new(255,0,0)
color2 = Color.new(255,255,0)
end
rect.width = (rect.width*(value / 100.0)).to_i
contents.gradient_fill_rect(rect,color1,color2)
rect = Rect.new(x+176,y+line_height*2+1,width - 222,line_height-2)
draw_fill_rect(rect, Color.new(0,0,0))
color1 = Color.new(0,255,0)
color2 = Color.new(128,128,128)
value = ShockSystem::NickNames[:shock_def][id]
if value < 0
value = -value
color1 = Color.new(255,0,0)
color2 = Color.new(128,128,128)
end
rect.width = (rect.width*(value / 100.0)).to_i
contents.gradient_fill_rect(rect,color1,color2)
end
#--------------------------------------------------------------------------
# ● 绘制说明
#--------------------------------------------------------------------------
def draw_description(x, y, id)
draw_text_ex(x, y, ShockSystem::NickNames[:description][id],contents_width - 2*x)
end
#--------------------------------------------------------------------------
# ● 绘制说明
#--------------------------------------------------------------------------
def set_item(id)
contents.clear
refresh
if id
draw_parameters(2, line_height * 4, id)
draw_horz_line(line_height * 8)
draw_description(2, line_height * 9,id)
end
end
end
#==============================================================================
# ■ Window_NicknameCommand
#------------------------------------------------------------------------------
# 称号指令画面
#==============================================================================
class Window_NicknameCommand < Window_Command
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, width)
@window_width = width
super(x, y)
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
@window_width
end
#--------------------------------------------------------------------------
# ● 获取窗口的高度
#--------------------------------------------------------------------------
def window_height
return 120
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command("使用该称号", :set)
add_command("放弃该称号", :del)
add_command("卸下原称号", :putoff)
add_command("上一角色" , :prev)
add_command("下一角色" , :next)
add_command("返回" , :back)
end
end
#==============================================================================
# ■ Scene_Nicknames
#------------------------------------------------------------------------------
# 称号更换画面
#==============================================================================
class Scene_Nicknames < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_select_window
create_info_window
end
#--------------------------------------------------------------------------
# ● 生成称号选择窗口
#--------------------------------------------------------------------------
def create_select_window
@select_window = Window_NicknameSelect.new(0, 0,156,Graphics.height,@actor)
@select_window.set_handler(:ok, method(:select_command))
@select_window.set_handler(:cancel, method(:return_scene))
@select_window.set_handler(:pagedown, method(:next_actor))
@select_window.set_handler(:pageup, method(:prev_actor))
@select_window.activate
end
#--------------------------------------------------------------------------
# ● 生成称号信息窗口
#--------------------------------------------------------------------------
def create_info_window
@info_window = Window_NicknameInfo.new(@select_window.width, 0,Graphics.width - @select_window.width,Graphics.height,@actor)
@select_window.help_window = @info_window
end
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
wx = @info_window.x
wy = @info_window.height - 120
ww = @info_window.width
@command_window = Window_NicknameCommand.new(wx, wy, ww)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.set_handler(:set, method(:set_nickname))
@command_window.set_handler(:del, method(:delete_nickname))
@command_window.set_handler(:putoff, method(:put_off_nickname))
@command_window.set_handler(:prev, method(:prev_actor))
@command_window.set_handler(:next, method(:next_actor))
@command_window.set_handler(:back, method(:back))
@command_window.set_handler(:cancel, method(:back))
end
#--------------------------------------------------------------------------
# ● 刷新窗口
#--------------------------------------------------------------------------
def refresh_windows
@select_window.refresh
@info_window.refresh
end
#--------------------------------------------------------------------------
# ● 选项
#--------------------------------------------------------------------------
def select_command
if @select_window.item
create_command_window
@command_window.activate
else
back
end
end
#--------------------------------------------------------------------------
# ● 指令“设置称号”
#--------------------------------------------------------------------------
def set_nickname
@actor.del_nickname
@actor.set_nickname(@select_window.item)
back
end
#--------------------------------------------------------------------------
# ● 指令“放弃称号”
#--------------------------------------------------------------------------
def delete_nickname
@actor.del_nicknames(@select_window.item)
back
end
#--------------------------------------------------------------------------
# ● 指令“卸下称号”
#--------------------------------------------------------------------------
def put_off_nickname
@actor.del_nickname
back
end
#--------------------------------------------------------------------------
# ● 指令“返回”
#--------------------------------------------------------------------------
def back
if @command_window
@command_window.close
@command_window.deactivate
end
refresh_windows
@select_window.activate
end
#--------------------------------------------------------------------------
# ● 切换角色
#--------------------------------------------------------------------------
def on_actor_change
@select_window.actor = @actor
@info_window.actor = @actor
back
end
end