[Joe Pro] Xpanded Event Control
class Xpanded Event Commands(version 0.3)
defInitialize:
Adds more functionallity and commands to events.
end
defFeatures:
[*]Proximity System
[*]Line of Sight System
[*]Define the distance of Sight
[*]Easily find the direction of the player from the event's location.
[*]Easily find the oppisite direction of which an event is facing.
end
defHow to use:
There are new command to be used inside of the events script calls and conditional branches. They can even be assigned to
$game_variables. More details can be found at the top of the scirpt.
end
defScript:
Spoiler#################################################################################↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓##↓ ↓##↓ Xpanded Event Control: Version 0.3 ↓##↓ ↓##↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕##↑ ↑##↑ Written By: Joe Pro ↑##↑ Last Edited: August 3, 2014 ↑##↑ ↑##↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑##################################################################################◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** Disclaimer ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ This script is not for commercial, if you wish to use this script in a ◙##◙ game please PM me. All credit is to be given to me as the author of this ◙##◙ script. ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** How To Use ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ * Use the following comment once anywhere in an event's page. ◙##◙ ◙##◙ distance: x ◙##◙ ◙##◙ ◙##◙ ◙##◙ * Use the example below in an event script call to refer to the current ◙##◙ event. Works like a self ( or the method get_charactor(0) )for scripting ◙##◙ within an event. ◙##◙ ◙##◙ event_self ◙##◙ ◙##◙ * Use the example below in an event script call to find the proximity of ◙##◙ the current event to the player. ◙##◙ ◙##◙ proximity? ◙##◙ ◙##◙ * Use the example below in an event script call to find if the current ◙##◙ event can see the player. ◙##◙ ◙##◙ viewable? ◙##◙ ◙##◙ * Use the example below in an event script call to find the direction of ◙##◙ the player from the event. ◙##◙ ◙##◙ player_direction ◙##◙ ◙##◙ * Use the example below in an event script call to find the oppisite ◙##◙ direction the is facing event. ◙##◙ ◙##◙ oppisite_direction ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** Updates / Version Notes ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ v0.1 ◙##◙ ~◄◙◙◙◙►~ ◙##◙ * This script adds more checks and methods for interactions between the ◙##◙ game player and events. It currently allows for proximity checks and ◙##◙ and a line of sight system. ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##################################################################################↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓##↓ ↓##↓ Keep EXP Save Spots: Version 0.1 ↓##↑ ↑##↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑##################################################################################==============================================================================# ** Xpanded Event Control Module#------------------------------------------------------------------------------#This module manages the customizable and function modules.#==============================================================================module Xpanded_Event_Control #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙Customizeable Area◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##=============================================================================# * Default Distance an Event can see. #============================================================================= Default_Distance = 8#◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙End Customizeable Area◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#end#==============================================================================# ** Game_Character#------------------------------------------------------------------------------#A character class with mainly movement route and other such processing# added. It is used as a super class of Game_Player, Game_Follower,# GameVehicle, and Game_Event.#==============================================================================class Game_Character < Game_CharacterBase#--------------------------------------------------------------------------# * Public Instance Variables#--------------------------------------------------------------------------attr_accessor:wait_time # forced move route flag#--------------------------------------------------------------------------# * Aliasing_method: Initialize Public Member Variables#--------------------------------------------------------------------------alias :gcipv32104506450 :init_public_members #--------------------------------------------------------------------------# * Initialize Public Member Variables#--------------------------------------------------------------------------def init_public_members gcipv32104506450() @wait_time = 0endend#==============================================================================# ** Game_Event#------------------------------------------------------------------------------#This class handles events. Functions include event page switching via# condition determinants and running parallel process events. Used within the# Game_Map class.#==============================================================================class Game_Event < Game_Character#--------------------------------------------------------------------------# * Aliasing_method: Move Type : Random#--------------------------------------------------------------------------alias :gemtr0401000004564 :move_type_random #--------------------------------------------------------------------------# * Move Type : Random#--------------------------------------------------------------------------def move_type_random if self.wait_time > 0 self.wait_time -= 1 else gemtr0401000004564() self.wait_time = (rand(240) + 60) if rand(6) == 1 endend #--------------------------------------------------------------------------# * Move Type : Approach#--------------------------------------------------------------------------def move_type_toward_player if near_the_player? move_toward_player else move_random endend #--------------------------------------------------------------------------# * Determine if Player is Within Proximity#--------------------------------------------------------------------------def proximity_to_player? return (x_proximity_to_player? + y_proximity_to_player?)end #--------------------------------------------------------------------------# * Determine if Player is Within X Proximity#--------------------------------------------------------------------------def x_proximity_to_player? return (self.x > $game_player.x) ? self.x - $game_player.x : $game_player.x - self.xend #--------------------------------------------------------------------------# * Determine if Player is Within Y Proximity#--------------------------------------------------------------------------def y_proximity_to_player? return (self.y > $game_player.y) ? self.y - $game_player.y : $game_player.y - self.yend #--------------------------------------------------------------------------# * Returns the Direction of the Player From This Event#--------------------------------------------------------------------------def oppisite_direction case @direction when 2 return 8 when 4 return 6 when 6 return 4 when 8 return 2 endend #--------------------------------------------------------------------------# * Returns the Direction of the Player From This Event#--------------------------------------------------------------------------def player_direction return (x_proximity_to_player? > y_proximity_to_player? ? (self.x > $game_player.x ? 4 : 6) : (self.y > $game_player.y ? 8 : 2))end #------------------------------------------------------------------------# * Return All Comments#------------------------------------------------------------------------def return_all_comments comments = [] @list.each { |command| comments.push command.parameters if command.code == 108 } if @list return commentsend #--------------------------------------------------------------------------# * Distance Viewable#--------------------------------------------------------------------------def distance comments = return_all_comments comments.each { |comment| comment.scan(/distance:\s*(\d*)/im) return $1.to_i if $1 } return Xpanded_Event_Control:
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7efault_Distanceend #--------------------------------------------------------------------------# * Determine if Player is Within Line of Sight.#--------------------------------------------------------------------------def line_of_sight? return (player_direction != oppisite_direction)end #--------------------------------------------------------------------------# * Determine if Player is Within View Without Obstruction#--------------------------------------------------------------------------def viewable? viewable = true ex = self.x ey = self.y px = $game_player.x py = $game_player.y#---------------------------------------------------------## * Checking if the Player is in the Events Line of Sight ##---------------------------------------------------------# if line_of_sight?#------------------------------------------## * Checking if Within Proximity of Player ##------------------------------------------# if distance > proximity_to_player?#---------------------------------## * Checking for any Obstructions ##---------------------------------# y_proximity_to_player?.times { |y| x_proximity_to_player?.times { |x| case when (ex < px) if (ey < py) viewable = false if !$game_map.passable?((ex + x), (ey + y), @direction) else viewable = false if !$game_map.passable?((ex + x), (ey - y), @direction) end when (ex > px) if (ey < py) viewable = false if !$game_map.passable?((ex - x), (ey + y), @direction) else viewable = false if !$game_map.passable?((ex - x), (ey - y), @direction) end end } }#----------------------------------------------------------------## * Checking for any Obstructions if y_proximity_to_player? == 0 ##----------------------------------------------------------------# x_proximity_to_player?.times { |x| case when (ex < px) viewable = false if !$game_map.passable?((ex + x), ey, @direction) when (ex > px) viewable = false if !$game_map.passable?((ex - x), ey, @direction) end } if y_proximity_to_player? == 0#----------------------------------------------------------------## * Checking for any Obstructions if x_proximity_to_player? == 0 ##----------------------------------------------------------------# y_proximity_to_player?.times { |y| case when (ey < py) viewable = false if !$game_map.passable?(ex, (ey - y), @direction) when (ey > py) viewable = false if !$game_map.passable?(ex, (ey + y), @direction) end } if x_proximity_to_player? == 0#---------------------------------------------------## * Returns false if distance < proximity_to_player?##---------------------------------------------------# else viewable = false end#------------------------------------## * Returns false if !line_of_sight? ##------------------------------------# else viewable = false end return viewableendend#==============================================================================# ** Game_Interpreter#------------------------------------------------------------------------------#An interpreter for executing event commands. This class is used within the# Game_Map, Game_Troop, and Game_Event classes.#==============================================================================class Game_Interpreter#--------------------------------------------------------------------------# * Get the Proximity of Event to Player#--------------------------------------------------------------------------def proximity? get_character(0).proximity_to_player?end#--------------------------------------------------------------------------# * Get the Direction of the Player From This Event#--------------------------------------------------------------------------def player_direction get_character(0).player_directionend#--------------------------------------------------------------------------# * Get the Direction of the Player From This Event#--------------------------------------------------------------------------def oppisite_direction get_character(0).oppisite_directionend#--------------------------------------------------------------------------# * Get the Direction of the Player From This Event#--------------------------------------------------------------------------def viewable? get_character(0).viewable?end#--------------------------------------------------------------------------# * Returns Current Event#--------------------------------------------------------------------------def event_self get_character(0)endend
end
defCredit, Licence & Commercial Usage:
This script is free to use for non-commercial use. If you want to obtain a license to use this script in a commercial game(contests included)
please PM me. Credit is to be give to myself, JoePro.
end
end
本贴来自国际rpgmaker官方论坛作者:JoePro处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/joe-pro-xpanded-event-control.30701/
页:
[1]