[XP] Visual Equipment for Blizz-ABS

Started by Blizzard, February 01, 2010, 09:39:36 am

Previous topic - Next topic

Blizzard

Your configuration says that "EXCLUDE_ARMORS" is "[4, 2, 3, 1, 0]" and not "[]".
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Eternal

I have a question. Why use your visual equipment instead of another one? I mean it seems like a great one, don't get me wrong, in fact it's the best I've ever seen, but why do we need to use this one if we're using Blizz-ABS? Why does it require Blizz-ABS? I trust you highly as a scripter, but why it this the only one working with Blizz-ABS?

I'd also like to say that it looks in every way perfect. You've done it again :P You should

Blizzard

Because Blizz-ABS already has a good sprite handling system. This code enhances Blizz-ABS rather than having completely independent (and therefore duplicate) code.

I'm not making a different script because I have retired from RMXP. *points to sig*
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Eternal


arialks

no matter what i do it keeps giving me non stop errors, it says i need higher version, even do I'm using the highest version S:
anyhow, is there a change you could upload a demo? :S I know it's a simple scripit and you dont need a demo for it, but it helps me figure out what is the problem when I see how it's suppose to be..

Blizzard

If you keep getting version errors, then you haven't updated Blizz-ABS properly.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

arialks

I'm asking for Demo because I dont really understand the Instructions.
my english isn't really good for reading stuff like that o-o..
and I'm trying to play around witht he scripit... but I have no idea where and what..
I made a folder in characters named Equipment, I put a sprite "a1"
I just see alot of clodes that just get me confused S:..
this is why I need a demo so I could just look into the scripit when Equips already made in it
so I'll know how to make Equips.. I just need to see how it looks like when it has Equips made already.

theone15247

I'm having the same problem that DreadWing had with my shields no showing up. 
My shield Id's are 1-4 and I have them all in my characters file called "Equipment.a2, Equipment.a3, ....."

Script:
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Visual Equipment for Blizz-ABS by Blizzard
# Version: 1.0
# Type: Blizz-ABS Add-on
# Date: 1.2.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#  This script is to be distributed under the same terms and conditions like
#  the script it was created for: Blizz-ABS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
#   This script must be placed below Blizz-ABS and requires Blizz-ABS v2.57 or
#   higher to work properly. It will display equipment on the map. All sprites
#   are placed in the Graphics/Characters folder. Also keep in mind that using
#   this script can cause additional lag due to additional sprite display.
#   
#   
# Configuration:
#   
#   EXCLUDE_WEAPONS - weapons that should not be drawn
#   EXCLUDE_ARMORS  - armors that should not be drawn
#   DRAW_ORDER      - drawing order from first to last sprite (0 for weapon;
#                     1, 2, 3 and 4 for armor kinds)
#   PREFIX_WEAPON   - prefix for each spriteset file for weapons (can include
#                     a full path)
#   PREFIX_ARMOR    - prefix for each spriteset file for armors (can include
#                     a full path)
#   ACTOR_UNIQUE    - allows separate equipment files for every single actor
#   
#   
# Notes:
#   
#   - The default file naming convention is:
#     
#       WPREFIX + WID          - weapon files
#       APREFIX + AID          - armor files
#       WPREFIX + WID + SUFFIX - weapon action files
#       APREFIX + AID + SUFFIX - armor action files
#     
#       WPREFIX - by default "Equipment/w", but it can be changed
#       APREFIX - by default "Equipment/a", but it can be changed
#       WID     - weapon ID
#       AID     - armor ID
#       SUFFIX  - action suffix (i.e. _atk1, _skl, etc.)
#     
#     examples:
#       
#       Equipment/w3.png      - weapon ID 3
#       Equipment/a41.png     - armor ID 41
#       Equipment/w1_atk1.png - weapon ID 1, attack type 1
#       Equipment/a76_skl.png - armor ID 1, skill use
#     
#     If you are using the ACTOR_UNIQUE option, then the naming convention are:
#     
#       WPREFIX + BID + SEPARATOR + WID          - weapon files
#       APREFIX + BID + SEPARATOR + AID          - armor files
#       WPREFIX + BID + SEPARATOR + WID + SUFFIX - weapon action files
#       APREFIX + BID + SEPARATOR + AID + SUFFIX - armor action files
#       
#       BID       - actor ID
#       SEPARATOR - the character _ (underscore)
#     
#     examples:
#       
#       Equipment/w4_2.png      - actor ID 4, weapon ID 2
#       Equipment/a1_22.png     - actor ID 1, armor ID 22
#       Equipment/w77_7_def.png - actor ID 77, weapon ID 7, defending
#       Equipment/a3_8_atk5.png - actor ID 3, armor ID 8, attack type 5
#     
#     The default prefixes can be changed in the configuration, but the other
#     parts are fixed.
#     
#   - If you are not using the ACTOR_UNIQUE option and Blizz-ABS's action
#     animation frames other than the default, you have to adjust the action
#     animation frames. In this case all actors will use the same equipment
#     files for display and the files' frame number has to match the animation
#     frames number for every actor which also means that all actors need to
#     have the same number of action sprites for the various actions. i.e. All
#     actors have to have the same number of frames for attack type 1, the same
#     number of frames for attack type 2, the same number of frames for skill
#     use, the same number of frames for defending, etc.
#     
#   - Keep in mind that the dimensions of the spriteset and the equipment
#     sprite should match. i.e. If the actor spriteset is 192x192 pixels, then
#     the equipment for that sprite has to be 192x192 pixels as well. If you
#     have actors that use different spritesets among each other
#     
#   - You can disable / enable Visual Equipment for specific characters by
#     using a Call Script event command with the following code:
#       
#       $game_actors[ID].visual_equipment = true/false
#       $game_party.actors[POS].visual_equipment = true/false
#     
#     ID  - the actor's ID in the database
#     POS - the actor's position in the party (STARTS FROM 0, not 1!)
#     
#   - You can disable / enable Visual Equipment globally by using a Call Script
#     event command with the following code:
#       
#       $game_system.visual_equipment = true/false
#     
#   
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

