VX 스크립트

Repel Effect
Version
1.0 revision final
Author puppeto4
Release Date 04/06/2008



Introduction

I always want repel effect in pokemon game in VX, so I made one smile.gif


Features

This script will enable random encounter to turn off temporarily and enable
it again when the character has moved up to the defined steps.
시작
#==============================================================================
# ** Repel Effect
#------------------------------------------------------------------------------
# Author  : puppeto4 (puppeto5@hotmail.com)
# Version : 1.0 revision final
# Date    : 04 / 06 / 2008
# Note    : Order Pizza Hut, support the rebellion.
# Check RPG RPG Revolution(http://www.rpgrevolution.com) for support
#------------------------------------------------------------------------------
# Function :  
#   This script will enable random encounter to turn off temporarily and enable
#   it again when the character has moved up to the defined steps.
#------------------------------------------------------------------------------
# Instruction :
#    Place this script, in a new script page below Material section.
#    Then create a new state(or more) and
#    write the Repel_Text value(default is "*REPEL") in the state's note field.
#    When the state is inflicted, random encounter will immediately disabled.
#    Also, write the Remove_Repel_Text value in the same state's note field.
#    If you don't, the random encounter won't be enabled again.Place it in this
#    format : value[steps] i.e : *REMOVE_REPEL[120]
#       value : Remove_Repel_Text value(default is "*REMOVE_REPEL")
#       steps : Steps taken before the state(the repel effect) is released.
#
#    Using the repel effect :
#
#    To use the repel effect from the menu, create a new item/skill and set the
#    item/skill to inflict the state that has repel effect. You need to write the
#    Repel_Text value(default is "*REPEL") in the item's/skill's note field too.
#    This is to enable notification when repel effect is activated.
#  
#    Player Notification :
#
#    If you want to notify the player when the repel effect is on,
#    in state message field(when actor is inflicted with the state),just write
#    the message that the repel effect is activated, i.e : " effect is activated."
#    It will show "[State name]  effect is activated." in game(not actor name as
#    opposed to usual).
#    As for the notification when the repel effect is off, in the state message
#    field(when state is released), just write the message that the repel effect
#    is off, i.e : " effect is weakened."
#    it will show "[State name]  effect is weakened." in game.
#    Anyway, if you don't want to notify the player, leave both field empty.
#==============================================================================
#==============================================================================
# ** RepelEffect : Configuration
#==============================================================================
#==============================================================================
# ** Puppeto
#------------------------------------------------------------------------------
#  This module handles setup for any script writen by me ^^.
#==============================================================================

module Puppeto
#==============================================================================
# ** Repel
#------------------------------------------------------------------------------
#  This module handles setup for the repel system script.
#==============================================================================
  
module Repel
  #------------------------------------------------------------------------
  # * Repel note text
  #     This is the text that you put in the state's note field for the repel
  #     to take effect when the state is inflicted on the character.
  #------------------------------------------------------------------------
  Repel_Text = "*REPEL"
  #------------------------------------------------------------------------
  # * Repel Remover Text
  #     This is the text that you put in the state's note field for the repel
  #     effect to be removed when the state is released for character.
  #------------------------------------------------------------------------
  Remove_Repel_Text = "*REMOVE_REPEL"
  #------------------------------------------------------------------------
  # * Setup for Message Window background and position
  # For the first object in array(default is 0), determine window background.
  # 0 : Normal Background, 1 : Dim Background, 2 : Transparent Background
  # For the second object in array(default is 2), determine window position.
  # 0 : Top Position, 1 : Middle Position, 2 : Bottom Position
  #------------------------------------------------------------------------
  Repel_Notify_Window = [0, 2]
#==============================================================================
# ** End of Repel module
#------------------------------------------------------------------------------    
end
#==============================================================================
# ** End of Puppeto module
#------------------------------------------------------------------------------
end  
#==============================================================================
# ** End of RepelEffect : Configuration
#==============================================================================
#==============================================================================
# ** RepelEffect : Script
#==============================================================================
#==============================================================================
# ** Class Alias
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Class(es) : Game_Battler, Game_Party, Game_Player, Scene_Item,
#                       Scene_Skill
#----------------------------------------------------------------------------
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : add_state, remove_state
#----------------------------------------------------------------------------

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias puppet_repel_add_state add_state
  alias puppet_repel_remove_state remove_state
  #--------------------------------------------------------------------------
  # * Add State
  #     state_id : state ID
  #--------------------------------------------------------------------------
  def add_state(state_id)
    # The usual
    puppet_repel_add_state(state_id)
    # Call create_repel_steps_count from $game_party
    $game_party.create_repel_steps_count(state_id)
  end
  #--------------------------------------------------------------------------
  # * Remove State
  #     state_id : state ID
  #--------------------------------------------------------------------------
  def remove_state(state_id)
    # The usual
    puppet_repel_remove_state(state_id)
    # Call clear_repel_steps_count from $game_party
    $game_party.clear_repel_steps_count(state_id)
  end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : initialize, on_player_walk
