Project1

标题: VX移植到VA上的灯光脚本。 [打印本页]

作者: dujian15    时间: 2012-12-14 11:31
标题: VX移植到VA上的灯光脚本。
本帖最后由 dujian15 于 2012-12-14 11:35 编辑

脚本初学者,目前在研究脚本移植。

献上灯光脚本一个,这个脚本的功能是。

在地图中定义一个事件,在事件中填加相应的注释,这个事件便可以发光。
可以通过开关关闭光源。

但目前还存在几个问题,最好请大神重新修正发布。

1.光源对焦不准,需要在游戏中自行调整。
2.代码为LIGHT的光源还有bug

如果需要使用这个光源脚本,需要在picture文下夹下建议一个LE.png的图片,图片即是光晕的造型。

奉上两张效果图

工程限于网速原因,回家再上传。



  1. #==============================================================================
  2. # ■ 灯光脚本 for VA 版本1.0.0
  3. #     12.14.2012
  4. #------------------------------------------------------------------------------
  5. #  脚本修改: dujian15
  6. #  脚本制作: Kylock (For XP 版本 by Near Fantastica)
  7. #==============================================================================


  8. # ■ 灯光脚本 for VX 版本1.1.1
  9. #     5.21.2008
  10. #------------------------------------------------------------------------------
  11. #  脚本制作: Kylock (For XP 版本 by Near Fantastica)
  12. #==============================================================================
  13. #   如果您想要启用脚本,请在需要灯光效果的事件添加一个注释.
  14. #   打开开关将禁用灯光效果,启用效果前会检查开关,如果已经添加注释但是开关开启,那么将会停止效果.
  15. #   译者的话:因为发现脚本有一些问题,所以是有改动过的,如果改的不对,请M我QQ或者留言.谢谢
  16. #
  17. #==============================================================================
  18. # ● 更新日志
  19. #------------------------------------------------------------------------------
  20. # 1.0 - 建立最初版本
  21. # 1.1 - 添加了新的效果: LIGHT2, TORCH, TORCH2
  22. #      - 更改了混合模式(使其看起来更好)
  23. #      - 对FIRE效果增加了红色
  24. # 1.1.1 -非官方更新
  25. #         -解决了效果FIRE 与 TORCH 效果当开关打开时没有消失的问题
  26. #         -简便了开关判断
  27. #==============================================================================
  28. # ● 支持的效果(您可以添加的注释)
  29. #------------------------------------------------------------------------------
  30. #   GROUND - 中等稳定的白光.
  31. #   FIRE   - 伴有轻微的闪烁的红色.
  32. #   LIGHT  - 小型稳定的白光.
  33. #   LIGHT2 -大型稳定的白光.
  34. #   TORCH  - 伴有强烈闪烁的大型稳定的红光.
  35. #   TORCH2 - 伴有中等烁的大型稳定的红光.
  36. #==============================================================================

  37.   $lsig = 1           #开关号


  38. class Spriteset_Map
  39.   alias les_spriteset_map_initalize initialize
  40.   alias les_spriteset_map_dispose dispose
  41.   alias les_spriteset_map_update update
  42.   def initialize
  43.     @light_effects = []
  44.     setup_lights
  45.     les_spriteset_map_initalize
  46.     update
  47.   end
  48.   def dispose
  49.     les_spriteset_map_dispose
  50.     for effect in @light_effects
  51.       effect.light.dispose
  52.     end
  53.     @light_effects = []
  54.   end
  55.   def update
  56.     les_spriteset_map_update
  57.     update_light_effects
  58.   end
  59.   def setup_lights
  60.     for event in $game_map.events.values
  61.       next if event.list == nil
  62.       for i in 0...event.list.size
  63.         if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
  64.           type = "GROUND"
  65.           light_effects = Light_Effect.new(event,type)
  66.           light_effects.light.zoom_x = 2
  67.           light_effects.light.zoom_y = 2
  68.           light_effects.light.opacity = 100
  69.           @light_effects.push(light_effects)
  70.         end
  71.         if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
  72.           type = "FIRE"
  73.           light_effects = Light_Effect.new(event,type)
  74.           light_effects.light.zoom_x = 300 / 100.0
  75.           light_effects.light.zoom_y = 300 / 100.0
  76.           light_effects.light.opacity = 100
  77.           @light_effects.push(light_effects)
  78.         end
  79.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
  80.           type = "LIGHT"
  81.           light_effects = Light_Effect.new(event,type)
  82.           light_effects.light.zoom_x = 1
  83.           light_effects.light.zoom_y = 1
  84.           light_effects.light.opacity = 150
  85.           @light_effects.push(light_effects)
  86.         end
  87.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
  88.           type = "LIGHT2"
  89.           light_effects = Light_Effect.new(event,type)
  90.           light_effects.light.zoom_x = 6
  91.           light_effects.light.zoom_y = 6
  92.           light_effects.light.opacity = 150
  93.           @light_effects.push(light_effects)
  94.         end
  95.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
  96.           type = "TORCH"
  97.           light_effects = Light_Effect.new(event,type)
  98.           light_effects.light.zoom_x = 6
  99.           light_effects.light.zoom_y = 6
  100.           light_effects.light.opacity = 150
  101.           @light_effects.push(light_effects)
  102.         end
  103.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
  104.           type = "TORCH2"
  105.           light_effects = Light_Effect.new(event,type)
  106.           light_effects.light.zoom_x = 6
  107.           light_effects.light.zoom_y = 6
  108.           light_effects.light.opacity = 150
  109.           @light_effects.push(light_effects)
  110.         end
  111.       end
  112.     end
  113.     for effect in @light_effects
  114.       case effect.type
  115.       when "GROUND"
  116.         effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
  117.         effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
  118.         effect.light.blend_type = 1
  119.       when "FIRE"
  120.         effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
  121.         effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
  122.         effect.light.tone = Tone.new(255,-100,-255,   0)
  123.         effect.light.blend_type = 1
  124.       when "LIGHT"
  125.         effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8
  126.         effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8
  127.         effect.light.blend_type = 1
  128.       when "LIGHT2"
  129.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  130.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  131.         effect.light.blend_type = 1
  132.       when "TORCH"
  133.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  134.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  135.         effect.light.tone = Tone.new(255,-100,-255,   0)
  136.         effect.light.blend_type = 1
  137.       when "TORCH2"
  138.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  139.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  140.         effect.light.tone = Tone.new(255,-100,-255,   0)
  141.         effect.light.blend_type = 1
  142.       end
  143.     end
  144.   end
  145.   def update_light_effects
  146.     if $game_switches[$lsig]
  147.       for effect in @light_effects
  148.         effect.light.visible = false
  149.       end
  150.     else
  151.       for effect in @light_effects

  152.         effect.light.visible = true
  153.       end
  154.     end
  155.     for effect in @light_effects
  156.       case effect.type
  157.       when "GROUND"
  158.         effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
  159.         effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
  160.       when "FIRE"
  161.         effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
  162.         effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
  163.         effect.light.opacity = rand(10) + 90
  164.       when "LIGHT"
  165.         effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  166.         effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  167.       when "LIGHT2"
  168.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  169.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  170.       when "TORCH"
  171.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
  172.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 + rand(20) - 10
  173.         effect.light.opacity = rand(30) + 70
  174.       when "TORCH2"
  175.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  176.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  177.         effect.light.opacity = rand(10) + 90
  178.       end
  179.     end
  180.   end
  181. end

  182. class Light_Effect
  183.   attr_accessor :light
  184.   attr_accessor :event
  185.   attr_accessor :type
  186.   def initialize(event, type)
  187.     [url=home.php?mod=space&uid=22469]@light[/url] = Sprite.new
  188.     @light.bitmap = Cache.picture("le.png")
  189.     @light.visible = true
  190.     @light.z = 1000
  191.     @event = event
  192.     @type = type
  193.   end
  194. end
