IceDragon200

ThomasEdison-Edited

Jun 16th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.90 KB | None | 0 0
  1. =begin
  2.                               Thomas Edison VX
  3.  
  4. Version: 0.1
  5. Author: BulletXt ([email protected])
  6. Date: 12/06/2009
  7. Script based upon Kylock's (http://www.rpgmakervx.net/index.php?showtopic=2432)
  8.  
  9.  
  10. Description:
  11.  To make an event glow, put a Comment inside event with one of the following
  12.  light modes. When importing this script to a new project, be sure to copy
  13.  Graphics/Pictures/le.png to your project.
  14.  
  15. Light Modes:
  16.  
  17.  GROUND - Medium steady white light.
  18.  GROUND2 - Medium white light with slight flicker.
  19.  GROUND3 - Small steady red light.
  20.  GROUND4 - Medium steady green light.
  21.  GROUND5 - Medium steady blue light.
  22.  GROUND6 - Medium steady purple light.
  23.  FIRE - Large red light with a slight flicker.
  24.  FIRE2 - Large blue light with a slight flicker.
  25.  LIGHT - Small steady white light.
  26.  LIGHT2 - X-Large steady white light.
  27.  LIGHT3 - Small white light with slight flicker.
  28.  TORCH - X-Large red light with a heavy flicker.
  29.  TORCH2 - X-Large red light with a sleight flicker.
  30.  TORCH3 - Large white light with a slight flicker.
  31.  
  32. You can make a specific light type turn off/on by turning
  33. one of the following switches id ON/off. By default, the switches are off so
  34. the lights will show. Of course, turning all switches to ON will make all
  35. light types go off.
  36.  
  37. =end
  38.  
  39. #id switch that if ON turns off FIRE mode lights
  40. #applies only to light mode: FIRE
  41. FIRE = 87
  42. #id switch that if ON turns off LIGHT mode lights
  43. #applies to light mode: LIGHT, LIGHT2, LIGHT3
  44. LIGHT = 86
  45. #id switch that if ON turns off GROUND mode lights
  46. #applies to light mode: GROUND, GROUND2, GROUND3, GROUND4, GROUND5
  47. GROUND = 85
  48. #id switch that if ON turns off TORCH mode lights
  49. #applies to light mode: TORCH, TORCH2, TORCH3
  50. TORCH = 84
  51.  
  52.  
  53. # this value can be true or false. If true, it enables compatibility with
  54. # KGC_DayNight script. When it's night, lights will automatically go on, when
  55. # morning comes back lights will go off. If you set this to true, be sure to
  56. # place this script below KGC_DayNight script in the Scripting Editor of VX.
  57. ENABLE_KGC_DAY_NIGHT_SCRIPT = false
  58.  
  59. =begin
  60. This value must be exactly the same of "PHASE_VARIABLE" setting in KGC_DayNight
  61. script. By default the script sets it to 11.
  62. To make the event light go on/off with DayNight system, set the event page
  63. to be triggered with this variable id and set it to be 1 or above.
  64. =end
  65. KGC_DAY_NIGHT_SCRIPT_VARIABLE = 11
  66.  
  67. =begin
  68. Tips and tricks:
  69.   You can't make a single specific light inside event go on/off if
  70.   a condition applies, for example if a switch is ON.
  71.   For the moment, you can achieve this by doing
  72.   a script call immediatley after you make the condition apply.
  73.   If for example the light event must go on if switch 100 is ON, after you turn
  74.   on the switch do this call script:
  75.   $scene = Scene_Map.new
  76.  
  77.   Be aware that doing this call script will make game freeze
  78.   for 30 milliseconds.
  79.  
  80. ################################################################################
  81. =end
  82.  
  83.  
  84. $bulletxt_day_check = 0
  85.  
  86. class Spriteset_Map
  87.    
  88.   alias bulletxt_spriteset_map_initalize initialize
  89.     def initialize
  90.         @light_effects = []
  91.         initialize_lights
  92.         bulletxt_spriteset_map_initalize
  93.         update
  94.     end
  95.  
  96.   alias bulletxt_spriteset_map_dispose dispose
  97.     def dispose
  98.         bulletxt_spriteset_map_dispose
  99.         for effect in @light_effects
  100.             effect.light.dispose
  101.         end
  102.         @light_effects = []
  103.     end
  104.    
  105.   alias bulletxt_spriteset_map_update update
  106.     def update
  107.         bulletxt_spriteset_map_update
  108.     check_day_night if ENABLE_KGC_DAY_NIGHT_SCRIPT
  109.         update_light_effects
  110.    
  111.     end
  112.  
  113.  
  114.   def check_day_night
  115.     #if night
  116.    if $bulletxt_day_check == 0
  117.     if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 1
  118.       $scene = Scene_Map.new
  119.       $bulletxt_day_check = 1
  120.  
  121.     end
  122.    
  123.   else
  124.     #if morning
  125.     if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 3
  126.       $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] = -1
  127.       $scene = Scene_Map.new
  128.       $bulletxt_day_check = 0
  129.     end
  130.   end
  131.  
  132.    
  133.    
  134.   end
  135.  
  136.  
  137.     def initialize_lights
  138.         for event in $game_map.events.values
  139.             next if event.list == nil
  140.                 for i in 0...event.list.size
  141.  
  142.                     if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
  143.                         type = "FIRE"
  144.                         light_effects = Light_Effect.new(event,type)
  145.                         light_effects.light.zoom_x = 260 / 100.0
  146.                         light_effects.light.zoom_y = 260 / 100.0
  147.                         light_effects.light.opacity = 100
  148.                         @light_effects.push(light_effects)
  149.                     end
  150.          
  151.           if event.list[i].code == 108 and event.list[i].parameters == ["FIRE2"]
  152.                         type = "FIRE2"
  153.                         light_effects = Light_Effect.new(event,type)
  154.                         light_effects.light.zoom_x = 260 / 100.0
  155.                         light_effects.light.zoom_y = 260 / 100.0
  156.                         light_effects.light.opacity = 100
  157.                         @light_effects.push(light_effects)
  158.                     end
  159.          
  160.                     if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
  161.                         type = "LIGHT"
  162.                         light_effects = Light_Effect.new(event,type)
  163.                         light_effects.light.zoom_x = 1
  164.                         light_effects.light.zoom_y = 1
  165.                         light_effects.light.opacity = 175
  166.                         @light_effects.push(light_effects)
  167.                     end
  168.                     if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
  169.                         type = "LIGHT2"
  170.                         light_effects = Light_Effect.new(event,type)
  171.                         light_effects.light.zoom_x = 6
  172.                         light_effects.light.zoom_y = 6
  173.                         light_effects.light.opacity = 150
  174.                         @light_effects.push(light_effects)
  175.                     end
  176.  
  177.                     if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT3"]
  178.                         type = "LIGHT3"
  179.                         light_effects = Light_Effect.new(event,type)
  180.                         light_effects.light.zoom_x = 1
  181.                         light_effects.light.zoom_y = 1
  182.                         light_effects.light.opacity = 150
  183.                         @light_effects.push(light_effects)
  184.                     end
  185.          
  186.                     if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
  187.                         type = "TORCH"
  188.                         light_effects = Light_Effect.new(event,type)
  189.                         light_effects.light.zoom_x = 6
  190.                         light_effects.light.zoom_y = 6
  191.                         light_effects.light.opacity = 150
  192.                         @light_effects.push(light_effects)
  193.                     end
  194.                     if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
  195.                         type = "TORCH2"
  196.                         light_effects = Light_Effect.new(event,type)
  197.                         light_effects.light.zoom_x = 6
  198.                         light_effects.light.zoom_y = 6
  199.                         light_effects.light.opacity = 150
  200.                         @light_effects.push(light_effects)
  201.                     end
  202.                     if event.list[i].code == 108 and event.list[i].parameters == ["TORCH3"]
  203.                         type = "TORCH3"
  204.                         light_effects = Light_Effect.new(event,type)
  205.                         light_effects.light.zoom_x = 300 / 100.0
  206.                         light_effects.light.zoom_y = 300 / 100.0
  207.                         light_effects.light.opacity = 100
  208.                         @light_effects.push(light_effects)
  209.                     end
  210.          
  211.                     if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
  212.                         type = "GROUND"
  213.                         light_effects = Light_Effect.new(event,type)
  214.                         light_effects.light.zoom_x = 2
  215.                         light_effects.light.zoom_y = 2
  216.                         light_effects.light.opacity = 100
  217.                         @light_effects.push(light_effects)
  218.                     end
  219.                     if event.list[i].code == 108 and event.list[i].parameters == ["GROUND2"]
  220.                         type = "GROUND2"
  221.                         light_effects = Light_Effect.new(event,type)
  222.                         light_effects.light.zoom_x = 2
  223.                         light_effects.light.zoom_y = 2
  224.                         light_effects.light.opacity = 100
  225.                         @light_effects.push(light_effects)
  226.                     end
  227.                     if event.list[i].code == 108 and event.list[i].parameters == ["GROUND3"]
  228.                         type = "GROUND3"
  229.                         light_effects = Light_Effect.new(event,type)
  230.                         light_effects.light.zoom_x = 2
  231.                         light_effects.light.zoom_y = 2
  232.                         light_effects.light.opacity = 100
  233.                         @light_effects.push(light_effects)
  234.                     end
  235.                     if event.list[i].code == 108 and event.list[i].parameters == ["GROUND4"]
  236.                         type = "GROUND4"
  237.                         light_effects = Light_Effect.new(event,type)
  238.                         light_effects.light.zoom_x = 2
  239.                         light_effects.light.zoom_y = 2
  240.                         light_effects.light.opacity = 100
  241.                         @light_effects.push(light_effects)
  242.                     end
  243.                     if event.list[i].code == 108 and event.list[i].parameters == ["GROUND5"]
  244.                         type = "GROUND5"
  245.                         light_effects = Light_Effect.new(event,type)
  246.                         light_effects.light.zoom_x = 2
  247.                         light_effects.light.zoom_y = 2
  248.                         light_effects.light.opacity = 65
  249.                         @light_effects.push(light_effects)
  250.                     end
  251.           if event.list[i].code == 108 and event.list[i].parameters == ["GROUND6"]
  252.                         type = "GROUND6"
  253.                         light_effects = Light_Effect.new(event,type)
  254.                         light_effects.light.zoom_x = 2
  255.                         light_effects.light.zoom_y = 2
  256.                         light_effects.light.opacity = 85
  257.                         @light_effects.push(light_effects)
  258.                     end
  259.                 end
  260.             end
  261.            
  262.     for effect in @light_effects
  263.         case effect.type
  264.        
  265.         when "FIRE"
  266.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  267.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  268.             effect.light.tone = Tone.new(255,-100,-255, 0)
  269.             effect.light.blend_type = 1
  270.     when "FIRE2"
  271.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  272.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  273.             effect.light.tone = Tone.new(-255,-100,255, 0)
  274.             effect.light.blend_type = 1
  275.         when "LIGHT"
  276.             effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  277.             effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  278.             effect.light.blend_type = 1
  279.         when "LIGHT2"
  280.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  281.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  282.             effect.light.blend_type = 1
  283.         when "LIGHT3"
  284.             effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  285.             effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  286.             effect.light.blend_type = 1
  287.         when "TORCH"
  288.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  289.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  290.             effect.light.tone = Tone.new(255,-100,-255, 0)
  291.             effect.light.blend_type = 1
  292.         when "TORCH2"
  293.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  294.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  295.             effect.light.tone = Tone.new(255,-100,-255, 0)
  296.             effect.light.blend_type = 1
  297.         when "TORCH3"
  298.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  299.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  300.             effect.light.blend_type = 1
  301.      
  302.         when "GROUND"
  303.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  304.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  305.             effect.light.blend_type = 1
  306.         when "GROUND2"
  307.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  308.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  309.             effect.light.blend_type = 1
  310.         when "GROUND3"
  311.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  312.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  313.             effect.light.tone = Tone.new(255,-255,-255, 255)
  314.             effect.light.blend_type = 1
  315.         when "GROUND4"
  316.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  317.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  318.             effect.light.tone = Tone.new(-255,255,-255, 100)
  319.             effect.light.blend_type = 1
  320.         when "GROUND5"
  321.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  322.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  323.             effect.light.tone = Tone.new(-255,255,255, 100)
  324.             effect.light.blend_type = 1
  325.     when "GROUND6"
  326.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  327.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  328.             effect.light.tone = Tone.new(147,-112,219, 100)
  329.             effect.light.blend_type = 1
  330.         end
  331.  
  332.     end
  333. end
  334.  
  335.  
  336. def update_light_effects
  337. ################################################################################
  338.  
  339.  
  340.   for effect in @light_effects
  341.     effect.light.visible = effect.event.onScreen?()
  342.     # handle FIRE
  343.     effect.light.visible = !$game_switches[FIRE] if effect.type == "FIRE"
  344.     # handle LIGHT
  345.     effect.light.visible = !$game_switches[LIGHT] if ["LIGHT", "LIGHT2", "LIGHT3"].include?( effect.type )
  346.     # handle GROUND
  347.     effect.light.visible = !$game_switches[GROUND] if ["GROUND", "GROUND2", "GROUND3", "GROUND4", "GROUND5", "GROUND6"].include?( effect.type )
  348.     # handle TORCH
  349.     effect.light.visible = !$game_switches[TORCH] if ["TORCH", "TORCH2", "TORCH3"].include?( effect.type )
  350.     case effect.type
  351.       when "FIRE"
  352.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  353.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  354.             effect.light.opacity = rand(10) + 90
  355.     when "FIRE2"
  356.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  357.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  358.             effect.light.opacity = rand(10) + 90    
  359.       when "LIGHT"
  360.             effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  361.             effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  362.       when "LIGHT2"
  363.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  364.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  365.       when "LIGHT3"
  366.             effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  367.             effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  368.             effect.light.opacity = rand(10) + 90
  369.       when "TORCH"
  370.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
  371.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8 + rand(20) - 10
  372.             effect.light.opacity = rand(30) + 70
  373.       when "TORCH2"
  374.             effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  375.             effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  376.             effect.light.opacity = rand(10) + 90
  377.       when "TORCH3"
  378.             effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  379.             effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  380.             effect.light.opacity = rand(10) + 90
  381.       when "GROUND"
  382.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  383.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  384.       when "GROUND2"
  385.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  386.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  387.             effect.light.opacity = rand(10) + 90
  388.       when "GROUND3"
  389.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  390.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  391.       when "GROUND4"
  392.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  393.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  394.       when "GROUND5"
  395.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  396.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  397.     when "GROUND6"
  398.             effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  399.             effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  400.     end
  401.   end  
  402.  
  403. ################################################################################
  404.  
  405.   #close def
  406.     end
  407. #close class   
  408. end
  409.  
  410.  
  411. class Light_Effect
  412.     attr_accessor :light
  413.     attr_accessor :event
  414.     attr_accessor :type
  415.    
  416.     def initialize(event, type)
  417.         @light = Sprite.new
  418.         @light.bitmap = Cache.picture("le.png")
  419.         @light.visible = true
  420.         @light.z = 9999
  421.         @event = event
  422.         @type = type
  423.     end
  424.  
  425. end
Advertisement
Add Comment
Please, Sign In to add comment