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
437 상태/속성 상태 메뉴 변경 스크립트 45 죄송해욧! 2008.03.01 4284
436 상점 상점의 자세한 표시 32 file RPGbooster 2008.10.11 4008
435 상점 상점을 색다르게 바꿔주는 스크립트 34 file 할렘 2009.02.02 6301
434 상점 상점에서 아이템 분류 5 file 파이어 2011.01.23 3510
433 상점 상점 할인 스크립트(변수를 이용한 물건 가격 조정) 9 달표범 2009.09.04 3185
432 상점 상점 아이템 목록 정리 14 정의로운녀석 2008.07.22 3771
431 상점 상점 무기, 방어구 능력치 비교 스크립트! 18 불독 2008.12.25 3611
430 기타 사이드뷰배틀에서 찌르기 공격 가능하게(Upgrade!) 6 078656577er 2009.10.15 2838
429 전투 사이드뷰배틀에서 찌르기 공격 가능하게 7 078656577er 2009.09.16 3223
428 전투 사이드뷰배틀에서 시각적으로 위치 지정하기 9 file 078656577er 2009.10.14 4910
427 전투 사이드뷰배틀3.3 + ATB1.1 스크립트. 65 할렘 2009.02.01 10946
426 전투 사이드뷰 애드온 7 비극ㆍ 2010.08.21 6758
425 전투 사이드뷰 스크립트 [2003 전투 방식] 39 아방스 2008.03.09 8406
424 전투 사이드 뷰 시스템 [시트르산님 제공] 56 아방스 2010.11.29 7499
423 오디오 사운드테스트 스크립트 13 file 카르와푸딩의아틀리에 2009.08.19 2106
422 오디오 사운드 자동 변환 설정 rukan 2009.07.01 1461
421 빠른 스킬사용 6 file RPGbooster 2008.10.08 2814
420 기타 빛 이펙트 71 file DEVIL<Li Patanis Roni Kraudus> 2008.06.06 5861
419 기타 블록 미니게임 11 file 사람이라면? 2010.08.15 2269
418 기타 블랙잭, 룰렛, 포커 스크립트 종합 9 file 도심 2010.08.22 2643
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