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

Project1

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

[已经解决] 请问一下这个光影脚本怎么用?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
211 小时
注册时间
2011-10-2
帖子
35
跳转到指定楼层
1
发表于 2012-10-26 22:53:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 Mic_洛洛 于 2012-11-13 23:05 编辑

好像是某个人的va大集合里的,我不知道怎么设置特定的地图有光影的效果。
RUBY 代码复制
  1. #------------------------------------------------------------------------------#
  2. # Name:     Auto/Event-Light Reborn                                            #
  3. # By:       SojaBird                                                           #
  4. # Version:  Reborn 4.1                                                         #
  5. #                                                                              #
  6. # Date:     30-08-09                                                           #
  7. #------------------------------------------------------------------------------#
  8.  
  9. $imported = {} if $imported == nil
  10. $imported["SojaBird_AutoLight"] = true
  11.  
  12. #------------------------------------------------------------------------------#
  13. # Call Script                                                                  #
  14. #------------------------------------------------------------------------------#
  15. # - AL.mode(val)                 #                                             #
  16. # - AL.light(parm, val)          # parm: name, opacity, blend, visible         #
  17. # - AL.shadow(parm, val)         # parm: name, opacity, blend, visible         #
  18. # - AL.spot(parm, val)           # parm: name, opacity, blend, visible         #
  19. # - AL.flicker(parm, val)        # parm: opacity, width, height, x, y          #
  20. #                                #                                             #
  21. # - EL.bitmap(val, index = nil)  #                                             #
  22. # - EL.color(val, index = nil)   #                                             #
  23. # - EL.opacity(val, index = nil) #                                             #
  24. # - EL.blend(val, index = nil)   #                                             #
  25. # - EL.visible(val, index = nil) #                                             #
  26. # - EL.zoom(val, index = nil)    #                                             #
  27. #------------------------------------------------------------------------------#
  28.  
  29. #------------------------------------------------------------------------------#
  30. # How to use                                                                   #
  31. #------------------------------------------------------------------------------#
  32. # *AutoLight                                                                   #
  33. #  MODE 0/2                                                                    #
  34. #   To use autolights, put a light- and/or shadow-map picture in the           #
  35. #   folder ../Graphics/Pictures/                                               #
  36. #   Name to picture correct! Start with the, by you set, light- and/or         #
  37. #   shadow-map name, followed by the corresponding map-ID.                     #
  38. #   Put the AutoLight mode to 0 or 2 to show light- and/or shadow-maps.        #
  39. #                                                                              #
  40. #  MODE 1/2                                                                    #
  41. #   To use the spot, put your spotpicture in the folder ../Graphics/Pictures/  #
  42. #   and set the name correct!                                                  #
  43. #   Put the AutoLight mode to 1 or 2 to show the spot.                         #
  44. #                                                                              #
  45. #                                                                              #
  46. # *EventLight                                                                  #
  47. #   To make a event cast a light, give it a comment with the following code:   #
  48. #     cast(*picture, *color, *opacity, *blend_type, *zoom)                     #
  49. #   All the parameters are optional. Default they are set to:                  #
  50. #     picture:    Default, set in the module                                   #
  51. #     color:      White                                                        #
  52. #     opacity:    255                                                          #
  53. #     blend_type: 1                                                            #
  54. #     zoom:       100                                                          #
  55. #   For the color you can choose:                                              #
  56. #    - white                                                                   #
  57. #    - red                                                                     #
  58. #    - green                                                                   #
  59. #    - blue                                                                    #
  60. #    - yellow                                                                  #
  61. #    - orange                                                                  #
  62. #    - purple                                                                  #
  63. #    - random (one of above, but not the same as it is at the moment (if set)) #
  64. #                                                                              #
  65. #------------------------------------------------------------------------------#
  66.  
  67. #--------------------------#
  68. # Customization AutoLights #
  69. #--------------------------#
  70. module AL
  71.  
  72.   #0 = Light and/or Shadow
  73.   #1 = Spot
  74.   #2 = Both
  75.   Mode = 0
  76.  
  77.   module Light
  78.     Name    = "Light"
  79.     Opacity = 150
  80.     Blend   = 1
  81.     Visible = true
  82.  
  83.   end
  84.   module Shadow
  85.     Name    = "Shadow"
  86.     Opacity = 150
  87.     Blend   = 2
  88.     Visible = true
  89.  
  90.   end
  91.   module Spot
  92.     Name    = "Spot"
  93.     Opacity = 255
  94.     Blend   = 2
  95.     Visible = true
  96.  
  97.     module Flicker
  98.       Opacity = 2 #Random opacity change
  99.       Width   = 2 #Random horizontal zoom
  100.       Height  = 2 #Random vertical zoom
  101.       X       = 2 #Random horizontal movement
  102.       Y       = 2 #Random vertical movement
  103.     end
  104.  
  105.   end
  106.  
  107. end
  108.  
  109.  
  110. #---------------------------#
  111. # Customization EventLights #
  112. #---------------------------#
  113. module EL
  114.  
  115.   Default = "EventLight"
  116.  
  117.   module Flicker
  118.     Opacity = 2 #Random opacity change
  119.     Width   = 2 #Random horizontal zoom
  120.     Height  = 2 #Random vertical zoom
  121.     X       = 2 #Random horizontal movement
  122.     Y       = 2 #Random vertical movement
  123.   end
  124.  
  125. end
  126.  
  127.  
  128. #\####/\####/\####/\####/\##------------------------##/\####/\####/\####/\####/#
  129. ##\##/##\##/##\##/##\##/##\# DON'T CROSS THIS LINE! #/##\##/##\##/##\##/##\##/##
  130. ###\/####\/####\/####\/####\------------------------/####\/####\/####\/####\/###
  131.  
  132.  
  133. #---------------------------#
  134. # Script playerlight engine #
  135. #---------------------------#
  136. class AutoLight
  137.  
  138.   include AL
  139.  
  140.   def initialize
  141.     @map_id = $game_map.map_id
  142.     @light_exist = check_existence("#{Light::Name}#{@map_id}")
  143.     @shadow_exist = check_existence("#{Shadow::Name}#{@map_id}")
  144.     @spot_exist = check_existence("#{Spot::Name}")
  145.     create_lights
  146.   end
  147.  
  148.   def check_existence(file)
  149.     format_list = [".png", ".jpeg", ".jpg"]
  150.     format_list.each do |format|
  151.       return true if FileTest.exist?("Graphics/Pictures/#{file}#{format}")
  152.     end
  153.     return false
  154.   end
  155.  
  156.   def create_lights
  157.     @viewport = Viewport.new(0, 0, 544, 416)
  158.     case Mode
  159.     when 0
  160.       draw_light
  161.       draw_shadow
  162.     when 1
  163.       draw_spot
  164.     when 2
  165.       draw_light
  166.       draw_shadow
  167.       draw_spot
  168.     end
  169.     update
  170.   end
  171.  
  172.   def draw_light
  173.     return if !@light_exist
  174.     @light = Sprite.new(@viewport)
  175.     @light.bitmap = Cache.picture("#{Light::Name}#{@map_id}")
  176.     @light.z = 9998
  177.     @light.opacity = Light::Opacity
  178.     @light.blend_type = Light::Blend
  179.     @light.visible = Light::Visible
  180.   end
  181.  
  182.   def draw_shadow
  183.     return if !@shadow_exist
  184.     @shadow = Sprite.new(@viewport)
  185.     @shadow.bitmap = Cache.picture("#{Shadow::Name}#{@map_id}")
  186.     @shadow.z = 9997
  187.     @shadow.opacity = Shadow::Opacity
  188.     @shadow.blend_type = Shadow::Blend
  189.     @shadow.visible = Shadow::Visible
  190.   end
  191.  
  192.   def draw_spot
  193.     return if !@spot_exist
  194.     @spot = Sprite.new(@viewport)
  195.     @spot.bitmap = Cache.picture("#{Spot::Name}")
  196.     @spot.z = 9999
  197.     @spot.opacity = Spot::Opacity
  198.     @spot.blend_type = Spot::Blend
  199.     @spot.visible = Spot::Visible
  200.   end
  201.  
  202.   def update
  203.     @map_x = $game_map.display_x    / 8
  204.     @map_y = $game_map.display_y    / 8
  205.     @player_x = $game_player.real_x / 8
  206.     @player_y = $game_player.real_y / 8
  207.     case Mode
  208.     when 0
  209.       update_light
  210.       update_shadow
  211.     when 1
  212.       update_spot
  213.     when 2
  214.       update_light
  215.       update_shadow
  216.       update_spot
  217.     end
  218.   end
  219.  
  220.   def update_light
  221.     return if !(@light_exist and !@light.nil?)
  222.     @light.visible = Light::Visible
  223.     return if !(@light.x == 0 or
  224.                 @light.y == 0 or
  225.                 @light.x != @map_x / 256 or
  226.                 @light.y != @map_y / 256)
  227.     @light.x = -@map_x
  228.     @light.y = -@map_y
  229.   end
  230.  
  231.   def update_shadow
  232.     return if !(@shadow_exist and !@shadow.nil?)
  233.     @shadow.visible = Shadow::Visible
  234.     return if !(@shadow.x == 0 or
  235.                 @shadow.y == 0 or
  236.                 @shadow.x != @map_x / 256 or
  237.                 @shadow.y != @map_y / 256)
  238.     @shadow.x = -@map_x
  239.     @shadow.y = -@map_y
  240.   end
  241.  
  242.   def update_spot
  243.     return if !(@spot_exist and !@spot.nil?)
  244.     @spot.visible = Spot::Visible
  245.     @spot.opacity = Spot::Opacity + rand(Spot::Flicker::Opacity) -
  246.                                     rand(Spot::Flicker::Opacity)
  247.     @spot.zoom_x = 1 + (rand(Spot::Flicker::Width)  / 100.0) -
  248.                        (rand(Spot::Flicker::Width)  / 100.0)
  249.     @spot.x = @player_x - @map_x - (@spot.width / 2) + 16 +
  250.                         rand(Spot::Flicker::X) - rand(Spot::Flicker::X)
  251.     @spot.zoom_y = 1 + (rand(Spot::Flicker::Height) / 100.0) -
  252.                        (rand(Spot::Flicker::Height) / 100.0)
  253.     @spot.y = @player_y - @map_y - (@spot.height / 2) + 16 +
  254.                         rand(Spot::Flicker::Y) - rand(Spot::Flicker::Y)
  255.   end
  256.  
  257.   def dispose
  258.     case Mode
  259.     when 0
  260.       dispose_light
  261.       dispose_shadow
  262.     when 1
  263.       dispose_spot
  264.     when 2
  265.       dispose_light
  266.       dispose_shadow
  267.       dispose_spot
  268.     end
  269.     @viewport.dispose
  270.   end
  271.  
  272.   def dispose_light
  273.     return if !(@light_exist and !@light.nil?)
  274.     @light.dispose
  275.   end
  276.  
  277.   def dispose_shadow
  278.     return if !(@shadow_exist and !@shadow.nil?)
  279.     @shadow.dispose
  280.   end
  281.  
  282.   def dispose_spot
  283.     return if !(@spot_exist and !@spot.nil?)
  284.     @spot.dispose
  285.   end
  286.  
  287. end
  288.  
  289.  
  290. #--------------------------#
  291. # Script eventlight engine #
  292. #--------------------------#
  293. class EventLight
  294.  
  295.   attr_reader :event_lights
  296.  
  297.   def initialize
  298.     create_autolights
  299.   end
  300.  
  301.   def create_autolights
  302.     @event_lights = {}
  303.     $game_map.events.values.each do |event|
  304.       next if event.list == nil
  305.       event.list.each do |list|
  306.         if (list.code == 108 or list.code == 408) and
  307.         list.parameters[0].include?("cast")
  308.           data = eval(list.parameters[0])
  309.           el = Event_LightHolder.new(event, data)
  310.           settings(el, data)
  311.           @event_lights[event.id] = el
  312.           update
  313.         end
  314.       end
  315.     end
  316.   end
  317.  
  318.   def cast(pic = EL::Default,
  319.            color = "white",
  320.            opacity = 255,
  321.            blend_type = 1,
  322.            zoom = 100,
  323.            range = 0)
  324.     return [pic, color, opacity, blend_type, zoom, range]
  325.   end
  326.  
  327.   def settings(event_light, data)
  328.     event_light.el.tone       = pick_color(data[1])
  329.     event_light.el.opacity    = data[2]
  330.     event_light.el.blend_type = data[3]
  331.     event_light.el.zoom_x     = event_light.el.zoom_y = data[4] / 100.0
  332.   end
  333.  
  334.   def dispose
  335.     @event_lights.each_value do |light|
  336.       light.el.dispose
  337.     end
  338.     @event_lights.clear
  339.   end
  340.  
  341.   def update
  342.     @event_lights.each_value do |light|
  343.       light.el.opacity = light.el.opacity + rand(EL::Flicker::Opacity) -
  344.                                             rand(EL::Flicker::Opacity)
  345.       x_zoom = light.el.zoom_x
  346.       y_zoom = light.el.zoom_y
  347.       light.el.zoom_x = x_zoom + (rand(EL::Flicker::Width)  / 100.0) -
  348.                                  (rand(EL::Flicker::Width)  / 100.0)
  349.       light.el.zoom_y = y_zoom + (rand(EL::Flicker::Height) / 100.0) -
  350.                                  (rand(EL::Flicker::Height) / 100.0)
  351.       light.el.x = (light.event.real_x - $game_map.display_x) / 8 -
  352.                    ((light.el.width * x_zoom) / 2) + 16 +
  353.                     rand(EL::Flicker::X) - rand(EL::Flicker::X)
  354.       light.el.y = (light.event.real_y - $game_map.display_y) / 8 -
  355.                    ((light.el.height * y_zoom) / 2) + 16 +
  356.                     rand(EL::Flicker::Y) - rand(EL::Flicker::Y)
  357.     end
  358.   end
  359.  
  360. end
  361.  
  362.  
  363. #-----------------#
  364. # Event lightdata #
  365. #-----------------#
  366. class Event_LightHolder
  367.  
  368.   attr_reader   :event
  369.         attr_accessor :el
  370.   attr_accessor :range
  371.  
  372.         def initialize(event, data)
  373.     @event = event
  374.                 @el = Sprite.new
  375.     @el.visible = true
  376.                 settings(data)
  377.         end
  378.  
  379.   def settings(data)
  380.     @el.bitmap = Cache.picture(data[0])
  381.     @el.tone = pick_color(data[1])
  382.     @el.opacity = data[2]
  383.     @el.blend_type = data[3]
  384.     @el.zoom_x = @el.zoom_y = data[4]
  385.     @range = data[5]
  386.   end
  387.  
  388. end
  389.  
  390.  
  391. #--------------#
  392. # Color picker #
  393. #--------------#
  394. def pick_color(color, old_value = Tone.new(0, 0, 0, 0))
  395.   @color = color
  396.   colors = {"white"   =>  Tone.new(255, 255, 255, 255),
  397.             "red"     =>  Tone.new(255, -255, -255, 255),
  398.             "green"   =>  Tone.new(-255, 255, -255, 255),
  399.             "blue"    =>  Tone.new(-255, -255, 255, 255),
  400.             "yellow"  =>  Tone.new(255, 255, -255, 255),
  401.             "orange"  =>  Tone.new(255, -128, -255, 255),
  402.             "purple"  =>  Tone.new(255, -255, 255, 255)
  403.             }
  404.   if @color == "random"
  405.     @color = colors.keys[rand(colors.size)]
  406.     until colors[@color] != old_value
  407.       @color = colors.keys[rand(colors.size)]
  408.     end
  409.   end
  410.   return colors[@color]
  411. end
  412.  
  413.  
  414. #----------------#
  415. # On map display #
  416. #----------------#
  417. class Scene_Map < Scene_Base
  418.  
  419.   alias autolight_start start
  420.   alias autolight_terminate terminate
  421.   alias autolight_update update
  422.   alias autolight_fadein fadein
  423.  
  424.   def start
  425.     autolight_start
  426.     light_start
  427.   end
  428.  
  429.   def light_start
  430.     $AutoLight = AutoLight.new
  431.     $EventLight = EventLight.new
  432.   end
  433.  
  434.   def terminate
  435.     autolight_terminate
  436.     light_terminate
  437.   end
  438.  
  439.   def light_terminate
  440.     $AutoLight.dispose
  441.     $EventLight.dispose
  442.   end
  443.  
  444.   def update
  445.     light_update
  446.     autolight_update
  447.   end
  448.  
  449.   def light_update
  450.     $AutoLight.update
  451.     $EventLight.update
  452.   end
  453.  
  454.   def fadein(duration)
  455.     light_fade
  456.     autolight_fadein(duration)
  457.   end
  458.  
  459.   def light_fade
  460.     $AutoLight.dispose
  461.     $AutoLight = AutoLight.new
  462.     $EventLight.dispose
  463.     $EventLight = EventLight.new
  464.   end
  465.  
  466. end
  467.  
  468.  
  469. #---------------#
  470. # Read event_id #
  471. #---------------#
  472. class Game_Interpreter
  473.  
  474.   attr_reader :event_id
  475.  
  476. end
  477.  
  478.  
  479. #---------------------#
  480. # Change Functions AL #
  481. #---------------------#
  482. module AL
  483.  
  484.   def self.mode(val)
  485.     @val = val
  486.     return if !fixnum?(@val)
  487.     eval("AL::Mode = #{@val}")
  488.     $AutoLight.dispose
  489.     $AutoLight = AutoLight.new
  490.   end
  491.  
  492.   def self.light(parm, val)
  493.     @val = val
  494.     case parm.capitalize
  495.     when "Name";    @val.to_s!
  496.     when "Visible"; return if !boolean?(@val)
  497.     else;           return if !fixnum?(@val)
  498.     end
  499.     eval("AL::Light::#{parm.capitalize} = #{@val}")
  500.     $AutoLight.dispose
  501.     $AutoLight = AutoLight.new
  502.   end
  503.  
  504.   def self.shadow(parm, val)
  505.     @val = val
  506.     case parm.capitalize
  507.     when "Name";    @val.to_s!
  508.     when "Visible"; return if !boolean?(@val)
  509.     else;           return if !fixnum?(@val)
  510.     end
  511.     eval("AL::Shadow::#{parm.capitalize} = #{@val}")
  512.     $AutoLight.dispose
  513.     $AutoLight = AutoLight.new
  514.   end
  515.  
  516.   def self.spot(parm, val)
  517.     @val = val
  518.     case parm.capitalize
  519.     when "Name";    @val.to_s!
  520.     when "Visible"; return if !boolean?(@val)
  521.     else;           return if !fixnum?(@val)
  522.     end
  523.     eval("AL::Spot::#{parm.capitalize} = #{@val}")
  524.     $AutoLight.dispose
  525.     $AutoLight = AutoLight.new
  526.   end
  527.  
  528.   def self.flicker(parm, val)
  529.     @val = val
  530.     return if !fixnum?(@val)
  531.     eval("AL::Spot::Flicker::#{parm.capitalize} = #{@val}")
  532.     $AutoLight.dispose
  533.     $AutoLight = AutoLight.new
  534.   end
  535.  
  536. end
  537.  
  538.  
  539. #---------------------#
  540. # Change Functions EL #
  541. #---------------------#
  542. module EL
  543.  
  544.   def self.bitmap(val, index = nil)
  545.     @val = val
  546.     index = $game_map.interpreter.event_id if index == nil
  547.     $EventLight.event_lights[index].el.bitmap = Cache.picture(@val)
  548.   end
  549.  
  550.   def self.color(val, index = nil)
  551.     @val = val
  552.     index = $game_map.interpreter.event_id if index == nil
  553.     old_value = $EventLight.event_lights[index].el.tone
  554.     $EventLight.event_lights[index].el.tone = pick_color(@val, old_value)
  555.   end
  556.  
  557.   def self.opacity(val, index = nil)
  558.     @val = val
  559.     return if !fixnum?(@val)
  560.     index = $game_map.interpreter.event_id if index == nil
  561.     $EventLight.event_lights[index].el.opacity = @val
  562.   end
  563.  
  564.   def self.blend(val, index = nil)
  565.     @val = val
  566.     return if !fixnum?(@val)
  567.     index = $game_map.interpreter.event_id if index == nil
  568.     $EventLight.event_lights[index].el.blend_type = @val
  569.   end
  570.  
  571.   def self.visible(val, index = nil)
  572.     @val = val
  573.     return if !boolean?(@val)
  574.     index = $game_map.interpreter.event_id if index == nil
  575.     $EventLight.event_lights[index].el.visible = @val
  576.   end
  577.  
  578.   def self.zoom(val, index = nil)
  579.     @val = val
  580.     return if !fixnum?(@val)
  581.     index = $game_map.interpreter.event_id if index == nil
  582.     $EventLight.event_lights[index].el.zoom_x = @val / 100.0
  583.     $EventLight.event_lights[index].el.zoom_y = @val / 100.0
  584.   end
  585.  
  586.   def self.range(val, index = nil)
  587.     @val = val
  588.     return if !fixnum?(@val)
  589.     index = $game_map.interpreter.event_id if index == nil
  590.     $EventLight.event_lights[index].range = @val
  591.   end
  592.  
  593. end
  594.  
  595.  
  596. #-----------------#
  597. # Wrong input fix #
  598. #-----------------#
  599.  
  600. # String/Fixnum -> Boolean
  601. def boolean?(val)
  602.   return false if !(val.is_a? FalseClass or
  603.                     val.is_a? TrueClass  or
  604.                     val.is_a? String     or
  605.                     val.is_a? Fixnum)
  606.   @val = eval(val) if val.is_a? String
  607.   if val.is_a? Fixnum or @val.is_a? Fixnum
  608.     val = @val if @val.is_a? Fixnum
  609.     if val == -1 or val == 1; @val = true
  610.     elsif val == 0;           @val = false
  611.     else;                     return false
  612.     end
  613.   end
  614.   return true
  615. end
  616.  
  617. # String -> Fixnum
  618. def fixnum?(val)
  619.   return false if !(val.is_a? Fixnum or val.is_a? String)
  620.   @val = val.to_i if val.is_a? String
  621.   return true
  622. end

Lv3.寻梦者

梦石
1
星屑
2073
在线时间
920 小时
注册时间
2012-10-18
帖子
428

开拓者

2
发表于 2012-10-27 14:58:09 | 只看该作者
把光亮图取名为LightXX,把影子图取名为ShadowXX,如果有使用远景画法的话就把图取名为SpotXX
以上XX为地图ID

评分

参与人数 1梦石 +2 收起 理由
Mic_洛洛 + 2 认可答案,附赠6R好人卡一张~

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
211 小时
注册时间
2011-10-2
帖子
35
3
 楼主| 发表于 2012-11-29 06:59:32 | 只看该作者
偶,谢谢!!知道了!!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 22:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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