想請問...能否幫忙 合成個腳本...
2 posters
想請問...能否幫忙 合成個腳本...
小弟在此想請問各位大大,讓 行走畫格更改 以及 待機動作 兩個腳本 解決衝突.....
以下為兩個腳本....
懇請各位大大幫忙一下.....
以下為兩個腳本....
- 代碼:
#==============================================================================
# ■ 角色待機小動畫1.2版 BY 億萬星辰
#------------------------------------------------------------------------------
# 更新了對移動事件的相容性,同時對演算法進行優化……。
#
# 使用說明:
#
# 可讓角色在地圖上經過一定時間不移動時,做出些小動作,比如撓頭,喘氣等等……
#
# 設置方法:
#
# 1、給下面的TIME_LIMIT常量設置一個值,大小可能不好拿捏,200可能就比較正常
# 最小值為1,瞬間發威。 ___Drz
#
# 2、在Graphics/Characters目錄下放置一個角色行走圖檔案名+"_W"的檔,如角色行
# 走圖為“001-Fighter01”,則許放置一個名為“001-Fighter01_W”的檔,其中就
# 是該角色的待機小動畫。(默認為4幀,如果角色不夠可自行對相關類中方法進行擴展)
#
# 更新記錄:
#
# 2006.5.27 1.2版更新
#
# 2006.1.28 1.1版更新 修正了替換隊員時的BUG。
#
# 2005.12.20 初版。
#==============================================================================
class Game_Player < Game_Character
#=======================================#
TIME_LIMIT = 1 # 抓耳撓腮前的等待時間 |
#=======================================#
attr_reader :time
def initialize
super
@time = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的檔案名及對像
@character_name = ""
@character_hue = 0
# 分支結束
return
end
# 獲取帶頭的角色
actor = $game_party.actors[0]
# 設置角色的檔案名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
@old_pic = @character_name
@time = 0
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
# 本地變數記錄移動資訊
last_moving = moving?
if @time == TIME_LIMIT
@character_name = @character_name + "-W"
@scratch = true
@step_anime = true
@time = TIME_LIMIT + 1
elsif @time < TIME_LIMIT
@scratch = false
@step_anime = false
end
# 移動中、事件執行中、強制移動路線中、
# 資訊視窗一個也不顯示的時候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向鍵被按下、主角就朝那個方向移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地變數記憶座標
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移動、畫面上的位置在中央下方的情況下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 畫面向下捲動
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移動、畫面上的位置在中央左方的情況下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 畫面向左捲動
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移動、畫面上的位置在中央右方的情況下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 畫面向右捲動
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移動、畫面上的位置在中央上方的情況下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 畫面向上捲動
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移動中的情況下
unless moving?
@time += 1 if @time < TIME_LIMIT
# 上次主角移動中的情況
if last_moving
# 與同位置的事件接觸就判定為事件啟動
result = check_event_trigger_here([1,2])
# 沒有可以啟動的事件的情況下
if result == false
# 調試模式為 ON 並且按下 CTRL 鍵的情況下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敵計數下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 判定為同位置以及正面的事件啟動
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
#--------------------------------------------------------------------------
# ● 向下移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 面向下
if turn_enabled
turn_down
end
# 可以通行的場合
if passable?(@x, @y, 2)
# 面向下
turn_down
# 更新座標
@y += 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y+1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 面向左
if turn_enabled
turn_left
end
# 可以通行的情況下
if passable?(@x, @y, 4)
# 面向左
turn_left
# 更新座標
@x -= 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x-1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 面向右
if turn_enabled
turn_right
end
# 可以通行的場合
if passable?(@x, @y, 6)
# 面向右
turn_right
# 更新座標
@x += 1
# 增加部數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x+1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向上移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 面向上
if turn_enabled
turn_up
end
# 可以通行的情況下
if passable?(@x, @y, 8)
# 面向上
turn_up
# 更新座標
@y -= 1
# 歩數増加
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y-1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左下移動
#--------------------------------------------------------------------------
def move_lower_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
# 下→左、左→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# 更新座標
@x -= 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右下移動
#--------------------------------------------------------------------------
def move_lower_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
# 下→右、右→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# 更新座標
@x += 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左上移動
#--------------------------------------------------------------------------
def move_upper_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
# 上→左、左→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# 更新座標
@x -= 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右上移動
#--------------------------------------------------------------------------
def move_upper_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
# 上→右、右→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# 更新座標
@x += 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
end
- 代碼:
#========================================
# 本腳本來自www.66rpg.com
#========================================
class Game_Character
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
# 跳躍中、移動中、停止中的分支
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# 動畫計數超過最大值的情況下
# ※最大值等於基本值減去移動速度 * 1 的值
if @anime_count > 16 - @move_speed * 2
# 停止動畫為 OFF 並且在停止中的情況下
if not @step_anime and @stop_count > 0
# 還原為原來的圖形
@pattern = @original_pattern
# 停止動畫為 ON 並且在移動中的情況下
else
# 更新圖形
fps = @character_name.split(/_/)[1] != nil ? @character_name.split(/_/)[1].to_i : 6
@pattern = (@pattern + 1) % fps
end
# 清除動畫計數
@anime_count = 0
end
# 等待中的情況下
if @wait_count > 0
# 減少等待計數
@wait_count -= 1
return
end
# 強制移動路線的場合
if @move_route_forcing
# 自定義移動
move_type_custom
return
end
# 事件執行待機中並且為鎖定狀態的情況下
if @starting or lock?
# 不做規則移動
return
end
# 如果停止計數超過了一定的值(由移動頻度算出)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# 移動類型分支
case @move_type
when 1 # 隨機
move_type_random
when 2 # 接近
move_type_toward_player
when 3 # 自定義
move_type_custom
end
end
end
end
#===============================================
# ■ Sprite_Character
#-------------------------------------------------
# 角色顯示用腳本。監視 Game_Character 類的實例、
# 自動變化腳本狀態。
#===============================================
class Sprite_Character < RPG::Sprite
#---------------------------------------
# ● 更新畫面
#-----------------------------------------
def update
super
# 元件 ID、檔案名、色相與現在的情況存在差異的情況下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 記憶元件 ID 與檔案名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 為有效值的情況下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 為無效值的情況下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
fps = @character.character_name.split(/_/)[1] != nil ? @character.character_name.split(/_/)[1].to_i : 4
@cw = bitmap.width / fps
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 設置可視狀態
self.visible = (not @character.transparent)
# 圖形是角色的情況下
if @tile_id == 0
# 設置傳送目標的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 設置腳本的座標
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 設置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 動畫
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
懇請各位大大幫忙一下.....
omgezero- 賣彩色內褲的小鱉三
- 文章數 : 3
注冊日期 : 2008-09-25
回復: 想請問...能否幫忙 合成個腳本...
omgezero 寫到:小弟在此想請問各位大大,讓 行走畫格更改 以及 待機動作 兩個腳本 解決衝突.....
懇請各位大大幫忙一下.....
基本上沒什麼大問題啊....以行走畫格更改來說如果你是用6格去跑那麼待機圖你也要做成6*4的規格(內建是4*4)
但是腳本還是幫忙你做了一些小修改
待機圖還是一樣用4*4去做但行走時就能依據你設定的行走畫格數去跑
- 代碼:
#==============================================================================
# ■ 角色待機小動畫1.2版 BY 億萬星辰
#------------------------------------------------------------------------------
# 更新了對移動事件的相容性,同時對演算法進行優化……。
#
# 使用說明:
#
# 可讓角色在地圖上經過一定時間不移動時,做出些小動作,比如撓頭,喘氣等等……
#
# 設置方法:
#
# 1、給下面的TIME_LIMIT常量設置一個值,大小可能不好拿捏,200可能就比較正常
# 最小值為1,瞬間發威。 ___Drz
#
# 2、在Graphics/Characters目錄下放置一個角色行走圖檔案名+"_W"的檔,如角色行
# 走圖為“001-Fighter01”,則許放置一個名為“001-Fighter01_W”的檔,其中就
# 是該角色的待機小動畫。(默認為4幀,如果角色不夠可自行對相關類中方法進行擴展)
#
# 更新記錄:
#
# 2006.5.27 1.2版更新
#
# 2006.1.28 1.1版更新 修正了替換隊員時的BUG。
#
# 2005.12.20 初版。
#==============================================================================
class Game_Player < Game_Character
#=======================================#
TIME_LIMIT = 100 # 抓耳撓腮前的等待時間 |
#=======================================#
attr_reader :time
attr_reader :scratch
def initialize
super
@time = 0
@scratch = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的檔案名及對像
@character_name = ""
@character_hue = 0
# 分支結束
return
end
# 獲取帶頭的角色
actor = $game_party.actors[0]
# 設置角色的檔案名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
@old_pic = @character_name
@time = 0
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
# 本地變數記錄移動資訊
last_moving = moving?
# 獲取帶頭的角色
actor = $game_party.actors[0]
actor_name = actor != nil ? actor.character_name : ""
if @time == TIME_LIMIT
@scratch = true
@character_name = actor_name + "-W"
@step_anime = true
@time = TIME_LIMIT + 1
elsif @time < TIME_LIMIT
@scratch = false
@character_name = actor_name if @character_name != actor_name
@step_anime = false
end
# 移動中、事件執行中、強制移動路線中、
# 資訊視窗一個也不顯示的時候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向鍵被按下、主角就朝那個方向移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地變數記憶座標
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移動、畫面上的位置在中央下方的情況下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 畫面向下捲動
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移動、畫面上的位置在中央左方的情況下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 畫面向左捲動
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移動、畫面上的位置在中央右方的情況下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 畫面向右捲動
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移動、畫面上的位置在中央上方的情況下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 畫面向上捲動
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移動中的情況下
unless moving?
@time += 1 if @time < TIME_LIMIT
# 上次主角移動中的情況
if last_moving
# 與同位置的事件接觸就判定為事件啟動
result = check_event_trigger_here([1,2])
# 沒有可以啟動的事件的情況下
if result == false
# 調試模式為 ON 並且按下 CTRL 鍵的情況下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敵計數下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 判定為同位置以及正面的事件啟動
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
#--------------------------------------------------------------------------
# ● 向下移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 面向下
if turn_enabled
turn_down
end
# 可以通行的場合
if passable?(@x, @y, 2)
# 面向下
turn_down
# 更新座標
@y += 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y+1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 面向左
if turn_enabled
turn_left
end
# 可以通行的情況下
if passable?(@x, @y, 4)
# 面向左
turn_left
# 更新座標
@x -= 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x-1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 面向右
if turn_enabled
turn_right
end
# 可以通行的場合
if passable?(@x, @y, 6)
# 面向右
turn_right
# 更新座標
@x += 1
# 增加部數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x+1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向上移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 面向上
if turn_enabled
turn_up
end
# 可以通行的情況下
if passable?(@x, @y, 8)
# 面向上
turn_up
# 更新座標
@y -= 1
# 歩數増加
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y-1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左下移動
#--------------------------------------------------------------------------
def move_lower_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
# 下→左、左→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# 更新座標
@x -= 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右下移動
#--------------------------------------------------------------------------
def move_lower_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
# 下→右、右→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# 更新座標
@x += 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左上移動
#--------------------------------------------------------------------------
def move_upper_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
# 上→左、左→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# 更新座標
@x -= 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右上移動
#--------------------------------------------------------------------------
def move_upper_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
# 上→右、右→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# 更新座標
@x += 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
end
#========================================
# 本腳本來自www.66rpg.com
#========================================
class Game_Character
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
# 跳躍中、移動中、停止中的分支
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# 動畫計數超過最大值的情況下
# ※最大值等於基本值減去移動速度 * 1 的值
if @anime_count > 16 - @move_speed * 2
# 停止動畫為 OFF 並且在停止中的情況下
if not @step_anime and @stop_count > 0
# 還原為原來的圖形
@pattern = @original_pattern
# 停止動畫為 ON 並且在移動中的情況下
else
fps_change = true
if self.is_a?(Game_Player)
fps_change = self.scratch ? false : true
end
if fps_change
# 更新圖形
fps = @character_name.split(/_/)[1] != nil ? @character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@pattern = (@pattern + 1) % fps
end
# 清除動畫計數
@anime_count = 0
end
# 等待中的情況下
if @wait_count > 0
# 減少等待計數
@wait_count -= 1
return
end
# 強制移動路線的場合
if @move_route_forcing
# 自定義移動
move_type_custom
return
end
# 事件執行待機中並且為鎖定狀態的情況下
if @starting or lock?
# 不做規則移動
return
end
# 如果停止計數超過了一定的值(由移動頻度算出)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# 移動類型分支
case @move_type
when 1 # 隨機
move_type_random
when 2 # 接近
move_type_toward_player
when 3 # 自定義
move_type_custom
end
end
end
end
#===============================================
# ■ Sprite_Character
#-------------------------------------------------
# 角色顯示用腳本。監視 Game_Character 類的實例、
# 自動變化腳本狀態。
#===============================================
class Sprite_Character < RPG::Sprite
#---------------------------------------
# ● 更新畫面
#-----------------------------------------
def update
super
# 元件 ID、檔案名、色相與現在的情況存在差異的情況下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 記憶元件 ID 與檔案名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 為有效值的情況下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 為無效值的情況下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
fps_change = true
if @character.is_a?(Game_Player)
fps_change = @character.scratch ? false : true
end
if fps_change
fps = @character.character_name.split(/_/)[1] != nil ? @character.character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@cw = bitmap.width / fps
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 設置可視狀態
self.visible = (not @character.transparent)
# 圖形是角色的情況下
if @tile_id == 0
# 設置傳送目標的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 設置腳本的座標
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 設置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 動畫
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
想請問...能否幫忙 合成個腳本...
恩..........如果要讓領隊切換的時候....把他改成待機的圖片 再移動時 在改為行走圖怎作呢... 我試過後 就出錯了
- 代碼:
#------------------------------------------------------------------------------
# 添加此腳本後,在地圖畫面按下X鍵更換當前的領隊。
# 領隊更改不會造成戰鬥隊伍、菜單隊伍次序的更改。
# 領隊的ID可以在第「ID」號的變量中取得(不再使用序列好了)
#==============================================================================
class Game_Player < Game_Character
ID = 5
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的檔案名及對像
@character_name = ""
@character_hue = 0
$game_variables[ID] = 0 unless ID.zero?
# 分支結束
return
end
if @leader_id.nil? or $game_party.actors[@leader_id].nil?
# 獲取帶頭的角色
actor = $game_party.actors[0]
@leader_id = 0
else
# 獲取帶頭的角色
actor = $game_party.actors[@leader_id]
end
$game_variables[ID] = $game_party.actors[@leader_id].id unless ID.zero?
# 設置角色的檔案名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
alias oir_update update
def update
# 按下 X 鍵的情況下
if Kboard.trigger?($R_Key_A)
@leader_id += 1
@leader_id = 0 if $game_party.actors[@leader_id].nil?
refresh
end
oir_update
end
end
omgezero- 賣彩色內褲的小鱉三
- 文章數 : 3
注冊日期 : 2008-09-25
回復: 想請問...能否幫忙 合成個腳本...
omgezero 寫到:恩..........如果要讓領隊切換的時候....把他改成待機的圖片 再移動時 在改為行走圖怎作呢... 我試過後 就出錯了
以下為整合修改版
- 代碼:
class Game_Player < Game_Character
#=======================================#
TIME_LIMIT = 100 # 抓耳撓腮前的等待時間 |
ID = 5
#=======================================#
attr_reader :time
attr_reader :scratch
def initialize
super
@time = 0
@scratch = false
@leader_id = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的檔案名及對像
@character_name = ""
@character_hue = 0
$game_variables[ID] = 0 unless ID.zero?
# 分支結束
return
end
if @leader_id.nil? or $game_party.actors[@leader_id].nil?
# 獲取帶頭的角色
actor = $game_party.actors[0]
@leader_id = 0
else
# 獲取帶頭的角色
actor = $game_party.actors[@leader_id]
end
$game_variables[ID] = $game_party.actors[@leader_id].id unless ID.zero?
# 設置角色的檔案名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
@old_pic = @character_name
@time = 0
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
# 本地變數記錄移動資訊
last_moving = moving?
# 按下 A 鍵的情況下
if Input.trigger?(Input::X)
@leader_id += 1
@leader_id = 0 if $game_party.actors[@leader_id].nil?
refresh
end
# 獲取帶頭的角色
actor = $game_party.actors[@leader_id]
actor_name = actor != nil ? actor.character_name : ""
if @time == TIME_LIMIT
@scratch = true
@character_name = actor_name + "-W"
@step_anime = true
@time = TIME_LIMIT + 1
elsif @time < TIME_LIMIT
@scratch = false
@character_name = actor_name if @character_name != actor_name
@step_anime = false
end
# 移動中、事件執行中、強制移動路線中、
# 資訊視窗一個也不顯示的時候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向鍵被按下、主角就朝那個方向移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地變數記憶座標
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移動、畫面上的位置在中央下方的情況下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 畫面向下捲動
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移動、畫面上的位置在中央左方的情況下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 畫面向左捲動
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移動、畫面上的位置在中央右方的情況下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 畫面向右捲動
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移動、畫面上的位置在中央上方的情況下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 畫面向上捲動
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移動中的情況下
unless moving?
@time += 1 if @time < TIME_LIMIT
# 上次主角移動中的情況
if last_moving
# 與同位置的事件接觸就判定為事件啟動
result = check_event_trigger_here([1,2])
# 沒有可以啟動的事件的情況下
if result == false
# 調試模式為 ON 並且按下 CTRL 鍵的情況下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敵計數下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 判定為同位置以及正面的事件啟動
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
#--------------------------------------------------------------------------
# ● 向下移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 面向下
if turn_enabled
turn_down
end
# 可以通行的場合
if passable?(@x, @y, 2)
# 面向下
turn_down
# 更新座標
@y += 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y+1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 面向左
if turn_enabled
turn_left
end
# 可以通行的情況下
if passable?(@x, @y, 4)
# 面向左
turn_left
# 更新座標
@x -= 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x-1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 面向右
if turn_enabled
turn_right
end
# 可以通行的場合
if passable?(@x, @y, 6)
# 面向右
turn_right
# 更新座標
@x += 1
# 增加部數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x+1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向上移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 面向上
if turn_enabled
turn_up
end
# 可以通行的情況下
if passable?(@x, @y, 8)
# 面向上
turn_up
# 更新座標
@y -= 1
# 歩數増加
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y-1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左下移動
#--------------------------------------------------------------------------
def move_lower_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
# 下→左、左→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# 更新座標
@x -= 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右下移動
#--------------------------------------------------------------------------
def move_lower_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
# 下→右、右→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# 更新座標
@x += 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左上移動
#--------------------------------------------------------------------------
def move_upper_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
# 上→左、左→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# 更新座標
@x -= 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右上移動
#--------------------------------------------------------------------------
def move_upper_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
# 上→右、右→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# 更新座標
@x += 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
end
#========================================
# 本腳本來自www.66rpg.com
#========================================
class Game_Character
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
# 跳躍中、移動中、停止中的分支
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# 動畫計數超過最大值的情況下
# ※最大值等於基本值減去移動速度 * 1 的值
if @anime_count > 16 - @move_speed * 2
# 停止動畫為 OFF 並且在停止中的情況下
if not @step_anime and @stop_count > 0
# 還原為原來的圖形
@pattern = @original_pattern
# 停止動畫為 ON 並且在移動中的情況下
else
fps_change = true
if self.is_a?(Game_Player)
fps_change = self.scratch ? false : true
end
if fps_change
# 更新圖形
fps = @character_name.split(/_/)[1] != nil ? @character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@pattern = (@pattern + 1) % fps
end
# 清除動畫計數
@anime_count = 0
end
# 等待中的情況下
if @wait_count > 0
# 減少等待計數
@wait_count -= 1
return
end
# 強制移動路線的場合
if @move_route_forcing
# 自定義移動
move_type_custom
return
end
# 事件執行待機中並且為鎖定狀態的情況下
if @starting or lock?
# 不做規則移動
return
end
# 如果停止計數超過了一定的值(由移動頻度算出)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# 移動類型分支
case @move_type
when 1 # 隨機
move_type_random
when 2 # 接近
move_type_toward_player
when 3 # 自定義
move_type_custom
end
end
end
end
#===============================================
# ■ Sprite_Character
#-------------------------------------------------
# 角色顯示用腳本。監視 Game_Character 類的實例、
# 自動變化腳本狀態。
#===============================================
class Sprite_Character < RPG::Sprite
#---------------------------------------
# ● 更新畫面
#-----------------------------------------
def update
super
# 元件 ID、檔案名、色相與現在的情況存在差異的情況下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 記憶元件 ID 與檔案名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 為有效值的情況下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 為無效值的情況下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
fps_change = true
if @character.is_a?(Game_Player)
fps_change = @character.scratch ? false : true
end
if fps_change
fps = @character.character_name.split(/_/)[1] != nil ? @character.character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@cw = bitmap.width / fps
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 設置可視狀態
self.visible = (not @character.transparent)
# 圖形是角色的情況下
if @tile_id == 0
# 設置傳送目標的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 設置腳本的座標
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 設置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 動畫
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 想請問...能否幫忙 合成個腳本...
[/quote]
以下為整合修改版
謝謝大大已經沒有問題了~
以下為整合修改版
- 代碼:
class Game_Player < Game_Character
#=======================================#
TIME_LIMIT = 100 # 抓耳撓腮前的等待時間 |
ID = 5
#=======================================#
attr_reader :time
attr_reader :scratch
def initialize
super
@time = 0
@scratch = false
@leader_id = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的檔案名及對像
@character_name = ""
@character_hue = 0
$game_variables[ID] = 0 unless ID.zero?
# 分支結束
return
end
if @leader_id.nil? or $game_party.actors[@leader_id].nil?
# 獲取帶頭的角色
actor = $game_party.actors[0]
@leader_id = 0
else
# 獲取帶頭的角色
actor = $game_party.actors[@leader_id]
end
$game_variables[ID] = $game_party.actors[@leader_id].id unless ID.zero?
# 設置角色的檔案名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
@old_pic = @character_name
@time = 0
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
# 本地變數記錄移動資訊
last_moving = moving?
# 按下 A 鍵的情況下
if Input.trigger?(Input::X)
@leader_id += 1
@leader_id = 0 if $game_party.actors[@leader_id].nil?
refresh
end
# 獲取帶頭的角色
actor = $game_party.actors[@leader_id]
actor_name = actor != nil ? actor.character_name : ""
if @time == TIME_LIMIT
@scratch = true
@character_name = actor_name + "-W"
@step_anime = true
@time = TIME_LIMIT + 1
elsif @time < TIME_LIMIT
@scratch = false
@character_name = actor_name if @character_name != actor_name
@step_anime = false
end
# 移動中、事件執行中、強制移動路線中、
# 資訊視窗一個也不顯示的時候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向鍵被按下、主角就朝那個方向移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地變數記憶座標
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移動、畫面上的位置在中央下方的情況下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 畫面向下捲動
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移動、畫面上的位置在中央左方的情況下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 畫面向左捲動
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移動、畫面上的位置在中央右方的情況下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 畫面向右捲動
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移動、畫面上的位置在中央上方的情況下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 畫面向上捲動
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移動中的情況下
unless moving?
@time += 1 if @time < TIME_LIMIT
# 上次主角移動中的情況
if last_moving
# 與同位置的事件接觸就判定為事件啟動
result = check_event_trigger_here([1,2])
# 沒有可以啟動的事件的情況下
if result == false
# 調試模式為 ON 並且按下 CTRL 鍵的情況下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敵計數下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 判定為同位置以及正面的事件啟動
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
#--------------------------------------------------------------------------
# ● 向下移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 面向下
if turn_enabled
turn_down
end
# 可以通行的場合
if passable?(@x, @y, 2)
# 面向下
turn_down
# 更新座標
@y += 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y+1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 面向左
if turn_enabled
turn_left
end
# 可以通行的情況下
if passable?(@x, @y, 4)
# 面向左
turn_left
# 更新座標
@x -= 1
# 增加步數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x-1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 面向右
if turn_enabled
turn_right
end
# 可以通行的場合
if passable?(@x, @y, 6)
# 面向右
turn_right
# 更新座標
@x += 1
# 增加部數
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x+1, @y)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向上移動
# turn_enabled : 本場地位置更改許可標誌
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 面向上
if turn_enabled
turn_up
end
# 可以通行的情況下
if passable?(@x, @y, 8)
# 面向上
turn_up
# 更新座標
@y -= 1
# 歩數増加
increase_steps
# 不能通行的情況下
else
# 接觸事件的啟動判定
check_event_trigger_touch(@x, @y-1)
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左下移動
#--------------------------------------------------------------------------
def move_lower_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
# 下→左、左→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# 更新座標
@x -= 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右下移動
#--------------------------------------------------------------------------
def move_lower_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
# 下→右、右→下 的通道可以通行的情況下
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# 更新座標
@x += 1
@y += 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向左上移動
#--------------------------------------------------------------------------
def move_upper_left
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
# 上→左、左→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# 更新座標
@x -= 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
#--------------------------------------------------------------------------
# ● 向右上移動
#--------------------------------------------------------------------------
def move_upper_right
# 沒有固定面向的場合
unless @direction_fix
# 朝向是右的情況下適合的面是左面、朝向是上的情況下適合的面是下面
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
# 上→右、右→上 的通道可以通行的情況下
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# 更新座標
@x += 1
@y -= 1
# 增加步數
increase_steps
end
@time = 0
@scratch = false
@character_name = @old_pic
end
end
#========================================
# 本腳本來自www.66rpg.com
#========================================
class Game_Character
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
# 跳躍中、移動中、停止中的分支
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# 動畫計數超過最大值的情況下
# ※最大值等於基本值減去移動速度 * 1 的值
if @anime_count > 16 - @move_speed * 2
# 停止動畫為 OFF 並且在停止中的情況下
if not @step_anime and @stop_count > 0
# 還原為原來的圖形
@pattern = @original_pattern
# 停止動畫為 ON 並且在移動中的情況下
else
fps_change = true
if self.is_a?(Game_Player)
fps_change = self.scratch ? false : true
end
if fps_change
# 更新圖形
fps = @character_name.split(/_/)[1] != nil ? @character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@pattern = (@pattern + 1) % fps
end
# 清除動畫計數
@anime_count = 0
end
# 等待中的情況下
if @wait_count > 0
# 減少等待計數
@wait_count -= 1
return
end
# 強制移動路線的場合
if @move_route_forcing
# 自定義移動
move_type_custom
return
end
# 事件執行待機中並且為鎖定狀態的情況下
if @starting or lock?
# 不做規則移動
return
end
# 如果停止計數超過了一定的值(由移動頻度算出)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# 移動類型分支
case @move_type
when 1 # 隨機
move_type_random
when 2 # 接近
move_type_toward_player
when 3 # 自定義
move_type_custom
end
end
end
end
#===============================================
# ■ Sprite_Character
#-------------------------------------------------
# 角色顯示用腳本。監視 Game_Character 類的實例、
# 自動變化腳本狀態。
#===============================================
class Sprite_Character < RPG::Sprite
#---------------------------------------
# ● 更新畫面
#-----------------------------------------
def update
super
# 元件 ID、檔案名、色相與現在的情況存在差異的情況下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 記憶元件 ID 與檔案名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 為有效值的情況下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 為無效值的情況下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
fps_change = true
if @character.is_a?(Game_Player)
fps_change = @character.scratch ? false : true
end
if fps_change
fps = @character.character_name.split(/_/)[1] != nil ? @character.character_name.split(/_/)[1].to_i : 4
else
fps = 4
end
@cw = bitmap.width / fps
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 設置可視狀態
self.visible = (not @character.transparent)
# 圖形是角色的情況下
if @tile_id == 0
# 設置傳送目標的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 設置腳本的座標
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 設置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 動畫
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
謝謝大大已經沒有問題了~
omgezero- 賣彩色內褲的小鱉三
- 文章數 : 3
注冊日期 : 2008-09-25
這個論壇的權限:
您 無法 在這個版面回復文章
|
|