赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 480 |
最后登录 | 2020-11-14 |
在线时间 | 2 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 2 小时
- 注册时间
- 2008-3-10
- 帖子
- 74
|
6楼
楼主 |
发表于 2008-10-24 20:43:48
|
只看该作者
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # 处理主角的类。事件启动的判定、以及地图的滚动等功能。
- # 本类的实例请参考 $game_player。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- 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
- if $game_map.battle?
- @need_move_speed = 4 + $game_party.actors[0].agi / 80
- if @need_move_speed > 7
- @need_move_speed = 7
- end
- else
- @need_move_speed = 5
- end
- @character_hue = actor.character_hue
- # 初始化不透明度和合成方式子
- @opacity = 255
- @blend_type = 0
- end
- #--------------------------------------------------------------------------
- # ● 画面更新
- #--------------------------------------------------------------------------
- def update
- # 本地变量记录移动信息
- last_moving = moving?
- # 移动中、事件执行中、强制移动路线中、
- # 信息窗口一个也不显示的时候
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing or !$game_party.actors[0].movable?
- # 如果方向键被按下、主角就朝那个方向移动
- case Input.dir4
- when 2
- if @move_speed < @need_move_speed
- @move_speed += 1
- end
- move_down
- when 4
- if @move_speed < @need_move_speed
- @move_speed += 1
- end
- move_left
- when 6
- if @move_speed < @need_move_speed
- @move_speed += 1
- end
- move_right
- when 8
- if @move_speed < @need_move_speed
- @move_speed += 1
- end
- move_up
- end
- end
- # 本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- super
- if Input.dir4 == 0
- @move_speed = 4
- end
- # 角色向下移动、画面上的位置在中央下方的情况下
- 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?
- # 上次主角移动中的情况
- 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
- if @action_wait_count > 0
- @action_wait_count -= 1
- end
- if $game_map.battle?
- if Kboard.trigger?($R_Key_1)
- use_item($data_items[$game_party.set_items[0]])
- return
- end
- if Kboard.trigger?($R_Key_2)
- use_item($data_items[$game_party.set_items[1]])
- return
- end
- if Kboard.trigger?($R_Key_3)
- use_item($data_items[$game_party.set_items[2]])
- return
- end
- if Kboard.trigger?($R_Key_4)
- use_item($data_items[$game_party.set_items[3]])
- return
- end
- end
- # 以下为不能行动的状况
- unless $game_party.actors.size > 0 and $game_party.actors[0].movable?
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 判定为同位置以及正面的事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- if $game_map.battle?
- check_event_attack
- end
- return
- end
- if Kboard.trigger?(MAP_SKILL_KEY)
- check_event_skill($data_skills[SKILL_IN_MAP[$game_party.actors[0].id-1]])
- return
- end
- if $game_map.battle?
- if $game_party.actors[0].hp <= $game_party.actors[0].maxhp / 5 and
- check_event_skill($data_skills[SKILL_IN_DANGER[$game_party.actors[0].id-1]])
- end
- if Kboard.trigger?(MENU_SKILL_KEY)
- check_event_skill($data_skills[SKILL_IN_MENU[$game_party.actors[1].id-1]], $game_party.actors[1])
- return
- end
- if Input.trigger?(Input::X)
- check_event_skill($data_skills[$game_party.actors[0].set_skills[0]])
- return
- end
- if Input.trigger?(Input::Y)
- check_event_skill($data_skills[$game_party.actors[0].set_skills[1]])
- return
- end
- if Input.trigger?(Input::Z)
- check_event_skill($data_skills[$game_party.actors[0].set_skills[2]])
- return
- end
- if Kboard.trigger?($R_Key_F)
- check_event_skill($data_skills[$game_party.actors[0].set_skills[3]])
- return
- end
- if Kboard.trigger?($R_Key_G)
- check_event_skill($data_skills[$game_party.actors[0].set_skills[4]])
- return
- end
- if Kboard.trigger?(JUMP_KEY) and @action_wait_count == 0
- dis = 4
- if $game_party.actors[0].id == 3
- dis = 6
- end
- case @direction
- when 2
- $game_player.jump(0,dis)
- when 4
- $game_player.jump(-dis,0)
- when 6
- $game_player.jump(dis,0)
- when 8
- $game_player.jump(0,-dis)
- end
- @action_wait_count = 45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
- Audio.se_play(JUMP_SE)
- return
- end
- end
- end
- end
- #===========================================================================
- # 物品判定
- #===========================================================================
- def use_item(item)
- if item.id == 0 or item == nil
- return
- end
- # 如果物品用完的情况下
- if $game_party.item_number(item.id) == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 目标是全体的情况下
- if item.scope == 4
- # 对同伴全体应用物品使用效果
- used = false
- for i in $game_party.actors
- used |= i.item_effect(item)
- end
- end
- # 目标是单体的情况下
- if item.scope == 3
- # 对目标角色应用物品的使用效果
- target = $game_party.actors[0]
- used = target.item_effect(item)
- end
- # 使用物品的情况下
- if used
- # 演奏物品使用时的 SE
- $game_system.se_play(item.menu_se)
- # 消耗品的情况下
- if item.consumable
- # 使用的物品数减 1
- $game_party.lose_item(item.id, 1)
- # 再描绘物品窗口的项目
- $skill_window_need_refresh = true
- end
- # 公共事件 ID 有效的情况下
- if item.common_event_id > 0
- # 预约调用公共事件
- $game_temp.common_event_id = item.common_event_id
- # 切换到地图画面
- return
- end
- end
- # 无法使用物品的情况下
- unless used
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- #===========================================================================
- # 技能判定
- #===========================================================================
- def check_event_skill(skill,actor = $game_party.actors[0])
- # 事件执行中的情况下
- if skill.id == 0 or skill == nil
- return
- end
- if $game_system.map_interpreter.running?
- return
- end
- unless actor.current_action.forcing
- # 因为 SP 耗尽而无法使用的情况下
- unless actor.skill_can_use?(skill.id)
- return
- end
- end
- if skill.scope == 1
- # 全部事件的循环
- for event in $game_map.events.values
- case @direction
- when 2
- attack_able = (event.y - @y > 0 and event.y - @y < skill.range and (@x - event.x).abs < 2)
- when 4
- attack_able = (@x - event.x > 0 and @x - event.x < skill.range and (@y - event.y).abs < 2)
- when 6
- attack_able = (event.x - @x > 0 and event.x - @x < skill.range and (@y - event.y).abs < 2)
- when 8
- attack_able = (@y - event.y > 0 and @y - event.y < skill.range and (@x - event.x).abs < 2)
- end
- if attack_able
- # 事件坐标与目标一致的情况下
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0
- if skill.animation1_id == 0
- self.white_flash = true
- else
- self.animation_id = skill.animation1_id
- end
- $game_variables[TARGET] = event.id
- event.damage = event.enemy.skill_effect(actor, skill) if event.enemy.id != 100
- event.damage_pop = event.enemy.id != 100
- event.animation_id = skill.animation2_id
- actor.sp -= skill.sp_cost
- if skill.cold.to_i != 0
- actor.cold[skill.id] = skill.cold.to_i
- end
- @action_wait_count = 45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
- end
- end
- end
- end
- if skill.scope == 2
- ####============================
- range = skill.range
- ####============================
- # 全部事件的循环
- $target = []
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- # 事件坐标与目标一致的情况下
- sx = @x - event.x
- sy = @y - event.y
- # 求得差的绝对值
- abs_sx = sx > 0 ? sx : -sx
- abs_sy = sy > 0 ? sy : -sy
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0 and abs_sx + abs_sy < range and event.enemy.id != 100
- if skill.animation1_id == 0
- self.white_flash = true
- else
- self.animation_id = skill.animation1_id
- end
- $target.push(event.id)
- event.damage = event.enemy.skill_effect(actor, skill)
- event.damage_pop = true
- unless $data_animations[skill.animation2_id].position == 3
- event.animation_id = skill.animation2_id
- else
- event.animation_id = 102
- end
- end
- end
- if $target == []
- return
- end
- if $data_animations[skill.animation2_id].position == 3
- self.animation_id = skill.animation2_id
- end
- @action_wait_count = 45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
- actor.sp -= skill.sp_cost
- if skill.cold.to_i != 0
- actor.cold[skill.id] = skill.cold.to_i
- end
- end
- if skill.scope == 3
- # 全部事件的循环
- # if $game_party.actors[0].hp == $game_party.actors[0].maxhp
- # return
- # end
- if skill.animation1_id == 0
- self.white_flash = true
- else
- self.animation_id = skill.animation1_id
- end
- self.damage = $game_party.actors[0].skill_effect(actor, skill)
- self.damage_pop = true
- self.animation_id = skill.animation2_id if skill.animation2_id != 0
- @action_wait_count = 45 - actor.dex / 5 + BASE_ACTION_COUNT
- actor.sp -= skill.sp_cost
- if skill.cold.to_i != 0
- actor.cold[skill.id] = skill.cold.to_i
- end
- end
- if skill.scope > 3 or skill.scope == 0
- if skill.animation1_id == 0
- self.white_flash = true
- else
- self.animation_id = skill.animation1_id
- end
- self.animation_id = skill.animation1_id
- @action_wait_count = 45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
- actor.sp -= skill.sp_cost
- if skill.cold.to_i != 0
- actor.cold[skill.id] = skill.cold.to_i
- end
- end
- if skill.common_event_id > 0
- # 设置事件
- common_event = $data_common_events[skill.common_event_id]
- $game_system.map_interpreter.setup(common_event.list, 0)
- end
- $skill_window_need_refresh = true
- return# result
- end
- #===========================================================================
- # 攻击判定
- #===========================================================================
- def check_event_attack
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全部事件的循环
- for event in $game_map.events.values
- # 武器射程判定
- attack_able = false
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- case @direction
- when 2
- attack_able = (event.y - @y > 0 and event.y - @y < $game_party.actors[0].range and @x == event.x)
- when 4
- attack_able = (@x - event.x > 0 and @x - event.x < $game_party.actors[0].range and @y == event.y)
- when 6
- attack_able = (event.x - @x > 0 and event.x - @x < $game_party.actors[0].range and @y == event.y)
- when 8
- attack_able = (@y - event.y > 0 and @y - event.y < $game_party.actors[0].range and @x == event.x)
- end
- if attack_able
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0 and event.enemy.id != 100
- make_attack(event)
- result = true
- @action_wait_count = 45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
- end
- end
- end
- end
- return result
- end
- def make_attack(event)
- # 设置攻击 ID
- if $game_party.actors[0].animation1_id == 0
- self.white_flash = true
- else
- self.animation_id = $game_party.actors[0].animation1_id
- end
- event.damage = event.enemy.attack_effect($game_party.actors[0])
- event.critical = event.enemy.critical
- event.damage_pop = true
- event.animation_id = $game_party.actors[0].animation2_id
- return
- end
- end
复制代码
就是这个了自己没一个队友的时候..按R特殊技能,就会出现160行的脚本错误 |
|