Project1

标题: 太阳影子脚本 [打印本页]

作者: 欧买歌    时间: 2014-1-8 13:40
标题: 太阳影子脚本
本帖最后由 欧买歌 于 2014-1-23 19:25 编辑

我在6r找不到,大大们帮我找找。
作者: 紫英晓狼1130    时间: 2014-1-8 19:29
http://rpg.blue/forum.php?mod=viewthread&tid=112237
作者: 你最珍贵    时间: 2014-1-8 21:38
使用方法:在事件第一页添加注释,内容为『s』,小写。这就是光源的设置方法。

  1. #A shadow is created when an opaque object is near a light source,
  2. #so in the event that is the light source (example:fire)
  3. #put a comment (on page 1) and simlpy write 's' (without the apostraphys)

  4. #Insert a new class called Character_Shadow above MAIN  

  5. #==============================================================================
  6. # 仭 Sprite_Shadow (Sprite_Ombre )
  7. # Based on Genzai Kawakami's shadows, dynamisme&features by Rataime, extra features Boushy
  8. #==============================================================================

  9. CATERPILLAR_COMPATIBLE = true

  10. class Game_Party
  11. attr_reader :characters
  12. end

  13. class Sprite_Shadow < RPG::Sprite

  14. attr_accessor :character

  15. def initialize(viewport, character = nil,source = nil,anglemin=0,anglemax=0,distancemax=0)
  16.    super(viewport)
  17.    @anglemin=anglemin.to_f
  18.    @anglemax=anglemax.to_f
  19.    @distancemax=distancemax.to_f
  20.    @character = character
  21.    [url=home.php?mod=space&uid=171370]@source[/url] = source
  22.    update
  23. end

  24. def update
  25.    super
  26.    
  27.    if @tile_id != @character.tile_id or
  28.       @character_name != @character.character_name or
  29.       @character_hue != @character.character_hue
  30.      @tile_id = @character.tile_id
  31.      @character_name = @character.character_name
  32.      @character_hue = @character.character_hue
  33.      if @tile_id >= 384
  34.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  35.          @tile_id, @character.character_hue)
  36.        self.src_rect.set(0, 0, 32, 32)
  37.        self.ox = 16
  38.        self.oy = 32
  39.      else
  40.        self.bitmap = RPG::Cache.character(@character.character_name,
  41.          @character.character_hue)
  42.        @cw = bitmap.width / 4
  43.        @ch = bitmap.height / 4
  44.        self.ox = @cw / 2
  45.        self.oy = @ch
  46.      end
  47.    end
  48.    self.visible = (not @character.transparent)
  49.    if @tile_id == 0
  50.      sx = @character.pattern * @cw
  51.      sy = (@character.direction - 2) / 2 * @ch
  52.      if self.angle>90 or angle<-90
  53.        if @character.direction== 6
  54.               sy = ( 4- 2) / 2 * @ch
  55.        end
  56.        if @character.direction== 4
  57.               sy = ( 6- 2) / 2 * @ch
  58.        end
  59.        if @character.direction== 2
  60.               sy = ( 8- 2) / 2 * @ch
  61.        end
  62.        if @character.direction== 8
  63.               sy = ( 2- 2) / 2 * @ch
  64.        end
  65.      end
  66.      self.src_rect.set(sx, sy, @cw, @ch)
  67.    end
  68.    self.x = @character.screen_x
  69.    self.y = @character.screen_y-5
  70.    self.z = @character.screen_z(@ch)-1
  71.    self.opacity = @character.opacity
  72.    self.blend_type = @character.blend_type
  73.    self.bush_depth = @character.bush_depth
  74.    if @character.animation_id != 0
  75.      animation = $data_animations[@character.animation_id]
  76.      animation(animation, true)
  77.      @character.animation_id = 0
  78.    end
  79.    @[email protected]
  80.    @deltay= @source.y-self.y
  81.    self.angle = 57.3*Math.atan2(@deltax, @deltay )
  82.    @angle_trigo=self.angle+90
  83.    if @angle_trigo<0
  84.      @angle_trigo=360+@angle_trigo
  85.    end
  86.    self.color = Color.new(0, 0, 0)
  87.    @distance = ((@deltax ** 2) + (@deltay ** 2))
  88.    if$game_map.shadows==-1
  89.      self.opacity = 0
  90.    else
  91.      self.opacity = 1200000/(@distance+6000)   
  92.    end
  93.    @distance = @distance ** 0.5
  94.    if @distancemax !=0 and @distance>=@distancemax
  95.      self.opacity=0
  96.    end
  97.    if @anglemin !=0 or @anglemax !=0
  98.       if (@angle_trigo<@anglemin or @angle_trigo>@anglemax) and @anglemin<@anglemax
  99.         self.opacity=0
  100.       end
  101.       if (@angle_trigo<@anglemin and @angle_trigo>@anglemax) and @anglemin>@anglemax
  102.         self.opacity=0
  103.       end     
  104.    end
  105. end
  106. end

  107. #===================================================
  108. # 仴 CLASS Sprite_Character edit
  109. #===================================================

  110. class Sprite_Character < RPG::Sprite
  111. alias shadow_initialize initialize

  112. def initialize(viewport, character = nil)
  113.    @character = character
  114.    super(viewport)
  115.    @ombrelist=[]
  116.    if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["s"])
  117.      if (character.list[1]!=nil and character.list[1].code == 108)
  118.        @anglemin=character.list[1].parameters[0]
  119.      end
  120.      if (character.list[2]!=nil and character.list[2].code == 108)
  121.        @anglemax=character.list[2].parameters[0]
  122.      end
  123.      if (character.list[3]!=nil and character.list[3].code == 108)
  124.        @distancemax=character.list[3].parameters[0]
  125.      end  
  126.     for i in $game_map.events.keys.sort
  127.      if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["o"])
  128.        @ombrelist[i+1] = Sprite_Shadow.new(viewport, $game_map.events[i],self,@anglemin,@anglemax,@distancemax)
  129.      end
  130.     end
  131.     @ombrelist[1] = Sprite_Shadow.new(viewport, $game_player,self,@anglemin,@anglemax,@distancemax)
  132. #===================================================
  133. # 仠 Compatibility with fukuyama's caterpillar script
  134. #===================================================
  135. if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil

  136. for member in $game_party.characters
  137.    @ombrelist.push(Sprite_Shadow.new(viewport, member,self,@anglemin,@anglemax,@distancemax))
  138. end

  139. end
  140. #===================================================
  141. # 仠 End of the compatibility
  142. #===================================================
  143.    end
  144.    shadow_initialize(viewport, @character)
  145. end

  146. alias shadow_update update

  147. def update
  148.    shadow_update
  149.    if @ombrelist!=[]
  150.      for i in [email protected]
  151.        if @ombrelist[i]!=nil
  152.          @ombrelist[i].update
  153.        end
  154.      end
  155.    end
  156. end  

  157. end

  158. #===================================================
  159. # 仴 CLASS Scene_Save edit
  160. #===================================================
  161. class Scene_Save < Scene_File

  162. alias shadows_write_save_data write_save_data

  163. def write_save_data(file)
  164.    $game_map.shadows = nil
  165.    shadows_write_save_data(file)
  166. end
  167. end

  168. #===================================================
  169. # 仴 CLASS Game_Map edit
  170. #===================================================
  171. class Game_Map
  172. attr_accessor :shadows
  173. end

复制代码





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