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
477 기타 책 읽기 스크립트. 19 허걱 2009.01.31 4490
476 전투 sbs battler configuration 한글 번역 13 file 시트르산 2010.09.23 4475
475 레벨업 할경우 hp/mp 등을 채워주는 스크립트 49 아방스 2008.09.09 4473
474 장비 Rei(레이)의 Paperdoll(비쥬얼 장비)스크립트 20 file 루시페르 2009.07.29 4467
473 이동 및 탈것 VX 기차 스크립트 28 아방스 2009.01.13 4467
472 기타 태양 스크립트. 15 file 할렘 2009.02.20 4463
471 기타 로딩중 스크립트 24 file NO.0 2009.07.11 4462
470 전투 GTBS 1.5.1.4 - GubiD's Tactical Battle System 10 아방스 2010.12.11 4451
469 저장 [퍼옴] Neo_Save_System ver.1.0 10 레오 2008.06.14 4451
468 제작도구 게임제작에 필수인 테스트 플레이 고속화 스크립트! ! ! ! 25 양념통닼 2008.05.30 4445
467 HUD 아이콘 그리기 7 file 허걱 2009.08.20 4442
466 타이틀/게임오버 [자작] 타이틀 화면 없이 게임을 시작하자! Title Skiper 29 케류 2009.04.05 4423
465 기타 글씨표시 스크립트 32 file 허걱 2009.08.10 4421
464 메시지 조합한글 21 file 허걱 2009.06.27 4410
463 맵/타일 ◆ 타일 세트 확장 스크립트 [업데이트 수정] 24 file 아방이 2008.01.30 4386
462 이름입력 한글 이름 입력 스크립트입니다.^^ 14 레시온 2008.03.18 4383
461 스킬 [ultimate series]스킬,아이템 데미지계산식을 자기입맛에 맞게 고치는 스크립트 16 file EuclidE 2010.05.04 4373
460 맵/타일 타일셋 변경 10 file 만들어보자꾸나 2008.06.08 4370
459 HUD 맵 이름 스크립트 21 file 개임맨 2010.10.03 4365
458 메시지 직접 생각해서 만든 "문장 속 특정 단어 색 바꾸기" 10 file X.66 2010.04.28 4363
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