VX 스크립트

=begin
                              Thomas Edison VX

Version: 0.1
Author: BulletXt (bulletxt@gmail.com)
Date: 12/06/2009
Script based upon Kylock's (http://www.rpgmakervx.net/index.php?showtopic=2432)


Description:
 To make an event glow, put a Comment inside event with one of the following
 light modes. When importing this script to a new project, be sure to copy
 Graphics/Pictures/le.png to your project.
 
Light Modes:
 
 GROUND - Medium steady white light.
 GROUND2 - Medium white light with slight flicker.
 GROUND3 - Small steady red light.
 GROUND4 - Medium steady green light.
 GROUND5 - Medium steady blu light.
 FIRE - Large red light with a slight flicker.
 LIGHT - Small steady white light.
 LIGHT2 - X-Large steady white light.
 LIGHT3 - Small white light with slight flicker.
 TORCH - X-Large red light with a heavy flicker.
 TORCH2 - X-Large red light with a sleight flicker.
 TORCH3 - Large white light with a slight flicker.

You can make a specific light type turn off/on by turning
one of the following switches id ON/off. By default, the switches are off so
the lights will show. Of course, turning all switches to ON will make all
light types go off.

=end

#id switch that if ON turns off FIRE mode lights
#applies only to light mode: FIRE
FIRE = 87
#id switch that if ON turns off LIGHT mode lights
#applies to light mode: LIGHT, LIGHT2, LIGHT3
LIGHT = 86
#id switch that if ON turns off GROUND mode lights
#applies to light mode: GROUND, GROUND2, GROUND3, GROUND4, GROUND5
GROUND = 85
#id switch that if ON turns off TORCH mode lights
#applies to light mode: TORCH, TORCH2, TORCH3
TORCH = 84


# this value can be true or false. If true, it enables compatibility with
# KGC_DayNight script. When it's night, lights will automatically go on, when
# morning comes back lights will go off. If you set this to true, be sure to
# place this script below KGC_DayNight script in the Scripting Editor of VX.
ENABLE_KGC_DAY_NIGHT_SCRIPT = true

=begin
This value must be exactly the same of "PHASE_VARIABLE" setting in KGC_DayNight
script. By default the script sets it to 11.
To make the event light go on/off with DayNight system, set the event page
to be triggered with this variable id and set it to be 1 or above.
=end
KGC_DAY_NIGHT_SCRIPT_VARIABLE = 11

=begin
Tips and tricks:
  You can't make a single specific light inside event go on/off if
  a condition applies, for example if a switch is ON.
  For the moment, you can achieve this by doing
  a script call immediatley after you make the condition apply.
  If for example the light event must go on if switch 100 is ON, after you turn
  on the switch do this call script:
  $scene = Scene_Map.new
 
  Be aware that doing this call script will make game freeze
  for 30 milliseconds.

################################################################################
=end


$bulletxt_day_check = 0

