查看: 3298|回复: 2

[已经解决] 有关烛光脚本使用问题

[复制链接]
梦石
0
星屑
1926
在线时间
640 小时
注册时间
2012-1-31
回帖
61
发表于 2014-12-2 11:09:37 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 VIPArcher 于 2014-12-2 12:42 编辑

先上脚本。
[pre lang="ruby" line="1"]#==============================================================================
# ■ 灯光脚本 for VA 版本1.0.0
#     12.14.2012
#------------------------------------------------------------------------------
#  脚本修改: dujian15
#  脚本制作: Kylock (For XP 版本 by Near Fantastica)
#==============================================================================


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

  $lsig = 100           #开关号


class Spriteset_Map
  alias les_spriteset_map_initalize initialize
  alias les_spriteset_map_dispose dispose
  alias les_spriteset_map_update update
  def initialize
    @light_effects = []
    setup_lights
    les_spriteset_map_initalize
    update
  end
  def dispose
    les_spriteset_map_dispose
    for effect in @light_effects
      effect.light.dispose
    end
    @light_effects = []
  end
  def update
    les_spriteset_map_update
    update_light_effects
  end
  def setup_lights
    for event in $game_map.events.values
      next if event.list == nil
      for i in 0...event.list.size
        if event.list.code == 108 and event.list.parameters == ["GROUND"]
          type = "GROUND"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 2
          light_effects.light.zoom_y = 2
          light_effects.light.opacity = 100
          @light_effects.push(light_effects)
        end
        if event.list.code == 108 and event.list.parameters == ["FIRE"]
          type = "FIRE"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 300 / 100.0
          light_effects.light.zoom_y = 300 / 100.0
          light_effects.light.opacity = 100
          @light_effects.push(light_effects)
        end
        if event.list.code == 108 and event.list.parameters == ["LIGHT"]
          type = "LIGHT"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 1
          light_effects.light.zoom_y = 1
          light_effects.light.opacity = 150
          @light_effects.push(light_effects)
        end
        if event.list.code == 108 and event.list.parameters == ["LIGHT2"]
          type = "LIGHT2"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 6
          light_effects.light.zoom_y = 6
          light_effects.light.opacity = 150
          @light_effects.push(light_effects)
        end
        if event.list.code == 108 and event.list.parameters == ["TORCH"]
          type = "TORCH"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 6
          light_effects.light.zoom_y = 6
          light_effects.light.opacity = 150
          @light_effects.push(light_effects)
        end
        if event.list.code == 108 and event.list.parameters == ["TORCH2"]
          type = "TORCH2"
          light_effects = Light_Effect.new(event,type)
          light_effects.light.zoom_x = 6
          light_effects.light.zoom_y = 6
          light_effects.light.opacity = 150
          @light_effects.push(light_effects)
        end
      end
    end
    for effect in @light_effects
      case effect.type
      when "GROUND"
        effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
        effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
        effect.light.blend_type = 1
      when "FIRE"
        effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
        effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
        effect.light.tone = Tone.new(255,-100,-255,   0)
        effect.light.blend_type = 1
      when "LIGHT"
        effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8
        effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8
        effect.light.blend_type = 1
      when "LIGHT2"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
        effect.light.blend_type = 1
      when "TORCH"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
        effect.light.tone = Tone.new(255,-100,-255,   0)
        effect.light.blend_type = 1
      when "TORCH2"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
        effect.light.tone = Tone.new(255,-100,-255,   0)
        effect.light.blend_type = 1
      end
    end
  end
  def update_light_effects
    if $game_switches[$lsig]
      for effect in @light_effects
        effect.light.visible = false
      end
    else
      for effect in @light_effects

        effect.light.visible = true
      end
    end
    for effect in @light_effects
      case effect.type
      when "GROUND"
        effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
        effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
      when "FIRE"
        effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
        effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
        effect.light.opacity = rand(10) + 90
      when "LIGHT"
        effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
        effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
      when "LIGHT2"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
      when "TORCH"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 + rand(20) - 10
        effect.light.opacity = rand(30) + 70
      when "TORCH2"
        effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
        effect.light.opacity = rand(10) + 90
      end
    end
  end
end

class Light_Effect
  attr_accessor :light
  attr_accessor :event
  attr_accessor :type
  def initialize(event, type)
    @light= Sprite.new
    @light.bitmap = Cache.picture("le.png")
    @light.visible = true
    @light.z = 1000
    @event = event
    @type = type
  end
end[/pre]

请教下这个脚本怎么用,插入工程后显示第195行错误。

发脚本可以用代码框,已编辑——VIPArcher
梦石
0
星屑
1926
在线时间
640 小时
注册时间
2012-1-31
回帖
61
 楼主| 发表于 2014-12-2 11:12:45 | 显示全部楼层
请教下各位大大:
1.插入工程后显示第195行错误,解决。
2.这个脚本如何使用。

点评

谢谢大大,已经解决了。  发表于 2014-12-2 18:56
195行,手滑了少打个1  发表于 2014-12-2 12:44
95行是论坛的BUG导致的,解决办法看图书馆的 Q&A第三条  发表于 2014-12-2 12:44
回复

使用道具 举报

闇吼者の災悪眷族

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
回帖
6408
发表于 2014-12-2 11:23:33 | 显示全部楼层
发脚本请使用脚本框。

首先确定一下你是否加入了用于作为发光效果的图片,
使用方法就是在事件中“注释”预设好的文字:
GROUND
FIRE
之类

点评

谢谢大大!已经解决了  发表于 2014-12-2 18:56

评分

参与人数 1星屑 +10 收起 理由
脚本盲 + 10 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部