[XP] Tons of Add-ons

Started by Blizzard, January 09, 2008, 08:50:47 am

Previous topic - Next topic

Heretic86

General Suggestion

How about something to allow large sprites to render as Flat?  You know this graphic?




...and it always seems to do this:




Make it render like this!




I managed to get a version of that to work great, but it is deeply embedded in another script and fully redefines screen_z instead of aliasing, which I think can cause what I did to be incompatible with other scripts.  Im also just curious to see how someone else might pull it off...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

dragon997

I know it's in there, that why i post here... ;p i just need only simple multi-attack script
when I cut them out from this script its doesn't work as i said im a beginner and I no have idea how i can fix that problem :( som1 can make just multi-hit for standard rpg xp? I was stuck in my project :(
i want add moore hits to my skills/spells (like omnislash in FF7)
pls help

sry for bad "inglish"

Boba Fett Link

@dragon997 You can't extract the script. Each separate script in TONS can be turned on or off. Just turn off all the ones you don't want.
This post will self-destruct in 30 seconds.

dragon997

April 16, 2012, 03:57:46 pm #823 Last Edit: April 16, 2012, 04:05:24 pm by ForeverZer0
can u say how :D ? Im rly newbie :( i only want turn on multi attack :P
i dont understand instruction :

Spoiler: ShowHide
Set up the following constants to configure the script:
#  
#   WEAPON_RANDOM - add any weapon IDs here and separate them with commas to
#                   make those specific weapons attack another random target
#                   for each other hit than the first
#   SKILL_RANDOM  - add any skill IDs here and separate them with commas to
#                   make those specific skills attack another random target
#                   for each other hit than the first
#   ITEM_RANDOM   - add any item IDs here and separate them with commas to
#                   make those specific items attack another random target
#                   for each other hit than the first
#   ENEMY_RANDOM  - add any enemy IDs here and separate them with commas to
#                   make those specific enemies attack another random target
#                   for each other hit than the first
#  
#   Further there are 4 configurations. Configuration 1 is for weapons,
#   Configuration 2 is for skills, Configuration 3 is for items and
#   Configuration 3 is for normal enemy attacks. Use following template to set
#   up how many hits should be done:
#
#     when ID then return HITS
#
#   ID   - ID of weapon, skill, item or enemy, depending on the configuration
#          number
#   HITS - number of hits


(its in 2nd script around 4000 lane)

can i get simple explain how turn on or how cfg it? :C when i change any numers here :

# START Basic Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 WEAPON_RANDOM = [1, 5]
 SKILL_RANDOM = [57]
 ITEM_RANDOM = [12]
 ENEMY_RANDOM = []
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Basic Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 def self.weapon_hits(id)
   case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 1
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   when 1 then return 3
   when 2 then return 4
   when 3 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 1
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   end
   return 1
 end
 
 def self.skill_hits(id)
   case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   when 57 then return 3
   when 58 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   end
   return 1
 end
 
 def self.item_hits(id)
   case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 3
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   when 12 then return 3
   when 13 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 3
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   end
   return 1
 end
 
 def self.enemy_hits(id)
   case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 4
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   when 1 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 4
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Then i get error :/

what its mean when 1 then 2 ? when 12 then 13? what is that numer ?
its ID skill or what ? plz help


ForeverZer0

April 16, 2012, 04:05:45 pm #824 Last Edit: April 16, 2012, 04:13:05 pm by ForeverZer0
Spoilers and code tags are your friend.

EDIT:
Also, here's just that script properly ripped from the other ones.
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Multi-Hit by Blizzard
# Version: 1.51b
# Type: Weapon/Skill/Enemy Enhancement
# Date: 12.8.2007
# Date 1.3b: 23.2.2008
# Date 1.4b: 23.7.2008
# Date 1.5b: 19.10.2008
# Date 1.51b: 6.10.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   95% compatible with SDK 1.x. 70% compatible with SDK 2.x. Might be
#   incompatible with exotic skills and/or CBS-es. Compatible with CRLS 5.1b or
#   higher.
#
#
# Explanation:
#
#   This add-on will allow that skills, weapons and enemies attack more than
#   once.
#
# new in v1.3b:
#   - now you can define weapons/skills/enemies which's other attacks will
#     target a random target instead of the originally chosen target
#   - now beta
#
# new in v1.4b:
#   - better compatibility with SP Cost Mod
#   - improved coding
#   
# new in v1.5b:
#   - added Multi-Hit items
#   
#   
# Configuration:
#   
#   Set up the following constants to configure the script:
#   
#   WEAPON_RANDOM - add any weapon IDs here and separate them with commas to
#                   make those specific weapons attack another random target
#                   for each other hit than the first
#   SKILL_RANDOM  - add any skill IDs here and separate them with commas to
#                   make those specific skills attack another random target
#                   for each other hit than the first
#   ITEM_RANDOM   - add any item IDs here and separate them with commas to
#                   make those specific items attack another random target
#                   for each other hit than the first
#   ENEMY_RANDOM  - add any enemy IDs here and separate them with commas to
#                   make those specific enemies attack another random target
#                   for each other hit than the first
#   
#   Further there are 4 configurations. Configuration 1 is for weapons,
#   Configuration 2 is for skills, Configuration 3 is for items and
#   Configuration 3 is for normal enemy attacks. Use following template to set
#   up how many hits should be done:
#
#     when ID then return HITS
#
#   ID   - ID of weapon, skill, item or enemy, depending on the configuration
#          number
#   HITS - number of hits
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#==============================================================================
# module BlizzCFG
#==============================================================================

module BlizzCFG
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Basic Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  WEAPON_RANDOM = [1, 2]
  SKILL_RANDOM = [57]
  ITEM_RANDOM = [12]
  ENEMY_RANDOM = []
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Basic Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  def self.weapon_hits(id)
    case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 1
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 1 then return 3
    when 2 then return 4
    when 3 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 1
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 1
  end
 
  def self.skill_hits(id)
    case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 57 then return 3
    when 58 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 1
  end
 
  def self.item_hits(id)
    case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 3
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 12 then return 3
    when 13 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 3
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 1
  end
 
  def self.enemy_hits(id)
    case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 4
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 1 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 4
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 1
  end
 
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle
 
  alias update_phase4_step1_multi_hit_later update_phase4_step1
  def update_phase4_step1(battler = nil)
    if battler != nil
      update_phase4_step1_multi_hit_later(battler)
      return
    end
    update_phase4_step1_multi_hit_later
    @repeat = [1, 1, 0]
    return unless @active_battler != nil
    if @active_battler.current_action.kind == 0
      if @active_battler.current_action.basic == 0
        if @active_battler.is_a?(Game_Actor)
          hits = BlizzCFG.weapon_hits(@active_battler.weapon_id)
        elsif @active_battler.is_a?(Game_Enemy)
          hits = BlizzCFG.enemy_hits(@active_battler.id)
        end
        @repeat = [hits, hits, 2]
      end
    elsif @active_battler.current_action.kind == 1
      @repeat[2] = 3
    elsif @active_battler.current_action.kind == 2
      @repeat[2] = 4
    end
  end
 
  alias update_phase4_step2_multi_hit_later update_phase4_step2
  def update_phase4_step2(battler = nil)
    if battler != nil
      update_phase4_step2_multi_hit_later(battler)
      return
    end
    update_phase4_step2_multi_hit_later
    if @phase4_step != 1
      if @repeat[2] == 3
        hits = BlizzCFG.skill_hits(@skill.id)
        @repeat = [hits, hits+1, 4]
      elsif @repeat[2] == 4
        hits = BlizzCFG.item_hits(@item.id)
        @repeat = [hits, hits+1, 4]
      end
    end
  end
 
  alias update_phase4_step5_multi_hit_later update_phase4_step5
  def update_phase4_step5(battler = nil)
    if battler != nil
      update_phase4_step5_multi_hit_later(battler)
      return
    end
    update_phase4_step5_multi_hit_later
    if @active_battler.current_action.kind == 1
      if BlizzCFG::SKILL_RANDOM.include?(@skill.id)
        if @active_battler.is_a?(Game_Actor)
          @active_battler.current_action.decide_random_target_for_actor
        elsif @active_battler.is_a?(Game_Enemy)
          @active_battler.current_action.decide_random_target_for_enemy
        end
      end
    elsif @active_battler.current_action.kind == 2
      if BlizzCFG::ITEM_RANDOM.include?(@item.id)
        if @active_battler.is_a?(Game_Actor)
          @active_battler.current_action.decide_random_target_for_actor
        elsif @active_battler.is_a?(Game_Enemy)
          @active_battler.current_action.decide_random_target_for_enemy
        end
      end
    elsif @active_battler.is_a?(Game_Actor)
      if BlizzCFG::WEAPON_RANDOM.include?(@active_battler.weapon_id)
        @active_battler.current_action.decide_random_target_for_actor
      end
    elsif @active_battler.is_a?(Game_Enemy)
      if BlizzCFG::ENEMY_RANDOM.include?(@active_battler.id)
        @active_battler.current_action.decide_random_target_for_enemy
      end
    end
    @phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0
    @repeat[0] -= 1
  end
 
  alias make_skill_action_result_multi_hit_later make_skill_action_result
  def make_skill_action_result(battler = nil, plus_id = nil)
    if battler != nil
      if plus_id != nil
        make_skill_action_result_multi_hit_later(battler, plus_id)
      else
        make_skill_action_result_multi_hit_later(battler)
      end
      return
    end
    make_skill_action_result_multi_hit_later
    if @repeat[2] > 3
      @active_battler.sp += @skill.sp_cost
      @status_window.refresh
    end
  end
end
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

dragon997

as i said its not woring without all Scripts together :/ i need explain how to configurate it :/ where put ID skill where number of hits etc :C dont know why its not work fine for me i need simple example

ForeverZer0

The script comes with a basic example.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

April 20, 2012, 09:28:52 pm #827 Last Edit: April 21, 2012, 05:16:22 pm by Heretic86
How would you guys feel about including my small contribution?

I dont think there are any scripts out there that do what this does at this time.  Basically, you know how the Ground Portal Sprites dont render quite right?  The script I put together adds the ability to make them render as flat on the ground.  By default, RMXP "thinks" that any event is standing up.  Minor oversight as 99% of the Events are standing up, but for things that need to look like they are laying flat on the ground that takes up more than 32 pixels, it makes those Events stand up straight as well.  So if you have a large event sprite, maybe used for something like a Flying Carpet, or a Boat, or something like that, the characters need to render on TOP without assigning "Always On Top" to the characters.

Ground Portal is the best one I can think of as an example, and I think the only example included in RMXP that has this issue.  Kind of like a reverse way to do "Always On Top", as the "Flat" property makes them render "Always On Bottom", if that makes any sense.

Flat Sprites

Spoiler: ShowHide
# ----------------------------------------------------------------------------
#          FLAT SPRITES by Heretic
# ----------------------------------------------------------------------------
# Flat-Z allows you to make large sprites look like they are laying flat
# on the ground.
#
# --- EVENT NAME RELATED---
#
# EV001\z_flat
# EV001\z_add[32]
#
# To make an Event always render as flat, change its Name to "event001\z_flat"
#
# To make an Event always have an adjusted Z-Index, name it "ev\z_add[Int]"
#
# --- SCRIPTED EVENT RELATED ---
# To change a Standing Sprite to render as flat, use a Move Route Script
#  for that event "set_flat".  Useful for when changing graphics of Events
#
# To specify a higher or lower Z-Index, use the optional parameter:
#  such as "event001\z_flat[32]"
#
# To Reset a Sprite that is flat to stand up
#  use a Move Route Script "reset_z"
#  "reset_z" will check the name again for special name related Z-Index commands
#
# To make a Manual Adjustment to a sprites Z-Index, use set_z(Int)
#  and I recommend incrementing the Int by 32 either way.
#
# To clear any special Z-Index Related properties, run a script
#  "clear_z"
#
# NOTE \z_add[0] will be treated as a request for a FLAT SPRITE
#
# NOTE 2:  Special Properties like "\foo" in an Events Name appear
#  to NOT COPY AND PASTE CORRECTLY at all times in RMXP Editor
#  if you COPY AND PASTE an Event.

DISPLAY_DEVELOPER_ERRORS = true

class Game_Event < Game_Character

  unless self.method_defined?('flat_sprite_initialize')
    alias flat_sprite_initialize :initialize   
  end   
 
  def initialize(map_id, event, *args)
    check_flat_sprites(event)
    flat_sprite_initialize(map_id, event, *args)   
  end
 
  #----------------------------------------------------------------------------
  #  * Check Each Event for a \z_flat  or \z_add flag
  #----------------------------------------------------------------------------
 
  def check_flat_sprites(event)
    # Options
    #
    # "Name\z_flat"
    # "Name\z_add[32]" for characters higher than 32 pixels high

    event.name.gsub(/\\z_flat\[([-]?[0-9]+)\]|\\z_flat/i) {@z_flat = $1.to_i }
    return if @z_flat   
   
    event.name.gsub(/\\z_add\[([-]?[0-9]+)\]/i) {@z_add = $1.to_i + 32 }
    return if @z_add
  end 
 
  #----------------------------------------------------------------------------
  # * Sets a sprite to render as Flat by saying its screen_z is 0 by default
  #----------------------------------------------------------------------------
 
  def set_flat
    # Always Render as Flat regardless of size
    @z_flat = 0
    @z_add = nil
  end

  #----------------------------------------------------------------------------
  # * Sets the Z-Index of an Event via a Script instead of a Name
  #----------------------------------------------------------------------------

  def set_z(new_z)
    # If Error Reporting is On and not a Release Game
    if $DEBUG and DISPLAY_DEVELOPER_ERRORS
      if new_z.nil?
        print "Warning!  \"set_z(int)\" expects an \"Argument\" of \"int\"!\n",
              "\"(int)\" should be a Number!\n\n",
              "I.E. set_z(32) or set_z(-64)" 
        return
      elsif not new_z.is_a? Numeric
        print "Warning!  \"", new_z, "\" is not an Number!\n",
              "set_flat(int) expects \"int\" to be a Number!\n\n",
              "I.E. set_z(32) or set_z(-65)"
        return
      end
    end 
   
    # Expects new_z as an Argument.  It adds whatever that value is to new number
    if new_z != 0
      # Manual Adjustment to Z-Index
      @z_add = new_z + 32
      @z_flat = nil
    else
      # Always Render as Flat regardless of size
      @z_flat = 0
      @z_add = nil
    end
     
  end

  #----------------------------------------------------------------------------
  # * Resets the Z-Index of an Event via a Script to get Name Properties
  #----------------------------------------------------------------------------
 
  def reset_z
    # Resets Z-Index adjusting Properties
    @z_flat = nil
    @z_add = nil
    # Reset this Event's Z-Index to be Name Based
    @event.name.gsub(/\\z_flat\[([-]?[0-9]+)\]|\\z_flat/i) {@z_flat = $1.to_i }
    return if @z_flat   
   
    @event.name.gsub(/\\z_add\[([-]?[0-9]+)\]/i) {@z_add = $1.to_i }
    @z_add + 32 if @z_add
    return if @z_add
  end

  #----------------------------------------------------------------------------
  # * Clears all Z-Index Related Properties.  Will reset when a map is reloaded
  #----------------------------------------------------------------------------
 
  def clear_z
    @z_flat = nil
    @z_add = nil
  end
 
  #----------------------------------------------------------------------------
  # * Redefine screen_z for Flat Sprites
  #----------------------------------------------------------------------------

  unless method_defined?(:caterpillar_screen_z)
    # Alias the Original
    alias :flat_sprite_screen_z :screen_z
  end   
 
  def screen_z(height = 0)
    if @always_on_top
      return 999
    end

    # This adds the feature of adjusting an events Z-Index on the fly
   
    # \z_flat[int]
    # Compensates for Sprite Height in Pixels
    if not @z_flat.nil? and !@always_on_top
      # Consider the Sprites Size and Adjust for it, check nil for no graphic
      flat_height = (height != 0 and not height.nil?) ? height : 0
      # Calculate new Z-Index with Adjustments     
      adjusted_z = (@real_y - $game_map.display_y + 3) / 4 - flat_height
      # Make sure those Characters stay Visible, < 0 they Disappear!
      adjusted_z = 0 if adjusted_z < 0
      # Return the Adjusted Z-Index Value
      return adjusted_z
    end

    # \z_add[int]
    # Allows for an adjusted Z-Index which may not always be flat
    if not @z_add.nil? and !@always_on_top
      # Consider the Sprites Size and Adjust for it, check nil for no graphic
      flat_height = (height.nil? and not height != 0) ? height : 0
      # Calculate new Z-Index with Adjustments
      adjusted_z = (@real_y - $game_map.display_y + 3) / 4 + flat_height + @z_add + 32 + ((flat_height > 32) ? 31 : 0)   
      # Make sure those Characters stay Visible, < 0 they Disappear!
      adjusted_z = 0 if adjusted_z < 0
      # Return the Adjusted Z-Index Value
      return adjusted_z
    end
   
    # If Normal Tile - Dont Adjust again!
    if @tile_id > 0
      # Add tile priority * 32
      return (@real_y - $game_map.display_y + 3) / 4 + 32 + $game_map.priorities[@tile_id] * 32
    # If character
    else
      # Calculates Original Screen-Z adjusted for Party Size so Party is Always On Top
      return (@real_y - $game_map.display_y + 3) / 4 + 32 + ((height > 32) ? 31 : 0)   
    end
  end 
end

#-----------------------
#  Interpreter
#-----------------------

# I use this section to let the developer know if they are using the script
# incorrectly, usually by calling a command from the wrong Script Window
# since there are two of them.
#
# Edit Event -> Scripts and Edit Event -> Set Move Route -> Scripts are DIFFERENT!

class Interpreter
  # DEBUG Msg here indicates Mapper needs to call from the right window, however...
  def reset_z(*args)
    if $DEBUG and DISPLAY_DEVELOPER_ERRORS == true
      print "Please call \"reset_z\" from\n",
            "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
            "instead of \n\"Edit Event\" -> Scripts Window"
    end
  end   
 
  # DEBUG Msg here indicates Mapper needs to call from the right window, however...
  def set_flat(*args)
    if $DEBUG and DISPLAY_DEVELOPER_ERRORS == true
      print "Please call \"set_flat\" from\n",
            "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
            "instead of \n\"Edit Event\" -> Scripts Window"
    end
  end   
 
  # DEBUG Msg here indicates Mapper needs to call from the right window, however...
  def set_z(*args)
    if $DEBUG and DISPLAY_DEVELOPER_ERRORS == true
      print "Please call \"set_z(", args, ")\" from\n",
            "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
            "instead of \n\"Edit Event\" -> Scripts Window"
    end
  end   

  # DEBUG Msg here indicates Mapper needs to call from the right window, however...
  def clear_z(*args) #args prevents any args from being used
    if $DEBUG and DISPLAY_DEVELOPER_ERRORS == true
      print "Please call \"clear_z\" from\n",
            "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
            "instead of \n\"Edit Event\" -> Scripts Window"
    end
  end     
end


Edit:  Pulled out unneeded code.

Not sure what I would need to do to allow this to be incorporated, but I can provide a more comprehensive demo if you guys want...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Blizzard

While a demo is not necessary for the final product, I'd appreciate it if you could make a simple demo so I can test and optimize the script. Then you can test it once more to see if everything is working right as it was working previously and I will add the final pieces of code to make it work fully with the rest of Tons.
I haven't looked through the script yet so I don't know how exactly it works, but it's possible that I might change a few small things (e.g. make it apply to sprites that have some text added in their event name) to make it easier to use.
Of course, only if all of that is fine with you. You will retain all the credit for your script. I will only add a small section on top that says "optimized by Blizzard for Tons of Add-ons" like I did with all the other scripts that were not made by me.

The funny thing is that I have some code in CP that I wrote myself that does exactly the same thing. xD All I have to do is add "TileY" to an event name and the sprite would be rendered flat.

That reminds me, I was supposed to add a few scripts by G_G there as well. ._. Maybe I should also take a look at some of the bugs people have reported. ._.;
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.

Heretic86

I'll put together a simple demo.  I might work on it tomorrow, getting kind of tired tonight...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Blizzard

Just a generic grass covered map with 2-3 example events is totally enough. Take your time.
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.

Heretic86

Ok, Demo, cleaned up code and pulled out some extra stuff that wasnt needed.

http://www.775.net/~heretic/downloads/rmxp/FlatSpritesDemo.exe

I tested heavily.  One thing I did was to make some Super Large Sprites, and they work as expected.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Honestly, that seem overly complicated.
All you really need is a couple simple methods. Here's what I mean, though it could be refined a bit more...

Spoiler: ShowHide
class Game_Event
 
  attr_accessor :custom_z
 
  alias flat_sprite_init initialize
  def initialize(*args)
    flat_sprite_init(*args)
    if @event.name =~ /\\[Zz]\[([0-9]+)\]/
      @custom_z = $1.to_i
    end
  end
end

class Game_Character
 
  alias flat_sprite_z screen_z
  def screen_z(height)
    return @custom_z != nil ? @custom_z : flat_sprite_z(height)
  end
end

class Interpreter
 
  def reset_z(id = @event_id)
    character = id == -1 ? $game_player : $game_map.events[@event_id]
    character.custom_z = nil
  end
 
  def set_z(z_value, id = @event_id)
    character = id == -1 ? $game_player : $game_map.events[@event_id]
    character.custom_z = z_value
  end
end
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Leave the optimization up to me, F0. ;)
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.

