查看: 2480|回复: 5

[已经解决] NPC可以跨地图移动吗

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2015-12-2 12:50:04 | 显示全部楼层 |阅读模式

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

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

×
我就是问问。不能的话就算了。
NPC要是能跨地图移动的话感觉更生动。

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
50
在线时间
168 小时
注册时间
2007-7-26
回帖
427
发表于 2015-12-2 12:52:52 | 显示全部楼层
本帖最后由 cmmd1 于 2015-12-2 12:54 编辑

事件设置NPC出现的地图啊,在一个地图一段时间就出现在另外一个地图。如果说脚本的话,我不懂。理论上一个地图和另一个地图是没有关联的。NPC不会自己去到别的地图。
回复

使用道具 举报

素材区好人

梦石
5
星屑
12712
在线时间
4359 小时
注册时间
2011-7-21
回帖
2270

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2015-12-2 13:00:55 | 显示全部楼层
上工程好了
Project1.zip (202.78 KB, 下载次数: 55)

回复

使用道具 举报

梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2015-12-2 13:04:51 | 显示全部楼层
无忧谷主幻 发表于 2015-12-2 13:00
上工程好了

你这个是固定模式的,只能用在剧情里。假设要让一个NPC在平时就从A村跑到B村玩,再从B村跑到A村玩。
回复

使用道具 举报

梦石
0
星屑
90
在线时间
357 小时
注册时间
2006-3-3
回帖
163
发表于 2015-12-2 15:50:05 | 显示全部楼层
你说的这种随机性的,如果不用脚本的话,肯定是大量变量加上并行事件,一个变量控制一个NPC,变量等于不同值的时候会在不同地图中出现,用一个并行事件控制这些变量的值的随机,至于什么时候随机,那就需要你自己再设置。感觉大体思路是这样。
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-12-2 17:28:48 | 显示全部楼层
本帖最后由 汪汪 于 2015-12-2 18:03 编辑


