| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2015-7-9 |
| 在线时间 | 38 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 38 小时
- 注册时间
- 2014-10-28
- 回帖
- 76
|
楼主 |
发表于 2014-11-1 09:50:52
|
显示全部楼层
本帖最后由 VIPArcher 于 2014-11-1 10:17 编辑
以下是技能冷却脚本:
[pre lang="ruby" line="1"]=begin
在VA默认战斗系统上增加技能冷却时间系统。使用一个技能后在一定回合内不可以使用。
需要在技能备注里添加<CD x>
调用脚本
$game_actors[x].skill_cool_add(y,z)可以使x号角色的y号技能的剩余冷却时间增加z,如果z为负数则减少剩余冷却时间
=end
class RPG::Skill < RPG::UsableItem
def cool_time
@note.each_line{|line|
case line
when /\<(?:CD)[ ]*(\d+)\>/
return $1.to_i
end
}
return 0
end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 管理角色的类。
# 本类在 Game_Actors 类 ($game_actors) 的内部使用。
# 具体使用请查看 Game_Party 类 ($game_party) 。
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias skill_cool_time_initialize initialize
def initialize
skill_cool_time_initialize
@skill_cool_time=[]
end
#--------------------------------------------------------------------------
# ● 应用技能/物品的效果★
#--------------------------------------------------------------------------
alias skill_cool_time_item_apply item_apply
def item_apply(user, item)
skill_cool_time_item_apply(user,item)
if item.is_a?(RPG::Skill)
user.set_cool_time(item)
end
end
#--------------------------------------------------------------------------
# ● 设置技能冷却时间
#--------------------------------------------------------------------------
def set_cool_time(skill)
if skill.cool_time
@skill_cool_time[skill.id] = skill.cool_time
end
end
#--------------------------------------------------------------------------
# ● 回合结束处理
#--------------------------------------------------------------------------
alias skill_cool_time_on_turn_end on_turn_end
def on_turn_end
skill_cool_time_on_turn_end
@skill_cool_time.each_index{|index|
@skill_cool_time[index] -= 1 if @skill_cool_time[index] and @skill_cool_time[index] > 0
}
end
#--------------------------------------------------------------------------
# ● 技能是否正在冷却
#--------------------------------------------------------------------------
def skill_cooling?(skill)
@skill_cool_time[skill.id] and @skill_cool_time[skill.id] != 0
end
#--------------------------------------------------------------------------
# ● 获取冷却回合
#--------------------------------------------------------------------------
def skill_cool_turn(skill)
@skill_cool_time[skill.id] ? @skill_cool_time[skill.id] : 0
end
#--------------------------------------------------------------------------
# ★ 增加与减少冷却回合
#--------------------------------------------------------------------------
def skill_cool_add(skill,y)
if y<0
if @skill_cool_time[skill.id]>-y
@skill_cool_time[skill.id]+=y
else
@skill_cool_time[skill.id]=0
end
else
@skill_cool_time[skill.id]+=y
end
end
#--------------------------------------------------------------------------
# ● 检查技能的使用条件
#--------------------------------------------------------------------------
alias skill_cool_time_skill_conditions_met? skill_conditions_met?
def skill_conditions_met?(skill)
skill_cool_time_skill_conditions_met?(skill) && !skill_cooling?(skill)
end
#--------------------------------------------------------------------------
# ● 战斗结束处理
#--------------------------------------------------------------------------
alias skill_cool_time_on_battle_end on_battle_end
def on_battle_end
skill_cool_time_on_battle_end
@skill_cool_time.clear
end
end
#==============================================================================
# ■ Window_SkillList
#------------------------------------------------------------------------------
# 技能画面中,显示技能的窗口。
#==============================================================================
class Window_SkillList < Window_Selectable
#--------------------------------------------------------------------------
# ● 绘制项目★
#--------------------------------------------------------------------------
alias skill_cool_time_draw_item draw_item
def draw_item(index)
skill = @data[index]
if skill
if @actor.skill_cooling?(skill)
rect = item_rect(index)
w = (skill.cool_time - @actor.skill_cool_turn(skill)).to_f / skill.cool_time
draw_gauge(rect.x,rect.y,rect.width,w,text_color(5),text_color(13))
end
end
skill_cool_time_draw_item(index)
end
end[/pre]
这个是【迷糊的安安】技能显示脚本:(我选择的是第2种风格)
[pre lang="ruby" line="1"]#ITEM:ID18NUM3 代表每次使用该技能需要消耗第18号物品,数量3个,
#没有该物品或不足消耗量将无法发动技能。
#ITEM:ID18NUM1UN 代表使用该技能的前提条件是队伍持有第18号物品1个,但是不会被消耗。
#ARM:ID10 代表使用该技能的前提条件是使用者装备着第10号防具。
#ITEM:ID19NUM1
#EQU:ID2
#这两行代表,代表使用该技能的前提条件是使用者装备着第2号武器。
#每次使用该技能消耗第19号物品1个。
#
module IISNOW_ITEM_CONSUME_SKILL
PATTERN = /.*ITEM:ID(\d+)NUM(\d+)(.*)/m
# 非专业人士请勿修改,正则匹配式,修改后注意备注写法的改变,下同
PATTERN_E = /.*EQU:ID(\d+).*/m
PATTERN_A = /.*ARM:ID(\d+).*/m
STR_UN_CONSUM = "UN" # 物品不消耗标识
TP_ICON = 189 # 你说你懂的
MP_ICON = 188
STYLE = 1 # 界面风格(支持1,2,3,4效果自己体会,不推荐4)
STYLE_A = 2 # 提示风格(支持1,2,3,同上)
PLACE = 3 # 消耗物品的图标与数目间的间距
PLACE_E = 2 # 不同消耗物品间的间距
ORDER = [0,1,2] # 从右往左的消耗显示顺序(0,TP;1,MP;2,物品)
COLOR_ITEM = Color.new(255,255,255) # 物品消耗数目的字的颜色
COLOR_WE_L = Color.new(255,0,0) # 具体限定武器的框的颜色
COLOR_WE_A = Color.new(255,0,0) # 具体限定防具的框的颜色
COLOR_UN_I = Color.new(0,255,0) # 物品限定但不消耗的提示框的颜色
TRAN_DE = 100 # 风格_A2下的透明度再次降低(最大为160)
end
class Window_SkillList
include IISNOW_ITEM_CONSUME_SKILL
def col_max
case STYLE
when 1,3,4
return 2
when 2
return 1
end
end
def item_height
case STYLE
when 3
line_height * 2
when 1,2,4
line_height + 1
end
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x, rect.y, enable?(skill))
draw_skill_cost(rect, skill)
end
end
alias :iisnow_draw_item_name :draw_item_name
def draw_item_name(item, x, y, enabled = true, width = 172)
iisnow_draw_item_name(item, x, y, enabled,width)
rect_temp = text_size(item.name)
if @actor.skill_eq_limt(item)
draw_kuang(x + 24 + PLACE + rect_temp.width,y,24,24,COLOR_WE_L,enabled)
draw_icon(@actor.skill_eq_limt(item).icon_index,x + 24 + PLACE + rect_temp.width,y,enabled)
rect_temp.width += (24 + PLACE_E)
end
if @actor.skill_ar_limt(item)
draw_kuang(x + 24 + PLACE + rect_temp.width,y,24,24,COLOR_WE_A,enabled)
draw_icon(@actor.skill_ar_limt(item).icon_index,x + 24 + PLACE + rect_temp.width,y,enabled)
end
end
def draw_skill_cost(rect, skill)
str = create_string(skill)
color = [tp_cost_color,mp_cost_color,COLOR_ITEM]
str.each_with_index do |str,i|
next unless str
change_color(color[ORDER], enable?(skill))
kuang = false
case i
when ORDER.index(2)
icon_index = str[0].icon_index
kuang = true if str[2]
str = str[1]
when ORDER.index(1)
icon_index = MP_ICON
when ORDER.index(0)
icon_index = TP_ICON
end
contents.font.size = STYLE == 1 ? Font.default_size - 6 : Font.default_size
draw_style(icon_index,rect,str,skill,kuang)
end
contents.font.size = Font.default_size
end
def draw_style(icon_index,rect,str,skill,kuang)
case STYLE
when 1
draw_kuang(rect.width - 24 + rect.x,rect.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
draw_icon(icon_index,rect.width - 24 + rect.x,rect.y,enable?(skill))
draw_text(Rect.new(rect.x + rect.width - 24,rect.y + 8,24,16),str,2) if str.to_i != 1
rect.width -= (24 + PLACE_E)
when 2,4
draw_text(rect,str,2) if str.to_i != 1
rect.width -= (text_size(str).width + PLACE) if str.to_i != 1
draw_kuang(rect.width - 24 + rect.x,rect.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
draw_icon(icon_index,rect.width - 24 + rect.x,rect.y,enable?(skill))
rect.width -= (24 + PLACE_E)
when 3
rect_temp = rect.clone
rect_temp.y += (rect_temp.height / 2)
rect_temp.height /= 2
draw_text(rect_temp,str,2) if str.to_i != 1
rect.width -= (text_size(str).width + PLACE) if str.to_i != 1
draw_kuang(rect.width - 24 + rect.x,rect_temp.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
draw_icon(icon_index,rect.width - 24 + rect.x,rect_temp.y,enable?(skill))
rect.width -= (24 + PLACE_E)
end
end
def draw_kuang(x,y,w,h,c,fl)
c.alpha = fl ? 255 : translucent_alpha - (STYLE_A == 2 ? TRAN_DE : 0)
case STYLE_A
when 1
contents.fill_rect(x,y,w,1,c)
contents.fill_rect(x,y + 1,1,h - 1,c)
contents.fill_rect(x + 1,y + h - 1,w - 1,1,c)
contents.fill_rect(x + w -1,y + 1,1,h - 2,c)
when 2
contents.fill_rect(x,y,w,h,c)
end
end
def create_string(skill)
str1 = @actor.skill_tp_cost(skill)
str2 = @actor.skill_mp_cost(skill)
str3 = @actor.skill_it_cost(skill)
str1 = str1 > 0 ? str1.to_s : nil
str2 = str2 > 0 ? str2.to_s : nil
str3 = str3[1] > 0 ? [str3[0],str3[1].to_s,str3[2]] : nil
str = [str1,str2,str3]
iisnow = [str[ORDER[0]],str[ORDER[1]],str[ORDER[2]]]
iisnow
end
end
class Game_BattlerBase
include IISNOW_ITEM_CONSUME_SKILL
def skill_it_cost(skill)
skill.note.match(PATTERN)
item = $data_items[$1.to_i] if $1 != 0
num = $2.to_i
flag = $3.match(/^#{STR_UN_CONSUM}/) if $3
return [item,num,flag]
end
def skill_eq_limt(skill)
skill.note.match(PATTERN_E)
eq = $data_weapons[$1.to_i] if $1 != 0
return eq
end
def skill_ar_limt(skill)
skill.note.match(PATTERN_A)
eq = $data_armors[$1.to_i] if $1 != 0
return eq
end
alias :iisnow_skill_cost_payable? :skill_cost_payable?
def skill_cost_payable?(skill)
result1 = iisnow_skill_cost_payable?(skill)
if skill_it_cost(skill)[0]
result2 = $game_party.item_number(skill_it_cost(skill)[0]) >= skill_it_cost(skill)[1]
return result1 && result2
end
return result1
end
alias :iisnow_pay_skill_cost :pay_skill_cost
def pay_skill_cost(skill)
iisnow_pay_skill_cost(skill)
if skill_it_cost(skill)[0] && !skill_it_cost(skill)[2]
$game_party.gain_item(skill_it_cost(skill)[0],-skill_it_cost(skill)[1])
end
end
end
class Game_Actor
alias :iisnow_skill_wtype_ok? :skill_wtype_ok?
def skill_wtype_ok?(skill)
result1 = iisnow_skill_wtype_ok?(skill)
result2 = skill_eq_limt(skill) ? weapons.include?(skill_eq_limt(skill)) : true
result3 = skill_ar_limt(skill) ? armors.include?(skill_ar_limt(skill)) : true
return result1 && result2 && result3
end
end[/pre]
这次帮你编辑了。下次请善用论坛功能。 VIPArcher ——留 |
|