SHARE
TWEET

SowS Exclude Player

a guest Jun 1st, 2012 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # Exclude Player in Party V1.0
  3. #   by SowS - 06/12/10
  4. #------------------------------------------------------------------------------
  5. # Instructions:
  6. #   Put the script under Materials section of your script editor.
  7. #   Set up the player charsheet, index and name.
  8. #   #--------------------------------------------------------------------------
  9. #   Using \N[ID] doesn't show the player name.
  10. #   To show player's name in messages, use "\P" instead(without the quotes).
  11. #   #--------------------------------------------------------------------------
  12. #   To change the player's charsheet, index, etc., do a script call:
  13. #     # for the name
  14. #       $game_player.name = "New Name"  
  15. #     # for the charsheet
  16. #       $game_player.character_name = "New Charsheet"
  17. #     # for the charsheet index
  18. #       $game_player.character_index = New_Charsheet_Index
  19. #     # for the face name
  20. #       $game_player.face_name = "New Faceset"
  21. #     # for the faceset index
  22. #       $game_player.face_index = New_Face_Index
  23. #   #--------------------------------------------------------------------------
  24. #   If you want to use do name input for the player's name, do a script call:
  25. #     $game_temp.name_max_char = 10    # change 10 to the max char you like.
  26. #     $scene = Scene_PlayerName.new
  27. #==============================================================================
  28.  
  29. module SOWS
  30.   #----------------------------------------------------------------------------
  31.   # start of config
  32.   #----------------------------------------------------------------------------
  33.   # switch to hide player character
  34.   PLAYER_SWITCH = 3 # turn it on to hide
  35.   # filename of the player character
  36.   PLAYER_CHAR_SPRITE = "$rsz_ethan_purple"
  37.   # change this if you're not using a single charsheet
  38.   PLAYER_CHAR_INDEX = 0
  39.   # filename of player face
  40.   PLAYER_FACE = "Actor2"
  41.   # change this if you're not using a single faceset
  42.   PLAYER_FACE_INDEX = 0
  43.   # player name
  44.   PLAYER_NAME = "SowS"
  45.   #----------------------------------------------------------------------------
  46.   # end of config
  47.   #----------------------------------------------------------------------------
  48. end
  49. #==============================================================================
  50. # ** Game_Player
  51. #------------------------------------------------------------------------------
  52. #  This class handles maps. It includes event starting determinants and map
  53. # scrolling functions. The instance of this class is referenced by $game_map.
  54. #==============================================================================
  55.  
  56. class Game_Player < Game_Character
  57.   include SOWS
  58.   #--------------------------------------------------------------------------
  59.   # * Public Instance Variables
  60.   #--------------------------------------------------------------------------
  61.   attr_accessor :name
  62.   attr_accessor :character_name
  63.   attr_accessor :character_index
  64.   attr_accessor :face_name
  65.   attr_accessor :face_index
  66.   #--------------------------------------------------------------------------
  67.   # * Refresh
  68.   #--------------------------------------------------------------------------
  69.   def refresh
  70.     if $game_switches[PLAYER_SWITCH]
  71.       @character_name = ""
  72.       @character_index = 0
  73.     else
  74.       @character_name = PLAYER_CHAR_SPRITE
  75.       @character_index = PLAYER_CHAR_INDEX
  76.       @name = PLAYER_NAME
  77.       @face_name = PLAYER_FACE
  78.       @face_index = PLAYER_FACE_INDEX
  79.     end
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Increase Steps
  83.   #--------------------------------------------------------------------------
  84.   def increase_steps
  85.     super
  86.     return if @move_route_forcing
  87.     return if in_vehicle?
  88.     $game_party.increase_steps
  89.     $game_party.on_player_walk if $game_party.members.size > 0
  90.   end
  91. end
  92.  
  93. #==============================================================================
  94. # ** Window_Message
  95. #------------------------------------------------------------------------------
  96. #  This message window is used to display text.
  97. #==============================================================================
  98.  
  99. class Window_Message < Window_Selectable
  100.   #--------------------------------------------------------------------------
  101.   # * Method Aliasing
  102.   #--------------------------------------------------------------------------
  103.   alias sows_convert_special_characters convert_special_characters unless $@
  104.   #--------------------------------------------------------------------------
  105.   # * Convert Special Characters
  106.   #--------------------------------------------------------------------------
  107.   def convert_special_characters
  108.     sows_convert_special_characters
  109.     @text.gsub!(/(\\P)/i)           { $game_player.name }
  110.   end
  111. end
  112.  
  113. #==============================================================================
  114. # ** Window_PlayerNameEdit
  115. #------------------------------------------------------------------------------
  116. #  This window is used to edit an actor's name on the name input screen.
  117. #==============================================================================
  118.  
  119. class Window_PlayerNameEdit < Window_Base
  120.   #--------------------------------------------------------------------------
  121.   # * Public Instance Variables
  122.   #--------------------------------------------------------------------------
  123.   attr_reader   :name                     # name
  124.   attr_reader   :index                    # cursor position
  125.   attr_reader   :max_char                 # maximum number of characters
  126.   #--------------------------------------------------------------------------
  127.   # * Object Initialization
  128.   #     actor    : actor
  129.   #     max_char : maximum number of characters
  130.   #--------------------------------------------------------------------------
  131.   def initialize(max_char)
  132.     super(88, 20, 368, 128)
  133.     @name = $game_player.name
  134.     @max_char = max_char
  135.     name_array = @name.split(//)[0...@max_char]   # Fit within max length
  136.     @name = ""
  137.     for i in 0...name_array.size
  138.       @name += name_array[i]
  139.     end
  140.     @default_name = @name
  141.     @index = name_array.size
  142.     self.active = false
  143.     refresh
  144.     update_cursor
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Return to Default Name
  148.   #--------------------------------------------------------------------------
  149.   def restore_default
  150.     @name = @default_name
  151.     @index = @name.split(//).size
  152.     refresh
  153.     update_cursor
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # * Add Text Character
  157.   #     character : text character to be added
  158.   #--------------------------------------------------------------------------
  159.   def add(character)
  160.     if @index < @max_char and character != ""
  161.       @name += character
  162.       @index += 1
  163.       refresh
  164.       update_cursor
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * Delete Text Character
  169.   #--------------------------------------------------------------------------
  170.   def back
  171.     if @index > 0
  172.       name_array = @name.split(//)          # Delete one character
  173.       @name = ""
  174.       for i in 0...name_array.size-1
  175.         @name += name_array[i]
  176.       end
  177.       @index -= 1
  178.       refresh
  179.       update_cursor
  180.     end
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Get rectangle for displaying items
  184.   #     index : item number
  185.   #--------------------------------------------------------------------------
  186.   def item_rect(index)
  187.     rect = Rect.new(0, 0, 0, 0)
  188.     rect.x = 220 - (@max_char + 1) * 12 + index * 24
  189.     rect.y = 36
  190.     rect.width = 24
  191.     rect.height = WLH
  192.     return rect
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Refresh
  196.   #--------------------------------------------------------------------------
  197.   def refresh
  198.     self.contents.clear
  199.     draw_actor_face(@actor, 0, 0)
  200.     name_array = @name.split(//)
  201.     for i in 0...@max_char
  202.       c = name_array[i]
  203.       c = '_' if c == nil
  204.       self.contents.draw_text(item_rect(i), c, 1)
  205.     end
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # * Update cursor
  209.   #--------------------------------------------------------------------------
  210.   def update_cursor
  211.     self.cursor_rect = item_rect(@index)
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * Frame Update
  215.   #--------------------------------------------------------------------------
  216.   def update
  217.     super
  218.     update_cursor
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # * Draw Actor Face Graphic
  222.   #     actor : actor
  223.   #     x     : draw spot x-coordinate
  224.   #     y     : draw spot y-coordinate
  225.   #     size  : Display size
  226.   #--------------------------------------------------------------------------
  227.   def draw_actor_face(actor, x, y, size = 96)
  228.     draw_face($game_player.face_name, $game_player.face_index, x, y, size)
  229.   end
  230. end
  231.  
  232.  
  233. #==============================================================================
  234. # ** Scene_PlayerName
  235. #------------------------------------------------------------------------------
  236. #  This class performs player name input screen processing.
  237. #==============================================================================
  238.  
  239. class Scene_PlayerName < Scene_Base
  240.   #--------------------------------------------------------------------------
  241.   # * Start processing
  242.   #--------------------------------------------------------------------------
  243.   def start
  244.     super
  245.     create_menu_background
  246.     @edit_window = Window_PlayerNameEdit.new($game_temp.name_max_char)
  247.     @input_window = Window_NameInput.new
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * Termination Processing
  251.   #--------------------------------------------------------------------------
  252.   def terminate
  253.     super
  254.     dispose_menu_background
  255.     @edit_window.dispose
  256.     @input_window.dispose
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # * Return to Original Screen
  260.   #--------------------------------------------------------------------------
  261.   def return_scene
  262.     $scene = Scene_Map.new
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # * Frame Update
  266.   #--------------------------------------------------------------------------
  267.   def update
  268.     super
  269.     update_menu_background
  270.     @edit_window.update
  271.     @input_window.update
  272.     if Input.repeat?(Input::B)
  273.       if @edit_window.index > 0             # Not at the left edge
  274.         Sound.play_cancel
  275.         @edit_window.back
  276.       end
  277.     elsif Input.trigger?(Input::C)
  278.       if @input_window.is_decision          # If cursor is positioned on [OK]
  279.         if @edit_window.name == ""          # If name is empty
  280.           @edit_window.restore_default      # Return to default name
  281.           if @edit_window.name == ""
  282.             Sound.play_buzzer
  283.           else
  284.             Sound.play_decision
  285.           end
  286.         else
  287.           Sound.play_decision
  288.           $game_player.name = @edit_window.name   # Change player name
  289.           return_scene
  290.         end
  291.       elsif @input_window.character != ""   # If text characters are not empty
  292.         if @edit_window.index == @edit_window.max_char    # at the right edge
  293.           Sound.play_buzzer
  294.         else
  295.           Sound.play_decision
  296.           @edit_window.add(@input_window.character)       # Add text character
  297.         end
  298.       end
  299.     end
  300.   end
  301. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top