# * New Method(s)     : repel?, repel_steps_count, create_repel_steps_count,
#                       clear_repel_steps_count, check_repel_steps
#----------------------------------------------------------------------------

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Include Puppeto::Repel modules
  #--------------------------------------------------------------------------  
  include Puppeto::Repel  
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------  
  alias puppet_repel_initialize initialize        
  alias puppet_repel_on_player_walk on_player_walk
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # The usual
    puppet_repel_initialize
    # Set repel
    @repel = false
    # Create @repel_steps_count hash object
    @repel_steps_count = {}
  end
  #--------------------------------------------------------------------------
  # * Processing Performed When Player Takes 1 Step
  #--------------------------------------------------------------------------
  def on_player_walk
    # The usual
    puppet_repel_on_player_walk
    # If @repel_steps_count is nil
    @repel_steps_count = {} if @repel_steps_count == nil
    # Browse through all object in @repel_steps_count's keys  
    @repel_steps_count.keys.each do |i|
      # if @repel_steps_count's object is more than 0
      @repel_steps_count[i] -= 1 if @repel_steps_count[i] > 0
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if repel states inflicted on actor
  #--------------------------------------------------------------------------  
  def repel?
    # Browse through all actor in members
    members.each do |actor|
      # Return true if repel states is inflicted on actor
      return true if actor.repel?
    end
    return false
  end  
  #--------------------------------------------------------------------------
  # * Repel Steps Count
  #--------------------------------------------------------------------------
  def repel_steps_count
    # Return @repel_steps_count
    return @repel_steps_count
  end
  #--------------------------------------------------------------------------
  # * Create Repel Steps Count
  #     state_id : state ID  
  #--------------------------------------------------------------------------
  def create_repel_steps_count(state_id)
    # Create state; local variable
    state = $data_states[state_id]
    # Create repel_text; local variable
    repel_text = Remove_Repel_Text.dup
    # If state's note contain repel_text
    if state.note[/#{Regexp.quote repel_text}[(d+)]/].to_a[0]
      # Create n; local variable
      n = $1.to_i
      # Set @repel_steps_count to n
      @repel_steps_count[state_id] = n
    end
  end
  #--------------------------------------------------------------------------
  # * Clear Repel Steps Count
  #     state_id : state ID  
  #--------------------------------------------------------------------------
  def clear_repel_steps_count(state_id)
    # Delete @repel_steps_count
    @repel_steps_count.delete(state_id)
  end
  #--------------------------------------------------------------------------
  # * Check Repel Steps
  #--------------------------------------------------------------------------
  def check_repel_steps
    # Browse through all objects in @repel_steps_count's keys
    @repel_steps_count.keys.each do |i|
      # Unless that @repel_steps_count[i] isn't 0
      next if @repel_steps_count[i] != 0
        # Browse through all actor in members
        members.each do |actor|
          # Remove state from actor
          actor.remove_state(i)
        end
        # Create state; local variable
        state = $data_states[i]
        # Ignore if release message for state is empty
        next if state.message4.empty?
        # Set background for message
        $game_message.background = Repel_Notify_Window[0]
        # Set position for message
        $game_message.position = Repel_Notify_Window[1]
        # Push state's release message to message's text
        $game_message.texts << state.name + state.message4
    end
  end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : update_encounter, check_touch_event
#----------------------------------------------------------------------------

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias puppet_repel_update_encounter update_encounter
  alias puppet_repel_check_touch_event check_touch_event
  #--------------------------------------------------------------------------
  # * Update Encounter
  #--------------------------------------------------------------------------
  def update_encounter
    # Return in repel states is inflicted on any actor in party
    return if $game_party.repel?
    # The usual
    puppet_repel_update_encounter
  end    
  #--------------------------------------------------------------------------
  # * Determine Event Start Caused by Touch (overlap)
  #--------------------------------------------------------------------------  
  def check_touch_event
    # Call check_repel_steps from $game_party
    $game_party.check_repel_steps
    # The usual
    puppet_repel_check_touch_event
  end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs the item screen processing.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : use_item_nontarget
#----------------------------------------------------------------------------

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Include Puppeto::Repel modules
  #--------------------------------------------------------------------------  
  include Puppeto::Repel    
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias puppet_repel_use_item_nontarget use_item_nontarget
  #--------------------------------------------------------------------------
  # * Use Item (apply effects to non-ally targets)
  #--------------------------------------------------------------------------
  def use_item_nontarget
    # The usual
    puppet_repel_use_item_nontarget
    # If Repel_Text is included in the item's note
    if @item.note.include?(Repel_Text)
      # Browse through all objects in @repel_steps_count's keys
      $game_party.repel_steps_count.keys.each do |i|
        # Create state; local variable
        state = $data_states[i]
        # Ignore if actor message for state is empty
        next if state.message1.empty?
        # Set background for message
        $game_message.background = Repel_Notify_Window[0]
        # Set position for message
        $game_message.position = Repel_Notify_Window[1]
        # Push state's actor message to message's text
        $game_message.texts << state.name + state.message1
      end
    # Return to Scene_Map  
    $scene = Scene_Map.new
    end
  end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
#  This class performs the skill screen processing.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : use_skill_nontarget
#----------------------------------------------------------------------------

class Scene_Skill < Scene_Base
  #--------------------------------------------------------------------------
  # * Include Puppeto::Repel modules
  #--------------------------------------------------------------------------  
  include Puppeto::Repel    
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias puppet_repel_use_skill_nontarget use_skill_nontarget  
  #--------------------------------------------------------------------------
  # * Use Skill (apply effects to non-ally targets)
  #--------------------------------------------------------------------------
  def use_skill_nontarget
    # The usual
    puppet_repel_use_skill_nontarget
    # If Repel_Text is included in the item's note
    if @skill.note.include?(Repel_Text)
      # Browse through all objects in @repel_steps_count's keys
      $game_party.repel_steps_count.keys.each do |i|
        # Create state; local variable
        state = $data_states[i]
        # Ignore if actor message for state is empty
        next if state.message1.empty?
        # Set background for message
        $game_message.background = Repel_Notify_Window[0]
        # Set position for message
        $game_message.position = Repel_Notify_Window[1]
        # Push state's actor message to message's text
        $game_message.texts << state.name + state.message1
      end
    # Return to Scene_Map  
    $scene = Scene_Map.new
    end
  end
end
#==============================================================================
# ** End of Class Alias
#==============================================================================
#==============================================================================
# ** Game_Actor(New Method)
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
#----------------------------------------------------------------------------
# * New Method(s) : repel?
#----------------------------------------------------------------------------

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Include Puppeto::Repel modules
  #--------------------------------------------------------------------------  
  include Puppeto::Repel
  #--------------------------------------------------------------------------
  # * Determine if repel note is included
  #--------------------------------------------------------------------------
  def repel?
    # Browse through all state in states
    states.each do |state|
      # Return true if Repel_Text is included in the state's note
      return true if state.note.include?(Repel_Text)
    end
    return false
  end
end
#==============================================================================
# ** End of RepelEffect : Script
#==============================================================================


Customization

Line 67, 73, 81. Change the value there if you want.


Compatibility

Should be compatible with other script, since it was aliased properly(no rewrite method)


Screenshot


Notification when repel effect is activated


데모

State setup...


item setup...


Skill setup...




DEMO

DEMO

Comment '1'
  • ?
    제이슨 2009.01.31 18:36
    랜덤으로 적과 조우하는거 100걸음 무효하는거...
    포켓몬스터 벌레스프레이랑 똑같은거네요...

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
97 스킬 미완성 구버전. 2칸 위에 있는 글을 이용해주세요. 7 Last H 2009.02.23 1925
96 기타 Etude87_GAGA_Chat 4 습작 2012.06.14 1916
95 전투 GTBS for 2d_iso_x3 by Clarabel 2 습작 2013.05.13 1879
94 기타 장애물을 피하고 다가오게 하는 스크립트 5 file 박력남 2014.02.25 1877
93 파티 파티원의 첫번째 멤버로 추가하기 5 허걱 2012.12.04 1865
92 장비 Equipment Set Bonus 6 Man... 2008.10.25 1849
91 타이틀/게임오버 New Title Screen 3 Man... 2008.10.28 1832
90 ES Character Info 6 file RPGbooster 2008.10.08 1824
89 기타 KGC counter 스크립트. 반격기 추가스크립트입니다. 4 우켈킁 2011.03.31 1812
88 제작도구 Windowskin generator VX by Aindra and Woratana 1 file Alkaid 2010.09.18 1791
87 Limit Break VX 3 Man... 2008.10.28 1777
86 메시지 Etude87_Item_Choice ver.1.00 file 습작 2013.02.16 1771
85 스킬 SW_BookSkill && EchantScroll(상호충돌수정버전) 6 시옷전사 2011.08.22 1758
84 기타 배틀신에서 곡 넘기기 2 rukan 2009.07.02 1757
» Repel Effect 1 Man... 2008.10.28 1753
82 엄청 좋음(DEMO)클릭 하이퍼링크 걸려있음(누가 변혁좀 해 줬으면...) 4 Man... 2008.10.27 1745
81 기타 Wora's Christmas Giftbox 2008 4 file Alkaid 2010.09.18 1744
80 Direction Movement Style 4 Man... 2008.10.28 1719
79 이동 및 탈것 이동 기능 파워업 (장애물 등을 피하는 이동방식) 8 file 파노 2014.04.27 1716
78 타이틀/게임오버 코아 코스튬씨의 랜덤 타이틀 스크립트를 VX용으로 변환 2 Alkaid 2012.09.14 1701
Board Pagination Prev 1 ... 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Next
/ 32