ForeverZer0

It wasn't an "optimization", I was showing a different way of handling it that is simpler.
I had no plans on submitting that code for this script.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

My "optimization" would have probably come down to a piece of code very similar to yours.
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.

Blizzard

April 22, 2012, 06:21:08 am #836 Last Edit: April 22, 2012, 06:44:29 am by Blizzard
Here is the final script.

Spoiler: ShowHide
# ----------------------------------------------------------------------------
#          FLAT SPRITES by Heretic
# ----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# - code reviewed, optimized, integrated into Tons of Add-ons, freed from
#   potential bugs and beta tested by Blizzard
# - this add-on is part of Tons of Add-ons with full permission of the original
#   author(s)
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Flat Sprites allows you to make large sprites look like they are laying flat
# on the ground.
#
# --- EVENT NAME RELATED---
#
# EV001\z_flat
# EV001\z_flat[32]
# EV001\z_add[32]
#
# To make an Event always have an adjusted Z-Index, add to its name "\z_add[Int]".
#
# To make an Event always render as flat, add to its nane "\z_flat".
#
# To make an Event always render as flat, but with an altered Z-Index,
# add to its name "\z_flat[Int]" (this is an equivalent to using \z_flat and
# \z_add[Int] together).
#
# --- SCRIPTED EVENT RELATED ---
#
# To change a Standing Sprite to render as flat, use a Move Route Script
# for that event "set_flat".  Useful for when changing graphics of Events.
#
# To specify a higher or lower Z-Index, use the optional parameter:
# such as "set_flat(Int)".
#
# To Reset a Sprite that is flat to stand up use a Move Route Script "reset_z".
# "reset_z" will check the name again for special name related Z-Index commands.
#
# To make a Manual Adjustment to a sprites Z-Index, use set_z(Int)
# and I recommend incrementing the Int by 32 either way.
#
# To clear any special Z-Index Related properties, run a script "clear_z".
#
# NOTE \z_add[0] will NOT be treated as a request for a FLAT SPRITE.
#
# NOTE 2:  Special Properties like "\foo" in an Events Name appear
#  to NOT COPY AND PASTE CORRECTLY at all times in RMXP Editor
#  if you COPY AND PASTE an Event.
# ----------------------------------------------------------------------------

