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

Project1

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

[已经过期] 请问vx的autolight脚本怎么使用啊

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
95 小时
注册时间
2012-4-18
帖子
90
跳转到指定楼层
1
发表于 2012-5-11 19:35:09 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 忧雪の伤 于 2012-5-13 09:36 编辑

请问vx的autolight脚本怎么使用啊,另外,xp有这样的光影效果脚本吗?
这是vx里的效果图:    
这是vx用的脚本,是国外网友制作的:(加在了main函数之前,但没有效果,好像要在Graphics\Pictures里放入光效或阴影图配合使用,请大家帮忙看看,另外,xp有这样的光影效果脚本吗?)
  1. #------------------------------------------------------------------------------#
  2. # Name:     Auto/Event-Light Reborn                                            #
  3. # By:       SojaBird                                                           #
  4. # Version:  Reborn 4.1                                                         #
  5. #                                                                              #
  6. # Date:     30-08-09                                                           #
  7. #------------------------------------------------------------------------------#

  8. $imported = {} if $imported == nil
  9. $imported["SojaBird_AutoLight"] = true

  10. #------------------------------------------------------------------------------#
  11. # Call Script                                                                  #
  12. #------------------------------------------------------------------------------#
  13. # - AL.mode(val)                 #                                             #
  14. # - AL.light(parm, val)          # parm: name, opacity, blend, visible         #
  15. # - AL.shadow(parm, val)         # parm: name, opacity, blend, visible         #
  16. # - AL.spot(parm, val)           # parm: name, opacity, blend, visible         #
  17. # - AL.flicker(parm, val)        # parm: opacity, width, height, x, y          #
  18. #                                #                                             #
  19. # - EL.bitmap(val, index = nil)  #                                             #
  20. # - EL.color(val, index = nil)   #                                             #
  21. # - EL.opacity(val, index = nil) #                                             #
  22. # - EL.blend(val, index = nil)   #                                             #
  23. # - EL.visible(val, index = nil) #                                             #
  24. # - EL.zoom(val, index = nil)    #                                             #
  25. #------------------------------------------------------------------------------#

  26. #------------------------------------------------------------------------------#
  27. # How to use                                                                   #
  28. #------------------------------------------------------------------------------#
  29. # *AutoLight                                                                   #
  30. #  MODE 0/2                                                                    #
  31. #   To use autolights, put a light- and/or shadow-map picture in the           #
  32. #   folder ../Graphics/Pictures/                                               #
  33. #   Name to picture correct! Start with the, by you set, light- and/or         #
  34. #   shadow-map name, followed by the corresponding map-ID.                     #
  35. #   Put the AutoLight mode to 0 or 2 to show light- and/or shadow-maps.        #
  36. #                                                                              #
  37. #  MODE 1/2                                                                    #
  38. #   To use the spot, put your spotpicture in the folder ../Graphics/Pictures/  #
  39. #   and set the name correct!                                                  #
  40. #   Put the AutoLight mode to 1 or 2 to show the spot.                         #
  41. #                                                                              #
  42. #                                                                              #
  43. # *EventLight                                                                  #
  44. #   To make a event cast a light, give it a comment with the following code:   #
  45. #     cast(*picture, *color, *opacity, *blend_type, *zoom)                     #
  46. #   All the parameters are optional. Default they are set to:                  #
  47. #     picture:    Default, set in the module                                   #
  48. #     color:      White                                                        #
  49. #     opacity:    255                                                          #
  50. #     blend_type: 1                                                            #
  51. #     zoom:       100                                                          #
  52. #   For the color you can choose:                                              #
  53. #    - white                                                                   #
  54. #    - red                                                                     #
  55. #    - green                                                                   #
  56. #    - blue                                                                    #
  57. #    - yellow                                                                  #
  58. #    - orange                                                                  #
  59. #    - purple                                                                  #
  60. #    - random (one of above, but not the same as it is at the moment (if set)) #
  61. #                                                                              #
  62. #------------------------------------------------------------------------------#

  63. #--------------------------#
  64. # Customization AutoLights #
  65. #--------------------------#
  66. module AL
  67.   
  68.   #0 = Light and/or Shadow
  69.   #1 = Spot
  70.   #2 = Both
  71.   Mode = 0
  72.   
  73.   module Light
  74.     Name    = "Light"
  75.     Opacity = 150
  76.     Blend   = 1
  77.     Visible = true
  78.    
  79.   end
  80.   module Shadow
  81.     Name    = "Shadow"
  82.     Opacity = 150
  83.     Blend   = 2
  84.     Visible = true
  85.    
  86.   end
  87.   module Spot
  88.     Name    = "Spot"
  89.     Opacity = 255
  90.     Blend   = 2
  91.     Visible = true
  92.    
  93.     module Flicker
  94.       Opacity = 2 #Random opacity change
  95.       Width   = 2 #Random horizontal zoom
  96.       Height  = 2 #Random vertical zoom
  97.       X       = 2 #Random horizontal movement
  98.       Y       = 2 #Random vertical movement
  99.     end
  100.    
  101.   end
  102.   
  103. end


  104. #---------------------------#
  105. # Customization EventLights #
  106. #---------------------------#
  107. module EL

  108.   Default = "EventLight"
  109.   
  110.   module Flicker
  111.     Opacity = 2 #Random opacity change
  112.     Width   = 2 #Random horizontal zoom
  113.     Height  = 2 #Random vertical zoom
  114.     X       = 2 #Random horizontal movement
  115.     Y       = 2 #Random vertical movement
  116.   end
  117.   
  118. end


  119. #\####/\####/\####/\####/\##------------------------##/\####/\####/\####/\####/#
  120. ##\##/##\##/##\##/##\##/##\# DON'T CROSS THIS LINE! #/##\##/##\##/##\##/##\##/##
  121. ###\/####\/####\/####\/####\------------------------/####\/####\/####\/####\/###


  122. #---------------------------#
  123. # Script playerlight engine #
  124. #---------------------------#
  125. class AutoLight
  126.   
  127.   include AL
  128.   
  129.   def initialize
  130.     @map_id = $game_map.map_id
  131.     @light_exist = check_existence("#{Light::Name}#{@map_id}")
  132.     @shadow_exist = check_existence("#{Shadow::Name}#{@map_id}")
  133.     @spot_exist = check_existence("#{Spot::Name}")
  134.     create_lights
  135.   end
  136.   
  137.   def check_existence(file)
  138.     format_list = [".png", ".jpeg", ".jpg"]
  139.     format_list.each do |format|
  140.       return true if FileTest.exist?("Graphics/Pictures/#{file}#{format}")
  141.     end
  142.     return false
  143.   end
  144.   
  145.   def create_lights
  146.     @viewport = Viewport.new(0, 0, 544, 416)
  147.     case Mode
  148.     when 0
  149.       draw_light
  150.       draw_shadow
  151.     when 1
  152.       draw_spot
  153.     when 2
  154.       draw_light
  155.       draw_shadow
  156.       draw_spot
  157.     end
  158.     update
  159.   end
  160.   
  161.   def draw_light
  162.     return if !@light_exist
  163.     @light = Sprite.new(@viewport)
  164.     @light.bitmap = Cache.picture("#{Light::Name}#{@map_id}")
  165.     @light.z = 9998
  166.     @light.opacity = Light::Opacity
  167.     @light.blend_type = Light::Blend
  168.     @light.visible = Light::Visible
  169.   end
  170.   
  171.   def draw_shadow
  172.     return if !@shadow_exist
  173.     @shadow = Sprite.new(@viewport)
  174.     @shadow.bitmap = Cache.picture("#{Shadow::Name}#{@map_id}")
  175.     @shadow.z = 9997
  176.     @shadow.opacity = Shadow::Opacity
  177.     @shadow.blend_type = Shadow::Blend
  178.     @shadow.visible = Shadow::Visible
  179.   end
  180.   
  181.   def draw_spot
  182.     return if !@spot_exist
  183.     @spot = Sprite.new(@viewport)
  184.     @spot.bitmap = Cache.picture("#{Spot::Name}")
  185.     @spot.z = 9999
  186.     @spot.opacity = Spot::Opacity
  187.     @spot.blend_type = Spot::Blend
  188.     @spot.visible = Spot::Visible
  189.   end
  190.   
  191.   def update
  192.     @map_x = $game_map.display_x    / 8
  193.     @map_y = $game_map.display_y    / 8
  194.     @player_x = $game_player.real_x / 8
  195.     @player_y = $game_player.real_y / 8
  196.     case Mode
  197.     when 0
  198.       update_light
  199.       update_shadow
  200.     when 1
  201.       update_spot
  202.     when 2
  203.       update_light
  204.       update_shadow
  205.       update_spot
  206.     end
  207.   end
  208.   
  209.   def update_light
  210.     return if !(@light_exist and [email protected]?)
  211.     @light.visible = Light::Visible
  212.     return if !(@light.x == 0 or
  213.                 @light.y == 0 or
  214.                 @light.x != @map_x / 256 or
  215.                 @light.y != @map_y / 256)
  216.     @light.x = -@map_x
  217.     @light.y = -@map_y
  218.   end
  219.   
  220.   def update_shadow
  221.     return if !(@shadow_exist and [email protected]?)
  222.     @shadow.visible = Shadow::Visible
  223.     return if !(@shadow.x == 0 or
  224.                 @shadow.y == 0 or
  225.                 @shadow.x != @map_x / 256 or
  226.                 @shadow.y != @map_y / 256)
  227.     @shadow.x = -@map_x
  228.     @shadow.y = -@map_y
  229.   end
  230.   
  231.   def update_spot
  232.     return if !(@spot_exist and [email protected]?)
  233.     @spot.visible = Spot::Visible
  234.     @spot.opacity = Spot::Opacity + rand(Spot::Flicker::Opacity) -
  235.                                     rand(Spot::Flicker::Opacity)
  236.     @spot.zoom_x = 1 + (rand(Spot::Flicker::Width)  / 100.0) -
  237.                        (rand(Spot::Flicker::Width)  / 100.0)
  238.     @spot.x = @player_x - @map_x - (@spot.width / 2) + 16 +
  239.                         rand(Spot::Flicker::X) - rand(Spot::Flicker::X)
  240.     @spot.zoom_y = 1 + (rand(Spot::Flicker::Height) / 100.0) -
  241.                        (rand(Spot::Flicker::Height) / 100.0)
  242.     @spot.y = @player_y - @map_y - (@spot.height / 2) + 16 +
  243.                         rand(Spot::Flicker::Y) - rand(Spot::Flicker::Y)
  244.   end
  245.   
  246.   def dispose
  247.     case Mode
  248.     when 0
  249.       dispose_light
  250.       dispose_shadow
  251.     when 1
  252.       dispose_spot
  253.     when 2
  254.       dispose_light
  255.       dispose_shadow
  256.       dispose_spot
  257.     end
  258.     @viewport.dispose
  259.   end
  260.   
  261.   def dispose_light
  262.     return if !(@light_exist and [email protected]?)
  263.     @light.dispose
  264.   end
  265.   
  266.   def dispose_shadow
  267.     return if !(@shadow_exist and [email protected]?)
  268.     @shadow.dispose
  269.   end
  270.   
  271.   def dispose_spot
  272.     return if !(@spot_exist and [email protected]?)
  273.     @spot.dispose
  274.   end
  275.   
  276. end


  277. #--------------------------#
  278. # Script eventlight engine #
  279. #--------------------------#
  280. class EventLight
  281.   
  282.   attr_reader :event_lights
  283.   
  284.   def initialize
  285.     create_autolights
  286.   end
  287.   
  288.   def create_autolights
  289.     @event_lights = {}
  290.     $game_map.events.values.each do |event|
  291.       next if event.list == nil
  292.       event.list.each do |list|
  293.         if (list.code == 108 or list.code == 408) and
  294.         list.parameters[0].include?("cast")
  295.           data = eval(list.parameters[0])
  296.           el = Event_LightHolder.new(event, data)
  297.           settings(el, data)
  298.           @event_lights[event.id] = el
  299.           update
  300.         end
  301.       end
  302.     end
  303.   end
  304.   
  305.   def cast(pic = EL::Default,
  306.            color = "white",
  307.            opacity = 255,
  308.            blend_type = 1,
  309.            zoom = 100,
  310.            range = 0)
  311.     return [pic, color, opacity, blend_type, zoom, range]
  312.   end
  313.   
  314.   def settings(event_light, data)
  315.     event_light.el.tone       = pick_color(data[1])
  316.     event_light.el.opacity    = data[2]
  317.     event_light.el.blend_type = data[3]
  318.     event_light.el.zoom_x     = event_light.el.zoom_y = data[4] / 100.0
  319.   end
  320.   
  321.   def dispose
  322.     @event_lights.each_value do |light|
  323.       light.el.dispose
  324.     end
  325.     @event_lights.clear
  326.   end
  327.   
  328.   def update
  329.     @event_lights.each_value do |light|
  330.       light.el.opacity = light.el.opacity + rand(EL::Flicker::Opacity) -
  331.                                             rand(EL::Flicker::Opacity)
  332.       x_zoom = light.el.zoom_x
  333.       y_zoom = light.el.zoom_y
  334.       light.el.zoom_x = x_zoom + (rand(EL::Flicker::Width)  / 100.0) -
  335.                                  (rand(EL::Flicker::Width)  / 100.0)
  336.       light.el.zoom_y = y_zoom + (rand(EL::Flicker::Height) / 100.0) -
  337.                                  (rand(EL::Flicker::Height) / 100.0)
  338.       light.el.x = (light.event.real_x - $game_map.display_x) / 8 -
  339.                    ((light.el.width * x_zoom) / 2) + 16 +
  340.                     rand(EL::Flicker::X) - rand(EL::Flicker::X)
  341.       light.el.y = (light.event.real_y - $game_map.display_y) / 8 -
  342.                    ((light.el.height * y_zoom) / 2) + 16 +
  343.                     rand(EL::Flicker::Y) - rand(EL::Flicker::Y)
  344.     end
  345.   end
  346.   
  347. end


  348. #-----------------#
  349. # Event lightdata #
  350. #-----------------#
  351. class Event_LightHolder
  352.   
  353.   attr_reader   :event
  354.         attr_accessor :el
  355.   attr_accessor :range
  356.         
  357.         def initialize(event, data)
  358.     @event = event
  359.                 @el = Sprite.new
  360.     @el.visible = true
  361.                 settings(data)
  362.         end
  363.   
  364.   def settings(data)
  365.     @el.bitmap = Cache.picture(data[0])
  366.     @el.tone = pick_color(data[1])
  367.     @el.opacity = data[2]
  368.     @el.blend_type = data[3]
  369.     @el.zoom_x = @el.zoom_y = data[4]
  370.     @range = data[5]
  371.   end
  372.   
  373. end


  374. #--------------#
  375. # Color picker #
  376. #--------------#
  377. def pick_color(color, old_value = Tone.new(0, 0, 0, 0))
  378.   @color = color
  379.   colors = {"white"   =>  Tone.new(255, 255, 255, 255),
  380.             "red"     =>  Tone.new(255, -255, -255, 255),
  381.             "green"   =>  Tone.new(-255, 255, -255, 255),
  382.             "blue"    =>  Tone.new(-255, -255, 255, 255),
  383.             "yellow"  =>  Tone.new(255, 255, -255, 255),
  384.             "orange"  =>  Tone.new(255, -128, -255, 255),
  385.             "purple"  =>  Tone.new(255, -255, 255, 255)
  386.             }
  387.   if @color == "random"
  388.     @color = colors.keys[rand(colors.size)]
  389.     until colors[@color] != old_value
  390.       @color = colors.keys[rand(colors.size)]
  391.     end
  392.   end
  393.   return colors[@color]
  394. end


  395. #----------------#
  396. # On map display #
  397. #----------------#
  398. class Scene_Map < Scene_Base
  399.   
  400.   alias autolight_start start
  401.   alias autolight_terminate terminate
  402.   alias autolight_update update
  403.   alias autolight_fadein fadein
  404.   
  405.   def start
  406.     autolight_start
  407.     light_start
  408.   end
  409.   
  410.   def light_start
  411.     $AutoLight = AutoLight.new
  412.     $EventLight = EventLight.new
  413.   end
  414.   
  415.   def terminate
  416.     autolight_terminate
  417.     light_terminate
  418.   end
  419.   
  420.   def light_terminate
  421.     $AutoLight.dispose
  422.     $EventLight.dispose
  423.   end
  424.   
  425.   def update
  426.     light_update
  427.     autolight_update
  428.   end
  429.   
  430.   def light_update
  431.     $AutoLight.update
  432.     $EventLight.update
  433.   end
  434.   
  435.   def fadein(duration)
  436.     light_fade
  437.     autolight_fadein(duration)
  438.   end
  439.   
  440.   def light_fade
  441.     $AutoLight.dispose
  442.     $AutoLight = AutoLight.new
  443.     $EventLight.dispose
  444.     $EventLight = EventLight.new
  445.   end
  446.   
  447. end


  448. #---------------#
  449. # Read event_id #
  450. #---------------#
  451. class Game_Interpreter
  452.   
  453.   attr_reader :event_id
  454.   
  455. end


  456. #---------------------#
  457. # Change Functions AL #
  458. #---------------------#
  459. module AL
  460.   
  461.   def self.mode(val)
  462.     @val = val
  463.     return if !fixnum?(@val)
  464.     eval("AL::Mode = #{@val}")
  465.     $AutoLight.dispose
  466.     $AutoLight = AutoLight.new
  467.   end
  468.   
  469.   def self.light(parm, val)
  470.     @val = val
  471.     case parm.capitalize
  472.     when "Name";    @val.to_s!
  473.     when "Visible"; return if !boolean?(@val)
  474.     else;           return if !fixnum?(@val)
  475.     end
  476.     eval("AL::Light::#{parm.capitalize} = #{@val}")
  477.     $AutoLight.dispose
  478.     $AutoLight = AutoLight.new
  479.   end
  480.   
  481.   def self.shadow(parm, val)
  482.     @val = val
  483.     case parm.capitalize
  484.     when "Name";    @val.to_s!
  485.     when "Visible"; return if !boolean?(@val)
  486.     else;           return if !fixnum?(@val)
  487.     end
  488.     eval("AL::Shadow::#{parm.capitalize} = #{@val}")
  489.     $AutoLight.dispose
  490.     $AutoLight = AutoLight.new
  491.   end
  492.   
  493.   def self.spot(parm, val)
  494.     @val = val
  495.     case parm.capitalize
  496.     when "Name";    @val.to_s!
  497.     when "Visible"; return if !boolean?(@val)
  498.     else;           return if !fixnum?(@val)
  499.     end
  500.     eval("AL::Spot::#{parm.capitalize} = #{@val}")
  501.     $AutoLight.dispose
  502.     $AutoLight = AutoLight.new
  503.   end
  504.   
  505.   def self.flicker(parm, val)
  506.     @val = val
  507.     return if !fixnum?(@val)
  508.     eval("AL::Spot::Flicker::#{parm.capitalize} = #{@val}")
  509.     $AutoLight.dispose
  510.     $AutoLight = AutoLight.new
  511.   end
  512.    
  513. end


  514. #---------------------#
  515. # Change Functions EL #
  516. #---------------------#
  517. module EL
  518.   
  519.   def self.bitmap(val, index = nil)
  520.     @val = val
  521.     index = $game_map.interpreter.event_id if index == nil
  522.     $EventLight.event_lights[index].el.bitmap = Cache.picture(@val)
  523.   end
  524.   
  525.   def self.color(val, index = nil)
  526.     @val = val
  527.     index = $game_map.interpreter.event_id if index == nil
  528.     old_value = $EventLight.event_lights[index].el.tone
  529.     $EventLight.event_lights[index].el.tone = pick_color(@val, old_value)
  530.   end
  531.   
  532.   def self.opacity(val, index = nil)
  533.     @val = val
  534.     return if !fixnum?(@val)
  535.     index = $game_map.interpreter.event_id if index == nil
  536.     $EventLight.event_lights[index].el.opacity = @val
  537.   end
  538.   
  539.   def self.blend(val, index = nil)
  540.     @val = val
  541.     return if !fixnum?(@val)
  542.     index = $game_map.interpreter.event_id if index == nil
  543.     $EventLight.event_lights[index].el.blend_type = @val
  544.   end
  545.   
  546.   def self.visible(val, index = nil)
  547.     @val = val
  548.     return if !boolean?(@val)
  549.     index = $game_map.interpreter.event_id if index == nil
  550.     $EventLight.event_lights[index].el.visible = @val
  551.   end
  552.   
  553.   def self.zoom(val, index = nil)
  554.     @val = val
  555.     return if !fixnum?(@val)
  556.     index = $game_map.interpreter.event_id if index == nil
  557.     $EventLight.event_lights[index].el.zoom_x = @val / 100.0
  558.     $EventLight.event_lights[index].el.zoom_y = @val / 100.0
  559.   end
  560.   
  561.   def self.range(val, index = nil)
  562.     @val = val
  563.     return if !fixnum?(@val)
  564.     index = $game_map.interpreter.event_id if index == nil
  565.     $EventLight.event_lights[index].range = @val
  566.   end
  567.   
  568. end


  569. #-----------------#
  570. # Wrong input fix #
  571. #-----------------#

  572. # String/Fixnum -> Boolean
  573. def boolean?(val)
  574.   return false if !(val.is_a? FalseClass or
  575.                     val.is_a? TrueClass  or
  576.                     val.is_a? String     or
  577.                     val.is_a? Fixnum)
  578.   @val = eval(val) if val.is_a? String
  579.   if val.is_a? Fixnum or @val.is_a? Fixnum
  580.     val = @val if @val.is_a? Fixnum
  581.     if val == -1 or val == 1; @val = true
  582.     elsif val == 0;           @val = false
  583.     else;                     return false
  584.     end
  585.   end
  586.   return true
  587. end

  588. # String -> Fixnum
  589. def fixnum?(val)
  590.   return false if !(val.is_a? Fixnum or val.is_a? String)
  591.   @val = val.to_i if val.is_a? String
  592.   return true
  593. end
复制代码

点评

该问题已过期,如果楼主依然存有此项疑问的话请重新发帖哦亲~  发表于 2012-5-26 00:19

评分

参与人数 2星屑 -40 收起 理由
Luciffer -80 纯弥补操作失误
忧雪の伤 + 40 错误分区 + 手动加框

查看全部评分

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

本版积分规则

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

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

GMT+8, 2024-4-20 11:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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