class Spriteset_Map
 
  alias bulletxt_spriteset_map_initalize initialize
 def initialize
  @light_effects = []
  initialize_lights
  bulletxt_spriteset_map_initalize
  update
 end

  alias bulletxt_spriteset_map_dispose dispose
 def dispose
  bulletxt_spriteset_map_dispose
  for effect in @light_effects
   effect.light.dispose
  end
  @light_effects = []
 end
 
  alias bulletxt_spriteset_map_update update
 def update
  bulletxt_spriteset_map_update
    check_day_night if ENABLE_KGC_DAY_NIGHT_SCRIPT
  update_light_effects
   
 end

 
  def check_day_night
    #if night
   if $bulletxt_day_check == 0
    if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 1
      $scene = Scene_Map.new
      $bulletxt_day_check = 1
 
    end
   
  else
    #if morning
    if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 3
      $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] = -1
      $scene = Scene_Map.new
      $bulletxt_day_check = 0
    end
  end
 
   
   
  end
 
 
 def initialize_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 == ["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 == ["LIGHT3"]
      type = "LIGHT3"
      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 == ["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[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
     if event.list[i].code == 108 and event.list[i].parameters == ["TORCH3"]
      type = "TORCH3"
      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 == ["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 == ["GROUND2"]
      type = "GROUND2"
      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 == ["GROUND3"]
      type = "GROUND3"
      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 == ["GROUND4"]
      type = "GROUND4"
      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 == ["GROUND5"]
      type = "GROUND5"
      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
    end
   end
   
 for effect in @light_effects
  case effect.type
  
  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 "LIGHT3"
   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 "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
  when "TORCH3"
   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.blend_type = 1
     
  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 "GROUND2"
   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 "GROUND3"
   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.tone = Tone.new(255,-255,-255, 255)
   effect.light.blend_type = 1
  when "GROUND4"
   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.tone = Tone.new(-255,255,-255, 100)
   effect.light.blend_type = 1
  when "GROUND5"
   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.tone = Tone.new(-255,255,255, 100)
   effect.light.blend_type = 1
  end
 end
end


def update_light_effects
################################################################################
 
  # handle FIRE
  if $game_switches[FIRE]
    for effect in @light_effects
      next if effect.type != "FIRE"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
     next if effect.type != "FIRE"
      effect.light.visible = true
    end
  end

  # handle LIGHT
  if $game_switches[LIGHT]
    for effect in @light_effects
      next if effect.type != "LIGHT" && effect.type != "LIGHT2" && effect.type != "LIGHT3"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "LIGHT" && effect.type != "LIGHT2" && effect.type != "LIGHT3"
      effect.light.visible = true
    end
  end


  # handle GROUND
  if $game_switches[GROUND]
    for effect in @light_effects
      next if effect.type != "GROUND" && effect.type != "GROUND2" && effect.type != "GROUND3" && effect.type != "GROUND4" && effect.type != "GROUND5"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "GROUND" && effect.type != "GROUND2" && effect.type != "GROUND3" && effect.type != "GROUND4" && effect.type != "GROUND5"
      effect.light.visible = true
    end
  end


  # handle TORCH
  if $game_switches[TORCH]
    for effect in @light_effects
      next if effect.type != "TORCH" && effect.type != "TORCH2" && effect.type != "TORCH3"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "TORCH" && effect.type != "TORCH2" && effect.type != "TORCH3"
      effect.light.visible = true
    end
  end

 

 

################################################################################

 for effect in @light_effects
  case effect.type

 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 "LIGHT3"
   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.opacity = rand(10) + 90
     
 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
 when "TORCH3"
   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 "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 "GROUND2"
   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.opacity = rand(10) + 90
 when "GROUND3"
   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 "GROUND4"
   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 "GROUND5"
   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
  end
 end

  #close def
 end
#close class 
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

밤낮스크립트와 같이쓰면 좋습니다.

데모를 반드시 확인해 주세요!

출처:rmrk

Comment '9'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
457 타이틀/게임오버 RPG VX - 타이틀 스크린 스크립트 23 아방스 2008.01.24 5740
456 기타 rpg vx 렉 줄이는 스크립트 34 아방스 2008.03.09 4813
455 그래픽 RPG XP의 Transitions효과를 VX에도 적용을 해보자 4 아방스 2008.01.27 3930
454 HUD rpg 만들기 vx - 맵이름 띠우는 스크립트 ^^ 74 아방스 2008.01.27 11923
453 맵/타일 RPG 만들기 VX 로 구현한 3D~ 42 아방스 2008.09.02 8405
452 메뉴 rpg 만들기 vx 정보창에 조금더 자세한 정보가 나오게 하는 스크립트 28 아방스 2008.01.25 5076
451 전투 RPGTankentai SBS3.3b 버전 (사이드뷰) 21 file 카르와푸딩의아틀리에 2009.07.01 8455
450 온라인 RPGVX 3D스크립트 11 file 고자몬 2011.07.10 5050
449 전투 rpgvx 간단액알 스크립트 제작: 41 *PS 2008.02.07 9821
448 기타 RTS? 미니게임 스크립트 7 file 사람이라면? 2010.08.16 2788
447 전투 sbs battler configuration 한글 번역 13 file 시트르산 2010.09.23 4475
446 Scene_Credit script Plug & Play 1 Man... 2008.10.27 1085
445 Screen Resolution 3 Man... 2008.10.28 1171
444 Screen Shortcut Script Man... 2008.10.27 1142
443 SephirothSpawn's Slanted Bars in VX 1.1 2 Man... 2008.10.28 1572
442 상점 Shopoholic(한글 설명) 11 Man... 2008.10.29 3185
441 Side View CBS 사이드뷰배틀 블리치버젼 13 RPGbooster 2008.10.11 5232
440 Simple Fon Chage 3 Man... 2008.10.28 1212
439 스킬 Simple Sort Inventory 1.3a by cozziekuns 5 file Alkaid 2010.11.10 1636
438 스킬 Simple Sort Inventory 2.0 by cozziekuns 1 file Alkaid 2011.09.29 2350
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32