DISPLAY_DEVELOPER_ERRORS = true

#==============================================================================
#  Game_Event
#==============================================================================

class Game_Event

 #----------------------------------------------------------------------------
 # * Redefine initialize for new variables
 #----------------------------------------------------------------------------
 
 unless self.method_defined?(:flat_sprite_initialize)
   alias :flat_sprite_initialize :initialize    
 end
 
 def initialize(map_id, event, *args)
   @z_flat = false
   @z_add = 0
   check_flat_sprites(event)
   flat_sprite_initialize(map_id, event, *args)    
 end
 
 #----------------------------------------------------------------------------
 # * Check Each Event for a \z_flat and \z_add flag
 #----------------------------------------------------------------------------
 
 def check_flat_sprites(event)
   # Initialize
   @z_flag = false
   @z_add = 0
   # Check z_flat and use z_add if necessary
   @z_flat = (event.name.clone.sub!(/\\z_flat\[[-]{0,1}(\d+)\]/i) {@z_add = $1.to_i} != nil)
   # If z_flat was not defined with optional z
   if !@z_flat
     # Check default z_flat
     @z_flat = (event.name.match(/\\z_flat/i) != nil)
     # Check default z_add
     event.name.sub(/\\z_add\[[-]{0,1}(\d+)\]/i) {@z_add = $1.to_i}
   end
 end
 
 #----------------------------------------------------------------------------
 # * Sets a sprite to render as Flat by saying its screen_z is 0 by default
 #----------------------------------------------------------------------------
 
 def set_flat(new_z = nil)
   # Always Render as Flat regardless of size
   @z_flat = true
   # Set optional Z-Index override
   @z_add = new_z if new_z.is_a?(Numeric)
 end

 #----------------------------------------------------------------------------
 # * Sets the Z-Index of an Event via a Script instead of a Name
 #----------------------------------------------------------------------------

 def set_z(new_z)
   # If Error Reporting is On and not a Release Game
   if $DEBUG && DISPLAY_DEVELOPER_ERRORS
     if !new_z.is_a?(Numeric)
       p "Warning!  \"#{new_z}\" is not an Number!\n",
         "set_flat(int) expects \"int\" to be a Number!\n\n",
         "I.E. set_z(32) or set_z(-65)"
       return
     end
   end  
   # Expects new_z as an Argument.  It adds whatever that value is to new number
   if new_z != 0
     # Manual Adjustment to Z-Index
     @z_flat = false
     @z_add = new_z
   else
     # Always Render as Flat regardless of size
     set_flat
   end
 end

 #----------------------------------------------------------------------------
 # * Resets the Z-Index of an Event via a Script to get Name Properties
 #----------------------------------------------------------------------------
 
 def reset_z
   check_flat_sprites(@event)
 end

 #----------------------------------------------------------------------------
 # * Clears all Z-Index Related Properties.  Will reset when a map is reloaded
 #----------------------------------------------------------------------------
 
 def clear_z
   @z_flat = false
   @z_add = 0
 end
 
 #----------------------------------------------------------------------------
 # * Redefine screen_z for Flat Sprites
 #----------------------------------------------------------------------------

 unless self.method_defined?(:flat_sprite_screen_z)
   alias :flat_sprite_screen_z :screen_z
 end
 
 def screen_z(height = 0)
   # Just skip the whole thing if always-on-top is on
   return flat_sprite_screen_z(height) if @always_on_top
   # If using z_flag or z_add
   if @z_flat || @z_add != 0
     # Consider the Sprites Size and Adjust for it, check nil for no graphic
     height = (height != 0 && height != nil) ? height : 0
   end
   # If using z_flag or z_add
   z = flat_sprite_screen_z(height)
   # Add flat correction value if using z_flat
   z -= 32 + height if @z_flat
   # Add Z-Index adjustment
   z += @z_add
   # Make sure those Characters stay Visible, < 0 they Disappear!
   return (z >= 0 ? z : 0)
 end
 
