赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 2430 |
最后登录 | 2014-2-3 |
在线时间 | 36 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 36 小时
- 注册时间
- 2006-5-22
- 帖子
- 35
|
8楼
楼主 |
发表于 2008-11-7 05:12:40
|
只看该作者
我不知道你要我貼什麼腳本,那我就貼怪物事件頁裡的內容,
事件第一頁就是:
註釋:@hp = 120
@sp = 40
@atk = 8
@pdef = 5
@mdef = 1
@exp = 5
@str = 5
@dex = 4
@agi = 3
@int = 5
我如果在事件開始條件設定開關的話,就會跟arpg_battle腳本發生問題。
- #==============================================================================
- # ■ ARPG_BATTLE
- #------------------------------------------------------------------------------
- # 處理ARPG 戰鬥的類。
- # 如果事件的第一個內容是註釋的話就會被認為是敵人....所以如果只是NPC的話~
- # 事件的內容的第一行一定不能是註釋``不然會有一大堆問題-________-~||||
- #==============================================================================
- class ARPG_BATTLE
- HP_BAR_DISP_TIME = 50 # 敵人血條消失時間
- ENEMY_HP = 1 # 敵人回血的技能ID #-___-無視這個`要敵人會加血的話直接在敵人的技能數組裡加上恢復HP的技能就好了``
- YC = false # 敵人被攻擊是否增加延遲
- KEYS = {
- "A"=>$R_Key_A,
- "S"=>$R_Key_S,
- "D"=>$R_Key_D,
- "F"=>$R_Key_F,
- "G"=>$R_Key_G}#Kboard.trigger?
- LVUP_ME = "Audio/ME/OS_13.wav" # 升級音效
- $refresh = {} # 全局化一個刷新列表
- #--------------------------------------------------------------------------
- # ● 初始化對像
- #--------------------------------------------------------------------------
- def initialize
- @actor = $game_party.actors[0]
- @x = $game_player.x
- @y = $game_player.y
- @d = $game_player.direction
- # 血條消失的時間
- @hp_disp_time = 0
- # 攻擊延遲
- @actor_atktime = 0
- #
- @bullets = []
- # 敵人攻擊延遲
- # 事件ID->延遲時間
- @event_atk = {}
- for event in $game_map.events.values
- next if !event.is_enemy?
- @event_atk[event.id] = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 釋放
- #--------------------------------------------------------------------------
- def dispose
- @sprite.dispose if [email protected]?
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- if @hp_disp_time >= 0
- @hp_disp_time -= 1
- if @hp_disp_time <= 0
- @attev = nil
- end
- end
- if @actor_atktime > 0
- @actor_atktime -= 1
- end
- update_actor
- update_event
- end
- #--------------------------------------------------------------------------
- # ● 刷新事件
- #--------------------------------------------------------------------------
- def update_event
- for event in $game_map.events.values
- next if !event.is_enemy?
- if @event_atk[event.id] > 0
- @event_atk[event.id] -= 1
- end
- new_x = event.x + (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)
- new_y = event.y + (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)
- if event.hp <= event.maxhp*0.4 and rand(101)>100-event.escape_rand and event.escape? and event.sp >= $game_skills[ENEMY_HP].sp_cost
- if (event.x - $game_player.x).abs < 64 and
- (event.y - $game_player.y).abs < 64
- for i in 0..randg(2,3)
- break if rand(100) < 10
- event.move_away_from_player
- end
- end
- damage_skill_enemy(event, $game_skills[ENEMY_HP])
- break
- end
- if new_x == @x and new_y == @y and @event_atk[event.id] <= 0
- if event.skill.size > 0 and rand(101)>100-event.skill_rand
- skill = event.skill[rand(event.skill.size)]
- damage_skill_enemy(event, $game_skills[skill])
- break
- end
- dagame_acon_actor(@actor,event_damage(event,@actor),event.animation2_id,event)
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 判斷可否移動
- #--------------------------------------------------------------------------
- def move?
- if @actor.states.size == 0
- return true
- end
- for i in @actor.states
- if $data_states[i].restriction == 4
- return false
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 是否可以用技能
- #--------------------------------------------------------------------------
- def skill?
- if @actor.states.size == 0
- return true
- end
- for i in @actor.states
- if $data_states[i].restriction == 1
- return false
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 刷新角色
- #--------------------------------------------------------------------------
- def update_actor
- refresh(0) if @x != $game_player.x
- refresh(1) if @y != $game_player.y
- refresh(2) if @d != $game_player.direction
- update_actor_attk if move?
- update_actor_skill if move? and skill?
- update_actor_item
- update_bullet if @bullets.size > 0
- end
- #--------------------------------------------------------------------------
- # ● 刷按下物品鍵時
- #--------------------------------------------------------------------------
- def update_actor_item
- if Kboard.trigger?($R_Key_Z)
- item = $data_items[@actor.item_key["Z"]]
- return if item.nil?
- item_effect(item)
- if item.common_event_id > 0
- $game_temp.common_event_id = item.common_event_id
- end
- end
- if Kboard.trigger?($R_Key_X)
- item = $data_items[@actor.item_key["X"]]
- return if item.nil?
- item_effect(item)
- if item.common_event_id > 0
- $game_temp.common_event_id = item.common_event_id
- end
- end
- if Kboard.trigger?($R_Key_C)
- item = $data_items[@actor.item_key["C"]]
- return if item.nil?
- item_effect(item)
- if item.common_event_id > 0
- $game_temp.common_event_id = item.common_event_id
- end
- end
- if Kboard.trigger?($R_Key_V)
- item = $data_items[@actor.item_key["V"]]
- return if item.nil?
- item_effect(item)
- if item.common_event_id > 0
- $game_temp.common_event_id = item.common_event_id
- end
- end
- def item_effect(item)
- damage = @actor.item_effect(item)
- $game_player.animation_id = item.animation2_id
- $game_system.se_play(item.menu_se)
- if item.consumable
- $game_party.lose_item(item.id,1)
- end
- $refresh["item"] = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新按下技能鍵時
- #--------------------------------------------------------------------------
- def update_actor_skill
- if @actor_atktime <= 0
- if Kboard.trigger?(KEYS["A"])
- skill = $game_skills[@actor.key["A"]]
- return if skill.nil?
- if skill.scope == 2
- rangs = ARPG_Rangs.new($game_player, skill.rang).rangs
- damage_skill(@actor, skill, rangs, skill.dop?)
- elsif skill.scope == 1 or skill.scope == 3
- damage_skill(@actor, skill)
- $game_temp.common_event_id = skill.common_event_id
- end
- end
- if Kboard.trigger?(KEYS["S"])
- skill = $game_skills[@actor.key["S"]]
- return if skill.nil?
- if skill.scope == 2
- rangs = ARPG_Rangs.new($game_player, skill.rang).rangs
- damage_skill(@actor, skill, rangs,skill.dop?)
- elsif skill.scope == 1 or skill.scope == 3
- damage_skill(@actor, skill)
- $game_temp.common_event_id = skill.common_event_id
- end
- end
- if Kboard.trigger?(KEYS["D"])
- skill = $game_skills[@actor.key["D"]]
- return if skill.nil?
- if skill.scope == 2
- rangs = ARPG_Rangs.new($game_player, skill.rang).rangs
- damage_skill(@actor, skill, rangs,skill.dop?)
- elsif skill.scope == 1 or skill.scope == 3
- damage_skill(@actor, skill)
- $game_temp.common_event_id = skill.common_event_id
- end
- end
- if Kboard.trigger?(KEYS["F"])
- skill = $game_skills[@actor.key["F"]]
- return if skill.nil?
- if skill.scope == 2
- rangs = ARPG_Rangs.new($game_player, skill.rang).rangs
- damage_skill(@actor, skill, rangs,skill.dop?)
- elsif skill.scope == 1 or skill.scope == 3
- damage_skill(@actor, skill)
- $game_temp.common_event_id = skill.common_event_id
- end
- end
- if Kboard.trigger?(KEYS["G"])
- skill = $game_skills[@actor.key["G"]]
- return if skill.nil?
- if skill.scope == 2
- rangs = ARPG_Rangs.new($game_player, skill.rang).rangs
- damage_skill(@actor, skill, rangs,skill.dop?)
- elsif skill.scope == 1 or skill.scope == 3
- damage_skill(@actor, skill)
- $game_temp.common_event_id = skill.common_event_id
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新角色普通攻擊行為
- #--------------------------------------------------------------------------
- def update_actor_attk
- # C按下時
- if ((Kboard.trigger?($R_Key_B) or Kboard.trigger?($R_Key_RETURN)) or S[1])and @actor_atktime <= 0
- if @actor.weapon_id.between?(50, 65) # and $data_weapons[@actor.weapon_id].rang >= 1
- new_x = @x + (@d == 6 ? 1 : @d == 4 ? -1 : 0)
- new_y = @y + (@d == 2 ? 1 : @d == 8 ? -1 : 0)
- event = $game_map.events[$game_map.check_event(new_x,new_y)]
- return if !event.nil? and !event.is_enemy?
- rang_atk#(@actor.animation1_id)
- return
- end
- new_x = @x + (@d == 6 ? 1 : @d == 4 ? -1 : 0)
- new_y = @y + (@d == 2 ? 1 : @d == 8 ? -1 : 0)
- event = $game_map.events[$game_map.check_event(new_x,new_y)]
- show_ain(@actor.animation1_id,true)
- if $data_weapons[@actor.weapon_id].element_set.include?(17)
- tag = []
- rang = ARPG_Rangs.new($game_player, 2).rangs
- for xy in rang
- event = $game_map.events[$game_map.check_event(xy[0],xy[1])]
- if !event.nil? and event.maxhp > 0
- tag.push(event)
- end
- end
- tag.each{|t|dagame_acon(t,event_damage(@actor, t),@actor.animation2_id)}
- end
- if $data_weapons[@actor.weapon_id].element_set.include?(18)
- tag = []
- rang = ARPG_Rangs.new($game_player, 4).rangs
- for xy in rang
- event = $game_map.events[$game_map.check_event(xy[0],xy[1])]
- if !event.nil? and event.maxhp > 0
- tag.push(event)
- end
- end
- tag.each{|t|dagame_acon(t,event_damage(@actor, t),@actor.animation2_id)}
- end
- if !event.nil? and event.maxhp > 0 and @actor_atktime <= 0
- @attev = event
- dagame_acon(event,event_damage(@actor, event),@actor.animation2_id)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新精靈的移動以及接觸判斷
- #--------------------------------------------------------------------------
- def update_bullet
- for bullet in @bullets
- bullet.update
- case bullet.hit_event
- when String
- if bullet.opacity <= 10
- $scene.spriteset.delete_bullet(bullet)
- @bullets.delete(bullet)
- end
- when Game_Event
- event = bullet.hit_event
- next if !event.is_enemy?
- @attev = event
- dagame_acon(event,event_damage(@actor, event),@actor.animation2_id)
- $scene.spriteset.delete_bullet(bullet)
- @bullets.delete(bullet)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成遠程攻擊的精靈
- #--------------------------------------------------------------------------
- def rang_atk
- bullet = ARPG_Bullet.new("Arrow", @x, @y, @d)
- $scene.spriteset.add_bullet(bullet)
- @bullets.push(bullet)
- @actor_atktime = $data_weapons[@actor.weapon_id].time
- end
- #--------------------------------------------------------------------------
- # ● 獲取被攻擊中的事件
- #--------------------------------------------------------------------------
- def target
- return @attev
- end
- #--------------------------------------------------------------------------
- # ● 敵人死亡處理
- #--------------------------------------------------------------------------
- def chae_deal(event)
- if event.hp <= 0
- $game_system.enemy_cun += 1
- list_level = @actor.level
- list_maxhp = @actor.maxhp
- list_maxsp = @actor.maxsp
- list_skill = @actor.skills.dup
- list_hp = @actor.hp
- list_sp = @actor.sp
- list_str = @actor.str
- list_dex = @actor.dex
- list_agi = @actor.agi
- list_int = @actor.int
- @actor.exp += event.exp
- Mess_Text.write("#{@actor.name}擊敗了#{event.name}")
- Mess_Text.write("#{@actor.name}獲得#{event.exp}經驗值")
- if event.item.size > 0
- for item in event.item
- if rand(101) > 100-item[1]
- Mess_Text.write("#{event.name}掉落了#{$data_items[item[0]].name}")
- $game_party.gain_item(item[0], 1)
- end
- end
- end
- if event.weapon.size > 0
- for weapon in event.weapon
- if rand(101) > 100-weapon[1]
- Mess_Text.write("#{event.name}掉落了#{$data_weapons[weapon[0]].name}")
- $game_party.gain_weapon(weapon[0], 1)
- end
- end
- end
- if event.armor.size > 0
- for armor in event.armor
- if rand(101) > 100-armor[1]
- Mess_Text.write("#{event.name}掉落了#{$data_armors[armor[0]].name}")
- $game_party.gain_armor(armor[0], 1)
- end
- end
- end
- if @actor.level > list_level
- @actor.hp = list_hp
- @actor.sp = list_sp
- Audio.me_play(LVUP_ME)
- Mess_Text.write("#{@actor.name}等級提升:")
- Mess_Text.write("#{@actor.name}HP最大值 上升 #{@actor.maxhp - list_maxhp}")
- Mess_Text.write("#{@actor.name}SP最大值 上升 #{@actor.maxsp - list_maxsp}")
- end
- ls = []
- if list_skill != @actor.skills
- for s in @actor.skills
- if !list_skill.include?(s)
- ls.push s
- end
- end
- end
- ls.each{|skill|
- Mess_Text.write("#{@actor.name}領悟:#{$game_skills[skill].name}")
- }
- $refresh["item"] = true
- delete_event(event)
- @attev = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 刪除事件
- #--------------------------------------------------------------------------
- def delete_event(event)
- # 生成獨立開關鍵
- key = [$game_map.map_id, event.id, 'A']
- # 更改獨立開關
- $game_self_switches[key] = true
- $game_map.need_refresh = true
- #$game_map.events.delete(event.id)
- #$scene.spriteset.dispose
- #$scene.spriteset = Spriteset_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 敵人被攻擊傷害處理(也就是角色的攻擊)
- #--------------------------------------------------------------------------
- def dagame_acon(event,damage,ani_id)
- event.hp -= damage.to_i
- event.animation_id = ani_id
- @hp_disp_time = HP_BAR_DISP_TIME
- @actor_atktime = $data_weapons[@actor.weapon_id].time
- if YC
- @event_atk[event.id] = [[@event_atk[event.id]+randg(5,8), event.atk_time*3].min, 0].max
- end
- event.damage = damage
- event.damage_pop = true
- if rand(2)==1
- #event.turn_toward_player
- if randg(1,4) == 2
- @event_atk[event.id] += randg(5,8)
- end
- end
- if event.move_type == 1
- event.move_type = 2
- event.move_speed = 3
- event.move_frequency = 6
- end
-
- if event.damage == "Miss"
- Mess_Text.write("#{event.name}沒有受到傷害")
- else
- Mess_Text.write("#{event.name}受到了#{event.damage}點傷害")
- end
-
- chae_deal(event)
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- end
- end
- #--------------------------------------------------------------------------
- # ● 角色被攻擊傷害處理(也就是敵人的攻擊)
- #--------------------------------------------------------------------------
- def dagame_acon_actor(actor,damage,ani_id,event)
- event.white_flash = true
- actor.hp -= damage.to_i
- if YC
- @actor_atktime = [[@actor_atktime+randg(5,8), $data_weapons[@actor.weapon_id].time*3].min, 0].max
- end
-
- if event.attk_states[0] > 0 and rand(100) > 100-event.attk_states[1]
- unless @actor.state_guard?(event.attk_states[0])
- @actor.add_state(event.attk_states[0])
- end
- end
-
- $game_player.animation_id = ani_id
- @event_atk[event.id] = event.atk_time
- $game_player.damage = damage
- $game_player.damage_pop = true
-
- if damage != "Miss"
- Mess_Text.write("#{@actor.name}受到了#{$game_player.damage}點傷害")
- else
- Mess_Text.write("#{actor.name}沒有受到傷害")
- end
-
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- end
- end
- #--------------------------------------------------------------------------
- # ● 敵人使用技能處理
- #--------------------------------------------------------------------------
- def damage_skill_enemy(user, skill, skill_rang=[])
- return if user.sp < skill.sp_cost
- if skill.scope == 1 or skill.scope == 2
- user.animation_id = skill.animation1_id
- Mess_Text.write("#{user.name}使用了#{skill.name}")
- damage = event_damage_skill(user,@actor,skill)
- dagame_acon_actor(@actor,damage,skill.animation2_id,user)
- user.sp -= skill.sp_cost
- elsif skill.scope == 3
- user.animation_id = skill.animation1_id
- user.animation_id = skill.animation2_id
- #damage = event_damage(user,user)
- damage = event_damage_skill(user,user,skill)
- user.hp -= damage.to_i
- user.sp -= skill.sp_cost
- @event_atk[user.id] = user.atk_time
- Mess_Text.write("#{user.name}使用了#{skill.name}恢復了#{damage.abs}HP")
- end
- end
- #--------------------------------------------------------------------------
- # ● 角色使用技能處理
- #--------------------------------------------------------------------------
- def damage_skill(user, skill, skill_rang=[],d = false)
- if user.sp < skill.sp_cost
- Mess_Text.write("SP不足")
- return
- end
- if skill.scope == 1
- new_x = @x + (@d == 6 ? 1 : @d == 4 ? -1 : 0)
- new_y = @y + (@d == 2 ? 1 : @d == 8 ? -1 : 0)
- event = $game_map.events[$game_map.check_event(new_x,new_y)]
- if !event.nil? and event.maxhp > 0 and @actor_atktime <= 0
- Mess_Text.write("#{user.name}使用了#{skill.name}")
- @attev = event
- $game_player.animation_id = skill.animation1_id
- damage = event_damage_skill(user, event, skill)
- dagame_acon(event,damage,skill.animation2_id)
- user.sp -= skill.sp_cost
- @actor_atktime = skill.time
- $game_skills[skill.id].exp += (damage/5).abs+(randg(damage*0.8,damage*1.2)/10)
- end
- elsif skill.scope == 2
- tag = []
- for xy in skill_rang
- event = $game_map.events[$game_map.check_event(xy[0],xy[1])]
- if !event.nil? and event.maxhp > 0
- tag.push(event)
- end
- end
- if tag.size == 0
- show_ain(skill.animation1_id ,d)
- user.sp -= skill.sp_cost
- @actor_atktime = skill.time#$data_weapons[@actor.weapon_id].time
- return
- end
- Mess_Text.write("#{user.name}使用了#{skill.name}")
- for e in tag
- @attev = e
- damage = event_damage_skill(user, e, skill)
- dagame_acon(e,damage,skill.animation2_id)
- @hp_disp_time = 0 if tag.size > 1
- end
- show_ain(skill.animation1_id,d)
- @actor_atktime = skill.time
- if tag != []
- user.sp -= skill.sp_cost
- $game_skills[skill.id].exp += (damage/5).abs+(randg(damage*0.8,damage*1.2)/10)
- end
- elsif skill.scope == 3
- $game_player.animation_id = skill.animation1_id
- $game_player.animation_id = skill.animation2_id
- damage = @actor.skill_effect(@actor,skill)#event_damage_skill(user, @actor, skill)
- #user.hp -= damage
- #user.sp -= skill.sp_cost
- $game_player.damage = damage.to_i
- $game_player.damage_pop = true
- #Mess_Text.write("#{user.name}使用了#{skill.name}恢復了#{damage.abs}HP")
- @actor_atktime = skill.time#$data_weapons[@actor.weapon_id].time
- end
- end
- #--------------------------------------------------------------------------
- # ● 獲取普通攻擊傷害
- #--------------------------------------------------------------------------
- def event_damage(attk,event)
- hit_result = (rand(100) < attk.hit)
- if hit_result
- atk = [attk.atk - event.pdef / 2, 0].max
- damage = atk * (20 + attk.str) / 20
- amp = [damage.abs * 15 / 100, 1].max
- damage += rand(amp+1) + rand(amp+1) - amp
- damage = damage.abs
-
- if attk.plus_state_set.size > 0
- if rand(100) > randg(85,100)
- event.add_state(attk.plus_state_set[0])
- end
- end
-
- else
- damage = "Miss"
- end
- return damage
- end
- #--------------------------------------------------------------------------
- # ● 獲取技能攻擊傷害
- #--------------------------------------------------------------------------
- def event_damage_skill(user,event,skill)
- # 計算威力
- power = skill.power + user.atk * skill.atk_f / 100
- if power > 0
- power -= event.pdef * skill.pdef_f / 200
- power -= event.mdef * skill.mdef_f / 200
- power = [power, 0].max
- end
- # 計算倍率
- rate = 20
- rate += (user.str * skill.str_f / 100)
- rate += (user.dex * skill.dex_f / 100)
- rate += (user.agi * skill.agi_f / 100)
- rate += (user.int * skill.int_f / 100)
- # 計算基本傷害
- damage = power * rate / 20
- # 分散
- if skill.variance > 0 and damage.abs > 0
- amp = [damage.abs * skill.variance / 100, 1].max
- damage += rand(amp+1) + rand(amp+1) - amp
- end
- if skill.plus_state_set.size > 0
- if rand(100) > 100-rand(skill.hit)
- event.add_state(skill.plus_state_set[0])
- end
- end
- return damage
- end
- #--------------------------------------------------------------------------
- # ● 更新一下坐標
- #--------------------------------------------------------------------------
- def refresh(type)
- case type
- when 0 then @x = $game_player.x
- when 1 then @y = $game_player.y
- when 2 then @d = $game_player.direction
- end
- end
- #--------------------------------------------------------------------------
- # ● 角色顯示動畫#skill.animation1_id
- #--------------------------------------------------------------------------
- def show_ain(ain_id,d)
- if d
- case @d
- when 2 then $game_player.animation_id = ain_id
- when 4 then $game_player.animation_id = ain_id + 1
- when 6 then $game_player.animation_id = ain_id + 2
- when 8 then $game_player.animation_id = ain_id + 3
- end
- else
- $game_player.animation_id = ain_id
- end
- end
- end
复制代码
貼個圖:
|
|