- foxhiveMembre
- Nombre de messages : 35
Distinction : aucune
Date d'inscription : 06/12/2010
[Résolue]Light Effects Version Ultime
Mar 3 Jan 2012 - 4:48
Salutation,
Je me demander, je viens de commencer a mapper un peu sur Ace mais certains script me manque beaucoup ,
dont un particulièrement ! il s'agit enfaite du script d'effet de lumière qui été assez puissant, on pouvait faire de très beau effet avec !
...Je me demander simplement si il y avait possibilité de le "traduire" en RGSS3 ?
Je vous remercie d'avoir lu et de vos éventuel réponse Voici le script en RGSS2
Voici les images qui vont avec le script :
Cordialement,
Je me demander, je viens de commencer a mapper un peu sur Ace mais certains script me manque beaucoup ,
dont un particulièrement ! il s'agit enfaite du script d'effet de lumière qui été assez puissant, on pouvait faire de très beau effet avec !
...Je me demander simplement si il y avait possibilité de le "traduire" en RGSS3 ?
Je vous remercie d'avoir lu et de vos éventuel réponse Voici le script en RGSS2
- Code:
=begin
Light Effects Version Ultime by CloudStrife/Garruk
Version: 0.1
Author: BulletXt (bulletxt@gmail.com) Kylock and Cloudstrife
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 - Le moyen stabilise la lumière blanche.
GROUND2 - Lumière blanche moyenne avec éclat léger.
GROUND3 - Petite lumière rouge stable.
GROUND4 - Le moyen stabilise le feu vert.
GROUND5 - Le moyen stabilise la lumière de blue
GROUND6- Le moyen stabilise la lumière de violet
GROUND7-Le moyen stabilise la lumière de jaune.
FIRE - Lumière rouge, intensité forte
LIGHT - Lumière standard, intensitée petite
# LIGHT2 - Lumière standard, intensitée moyenne
# LIGHT3 - Lumière standard, intensitée forte
TORCH - X-Large lumière rouge avec un lourd éclat.
TORCH2 - X-Large lumière rouge avec un éclat d'habileté.
TORCH3 - Grande lumière blanche avec un éclat léger.
TORCH4 - Lumière Rouge moyenne.
# TORCH1B - Lumiére bleu, intesitée petite, ondule
# TORCH2B - Lumiére bleu, intesitée moyenne, ondule
# TORCH3B - Lumiére bleu, intesitée forte, ondule
# TORCH1V - Lumiére verte, intesitée petite, ondule
# TORCH2V - Lumiére verte, intesitée forte, ondule
# LIGHT1B - Lumière bleu, intensitée petite
# LIGHT2B - Lumière bleu, intensitée moyenne
# LIGHT1V - Lumière verte, intensitée petite
# LIGHT2V - Lumière verte, intensitée moyenne
# OMBRE - Lumière noir
Cette partie permet d'éteindre les lumières à l'aide des interrupteurs.
Chaque interrupteur permet d'éteindre un groupe de lumière comme les LIGHT par exemple
Vous pouvez changer l'ID de l'interrupteur comme bon vous sembles
Bref amusez-vous à éteindre/allumer les lumière de votre projet pour créer des scénes surpuissantes
Modification by CloudStrife (le faux
=end
#ID de l'interrupteur qui permet d'éteindre les lumières de mode de FIRE
#Ne marche seulement pour allumer et éteindre le mode : FIRE
FIRE = 87
#Pareil pour le mode LIGHT
#Eteins et allume les lumière avec les commentaires: LIGHT, LIGHT2, LIGHT3
LIGHT = 86
#On fini avec les GROUND
#Donc: GROUND, GROUND2, GROUND3, GROUND4, GROUND5
GROUND = 85
#Ma après les GROUND il reste les TORCH
#applies to light mode: TORCH, TORCH2, TORCH3 et les autres qui ne sont pas cités
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 = 999
=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 == ["TORCH4"]
type = "TORCH4"
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 == ["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
if event.list[i].code == 108 and event.list[i].parameters == ["GROUND6"]
type = "GROUND6"
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 == ["GROUND7"]
type = "GROUND7"
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 == ["TORCH1B"]
type = "TORCH1B"
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 == ["TORCH2B"]
type = "TORCH2B"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 3
light_effects.light.zoom_y = 3
light_effects.light.opacity = 150
@light_effects.push(light_effects)
end
if event.list[i].code == 108 and event.list[i].parameters == ["TORCH3B"]
type = "TORCH3B"
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 == ["TORCH1V"]
type = "TORCH1V"
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 == ["TORCH2V"]
type = "TORCH2V"
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 == ["TORCH1VIO"]
type = "TORCH1VIO"
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 == ["LIGHT1B"]
type = "LIGHT1B"
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 == ["LIGHT2B"]
type = "LIGHT2B"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 3
light_effects.light.zoom_y = 3
light_effects.light.opacity = 150
@light_effects.push(light_effects)
end
if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT1V"]
type = "LIGHT1V"
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 == ["LIGHT2V"]
type = "LIGHT2V"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 3
light_effects.light.zoom_y = 3
light_effects.light.opacity = 150
@light_effects.push(light_effects)
end
if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2VV"]
type = "LIGHT2VV"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 3
light_effects.light.zoom_y = 3
light_effects.light.opacity = 150
@light_effects.push(light_effects)
end
if event.list[i].code == 108 and event.list[i].parameters == ["OMBRE"]
type = "OMBRE"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 3
light_effects.light.zoom_y = 3
light_effects.light.opacity = 150
@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 "TORCH4"
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 "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
when "GROUND6"
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(85,-255,85, 255)
effect.light.blend_type = 1
when "GROUND7"
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
#"Tone" indique la couleur
when "TORCH1B"
effect.light.x = (effect.event.real_x - -10 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 100 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-100,-60,200, 0)
effect.light.blend_type = 1
when "TORCH2B"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-100,-60,200, 0)
effect.light.blend_type = 1
when "TORCH3B"
effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 1400 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-100,-60,200, 0)
effect.light.blend_type = 1
when "TORCH1V"
effect.light.x = (effect.event.real_x - -10 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 100 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-100,100,-100, 0)
effect.light.blend_type = 1
when "TORCH2V"
effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 1400 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-100,100,-100, 0)
effect.light.blend_type = 1
when "TORCH1VIO"
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(80,-100,80, 0)
effect.light.blend_type = 1
when "LIGHT1B"
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.tone = Tone.new(-150,-150,300, 0)
effect.light.blend_type = 1
when "LIGHT2B"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-150,-150,300, 0)
effect.light.blend_type = 1
when "LIGHT1V"
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.tone = Tone.new(-150,300,-150, 0)
effect.light.blend_type = 1
when "LIGHT2V"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-150,300,-100, 0)
effect.light.blend_type = 1
when "LIGHT2VV"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-150,300,10, 0)
effect.light.blend_type = 1
when "OMBRE"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
effect.light.tone = Tone.new(-255,-255,-255, -255)
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.type != "GROUND6" && effect.type != "GROUND7"
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.type != "GROUND6" && effect.type != "GROUND7"
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.type != "TORCH4"
effect.light.visible = false
end
else
for effect in @light_effects
next if effect.type != "TORCH" && effect.type != "TORCH2" && effect.type != "TORCH3"&& effect.type != "TORCH4"
effect.light.visible = true
end
end
# handle TORCH
if $game_switches[TORCH]
for effect in @light_effects
next if effect.type != "TORCH1B" && effect.type != "TORCH2B" && effect.type != "TORCH3B"&& effect.type != "TORCH1V"
effect.light.visible = false
end
else
for effect in @light_effects
next if effect.type != "TORCH1B" && effect.type != "TORCH2B" && effect.type != "TORCH3B"&& effect.type != "TORCH1V"
effect.light.visible = true
end
end
# handle TORCH
if $game_switches[TORCH]
for effect in @light_effects
next if effect.type != "TORCH2V" && effect.type != "LIGHT1B" && effect.type != "LIGHT2B"&& effect.type != "LIGHT1V"
effect.light.visible = false
end
else
for effect in @light_effects
next if effect.type != "TORCH2V" && effect.type != "LIGHT1B" && effect.type != "LIGHT2B"&& effect.type != "LIGHT1V"
effect.light.visible = true
end
end
# handle TORCH
if $game_switches[TORCH]
for effect in @light_effects
next if effect.type != "LIGHT2V" && effect.type != "OMBRE"
effect.light.visible = false
end
else
for effect in @light_effects
next if effect.type != "LIGHT2V" && effect.type != "OMBRE"
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"TORCH4"
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 "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
when "GROUND6"
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 "GROUND7"
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 "TORCH1B"
effect.light.x = (effect.event.real_x - -10 - $game_map.display_x) / 8 - 20 + rand(6) - 3
effect.light.y = (effect.event.real_y - 100 - $game_map.display_y) / 8 + rand(6) - 3
effect.light.opacity = rand(30) + 70
when "TORCH2B"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20 + rand(20) - 10
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8 + rand(20) - 10
effect.light.opacity = rand(30) + 70
when "TORCH3B"
effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
effect.light.y = (effect.event.real_y - 1400 - $game_map.display_y) / 8 + rand(20) - 10
effect.light.opacity = rand(30) + 70
when "TORCH1V"
effect.light.x = (effect.event.real_x - -10 - $game_map.display_x) / 8 - 20 + rand(20) - 10
effect.light.y = (effect.event.real_y - 100 - $game_map.display_y) / 8 + rand(20) - 10
effect.light.opacity = rand(30) + 70
when "TORCH2V"
effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20+ + rand(6) - 3
effect.light.y = (effect.event.real_y - 1400 - $game_map.display_y) / 8 + rand(6) - 3
effect.light.opacity = rand(30) + 70
when "TORCH1VIO"
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 "LIGHT1B"
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 "LIGHT2B"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
when "LIGHT1V"
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 "LIGHT2V"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
when "LIGHT2VV"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
when "OMBRE"
effect.light.x = (effect.event.real_x - 490 - $game_map.display_x) / 8 - 20
effect.light.y = (effect.event.real_y - 650 - $game_map.display_y) / 8
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
Voici les images qui vont avec le script :
Cordialement,
- UltimaSasukeMembre
- Nombre de messages : 88
Age : 28
Localisation : France, 05
Distinction : aucune
Date d'inscription : 27/07/2011
Re: [Résolue]Light Effects Version Ultime
Mar 3 Jan 2012 - 18:57
Il existe sous RPG Maker VX Ace un script d'effet de lumière beaucoup plus intéréssant que celui-ci le voici :
C'est un script de Victor, je te conseil de te rendre sur son site pour télécharger sa démo avec les images.
Et si tu te dis non je n'y vais pas voici un apperçu de ce que se script peut faire partielement car il existe de nombreuses autres chose à découvrire, le script est en anglais, je bosserais surement sur la trad' quand j'aurais le temps.
Le site de Victor et le post sur ce script
Bonne chance! =)
- Code:
#==============================================================================
# ** Victor Engine - Light Effects
#------------------------------------------------------------------------------
# Author : Victor Sant
#
# Version History:
# v 1.00 - 2011.12.21 - First relase
# v 1.01 - 2011.12.23 - Compatibility with Diagonal Movement
# v 1.02 - 2011.12.24 - Better checks for images bigger than screen
# v 1.03 - 2011.12.27 - Fixed bug when teleporting to same map
# v 1.04 - 2011.12.30 - Faster Regular Expressions
#------------------------------------------------------------------------------
# This scripts allow to add varied light effects to the maps. But it works
# different from other scripts with this function.
# Normally, light effect scripts add images above the events, and then the
# screen is tone is changed, with the images staying bellow the darker layer.
# This script add an new darkened layer, and apply the light effect images
# on this layer.
#
#------------------------------------------------------------------------------
# Compatibility
# Requires the script 'Victor Engine - Basic Module'
#
# * Overwrite methods
# None
#
# * Alias methods
# class Game_Map
# def setup(map_id)
#
# class Game_CharacterBase
# def init_public_members
# def update
#
# class Game_Event < Game_Character
# def clear_starting_flag
#
# class Spriteset_Map
# def initialize
# def update
# def dispose
#
# class Scene_Map
# def pre_transfer
#
# class Game_Interpreter
# def comment_call
#
#------------------------------------------------------------------------------
# Instructions:
# To instal the script, open you script editor and paste this script on
# a new section on bellow the Materials section. This script must also
# be bellow the script 'Victor Engine - Basic'
# The lights must be placed on the folder "Graphics/Lights". Create a folder
# named "Lights" on the Graphics folder.
#
#------------------------------------------------------------------------------
# Comment calls note tags:
# Tags to be used in events comment box, works like a script call.
#
# <create shade>
# setting
# </create shade>
# Create a shade effect on the map, add the following values to the setting.
# opacity: x : opacity (0-255)
# red: x : red tone (0-255, can be negative)
# green: x : green tone (0-255, can be negative)
# blue: x : blue tone (0-255, can be negative)
# blend: x : fog blend type (0: normal, 1: add, 2: subtract)
#
# <actor light> <event light> <vehicle light>
# setting setting setting
# </actor light> </event light> </vehicle ligth>
# Create a light effect on actor, event or vehicle, add the following
# values to the info. The ID, index and name must be added, other values
# are optional.
# id: x : ligh effect ID
# name: "x" : ligh effect graphic filename ("filename")
# index: x : actor index, event id or (0: boat, 1: ship, 2: airship)
# opacity: x : light opacity (0-255)
# pos_x: x : coordinate X adjust
# pos_y: x : coordinate Y adjust
# var: x : light opacity variation
# speed: x : light variation speed
# zoom: x : ligh effect zoom (100 = default size)
#
# <map light>
# setting
# </map light>
# Create a light effect on a specific map postion, add the following
# values to the info. The ID, map_x, map_y and name must be added, other
# values are optional.
# id: x : ligh effect ID
# name: "x" : ligh effect graphic filename ("filename")
# map_x: x : map X coordinate
# map_y: x : map Y coordinate
# opacity: x : light opacity (0-255)
# pos_x: x : coordinate X adjust
# pos_y: x : coordinate Y adjust
# var: x : light opacity variation
# speed: x : light variation speed
# zoom: x : ligh effect zoom (100 = default size)
#
# <actor lantern i: o>
# <event lantern i: o>
# <vehicle lantern i: o>
# Call a lantern on the target character, lanterns are effets that
# lights the front of the character
# i : actor index, event id or (0: boat, 1: ship, 2: airship)
# o : light opacity (0-255)
#
# <light opacity id: o, d>
# This tag allows to change the light opacity gradually
# i : light effect ID
# o : new opacity (0-255)
# d : wait until complete change (60 frames = 1 second)
#
# <shade opacity: o, d>
# This tag allows to change the shade opacity gradually
# o : new opacity (0-255)
# d : wait until complete change (60 frames = 1 second)
#
# <shade tone: r, g, b, d>
# This tag allows to change the shade opacity gradually
# r : red tone (0-255, can be negative)
# g : green tone (0-255, can be negative)
# b : blue tone (0-255, can be negative)
# d : wait until complete change (60 frames = 1 second)
#
# <remove_light: id>
# This tag allows remove a light effect
# id: ligh effect ID
#
#------------------------------------------------------------------------------
# Maps note tags:
# Tags to be used on the Maps note box in the database
#
# <create shade>
# setting
# </create shade>
# Create a shade effect on the map, add the following values to the setting.
# opacity: x : opacity (0-255)
# red: x : red tone (0-255, can be negative)
# green: x : green tone (0-255, can be negative)
# blue: x : blue tone (0-255, can be negative)
# blend: x : fog blend type (0: normal, 1: add, 2: subtract)
#
# <actor light> <event light> <vehicle light>
# setting setting setting
# </actor light> </event light> </vehicle ligth>
# Create a light effect on actor, event or vehicle, add the following
# values to the info. The ID, index and name must be added, other values
# are optional.
# id: x : ligh effect ID
# name: "x" : ligh effect graphic filename ("filename")
# index: x : actor index, event id or (0: boat, 1: ship, 2: airship)
# opacity: x : light opacity (0-255)
# pos_x: x : coordinate X adjust
# pos_y: x : coordinate Y adjust
# var: x : light opacity variation
# speed: x : light variation speed
# zoom: x : ligh effect zoom (100 = default size)
#
# <map light>
# setting
# </map light>
# Create a light effect on a specific map postion, add the following
# values to the info. The ID, map_x, map_y and name must be added, other
# values are optional.
# id: x : ligh effect ID
# name: "x" : ligh effect graphic filename ("filename")
# map_x: x : map X coordinate
# map_y: x : map Y coordinate
# opacity: x : light opacity (0-255)
# pos_x: x : coordinate X adjust
# pos_y: x : coordinate Y adjust
# var: x : light opacity variation
# speed: x : light variation speed
# zoom: x : ligh effect zoom (100 = default size)
#
# <actor lantern i: o>
# <event lantern i: o>
# <vehicle lantern i: o>
# Call a lantern on the target character, lanterns are effets that
# lights the front of the character
# i : actor index, event id or (0: boat, 1: ship, 2: airship)
# o : light opacity (0-255)
#
#------------------------------------------------------------------------------
# Comment boxes note tags:
# Tags to be used on events Comment boxes. They're different from the
# comment call, they're called aways the even refresh.
#
# <custom light>
# settings
# </custom light>
# Create a custom light effect on actor, event or vehicle, add the following
# values to the settings. The name must be added, other values
# are optional.
# name: "x" : ligh effect graphic filename ("filename")
# opacity: x : light opacity (0-255)
# pos_x: x : coordinate X adjust
# pos_y: x : coordinate Y adjust
# var: x : light opacity variation
# speed: x : light variation speed
# zoom: x : ligh effect zoom (100 = default size)
#
# <simple light: o>
# <simple lamp: o>
# <simple torch: o>
# <simple window 1: o>
# <simple window 2: o>
# Simple light shortcuts
# o : new opacity (0-255)
#
# <flash light: o>
# <flash lamp: o>
# <flash torch: o>
# <flash window 1: o>
# <flash window 2: o>
# Flashing light shortcuts
# o : new opacity (0-255)
#
# <lantern: o>
# Lanterns shortcut
# o : new opacity (0-255)
#
#------------------------------------------------------------------------------
# Additional instructions:
#
# The lights are placed on the shade, so you *must* create a shade in order
# to display the lights. No shade, no lights.
#
# The IDs of the light effects are used as identifiers. Don't use the
# same value for different light spots, if you do so, one light will
# replace the other. Also the IDs are used as referece to when
# removing lights and changing light opacity.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
#------------------------------------------------------------------------------
# Setting module for the Victor Engine
#==============================================================================
$imported[:ve_light_effects] = true
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
# This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# * New method: lights
#--------------------------------------------------------------------------
def self.lights(filename)
self.load_bitmap('Graphics/Lights/', filename)
end
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as change in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :lights
attr_reader :shade
attr_accessor :remove_light
#--------------------------------------------------------------------------
# * Alias method: clear
#--------------------------------------------------------------------------
alias :clear_ve_light_effects :clear
def clear
clear_ve_light_effects
clear_lights
end
#--------------------------------------------------------------------------
# * New method: clear_lights
#--------------------------------------------------------------------------
def clear_lights
@lights = {}
@remove_light = []
@shade = Game_ShadeEffect.new
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Alias method: setup
#--------------------------------------------------------------------------
alias :setup_ve_light_effects :setup
def setup(map_id)
setup_ve_light_effects(map_id)
setup_lights_effect
end
#--------------------------------------------------------------------------
# * New method: setup_lights_effect
#--------------------------------------------------------------------------
def setup_lights_effect
setup_map_shade(note)
setup_map_lights(:actor, note)
setup_map_lights(:event, note)
setup_map_lights(:vehicle, note)
setup_map_lights(:map, note)
setup_map_lantern(:actor, note)
setup_map_lantern(:event, note)
setup_map_lantern(:vehicle, note)
end
#--------------------------------------------------------------------------
# * New method: setup_map_shade
#--------------------------------------------------------------------------
def setup_map_shade(text)
regexp = /<CREATE SHADE>([^><]*)<\/CREATE SHADE>/im
if text =~ regexp
info = $1.dup
shade = @screen.shade
shade.show
shade.opacity = info =~ /OPACITY: (\d+)/i ? $1.to_i : 192
shade.blend = info =~ /BLEND: (\d+)/i ? $1.to_i : 2
red = info =~ /RED: (\d+)/i ? $1.to_i : 0
green = info =~ /GREEN: (\d+)/i ? $1.to_i : 0
blue = info =~ /BLUE: (\d+)/i ? $1.to_i : 0
shade.set_color(red, green, blue)
end
end
#--------------------------------------------------------------------------
# * New method: setup_map_lights
#--------------------------------------------------------------------------
def setup_map_lights(type, text)
value = get_regexp_value(type)
regexp = /<#{value} LIGHT>([^><]*)<\/#{value} LIGHT>/im
text.scan(regexp) do |info|
light = setup_light(info.dup, type)
@screen.lights[light.id] = light if light.id
end
end
#--------------------------------------------------------------------------
# * New method: setup_map_lantern
#--------------------------------------------------------------------------
def setup_map_lantern(type, text)
value = get_regexp_value(type)
regexp = /<#{value} LANTERN (\d+): (\d+)>/i
text.scan(regexp) do |index, opacity|
target = get_font(type, index.to_i)
next unless target
target.lantern = opacity.to_i
target.update_lantern
end
end
#--------------------------------------------------------------------------
# * New method: get_regexp_value
#--------------------------------------------------------------------------
def get_regexp_value(type)
case type
when :actor then "ACTOR"
when :event then "EVENT"
when :vehicle then "VEHICLE"
when :map then "MAP"
end
end
#--------------------------------------------------------------------------
# * New method: setup_light
#--------------------------------------------------------------------------
def setup_light(info, type)
light = Game_LightEffect.new
light.name = info =~ /NAME: [\"\'](.*)[\"\']/i ? $1.dup : ""
light.id = info =~ /ID: (\w+)/i ? $1.to_s : 0
light.id = info =~ /ID: (\d+)/i ? $1.to_i : light.id
light.x = info =~ /POS X: (-?\d+)/i ? $1.to_i : 0
light.y = info =~ /POS Y: (-?\d+)/i ? $1.to_i : 0
light.speed = info =~ /SPEED: (\d+)/i ? $1.to_i : 0
light.zoom = info =~ /ZOOM: (\d+)/i ? $1.to_f : 100.0
light.opacity = info =~ /OPACITY: (\d+)/i ? $1.to_i : 192
light.variance = info =~ /VAR: (\d+)/i ? $1.to_i : 0
if type == :map
map_x = info =~ /MAP X: (\d+)/i ? $1.to_i : 0
map_y = info =~ /MAP Y: (\d+)/i ? $1.to_i : 0
light.info = {x: map_x, y: map_y}
else
index = info =~ /INDEX: (\d+)/i ? $1.to_i : 0
light.info = {type => index}
end
light
end
#--------------------------------------------------------------------------
# * New method: set_light
#--------------------------------------------------------------------------
def set_light(id, name, info, op = 0, x = 0, y = 0, v = 0, s = 0, z = 100)
light = Game_LightEffect.new
light.id = id
light.name = name
light.info = info
light.opacity = op.to_i
light.x = x.to_i
light.y = y.to_i
light.variance = v.to_i
light.speed = s.to_i
light.zoom = z.to_f
light
end
#--------------------------------------------------------------------------
# * New method: get_font
#--------------------------------------------------------------------------
def get_font(type, i)
case type
when :actor then actors[i]
when :event then events[i]
when :vehicle then vehicles[i]
end
end
end
#==============================================================================
# ** Game_CharacterBase
#------------------------------------------------------------------------------
# This class deals with characters. Common to all characters, stores basic
# data, such as coordinates and graphics. It's used as a superclass of the
# Game_Character class.
#==============================================================================
class Game_CharacterBase
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :lantern
#--------------------------------------------------------------------------
# * Alias method: init_public_members
#--------------------------------------------------------------------------
alias :init_public_members_ve_light_effects :init_public_members
def init_public_members
init_public_members_ve_light_effects
@lantern = 0
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_light_effects :update
def update
update_ve_light_effects
update_lantern
end
#--------------------------------------------------------------------------
# * New method: update_lantern
#--------------------------------------------------------------------------
def update_lantern
diag = $imported[:ve_diagonal_move] && diagonal?
if @lantern != 0 && ((!diag && @lantern_direction != @direction) ||
(diag && @lantern_direction != @diagonal))
@lantern_direction = (diag ? @diagonal : @direction)
light = setup_lantern
$game_map.screen.lights[light.id] = light
elsif @lantern == 0 && @lantern_direction
id = is_event? ? "EL#{@id}" : "AL#{@id}"
$game_map.screen.remove_light.push(id) if $game_map.screen.remove_light
@lantern_direction = nil
end
end
#--------------------------------------------------------------------------
# * New method: setup_lantern
#--------------------------------------------------------------------------
def setup_lantern
id = is_event? ? "EL#{@id}" : "AL#{@id}"
type = is_event? ? :event : :actor
case @lantern_direction
when 1
name = 'lantern_downleft'
value = [id, name, {type => @id}, @lantern, -48, 48]
when 3
name = 'lantern_downright'
value = [id, name, {type => @id}, @lantern, 48, 48]
when 2
name = 'lantern_down'
value = [id, name, {type => @id}, @lantern, 0, 64]
when 4
name = 'lantern_left'
value = [id, name, {type => @id}, @lantern, -64, 0]
when 6
name = 'lantern_right'
value = [id, name, {type => @id}, @lantern, 64, 0]
when 7
name = 'lantern_upleft'
value = [id, name, {type => @id}, @lantern, -48, -48]
when 8
name = 'lantern_up'
value = [id, name, {type => @id}, @lantern, 0, -64,]
when 9
name = 'lantern_upright'
value = [id, name, {type => @id}, @lantern, 48, -48]
end
$game_map.set_light(*value)
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player.
# The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * New method: perform_transfer
#--------------------------------------------------------------------------
def new_map_id
@new_map_id
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Alias method: clear_starting_flag
#--------------------------------------------------------------------------
alias :clear_starting_flag_ve_light_effects :clear_starting_flag
def clear_starting_flag
clear_starting_flag_ve_light_effects
@lantern = 0
$game_map.screen.remove_light.push("EV#{@id}")
refresh_lights if @page
end
#--------------------------------------------------------------------------
# * New method: refresh_lights
#--------------------------------------------------------------------------
def refresh_lights
case note
when /<SIMPLE LIGHT: (\d+)?>/i
set_light("EV#{@id}", "light", $1 ? $1 : 255)
when /<SIMPLE LAMP: (\d+)?>/i
set_light("EV#{@id}", "lamp", $1 ? $1 : 255)
when /<SIMPLE TORCH: (\d+)?>/i
set_light("EV#{@id}", "torch", $1)
when /<SIMPLE WINDOW (\d+): (\d+)?>/i
adj = $1 == "1" ? 0 : 14
set_light("EV#{@id}", "window", $2 ? $2 : 255, 0, 0, 0, adj)
when /<FLASH LIGHT: (\d+)?>/i
set_light("EV#{@id}", "light", $1 ? $1 : 255, 30, 1)
when /<FLASH LAMP: (\d+)?>/i
set_light("EV#{@id}", "lamp", $1 ? $1 : 255, 30, 1)
when /<FLASH TORCH: (\d+)?>/i
set_light("EV#{@id}", "torch", $1 ? $1 : 255, 30, 1)
when /<FLASH WINDOW (\d+): (\d+)?>/i
adj = $1 == "1" ? 0 : 14
set_light("EV#{@id}", "window", $2 ? $2 : 255, 30, 1, 0, adj)
when /<CUSTOM LIGHT>([^><]*)<\/CUSTOM LIGHT>/im
info = $1.dup
n = info =~ /NAME: ["'](.*)["']/i ? $1.dup : ""
x = info =~ /POS X: (-?\d+)/i ? $1.to_i : 0
y = info =~ /POS Y: (-?\d+)/i ? $1.to_i : 0
s = info =~ /SPEED: (\d+)/i ? $1.to_i : 0
z = info =~ /ZOOM: (\d+)/i ? $1.to_f : 100.0
o = info =~ /OPACITY: (\d+)/i ? $1.to_i : 192
v = info =~ /VAR: (\d+)/i ? $1.to_i : 0
set_light("EV#{@id}", n, o, v, s, x, y, z)
when /<LANTERN: (\d+)?>/i
@lantern = ($1 ? $1.to_i : 255)
end
end
#--------------------------------------------------------------------------
# * New method: set_light
#--------------------------------------------------------------------------
def set_light(id, name, op = 255, v = 0, s = 0, x = 0, y = 0, z = 100)
value = [id, name, {:event => @id}, op, x, y, v, s, z].compact
$game_map.screen.lights[id] = $game_map.set_light(*value)
$game_map.screen.remove_light.delete(id)
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Alias method: comment_call
#--------------------------------------------------------------------------
alias :comment_call_ve_light_effects :comment_call
def comment_call
call_create_lights
call_change_shade_opacity
call_change_shade_tone
call_change_light_opacity
call_remove_light
comment_call_ve_light_effects
end
#--------------------------------------------------------------------------
# * New method: create_lights
#--------------------------------------------------------------------------
def call_create_lights
$game_map.setup_map_shade(note)
$game_map.setup_map_lights(:actor, note)
$game_map.setup_map_lights(:event, note)
$game_map.setup_map_lights(:vehicle, note)
$game_map.setup_map_lights(:map, note)
$game_map.setup_map_lantern(:actor, note)
$game_map.setup_map_lantern(:event, note)
$game_map.setup_map_lantern(:vehicle, note)
end
#--------------------------------------------------------------------------
# * New method: call_change_shade_opacity
#--------------------------------------------------------------------------
def call_change_shade_opacity
return if !$game_map.screen.shade.visible
note.scan(/<SHADE OPACITY:?((?: \d+,?){2})>/i) do |value|
if value.first =~ /(\d+)\s*,?\s*(\d+)?/i
$game_map.screen.shade.change_opacity($1.to_i, $2.to_i)
end
end
end
#--------------------------------------------------------------------------
# * New method: call_change_shade_tone
#--------------------------------------------------------------------------
def call_change_shade_tone
return if !$game_map.screen.shade.visible
note.scan(/<SHADE TONE:\s+((?:\d+,?\s*){4})>/i) do |value|
if value.first =~ /(\d+)\s*,?\s*(\d+)\s*,?\s*(\d+)\s*,?\s*(\d+)/i
$game_map.screen.shade.change_color($1.to_i, $2.to_i, $3.to_i, $4.to_i)
end
end
end
#--------------------------------------------------------------------------
# * New method: call_change_light_opacity
#--------------------------------------------------------------------------
def call_change_light_opacity
return if !$game_map.screen.shade.visible
note.scan(/<LIGHT OPACITY\s+(\w+):?((?: \d+,?){2})>/i) do |value|
light = $game_map.screen.lights[value.first]
if light && $2 =~ /(\d+)\s*,?\s*(\d+)?/i
light.change_opacity($1.to_i, $2.to_i)
end
end
end
#--------------------------------------------------------------------------
# * New method: call_remove_light
#--------------------------------------------------------------------------
def call_remove_light
note.scan(/<REMOVE LIGHT: (\d+)>/i) do |id|
$game_map.screen.remove_light.push(id.first.to_i)
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias method: initialize
#--------------------------------------------------------------------------
alias :initialize_ve_light_effects :initialize
def initialize
initialize_ve_light_effects
update_light
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_light_effects :update
def update
update_ve_light_effects
update_light
end
#--------------------------------------------------------------------------
# * Alias method: dispose
#--------------------------------------------------------------------------
alias :dispose_ve_light_effects :dispose
def dispose
dispose_ve_light_effects
dispose_light unless SceneManager.scene_is?(Scene_Map)
end
#--------------------------------------------------------------------------
# * New method: update_light
#--------------------------------------------------------------------------
def update_light
update_shade
update_effects
end
#--------------------------------------------------------------------------
# * New method: dispose_light
#--------------------------------------------------------------------------
def dispose_light
if @light_effect
@light_effect.dispose
@light_effect = nil
@screen_shade = nil
end
end
#--------------------------------------------------------------------------
# * New method: update_shade
#--------------------------------------------------------------------------
def update_shade
if !@light_effect && $game_map.screen.shade.visible
refresh_lights
elsif $game_map.screen.shade.visible && @light_effect
@light_effect.update
elsif @light_effect && !$game_map.screen.shade.visible
dispose_light
end
end
#--------------------------------------------------------------------------
# * New method: refresh_lights
#--------------------------------------------------------------------------
def refresh_lights
@light_effect.dispose if @light_effect
@screen_shade = $game_map.screen.shade
@light_effect = Sprite_Light.new(@screen_shade, @viewport2)
$game_map.event_list.each {|ev| ev.refresh_lights}
@light_effect.update
end
#--------------------------------------------------------------------------
# * New method: update_effects
#--------------------------------------------------------------------------
def update_effects
return if !@light_effect || $game_map.screen.lights.empty?
$game_map.screen.lights.keys.each {|key| create_light(key) }
$game_map.screen.remove_light.clear
end
#--------------------------------------------------------------------------
# * New method: create_light
#--------------------------------------------------------------------------
def create_light(key)
effect = @light_effect.lights[key]
return if remove_light(key)
return if effect && effect.light == $game_map.screen.lights[key]
@light_effect.create_light($game_map.screen.lights[key])
end
#--------------------------------------------------------------------------
# * New method: remove_light
#--------------------------------------------------------------------------
def remove_light(key)
return false if !$game_map.screen.remove_light.include?(key)
@light_effect.remove_light(key)
$game_map.screen.lights.delete(key)
return true
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias method: pre_transfer
#--------------------------------------------------------------------------
alias :pre_transfer_ve_light_effects :pre_transfer
def pre_transfer
pre_transfer_ve_light_effects
if $game_player.new_map_id != $game_map.map_id
@spriteset.dispose_light
$game_map.screen.clear_lights
end
end
end
#==============================================================================
# ** Game_ShadeEffect
#------------------------------------------------------------------------------
# This class handles the shade layer data
#==============================================================================
class Game_ShadeEffect
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :visible
attr_reader :color
attr_accessor :blend
attr_accessor :opacity
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize
init_opacity
init_color
end
#--------------------------------------------------------------------------
# * init_opacity
#--------------------------------------------------------------------------
def init_opacity
@visible = false
@opacity = 0
@opacity_target = 0
@opacity_duration = 0
end
#--------------------------------------------------------------------------
# * init_color
#--------------------------------------------------------------------------
def init_color
@blend = 0
@color = Color.new(0, 0, 0, 0)
@color_duration = 0
@color_target = Color.new(0, 0, 0, 0)
end
#--------------------------------------------------------------------------
# * show
#--------------------------------------------------------------------------
def show
@visible = true
end
#--------------------------------------------------------------------------
# * hide
#--------------------------------------------------------------------------
def hide
@visible = false
end
#--------------------------------------------------------------------------
# * set_color
#--------------------------------------------------------------------------
def set_color(r = 0, g = 0, b = 0)
@color = get_colors(r, g, b)
@color_target = @color.clone
end
#--------------------------------------------------------------------------
# * change_opacity
#--------------------------------------------------------------------------
def change_opacity(op, d)
@opacity_target = op
@opacity_duration = [d, 0].max
@opacity = @opacity_target if @opacity_duration == 0
end
#--------------------------------------------------------------------------
# * change_color
#--------------------------------------------------------------------------
def change_color(r, g, b, d)
@color_target = get_colors(r, g, b)
@color_duration = [d, 0].max
@color = @color_target.clone if @color_duration == 0
end
#--------------------------------------------------------------------------
# * get_colors
#--------------------------------------------------------------------------
def get_colors(r, g, b)
color = Color.new(255 - r, 255 - g, 255 - b, 255) if @blend == 2
color = Color.new(r, g, b, 255) if @blend != 2
color
end
#--------------------------------------------------------------------------
# * update
#--------------------------------------------------------------------------
def update
update_opacity
update_color
end
#--------------------------------------------------------------------------
# * update_opacity
#--------------------------------------------------------------------------
def update_opacity
return if @opacity_duration == 0
d = @opacity_duration
@opacity = (@opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
end
#--------------------------------------------------------------------------
# * update_color
#--------------------------------------------------------------------------
def update_color
return if @color_duration == 0
d = @color_duration
@color.red = (@color.red * (d - 1) + @color_target.red) / d
@color.green = (@color.green * (d - 1) + @color_target.green) / d
@color.blue = (@color.blue * (d - 1) + @color_target.blue) / d
@color_duration -= 1
end
end
#==============================================================================
# ** Game_LightEffect
#------------------------------------------------------------------------------
# This class handles the light sprite data
#==============================================================================
class Game_LightEffect
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :id
attr_accessor :name
attr_accessor :info
attr_accessor :opacity
attr_accessor :x
attr_accessor :y
attr_accessor :variance
attr_accessor :speed
attr_accessor :zoom
end
#==============================================================================
# ** Game_LightBitmap
#------------------------------------------------------------------------------
# This class handles the bitmpas of each light spot
#==============================================================================
class Game_LightBitmap
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :light
attr_reader :bitmap
attr_reader :opacity
attr_reader :x
attr_reader :y
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize(light)
@light = light
init_basic
update
end
#--------------------------------------------------------------------------
# * init_basic
#--------------------------------------------------------------------------
def init_basic
@bitmap = Cache.lights(@light.name)
@target = set_target
@opacity = @light.opacity
@speed = @light.speed
@variance = 0.0
@opacity_duration = 0
@opacity_target = 0
end
#--------------------------------------------------------------------------
# * width
#--------------------------------------------------------------------------
def width
@bitmap.width * @light.zoom / 100.0
end
#--------------------------------------------------------------------------
# * height
#--------------------------------------------------------------------------
def height
@bitmap.height * @light.zoom / 100.0
end
#--------------------------------------------------------------------------
# * update
#--------------------------------------------------------------------------
def update
update_position
update_opacity
update_variance
end
#--------------------------------------------------------------------------
# * update_position
#--------------------------------------------------------------------------
def update_position
@target.is_a?(Game_Character) ? character_position : map_position
end
#--------------------------------------------------------------------------
# * character_position
#--------------------------------------------------------------------------
def character_position
@x = $game_map.adjust_x(@target.real_x) * 32 - width / 2 + @light.x + 16
@y = $game_map.adjust_y(@target.real_y) * 32 - height / 2 + @light.y + 16
end
#--------------------------------------------------------------------------
# * map_position
#--------------------------------------------------------------------------
def map_position
@x = $game_map.adjust_x(@target[:x]) * 32 - width / 2 + @light.x + 16
@y = $game_map.adjust_y(@target[:y]) * 32 - height / 2 + @light.y + 16
end
#--------------------------------------------------------------------------
# * change_opacity
#--------------------------------------------------------------------------
def change_opacity(op, d)
@opacity_target = op
@opacity_duration = [d, 0].max
@light.opacity = @opacity_target if @opacity_duration == 0
end
#--------------------------------------------------------------------------
# * update_opacity
#--------------------------------------------------------------------------
def update_opacity
return if @opacity_duration == 0
d = @opacity_duration
@light.opacity = (@light.opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
end
#--------------------------------------------------------------------------
# * update_variance
#--------------------------------------------------------------------------
def update_variance
@variance += @speed
@speed *= -1 if @variance.abs > @light.variance.abs
@opacity = [[@light.opacity + @variance, 0].max, 255].min
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
@bitmap.dispose
end
#--------------------------------------------------------------------------
# * set_target
#--------------------------------------------------------------------------
def set_target
if @light.info.keys.include?(:actor)
target = $game_map.actors[@light.info[:actor]]
elsif @light.info.keys.include?(:event)
target = $game_map.events[@light.info[:event]]
elsif @light.info.keys.include?(:vehicle)
target = $game_map.vehicles[@light.info[:vehicle]]
else
target = @light.info
end
target
end
end
#==============================================================================
# ** Sprite_Light
#------------------------------------------------------------------------------
# This sprite is used to display the light effects
#==============================================================================
class Sprite_Light < Sprite_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :lights
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize(shade, viewport)
super(viewport)
@shade = shade
self.bitmap = Bitmap.new(Graphics.width, Graphics.height)
self.blend_type = @shade.blend
self.opacity = @shade.opacity
self.z = 100
@lights = {}
end
#--------------------------------------------------------------------------
# * map_x
#--------------------------------------------------------------------------
def map_x
$game_map.adjust_x($game_map.display_x)
end
#--------------------------------------------------------------------------
# * map_y
#--------------------------------------------------------------------------
def map_y
$game_map.adjust_y($game_map.display_y)
end
#--------------------------------------------------------------------------
# * update
#--------------------------------------------------------------------------
def update
super
self.ox = map_x
self.oy = map_y
update_opacity
update_lights
end
#--------------------------------------------------------------------------
# * update lights
#--------------------------------------------------------------------------
def update_lights
rect = Rect.new(map_x, map_y, Graphics.width, Graphics.height)
self.bitmap.fill_rect(rect, color)
draw_light_effects
end
#--------------------------------------------------------------------------
# * color
#--------------------------------------------------------------------------
def color
@shade.color
end
#--------------------------------------------------------------------------
# * draw_light_effects
#--------------------------------------------------------------------------
def draw_light_effects
@lights.values.each do |light|
light.update
next if !on_screen?(light)
draw_light(light)
end
end
#--------------------------------------------------------------------------
# * on_sceen?
#--------------------------------------------------------------------------
def on_screen?(light)
ax1 = light.x
ay1 = light.y
ax2 = light.x + light.width
ay2 = light.y + light.height
bx1 = map_x
by1 = map_y
bx2 = map_x + Graphics.width
by2 = map_y + Graphics.height
check1 = ax1.between?(bx1, bx2) || ax2.between?(bx1, bx2) ||
ax1 < bx1 && ax2 > bx2
check2 = ay1.between?(by1, by2) || ay2.between?(by1, by2) ||
ay1 < by1 && ay2 > by2
check1 && check2
end
#--------------------------------------------------------------------------
# * draw_light
#--------------------------------------------------------------------------
def draw_light(light)
img = light.bitmap
rect = Rect.new(light.x, light.y, light.width, light.height)
self.bitmap.stretch_blt(rect, img, img.rect, light.opacity)
end
#--------------------------------------------------------------------------
# * update_opacity
#--------------------------------------------------------------------------
def update_opacity
@shade.update
self.opacity = @shade.opacity
self.blend_type = @shade.blend
end
#--------------------------------------------------------------------------
# * create_light
#--------------------------------------------------------------------------
def create_light(light)
remove_light(light.id)
@lights[light.id] = Game_LightBitmap.new(light)
end
#--------------------------------------------------------------------------
# * remove_light
#--------------------------------------------------------------------------
def remove_light(id)
@lights.delete(id) if @lights[id]
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
super
@lights.values.each {|light| light.dispose unless light.bitmap.disposed? }
end
end
C'est un script de Victor, je te conseil de te rendre sur son site pour télécharger sa démo avec les images.
Et si tu te dis non je n'y vais pas voici un apperçu de ce que se script peut faire partielement car il existe de nombreuses autres chose à découvrire, le script est en anglais, je bosserais surement sur la trad' quand j'aurais le temps.
Le site de Victor et le post sur ce script
Bonne chance! =)
- foxhiveMembre
- Nombre de messages : 35
Distinction : aucune
Date d'inscription : 06/12/2010
Re: [Résolue]Light Effects Version Ultime
Mar 3 Jan 2012 - 19:09
Ouahou Je ne savait pas qu'un tel script exister déjà pour Ace ! Cependant il est vrai qu'il est encore a ses début :3
J'ai hâte de voir ta traduction la dessus car il me semble très complet ! et complexe lol
Je te remercie de ton aide surtout que c'est grâce a toi qu'on a une démo qui facilite la compréhension
Merci encore !
J'ai hâte de voir ta traduction la dessus car il me semble très complet ! et complexe lol
Je te remercie de ton aide surtout que c'est grâce a toi qu'on a une démo qui facilite la compréhension
Merci encore !
- UltimaSasukeMembre
- Nombre de messages : 88
Age : 28
Localisation : France, 05
Distinction : aucune
Date d'inscription : 27/07/2011
Re: [Résolue]Light Effects Version Ultime
Mar 3 Jan 2012 - 19:30
Oui ^^" Je lui ais fait la demande car ce n'est pas facile au début de premier abord mais après on comprend mieux, en tout cas de rien. ^^
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|