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

Project1

 找回密码
 注册会员
搜索

如何过段时间清除地图上的垃圾keng

查看数: 373 | 评论数: 13 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2024-9-5 17:00

正文摘要:

本帖最后由 金芒芒 于 2024-9-7 09:06 编辑 RUBY 代码复制class Scene_Map   #--------------------------------------------------------  # ●爆炸 (中心X, ...

回复

金芒芒 发表于 7 天前
本帖最后由 金芒芒 于 2024-9-13 07:26 编辑
魔法丶小肉包 发表于 2024-9-12 19:38
你这段可不可以放进去测试一下就知道了,这里详细说一下楼上我给你的思路
1.你在Game_Event里新写一个实 ...


RUBY 代码复制
  1. class Scene_Map
  2.  
  3.   #--------------------------------------------------------
  4.   # ●爆炸 (中心X,中心Y,中心伤害,范围,动画ID,施放者,队伍不受(0是所有人受)是否留垃圾)
  5.   #--------------------------------------------------------  
  6. #定义 EFS爆炸(x,y,ini伤害,范围,动画id,施放者= 无,队伍 =0,垃圾=true)
  7.   def EFS_Explosion(x,y,ini_damage,range,animation_id,shifazhe = nil,team = 0,trash = true)
  8.     if trash#如果垃圾
  9.      #坑= 变魔术出现临时演员 (x,y,“垃圾”,“180-开关03”,8,1,错误)
  10.       keng = conjure_temp(x,y,"trash","180-Switch03",8,1,false)
  11.      #演 = 变魔术出现临时演员(x,y,“垃圾”,“197-支架05”,4,0,true)
  12.       yan = conjure_temp(x,y,"trash","197-Support05",4,0,true)
  13.     end
  14.    #事件=变出临时演员(x,y,“爆炸”,“”,2)
  15.     event = conjure_temp(x,y,"EXPLOSION","",2)
  16.     refresh_screen#刷新屏幕
  17.     event.animation_id = animation_id#事件动画id=动画id
  18.    # $游戏屏幕。开始抖动(功率(x,y,15,1),功率(x、y,20,1)、45)
  19.     $game_screen.start_shake(power(x,y,15,1),power(x,y,20,1),45)
  20.    #$游戏屏幕。启动闪光灯(新颜色(255255255,功率(x,y,100,4)),10)
  21.     $game_screen.start_flash(Color.new(255,255,255,power(x,y,100,4)), 10)
  22.     #对于$游戏地图中的f。战士.价值
  23.     for f in $game_map.fighters.values
  24.       #下一个if团队!=0和f.团队==团队
  25.       next if team != 0 and f.team == team
  26.       next if f.dead?#下一个如果f.死了?
  27.       f_juli = juli(f.x,f.y,x,y)
  28.       if f_juli <= range#范围
  29.        # 伤害=(范围-f_距离)*中心伤害/(范围+0.0)
  30.         damage =  (range-f_juli)*ini_damage/(range+0.0)
  31.         #自然_伤害(f,伤害,施放者,Wzj::ONFIRE_ANIMATION)#士兵着火动画
  32.         nature_damage(f,damage,shifazhe,Wzj::ONFIRE_ANIMATION)
  33.         f.zhafei(x,y,5) if damage >=25# f.施放者(x,y,5) if 伤害 >=25
  34.  
  35.       end
  36.  
  37.  
  38.     end
  39.  
  40.  
  41.     keng .animation_id = 123 #123坑。动画_id=123
  42.  
  43.  
  44.   end
  45.  
  46. #定义 自然伤害(目标、伤害、什法哲、动画)
  47.   def nature_damage(target,damage,shifazhe,animation)
  48.     target.hp -=  damage #目标 hp-= 伤害
  49.    # p EFS_Hero
  50.     if target.dead? #如果目标死了
  51.       target.dead #目标死了
  52.       #提示信息
  53.       display_nature_killing_msg(target,shifazhe)#跳转定义显示自然杀伤信息(目标,释放者)
  54.     end  
  55.     #如果目标是玩家控制的英雄
  56.     if target.is_a?(EFS_Hero)
  57.      #游戏场景 开始摇晃(5,10,20)
  58.       $game_screen.start_shake(5,10,20)
  59.       unless target.hero_get_hit_se==nil#除非目标。英雄被击中==无
  60.       Audio.se_play("Audio/SE/"+target.hero_get_hit_se+ (rand(target.hero_get_hit_se_num)+1).to_s,100, 100)
  61.       end      
  62.     end
  63.  
  64.     #闪烁动画
  65.      target.animation_id=  animation if damage >=25#闪烁动画=如果损坏>=25,则显示动画
  66.  
  67.  
  68.   end
  69.  
  70.   def display_nature_killing_msg(target,shifazhe)#显示自然杀伤信息(目标,释放者)
  71.   # p shifazhe
  72.     return if target==nil
  73.  
  74.     if(shifazhe == nil)
  75.       if(target.team == 2)#敌军
  76.         if target.dead?
  77.           if target.killed?
  78.             Notification.font.color =  Wzj::T_K_E_COLOR
  79.             Notification.post(target.the_name+"被杀了")
  80.             Notification.font.color = Wzj::NORMAL_COLOR
  81.           else
  82.             Notification.font.color =  Wzj::T_B_E_COLOR
  83.             Notification.post(target.the_name+"被击昏了")
  84.             Notification.font.color = Wzj::NORMAL_COLOR
  85.           end
  86.         end
  87.       else#我军
  88.         if target.dead?
  89.           if target.killed?
  90.             Notification.font.color =  Wzj::E_K_T_COLOR
  91.             Notification.post(target.the_name+"被杀了")
  92.             Notification.font.color = Wzj::NORMAL_COLOR
  93.           else
  94.             Notification.font.color =  Wzj::E_B_T_COLOR
  95.             Notification.post(target.the_name+"被击昏了")
  96.             Notification.font.color = Wzj::NORMAL_COLOR
  97.           end
  98.         end
  99.       end  #if(target.team == 2)#敌军
  100.     else #if 释放者 != nil
  101.             if(target.team == 2)#敌军
  102.         if target.dead?
  103.           if target.killed?
  104.             Notification.font.color =  Wzj::T_K_E_COLOR
  105.             Notification.post(target.the_name+"被杀了")
  106.             Notification.font.color = Wzj::NORMAL_COLOR
  107.           else
  108.             Notification.font.color =  Wzj::T_B_E_COLOR
  109.             Notification.post(target.the_name+"被击昏了")
  110.             Notification.font.color = Wzj::NORMAL_COLOR
  111.           end
  112.         end
  113.       else#我军
  114.         if target.dead?
  115.           if target.killed?
  116.             Notification.font.color =  Wzj::E_K_T_COLOR
  117.             Notification.post(target.the_name+"被杀了")
  118.             Notification.font.color = Wzj::NORMAL_COLOR
  119.           else
  120.             Notification.font.color =  Wzj::E_B_T_COLOR
  121.             Notification.post(target.the_name+"被击昏了")
  122.             Notification.font.color = Wzj::NORMAL_COLOR
  123.           end
  124.         end
  125.       end  #if(target.team == 2)#敌军
  126.         if target.team == 2 #di军
  127.           if target.dead?
  128.             if target.killed?
  129.               Notification.font.color =  Wzj::T_K_E_COLOR
  130.               Notification.post(shifazhe.the_name+"击杀了"+target.the_name)
  131.               Notification.font.color = Wzj::NORMAL_COLOR
  132.             else
  133.               Notification.font.color =  Wzj::T_B_E_COLOR
  134.               Notification.post(shifazhe.the_name+"打昏了"+target.the_name)
  135.               Notification.font.color = Wzj::NORMAL_COLOR
  136.             end
  137.           end
  138.         else #wo军
  139.           if target.dead?
  140.             if target.killed?
  141.               Notification.font.color =  Wzj::E_K_T_COLOR
  142.               Notification.post(shifazhe.the_name+"击杀了"+target.the_name)
  143.               Notification.font.color = Wzj::NORMAL_COLOR
  144.             else
  145.               Notification.font.color =  Wzj::E_B_T_COLOR
  146.               Notification.post(shifazhe.the_name+"打昏了"+target.the_name)
  147.               Notification.font.color = Wzj::NORMAL_COLOR
  148.             end #shasile
  149.  
  150.           end #死了
  151.  
  152.         end  #哪个军
  153.  
  154.  
  155.     end #释放者
  156.  
  157.  
  158.  
  159.  
  160.   end # def
  161.  
  162.   def power(x,y,initial,rate)#功率(x,y,初始,速率)
  163.     unless @player_controll#除非@player控制
  164.       #方向=(x - $游戏玩家.x).绝对值 + (y - $游戏玩家.y).绝对值
  165.     d = (x - $game_player.x).abs + (y - $game_player.y).abs
  166.   else
  167.     #方向=(x - $现任领导人.x).绝对值 + (y - $现任领导人.y).绝对值
  168.     d = (x - @current_leader.x).abs + (y - @current_leader.leader.y).abs
  169.     end
  170.     v = initial - d*rate
  171.     return 0 if v <= 0
  172.     return v
  173.   end
  174.  
  175.   # 生成临时物
  176.   def conjure_temp(x,y,name,character_name,d,pattern = 0,moving = false)
  177.    # p conjure_temp
  178.     e = Game_Event.new($game_map.map_id,produce_event_temp(x,y,name,character_name,d,pattern,moving))
  179.     # 生成实例
  180.     $game_map.events[$game_map.events.size+1] = e
  181.     # 处理各项属性
  182.     $game_map.map.events[$game_map.events.size] = produce_event_temp(x,y,name,character_name,d,pattern,moving)
  183.     return e
  184.   end
  185.  
  186.  
  187.   def refresh_screen
  188.     # 重置
  189.     @spriteset.dispose
  190.     @spriteset = Spriteset_Map.new
  191. #    @spriteset.efs_refresh_character
  192.  
  193.  
  194.   end  
  195. #end
  196.  
  197. #=begin
  198.   # 开始生产召唤物+++++++++++++
  199.   #产生事件临时
  200.   def produce_event_temp(x,y,name,character_name,d,pattern = 0,moving = false)
  201.     e = RPG::Event.new(x,y)
  202.     e.id = $game_map.events.size
  203.   #  p e.id
  204.     e.name = name
  205.              # 角色扮演游戏::事件::页面。新
  206.     e.pages = [RPG::Event::Page.new]
  207.    # e.第[0].页图形
  208.     e.pages[0].graphic = RPG::Event::Page::Graphic.new
  209.     e.pages[0].graphic.character_name = character_name#图形字符名
  210.  
  211.     e.pages[0].graphic.pattern = pattern
  212.     e.pages[0].graphic.direction = d #方向
  213.     e.pages[0].through = true
  214.     e.pages[0].move_frequency = 6
  215.     e.pages[0].move_speed = 3
  216.     e.pages[0].step_anime = moving
  217. # p  e.pages[0].graphic.character_name
  218. #  p  produce_event_temp[0]
  219.     return e
  220.   end
  221. end