跨地图的各种修改....做出跨地图移动npc非常简单的....唯一担心的就是你的内存了.....

  1.   

  2. #--------------------------------------------------------------------------
  3.   # Mod地图修改 1.2
  4.   # ● 参考 yangff 先生 的
  5.   #     我要造房子!修改地图元件 - RPG Maker 技术区 - 66RPG
  6.   #     [url]https://rpg.blue/forum.php?mod=viewthread&tid=88421[/url]
  7.   #    额,主要是不读取所有地图,好像也没什么作用。。
  8.   # ● 参考 某位 的 事件位置保存脚本,
  9.   #    由于种种原因,未能找到脚本作者名,十分抱歉。
  10.   # ● 额,
  11.   #    主要是脚本合并,bug 未知,如有请告知,
  12.   #    若原作者不允许对脚本进行修改或有其他意见,万望告知。
  13.   #  作者,修改者:汪汪
  14.   #--------------------------------------------------------------------------

  15. class Game_Map
  16. attr_accessor :mod
  17. attr_accessor :map
  18. attr_accessor :events
  19.   def initialize
  20.     @map_id = 0
  21.     @display_x = 0
  22.     @display_y = 0
  23.     @mod={}
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 设置
  27.   #     map_id : 地图 ID
  28.   #--------------------------------------------------------------------------
  29.   def setup(map_id)
  30.     save_event_pos
  31.    
  32.     load(map_id)
  33.    
  34.     @map_id = map_id
  35.     tileset = $data_tilesets[@map.tileset_id]
  36.     @tileset_name = tileset.tileset_name
  37.     @autotile_names = tileset.autotile_names
  38.     @panorama_name = tileset.panorama_name
  39.     @panorama_hue = tileset.panorama_hue
  40.     @fog_name = tileset.fog_name
  41.     @fog_hue = tileset.fog_hue
  42.     @fog_opacity = tileset.fog_opacity
  43.     @fog_blend_type = tileset.fog_blend_type
  44.     @fog_zoom = tileset.fog_zoom
  45.     @fog_sx = tileset.fog_sx
  46.     @fog_sy = tileset.fog_sy
  47.     @battleback_name = tileset.battleback_name
  48.     @passages = tileset.passages
  49.     @priorities = tileset.priorities
  50.     @terrain_tags = tileset.terrain_tags
  51.     # 初始化显示坐标
  52.     @display_x = 0
  53.     @display_y = 0
  54.     # 清除刷新要求标志
  55.     @need_refresh = false
  56.     # 设置地图事件数据
  57.     @events = {}
  58.     for i in @map.events.keys
  59.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  60.     end
  61.     # 设置公共事件数据
  62.     @common_events = {}
  63.     for i in 1...$data_common_events.size
  64.       @common_events[i] = Game_CommonEvent.new(i)
  65.     end
  66.     # 初始化雾的各种信息
  67.     @fog_ox = 0
  68.     @fog_oy = 0
  69.     @fog_tone = Tone.new(0, 0, 0, 0)
  70.     @fog_tone_target = Tone.new(0, 0, 0, 0)
  71.     @fog_tone_duration = 0
  72.     @fog_opacity_duration = 0
  73.     @fog_opacity_target = 0
  74.     # 初始化滚动信息
  75.     @scroll_direction = 2
  76.     @scroll_rest = 0
  77.     @scroll_speed = 4
  78.    
  79.     load_event_pos
  80.    
  81.   end

  82.   #--------------------------------------------------------------------------
  83.   # ● 读取  map_id : 地图 ID
  84.   #--------------------------------------------------------------------------
  85.   def load(mapid)
  86.     if FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  87.       @map = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  88.     end
  89.     loadmod(mapid)
  90.   end

  91.   def loadmod(mapid)
  92.             chushimap(mapid)
  93.       mod =@mod[mapid].clone
  94.     if mod != nil
  95.             #地图
  96.       if mod[0] != nil
  97.         w = mod[0][0]
  98.         h = mod[0][1]
  99.         @map=RPG::Map.new(w,h)
  100.       end
  101.         #图块
  102.       if mod[1] != nil
  103.         mod[1].each {|wz,dat|@map.data[wz[0],wz[1],wz[2]]=dat}
  104.       end
  105.        #新事件
  106.       if mod[2] != nil
  107.         mod[2].each {|id,ev|@map.events[id] = ev }
  108.       end
  109.         #事件位置保存记录
  110.       if mod[3] != nil
  111.         mod[3].each {|id,pos|
  112.           @map.events[id].x=pos[0] if pos[0] != nil
  113.           @map.events[id].y=pos[1] if pos[1] != nil
  114.         }
  115.       end
  116.         #事件位置开始页显示
  117.       if mod[4] != nil
  118.         mod[4].each {|id,pos|
  119.                 @map.events[id].x=pos[0] if pos[0] != nil
  120.                 @map.events[id].y=pos[1] if pos[1] != nil
  121.                 @map.events[id].startpage=pos[2] if pos[2] != nil  
  122.         }
  123.       end
  124.     end
  125.   end
  126.   
  127.   def chushimap(mapid)
  128.     @mod[mapid]={} if  @mod[mapid]==nil
  129.     @mod[mapid][1]={} if @mod[mapid][1] == nil
  130.     @mod[mapid][2]={} if @mod[mapid][2] == nil
  131.     @mod[mapid][3]={} if @mod[mapid][3] == nil
  132.     @mod[mapid][4]={} if @mod[mapid][4] == nil
  133.     @mod[mapid][5]={} if @mod[mapid][5] == nil
  134.   end

  135.   #--------------------------------------------------------------------------
  136.   # ●  Mod创建新地图
  137.   #--------------------------------------------------------------------------
  138.   def newmap(mapid,w,h)
  139.     @map=RPG::Map.new(w,h) if mapid==$game_map.map_id
  140.     chushimap(mapid)
  141.     @mod[mapid][0] = [w,h]
  142.   end


  143.   #--------------------------------------------------------------------------
  144.   # ●  Mod用图块id改变地图
  145.   #--------------------------------------------------------------------------
  146.   def edit(mapid,x,y,lv,dat)
  147.     @map.data[x,y,lv] = dat if mapid == $game_map.map_id
  148.     chushimap(mapid)
  149.     @mod[mapid][1][[x,y,lv]] = dat
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ●  Mod用图块id改变地图区域
  153.   #--------------------------------------------------------------------------
  154.   def editarea(mapid,x,y,w,h,lv,dat) #lv=0,1,2
  155.     for x1 in x...w+x
  156.       for y1 in y...y+h
  157.         @map.data[x1,y1,lv] = dat if mapid==$game_map.map_id
  158.         chushimap(mapid)
  159.         @mod[mapid][1][[x1,y1,lv]] = dat
  160.       end
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● Mod用地图的区域改变地图
  165.   #--------------------------------------------------------------------------
  166.   def editbymap(mapid,x,y,lv,mapid1,x1,y1,lv1,w1,h1)
  167.     chushimap(mapid)
  168.     if FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid1))
  169.       map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid1))
  170.     end
  171.     x3 = x
  172.     for y2 in x1..h1+(x1-1)
  173.       for x2 in y1..w1+(y1-1)
  174.         dat = @mod[mapid1][1][x2,y2,lv1]
  175.         dat = map1.data[x2,y2,lv1] if dat == nil
  176.         @map.data[x3,y,lv] = dat  if mapid==$game_map.map_id
  177.         @mod[mapid][1][[x3,y,lv]] = dat
  178.         x3 = x3+1
  179.       end
  180.       y = y+1
  181.       x3 = x
  182.     end
  183.   end

  184.   #--------------------------------------------------------------------------
  185.   # ●  Mod创建新事件
  186.   #--------------------------------------------------------------------------
  187.   def newev(ev=nil)
  188.     if ev.is_a?(RPG::Event)
  189.       @map.events[ev.id] =  ev
  190.       @events[ev.id] = Game_Event.new(@map_id , ev)     
  191.       $game_map.need_refresh = true
  192.       $game_map.update
  193.       if $scene.is_a?(Scene_Map)
  194.         $scene.refresh_spriteset       #这里要修改
  195.       end
  196.     end
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ●  Mod复制地图事件到       #添加++++++++++
  200.   #--------------------------------------------------------------------------
  201.   def copyev(fomap=1,foevid=1,tomap=1,x=0,y=0,id=nil)
  202.     ev = nil
  203.     if @mod[fomap] != nil and @mod[fomap][2] != nil
  204.       ev = @mod[fomap][2][foevid].clone if
  205.       @mod[fomap][2][foevid].is_a?(RPG::Event)
  206.     end
  207.     if !ev.is_a?(RPG::Event)
  208.       if FileTest.exist?(sprintf("Data/Map%03d.rxdata", fomap))
  209.         map1 = load_data(sprintf("Data/Map%03d.rxdata", fomap))
  210.         ev = map1.events[foevid].clone if
  211.         map1.events[foevid].is_a?(RPG::Event)
  212.       end
  213.     end
  214.     if ev.is_a?(RPG::Event)
  215.       chushimap(tomap)
  216.       if tomap == @map_id
  217.         if id ==nil
  218.           id=1
  219.           until @events[id] == nil
  220.             id+=1
  221.           end
  222.         end
  223.         ev.id = id
  224.         ev.x = x
  225.         ev.y = y
  226.         @mod[tomap][4].delete(ev.id)
  227.         @mod[tomap][3].delete(ev.id)
  228.         @mod[tomap][2][ev.id]= ev
  229.         newev(ev)
  230.       else
  231.         if FileTest.exist?(sprintf("Data/Map%03d.rxdata", tomap))
  232.           map0 = load_data(sprintf("Data/Map%03d.rxdata", tomap))
  233.         end
  234.         if id ==nil
  235.           id=1
  236.           until (map0.events[id] == nil and @mod[tomap][2][id] == nil )
  237.             id+=1
  238.           end
  239.         end
  240.         ev.id=id
  241.         ev.x=x
  242.         ev.y=y
  243.         @mod[tomap][4].delete(ev.id)
  244.         @mod[tomap][3].delete(ev.id)
  245.         @mod[tomap][2][ev.id]= ev
  246.       end
  247.     end
  248.   end



  249.   #--------------------------------------------------------------------------
  250.   # ● Mod移动事件       #添加++++++++++
  251.   #--------------------------------------------------------------------------
  252.   def evxy(mapid=1,id=1,x=0,y=0)
  253.     chushimap(mapid)
  254.     if mapid == @map_id
  255.       @events[id].moveto(x, y)
  256.       @mod[mapid][4][id]||=[]
  257.       @mod[mapid][4][id][0] = x
  258.       @mod[mapid][4][id][1] = y      
  259.     else
  260.       ev = false
  261.       if @mod[mapid][2][id].is_a?(RPG::Event)
  262.         ev = true
  263.       end
  264.       if ev !=true and
  265.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  266.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  267.         ev = true  if map1.events[id].is_a?(RPG::Event)
  268.       end
  269.       if ev = true
  270.         @mod[mapid][4][id]||=[]
  271.         @mod[mapid][4][id][0] = x
  272.         @mod[mapid][4][id][1] = y      
  273.       end
  274.     end
  275.   end  
  276.   #--------------------------------------------------------------------------
  277.   #  Mod更改事件初始页       #添加++++++++++
  278.   #--------------------------------------------------------------------------
  279.   def evst(mapid=1,id=1,startpage = 0)      
  280.     chushimap(mapid)
  281.     if mapid == @map_id
  282.       @events[id].startpage = startpage
  283.       @events[id].refresh
  284.       @mod[mapid][4][id]||=[]
  285.       @mod[mapid][4][id][2] = startpage
  286.     else
  287.       ev = false
  288.       if @mod[mapid][2][id].is_a?(RPG::Event)
  289.         ev = true
  290.       end
  291.       if ev !=true and
  292.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  293.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  294.         ev = true  if map1.events[id].is_a?(RPG::Event)
  295.       end
  296.       if ev = true
  297.         @mod[mapid][4][id]||=[]
  298.         @mod[mapid][4][id][2] = startpage
  299.       end
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● Mod更改事件朝向       #添加++++++++++
  304.   #--------------------------------------------------------------------------
  305.   def evdic(mapid=1,id=1,dic = 0)
  306.     chushimap(mapid)
  307.     if mapid == @map_id
  308.       case dic
  309.       when 2
  310.         @events[id].turn_down
  311.       when 4
  312.         @events[id].turn_left
  313.       when 6
  314.         @events[id].turn_right
  315.       when 8
  316.         @events[id].turn_up
  317.       end
  318.       @mod[mapid][4][id]||=[]
  319.       @mod[mapid][4][id][3] = dic
  320.     else
  321.       ev = false
  322.       if @mod[mapid][2][id].is_a?(RPG::Event)
  323.         ev = true
  324.       end
  325.       if ev !=true and
  326.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  327.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  328.         ev = true  if map1.events[id].is_a?(RPG::Event)
  329.       end
  330.       if ev = true
  331.         @mod[mapid][4][id]||=[]
  332.         @mod[mapid][4][id][3] = dic
  333.       end
  334.     end
  335.   end  
  336.   #--------------------------------------------------------------------------
  337.   # ●  Mod显示隐藏新事件       #添加++++++++++
  338.   #--------------------------------------------------------------------------
  339.   def evxs(mapid,id,erased = true)
  340.           chushimap(mapid)
  341.     if mapid == @map_id
  342.       @events[id].erased = erased
  343.       @events[id].refresh
  344.       @mod[mapid][4][id]||=[]
  345.       @mod[mapid][4][id][3] = erased
  346.     else
  347.       ev = false
  348.       if @mod[mapid][2][id].is_a?(RPG::Event)
  349.         ev = true
  350.       end
  351.       if ev !=true and
  352.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  353.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  354.         ev = true  if map1.events[id].is_a?(RPG::Event)
  355.       end
  356.       if ev = true
  357.         @mod[mapid][4][id]||=[]
  358.         @mod[mapid][4][id][4] = erased
  359.       end
  360.     end
  361.   end

  362.   #--------------------------------------------------------------------------
  363.   # ● Mod改变事件 位置 开始页,方向     #添加++++++++++
  364.   #--------------------------------------------------------------------------
  365.   def changev(mapid=1,id=1,x=0,y=0,startpage =0,dic=nil)
  366.     chushimap(mapid)
  367.     if mapid == @map_id
  368.       @events[id].moveto(x, y)
  369.       @events[id].startpage = startpage
  370.       @events[id].refresh
  371.       case dic
  372.       when 2
  373.         @events[id].turn_down
  374.       when 4
  375.         @events[id].turn_left
  376.       when 6
  377.         @events[id].turn_right
  378.       when 8
  379.         @events[id].turn_up
  380.       end
  381.       @mod[mapid][3].delete(id)
  382.       @mod[mapid][4][id] = [x,y,startpage,dic]
  383.     else
  384.       ev = false
  385.       if @mod[mapid][2][id].is_a?(RPG::Event)
  386.         ev = true
  387.       end
  388.       if ev !=true and
  389.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  390.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  391.         ev = true  if map1.events[id].is_a?(RPG::Event)
  392.       end
  393.       if ev = true
  394.         @mod[mapid][3].delete(id)
  395.         @mod[mapid][4][id] = [x,y,startpage,dic]
  396.       end
  397.     end
  398.   end
  399.   

  400.   #--------------------------------------------------------------------------
  401.   # ● Mod事件位置重置     #添加++++++++++
  402.   #--------------------------------------------------------------------------
  403.   def evxyre(mapid=1,id=1)
  404.     chushimap(mapid)
  405.     if mapid == @map_id
  406.       @mod[mapid][4][id]||=[]
  407.       @mod[mapid][4][id][0] = nil
  408.       @mod[mapid][4][id][1] = nil   
  409.     else
  410.       ev = false
  411.       if @mod[mapid][2][id].is_a?(RPG::Event)
  412.         ev = true
  413.       end
  414.       if ev !=true and
  415.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  416.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  417.         ev = true  if map1.events[id].is_a?(RPG::Event)
  418.       end
  419.       if ev = true
  420.         @mod[mapid][4][id]||=[]
  421.         @mod[mapid][4][id][0] = nil
  422.         @mod[mapid][4][id][1] = nil      
  423.       end
  424.     end
  425.   end  
  426.   #--------------------------------------------------------------------------
  427.   # ● Mod事件初始页重置     #添加++++++++++
  428.   #--------------------------------------------------------------------------
  429.   def evstre(mapid=1,id=1)
  430.     chushimap(mapid)
  431.     if mapid == @map_id
  432.       @events[id].startpage = 0
  433.       @events[id].refresh
  434.       @mod[mapid][4][id]||=[]
  435.       @mod[mapid][4][id][2] = 0
  436.     else
  437.       ev = false
  438.       if @mod[mapid][2][id].is_a?(RPG::Event)
  439.         ev = true
  440.       end
  441.       if ev !=true and
  442.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  443.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  444.         ev = true  if map1.events[id].is_a?(RPG::Event)
  445.       end
  446.       if ev = true
  447.         @mod[mapid][4][id]||=[]
  448.         @mod[mapid][4][id][2] = 0
  449.       end
  450.     end
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● Mod事件方向重置     #添加++++++++++
  454.   #--------------------------------------------------------------------------
  455.   def evxyre(mapid=1,id=1)
  456.     chushimap(mapid)
  457.     if mapid == @map_id
  458.       @mod[mapid][4][id]||=[]
  459.       @mod[mapid][4][id][3] = nil
  460.     else
  461.       ev = false
  462.       if @mod[mapid][2][id].is_a?(RPG::Event)
  463.         ev = true
  464.       end
  465.       if ev !=true and
  466.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  467.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  468.         ev = true  if map1.events[id].is_a?(RPG::Event)
  469.       end
  470.       if ev = true
  471.         @mod[mapid][4][id]||=[]
  472.         @mod[mapid][4][id][3] = nil     
  473.       end
  474.     end
  475.   end  
  476.   #--------------------------------------------------------------------------
  477.   # ● Mod事件显示重置     #添加++++++++++
  478.   #--------------------------------------------------------------------------
  479.   def evxyre(mapid=1,id=1)
  480.     chushimap(mapid)
  481.     if mapid == @map_id
  482.       @mod[mapid][4][id]||=[]
  483.       @mod[mapid][4][id][4] = nil
  484.     else
  485.       ev = false
  486.       if @mod[mapid][2][id].is_a?(RPG::Event)
  487.         ev = true
  488.       end
  489.       if ev !=true and
  490.         FileTest.exist?(sprintf("Data/Map%03d.rxdata", mapid))
  491.         map1 = load_data(sprintf("Data/Map%03d.rxdata", mapid))
  492.         ev = true  if map1.events[id].is_a?(RPG::Event)
  493.       end
  494.       if ev = true
  495.         @mod[mapid][4][id]||=[]
  496.         @mod[mapid][4][id][4] = nil     
  497.       end
  498.     end
  499.   end  
  500.   #--------------------------------------------------------------------------
  501.   # ● Mod事件重置     #添加++++++++++
  502.   #--------------------------------------------------------------------------
  503.   def evre(mapid=1,id=1)
  504.     chushimap(mapid)
  505.     if mapid == @map_id
  506.       @mod[mapid][3].delete(id)
  507.       @mod[mapid][4].delete(id)
  508.     else
  509.       @mod[mapid][3].delete(id)
  510.       @mod[mapid][4].delete(id)
  511.     end
  512.   end  
  513.   
  514.   
  515.   
  516.   #--------------------------------------------------------------------------
  517.   # ● 保存事件位置    #添加++++++++++
  518.   #--------------------------------------------------------------------------
  519.   def save_event_pos
  520.     chushimap(@map_id)
  521.     if @events != nil
  522.       @events.each{|i,e|
  523.       if e.save_pos?
  524.         @mod[@map_id][3][i]= [e.x,e.y,e.pagenum,e.direction]
  525.       else
  526.         @mod[@map_id][3][i]= nil
  527.       end}
  528.     end
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # ● 读取事件位置    #添加++++++++++
  532.   #--------------------------------------------------------------------------
  533.   def load_event_pos
  534.     chushimap(@map_id)
  535.     mod =@mod[@map_id].clone
  536.     if mod[3] != nil
  537.       mod[3].each {|id,pos|
  538.         next if @events[id] == nil
  539.         next if @events[id].pagenum != pos[2]
  540.         case pos[3]
  541.         when 2
  542.           @events[id].turn_down
  543.         when 4
  544.           @events[id].turn_left
  545.         when 6
  546.           @events[id].turn_right
  547.         when 8
  548.           @events[id].turn_up
  549.         end
  550.       }
  551.     end
  552.     if mod[4] != nil
  553.       mod[4].each {|id,pos|
  554.         next if @events[id] == nil
  555.         case pos[3]
  556.         when 2
  557.           @events[id].turn_down
  558.         when 4
  559.           @events[id].turn_left
  560.         when 6
  561.           @events[id].turn_right
  562.         when 8
  563.           @events[id].turn_up
  564.         end
  565.         @events[id].erase if pos[4] == true
  566.       }
  567.     end
  568.   end
  569. end

  570. #==============================================================================
  571. # ■ Game_Event
  572. #------------------------------------------------------------------------------
  573. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  574. # 在 Game_Map 类的内部使用。
  575. #==============================================================================
  576. module RPG
  577.   class Event
  578.     attr_accessor :startpage
  579.   end
  580. end


  581. class Game_Event < Game_Character
  582.   #--------------------------------------------------------------------------
  583.   # ● 定义实例变量
  584.   #--------------------------------------------------------------------------
  585.   attr_reader   :trigger                  # 目标
  586.   attr_reader   :list                     # 执行内容
  587.   attr_reader   :starting                 # 启动中标志
  588.   attr_accessor :erased
  589.   attr_accessor :pagenum
  590.   attr_accessor :startpage
  591.   
  592.   #--------------------------------------------------------------------------
  593.   # ● 初始化对像
  594.   #     map_id : 地图 ID
  595.   #     event  : 事件 (RPG::Event)
  596.   #--------------------------------------------------------------------------
  597.   def initialize(map_id, event)
  598.     super()
  599.     @map_id = map_id
  600.     @event = event
  601.     @id = @event.id   

  602.     @erased = false
  603.     @starting = false
  604.     @through = true
  605.     # 初期位置的移动
  606.     moveto(@event.x, @event.y)
  607.    
  608.     #修改
  609.     @pagenum = nil
  610.     if event.startpage == nil
  611.       @startpage = 0
  612.     else
  613.       @startpage = event.startpage
  614.     end
  615.     #修改
  616.    
  617.     refresh
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 启动事件    #修改++++++++++
  621.   #--------------------------------------------------------------------------
  622.   def start(num = nil)
  623.     @startpage = num if num != nil
  624.     refresh if num != nil
  625.     # 执行内容不为空的情况下
  626.     if @list != nil and @list.size > 1
  627.       @starting = true
  628.     end
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ● 刷新    #修改++++++++++
  632.   #--------------------------------------------------------------------------
  633.   def refresh
  634.     # 初始化本地变量 new_page
  635.     new_page = nil
  636.     # 无法暂时消失的情况下
  637.     unless @erased
  638.       # 从编号大的事件页按顺序调查
  639.       @pagenum = @event.pages.size + 1
  640.       for page in @event.pages.reverse
  641.         
  642.         #修改++++++++++
  643.         @pagenum -= 1
  644.         new_page = page if @startpage == @pagenum
  645.         break if @startpage == @pagenum
  646.         next if @startpage != 0
  647.         #修改++++++++++
  648.         
  649.         
  650.         # 可以参考事件条件 c
  651.         c = page.condition
  652.         # 确认开关条件 1
  653.         if c.switch1_valid
  654.           if $game_switches[c.switch1_id] == false
  655.             next
  656.           end
  657.         end
  658.         # 确认开关条件 2
  659.         if c.switch2_valid
  660.           if $game_switches[c.switch2_id] == false
  661.             next
  662.           end
  663.         end
  664.         # 确认变量条件
  665.         if c.variable_valid
  666.           if $game_variables[c.variable_id] < c.variable_value
  667.             next
  668.           end
  669.         end
  670.         # 确认独立开关条件
  671.         if c.self_switch_valid
  672.           key = [@map_id, @event.id, c.self_switch_ch]
  673.           if $game_self_switches[key] != true
  674.             next
  675.           end
  676.         end
  677.         # 设置本地变量 new_page
  678.         new_page = page
  679.         # 跳出循环
  680.         break
  681.       end
  682.     end
  683.     # 与上次同一事件页的情况下
  684.     if new_page == @page
  685.       # 过程结束
  686.       return
  687.     end
  688.     # @page 设置为现在的事件页
  689.     @page = new_page
  690.     # 清除启动中标志
  691.     clear_starting
  692.     # 没有满足条件的页面的时候
  693.     if @page == nil
  694.       # 设置各实例变量
  695.       @tile_id = 0
  696.       @character_name = ""
  697.       @character_hue = 0
  698.       @move_type = 0
  699.       @through = true
  700.       @trigger = nil
  701.       @list = nil
  702.       @interpreter = nil
  703.       # 过程结束
  704.       return
  705.     end
  706.     # 设置各实例变量
  707.     @tile_id = @page.graphic.tile_id
  708.     @character_name = @page.graphic.character_name
  709.     @character_hue = @page.graphic.character_hue
  710.     if @original_direction != @page.graphic.direction
  711.       @direction = @page.graphic.direction
  712.       @original_direction = @direction
  713.       @prelock_direction = 0
  714.     end
  715.     if @original_pattern != @page.graphic.pattern
  716.       @pattern = @page.graphic.pattern
  717.       @original_pattern = @pattern
  718.     end
  719.     @opacity = @page.graphic.opacity
  720.     @blend_type = @page.graphic.blend_type
  721.     @move_type = @page.move_type
  722.     @move_speed = @page.move_speed
  723.     @move_frequency = @page.move_frequency
  724.     @move_route = @page.move_route
  725.     @move_route_index = 0
  726.     @move_route_forcing = false
  727.     @walk_anime = @page.walk_anime
  728.     @step_anime = @page.step_anime
  729.     @direction_fix = @page.direction_fix
  730.     @through = @page.through
  731.     @always_on_top = @page.always_on_top
  732.     @trigger = @page.trigger
  733.     @list = @page.list
  734.     @interpreter = nil
  735.     # 目标是 [并行处理] 的情况下
  736.     if @trigger == 4
  737.       # 生成并行处理用解释器
  738.       @interpreter = Interpreter.new
  739.     end
  740.     # 自动事件启动判定
  741.     check_event_trigger_auto
  742.   end

  743.   #--------------------------------------------------------------------------
  744.   # ● 是否储存位置     #修改++++++++++
  745.   #--------------------------------------------------------------------------
  746.   def save_pos?
  747.     return true unless @list
  748.     return true if @list[0].code != 108
  749.     return !@list[0].parameters[0].include?("不保存事件位置")
  750.   end
  751. end

  752. class Scene_Map
  753.   #--------------------------------------------------------------------------
  754.   # ● 重新描绘地图     #修改++++++++++
  755.   #--------------------------------------------------------------------------
  756.   def refresh_spriteset
  757.     @spriteset.dispose
  758.     @spriteset = Spriteset_Map.new
  759.   end
  760. end

复制代码



点评

不是...是之前的那个是很久之前写完就放着的版本,有点bug,另外添加了一个让事件暂时消失的功能(基于原本的事件暂时消失).  发表于 2015-12-2 19:43
恩,是在脚本里注明作者修改者汪汪吧。这个里面已经有写了  发表于 2015-12-2 19:12
用的话用 现在这个吧  发表于 2015-12-2 18:04
 ̄_ ̄||为什么越修改bug越多...  发表于 2015-12-2 18:03
额,刚才做了一下修改...  发表于 2015-12-2 17:46

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部