[XP] Tons of Add-ons

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

Previous topic - Next topic

ForeverZer0

Thats only if there are tiles. If you wanted something below the tilemap, but above the panorama, the z could be lower.
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

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

Actually, I think you have a point Z0.

It could be kind of useful to have an event with a < 0 Z-Index with Panoramas.  For example, standing on top of a cliff with a Panorama, and an event sails off into the distance might need a negtive Z-Index.  I dont want to try implementing at this
time because Panoramas move differently, and doing it like that may require messing with event movement.  Over my head at this point.  Might be useful for background birds, but not for Boats without more event movement stuff.

The 0 bug I came across I found happened while the player moved around on a bit larger maps.  Events were disappearing as soon as I stepped below them, but reappeared when I walked back to my original position.  Again, it could be useful in specific cutscenes with Panoramas. 

I think Blizzard has a better idea of just returning 1 for flat sprites, way faster, but again, it takes away control of the stack order, like 2 flat sprites that stack on top of each other would revert to no direct control for the mapper to adjust, and it would be controlled by the Event ID for which ever one got the higher Event ID would be on top.  What I wanted to accomplish was to give mappers more control than just surrendering to Event ID order.

In regards to comment #6 bug, got an example.  http://www.775.net/~heretic/downloads/rmxp/cat.php Map #4, Event at 9, 15, cut and paste, name disappears.

Im confused on the names bit.  I'll trust your experience if you feel like renaming them to be less confusing to others.

Change Log:
Updated Comments for better explanations.
Pulled out set_z error msg, but left in error msgs in interpreter.
Pulled out developer errors.  Errors just display in non Debug games as well.
Changed Title to "Event Z-Index Controller"

Revised Version


Spoiler: ShowHide
# ----------------------------------------------------------------------------
#          Event Z-Index Controller 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.  All EVENTS cover flat sprites.  Non priority tiles will
# appear beneath a Flat Sprite Event.
#
# Added Controls added to allow Mappers more control over Event Z-Index, which
# is useful for Stacking Events or Event Layering.  Event ID's used to determine
# which event would render on top of another.  The Z-Index controls allow a
# mapper to determine which event will be on top of another without needing to
# fight with Event ID's.
#
# 32:  Each Tile in RMXP is 32 pixels tall.  If you need to adjust an
# events Z-Index, I recommend trying increments of 32 at first to get you
# closer to your goal.  If you need to, you can specify any whole number
# that you wish.
#
# --- EVENT NAME RELATED---
#
# EV001\z_flat
# EV001\z_flat[32]
# EV001\z_add[32]
#
# To make an Event always render as flat, add to its nane "\z_flat".
#
# 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, 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).  Imagine having one graphic that has flat parts and
#  other parts that should be standing.
#
# --- 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.
#
# This bug is difficult to reproduce.  One project this bug occurs all the time
#  but other projects it never occurs.  Just be aware when moving events.
# ----------------------------------------------------------------------------

#==============================================================================
#  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)
    # Expects new_z as an Argument.  It adds whatever that value is to new number
    if new_z != 0 and new_z.is_a?(Numeric)
      # 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
# Edit Event -> Set Move Route -> Scripts
# are DIFFERENT!  Edit Event -> Scirpts doesnt specify the Event.
#==============================================================================

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

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


Off Topic, do you have anything in TONS for Fading Events in and out like a Fog can do?  If you dont, would that be another worthwhile addition?
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.)

Heretic86

April 22, 2012, 11:00:15 pm #843 Last Edit: April 22, 2012, 11:01:42 pm by Heretic86
Ok, heres the script for Fade Events, as promised.  Separate post to keep topics a bit more organized.  If there is already something included in TONS, this is unnecessary.

Fade Events

Spoiler: ShowHide
# Heretic's Object Fade v1.0
#
# Super simple to use.  Put above Main somewhere. 

# Pretty much anywhere between Scene_Debug and Main should be fine
# In the Editor, in Edit Events, go to Set Move Route, and hit Script
# in that window, enter "fade_event(255, 20)" without the quotes
# and adjust 255 for Not Transparent to 0 for Fully Invisible
# the second number is the number of Frames for the Transition

module Fade_Events #(for including in any new or custom classes)
  #--------------------------------------------------------------------------
  # * Fade Event - (Opacity 0 to 255, Duration in Frames)
  #--------------------------------------------------------------------------
 
  def fade_event(arg_opacity_target, arg_opacity_duration)
    if arg_opacity_target.nil? or arg_opacity_duration.nil?
      print "fade_event(opacity, duration) expects Two Arguments\n"
      return
    elsif not arg_opacity_target.is_a? Numeric
      print "\"", arg_opacity_target, "\" is not an Number!\n",
            "Both Arguments should be Numbers!\n\n",
            "I.E. fade_event(255,20)"
      return
    elsif not arg_opacity_duration.is_a? Numeric
      print "\"", arg_opacity_duration, "\" is not an Number!\n",
            "Both Arguments should be Numbers!\n\n",
            "I.E. fade_event(255,20)"
      return
    elsif arg_opacity_target < 0 or arg_opacity_target > 255
      print "\"", arg_opacity_target, "\" Opacity Out of Range\n",
            "Valid Range: 0 - 255"
    elsif arg_opacity_duration < 0
      print "\"", arg_opacity_target, "\" Duration Out of Range\n",
            "Valid Range: Any Positive Number or 0"
    end
   
    self.opacity_target = arg_opacity_target * 1.0
    self.opacity_duration = arg_opacity_duration
    if self.opacity_duration == 0
      self.opacity = self.opacity_target.clone
    end
  end