if !$BlizzABS || BlizzABS::VERSION < 2.57
  raise 'ERROR: The "Visual Equipment" plugin requires Blizz-ABS 2.57 or higher.'
end
 
#==============================================================================
# module BlizzCFG
#==============================================================================

module BlizzCFG
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # START Configuration
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  EXCLUDE_WEAPONS = [1, 25, 33]
  EXCLUDE_ARMORS = [46]
  DRAW_ORDER = [1, 0, 2, 3, 4]
  PREFIX_WEAPON = 'Equipment.w'
  PREFIX_ARMOR = 'Equipment.a'
  ACTOR_UNIQUE = false
 
  def self.equipment_offset(character_name)
    case character_name
    #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    # START Equipment Sprite Offset
    #   
    #   Here you can define the equipment Y offset in pixels. This can be used
    #   to adjust the equipment sprites' position for smaller or tall
    #   character spritesets. Configure which spritesets have an offset:
    #   
    #     when NAME then return OFFSET
    #   
    #   NAME   - spriteset name
    #   OFFSET - offset in pixels
    #   
    #   Make sure you don't mispell the filenames.
    #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when '011-Lancer03' then return -1
    #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    # END Equipment Sprite Offset
    #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 0
  end

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # END Configuration
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  $blizzabs_visual_equipment = 1.0
 
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_accessor :visual_equipment
 
  alias init_blizzabsve_later initialize
  def initialize
    init_blizzabsve_later
    @visual_equipment = true
  end
 
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor

  attr_accessor :visual_equipment
 
  alias init_blizzabsve_later initialize
  def initialize(actor_id)
    init_blizzabsve_later(actor_id)
    @visual_equipment = true
  end
 
  def weapons
    return (self.weapon_ids - BlizzCFG::EXCLUDE_WEAPONS -
  • ) if defined?(G7_MS_MOD)
        return ([@weapon_id] - BlizzCFG::EXCLUDE_WEAPONS -
  • )
      end
     
      def armors
        return (self.armor_ids - BlizzCFG::EXCLUDE_ARMORS -
  • ) if defined?(G7_MS_MOD)
        return ([@armor1_id, @armor2_id, @armor3_id, @armor4_id] -
            BlizzCFG::EXCLUDE_ARMORS -
  • )
      end
     
    end

    #==============================================================================
    # Sprite_CharacterEquipment
    #==============================================================================

    class Sprite_CharacterEquipment < RPG::Sprite
     
      def initialize(viewport, character)
        super(viewport)
        @character = character
        update
      end
     
      def update
        super
        weapons = @character.battler.weapons
        armors = @character.battler.armors
        if @weapons != weapons || @armors != armors ||
            @character_name != @character.character_name
          @weapons = weapons
          @armors = armors
          @character_name = @character.character_name
          self.create_bitmap
          @cw = self.bitmap.width / @character.pattern_size
          @ch = bitmap.height / 4
          self.ox = @cw / 2
          self.oy = @ch
          self.src_rect.x = @character.pattern * @cw
          self.src_rect.width = @cw
        end
        self.visible = !@character.transparent
        sx = @character.pattern * @cw
        sy = (@character.direction - 2) / 2 * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
        self.x = @character.screen_x
        self.y = @character.screen_y
        self.z = @character.screen_z(@ch)
        self.opacity = @character.opacity
        self.blend_type = @character.blend_type
        self.bush_depth = @character.bush_depth
      end
     
      def create_bitmap
        self.bitmap.dispose if self.bitmap != nil
        bitmap = RPG::Cache.character(@character_name, 0)
        self.bitmap = Bitmap.new(bitmap.width, bitmap.height)
        equipment = []
        a_id = (BlizzCFG::ACTOR_UNIQUE ? "#{@character.battler.id}_" : '')
        BlizzCFG::DRAW_ORDER.each {|index|
            if index == 0
              @weapons.each {|id|
                  equipment.push("#{BlizzCFG::PREFIX_WEAPON}#{a_id}#{id}")}
            else
              @armors.each {|id|
                  if $data_armors[id].kind == index
                    equipment.push("#{BlizzCFG::PREFIX_ARMOR}#{a_id}#{id}")
                  end}
            end}
        sprite_name = @character.character_name.sub(
            @character.character_name_org) {''}
        y = BlizzCFG.equipment_offset(@character.character_name_org)
        equipment.each {|name|
            b = RPG::Cache.character("#{name}#{sprite_name}", 0)
            self.bitmap.blt(0, y, b, Rect.new(0, 0, b.width, b.height))}
      end
     
    end

    #==============================================================================
    # Control_Sprite_Character
    #==============================================================================

    class Control_Sprite_Character
     
      alias update_blizzabsve_later update
      def update
        update_blizzabsve_later
        return if !@character.is_a?(Map_Actor)
        if $game_system.visual_equipment && @character.valid? &&
            @character.battler.visual_equipment && @sprite != nil &&
            (@character.battler.weapons.size > 0 ||
            @character.battler.armors.size > 0)
          if @equipment == nil
            @equipment = Sprite_CharacterEquipment.new(@viewport, @character)
          else
            @equipment.update
          end
        elsif @equipment != nil
          @equipment.dispose if !@equipment.disposed?
          @equipment = nil
        end
      end
     
      alias dispose_blizzabsve_later dispose
      def dispose
        dispose_blizzabsve_later
        @equipment.dispose unless @equipment == nil || @equipment.disposed?
        @equipment = nil
      end
     
    end

