Composite Characters/Visual Equipment, by modern algebra |
|
|
|
|
Sep 4 2008, 10:33 PM
|

GFX Pro

Group: +Gold Member
Posts: 409
Type: Artist
RM Skill: Skilled

|
Composite Characters/Visual EquipmentVersion: 1.0 Author: modern algebra Date: July 5, 2008 Description:This script allows you to create character sets from multiple character sheets, layering them on top of each other. It also allows you to set character graphics to armors and weapons, and these character sets will be layered on top of the character, thus making it a Visual Equipment script as well. FeaturesEasy configuration Hundreds of unique characters can be made from a limited set of resources. Allows you to set hue for character sheets, meaning each resource can have hundreds of distinct colours. Allows any weapon or armor to have any number of character sets stacked onto the character upon equip. Events and Actors can also be set up so that they are composed of multiple character sets Screenshots All character sets seen composed of this one character sheet, with all resources taken from the character generator here: http://www.famitsu.com/freegame/tool/chibi/index1.html CODE #============================================================================== # 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.height 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 1 # 1st Actor # Create Hair Sprite @composite_character.push (['VisEquipSample', 1, 100]) when 3 # 3rd Actor # Create skin sprite with different hue @composite_character.push (['VisEquipSample', 0, 20]) # Create Hair Sprites @composite_character.push (['VisEquipSample', 2, 75]) @composite_character.push (['VisEquipSample', 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 end Creditmodern algebra -Writing the script Known Compatibility IssuesAny scripts that play around with the way character sets are drawn will undoubtedly have some problems with this script. If you encounter any problems, please post the error and the script that is causing the problem and I will see if I can make them compatible. Does not work with Dash Animation Does not work with Extra Movement Frames *NOTE* I did not make this script, I'm bringing this over from another forum *NOTE*DEMO File included in Attachments
__________________________
THE SAVAGE NYMPH Note: this is Magdreamer, I'm using my real name for my forum name now.
|
|
|
|
|
|
|
Posts in this topic
Magdreamer Composite Characters/Visual Equipment Sep 4 2008, 10:33 PM shadow_fox22 I'm going to check it out in a second but woul... Sep 5 2008, 03:34 AM Magdreamer I'd guess, not properly. Probably only the fir... Sep 5 2008, 03:56 AM modern algebra Well, assuming you are referring to Diedrupo's... Sep 9 2008, 06:28 AM Zelda Freak QUOTE (Magdreamer @ Sep 4 2008, 10:33 PM)... Oct 10 2008, 11:37 AM lucifer1101 hey all was just wondering if this has anything li... Oct 22 2008, 04:37 PM killcon I get a error on
CODEreturn @composite_character ... Jan 10 2009, 07:35 PM BigEd781 Add this line above that one:
CODE@composite_char... Jan 10 2009, 07:55 PM killcon now when i put the armor or helm on my player wont... Jan 10 2009, 08:35 PM Ocsecnarf Good Job! Jan 11 2009, 04:13 AM nevious i get a lovely error tellin me stack level too dee... Jan 29 2009, 01:24 AM Shiryo Works fine for me: you just have to spend some tim... Dec 26 2009, 07:29 PM Sparrowsmith hmmmmm
useful for my game me thinks... Thank you ... Dec 26 2009, 07:57 PM Shiryo I solved all my previews problems, ut I still have... Dec 29 2009, 04:14 PM chuckeddy im having a litle issue with integrating the catip... May 3 2011, 01:57 PM Kread-EX Sorry, I'm going to close this because it... May 4 2011, 01:30 AM
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|