赞 | 13 |
VIP | 0 |
好人卡 | 0 |
积分 | 21 |
经验 | 70950 |
最后登录 | 2023-8-23 |
在线时间 | 740 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 2125
- 在线时间
- 740 小时
- 注册时间
- 2010-9-6
- 帖子
- 338
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 804173948 于 2014-7-12 12:52 编辑
好像一直都没什么脚本关于称号这方面(如果有原谅我见识短浅、、、)
这是在做游戏时、、突然想到的系统-、
于是从“百忙”之中抽出了一段时间写了出来-、、、(由于某脚本的影响已经好久没接触过RM的默认界面了、、所以界面弄得不好额- -)
进入正题、、这系统作用就是通过更换称号来实现震慑的效果、、
简单地说就是增加了“震慑力”、“震慑抵抗力”这两个属性(角色与敌人都拥有)
所谓震慑效果就是向对方发起攻击时或被对方攻击时按一定比例减少对方属性
而震慑抵抗力能够减缓或者无视对方的震慑、之类的。
以下是称号更换界面(界面不好看请谅解- 、有时间再优化。。。有急需的联系QQ。。)、、
战斗界面还是默认的那个-、
脚本
=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
=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
注:本脚本需要用到
自动换行脚本 【 原作者:叶子 修改:wyongcan】
class Window_Base < Window #~ draw_text_ex的增强,使其可以自动换行 原作者:叶子 修改:wyongcan #-------------------------------------------------------------------------- # ● 绘制带有控制符的文本内容 # 如果传递了width参数的话,会自动换行 #-------------------------------------------------------------------------- def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true) reset_font_settings if normalfont == true text = convert_escape_characters(text) pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)} if width != nil pos[:height] = contents.font.size pos[:width] = width pos[:textwidth] = textwidth end process_character(text.slice!(0, 1), text, pos) until text.empty? end #-------------------------------------------------------------------------- # ● 文字的处理 # c : 文字 # text : 绘制处理中的字符串缓存(字符串可能会被修改) # pos : 绘制位置 {:x, :y, :new_x, :height} #-------------------------------------------------------------------------- def process_character(c, text, pos) case c when "\r" # 回车 return when "\n" # 换行 process_new_line(text, pos) when "\f" # 翻页 process_new_page(text, pos) when "\e" # 控制符 process_escape_character(obtain_escape_code(text), text, pos) else # 普通文字 pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth] if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width] process_new_line(text, pos) end process_normal_character(c, pos) end end end
class Window_Base < Window
#~ draw_text_ex的增强,使其可以自动换行 原作者:叶子 修改:wyongcan
#--------------------------------------------------------------------------
# ● 绘制带有控制符的文本内容
# 如果传递了width参数的话,会自动换行
#--------------------------------------------------------------------------
def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
reset_font_settings if normalfont == true
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
if width != nil
pos[:height] = contents.font.size
pos[:width] = width
pos[:textwidth] = textwidth
end
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
#--------------------------------------------------------------------------
# ● 文字的处理
# c : 文字
# text : 绘制处理中的字符串缓存(字符串可能会被修改)
# pos : 绘制位置 {:x, :y, :new_x, :height}
#--------------------------------------------------------------------------
def process_character(c, text, pos)
case c
when "\r" # 回车
return
when "\n" # 换行
process_new_line(text, pos)
when "\f" # 翻页
process_new_page(text, pos)
when "\e" # 控制符
process_escape_character(obtain_escape_code(text), text, pos)
else # 普通文字
pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
process_new_line(text, pos)
end
process_normal_character(c, pos)
end
end
end
绘制线段脚本 【原作者:忘了。。。】
class Bitmap def draw_line(x1, y1, x2, y2, color) if x1 == x2 x = x1 for y in (y1 < y2 ? y1..y2 : y2..y1) set_pixel(x, y, color) end else a = (y2-y1)/(x2-x1).to_f if -1 < a and a < 1 for x in (x1 < x2 ? x1..x2 : x2..x1) y = a * (x - x1) + y1 set_pixel(x, y, color) end else for y in (y1 < y2 ? y1..y2 : y2..y1) x = (y - y1) / a + x1 set_pixel(x, y, color) end end end end end
class Bitmap
def draw_line(x1, y1, x2, y2, color)
if x1 == x2
x = x1
for y in (y1 < y2 ? y1..y2 : y2..y1)
set_pixel(x, y, color)
end
else
a = (y2-y1)/(x2-x1).to_f
if -1 < a and a < 1
for x in (x1 < x2 ? x1..x2 : x2..x1)
y = a * (x - x1) + y1
set_pixel(x, y, color)
end
else
for y in (y1 < y2 ? y1..y2 : y2..y1)
x = (y - y1) / a + x1
set_pixel(x, y, color)
end
end
end
end
end
范例:(已含DLL)
称号震慑系统.zip
(1.44 MB, 下载次数: 800)
|
评分
-
查看全部评分
|