~Site
¤Accueil
¤Forum
¤Admin

~Base de scripts
¤Scripts de base
¤Scripts Menu
¤Scripts Combat
¤Scripts Système
¤Scripts Modifiés

Scripts de Base
Game_Temp
Game_System
Game_Switches
Game_Variables
Game_SelfSwitches
Game_Screen
Game_Picture
Game_Battler 1
Game_Battler 2
Game_Battler 3
Game_BattleAction
Game_Actor
Game_Enemy
Game_Actors
Game_Party
Game_Troop
Game_Map
Game_CommonEvent
Game_Character 1
Game_Character 2
Game_Character 3
Game_Event
Game_Player
Sprite_Character
Sprite_Battler
Sprite_Picture
Sprite_Timer
Spriteset_Map
Spriteset_Battle
Window_Base
Window_Selectable
Window_Command
Window_Help
Window_Gold
Window_PlayTime
Window_Steps
Window_MenuStatus
Window_Item
Window_Skill
Window_SkillStatus
Window_Target
Window_EquipLeft
Window_EquipRight
Window_EquipItem
Window_Status
Window_SaveFile
Window_ShopCommand
Window_ShopBuy
Window_ShopSell
Window_ShopNumber
Window_ShopStatus
Window_NameEdit
Window_NameInput
Window_InputNumber
Window_Message
Window_PartyCommand
Window_BattleStatus
Window_BattleResult
Window_DebugLeft
Window_DebugRight
Window_Dataset
Arrow_Base
Arrow_Enemy
Arrow_Actor
Interpreter 1
Interpreter 2
Interpreter 3
Interpreter 4
Interpreter 5
Interpreter 6
Interpreter 7
Scene_Title
Scene_Map
Scene_Menu
Scene_Item
Scene_Skill
Scene_Equip
Scene_Status
Scene_File
Scene_Save
Scene_Load
Scene_End
Scene_Battle 1
Scene_Battle 2
Scene_Battle 3
Scene_Battle 4
Scene_Shop
Scene_Name
Scene_Gameover
Scene_Debug
Main


Game_Character 3 ::: posté le 2006-02-16 @ 09:36:00
Auteur: Yukihiro matsumoto

#============================================
# ¡ Game_Character (•ªŠ„’è‹` 3)
#----------------------------------------------
# @ƒLƒƒƒ‰ƒNƒ^[‚ðˆµ‚¤ƒNƒ‰ƒX‚Å‚·B‚±‚̃Nƒ‰ƒX‚Í Game_Player ƒNƒ‰ƒX‚Æ Game_Event
# ƒNƒ‰ƒX‚̃X[ƒp[ƒNƒ‰ƒX‚Æ‚µ‚ÄŽg—p‚³‚ê‚Ü‚·B
#============================================

