Game_Battler 1

Publié le par chindan

#============================================
# ¡ Game_Battler (•ªŠ„’è‹` 1)
#--------------------------------------------
# @ƒoƒgƒ‰[‚ðˆµ‚¤ƒNƒ‰ƒX‚Å‚·B‚±‚̃Nƒ‰ƒX‚Í Game_Actor ƒNƒ‰ƒX‚Æ Game_Enemy ƒNƒ‰
# ƒX‚̃X[ƒp[ƒNƒ‰ƒX‚Æ‚µ‚Ďg—p‚³‚ê‚Ü‚·B
#============================================

class Game_Battler
#------------------------------------------
# œ ŒöŠJƒCƒ“ƒXƒ^ƒ“ƒX•Ï”
#------------------------------------------
attr_reader :battler_name # ƒoƒgƒ‰[ ƒtƒ@ƒCƒ‹–¼
attr_reader :battler_hue # ƒoƒgƒ‰[ F‘Š
attr_reader :hp # HP
attr_reader :sp # SP
attr_reader :states # ƒXƒe[ƒg
attr_accessor :hidden # ‰B‚êƒtƒ‰ƒO
attr_accessor :immortal # •sŽ€gƒtƒ‰ƒO
attr_accessor :damage_pop # ƒ_ƒ[ƒW•Ž¦ƒtƒ‰ƒO
attr_accessor :damage # ƒ_ƒ[ƒW’l
attr_accessor :critical # ƒNƒŠƒeƒBƒJƒ‹ƒtƒ‰ƒO
attr_accessor :animation_id # ƒAƒjƒ[ƒVƒ‡ƒ“ ID
attr_accessor :animation_hit # ƒAƒjƒ[ƒVƒ‡ƒ“ ƒqƒbƒgƒtƒ‰ƒO
attr_accessor :white_flash # ”’ƒtƒ‰ƒbƒVƒ…ƒtƒ‰ƒO
attr_accessor :blink # –¾–Ńtƒ‰ƒO
#------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»
#------------------------------------------
def initialize
@battler_name = ""
@battler_hue = 0
@hp = 0
@sp = 0
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
@hidden = false
@immortal = false
@damage_pop = false
@damage = nil
@critical = false
@animation_id = 0
@animation_hit = false
@white_flash = false
@blink = false
@current_action = Game_BattleAction.new
end
#------------------------------------------
# œ MaxHP ‚̎擾
#------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, 999999].min
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, 999999].min
return n
end
#------------------------------------------
# œ MaxSP ‚̎擾
#------------------------------------------
def maxsp
n = [[base_maxsp + @maxsp_plus, 0].max, 9999].min
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
n = [[Integer(n), 0].max, 9999].min
return n
end
#------------------------------------------
# œ ˜r—͂̎擾
#------------------------------------------
def str
n = [[base_str + @str_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].str_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#------------------------------------------
# œ Ší—p‚³‚̎擾
#------------------------------------------
def dex
n = [[base_dex + @dex_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].dex_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#------------------------------------------
# œ ‘f‘‚³‚̎擾
#------------------------------------------
def agi
n = [[base_agi + @agi_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].agi_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#------------------------------------------
# œ –‚—͂̎擾
#------------------------------------------
def int
n = [[base_int + @int_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].int_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#------------------------------------------
# œ MaxHP ‚̐ݒè
# maxhp : V‚µ‚¢ MaxHP
#------------------------------------------
def maxhp=(maxhp)
@maxhp_plus += maxhp - self.maxhp
@maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min
@hp = [@hp, self.maxhp].min
end
#------------------------------------------
# œ MaxSP ‚̐ݒè
# maxsp : V‚µ‚¢ MaxSP
#------------------------------------------
def maxsp=(maxsp)
@maxsp_plus += maxsp - self.maxsp
@maxsp_plus = [[@maxsp_plus, -9999].max, 9999].min
@sp = [@sp, self.maxsp].min
end
#------------------------------------------
# œ ˜r—͂̐ݒè
# str : V‚µ‚¢˜r—Í
#------------------------------------------
def str=(str)
@str_plus += str - self.str
@str_plus = [[@str_plus, -999].max, 999].min
end
#------------------------------------------
# œ Ší—p‚³‚̐ݒè
# dex : V‚µ‚¢Ší—p‚³
#------------------------------------------
def dex=(dex)
@dex_plus += dex - self.dex
@dex_plus = [[@dex_plus, -999].max, 999].min
end
#------------------------------------------
# œ ‘f‘‚³‚̐ݒè
# agi : V‚µ‚¢‘f‘‚³
#------------------------------------------
def agi=(agi)
@agi_plus += agi - self.agi
@agi_plus = [[@agi_plus, -999].max, 999].min
end
#------------------------------------------
# œ –‚—͂̐ݒè
# int : V‚µ‚¢–‚—Í
#------------------------------------------
def int=(int)
@int_plus += int - self.int
@int_plus = [[@int_plus, -999].max, 999].min
end
#------------------------------------------
# œ –½’†—¦‚̎擾
#------------------------------------------
def hit
n = 100
for i in @states
n *= $data_states[i].hit_rate / 100.0
end
return Integer(n)
end
#------------------------------------------
# œ UŒ‚—͂̎擾
#------------------------------------------
def atk
n = base_atk
for i in @states
n *= $data_states[i].atk_rate / 100.0
end
return Integer(n)
end
#------------------------------------------
# œ •¨—–hŒä‚̎擾
#------------------------------------------
def pdef
n = base_pdef
for i in @states
n *= $data_states[i].pdef_rate / 100.0
end
return Integer(n)
end
#------------------------------------------
# œ –‚–@–hŒä‚̎擾
#------------------------------------------
def mdef
n = base_mdef
for i in @states
n *= $data_states[i].mdef_rate / 100.0
end
return Integer(n)
end
#------------------------------------------
# œ ‰ñ”ðC³‚̎擾
#------------------------------------------
def eva
n = base_eva
for i in @states
n += $data_states[i].eva
end
return n
end
#------------------------------------------
# œ HP ‚̕ύX
# hp : V‚µ‚¢ HP
#------------------------------------------
def hp=(hp)
@hp = [[hp, maxhp].min, 0].max
# í“¬•s”‚ð•t‰Á‚Ü‚½‚͉ðœ
for i in 1...$data_states.size
if $data_states[i].zero_hp
if self.dead?
add_state(i)
else
remove_state(i)
end
end
end
end
#------------------------------------------
# œ SP ‚̕ύX
# sp : V‚µ‚¢ SP
#------------------------------------------
def sp=(sp)
@sp = [[sp, maxsp].min, 0].max
end
#------------------------------------------
# œ ‘S‰ñ•œ
#------------------------------------------
def recover_all
@hp = maxhp
@sp = maxsp
for i in @states.clone
remove_state(i)
end
end
#------------------------------------------
# œ ƒJƒŒƒ“ƒgƒAƒNƒVƒ‡ƒ“‚̎擾
#------------------------------------------
def current_action
return @current_action
end
#------------------------------------------
# œ ƒAƒNƒVƒ‡ƒ“ƒXƒs[ƒh‚ÌŒˆ’è
#------------------------------------------
def make_action_speed
@current_action.speed = agi + rand(10 + agi / 4)
end
#------------------------------------------
# œ í“¬•s””»’è
#------------------------------------------
def dead?
return (@hp == 0 and not @immortal)
end
#------------------------------------------
# œ ‘¶Ý”»’è
#------------------------------------------
def exist?
return (not @hidden and (@hp > 0 or @immortal))
end
#------------------------------------------
# œ HP 0 ”»’è
#------------------------------------------
def hp0?
return (not @hidden and @hp == 0)
end
#------------------------------------------
# œ ƒRƒ}ƒ“ƒh“ü—͉””»’è
#------------------------------------------
def inputable?
return (not @hidden and restriction <= 1)
end
#------------------------------------------
# œ s“®‰Â””»’è
#------------------------------------------
def movable?
return (not @hidden and restriction < 4)
end
#------------------------------------------
# œ –hŒä’†”»’è
#------------------------------------------
def guarding?
return (@current_action.kind == 0 and @current_action.basic == 1)
end
#------------------------------------------
# œ ‹xŽ~’†”»’è
#------------------------------------------
def resting?
return (@current_action.kind == 0 and @current_action.basic == 3)
end
end

Publié dans poubelle

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article