魔法丶小肉包 发表于 2024-9-12 19:38:34
金芒芒 发表于 2024-9-12 16:11
先研究一下我对脚本不熟悉 下面的脚本可以吗
把血迹改成垃圾keng
class Spriteset_Map

你这段可不可以放进去测试一下就知道了,这里详细说一下楼上我给你的思路
1.你在Game_Event里新写一个实例变量记录一个时间,初始值为nil
RUBY 代码复制
  1. class Game_Event
  2.   attr_accessor :keng_time
  3.   alias mf240912initialize initialize
  4.   def initialize(map_id, event)
  5.     mf240912initialize(map_id, event)
  6.     @keng_time = nil
  7.   end
  8. end


2.在创建坑事件的时候给这个实例变量赋值(可以使用rand来赋予每个事件存在的时间随机化)
首先要找到该方法,假设是你7楼贴出的"召唤的函数"那个,这里只是假设,如果生成坑的方法不是这个,你需要找到对应的方法然后按照例子来做
并且假设要让每个坑存在的时间随机在一定范围内的话,假设设定60~120帧
RUBY 代码复制
  1. # 召唤的函数
  2.   def conjure_slg(x,y,name,character_name,d)
  3.     # 生成实例
  4.     $game_map.events[$game_map.events.size+1] = Game_Event.new($game_map.map_id,produce_event_slg(x,y,name,character_name,d))
  5.  
  6.     #赋予存在时间
  7.     $game_map.events[$game_map.events.size+1].keng_time = rand(61) + 60
  8.  
  9.     # 处理各项属性
  10.     $game_map.map.events[$game_map.events.size] = produce_event_slg(x,y,name,character_name,d)
  11.     # 重置
  12.     @spriteset.dispose
  13.     @spriteset = Spriteset_Map.new
  14.  
  15.   end


