vindaca510

Xpanded Event Control v0.3

Aug 4th, 2014
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.03 KB | None | 0 0
  1.  
  2. ################################################################################
  3. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  4. #↓                                                                            ↓#
  5. #↓                     Xpanded Event Control: Version 0.3                     ↓#
  6. #↓                                                                            ↓#
  7. #↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕#
  8. #↑                                                                            ↑#
  9. #↑                            Written By: Joe Pro                             ↑#
  10. #↑                        Last Edited: August 3, 2014                         ↑#
  11. #↑                                                                            ↑#
  12. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  13. ################################################################################
  14.  
  15. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  16. #◙ ** Disclaimer                                                              ◙#
  17. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  18. #◙                                                                            ◙#
  19. #◙ This script is not for commercial, if you wish to use this script in a     ◙#
  20. #◙ game please PM me. All credit is to be given to me as the author of this   ◙#
  21. #◙ script.                                                                    ◙#
  22. #◙                                                                            ◙#
  23. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  24. #◙ ** How To Use                                                              ◙#
  25. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  26. #◙                                                                            ◙#
  27. #◙ * Use the following comment once anywhere in an event's page.              ◙#
  28. #◙                                                                            ◙#
  29. #◙    distance: x                                                             ◙#
  30. #◙                                                                            ◙#
  31. #◙                                                                            ◙#
  32. #◙                                                                            ◙#
  33. #◙ * Use the example below in an event script call to refer to the current    ◙#
  34. #◙   event. Works like a self ( or the method get_charactor(0) )for scripting ◙#
  35. #◙   within an event.                                                         ◙#
  36. #◙                                                                            ◙#
  37. #◙    event_self                                                              ◙#
  38. #◙                                                                            ◙#
  39. #◙ * Use the example below in an event script call to find the proximity of   ◙#
  40. #◙   the current event to the player.                                         ◙#
  41. #◙                                                                            ◙#
  42. #◙    proximity?                                                              ◙#
  43. #◙                                                                            ◙#
  44. #◙ * Use the example below in an event script call to find if the current     ◙#
  45. #◙   event can see the player.                                                ◙#
  46. #◙                                                                            ◙#
  47. #◙    viewable?                                                               ◙#
  48. #◙                                                                            ◙#
  49. #◙ * Use the example below in an event script call to find the direction of   ◙#
  50. #◙   the player from the event.                                               ◙#
  51. #◙                                                                            ◙#
  52. #◙    player_direction                                                        ◙#
  53. #◙                                                                            ◙#
  54. #◙ * Use the example below in an event script call to find the oppisite       ◙#
  55. #◙   direction the is facing event.                                           ◙#
  56. #◙                                                                            ◙#
  57. #◙    oppisite_direction                                                      ◙#
  58. #◙                                                                            ◙#
  59. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  60. #◙ ** Updates / Version Notes                                                 ◙#
  61. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  62. #◙                                                                            ◙#
  63. #◙   v0.1                                                                     ◙#
  64. #◙ ~◄◙◙◙◙►~                                                                   ◙#
  65. #◙ * This script adds more checks and methods for interactions between the    ◙#
  66. #◙   game player and events. It currently allows for proximity checks and     ◙#
  67. #◙   and a line of sight system.                                              ◙#
  68. #◙                                                                            ◙#
  69. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  70.  
  71.  
  72.  
  73. ################################################################################
  74. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  75. #↓                                                                            ↓#
  76. #↓                      Keep EXP Save Spots: Version 0.1                      ↓#
  77. #↑                                                                            ↑#
  78. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  79. ################################################################################
  80.  
  81.  
  82.  
  83. #==============================================================================
  84. # ** Xpanded Event Control Module
  85. #------------------------------------------------------------------------------
  86. #  This module manages the customizable and function modules.
  87. #==============================================================================
  88. module Xpanded_Event_Control
  89.  
  90.  
  91.  
  92. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  93. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  94. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙Customizeable Area◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  95. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  96. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  97.  
  98.   #=============================================================================
  99.   # * Default Distance an Event can see.
  100.   #=============================================================================
  101.     Default_Distance = 8
  102.  
  103. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  104. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  105. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙End Customizeable Area◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  106. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  107. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  108.  
  109.  
  110.  
  111. end
  112.  
  113.  
  114. #==============================================================================
  115. # ** Game_Character
  116. #------------------------------------------------------------------------------
  117. #  A character class with mainly movement route and other such processing
  118. # added. It is used as a super class of Game_Player, Game_Follower,
  119. # GameVehicle, and Game_Event.
  120. #==============================================================================
  121.  
  122. class Game_Character < Game_CharacterBase
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # * Public Instance Variables
  126.   #--------------------------------------------------------------------------
  127.   attr_accessor  :wait_time               # forced move route flag
  128.  
  129.   #--------------------------------------------------------------------------
  130.   # * Aliasing_method: Initialize Public Member Variables
  131.   #--------------------------------------------------------------------------
  132.   alias :gcipv32104506450 :init_public_members
  133.    
  134.   #--------------------------------------------------------------------------
  135.   # * Initialize Public Member Variables
  136.   #--------------------------------------------------------------------------
  137.   def init_public_members
  138.     gcipv32104506450()
  139.     @wait_time = 0
  140.   end
  141.  
  142. end
  143.  
  144.  
  145. #==============================================================================
  146. # ** Game_Event
  147. #------------------------------------------------------------------------------
  148. #  This class handles events. Functions include event page switching via
  149. # condition determinants and running parallel process events. Used within the
  150. # Game_Map class.
  151. #==============================================================================
  152.  
  153. class Game_Event < Game_Character
  154.  
  155.   #--------------------------------------------------------------------------
  156.   # * Aliasing_method: Move Type : Random
  157.   #--------------------------------------------------------------------------
  158.   alias :gemtr0401000004564 :move_type_random
  159.    
  160.   #--------------------------------------------------------------------------
  161.   # * Move Type : Random
  162.   #--------------------------------------------------------------------------
  163.   def move_type_random
  164.     if self.wait_time > 0
  165.       self.wait_time -= 1
  166.     else
  167.       gemtr0401000004564()
  168.       self.wait_time = (rand(240) + 60) if rand(6) == 1
  169.     end
  170.   end
  171.  
  172.   #--------------------------------------------------------------------------
  173.   # * Move Type : Approach
  174.   #--------------------------------------------------------------------------
  175.   def move_type_toward_player
  176.     if near_the_player?
  177.       move_toward_player
  178.     else
  179.       move_random
  180.     end
  181.   end
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # * Determine if Player is Within Proximity
  185.   #--------------------------------------------------------------------------
  186.   def proximity_to_player?
  187.     return (x_proximity_to_player? + y_proximity_to_player?)
  188.   end
  189.  
  190.   #--------------------------------------------------------------------------
  191.   # * Determine if Player is Within X Proximity
  192.   #--------------------------------------------------------------------------
  193.   def x_proximity_to_player?
  194.     return (self.x > $game_player.x) ? self.x - $game_player.x : $game_player.x - self.x
  195.   end
  196.  
  197.   #--------------------------------------------------------------------------
  198.   # * Determine if Player is Within Y Proximity
  199.   #--------------------------------------------------------------------------
  200.   def y_proximity_to_player?
  201.     return (self.y > $game_player.y) ? self.y - $game_player.y : $game_player.y - self.y
  202.   end
  203.  
  204.   #--------------------------------------------------------------------------
  205.   # * Returns the Direction of the Player From This Event
  206.   #--------------------------------------------------------------------------
  207.   def oppisite_direction
  208.     case @direction
  209.     when 2
  210.       return 8
  211.     when 4
  212.       return 6
  213.     when 6
  214.       return 4
  215.     when 8
  216.       return 2
  217.     end
  218.   end
  219.  
  220.   #--------------------------------------------------------------------------
  221.   # * Returns the Direction of the Player From This Event
  222.   #--------------------------------------------------------------------------
  223.   def player_direction
  224.     return (x_proximity_to_player? > y_proximity_to_player? ? (self.x > $game_player.x ? 4 : 6) : (self.y > $game_player.y ? 8 : 2))
  225.   end
  226.  
  227.   #------------------------------------------------------------------------
  228.   # * Return All Comments
  229.   #------------------------------------------------------------------------
  230.   def return_all_comments
  231.     comments = []
  232.     @list.each { |command| comments.push command.parameters[0] if command.code == 108 } if @list
  233.     return comments
  234.   end  
  235.  
  236.   #--------------------------------------------------------------------------
  237.   # * Distance Viewable
  238.   #--------------------------------------------------------------------------
  239.   def distance
  240.     comments = return_all_comments
  241.     comments.each { |comment|
  242.       comment.scan(/distance:\s*(\d*)/im)
  243.       return $1.to_i if $1
  244.     }
  245.     return Xpanded_Event_Control::Default_Distance
  246.   end
  247.  
  248.   #--------------------------------------------------------------------------
  249.   # * Determine if Player is Within Line of Sight.
  250.   #--------------------------------------------------------------------------
  251.   def line_of_sight?
  252.     return (player_direction != oppisite_direction)
  253.   end
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # * Determine if Player is Within View Without Obstruction
  257.   #--------------------------------------------------------------------------
  258.   def viewable?
  259.     viewable = true
  260.     ex = self.x
  261.     ey = self.y
  262.     px = $game_player.x
  263.     py = $game_player.y
  264.   #---------------------------------------------------------#
  265.   # * Checking if the Player is in the Events Line of Sight #
  266.   #---------------------------------------------------------#
  267.     if line_of_sight?
  268.   #------------------------------------------#
  269.   # * Checking if Within Proximity of Player #
  270.   #------------------------------------------#
  271.       if distance > proximity_to_player?
  272.   #---------------------------------#
  273.   # * Checking for any Obstructions #
  274.   #---------------------------------#
  275.         y_proximity_to_player?.times { |y|
  276.           x_proximity_to_player?.times { |x|
  277.             case
  278.             when (ex < px)
  279.               if (ey < py)
  280.                 viewable = false if !$game_map.passable?((ex + x), (ey + y), @direction)
  281.               else
  282.                 viewable = false if !$game_map.passable?((ex + x), (ey - y), @direction)
  283.               end
  284.             when (ex > px)
  285.               if (ey < py)
  286.                 viewable = false if !$game_map.passable?((ex - x), (ey + y), @direction)
  287.               else
  288.                 viewable = false if !$game_map.passable?((ex - x), (ey - y), @direction)
  289.               end
  290.             end
  291.           }
  292.         }
  293.   #----------------------------------------------------------------#
  294.   # * Checking for any Obstructions if y_proximity_to_player? == 0 #
  295.   #----------------------------------------------------------------#
  296.         x_proximity_to_player?.times { |x|
  297.           case
  298.           when (ex < px)
  299.             viewable = false if !$game_map.passable?((ex + x), ey, @direction)
  300.           when (ex > px)
  301.             viewable = false if !$game_map.passable?((ex - x), ey, @direction)
  302.           end
  303.           } if y_proximity_to_player? == 0
  304.   #----------------------------------------------------------------#
  305.   # * Checking for any Obstructions if x_proximity_to_player? == 0 #
  306.   #----------------------------------------------------------------#
  307.         y_proximity_to_player?.times { |y|
  308.           case
  309.           when (ey < py)
  310.             viewable = false if !$game_map.passable?(ex, (ey - y), @direction)
  311.           when (ey > py)
  312.             viewable = false if !$game_map.passable?(ex, (ey + y), @direction)
  313.           end
  314.           } if x_proximity_to_player? == 0
  315.   #---------------------------------------------------#
  316.   # * Returns false if distance < proximity_to_player?#
  317.   #---------------------------------------------------#
  318.       else
  319.         viewable = false
  320.       end
  321.   #------------------------------------#
  322.   # * Returns false if !line_of_sight? #
  323.   #------------------------------------#
  324.     else
  325.       viewable = false
  326.     end
  327.     return viewable
  328.   end
  329.  
  330. end
  331.  
  332.  
  333. #==============================================================================
  334. # ** Game_Interpreter
  335. #------------------------------------------------------------------------------
  336. #  An interpreter for executing event commands. This class is used within the
  337. # Game_Map, Game_Troop, and Game_Event classes.
  338. #==============================================================================
  339.  
  340. class Game_Interpreter
  341.  
  342.   #--------------------------------------------------------------------------
  343.   # * Get the Proximity of Event to Player
  344.   #--------------------------------------------------------------------------
  345.   def proximity?
  346.     get_character(0).proximity_to_player?
  347.   end
  348.  
  349.   #--------------------------------------------------------------------------
  350.   # * Get the Direction of the Player From This Event
  351.   #--------------------------------------------------------------------------
  352.   def player_direction
  353.     get_character(0).player_direction
  354.   end
  355.  
  356.   #--------------------------------------------------------------------------
  357.   # * Get the Direction of the Player From This Event
  358.   #--------------------------------------------------------------------------
  359.   def oppisite_direction
  360.     get_character(0).oppisite_direction
  361.   end
  362.  
  363.   #--------------------------------------------------------------------------
  364.   # * Get the Direction of the Player From This Event
  365.   #--------------------------------------------------------------------------
  366.   def viewable?
  367.     get_character(0).viewable?
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # * Returns Current Event
  372.   #--------------------------------------------------------------------------
  373.   def event_self
  374.     get_character(0)
  375.   end
  376.  
  377. end
Advertisement
Add Comment
Please, Sign In to add comment