Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.

Share | 
 

 [XP] Caterpillar

Topik sebelumnya Topik selanjutnya Go down 
[XP] Caterpillar Empty2011-06-23, 14:25
Post[XP] Caterpillar
#1
LiTTleDRAgo 
Senior
Senior
LiTTleDRAgo

Level 5
Posts : 712
Thanked : 27
Engine : RMXP
Skill : Skilled
Type : Scripter
Awards:
[XP] Caterpillar Vide
Caterpillar
Versi: 1.00
Tipe: ???


Pengenalan

Iseng-iseng ngoprek skrip ternyata hasilnya jadi caterpillar, yauda deh gw lanjutin


Fitur


  • Caterpillar
  • Bisa ngerubah max actor di party (cuma di map, kalo di battle tetep)



Screenshots

[XP] Caterpillar 0ac0af137691584



Demo

---


Scripts

Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# [Xp] Caterpillar
# Version: 1.00
# Author : LiTTleDRAgo
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

module Caterpillar
 
  ACTOR_MAX_PARTY = 4
  PARTY_SPEED = 4

end

#------------------------------------------------------------------------------
# SDK Check
#------------------------------------------------------------------------------
if Object.const_defined?('SDK')
 SDK.log('Caterpillar', 'LiTTleDRAgo', 2, '22.06.11')
 @drg_caterpillar_disabled = !SDK.enabled?('Caterpillar')
end

