Project1

标题: 神思走路幻影腳本怎么弄成事件也有效 [打印本页]

作者: ppspssss    时间: 2018-7-28 14:01
标题: 神思走路幻影腳本怎么弄成事件也有效
RUBY 代码复制
  1. #幻影by 66rpg 神思 不知为什么在原点(大慨要在scene_map下
  2. #__END__
  3. class Game_Player < Game_Character
  4.  
  5.   def mirage(opacity)
  6.  
  7.     $scene.spriteset.mirage(self, opacity)
  8.  
  9.   end
  10.  
  11.   alias update_naiyoudadangao update
  12.  
  13.     def update
  14.  
  15.     update_naiyoudadangao
  16.  
  17.     if Input.dir8 != 0
  18.  
  19.     mirage(120)  
  20.  
  21.     end
  22.  
  23.     end
  24.  
  25.   end
  26.   class Game_Event < Game_Character
  27.   def mirage(opacity)
  28.     $scene.spriteset.mirage(self, opacity)
  29.   end
  30. end
  31.  
  32. class Sprite_MirageCharacter < RPG::Sprite
  33.  
  34.   attr_accessor :character            
  35.  
  36.   def initialize(viewport, opacity, character = nil)
  37.  
  38.     super(viewport)
  39.  
  40.     @character = character
  41.  
  42.     self.opacity = opacity
  43.  
  44.     update
  45.  
  46.   end
  47.  
  48.   def update
  49.  
  50.     super
  51.  
  52.     if @tile_id != @character.tile_id or
  53.  
  54.        @character_name != @character.character_name or
  55.  
  56.        @character_hue != @character.character_hue
  57.  
  58.       @tile_id = @character.tile_id
  59.  
  60.       @character_name = @character.character_name
  61.  
  62.       @character_hue = @character.character_hue
  63.  
  64.       if @tile_id >= 384
  65.  
  66.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  67.  
  68.           @tile_id, @character.character_hue)
  69.  
  70.         self.src_rect.set(0, 0, 32, 32)
  71.  
  72.         self.ox = 16
  73.  
  74.         self.oy = 32
  75.  
  76.       else
  77.  
  78.         self.bitmap = RPG::Cache.character(@character.character_name,
  79.  
  80.           @character.character_hue)
  81.  
  82.         @cw = bitmap.width / 4
  83.  
  84.         @ch = bitmap.height / 4
  85.  
  86.         self.ox = @cw / 2
  87.  
  88.         self.oy = @ch
  89.  
  90.         self.x = @character.screen_x
  91.  
  92.         self.y = @character.screen_y
  93.  
  94.       end
  95.  
  96.     end
  97.  
  98.     self.visible = (not @character.transparent)
  99.  
  100.     if @tile_id == 0 and !@t
  101.  
  102.       sx = @character.pattern * @cw
  103.  
  104.       sy = (@character.direction - 2) / 2 * @ch
  105.  
  106.       self.src_rect.set(sx, sy, @cw, @ch)
  107.  
  108.       @t = true
  109.  
  110.     end
  111.  
  112.     self.z = @character.screen_z(@ch)
  113.  
  114.     self.color.set(0,0,170,120)
  115.  
  116.     self.opacity -= 8 #b残像减少(大就没有)小效果多
  117.  
  118.     self.blend_type = 0
  119.  
  120.     self.bush_depth = @character.bush_depth
  121.  
  122.     if @character.animation_id != 0
  123.  
  124.       animation = $data_animations[@character.animation_id]
  125.  
  126.       animation(animation, true)
  127.  
  128.       @character.animation_id = 0
  129.  
  130.     end
  131.  
  132.   end
  133.  
  134. end
  135.  
  136.  
  137.  
  138. class Spriteset_Map
  139.  
  140.   alias initialize_naiyoudadangao  initialize
  141.  
  142.   def initialize
  143.  
  144.     @mirage = {}
  145.  
  146.     initialize_naiyoudadangao   
  147.  
  148.   end
  149.  
  150.   def mirage(obj, opacity)
  151.  
  152.     @mirage[obj] ||= []
  153.  
  154.     smc = Sprite_MirageCharacter.new(@viewport1, opacity, obj)
  155.  
  156.     @mirage[obj] << Mirage.new(obj.real_x, obj.real_y, smc)#(Sprite_MirageCharacter.new(@viewport1, opacity, obj))
  157.  
  158.   end
  159.  
  160.  
  161.  
  162. alias update_naiyoudadangao update
  163.  
  164. def update
  165.  
  166.    update_naiyoudadangao
  167.  
  168.     for value in @mirage.values
  169.  
  170.       for v in value
  171.  
  172.  
  173.         v.smc.x = (v.x - $game_map.display_x + 3) / 4 + 16
  174.  
  175.         v.smc.y = (v.y - $game_map.display_y + 3) / 4 + 32
  176.  
  177.  
  178.         v.smc.update
  179.  
  180.         if v.smc.opacity <= 0
  181.  
  182.           v.smc.dispose
  183.  
  184.           value.delete(v)
  185.  
  186.         end
  187.  
  188.       end
  189.  
  190.     end
  191.  
  192.   end
  193.  
  194. end
  195.  
  196. class Scene_Map
  197.  
  198.   attr_reader   :spriteset
  199.  
  200. end
  201.  
  202. Mirage = Struct.new(:x, :y, :smc)


  class Game_Event < Game_Character
  def mirage(opacity)
    $scene.spriteset.mirage(self, opacity)
  end
end
这个是我加的貌似加了也没效
作者: ppspssss    时间: 2018-8-21 16:04
$game_player.mirage(120)就行了,
事件就$game_map.event_id[XX].mirage(120)
@guoxiaomi




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1