复制代码

作者: 0newing    时间: 2012-12-14 11:43
想要VX原版的,可以一并发上来吗?
作者: garfeng    时间: 2012-12-14 13:07
楼主强大~~~~~
但是,我可以说一下,其实,这个功能的脚本已经有了么有了么……{:2_264:}
哇哇,即va真,烛光脚本,还是个繁体的帖子。
作者: 你最珍贵    时间: 2012-12-14 13:13
有没有xp的
作者: dujian15    时间: 2012-12-14 14:07
你最珍贵 发表于 2012-12-14 13:13
有没有xp的

原作者的信息我已经在代码里给出了,呵呵,善用搜索,世界会很美好。
作者: dujian15    时间: 2012-12-14 14:07
0newing 发表于 2012-12-14 11:43
想要VX原版的,可以一并发上来吗?

原作者的信息我已经在代码里给出了,呵呵,善用搜索,世界会很美好。
作者: Yang2012    时间: 2012-12-14 14:54
有XP的吗?谢谢!
作者: 杰总    时间: 2012-12-15 13:27
加了这个脚本 一进入游戏就错误报告....
作者: alann    时间: 2012-12-21 10:28
哎呀呀,终于有人移植这个了……
之前的烛光系统都只是跟着主角走的亮光
作者: leoyayaleo    时间: 2012-12-27 16:20
完全没效果耶.... 也有光晕图 也有在事件设注释  怎就是没效果?
作者: fans2010    时间: 2013-1-14 11:56
这个特效真的是太美了!!
作者: 745336784    时间: 2013-2-2 23:20
想请问下光晕图能在哪里下?
作者: 我是老A    时间: 2013-2-17 20:31
745336784 发表于 2013-2-2 23:20
想请问下光晕图能在哪里下?



这是我做的,似乎颜色重了些。
作者: 我是老A    时间: 2013-2-17 20:36
745336784 发表于 2013-2-2 23:20
想请问下光晕图能在哪里下?

也可以是这个。


作者: 我是老A    时间: 2013-2-17 20:42
第195行出错了。
作者: mjn3161644    时间: 2013-2-21 04:57
为什么只在一张地图上有用,换了一张地图就没用了??
作者: 怀念过去    时间: 2013-11-24 12:46
需要啊!!!!!
作者: 1450131341    时间: 2014-1-28 13:52
我是老A 发表于 2013-2-17 20:42
第195行出错了。

改成@light = Sprite.new  
作者: 里世界住人雅翠    时间: 2014-5-8 19:51
1450131341 发表于 2014-1-28 13:52
改成@light = Sprite.new

    [url=home.php?mod=space&uid=22469]@light = Sprite.new  
这样?
作者: 幻想叽    时间: 2014-6-18 16:54
楼主请问一下,所谓的灯光位置在游戏里设置,到底是怎么设置啊?完全搞不懂呢
作者: 日月星辰    时间: 2014-6-19 20:31
这个光真是亮瞎狗眼。。。

话说为什么一群人要问烛光脚本怎么用。。。会用就用,不会用 用事件显示图片都能完成的事情= =
作者: marco99168    时间: 2014-6-19 21:58
本帖最后由 marco99168 于 2014-6-19 22:01 编辑

…………




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