end

#==============================================================================
#  Interpreter
#==============================================================================
# I use this section to let the developer know if they are using the script
# incorrectly, usually by calling a command from the wrong Script Window
# since there are two of them.
#
# Edit Event -> Scripts and Edit Event -> Set Move Route -> Scripts are DIFFERENT!
#==============================================================================

class Interpreter
 
 # DEBUG Msg here indicates Mapper needs to call from the right window, however...
 def reset_z(*args)
   if $DEBUG && DISPLAY_DEVELOPER_ERRORS
     p "Please call \"reset_z\" from\n",
       "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
       "instead of \n\"Edit Event\" -> Scripts Window"
   end
 end
 
 # DEBUG Msg here indicates Mapper needs to call from the right window, however...
 def set_flat(*args)
   if $DEBUG && DISPLAY_DEVELOPER_ERRORS
     p "Please call \"set_flat\" from\n",
       "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
       "instead of \n\"Edit Event\" -> Scripts Window"
   end
 end
 
 # DEBUG Msg here indicates Mapper needs to call from the right window, however...
 def set_z(*args)
   if $DEBUG and DISPLAY_DEVELOPER_ERRORS
     p "Please call \"set_z(#{args})\" from\n",
       "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
       "instead of \n\"Edit Event\" -> Scripts Window"
   end
 end

 # DEBUG Msg here indicates Mapper needs to call from the right window, however...
 def clear_z(*args) #args prevents any args from being used
   if $DEBUG and DISPLAY_DEVELOPER_ERRORS
     p "Please call \"clear_z\" from\n",
       "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
       "instead of \n\"Edit Event\" -> Scripts Window"
   end
 end
 
