It is currently Mon May 21, 2012 1:21 am



Welcome
Welcome to icugigasoft

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!





 Page 1 of 3 [ 23 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Caterpillar System XP 1.1 and VX 1.2
PostPosted: Wed Aug 11, 2010 1:10 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
Caterpillar System by MarioSuperStar

Image

Note: Give Credit if Used

This script let's you have your party in the map, with everyone following the leader.

Features:
*Follow the player's back
*Follow Players Move Route(If the player does a move route, the party will do too)
*Party can make actions.(Animations, Move Routes, etc.)

Activating/Deactivating the party caterpillar:

Activate:
$scene.spriteset.on_partner.

Deactive:
$scene.spriteset.off_partner

Perform an Action for the a Caterpillar Party member
First, in the settings set the $ACTION_VAR as any variable you have free.
Then make in an event the action you want the caterpillar member to perform like this:
Image
Note: When finished to do action for event, set the variable to -1 to return back to normal.

Caterpillar System XP 1.1
#==============================================================================
# ** Partner System XP Version 1.1
#    By MarioSuperStar
#    Give credit if used
#==============================================================================

#==============================================================================
# ** Settings
# $ACTION_VAR = variable to select partner to process
# =============================================================================

$ACTION_VAR = 2

class Game_Character
  attr_accessor :move_route
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================

class Game_Partner < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actor_id
  attr_accessor :interpreter
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID
  #     event  : event (RPG::Event)
  #--------------------------------------------------------------------------
  def initialize(map_id, actor_id)
    super()
    @map_id = $game_map.map_id
    @actor_id = actor_id
    actor = $game_actors[actor_id]
    @id = 0 - actor.index
    @anime_count = 0
    @playing_move_route = false
    through = false
    @walk_anime = true
    @interpreter = nil
    @coord = []
    moveto(formulate_x, formulate_y)            # Move to initial position
    refresh
  end
  #--------------------------------------------------------------------------
  # * Formulate Starting Coordinates
  #--------------------------------------------------------------------------
  def formulate_x
    player = $game_player
    @direction = player.direction
    actor = $game_actors[@actor_id]
    index = actor.index
    case player.direction
    when 2
      return $game_player.x
    when 4
      return $game_player.x + index
    when 6
      return $game_player.x - index
    when 8
      return $game_player.x
    end
  end
 
  def formulate_y
    player = $game_player
    @direction = player.direction
    actor = $game_actors[@actor_id]
    index = actor.index
    player = $game_player
    case player.direction
    when 4
      return $game_player.y
    when 8
      return $game_player.y + index
    when 2
      return $game_player.y - index
    when 6
      return $game_player.y
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    actor = $game_actors[@actor_id]
    index = actor.index
    if $game_party.actors.size == 0 and $game_party.actors[index] == nil
      @character_name = ""
    else
      if $game_party.actors[index] != nil
        @character_name = actor.character_name
      end
    end
  end
 
  def check_event_trigger_touch(x = 0, y = 0)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @playing_move_route = false if $game_player.move_route == nil
    return if @playing_move_route
    return @playing_move_route = true && force_move_route($game_player.move_route) if $game_player.move_route != nil
    through = false
    return if moving?
    if @interpreter != nil                      # Now parallel processing?
      @interpreter.update                       # Update interpreter
      return
    end
    return if $game_system.map_interpreter.running?
    @x_ = formulate_x
    @y_ = formulate_y
    if passable?(@x_, @y_)
      if @x_ > @x and @y_ > @y
        move_lower_right
        return
      end
      if @x_ > @x and @y_ < @y
        move_upper_right
        return
      end
      if @x_ < @x and @y_ > @y
        move_lower_left
        return
      end
      if @x_ < @x and @y_ < @y
        move_upper_left
        return
      end
      if @x_ > @x
        move_right
        return
      end
      if @x_ < @x
        move_left
        return
      end
      if @y_ > @y
        move_down
        return
      end
      if @y_ < @y
        move_up
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x : x-coordinate
  #     y : y-coordinate
  #     d : direction (0,2,4,6,8)
  #         * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d = 0)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      # impassable
      return false
    end
    # If through is ON
    if @through
      # passable
      return true
    end
    # If unable to leave first move tile in designated direction
    unless $game_map.passable?(x, y, d, self)
      # impassable
      return false
    end
    # If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      # impassable
      return false
    end
    # Loop all events
    for event in $game_map.events.values
      # If event coordinates are consistent with move destination
      if event.x == new_x and event.y == new_y
        # If through is OFF
        unless event.through
          # If self is event
          if self != $game_player
            # impassable
            return false
          end
          # With self as the player and partner graphic as character
          if event.character_name != ""
            # impassable
            return false
          end
        end
      end
    end
    # passable
    return true
  end
 
  def distance_x_from_player
    return @x - formulate_x
  end
  def distance_y_from_player
    return @y - formulate_y
  end
end

class Scene_Map
  attr_accessor :spriteset
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    partner_flug = @spriteset.partners != nil
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    @spriteset.on_partner if partner_flug
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      Graphics.transition(20)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end

class Interpreter
  #--------------------------------------------------------------------------
  # * Get Character
  #     parameter : parameter
  #--------------------------------------------------------------------------
  def get_character(parameter)
    # Branch by parameter
    case parameter
    when -1   # Player
      if $scene.spriteset.partners != nil
        partners = $scene.spriteset.partners
        partner = $scene.spriteset.partners[$game_variables[$ACTION_VAR]]
        partner = partner.character
      end
      return partner == nil ? nil : partner if $game_variables[$ACTION_VAR] > -1 and $scene.spriteset.partners != nil
      return $game_player
    when 0  # this event
      events = $game_map.events
      return events == nil ? nil : events[@event_id]
    else  # specific event
      events = $game_map.events
      return events == nil ? nil : events[parameter]
    end
  end
end

class Spriteset_Map
 
  attr_accessor :partners
 
  def on_partner
    @partners = []
    for i in 1...$game_party.actors.size
      actor = $game_party.actors[i]
      @partners.push(Sprite_Character.new(@viewport1, Game_Partner.new(@viewport1, actor.id)))
    end
  end
 
  def off_partner
    return if @partners == nil
    for sprite in @partners
      sprite.dispose
    end
    @partners = nil
  end
 
  def update_partners
    for sprite in @partners
      sprite.update
    end
    for partner in @partners
      partner.character.update
    end
  end
 
  alias update_partner update
  def update
    update_partners if @partners != nil
    update_partner
  end
end


Caterpillar System VX 1.0

#==============================================================================
# ** Partner System VX Version 1.0
#    By MarioSuperStar
#    Give credit if used
#==============================================================================

#==============================================================================
# ** Settings
# $ACTION_VAR = variable to select partner to process
# =============================================================================

$ACTION_VAR = 2

class Game_Character
  attr_accessor :move_route
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================

class Game_Partner < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actor_id
  attr_accessor :interpreter
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID
  #     event  : event (RPG::Event)
  #--------------------------------------------------------------------------
  def initialize(map_id, actor_id)
    super()
    @map_id = $game_map.map_id
    @actor_id = actor_id
    actor = $game_actors[actor_id]
    @id = 0 - actor.index
    @anime_count = 0
    @playing_move_route = false
    through = false
    @walk_anime = true
    @interpreter = nil
    @coord = []
    moveto(formulate_x, formulate_y)            # Move to initial position
    refresh
  end
  #--------------------------------------------------------------------------
  # * Formulate Starting Coordinates
  #--------------------------------------------------------------------------
  def formulate_x
    player = $game_player
    @direction = player.direction
    actor = $game_actors[@actor_id]
    index = actor.index
    case player.direction
    when 2
      return $game_player.x
    when 4
      return $game_player.x + index
    when 6
      return $game_player.x - index
    when 8
      return $game_player.x
    end
  end
 
  def formulate_y
    player = $game_player
    @direction = player.direction
    actor = $game_actors[@actor_id]
    index = actor.index
    player = $game_player
    case player.direction
    when 4
      return $game_player.y
    when 8
      return $game_player.y + index
    when 2
      return $game_player.y - index
    when 6
      return $game_player.y
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    actor = $game_actors[@actor_id]
    index = actor.index
    if $game_party.members.size == 0 and $game_party.members[index] == nil
      @character_name = ""
      @character_index = 0
    else
      if $game_party.members[index] != nil
        @character_name = actor.character_name
        @character_index = actor.character_index
      end
    end
  end
 
  def check_event_trigger_touch(x = 0, y = 0)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @playing_move_route = false if $game_player.move_route == nil
    return if @playing_move_route
    return @playing_move_route = true && force_move_route($game_player.move_route) if $game_player.move_route != nil
    through = false
    return if moving?
    if @interpreter != nil                      # Now parallel processing?
      @interpreter.update                       # Update interpreter
      return
    end
    return if $game_map.interpreter.running?
    @x_ = formulate_x
    @y_ = formulate_y
    if passable?(@x_, @y_)
      if @x_ > @x and @y_ > @y
        move_lower_right
        return
      end
      if @x_ > @x and @y_ < @y
        move_upper_right
        return
      end
      if @x_ < @x and @y_ > @y
        move_lower_left
        return
      end
      if @x_ < @x and @y_ < @y
        move_upper_left
        return
      end
      if @x_ > @x
        move_right
        return
      end
      if @x_ < @x
        move_left
        return
      end
      if @y_ > @y
        move_down
        return
      end
      if @y_ < @y
        move_up
        return
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Determine Character Collision
  #     x : x-coordinate
  #     y : y-coordinate
  #    Detects normal character collision, including the player and vehicles.
  #--------------------------------------------------------------------------
  def collide_with_characters?(x, y)
    for event in $game_map.events_xy(x, y)          # Matches event position
      unless event.through                          # Passage OFF?
        return true if self.is_a?(Game_Event)       # Self is event
        return true if event.priority_type == 1     # Target is normal char
      end
    end
    return false
  end
 
  def distance_x_from_player
    return @x - formulate_x
  end
  def distance_y_from_player
    return @y - formulate_y
  end
end

class Scene_Map
  attr_accessor :spriteset
  #--------------------------------------------------------------------------
  # * Player Transfer  Processing
  #--------------------------------------------------------------------------
  def update_transfer_player
    return unless $game_player.transfer?
    fade = (Graphics.brightness > 0)
    fadeout(30) if fade
    partner_flag = @spriteset.partners != nil
    @spriteset.dispose              # Dispose of sprite set
    $game_player.perform_transfer   # Execute player transfer
    $game_map.autoplay              # Automatically switch BGM and BGS
    $game_map.update
    Graphics.wait(15)
    @spriteset = Spriteset_Map.new  # Recreate sprite set
    @spriteset.on_partner if partner_flag
    fadein(30) if fade
    Input.update
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Get Character
  #     parameter : parameter
  #--------------------------------------------------------------------------
  def get_character(parameter)
    # Branch by parameter
    case parameter
    when -1   # Player
      if $scene.spriteset.partners != nil
        partners = $scene.spriteset.partners
        partner = $scene.spriteset.partners[$game_variables[$ACTION_VAR]]
        partner = partner.character
      end
      return partner == nil ? nil : partner if $game_variables[$ACTION_VAR] > -1 and $scene.spriteset.partners != nil
      return $game_player
    when 0  # this event
      events = $game_map.events
      return events == nil ? nil : events[@event_id]
    else  # specific event
      events = $game_map.events
      return events == nil ? nil : events[parameter]
    end
  end
end

class Spriteset_Map
 
  attr_accessor :partners
 
  def on_partner
    @partners = []
    for i in 1...$game_party.members.size
      actor = $game_party.members[i]
      @partners.push(Sprite_Character.new(@viewport1, Game_Partner.new(@viewport1, actor.id)))
    end
  end
 
  def off_partner
    return if @partners == nil
    for sprite in @partners
      sprite.dispose
    end
    @partners = nil
  end
 
  def update_partners
    for sprite in @partners
      sprite.update
    end
    for partner in @partners
      partner.character.update
    end
  end
 
  alias update_partner update
  def update
    update_partners if @partners != nil
    update_partner
  end
end


Last edited by MarioSuperStar on Wed Feb 01, 2012 8:30 pm, edited 3 times in total.


_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP
PostPosted: Thu Aug 12, 2010 1:34 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
sorry forgot to add this:

on the Game_Event on def initialize add this:

@name = @event.name



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP
PostPosted: Thu Aug 12, 2010 3:20 pm 
Senior Member
Senior Member
User avatar

Joined: Sun Nov 01, 2009 7:38 pm
Posts: 4321
Looking at the video, it seems to work rather well.


Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP
PostPosted: Thu Aug 12, 2010 3:57 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
thanks



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Sat Feb 12, 2011 4:52 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
updated and improved. also vx version.



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Sat Feb 12, 2011 4:56 pm 
Senior Member
Senior Member
User avatar

Joined: Sun Nov 01, 2009 7:38 pm
Posts: 4321
Wow nice. I might have to use that VX one...
You are quite the scripter, MSS!


Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Sun Feb 13, 2011 11:24 am 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
yes, this was made for other project of mine... but it can be also helpful for star bits journey.



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Mon May 02, 2011 6:02 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
This is now protected by a creative commons license:

Image
MSS Caterpillar System by MarioSuperStar is licensed under a Creative Commons Attribution 3.0 Unported License.



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Mon May 02, 2011 10:26 pm 
Senior Member
Senior Member
User avatar

Joined: Sun Nov 01, 2009 7:38 pm
Posts: 4321
Sweet, how exactly do you go about doing that?


Offline
 Profile  
 
 Post subject: Re: Caterpillar System XP 1.1 and VX 1.0
PostPosted: Tue May 03, 2011 3:27 pm 
Senior Member
Senior Member
User avatar

Joined: Mon Jun 28, 2010 5:55 pm
Posts: 1270
Location: Look somewhere else...
i saw a work of someone with the liscence, clicked on the link and made my license.
not so head-breaking.



_________________
Super Mario RPG
Working on:Maps :P
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 3 [ 23 posts ]  Go to page 1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron

suspicion-preferred