Jump to content
Rpg²S Forum
  • 0

Problema con script di effetti luce e di riflessione


Kirbfile
 Share

Question

Ho riscontrato un problema con l'effetto luci di questo script (http://www.rpg2s.net/forum/index.php/topic/15115-kylocks-light-effects-vx-ace-unofficial-porting/ ) praticamente quando cambio mappa le luci della mappa precedente rimangono ancora presenti nella mappa nuova circa per un secondo.

Facendo delle prove ho scoperto che era un conflitto fra lo script delle luci e questo script per effetti di riflessione ( http://galvs-scripts.com/galvs-character-effects/ ).

Il problema è che tutti e due gli script sono molto essenziali per il mio progetto e vorrei capire se è possibile risolvere il problema senza eliminare gli script

Edited by Kirbfile
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Risposta senza basi sperimentali, ma vedo che entrambi gli script definiscono nella classe Spriteset_Map un nuovo metodo dispose_effects:

 

Clyde

 

def dispose_effects
	for effect in @light_effects
		effect.light.dispose
	end
	@light_effects = []
end

 


Galv

 

def dispose_effects
    @reflect_sprites.each {|s| s.dispose}
    @shadow_sprites.each {|s| s.dispose}
    @mirror_sprites.each {|s| s.dispose}
    @icon_sprites.each {|s| s.dispose}
end
 

 

 

 

Quello che compare per secondo sovrascrive il primo impedendo il corretto funzionamento (quindi invertire l'ordine dei due script non risolve niente).
Prova ad aggiungere questa pezza sotto agli altri due script:

 

class Spriteset_Map
	def dispose_effects
		#clyde
		for effect in @light_effects
		  effect.light.dispose
		end
		@light_effects = []
		#galv
		@reflect_sprites.each {|s| s.dispose}
		@shadow_sprites.each {|s| s.dispose}
		@mirror_sprites.each {|s| s.dispose}
		@icon_sprites.each {|s| s.dispose}
	 end
end # Spriteset_Map 

 

 

 

EDIT: (offtopic) ogni volta che leggo luci e riflessioni mi viene da leggere il topic XD

Edited by BuddyTroller
Link to comment
Share on other sites

  • 0

La pezza che avevo scritto era sicuramente sbagliata e l'ho modificata. Dovresti aggiungerla come nuovo script, sotto gli altri due.

Non ho rpg maker quindi non posso fare alcuna prova, per cui proviamo con una cosa differente. Ho modificato direttamente lo script di kylock per cambiare nome al metodo, così che i due non vadano in conflitto:

 

#==============================================================================
# WARNING: EDITED BY BUDDYTROLLER, USE AT YOUR OWN RISK!
#==============================================================================
# AUTOLIGHT 1.3.1 UNOFFICIAL PORTING VX ACE
# 12.27.2008
#------------------------------------------------------------------------------
# SCRIPT BY: Kylock
# PORTING BY: I don't want to be credited.
#
#==============================================================================
# INSTRUCTIONS
#
# Remember, you must have the file "le.png" in your "Graphics\Pictures" folder!
# If you're missing the file follow this link:
# http://imageshack.us/photo/my-images/189/81598086.png/
#
# To make an event glow, choose the desired event and comment with the applied
# term. If you want Light 1, comment "LIGHT 1".
#==============================================================================
# ? Change Log
#------------------------------------------------------------------------------
# 1.0 - Original Release
# 1.1 - New light modes added: LIGHT2, TORCHLIT 1, TORCHLIT 2
#	 - Changed sprite blend mode to ADD
#	 - Fire-based lights are now red in color
# 1.2 - Bug fixed with looping maps and lights displaying above message boxes
# 1.3 - More bugfixes
#==============================================================================
# ? Light Modes
#------------------------------------------------------------------------------
# LIGHT 1 - Steady white light. (Small)
# FIREPIT - Flicker.
# LIGHT 2 - Steady white light. (Large)
# LIGHT 3 - Steady white light.
# TORCHLIT 1 - Flicker. (Heavy)
# TORCHLIT 2 - Flicker. (Light)
#==============================================================================

module LES

  #The switch used to turn lights ON/OFF
  #If the Switch is ON the lights turn OFF
  #If the Switch is OFF the lights turn ON
  SWITCH = 30

end

#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map

  alias les_spriteset_map_initalize initialize

  def initialize
	initialize_effects
	les_spriteset_map_initalize
	update
  end

  def initialize_effects
	@light_effects = []
	setup_lights
  end

  alias les_spriteset_map_dispose dispose
  def dispose
	les_spriteset_map_dispose
	kyl_dispose_effects
  end

  def kyl_dispose_effects
	for effect in @light_effects
	  effect.light.dispose
	end
	@light_effects = []
  end

  alias les_spriteset_map_update update
  def update
	les_spriteset_map_update
	update_light_effects
  end

  def setup_lights
	for event in $game_map.events.values
	  next if event.list == nil
	  for i in 0...event.list.size
		if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT 1"]
		  type = "LIGHT 1"
		  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 == ["FIREPIT"]
		  type = "FIREPIT"
		  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 2"]
		  type = "LIGHT 2"
		  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 == ["LIGHT 3"]
		  type = "LIGHT 3"
		  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 == ["TORCHLIT 1"]
		  type = "TORCHLIT 1"
		  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 == ["TORCHLIT 2"]
		  type = "TORCHLIT 2"
		  light_effects = Light_Effect.new(event,type)
		  light_effects.light.zoom_x = 6
		  light_effects.light.zoom_y = 6
		  light_effects.light.opacity = 150
		  @light_effects.push(light_effects)
		end
	  end
	end
	for effect in @light_effects
	  case effect.type
	  when "LIGHT 1"
		effect.light.x = effect.event.screen_x - 64
		effect.light.y = effect.event.screen_y - 86
		effect.light.blend_type = 1
	  when "FIREPIT"
		effect.light.x = effect.event.screen_x - 96 + rand(6) - 3
		effect.light.y = effect.event.screen_y - 118 + rand(6) - 3
		effect.light.tone = Tone.new(255,-100,-255, 0)
		effect.light.blend_type = 1
	  when "LIGHT 2"
		effect.light.x = effect.event.screen_x - 32
		effect.light.y = effect.event.screen_y - 54
		effect.light.blend_type = 1
	  when "LIGHT 3"
		effect.light.x = effect.event.screen_x - 182 - 20
		effect.light.y = effect.event.screen_y - 214
		effect.light.blend_type = 1
	  when "TORCHLIT 1"
		effect.light.x = effect.event.screen_x - 182 - 20 + rand(20) - 10
		effect.light.y = effect.event.screen_y - 214 + rand(20) - 10
		effect.light.tone = Tone.new(255,-100,-255, 0)
		effect.light.blend_type = 1
	  when "TORCHLIT 2"
		effect.light.x = effect.event.screen_x - 182 - 20
		effect.light.y = effect.event.screen_y - 214
		effect.light.tone = Tone.new(255,-100,-255, 0)
		effect.light.blend_type = 1
	  end
	end
  end #def setup_lights

  def update_light_effects
	if $game_switches[LES::SWITCH]
	  for effect in @light_effects
		next if effect.type == "FIREPIT" || effect.type == "TORCHLIT 1"
		effect.light.visible = false
	  end
	else
	  for effect in @light_effects
		next if effect.type == "FIREPIT" || effect.type == "TORCHLIT 2"
		effect.light.visible = true
	  end
	end
	for effect in @light_effects
	  case effect.type
	  when "LIGHT 1"
		effect.light.x = effect.event.screen_x - 64
		effect.light.y = effect.event.screen_y - 86
	  when "FIREPIT"
		effect.light.x = effect.event.screen_x - 96 + rand(6) - 3
		effect.light.y = effect.event.screen_y - 118 + rand(6) - 3
		effect.light.opacity = rand(10) + 90
	  when "LIGHT 2"
		effect.light.x = effect.event.screen_x - 32
		effect.light.y = effect.event.screen_y - 54
	  when "LIGHT 3"
		effect.light.x = effect.event.screen_x - 182 - 20
		effect.light.y = effect.event.screen_y - 214
	  when "TORCHLIT 1"
		effect.light.x = effect.event.screen_x - 182 - 20 + rand(20) - 10
		effect.light.y = effect.event.screen_y - 214 + rand(20) - 10
		effect.light.opacity = rand(30) + 70
	  when "TORCHLIT 2"
		effect.light.x = effect.event.screen_x - 182 - 20
		effect.light.y = effect.event.screen_y - 214
		effect.light.opacity = rand(10) + 90
	  end
	end
  end #def update_light_effects

end #class Spriteset_Map

#==============================================================================
# ■ Light_Effect
#==============================================================================
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 = 190
	@event = event
	@type = type
  end

end #class Light_Effect

#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map

  alias les_pre_transfer pre_transfer
  def pre_transfer
	les_pre_transfer
	@spriteset.kyl_dispose_effects
  end

  alias les_post_transfer post_transfer
  def post_transfer
	@spriteset.initialize_effects
	les_post_transfer
  end

end #Scene_Map

#==============================================================================
# END OF FILE
#==============================================================================

 



EDIT: Aggiunto il warning a inizio script per avvertire che non si tratta della versione originale, ormai questi dettagli me li perdo!

Edited by BuddyTroller
Link to comment
Share on other sites

  • 0

Mentre rispondevi ho modificato il messaggio, prova la nuova soluzione.

EDIT:
Il conflitto potrebbe essere anche più grosso di quello che vedo, onestamente non avevo mai visto lo script di Galv e sono molto arrugginito per capirci qualcosa ad occhio.

Edited by BuddyTroller
Link to comment
Share on other sites

  • 0

Ho semplicemente rinominato dispose_effects in kyl_dispose_effects (compare in 3 punti dello script).
Onestamente mi stupisce che Kylock non abbia dato un nome meno comune al metodo, o forse c'entra lo zampino cricetoso di clyde.

OT: Quant'è bello sperimentare con script esistenti e capire come funzionano <3 Se capisci le basi puoi divertirti a personalizzare e integrare fra di loro i vari script. Ogni volta che iniziavo qualche folle progetto il primo passo è sempre stato quello di scegliere tutti gli script più interessanti, eliminare il superfluo e farli interagire dove c'erano i presupposti. Partivo con 100+ script, infinite righe di codice e poi ne rimaneva solo uno bello condensato :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...