查看: 1809|回复: 0

[已经过期] 怎么修改这个提取放置事件的脚本

[复制链接]
梦石
0
星屑
50
在线时间
26 小时
注册时间
2016-4-14
回帖
3
发表于 2016-6-28 20:07:16 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
主要是想让它生成的脚本 在切换地图后可以保存下来
再添加一个事件脚本为 "删除本事件" 的指令

  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Spawn Event v1.00
  4. # -- Last Updated: 2012.02.08
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-SpawnEvent"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.02.08 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # For those who would like to spawn pre-made events from the current map or
  20. # even other maps, this script allows you to do so. With the option of spawning
  21. # the events at specific locations or a random spot marked by a certain region,
  22. # you can have events spawn using simple script calls. The events remain until
  23. # a map change.
  24. #
  25. #==============================================================================
  26. # ▼ Instructions
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  30. #
  31. # -----------------------------------------------------------------------------
  32. # Script Calls - These commands are used with script calls.
  33. # -----------------------------------------------------------------------------
  34. # spawn_event_location(x, y, event_id)
  35. # spawn_event_location(x, y, event_id, map_id)
  36. # This causes a new event to be created at location x and y on the current map.
  37. # The event to be created will use the event data from event_id. If no map_id
  38. # is used, then the current map's event will be used to spawn the new event.
  39. # The event cannot spawn on top of another event or vehicle. If there is an
  40. # event or vehicle in place, then no event will be spawned at all.
  41. #
  42. # spawn_event_region(region_id, event_id)
  43. # spawn_event_region(region_id, event_id, map_id)
  44. # This causes a new event to be created at a random location with a matching
  45. # region_id. The event to be created will use the event data from event_id. If
  46. # no map_id is used, then the current map's event will be used to spawn the
  47. # new event. If the region_id does not exist on the current map, then no event
  48. # will be spawned. The event will not spawn on top of another event nor on top
  49. # of a vehicle. If there is not enough room to spawn an event, then no event
  50. # will be spawned at all. This process takes slightly longer on larger maps.
  51. #
  52. #==============================================================================
  53. # ▼ Compatibility
  54. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  55. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  56. # it will run with RPG Maker VX without adjusting.
  57. #
  58. #==============================================================================

  59. #==============================================================================
  60. # ■ Game_Map
  61. #==============================================================================

  62. class Game_Map

  63.   #--------------------------------------------------------------------------
  64.   # new method: spawn_event
  65.   #--------------------------------------------------------------------------
  66.   def spawn_event(dx, dy, event_id, map_id)
  67.     return if $game_player.collide_with_characters?(dx, dy)
  68.     return if dx == $game_player.x && dy == $game_player.y
  69.     map_id = @map_id if map_id == 0
  70.     map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  71.     event = generated_event(map, event_id)
  72.     return if event.nil?
  73.     key_id = @events.keys.max + 1
  74.     @events[key_id] = Game_Event.new(@map_id, event)
  75.     @events[key_id].moveto(dx, dy)
  76.     SceneManager.scene.spriteset.refresh_characters
  77.   end

  78.   #--------------------------------------------------------------------------
  79.   # new method: generated_event
  80.   #--------------------------------------------------------------------------
  81.   def generated_event(map, event_id)
  82.     for key in map.events
  83.       event = key[1]
  84.       next if event.nil?
  85.       return event if event.id == event_id
  86.     end
  87.     return nil
  88.   end

  89.   #--------------------------------------------------------------------------
  90.   # new method: spawn_event_region
  91.   #--------------------------------------------------------------------------
  92.   def spawn_event_region(reg_id, event_id, map_id)
  93.     tile = get_random_region_tile(reg_id)
  94.     return if tile.nil?
  95.     spawn_event(tile[0], tile[1], event_id, map_id)
  96.   end

  97.   #--------------------------------------------------------------------------
  98.   # new method: get_random_region_tile
  99.   #--------------------------------------------------------------------------
  100.   def get_random_region_tile(reg_id)
  101.     tiles = []
  102.     for i in 0...width
  103.       for j in 0...height
  104.         next unless (region_id(i, j) == reg_id) or (reg_id == 0)
  105.         next if $game_player.collide_with_characters?(i, j)
  106.         next if i == $game_player.x && j == $game_player.y
  107.         tiles.push([i, j])
  108.       end
  109.     end
  110.     return tiles.sample
  111.   end

  112. end # Game_Map

  113. #==============================================================================
  114. # ■ Game_Interpreter
  115. #==============================================================================

  116. class Game_Interpreter

  117.   #--------------------------------------------------------------------------
  118.   # new method: spawn_event_location
  119.   #--------------------------------------------------------------------------
  120.   def spawn_event_location(dx, dy, event_id, map_id = 0)
  121.     return unless SceneManager.scene_is?(Scene_Map)
  122.     $game_map.spawn_event(dx, dy, event_id, map_id)
  123.   end

  124.   #--------------------------------------------------------------------------
  125.   # new method: spawn_event_region
  126.   #--------------------------------------------------------------------------
  127.   def spawn_event_region(region_id, event_id, map_id = 0)
  128.     return unless SceneManager.scene_is?(Scene_Map)
  129.     $game_map.spawn_event_region(region_id, event_id, map_id)
  130.   end

  131. end # Game_Interpreter

  132. #==============================================================================
  133. # ■ Scene_Map
  134. #==============================================================================

  135. class Scene_Map < Scene_Base

  136.   #--------------------------------------------------------------------------
  137.   # public instance variables
  138.   #--------------------------------------------------------------------------
  139.   attr_accessor :spriteset

  140. end # Scene_Map

  141. #==============================================================================
  142. #
  143. # ▼ End of File
  144. #
  145. #==============================================================================
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部