Blizzard

This isn't a fix, it's a hack. Worse, it's a hack that causes a bug which will turn all shields into helms in-game.

I fixed the problem in the script in the first post properly.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

mroedesigns

Is there / would there need to be (I'm assuming yes) a controller for use with RMX-OS? I saw you talking about compatibility with it earlier, but wasn't sure. And I didn't see anything in the script database.


mroedesigns

Alright thanks. I wasn't sure if the original blizz-ABS controller handled this, or if it needed a separate one.

Soloman

June 13, 2011, 03:38:58 am #32 Last Edit: June 13, 2011, 03:55:37 am by Soloman
Is it possible to make multiple DRAW_ORDER arrays that are dependent on the direction that the character is facing? So if the character is facing down, then the weapon is drawn last (behind the actor), but if he is facing up, then the weapon is drawn first (on top of the actor). Something along these lines, I would think:
if @direction = 2
   then DRAW_ORDER = [3, 2, 1, 0]
 else DRAW_ORDER = [0, 3, 2, 1]
   end

This forum is very neat, by the way. I've followed Blizz-Abs for a while now, and just the sheer number of possibilities that it opened up in RPG maker inspired me to buy it and start up again. Blizzard should be given a medal and a congressionally funded retirement plan for the amount of work he's put into this ABS.




Sometimes I like to fill up my tub up with water, turn the shower on and pretend like I'm in a submarine that's just been hit.

Blizzard

June 13, 2011, 04:13:16 am #33 Last Edit: June 13, 2011, 09:55:40 am by Blizzard
A retirement plan would be awesome. ._.
Yes, it's possible. I can quickly edit the script to allow that. I'll do it when I get home from work.

EDIT: There you go. It's a simple but necessary feature so I quickly added it. I may have retired from RMXP, but I hate unfinished things.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Soloman

June 13, 2011, 03:48:48 pm #34 Last Edit: June 13, 2011, 04:40:34 pm by Soloman
Thank you! I see what you did now. That is much simpler than any idea I would have come up with. It's exactly what I needed, although the direction of the equipment is now always facing left, while the actor moves normally under it. I don't see what's wrong with the script, though.

I saw that you had retired from RMXP. Probably because you were tired the endless masses asking you questions about your scripts...
Sometimes I like to fill up my tub up with water, turn the shower on and pretend like I'm in a submarine that's just been hit.

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Soloman

June 14, 2011, 03:00:55 pm #36 Last Edit: June 14, 2011, 03:05:57 pm by Soloman
I didn't know that they used "my bad" in the U.K. It fixed the error, but now the equipment completely disappears when the character is facing down...

Sometimes I like to fill up my tub up with water, turn the shower on and pretend like I'm in a submarine that's just been hit.

Blizzard

June 14, 2011, 03:56:14 pm #37 Last Edit: June 14, 2011, 04:02:27 pm by Blizzard
Ah, shit, then I didn't fix it properly. :/ I'll take another look at it.
Also, I'm not from the UK. :P

EDIT: Alright, this time I checked everything properly. It worked for me just fine so you shouldn't have any more problems with it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Soloman

June 14, 2011, 04:27:25 pm #38 Last Edit: June 14, 2011, 04:47:22 pm by Soloman
Really? The version dates in the script are European style. And yes, it works perfectly. One last question: Is there an index number for the actor?
Sometimes I like to fill up my tub up with water, turn the shower on and pretend like I'm in a submarine that's just been hit.

Blizzard

I'm actually not American either. xD I'm actually Croatian, English is just my third language.

What do you mean by index number? There is an actor ID (in the database) and there is party member index. Which one do you need?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.