#============================================================================== # Composite Characters / Visual Equipment # Version 1.0 # Author: modern algebra (rmrk.net) # Date: July 5, 2008 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Instructions: # # Place this script in between Materials and Main in the Script Editor # # To set a graphic for an armor or weapon, all you need to do is place this # code in the Notes box of the item: # # \CG[<Name of Character Set>, <index in character set>, <hue>] # # If you leave out index, it defaults to 0 and if you leave out hue, it also # defaults to 0. You can put more than one graphic to an armor or weapon and # they will stack, first one on bottom last one on top. # # Setting up an Event is similar - all you need to do is place a comment at # the very beginning of the event and put in the same code to generate a # composite character set for the event. Same rules apply, and remember, you # can stack character sets. # # EXAMPLES: # \cg[Actor1, 2] # Character Set = Actor1 : index = 2 : hue = 0 # \CG[Evil] # Character Set = Evil : index = 0 : hue = 0 # \cG[Actor2, 3, 50] # Character Set = Actor2 : index = 3 : hue = 50 # # Setting up your Actors is similar - see line 151 for details. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Compatibility: # # Unfortunately, I did need to overwrite some methods for this script, and # as such there are likely to be compatibility problems. I know that my # Extra Movement Frames Script certainly will not work with this script, and # any script that tampers with the way a character set is drawn will also # likely encounter problems. Now, this is not to say that any script that # draws a character set will be incompatible - as long as that scripter uses # the draw_actor_graphic method of Window_Base it should work fine - it is # only scripts that change the way a character set is drawn that will cause # problems. Also, I tamper with the load_gamedata method of Window_SaveFile, # and so if another script overwrites that then there will again be # compatibility issues. If you find a script that seems to cause problems, # please post at the topic at rmrk.net and I will try my best to assist you. #============================================================================== #============================================================================== # *** module Cache #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new method - composite_character #============================================================================== module Cache #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Composite Character # char_array : An array holding the names of all parts of a graphic #-------------------------------------------------------------------------- # Composes a single character bitmap out of all the ones given. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def self.composite_character (char_array) @cache = {} if @cache == nil # Blank bitmap if there is nothing in the array. @cache[char_array] = Bitmap.new (32, 32) if char_array.empty? # If not in the cache if !@cache.include? (char_array) || @cache[char_array].disposed? # Create a template bitmap bitmap = Bitmap.new (32, 32) # Add in all other graphics char_array.each { |i| name, index, hue = i[0], i[1], i[2] # Bypass self.character in order to allow for setting hue bmp = load_bitmap ("Graphics/Characters/", name, hue) sign = name[/^[\!\$]./] # Get the width and height of the single character if sign != nil && sign.include? ('$') wdth, hght = bmp.width, bmp.width else wdth = bmp.width / 4 hght = bmp.height / 2 end # Expand bitmap if necessary if bitmap.width < wdth || bitmap.height < hght # Recreate bitmap temp_bmp = bitmap.dup bitmap = Bitmap.new ([temp_bmp.width, wdth].max, [temp_bmp.height, hght].max) bitmap.blt (0, 0, temp_bmp, temp_bmp.rect) temp_bmp.dispose end # Draw new character graphic onto bitmap src_rect = Rect.new ((index%4)*wdth, (index/4)*hght, wdth, hght) bitmap.blt (0, 0, bmp, src_rect) } @cache[char_array] = bitmap end return @cache[char_array] end end #============================================================================== # ** RPG::BaseItem #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new method - character_graphics #============================================================================== class RPG::BaseItem #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Character Graphics #-------------------------------------------------------------------------- # Retrieves Character Graphics from Note Field #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def character_graphics graphics = [] # Retrieve Note Field text = self.note.dup while text.sub! (/\\cg\[([\w\s]+),*\s*(\d*),*\s*(\d*)\]/i) { '' } != nil graphics.push ([$1.to_s, $2.to_i, $3.to_i]) end return graphics end end #============================================================================== # ** Game_Actor #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new method - composite_character # aliased_method - initialize, change_equip #============================================================================== class Game_Actor #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_writer :composite_character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initalization #------------------------------------------------------------------------- # Initializes stacked_character variable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_arclght_vsual_equip_init_4t6h initialize def initialize (id) # Run Original Method modalg_arclght_vsual_equip_init_4t6h (id) @composite_character = [] case @actor_id #--------------------------------------------------------------------- # EDITABLE REGION #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| # An actor will automatically have whatever you set in the database # as a bottom layer for him, but if you need to have other character # sets piled on top, then put them in this format: # # when <actor_id> # @composite_character.push (['graphic_name', index, hue]) # *for as many graphics as you want - first ones drawn first. If you # want to know what each is, see the Instructions in the header. #---------------------------------------------------------------------- when 99 # 1st Actor # Create Hair Sprite @composite_character.push (['', 1, 100]) when 99 # 3rd Actor # Create skin sprite with different hue @composite_character.push (['', 0, 20]) # Create Hair Sprites @composite_character.push (['', 2, 75]) @composite_character.push (['', 3, 75]) #---------------------------------------------------------------------- # END EDITABLE REGION #---------------------------------------------------------------------- end @composite_character.each { |i| i[1] = 0 if i[1] == nil i[2] = 0 if i[2] == nil } @composite_character.unshift ([@character_name, @character_index, 0]) if @character_name != '' end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Get Composite Character #-------------------------------------------------------------------------- # Returns Graphic Array for the actor #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def composite_character armor_graphics = [] weapon_graphics = [] # Body Armor, then Helmet, then Shield, then all others dup_armors = armors.dup for i in 0 ...2 j = 2 - i armor_graphics += dup_armors[j].character_graphics if dup_armors[j] != nil dup_armors.delete_at (j) end # If there is some multi-equip script, will get accessories and rest in order dup_armors.each { |armr| armor_graphics += armr.character_graphics if armr != nil } weapons.each { |wpn| weapon_graphics += wpn.character_graphics if wpn != nil } return @composite_character + armor_graphics + weapon_graphics end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Change Equipment (designate object) #-------------------------------------------------------------------------- # Refresh Player to demonstrate armor cg #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_rfrsh_plyer_eq_chnge_8mj2 change_equip def change_equip(equip_type, item, test = false) modalg_rfrsh_plyer_eq_chnge_8mj2 (equip_type, item, test) $game_player.refresh end end #============================================================================== # ** Game_Party #============================================================================== class Game_Party attr_reader :actors end #============================================================================== # ** Game_Character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new instance variable - composite_character #============================================================================== class Game_Character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :composite_character end #============================================================================== # ** Game_Event #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # aliased methods - setup #============================================================================== class Game_Event #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Event page setup #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias malgbr_rclgh_req_comp_char_setup_5msk setup def setup(new_page) malgbr_rclgh_req_comp_char_setup_5msk (new_page) # Create Composite Character @composite_character = [] @composite_character.push ([@character_name, @character_index, 0]) unless @character_name.nil? # If page == nil, return return if @page == nil # Retrieve first line comments comments = [] @page.list.each { |i| i.code == 108 || i.code == 408 ? comments.push (i) : break } # Evaluate comments for \CG codes comments.each { |i| text = i.parameters[0].dup while text.sub! (/\\cg\[([\w\s]+),*\s*(\d*),*\s*(\d*)\]/i) { '' } != nil @composite_character.push ([$1.to_s, $2.to_i, $3.to_i]) end } end end #============================================================================== # ** Game_Player #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # aliased method - refresh #============================================================================== class Game_Player #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Refresh #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias mdalg_arc_comp_character_find_rfrsh_8kwi refresh def refresh mdalg_arc_comp_character_find_rfrsh_8kwi return if $game_party.members.empty? @composite_character = $game_party.members[0].composite_character end end #============================================================================== # ** Sprite_Character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # aliased method - update_bitmap #============================================================================== class Sprite_Character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Transfer Origin Bitmap #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modern_alg_arclightrequest_visual_equip_bmp_update update_bitmap def update_bitmap if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_index != @character.character_index || @composite_character != @character.composite_character @tile_id = @character.tile_id @character_name = @character.character_name @character_index = 0 @composite_character = @character.composite_character if @tile_id > 0 sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32; sy = @tile_id % 256 / 8 % 16 * 32; self.bitmap = tileset_bitmap(@tile_id) self.src_rect.set(sx, sy, 32, 32) self.ox = 16 self.oy = 32 else if @composite_character == nil # Regular Character Picture self.bitmap = Cache.character(@character_name) sign = @character_name[/^[\!\$]./] if sign != nil and sign.include?('$') @cw = bitmap.width / 3 @ch = bitmap.height / 4 else @cw = bitmap.width / 12 @ch = bitmap.height / 8 end else self.bitmap = Cache.composite_character(@composite_character) @cw = self.bitmap.width / 3 @ch = self.bitmap.height / 4 end self.ox = @cw / 2 self.oy = @ch end end end #-------------------------------------------------------------------------- # * Update Transfer Origin Rectangle #-------------------------------------------------------------------------- def update_src_rect if @tile_id == 0 index = 0 pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end end end #============================================================================== # ** Window_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # overwritten method - draw_character_graphic #============================================================================== class Window_Base #-------------------------------------------------------------------------- # * Draw Actor Walking Graphic # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_actor_graphic(actor, x, y) bitmap = Cache.composite_character (actor.composite_character) cw = bitmap.width / 3 ch = bitmap.height / 4 rect = Rect.new (cw, 0, cw, ch) self.contents.blt (x - (cw / 2), y - ch, bitmap, rect) end end #============================================================================== # ** Window_SaveFile #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # overwritten_methods - load_gamedata, #============================================================================== class Window_SaveFile < Window_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Load Partial Game Data #-------------------------------------------------------------------------- # The same as the original method with the exception that it gets all of # that file's data up to @game_party - necessary for composite graphics #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def load_gamedata @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime begin @characters = Marshal.load(file) @frame_count = Marshal.load(file) @last_bgm = Marshal.load(file) @last_bgs = Marshal.load(file) @game_system = Marshal.load(file) @game_message = Marshal.load(file) @game_switches = Marshal.load(file) @game_variables = Marshal.load(file) # Bypass self-switches @game_self_switches = Marshal.load(file) # Bypass Actors @game_actors = Marshal.load(file) # Get Party @game_party = Marshal.load (file) @total_sec = @frame_count / Graphics.frame_rate rescue @file_exist = false ensure file.close end end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Draw Party Characters # x : Draw spot X coordinate # y : Draw spot Y coordinate #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def draw_party_characters(x, y) for i in 0...@game_party.actors.size draw_actor_graphic (@game_actors[@game_party.actors[i]], x + i * 48, y) end end endaiutatemi non riesco a far funzionare sto script, questo script serve a far cambiare grafica durante il cambio equip, ma ho il prblema che cambia la grafica agli alleati come vuole lui, quindi aiuto
#1 Inviato 16 September 2012 - 11:27 AM
#2 Inviato 16 September 2012 - 13:11 PM
Au revoir.
#3 Inviato 16 September 2012 - 18:02 PM
1. Titoli indicativi del problema interno.
2. No linguaggi sms (non qui ma altrove fatto... )
3. Spiegarsi per bene, usare punteggiatura e dopo aver scritto il topic rileggerlo, correggere gli errori e vedere se c'è tutto il necessario per capire.
4. Spiegare cosa hai fatto per far funzionare lo script, i parametri che hai dato, cosa vuoi ottenere...
Mmmmh
Lo script qui sembra specificare per bene che devi mettere nome, indice e cose del genere, tu cosa hai messo? ^ ^# \CG[<Name of Character Set>, <index in character set>, <hue>]
#
# If you leave out index, it defaults to 0 and if you leave out hue, it also
# defaults to 0. You can put more than one graphic to an armor or weapon and
# they will stack, first one on bottom last one on top.
(\_/)
(^ ^) <----coniglietto rosso, me!
(> <)
Il mio Tumblr dove seguire i miei progetti, i progetti della Reverie : : Project ^ ^
disponibile su Google Play, qui i dettagli! ^ ^
completo! Giocabile online, qui i dettagli! ^ ^
REVERIE : : RENDEZVOUS (In allenamento per apprendere le buone arti prima di cominciarlo per bene ^ ^) Trovate i dettagli qui insieme alla mia intervista (non utilizzerò più rpgmaker) ^ ^
#4 Inviato 16 September 2012 - 18:26 PM
#5 Inviato 18 September 2012 - 19:52 PM
poi metti uno spoiler la prossima volta perchè mi sono rotto il dito sulla rotellina del mouse
Modificato da Seanbb, 18 September 2012 - 19:52 PM.
#7 Inviato 19 September 2012 - 19:34 PM
Modificato da Seanbb, 19 September 2012 - 19:34 PM.
#8 Inviato 19 September 2012 - 20:14 PM
#9 Inviato 19 September 2012 - 23:09 PM
My adventure game
Little Briar Rose
Altri progetti: Oh! I'm Getting Taller! / Il pifferaio di Hamelin
I miei Fumetti: Folletto Vs Nenè / A.s.D. / A.s.D.2
Un sogno nel cassetto...
Citaziò!
Scheda di Zuppo Del'Oquie
#11 Inviato 20 September 2012 - 13:15 PM
(\_/)
(^ ^) <----coniglietto rosso, me!
(> <)
Il mio Tumblr dove seguire i miei progetti, i progetti della Reverie : : Project ^ ^
disponibile su Google Play, qui i dettagli! ^ ^
completo! Giocabile online, qui i dettagli! ^ ^
REVERIE : : RENDEZVOUS (In allenamento per apprendere le buone arti prima di cominciarlo per bene ^ ^) Trovate i dettagli qui insieme alla mia intervista (non utilizzerò più rpgmaker) ^ ^