end


There are a few things I want you to know before you go ahead and check everything:

1. I have changed only one feature. In the instructions it was mentioned that using z_add would force a sprite to be rendered flat which makes no sense as z_add only is supposed to alter the Z on a specific event while z_flat was supposed to alter the Z automatically in such a way that it appears flat on the floor.

2. Technically it is enough to return a Z of 1 if you want flat sprites. But this is your implementation so I have left the code like in the original.

3. Previously z_flat and z_add were working together in a kind of weird and confusing way. Honestly, I was not exactly able to tell when one overrides the other. I have changed that. They now work independently and they can work together.

4. If you now use \z_flat[Int], it works just like \z_flat with \z_add[Int] together.

5. Your method naming (reset_z, clear_z, set_z) is ambiguous. IMO you should have just added set_z_flat(Bool), set_z_add(Int) and reset_flat_sprites. This is much more congruent with your script as it is exactly clear what parameters are being modified. set_z might be confused with changing some other Z values. Also, set_z is functionally incoherent as the execution depends on the parameters, especially since both z_flat and z_add are being modified in a way that they are mutually exclusive. If you set it to 0, a "completely different" execution path is executed. That's why I suggested set_z_flat and set_z_add since it's exactly clear what they do to someone who doesn't understand the script.

6. You have a note in the instructions that say that event names or events don't copy-paste properly. I have never experienced such a problem in all my years while working in RMXP. Are you 100% that you didn't accidentally mess up something and you actually just didn't copy-paste it right?