3.在update相关的方法里进行所有事件每n秒该实例变量-1的操作,条件是if 该实例变量
找到Scene_Map的update方法,在里面写入
RUBY 代码复制
  1. $game_map.events.values.each do |e|
  2.   e.keng_time -= 1 if e.keng_time
  3. end


4.当该实例变量<=0的时候,把该事件erase掉然后在$game_map.events里删除该事件
同样还是Scene_Map的update方法,刚刚的循环中继续写下去,3里刚刚那段也包括在里面了
RUBY 代码复制
  1. @del_event ||= []
  2. $game_map.events.values.each do |e|
  3.   if e.keng_time
  4.     e.keng_time -= 1
  5.     if e.keng_time <= 0
  6.       e.erase
  7.       @del_event << e
  8.     end
  9.   end
  10. end
  11. if @del_event != []
  12.   @del_event.each {|e| $game_map.events.delete($game_map.events.index(e))}
  13.   @del_event = []
  14. end


5.附加:1~4是为你提供例子,如果照做之后发现有细节上的问题是需要做小修改才能正常运行的
金芒芒 发表于 2024-9-12 16:11:16
本帖最后由 金芒芒 于 2024-9-12 16:17 编辑
魔法丶小肉包 发表于 2024-9-11 16:25
1.你在Game_Event里新写一个实例变量记录一个时间,初始值为nil
2.在创建坑事件的时候给这个实例变量赋值( ...

先研究一下我对脚本不熟悉 下面的脚本可以吗
把血迹改成垃圾keng
class Spriteset_Map
@EFS_bloods = []#血迹

def dispose
  for b in @EFS_bloods
       b.dispose
    end  

DEFAULT_BLOOD_DISAPPEAR_TIME = 300


  1. #==============================================================================
  2. # ■ Sprite_Character
  3. #------------------------------------------------------------------------------
  4. #  角色显示用脚本。监视 Game_Character 类的实例、
  5. # 自动变化脚本状态。
  6. #==============================================================================
  7. class Game_Blood
  8.   attr_accessor :fighter
  9.   attr_accessor :real_x
  10.   attr_accessor :real_y
  11.   attr_reader   :rand_x
  12.   attr_reader   :rand_y
  13.   def initialize(fighter)
  14.     @fighter = fighter
  15.     @real_x = fighter.real_x #- 34
  16.     @real_y = fighter.real_y
  17.     @rand_x =  rand(4)*100
  18.     @rand_y = rand(4)*100
  19.   end  
  20.   def screen_x
  21.     return (@real_x - $game_map.display_x + 3) / 4 + 16
  22.   end
  23.   def screen_y
  24.     y = (@real_y - $game_map.display_y + 3) / 4 + 32
  25.     return y
  26.   end
  27.   
  28.   
  29. end

  30. class Sprite_Blood < RPG::Sprite
  31.   #--------------------------------------------------------------------------
  32.   # ● 定义实例变量
  33.   #--------------------------------------------------------------------------
  34.   #attr_accessor :arrow         
  35.   attr_reader :deleteable
  36.   #--------------------------------------------------------------------------
  37.   # ● 初始化对像
  38.   #     viewport  : 查看端口
  39.   #--------------------------------------------------------------------------
  40.   def initialize(viewport,blood)
  41.     super(viewport)
  42.     @blood = blood
  43.     self.opacity = 165
  44.     self.z = 9
  45.     self.ox = 50
  46.     self.oy = 75
  47.     self.bitmap=RPG::Cache.character("DROP_Blood",0)
  48.     self.src_rect.set(blood.rand_x,blood.rand_y, 100, 100)
  49.    
  50.     @deleteable = false
  51.     @disappear_time = Wzj::DEFAULT_BLOOD_DISAPPEAR_TIME
  52.     @stop_count = 0
  53.   end
  54.   
  55.   def drop_blood(blood)
  56.     @blood = blood
  57.     #self.opacity = 205
  58.     self.zoom_x = 0
  59.     self.zoom_y = 0
  60.    
  61.     self.opacity = 145
  62.     self.z = 9
  63.     self.bitmap=RPG::Cache.character("DROP_Blood",0)

  64.    # rand_x = rand(4)*100
  65.    # rand_y = rand(4)*100

  66.     self.src_rect.set(blood.rand_x,blood.rand_y, 100, 100)
  67.     self.ox = 50
  68.     self.oy = 75
  69.    
  70.    
  71.     update
  72.   end  
  73.   
  74.   #--------------------------------------------------------------------------
  75.   # ● 更新画面
  76.   #--------------------------------------------------------------------------
  77.   def update
  78.     super
  79.     #return if @blood == nil
  80.     self.x = @blood.screen_x
  81.     self.y = @blood.screen_y - 32

  82.     if self.zoom_x  >= 1
  83.       
  84.       @stop_count+=1
  85.       
  86.       if @stop_count > @disappear_time
  87.         @deleteable = true
  88.       elsif @stop_count > @disappear_time - 40
  89.         self.opacity -= 165/40
  90.       end  
  91.       return
  92.     end  
  93.       
  94.     self.zoom_x += 0.03
  95.     self.zoom_y += 0.03
  96.       
  97.   end
  98.   
  99.   

  100.   
  101.   
  102. end
复制代码
魔法丶小肉包 发表于 2024-9-11 16:25:43
1.你在Game_Event里新写一个实例变量记录一个时间,初始值为nil
2.在创建坑事件的时候给这个实例变量赋值(可以使用rand来赋予每个事件存在的时间随机化)
3.在update相关的方法里进行所有事件每n秒该实例变量-1的操作,条件是if 该实例变量
4.当该实例变量<=0的时候,把该事件erase掉然后在$game_map.events里删除该事件(只要该实例变量的值不为nil的话就一定是坑事件,所以不用特别判断哪个是坑)
soulsaga 发表于 2024-9-10 20:10:06
金芒芒 发表于 2024-9-10 13:00
character_name = keng
keng = conjure_temp(x,y,"trash","180-Switch03",8,1,false)
yan = conjure_tem ...

之后等大佬搞就行了
soulsaga 发表于 2024-9-10 10:30:22
金芒芒 发表于 2024-9-10 10:21
# 召唤的函数
  def conjure_slg(x,y,name,character_name,d)
    # 生成实例

看来只能从character_name着手
你的character_name是什么呢?
金芒芒 发表于 2024-9-10 10:21:31
soulsaga 发表于 2024-9-9 19:01
你要除坑
先要知道怎么判断这个事件是坑

  # 召唤的函数
  def conjure_slg(x,y,name,character_name,d)
    # 生成实例
    $game_map.events[$game_map.events.size+1] = Game_Event.new($game_map.map_id,produce_event_slg(x,y,name,character_name,d))
    # 处理各项属性
    $game_map.map.events[$game_map.events.size] = produce_event_slg(x,y,name,character_name,d)
    # 重置
    @spriteset.dispose
    @spriteset = Spriteset_Map.new

  end
  
  # 开始生产召唤物
  def produce_event_slg(x,y,name,character_name,d)
    e = RPG::Event.new(x,y)
    e.id = $game_map.events.size
    e.name = name
    e.pages = [RPG::Event::Page.new]   
    e.pages[0].graphic = RPG::Event::Page::Graphic.new
    e.pages[0].graphic.character_name = character_name
    e.pages[0].graphic.direction = d
    e.pages[0].through = false
    return e
  end
  

  
end
soulsaga 发表于 2024-9-9 19:01:51
你要除坑
先要知道怎么判断这个事件是坑
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-9-20 12:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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