#-----------------------------------------------------------------------------
#  * Change Event Opacity
#-----------------------------------------------------------------------------
 
  def change_event_opacity
    # Manage change in Event Opacity Level
    if @opacity_duration >= 1
      d = @opacity_duration
      @opacity = (@opacity * (d - 1) + @opacity_target) / d
      @opacity_duration -= 1
    end
  end

end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------

class Game_Character
 
  attr_accessor     :opacity_target
  attr_accessor     :opacity_duration
  attr_accessor     :original_opacity
 
  unless self.method_defined?('fade_events_initialize')
    alias fade_events_initialize initialize
  end

  def initialize
    # Initilaize Original First
    fade_events_initialize
    # Added Properties
    @opacity_target = 255
    @opacity_duration = 0
    @original_opacity = @opacity
  end

  # IF the method hasn't been defined yet
  unless self.method_defined?('fade_events_update')
    alias fade_events_update update
  end
 
  # Redefine Updater
  def update
    # Run Original First
    fade_events_update
    if @opacity_duration >= 1
      # Manages the Events Current Opacity
      change_event_opacity
    end
  end

  # Check if the Fade_Event is already Defined (prevents errors)
  unless Game_Character.included_modules.include? (Fade_Events)
    # Make the functions inside the Module available to this class
    include Fade_Events
  end
 
end

class Interpreter
  def fade_event(opacity, duration)
    print "Please call \"fade_event\" from\n",
           "\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
           "instead of \n\"Edit Event\" -> Scripts Window"
  end
end
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

IMO this script is not really necessary as you can change the opacity through event commands. It's not like you have events that fade that often.
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

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

April 23, 2012, 01:08:54 pm #846 Last Edit: April 23, 2012, 01:45:24 pm by Blizzard
Can still be done with a few event commands. I did it every time in CP.

EDIT: It is done. v7.6 is out.
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

Cool!  Thank you sir!

No biggie on Fading Events.  I'll just submit it as a Standalone Script instead.
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

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.

ruiran1

April 30, 2012, 02:06:09 am #849 Last Edit: April 30, 2012, 02:22:52 am by ruiran1
Would it be possible to make asmall script for commercial use with only these things(as i cant script very well,)
(and i found multiple scripts that work like most under here, just a small problem that most dont work togheter nad have a very low Compatibility with teh other scripts)




    Location Names (shows pictures or names of the location the player visits)
    Death Image (displays an image instead of nothing for dead actors) 
    Target 'em all! (make skills target all battlers)
    Passive Skills (modify attributes when learned)
    Different Difficulties (like "Easy", "Normal", "Hard")
    Multi-Hit (make weapons/skills/enemies hit more than once)     
    HP/SP Crush (weapons consume HP/SP when attacking)
    Percentage Health States (states added/removed on specific HP percentages)

    Zombie Status (Healing items will hurt and light attacks are effective)
    Regen Status (progressive healing aka poison, but the other way)
    Fury Status (if a specific character dies, another one will become Fury)
    Invincible Status (this status will nullify ANY DAMAGE done by enemies)
    SP Cost Mod Status (this status will change SP cost to percentages or fixed values)
    Doom Status (countdown to death)

    Absorb HP/SP Skill (with considering undead enemies)
    Demi Skill (deals damage equal to a percentage of the remaining HP)
    Revenge Skill (does damage equal to MAX_HP - CURRENT_HP)
    Destructor Skill (kills self to achieve various effects)
    SP Damage Skill (skills that damage / heal SP instead of HP)
    Charge Skill (skills that count down before usage)
    Master Thief Skill (steals weapon, armors, items and gold from enemies)
    HP Consuming Skill (consumes HP upon usage)

ForeverZer0

There's one for Sub's sig...
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.

Spoofus

So I am looking for some help with the Caterpillar script portion of TONS,basically I am trying to increase the spacing between the party members.I have tried messing with it but I am unable to get any results.If anyone knows what I should be editing to go about please let me know.


My Blog site I am working on: http://spoofus.weebly.com/

Blizzard

@ruiran1: Send me an email at blizzard@chaos-project.com with a request to use Tons in a commercial game and I will give you permission. It's no problem.
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

Hey, um, real quick, F12 Reset is causing stack level too deep on script 2 line 1291...
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

June 04, 2012, 08:50:39 am #854 Last Edit: June 23, 2012, 08:47:53 am by Blizzard
Quote from: Blizzard on December 03, 2009, 03:04:51 pm
Normal F12 crash. Just get the F12 fix. It's something Enterbrain messed up with RMXP and it can't be fixed.
The general problem with F12 is that instead of resetting the entire application, the scripts stay untouched. If you have used an alias anywhere, RMXP will do the alias again and on first occasion where the aliased method should be called, the crash happens.


Use this:

Quote from: Ryex on February 06, 2010, 09:10:43 pm
this is the classic F12 error known to almost every scripter. the fix is simple

create a new script at the top of the editor and paste this code into it


#==============================================================================
# F12 fix
#==============================================================================

if $game_exists
 Thread.new {system('Game')}
 exit
end

$game_exists = true




Change "Game" to if you renamed "Game.exe".

EDIT: I have uploaded v7.61b with an improved Input module.
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.

Mekool

Bug report:
Custom Game Controls
"Number pad 0"doesn't work as input::B
but "Insert"  does

Blizzard

Turn on/off NUM-LOCK. If I remember right, turning on NUM-LOCK should make 0 be used instead of Insert.
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.

Mekool

"Number pad 0" works when NUM LOCK is on
But "Insert" works no matter NUM LOCK is on or off

Blizzard

That's expected behavior. Numberpad keys usually don't work as number unless you turn on NUM-LOCK.

Also, on some keyboards "Numberpad 0" should work as "Insert" if NUM-LOCK is off.
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.

Mekool

I am still confused.
My question is : I cannot turn on the menu when the NUM LOCK light is ON.