赞 | 0 |
VIP | 1 |
好人卡 | 0 |
积分 | 1 |
经验 | 3179 |
最后登录 | 2013-10-25 |
在线时间 | 140 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 66
- 在线时间
- 140 小时
- 注册时间
- 2012-2-6
- 帖子
- 384
|
雪流星 发表于 2012-3-8 13:40
我來試試看
------------------------------------------------------------------------------
... - #===============================================================
- # ■ 即时遇敌,
- #---------------------------------------------------------------
- # 碰到什么怪物,周围是什么怪物战斗中就是什么怪物
- # 与雪流星版本简直是完全不同的一个版本
- #===============================================================
- $win_common_event_id = 1 # 战胜时的公共事件
- $lose_common_event_id = 2 # 战败时的公共事件
- $escape_common_event_id = 3 # 逃跑时的公共事件
- class Game_Event < Game_Character
- alias old_initialize initialize
- def initialize(map_id, event)
- old_initialize(map_id, event)
- name = event.name
- @enemy_id = 0
- if name =~ /(?:敌人),(?:\s)(\d+)/
- @enemy_id = $1.to_i
- setup_as_enemy
- end
- end
- def setup_as_enemy
- command = RPG::EventCommand.new(301, 0, [0, 1, true, true])
- @list.push(command)
- command = RPG::EventCommand.new(601, 0, [])
- @list.push(command)
- command = RPG::EventCommand.new(117, 1, [$win_common_event_id])
- @list.push(command)
- command = RPG::EventCommand.new(602, 0, [])
- @list.push(command)
- command = RPG::EventCommand.new(117, 1, [$escape_common_event_id])
- @list.push(command)
- command = RPG::EventCommand.new(603, 0, [])
- @list.push(command)
- command = RPG::EventCommand.new(117, 1, [$lose_common_event_id])
- @list.push(command)
- command = RPG::EventCommand.new(604, 0, [])
- @list.push(command)
- command = RPG::EventCommand.new
- @list.push(command)
- end
- def exist?
- return !@erased
- end
- def isEnemy?
- return @enemy_id > 0
- end
- attr_reader :enemy_id # 指定的敌人ID
- end
- class Game_Map
- ENCOUNTER_RANGE = 3 #这个代表遇到敌人的范围大小
- def scope_event
- scope_event = []
- x = $game_player.x
- y = $game_player.y
- for event in $game_map.events.values
- next unless event.isEnemy?
- if (event.x - x).abs + (event.y - y).abs <=ENCOUNTER_RANGE and event.exist?
- scope_event.push(event.id)
- break if scope_event.size >= 8
- end
- end
- return scope_event
- end
- end
- module BattleManager
- class << self
- alias instant_encounter_battle_end battle_end
- def battle_end(result)
- if result == 0
- scope_event = $game_map.scope_event
- $game_troop.members.size.times{ |i|
- $game_map.events[scope_event[i]].erase
- }
- end
- instant_encounter_battle_end(result)
- end
- alias instant_encounter_setup setup
- def setup(troop_id, can_escape = true, can_lose = false)
- if troop_id == 1
- $data_troops[1].members = []
- scope_event = $game_map.scope_event
- for i in 1..scope_event.size
- temp = RPG::Troop::Member.new
- temp.enemy_id = $game_map.events[scope_event[i-1]].enemy_id
- temp.x = Graphics.width * (i - 0.5) / scope_event.size
- temp.y = 288
- $data_troops[1].members.push(temp)
- end
- end
- instant_encounter_setup(troop_id, can_escape, can_lose)
- end
- end
- end
复制代码 与您的脚本结构不一样的脚本。已经实现战斗后消除事件 |
|