module TacticalSkill
#==============================================================================
# START
#==============================================================================
# 按键设定
A = Input::A # 对应按键:Z
B = Input::B # 对应按键:X
C = Input::C # 对应按键:C
X = Input::X # 对应按键:A
Y = Input::Y # 对应按键:S
Z = Input::Z # 对应按键:D
L = Input::L # 对应按键:Q
R = Input::R # 对应按键:W
UP = Input::UP
DOWN = Input::DOWN
LEFT = Input::LEFT
RIGHT = Input::RIGHT
#==============================================================================
# END
#==============================================================================
end
#==============================================================================
# Input
#==============================================================================
module Input
module_function
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def n_trigger?(num)
if trigger?(num)
return false
elsif trigger?(A) or trigger?(B) or trigger?(C) or
trigger?(X) or trigger?(Y) or trigger?(Z) or
trigger?(L) or trigger?(R) or
trigger?(UP) or trigger?(DOWN) or trigger?(RIGHT) or trigger?(LEFT)
return true
end
return false
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def key_converter(key)
# 按键对应的字母或文字
case key
when A
return "Z"
when B
return "X"
when C
return "C"
when X
return "A"
when Y
return "S"
when Z
return "D"
when L
return "Q"
when R
return "W"
when UP
return "上"
when DOWN
return "下"
when LEFT
return "左"
when RIGHT
return "右"
end
end
end
#==============================================================================
# Game_Battler
#==============================================================================
class Game_Battler
# attr_accessor :tact_flag
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# alias initialize_tactical initialize
# def initialize
# initialize_tactical #
# @tact_flag = false
# end
#--------------------------------------------------------------------------
# user :
# skill :
#--------------------------------------------------------------------------
alias skill_effect_tactical skill_effect
def skill_effect(user, skill)
skill_copy = $data_skills[skill.id].dup
if $game_switches[8] == true
skill.power += 1 + TacticalSkill::T_SKILL[skill.id][1]
end
$game_switches[8] = false
skill.hit = 0 if skill.power == 0
ret = skill_effect_tactical(user, skill)
user.tact_flag = false
$data_skills[skill.id] = skill_copy.dup
return ret
end
end
#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
def make_rand_tact(ini)
b = []
for i in 0...ini
case rand(12).to_i
when 0
b.push(Input::A)
when 1
b.push(Input::B)
when 2
b.push(Input::C)
when 3
b.push(Input::X)
when 4
b.push(Input::Y)
when 5
b.push(Input::Z)
when 6
b.push(Input::L)
when 7
b.push(Input::R)
when 8
b.push(Input::RIGHT)
when 9
b.push(Input::UP)
when 10
b.push(Input::LEFT)
when 11
b.push(Input::DOWN)
end
end
return b
end
def make_rand_tact4(ini)
b = []
for i in 0...ini
case rand(4).to_i
when 0
b.push(Input::RIGHT)
when 1
b.push(Input::UP)
when 2
b.push(Input::LEFT)
when 3
b.push(Input::DOWN)
end
end
return b
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def make_tactical_skill_result
ta = @active_battler.current_action.skill_id
ta2 = $data_skills[ta].att
if @active_battler.att != ta2
return false
end
tact_skill = TacticalSkill::T_SKILL[@active_battler.current_action.skill_id][0]
if tact_skill.is_a?(Numeric)
a = tact_skill
tact_skill = make_rand_tact(a)
elsif tact_skill.is_a?(String)
a = tact_skill.to_i
tact_skill = make_rand_tact4(a)
end
# window_keycount.x = window_counter.x = actor_x
window_keycount.x = 0
window_counter.x = 0
window_keycount.y = 160
window_counter.y = 190
@a = Sprite.new
@a.bitmap = RPG::Cache.title("窗体2.png")
for i in 0...time
if Input.trigger?(tact_skill[key_count])
key_count += 1
window_keycount.key_in
elsif Input.n_trigger?(tact_skill[key_count])
break
end
# 如果成功
if key_count >= tact_skill.size
window_keycount.text_in("成功")
# 成功提示音
Audio.se_play("Audio/SE/056-Right02")
@active_battler.tact_flag = false
common_event = $data_common_events[7]
$game_system.battle_interpreter.setup($data_common_events[7].list, 0)
# 成功与失败后的处理
for i in 0...10
Graphics.update
@spriteset.update
end
window_keycount.dispose
window_counter.dispose
@a.dispose
$game_switches[8] = true
return true
end
# 刷新
window_counter.refresh((i*100/time).truncate)
Graphics.update
Input.update
end
# 如果失败
if @active_battler.tact_flag
#失败提示音
Audio.se_play("Audio/SE/057-Wrong01")
window_keycount.text_in("失败")
end
# 成功与失败后的处理
for i in 0...10
Graphics.update
@spriteset.update
end
window_keycount.dispose
window_counter.dispose
@a.dispose
$game_switches[8] = false
return false
end
end
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_counter_bar(x, y, current)
bitmap = RPG::Cache.windowskin(TacticalSkill::T_BAR_NAME)
cw = bitmap.width * current / 100
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x, y, bitmap, src_rect)
end
end
#==============================================================================
# Window_KeyCounter
#==============================================================================
class Window_KeyCounter < Window_Base
#--------------------------------------------------------------------------
# 输入窗口的描绘
#--------------------------------------------------------------------------
def initialize
super(0, 256, 160, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 1
refresh(0)
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def refresh(current)
self.contents.clear
draw_counter_bar(0, 0, current)
end
end
#==============================================================================
# Window_KeyCount
#------------------------------------------------------------------------------
#
#==============================================================================
class Window_KeyCount < Window_Base
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def initialize(key)
super(0, 230, 160, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 0
@key = key
@key_count = 0
refresh
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in [email protected]
if @key.size > 4
if @key_count >= 3
x = (i- @key_count+2)*32
else
x = i *32
end
else
x = i * 32
end
if i < @key_count
self.contents.font.color = disabled_color
self.contents.font.size = 16
elsif i== @key_count
self.contents.font.color = normal_color
self.contents.font.size = 25
else
self.contents.font.color = disabled_color
self.contents.font.size = 18
end
self.contents.draw_text(x, 0, 100, 32, Input.key_converter(@key))
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def key_in
@key_count += 1
refresh
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def text_in(text)
self.contents.clear
self.contents.font.size = 20
self.contents.draw_text(0, 0, 130, 32, text, 1)
end
end
=begin
=end作者: HeRo_SKY 时间: 2013-7-11 23:49
额。。。 我这是从另一个游戏中拿的,那还有按键连续技能和两者兼容脚本,会不会有冲突。。。作者: 弗雷德 时间: 2013-7-11 23:56
不好说,首先这段脚本就不完整,有几个函数根本就没调用过,LZ说说是哪个游戏,俺对这个系统也挺好奇的。作者: HeRo_SKY 时间: 2013-7-12 10:59