질문과 답변

Extra Form
#==============================================================================
# ■ Light Effects VX 1.1
#     5.21.2008
#------------------------------------------------------------------------------
#  Script by: Kylock (originally for RMXP by Near Fantastica)
#==============================================================================
#   To make an event glow, give it a Comment: with any of the supported light
# modes.
#   The SWITCH setting below will disable light effects from updating with the
# switch is on.
#==============================================================================
# ● Change Log
#------------------------------------------------------------------------------
# 1.0 - Original Release
# 1.1 - New light modes added: LIGHT2, TORCH, TORCH2
#     - Changed sprite blend mode to ADD (looks slightly better)
#     - Fire-based lights are now red in color
#==============================================================================
# ● Light Modes
#------------------------------------------------------------------------------
#   GROUND - Medium steady white light.
#   FIRE   - Large red light with a slight flicker.
#   LIGHT  - Small steady white light.
#   LIGHT2 - X-Large steady white light.
#   TORCH  - X-Large red light with a heavy flicker.
#   TORCH2 - X-Large red light with a sleight flicker.
#==============================================================================

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[i].code == 108 and event.list[i].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[i].code == 108 and event.list[i].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[i].code == 108 and event.list[i].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[i].code == 108 and event.list[i].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[i].code == 108 and event.list[i].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
        end
        if event.list[i].code == 108 and event.list[i].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.real_x - 400 - $game_map.display_x) / 8
        effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
        effect.light.blend_type = 1
      when "FIRE"
        effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
        effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
        effect.light.tone = Tone.new(255,-100,-255,   0)
        effect.light.blend_type = 1
      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
        effect.light.blend_type = 1
      when "LIGHT2"
        effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
        effect.light.blend_type = 1
      when "TORCH"
        effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.real_y - 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.real_x - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.real_y - 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[1]
      for effect in @light_effects
        next if effect.type == "FIRE" || effect.type == "TORCH"
        effect.light.visible = false
      end
    else
      for effect in @light_effects
        next if effect.type == "FIRE" || effect.type == "TORCH"
        effect.light.visible = true
      end
    end
    for effect in @light_effects
      case effect.type
      when "GROUND"
        effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
        effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
      when "FIRE"
        effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
        effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
        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.real_x - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
      when "TORCH"
        effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
        effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8 + rand(20) - 10
        effect.light.opacity = rand(30) + 70
      when "TORCH2"
        effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
        effect.light.y = (effect.event.real_y - 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









이 빛스크립트를 스위치나 주석으로 turn/off할수있게 편집해주세요 부탁드립니다,

Comment '2'
  • ?
    AltusZeon 2014.08.03 03:00

    설명 읽어보시면 아시겠지만 이미 있는 기능입니다.
    The SWITCH setting below will disable light effects from updating with the switch is on.
    (아래의 스위치 설정은 광원 효과를 켜고 끌 수 있게 해줍니다.)

    스크립트 내에 $game_switches[1]이라고 적힌 부분이 있습니다. (찾기 어려우시면 검색 기능 Ctrl+F로 찾으시길 바랍니다.)
    1이라는 숫자를 원하시는 스위치의 ID로 바꾸셔서 사용하시면 될 것 같습니다.


    스크립트 설명에는 안 나와있지만, 광원 모드가 FIRE와 TORCH일 때는

    스위치를 이용한 광원 효과 켜고 끄기가 안 되는 걸로 보입니다.

  • ?
    붉은 원숭이 2014.08.03 22:34
    아하 제가 FIRE을 써서 켜고끄기가 않됀거였군요 감사합니다!

계속 검색
List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12387
기타 RMMV 이미지캐시가 쌓여 게임이 꺼집니다 1 hurakan 2023.07.12 40
스크립트 사용 RMVXA 그림 각도 회전 스크립트 질문 file slieun 2022.10.03 50
이벤트 작성 RMVXA 상점에서 돈이 있어도 아이템을 딱 하나만 살 수 있게 바꿀 수 있나요? 4 유리컵 2022.09.22 243
턴제 전투 RMVXA 한글패치후 턴제전투시 번역되지 않은 を倒した!위치가 궁금합니다. 2 file 유리컵 2022.02.26 269
스크립트 사용 RMVXA vx ace) 잘 작동하던 스크립트가 갑자기 작동하지 않습니다. file 게임이만들고파 2021.03.20 63
스크립트 작성 RMVXA vx ace) 변수에 스크립트 대입하는 방법 2 게임이만들고파 2021.03.13 166
스크립트 사용 RMVXA vx ace) 스크립트가 작동하질 않습니다... 2 file 게임이만들고파 2021.01.05 188
스크립트 작성 RMMV (스크립트 요청)4개의 변수중에서 음수를 제외한 가장 작은 수를 찾는 법을 찾고있습니다. 2 나 어토믹 2019.03.27 134
RMVXA 고수분들 도와주세요! 자꾸 스크립트에 NoMethodError undefined method ~~for nil:NilClass가 뜨네요 ㅠ 미스터챈 2017.02.21 168
RMVXA 스크립트 처리하는데 다른 클래스에서 대기 시간은 어떻게 넣나요?? 미스터챈 2017.02.19 67
RMVXA 스크립트 에디터에서 게임오버시... 3 BeNew 2016.09.08 145
RMVXA 편집창이 커졌어요 2 file bs0429 2016.03.01 213
RMVXA 스크립트를 수정했는데, refresh 처리 할때 프레임 낮아집니다... 도와주세요! 5 file 몽롱하다 2016.02.20 127
RMVXA 스크립트 에디터의 내용을 필드 이벤트에 있는 스크립트로 바꾸는 방법? 몽롱하다 2016.02.14 146
RMVXA 특정 아이템끼리 모아놓기 2 길라잡이 2015.06.21 142
RMVX RGSS2에서의 아이템의 이름제작 및 아이템의 갯수 확인 4 FNS키리토 2015.04.20 332
RMVX 빛스크립트좀 편집해주세요 2 붉은 원숭이 2014.08.03 576
계속 검색
Board Pagination Prev 1 Next
/ 1