How to make an enemy stand still until it sees, hears or percieves the player?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Quote from: Taiine on October 15, 2010, 11:43:35 pm
Additionally, did something change in the last build? When I add the branches to check if an arrow key is also being pressed before it starts doing the drain (so you don't drain energy while standing in place) I get
thats with using call script
Input.pressed?(Input::Key['Arrow Up'])
and so on. But it gives that error. It use to work! I have a demo of another game that uses the last version of the battle system and it also uses the same means and it don't throw an error back.
#==============================================================================
# Diablo 2 Waypoints
# by arevulopapo
# Feb 9th 2007
#
#
# To call the Waypoint scene use the "Call script" event command:
# $scene = Scene_Waypoint.new(parameter)
# where 'parameter' is the index of the waypoint you're using.
#
# If you want to activate a waypoint without "touching" it
# call a script like this:
# $game_system.waypoints_active << index
# where 'index' is the index of the waypoint you want to activate.
#
# See the comments in the Game_System section (right below)
# for informations on how to customize.
#
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
attr_accessor :waypoints
attr_accessor :waypoints_active
attr_accessor :waypoint_sound
#--------------------------------------------------------------------------
alias game_system_initialize initialize
#--------------------------------------------------------------------------
def initialize
#--------------------------------------------------------------------------
# Here you can change the sound played while teleporting
#--------------------------------------------------------------------------
@waypoint_sound = "Audio/SE/020-Teleport03"
#--------------------------------------------------------------------------
@waypoints = []
#--------------------------------------------------------------------------
# Here you add new waypoints. The formula is like this
# ["Name", map_id, player_x, player_y]
#--------------------------------------------------------------------------
@waypoints << ["Drasgora", 5, 143, 76] # This is the first waypoint. Its index is 0
@waypoints << ["Admin Hideout", 4, 13, 14] # This is the second waypoint. Its index is 1
@waypoints << ["Train Ground", 14, 24, 18] # 2, monster testing zone
#--------------------------------------------------------------------------
@waypoints_active = []
game_system_initialize
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Window_Waypoint_Name < Window_Base
#--------------------------------------------------------------------------
def initialize(waypoint_name)
super(0,0,320,64)
self.contents = Bitmap.new(288,32)
self.back_opacity = 160
@waypoint_name = waypoint_name
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(0,0,288,32,@waypoint_name.to_s,1)
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Window_Waypoint_List < Window_Selectable
#--------------------------------------------------------------------------
def initialize
super(0, 64, 320, 416)
self.back_opacity = 160
refresh
self.index = 0
end
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = $game_system.waypoints.size
self.contents = Bitmap.new(288, @item_max * 32)
for i in 0..@item_max - 1
draw_item(i)
end
end
#--------------------------------------------------------------------------
def draw_item(index)
x = 0
y = (index) * 32
if $game_system.waypoints_active.include?(index)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
self.contents.draw_text(x, y, 288, 32, $game_system.waypoints[index][0].to_s, 1)
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Scene_Waypoint
#--------------------------------------------------------------------------
def initialize(waypoint)
@waypoint = waypoint
$game_system.waypoints_active << @waypoint unless $game_system.waypoints_active.include?(@waypoint)
end
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@name_window = Window_Waypoint_Name.new($game_system.waypoints[@waypoint][0])
@list = Window_Waypoint_List.new
if $game_player.screen_x < 320
@name_window.x = 320
@list.x = 320
end
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@name_window.dispose
@list.dispose
end
#--------------------------------------------------------------------------
def update
@list.update
if Input.trigger?(Input::C)
if $game_system.waypoints_active.include?(@list.index)
Audio.se_play($game_system.waypoint_sound)
$game_screen.start_flash(Color.new(255,255,255,160), 5)
$game_map.setup($game_system.waypoints[@list.index][1])
$game_player.moveto($game_system.waypoints[@list.index][2], $game_system.waypoints[@list.index][3])
$game_player.straighten
$game_map.update
$game_map.autoplay
$scene = Scene_Map.new
Graphics.transition(20)
else
$game_system.se_play($data_system.buzzer_se)
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
end
module RMXOS
module Options
SAVE_DATA[Game_System].push('@waypoints_active')
end
end
Script 'Waypoints'line 107: NoMethodError occured.
undefined method 'include?' for nil:NilClass