if !@drg_caterpillar_disabled
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias cater_game_map_setup setup
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(map_id)
    cater_game_map_setup(map_id)
    setup_caterpillar
  end
  #--------------------------------------------------------------------------
  # * Setup Train Actors
  #--------------------------------------------------------------------------
  def setup_caterpillar
    map_event = RPG::Event.new(0, 0)
    size = (2000+Caterpillar::ACTOR_MAX_PARTY)-1
    for i in 2001..size
      map_event.id = i
      @events[i] = Game_Event.new(0, map_event)
      @events[i].move_speed = Caterpillar::PARTY_SPEED
      @events[i].move_frequency = 6
      @events[i].follow_event_id = 0
      @events[i].uncensor = true
    end
    $game_party.caterpillar($game_party.caterpillar_visible)
  end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :caterpillar_visible
  #--------------------------------------------------------------------------
  # * Train Actors
  #--------------------------------------------------------------------------
  def caterpillar(visible)
    @caterpillar_visible = visible.nil? ? false : visible
    size = (2000+Caterpillar::ACTOR_MAX_PARTY)-1
    for i in 2001..size
      actor = $game_party.actors[i-2000]
      next if $game_map.events[i].nil?
      if $game_party.caterpillar_visible and actor
        $game_map.events[i].move_type = 5
        $game_map.events[i].moveto($game_player.x,$game_player.y)
        $game_map.events[i].character_name = actor.character_name
        $game_map.events[i].character_hue = actor.character_hue
      else $game_map.events[i].move_type = 4
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Add an Actor
  #    actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    actor = $game_actors[actor_id]
    if @actors.size < Caterpillar::ACTOR_MAX_PARTY && !@actors.include?(actor)
      @actors.push(actor)
      $game_player.refresh
    end
  end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #-------------------------------------------------------------------------- 
  attr_accessor :character_name,:character_hue,
      :through,  :move_speed, :move_frequency, :move_type,
      :follow_event_id, :uncensor,
      :x2, :y2
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias init_cater_fusion initialize
  alias update_cater_fusion update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    init_cater_fusion
    setup_caterpillar
  end
  #--------------------------------------------------------------------------
  # * Setup Caterpillar
  #--------------------------------------------------------------------------
  def setup_caterpillar
    @follow_event_id = 0
    @x2 = @y2 = 0
  end
  #--------------------------------------------------------------------------
  # * Fusion with Event
  #--------------------------------------------------------------------------
  def move_type_fusion_with_event
    event = (@follow_event_id == 0) ? $game_player : $game_map.events[@follow_event_id]
    return unless event
    @x, @y, @x2, @y2 = event.x, event.y, event.x2, event.y2
    unless @character_name.empty?
      sx, sy = (@real_x - event.real_x).abs, (@real_y - event.real_y).abs
      speed = 7
      if Math.hypot(sx, sy) < 2**speed * 2
        self.character_name = "" if sx == 0 && sy == 0
      else turn_toward_event(@follow_event_id)
      end
    else# @real_x, @real_y = @x2, @y2
    end
  end
  #--------------------------------------------------------------------------
  # * Move to Party Leader
  #--------------------------------------------------------------------------
  def move_type_to_leader
    sx, sy = (@x - $game_player.x), (@y - $game_player.y)
    return if $xrxs_xas && self.throw_active
    return (sx == 0 && sy == 0) ? move_random : move_toward_player
        turn_toward_event  if (sx <= 1 && sx >= -1) && (sy <= 1 && sy >= -1)
    method_defined?(:move_to_me) ?  move_to_me :
    unless moving? || @direction_fix
      x = @direction == 4 ? -1 : @direction == 6 ? 1 : 0
      y = @direction == 2 ? 1 : @direction == 8 ? -1 : 0
      passable?(@x+x, @y+y, @direction) && !(x == 0 && y == 0) ? jump(x*2,y*2) :
      move_toward_player
    end
    @wait_count = 30 * 2 - 1 if !moving?
  end
  #--------------------------------------------------------------------------
  # * Turn Toward Event
  #--------------------------------------------------------------------------
  $noupperleft = true if !method_defined?(:turn_upper_left)
  def turn_toward_event(event_id = 0)
    event = (event_id == 0) ? $game_player : $game_map.events[event_id]
    return unless event
    sx, sy = @x - event.x, @y - event.y
    return if sx == 0 and sy == 0
    if sx.abs == sy.abs
      return if $noupperleft
      sy > 0 ? (sx > 0 ? turn_upper_left : turn_upper_right) :
        (sx > 0 ? turn_lower_left : turn_lower_right)
    else
      sx.abs > sy.abs ? (sx > 0 ? turn_left : turn_right) :
                      (sy > 0 ?  turn_up : turn_down)
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Away From Event
  #--------------------------------------------------------------------------
  def turn_away_from_event(event_id = 0)
    event = (event_id == 0) ? $game_player : $game_map.events[event_id]
    return unless event
    sx, sy = @x - event.x, @y - event.y
    return if sx == 0 and sy == 0
    if sx.abs == sy.abs
      return if $noupperleft
      sy > 0 ? (sx > 0 ? turn_lower_right : turn_lower_left) :
        (sx > 0 ? turn_upper_right : turn_upper_left)
    else
      sx.abs > sy.abs ? (sx > 0 ? turn_right : turn_left) :
                      (sy > 0 ?  turn_down : turn_up)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    update_cater_fusion
    return if @wait_count > 0 or @move_route_forcing or @starting or lock?
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      case @move_type
      when 4 then move_type_fusion_with_event
      when 5 then move_type_to_leader
      end
    end
  end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias cater_game_player_moveto moveto
  alias cater_game_player_refresh refresh
  alias passable_cater  passable?
  #--------------------------------------------------------------------------
  # * Moveto
  #--------------------------------------------------------------------------
  def moveto(x, y)
    cater_game_player_moveto(x, y)
    size = (2000+Caterpillar::ACTOR_MAX_PARTY)-1
    (2001..size).each {|i| $game_map.events[i].moveto(x, y)}
  end
  #--------------------------------------------------------------------------
  # * Move to Designated Position
  #    x : x-coordinate
  #    y : y-coordinate
  #--------------------------------------------------------------------------
  def originmoveto(x, y)
    @x,@y = x % $game_map.width, y % $game_map.height
    @real_x,@real_y = @x * 128, @y * 128
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    cater_game_player_refresh
    self.character_name = @character_name
    $game_party.caterpillar($game_party.caterpillar_visible)
  end
  #--------------------------------------------------------------------------
  # * Passable
  #--------------------------------------------------------------------------
  def passablecater?(x, y, d)
    result = passable_cater(x,y,d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return true if $xrxs_xas && self.is_a?(Game_Player) && $game_system.fly 
    return false unless $game_map.valid?(new_x, new_y)
    return result if @through
    return false unless $game_map.passable?(x, y, d, self) &&
          $game_map.passable?(new_x, new_y, 10 - d)
    $game_map.events.each_value {|event|
      if event.x == new_x && event.y == new_y
        unless event.through
          return true if event.name =~ /<Tembus>/i or
                  event.id > 2000
          return false if self != $game_player
          return false if event.character_name != ""
        end
      end }
    if $game_player.x == new_x and $game_player.y == new_y
      unless $game_player.through
        return false if @character_name != ""
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Passable
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return true if $DEBUG and Input.press?(Input::CTRL)
    return false unless $game_map.valid?(new_x, new_y)
    return passablecater?(x, y, d)
  end
end
#===============================================================================
# ■ Patch for XAS
#===============================================================================
if $xrxs_xas
module XRXS_EnemySensor
 #--------------------------------------------------------------------------
 # ● Update Sensor
 #--------------------------------------------------------------------------
  alias update_sensor_uncensor update_sensor
  def update_sensor
    update_sensor_uncensor if !self.uncensor
  end
end
end
#--------------------------------------------------------------------------
# SDK Check End
#--------------------------------------------------------------------------
end
#--------------------------------------------------------------------------
# END OF SCRIPT
#--------------------------------------------------------------------------


Credits


  • LiTTleDRAgo
 

[XP] Caterpillar

Topik sebelumnya Topik selanjutnya Kembali Ke Atas 

Similar topics

+
Halaman 1 dari 1

Permissions in this forum:Anda tidak dapat menjawab topik
RPGMakerID :: Scripts & Event Systems :: RMXP Scripts-