7. I have left your developer errors even though I feel they are kind of overkill for such a simple script. The ones at the bottom in Interpreter I can understand, but I don't really see the point of the one in set_z.

8. I would actually remove the optional parameter DISPLAY_DEVELOPER_ERRORS completely and the if-condition with $DEBUG. If somebody's game isn't working right, it would be good that certain error message stay in the release build as well and are displayed to the user if things go haywire. There's nothing worse than somebody reporting a bud without any kind of error message.

9. Other than that I have retained all the functionality in your script. Even though the name is actually inaccurate as this script does not only make sprites flat. "Event Z-Index Controller" or something like that would be a more accurate name for the script. It may not sound as fancy, but it tells you what it does.

Alright, this is all. Once we have solved these issues, I can finalize the script and add it to Tons.

EDIT: @F0: Your script alters the Z in absolute values. Making a sprite flat would require you to simply set its Z to 1, but your script doesn't allow to alter the current Z, e.g. add 32 to an event's Z. Of course, your script could be altered to support that as well. But then it would look almost like Heretic's script since you need one Z value for relative adding and one that would force absolute values. And you still wouldn't be able to combine these two functionalities. In Heretic's script you can do that (or at least in the version I have edited).
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.

Heretic86

I'll do some more cleaning on it and take those things in mind.