class Game_Character
#------------------------------------------
# œ ‰º‚Ɉړ®
# turn_enabled : ‚»‚Ìê‚ł̌ü‚«•ÏX‚ð‹–‰Â‚·‚éƒtƒ‰ƒO
#------------------------------------------
def move_down(turn_enabled = true)
# ‰º‚ðŒü‚­
if turn_enabled
turn_down
end
# ’Ês‰Â”‚Èê‡
if passable?(@x, @y, 2)
# ‰º‚ðŒü‚­
turn_down
# À•W‚ðXV
@y += 1
# •à”‘‰Á
increase_steps
# ’Ês•s‰Â”‚Èê‡
else
# ÚGƒCƒxƒ“ƒg‚Ì‹N“®”»’è
check_event_trigger_touch(@x, @y+1)
end
end
#------------------------------------------
# œ ¶‚Ɉړ®
# turn_enabled : ‚»‚Ìê‚ł̌ü‚«•ÏX‚ð‹–‰Â‚·‚éƒtƒ‰ƒO
#------------------------------------------
def move_left(turn_enabled = true)
# ¶‚ðŒü‚­
if turn_enabled
turn_left
end
# ’Ês‰Â”‚Èê‡
if passable?(@x, @y, 4)
# ¶‚ðŒü‚­
turn_left
# À•W‚ðXV
@x -= 1
# •à”‘‰Á
increase_steps
# ’Ês•s‰Â”‚Èê‡
else
# ÚGƒCƒxƒ“ƒg‚Ì‹N“®”»’è
check_event_trigger_touch(@x-1, @y)
end
end
#------------------------------------------
# œ ‰E‚Ɉړ®
# turn_enabled : ‚»‚Ìê‚ł̌ü‚«•ÏX‚ð‹–‰Â‚·‚éƒtƒ‰ƒO
#------------------------------------------
def move_right(turn_enabled = true)
# ‰E‚ðŒü‚­
if turn_enabled
turn_right
end
# ’Ês‰Â”‚Èê‡
if passable?(@x, @y, 6)
# ‰E‚ðŒü‚­
turn_right
# À•W‚ðXV
@x += 1
# •à”‘‰Á
increase_steps
# ’Ês•s‰Â”‚Èê‡
else
# ÚGƒCƒxƒ“ƒg‚Ì‹N“®”»’è
check_event_trigger_touch(@x+1, @y)
end
end
#------------------------------------------
# œ ã‚Ɉړ®
# turn_enabled : ‚»‚Ìê‚ł̌ü‚«•ÏX‚ð‹–‰Â‚·‚éƒtƒ‰ƒO
#------------------------------------------
def move_up(turn_enabled = true)
# ã‚ðŒü‚­
if turn_enabled
turn_up
end
# ’Ês‰Â”‚Èê‡
if passable?(@x, @y, 8)
# ã‚ðŒü‚­
turn_up
# À•W‚ðXV
@y -= 1
# •à”‘‰Á
increase_steps
# ’Ês•s‰Â”‚Èê‡
else
# ÚGƒCƒxƒ“ƒg‚Ì‹N“®”»’è
check_event_trigger_touch(@x, @y-1)
end
end
#------------------------------------------
# œ ¶‰º‚Ɉړ®
#------------------------------------------
def move_lower_left
# Œü‚«ŒÅ’è‚łȂ¢ê‡
unless @direction_fix
# ‰EŒü‚«‚¾‚Á‚½ê‡‚Ͷ‚ðAãŒü‚«‚¾‚Á‚½ê‡‚͉º‚ðŒü‚­
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
# ‰º¨¶A¶¨‰º ‚̂ǂ¿‚ç‚©‚̃R[ƒX‚ª’Ês‰Â”‚Èê‡
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# À•W‚ðXV
@x -= 1
@y += 1
# •à”‘‰Á
increase_steps
end
end
#------------------------------------------
# œ ‰E‰º‚Ɉړ®
#------------------------------------------
def move_lower_right
# Œü‚«ŒÅ’è‚łȂ¢ê‡
unless @direction_fix
# ¶Œü‚«‚¾‚Á‚½ê‡‚͉E‚ðAãŒü‚«‚¾‚Á‚½ê‡‚͉º‚ðŒü‚­
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
# ‰º¨‰EA‰E¨‰º ‚̂ǂ¿‚ç‚©‚̃R[ƒX‚ª’Ês‰Â”‚Èê‡
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# À•W‚ðXV
@x += 1
@y += 1
# •à”‘‰Á
increase_steps
end
end
#------------------------------------------
# œ ¶ã‚Ɉړ®
#------------------------------------------
def move_upper_left
# Œü‚«ŒÅ’è‚łȂ¢ê‡
unless @direction_fix
# ‰EŒü‚«‚¾‚Á‚½ê‡‚Ͷ‚ðA‰ºŒü‚«‚¾‚Á‚½ê‡‚Íã‚ðŒü‚­
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
# 㨶A¶¨ã ‚̂ǂ¿‚ç‚©‚̃R[ƒX‚ª’Ês‰Â”‚Èê‡
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# À•W‚ðXV
@x -= 1
@y -= 1
# •à”‘‰Á
increase_steps
end
end
#------------------------------------------
# œ ‰Eã‚Ɉړ®
#------------------------------------------
def move_upper_right
# Œü‚«ŒÅ’è‚łȂ¢ê‡
unless @direction_fix
# ¶Œü‚«‚¾‚Á‚½ê‡‚͉E‚ðA‰ºŒü‚«‚¾‚Á‚½ê‡‚Íã‚ðŒü‚­
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
# 㨉EA‰E¨ã ‚̂ǂ¿‚ç‚©‚̃R[ƒX‚ª’Ês‰Â”‚Èê‡
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# À•W‚ðXV
@x += 1
@y -= 1
# •à”‘‰Á
increase_steps
end
end
#------------------------------------------
# œ ƒ‰ƒ“ƒ_ƒ€‚Ɉړ®
#------------------------------------------
def move_random
case rand(4)
when 0 # ‰º‚Ɉړ®
move_down(false)
when 1 # ¶‚Ɉړ®
move_left(false)
when 2 # ‰E‚Ɉړ®
move_right(false)
when 3 # ã‚Ɉړ®
move_up(false)
end
end
#------------------------------------------
# œ ƒvƒŒƒCƒ„[‚ɋ߂­
#------------------------------------------
def move_toward_player
# ƒvƒŒƒCƒ„[‚ÌÀ•W‚Ƃ̷‚ð‹‚ß‚é
sx = @x - $game_player.x
sy = @y - $game_player.y
# À•W‚ª“™‚µ‚¢ê‡
if sx == 0 and sy == 0
return
end
# ·‚Ìâ‘Î’l‚ð‹‚ß‚é
abs_sx = sx.abs
abs_sy = sy.abs
# ‰¡‚Ì‹——£‚Æc‚Ì‹——£‚ª“™‚µ‚¢ê‡
if abs_sx == abs_sy
# ƒ‰ƒ“ƒ_ƒ€‚łǂ¿‚ç‚©‚ð 1 ‘‚â‚·
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# ‰¡‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
if abs_sx > abs_sy
# ¶‰E•ûŒü‚ð—D悵AƒvƒŒƒCƒ„[‚Ì‚¢‚é‚Ù‚¤‚ÖˆÚ“®
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
# c‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
else
# ㉺•ûŒü‚ð—D悵AƒvƒŒƒCƒ„[‚Ì‚¢‚é‚Ù‚¤‚ÖˆÚ“®
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
#------------------------------------------
# œ ƒvƒŒƒCƒ„[‚©‚牓‚´‚©‚é
#------------------------------------------
def move_away_from_player
# ƒvƒŒƒCƒ„[‚ÌÀ•W‚Ƃ̷‚ð‹‚ß‚é
sx = @x - $game_player.x
sy = @y - $game_player.y
# À•W‚ª“™‚µ‚¢ê‡
if sx == 0 and sy == 0
return
end
# ·‚Ìâ‘Î’l‚ð‹‚ß‚é
abs_sx = sx.abs
abs_sy = sy.abs
# ‰¡‚Ì‹——£‚Æc‚Ì‹——£‚ª“™‚µ‚¢ê‡
if abs_sx == abs_sy
# ƒ‰ƒ“ƒ_ƒ€‚łǂ¿‚ç‚©‚ð 1 ‘‚â‚·
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# ‰¡‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
if abs_sx > abs_sy
# ¶‰E•ûŒü‚ð—D悵AƒvƒŒƒCƒ„[‚Ì‚¢‚È‚¢‚Ù‚¤‚ÖˆÚ“®
sx > 0 ? move_right : move_left
if not moving? and sy != 0
sy > 0 ? move_down : move_up
end
# c‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
else
# ㉺•ûŒü‚ð—D悵AƒvƒŒƒCƒ„[‚Ì‚¢‚È‚¢‚Ù‚¤‚ÖˆÚ“®
sy > 0 ? move_down : move_up
if not moving? and sx != 0
sx > 0 ? move_right : move_left
end
end
end
#------------------------------------------
# œ ˆê•à‘Oi
#------------------------------------------
def move_forward
case @direction
when 2
move_down(false)
when 4
move_left(false)
when 6
move_right(false)
when 8
move_up(false)
end
end
#------------------------------------------
# œ ˆê•àŒã‘Þ
#------------------------------------------
def move_backward
# Œü‚«ŒÅ’è‚Ìó‘Ô‚ð‹L‰¯
last_direction_fix = @direction_fix
# ‹­§“I‚ÉŒü‚«ŒÅ’è
@direction_fix = true
# Œü‚«‚Å•ªŠò
case @direction
when 2 # ‰º
move_up(false)
when 4 # ¶
move_right(false)
when 6 # ‰E
move_left(false)
when 8 # ã
move_down(false)
end
# Œü‚«ŒÅ’è‚Ìó‘Ô‚ðŒ³‚É–ß‚·
@direction_fix = last_direction_fix
end
#------------------------------------------
# œ ƒWƒƒƒ“ƒv
# x_plus : X À•W‰ÁŽZ’l
# y_plus : Y À•W‰ÁŽZ’l
#------------------------------------------
def jump(x_plus, y_plus)
# ‰ÁŽZ’l‚ª (0,0) ‚ł͂Ȃ¢ê‡
if x_plus != 0 or y_plus != 0
# ‰¡‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
if x_plus.abs > y_plus.abs
# ¶‰E‚Ç‚¿‚ç‚©‚ÉŒü‚«•ÏX
x_plus < 0 ? turn_left : turn_right
# c‚Ì‹——£‚̂ق¤‚ª’·‚¢‚©“™‚µ‚¢ê‡
else
# ㉺‚Ç‚¿‚ç‚©‚ÉŒü‚«•ÏX
y_plus < 0 ? turn_up : turn_down
end
end
# V‚µ‚¢À•W‚ðŒvŽZ
new_x = @x + x_plus
new_y = @y + y_plus
# ‰ÁŽZ’l‚ª (0,0) ‚Ìꇂ©AƒWƒƒƒ“ƒv悪’Ês‰Â”‚Èê‡
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
# Žp¨‚ð‹¸³
straighten
# À•W‚ðXV
@x = new_x
@y = new_y
# ‹——£‚ðŒvŽZ
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
# ƒWƒƒƒ“ƒvƒJƒEƒ“ƒg‚ðÝ’è
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
# ’âŽ~ƒJƒEƒ“ƒg‚ðƒNƒŠƒA
@stop_count = 0
end
end
#------------------------------------------
# œ ‰º‚ðŒü‚­
#------------------------------------------
def turn_down
unless @direction_fix
@direction = 2
@stop_count = 0
end
end
#------------------------------------------
# œ ¶‚ðŒü‚­
#------------------------------------------
def turn_left
unless @direction_fix
@direction = 4
@stop_count = 0
end
end
#------------------------------------------
# œ ‰E‚ðŒü‚­
#------------------------------------------
def turn_right
unless @direction_fix
@direction = 6
@stop_count = 0
end
end
#------------------------------------------
# œ ã‚ðŒü‚­
#------------------------------------------
def turn_up
unless @direction_fix
@direction = 8
@stop_count = 0
end
end
#------------------------------------------
# œ ‰E‚É 90 “x‰ñ“]
#------------------------------------------
def turn_right_90
case @direction
when 2
turn_left
when 4
turn_up
when 6
turn_down
when 8
turn_right
end
end
#------------------------------------------
# œ ¶‚É 90 “x‰ñ“]
#------------------------------------------
def turn_left_90
case @direction
when 2
turn_right
when 4
turn_down
when 6
turn_up
when 8
turn_left
end
end
#------------------------------------------
# œ 180 “x‰ñ“]
#------------------------------------------
def turn_180
case @direction
when 2
turn_up
when 4
turn_right
when 6
turn_left
when 8
turn_down
end
end
#------------------------------------------
# œ ‰E‚©¶‚É 90 “x‰ñ“]
#------------------------------------------
def turn_right_or_left_90
if rand(2) == 0
turn_right_90
else
turn_left_90
end
end
#------------------------------------------
# œ ƒ‰ƒ“ƒ_ƒ€‚É•ûŒü“]Š·
#------------------------------------------
def turn_random
case rand(4)
when 0
turn_up
when 1
turn_right
when 2
turn_left
when 3
turn_down
end
end
#------------------------------------------
# œ ƒvƒŒƒCƒ„[‚Ì•û‚ðŒü‚­
#------------------------------------------
def turn_toward_player
# ƒvƒŒƒCƒ„[‚ÌÀ•W‚Ƃ̷‚ð‹‚ß‚é
sx = @x - $game_player.x
sy = @y - $game_player.y
# À•W‚ª“™‚µ‚¢ê‡
if sx == 0 and sy == 0
return
end
# ‰¡‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
if sx.abs > sy.abs
# ¶‰E•ûŒü‚ŃvƒŒƒCƒ„[‚Ì‚¢‚é‚Ù‚¤‚ðŒü‚­
sx > 0 ? turn_left : turn_right
# c‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
else
# ㉺•ûŒü‚ŃvƒŒƒCƒ„[‚Ì‚¢‚é‚Ù‚¤‚ðŒü‚­
sy > 0 ? turn_up : turn_down
end
end
#------------------------------------------
# œ ƒvƒŒƒCƒ„[‚Ì‹t‚ðŒü‚­
#------------------------------------------
def turn_away_from_player
# ƒvƒŒƒCƒ„[‚ÌÀ•W‚Ƃ̷‚ð‹‚ß‚é
sx = @x - $game_player.x
sy = @y - $game_player.y
# À•W‚ª“™‚µ‚¢ê‡
if sx == 0 and sy == 0
return
end
# ‰¡‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
if sx.abs > sy.abs
# ¶‰E•ûŒü‚ŃvƒŒƒCƒ„[‚Ì‚¢‚È‚¢‚Ù‚¤‚ðŒü‚­
sx > 0 ? turn_right : turn_left
# c‚Ì‹——£‚̂ق¤‚ª’·‚¢ê‡
else
# ㉺•ûŒü‚ŃvƒŒƒCƒ„[‚Ì‚¢‚È‚¢‚Ù‚¤‚ðŒü‚­
sy > 0 ? turn_down : turn_up
end
end
end
Design By RaZ © Watery Build 2005