设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1581|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
26 小时
注册时间
2016-4-14
帖子
7
跳转到指定楼层
1
发表于 2016-6-28 20:07:16 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

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

RUBY 代码复制
  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.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SpawnEvent"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.02.08 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # For those who would like to spawn pre-made events from the current map or
  22. # even other maps, this script allows you to do so. With the option of spawning
  23. # the events at specific locations or a random spot marked by a certain region,
  24. # you can have events spawn using simple script calls. The events remain until
  25. # a map change.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Script Calls - These commands are used with script calls.
  35. # -----------------------------------------------------------------------------
  36. # spawn_event_location(x, y, event_id)
  37. # spawn_event_location(x, y, event_id, map_id)
  38. # This causes a new event to be created at location x and y on the current map.
  39. # The event to be created will use the event data from event_id. If no map_id
  40. # is used, then the current map's event will be used to spawn the new event.
  41. # The event cannot spawn on top of another event or vehicle. If there is an
  42. # event or vehicle in place, then no event will be spawned at all.
  43. #
  44. # spawn_event_region(region_id, event_id)
  45. # spawn_event_region(region_id, event_id, map_id)
  46. # This causes a new event to be created at a random location with a matching
  47. # region_id. The event to be created will use the event data from event_id. If
  48. # no map_id is used, then the current map's event will be used to spawn the
  49. # new event. If the region_id does not exist on the current map, then no event
  50. # will be spawned. The event will not spawn on top of another event nor on top
  51. # of a vehicle. If there is not enough room to spawn an event, then no event
  52. # will be spawned at all. This process takes slightly longer on larger maps.
  53. #
  54. #==============================================================================
  55. # ▼ Compatibility
  56. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  57. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  58. # it will run with RPG Maker VX without adjusting.
  59. #
  60. #==============================================================================
  61.  
  62. #==============================================================================
  63. # ■ Game_Map
  64. #==============================================================================
  65.  
  66. class Game_Map
  67.  
  68.   #--------------------------------------------------------------------------
  69.   # new method: spawn_event
  70.   #--------------------------------------------------------------------------
  71.   def spawn_event(dx, dy, event_id, map_id)
  72.     return if $game_player.collide_with_characters?(dx, dy)
  73.     return if dx == $game_player.x && dy == $game_player.y
  74.     map_id = @map_id if map_id == 0
  75.     map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  76.     event = generated_event(map, event_id)
  77.     return if event.nil?
  78.     key_id = @events.keys.max + 1
  79.     @events[key_id] = Game_Event.new(@map_id, event)
  80.     @events[key_id].moveto(dx, dy)
  81.     SceneManager.scene.spriteset.refresh_characters
  82.   end
  83.  
  84.   #--------------------------------------------------------------------------
  85.   # new method: generated_event
  86.   #--------------------------------------------------------------------------
  87.   def generated_event(map, event_id)
  88.     for key in map.events
  89.       event = key[1]
  90.       next if event.nil?
  91.       return event if event.id == event_id
  92.     end
  93.     return nil
  94.   end
  95.  
  96.   #--------------------------------------------------------------------------
  97.   # new method: spawn_event_region
  98.   #--------------------------------------------------------------------------
  99.   def spawn_event_region(reg_id, event_id, map_id)
  100.     tile = get_random_region_tile(reg_id)
  101.     return if tile.nil?
  102.     spawn_event(tile[0], tile[1], event_id, map_id)
  103.   end
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # new method: get_random_region_tile
  107.   #--------------------------------------------------------------------------
  108.   def get_random_region_tile(reg_id)
  109.     tiles = []
  110.     for i in 0...width
  111.       for j in 0...height
  112.         next unless (region_id(i, j) == reg_id) or (reg_id == 0)
  113.         next if $game_player.collide_with_characters?(i, j)
  114.         next if i == $game_player.x && j == $game_player.y
  115.         tiles.push([i, j])
  116.       end
  117.     end
  118.     return tiles.sample
  119.   end
  120.  
  121. end # Game_Map
  122.  
  123. #==============================================================================
  124. # ■ Game_Interpreter
  125. #==============================================================================
  126.  
  127. class Game_Interpreter
  128.  
  129.   #--------------------------------------------------------------------------
  130.   # new method: spawn_event_location
  131.   #--------------------------------------------------------------------------
  132.   def spawn_event_location(dx, dy, event_id, map_id = 0)
  133.     return unless SceneManager.scene_is?(Scene_Map)
  134.     $game_map.spawn_event(dx, dy, event_id, map_id)
  135.   end
  136.  
  137.   #--------------------------------------------------------------------------
  138.   # new method: spawn_event_region
  139.   #--------------------------------------------------------------------------
  140.   def spawn_event_region(region_id, event_id, map_id = 0)
  141.     return unless SceneManager.scene_is?(Scene_Map)
  142.     $game_map.spawn_event_region(region_id, event_id, map_id)
  143.   end
  144.  
  145. end # Game_Interpreter
  146.  
  147. #==============================================================================
  148. # ■ Scene_Map
  149. #==============================================================================
  150.  
  151. class Scene_Map < Scene_Base
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # public instance variables
  155.   #--------------------------------------------------------------------------
  156.   attr_accessor :spriteset
  157.  
  158. end # Scene_Map
  159.  
  160. #==============================================================================
  161. #
  162. # ▼ End of File
  163. #
  164. #==============================================================================
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-16 18:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表