One quick thing for F0, in the effort to trim the fat on the racecar, you pulled out the brakes!  Some stuff is kind of necessary.  One line specifically where it checked < 0, which fixed an issue with an Event Sprite disappearing because ground appears to render at a Z of 0.  Rendering Sprites as Flat needs to subtract the height from its normal Z-Index, so they end up being able to go < 0 depending on the size of the sprite.  Of course, it was an example, but no biggie.

I am still trying to learn this, so I am also stuck at having bad habits that I dont even know are bad yet, as well as not having a 100% understanding of how the syntax works.  Never had any form of formal education in computer related anything, as I've never had a job that was willing to train me.  I dont need a job to learn, or need to pay someone money I dont have to read a book to me I can read myself.  Im not illegitimate, I know who my parents are!  :P  What I do need are projects.  A goal.  Something to accomplish.  And I find those when I think something else can be improved.  And many a times, I do have a need for a human being to explain something to me that I didnt grasp quite right or didnt know before.  So I dont expect anything from anyone, and when I do ask for a bit of help, or advice is offered, I do try to take it and try not to be a burden on someone that offered me their advice.

Got some stuff to do today, so let me work with it when I get a chance and I'll see what I can improve.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

I personally didn't feel the need for checking if something is less than 0.
I leave those things to the person making there game to make sure that script calls don't mess up the game. I find it better to simply instruct the user what could happen if they do this and this, but leave the ability there. There are a lot of other scripts out there, and they may for whatever reason have the need for a Z of less than 0. Neither way is in this particular example is incorrect, but you can fill a whole script making sure everyone makes a perfect script call with additional checks and exceptions just in case. I will often times clamp out of range values, but rarely do I make it throw exceptions unless there are a lot of advanced script calls that could be easily confused.

Anyways, good job on your script, I hope to see more! :D  Level++
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

@Heretic: Don't you worry about that. Everything comes with experience. The knowledge that I have now is also the result of a lot of work. I am happy to share my knowledge and experience with others as you can see. :)

As for improving, you don't need to worry about that too much either. As I said, I have basically altered the script to my own maximum capabilities so it works the best I can make it work. You just check on some stuff here and there and tell me if you're fine with the rest of the things that I listed in my previous post and I'll put in the compatibility code for Tons and add it to Tons then. :)

@F0: Neither do I usually use a < 0 check, but in this case it causes a bug if it's not there. The minimum Z for a tile on the tilemap is 0. If you have a sprite with z < 0, it will be behind the tilemap and it will be invisible (except if it is in another viewport obviously). Basically if you put a sprite off the map (e.g. an event at (0, 0) that has a sprite higher than 32 pixels), it will disappear because it will have a negative Z instead of it being flat on the floor.
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.