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 5408
637 스킬 훔치기 스킬을 만드는 스크립트! 5 우켈킁 2011.03.31 2390
636 기타 회피,명중,크리 스테이트를 작성하는 스크립트 9 카르와푸딩의아틀리에 2009.06.30 2394
635 기타 확장 에러 메시지 13 file 허걱 2009.08.17 2497
634 메뉴 확장 스테이터스 화면 - KGC 23 file 카르와푸딩의아틀리에 2009.08.19 5057
633 기타 화폐단위 구분해 주는 스크립트 38 file 허걱 2010.04.13 3652
632 이동 및 탈것 화면의 부드러운 스크롤 스크립트 32 카르와푸딩의아틀리에 2009.07.17 3821
631 기타 화면에 그림 그리는 스크립트 21 file 강진수 2010.02.27 2962
630 기타 화면 확대 스크립트 12 file 에돌이 2011.07.22 3061
629 기타 화면 해상도(640 X 480) 스크립트 6 file 쿠쿠밥솥 2012.01.10 3972
628 아이템 현재있는 파티원 선택 레벨업 아이템 만들기 1 file 싸패 2016.06.06 713
627 헬프윈도우 확장 13 file RPGbooster 2008.10.08 2872
626 메뉴 헬프 윈도우 중앙표시 스크립트 11 file 양념통닼 2008.06.10 3348
625 키입력 해외 제작자 He Who Jets님의 마우스 스크립트(mouse system) 1 file 보자기군 2014.09.30 1261
624 기타 해상도 변경 스크립트 11 카리스 2011.07.19 2723
623 스킬 합성샾 스크립트 ^^ [동영상 포함] 6 file 아방스 2008.09.23 6038
622 키입력 한글입력기(펌) 수정 10 전설의달빛조각사 2011.04.03 2674
621 이름입력 한글로 이름 입력하는 스크립트입니다. 55 file 헤르코스 2009.03.18 6662
620 이름입력 한글 이름 입력 스크립트입니다.^^ 14 레시온 2008.03.18 4383
619 액터 한계돌파(렙9999) 18 작은샛별 2010.03.07 3273
618 이동 및 탈것 피티원이 따라다니는 스크립트 38 file 아방스 2009.02.05 5024
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32