Sneaking Enemies

supedaglup

Villager
Member
Joined
Sep 20, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Hello.

I'm trying to make a horror-esque game and I want the enemies to chase you from behind, but run when you are facing them (Kinda like the Boos in Mario). I want this, because the main character uses the flashlight to make them run away. I used Yanfly's chase script to make them chase/run, but unfortunately, they do not chase you from behind, and run when you face them. Is there any way that this can be done?
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
You might want to post the link to Yanfly's Chase Event Right here:

https://github.com/Archeia/YEARepo/blob/master/Field/Event_Chase_Player.rb

Other than that, it could probably be as simple as modifying it to say like if $game_player.direction != $game_map.event.direction then do the chase. But then again, gonna suck cuz that means that the script is only good for that particular enemy, LoL
 

supedaglup

Villager
Member
Joined
Sep 20, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Thank you for replying! This sounds fine, since I only intend for one enemy in game, but where would put that tidbit into the script?
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
Thank you for replying! This sounds fine, since I only intend for one enemy in game, but where would put that tidbit into the script?
No problem maaaaaan! XD

Here replace the code below with this:

#-------------------------------------------------------------------------- # alias method: update_self_movement #-------------------------------------------------------------------------- alias game_event_update_self_movement_ecp update_self_movement def update_self_movement return if $game_map.events[1].direction == $game_player.reverse_dir($game_player.direction) && !@chase_range.nil? return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement update_chase_distance update_flee_distance if @stop_count > 0 && @chase_player move_type_toward_player elsif @stop_count > 0 && @flee_player move_type_away_player else game_event_update_self_movement_ecp end update_alert_balloon end The event will chase only if player is not facing the event. Otherwise it will chase the player if player has his/her back towards the event. I tested it and it works XD
 

supedaglup

Villager
Member
Joined
Sep 20, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Awesome! So I'm guessing that all that's left is to set the movement options, then it will be good?

EDIT: I noticed that they only stop moving when you face the original starting position of the event. Is this intentional, or did I set it up wrong?
 
Last edited by a moderator:
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
It doesn't do that for mine. It does just as u want it for example, u want it to stop chasing u when u face towards the event in which it does. No matter which direction the event is and when u face towards it then it stops chasing u. It does this to my demo and not sure whats causing it to do what u said, try having just yanflys chase script on a new demo project XD

EDIT:

I think I figured out whats ur problem XD

U have to make sure that the event that u have facing is within the distance range.

Make sure u add

@chase_range = XIn the movement route of the event where X is the distance range. Try setting it to @chase_range = 10 and test it. I believe ur issue was that since u got out of range from the event, it stopped chasing. XD
 
Last edited by a moderator:

supedaglup

Villager
Member
Joined
Sep 20, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Ahhh! Okay! That clears up alot  ;)  Thanks for the help man!

Just one last thing, is it possible to make it that they run away from you instead of just stopping, or is that gonna require some super special coding?

(You see, I'm trying to make it that the flashlight kills the enemy on contact, but if they don't run away, then the enemies are just sitting ducks with this flashlight out.)
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
Ugh, u can try this. U might need someone far more advance to take a look at it though just in case its properly done LoL XD

#==============================================================================# # ▼ Yanfly Engine Ace - Event Chase Player v1.00# -- Last Updated: 2012.01.05# -- Level: Normal# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-EventChasePlayer"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.01.05 - Started Script and Finished.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script allows you to make events that will chase the player or flee from# the player when the player enters within range of the event or when the event# sees the player. # #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # -----------------------------------------------------------------------------# Move Script Call - Open up the script call in the event move menu and use:# -----------------------------------------------------------------------------# Add these variable changes to an event's move route to use them.# # @chase_range = x# Event will chase the player after reaching x range.# # @flee_range = x# Event will flee from player after reaching x range.# # @scared_range = x# Event will flee from player after reaching x range.## @chase_speed = x# Event will move at x speed when chasing.# # @flee_speed = x# Event will move at x speed when fleeing.# # @sight_lock = x# Event will chase/flee from player for x frames.# # @alert_balloon = x# Event will show ballon ID x when chasing or fleeing.# # @alert_sound = x# Event will play this sound upon sighting the player ## @see_player = true# For events that require them to see the player first, use this script call# inside the movement boxes. This does not follow line of sight rules, which# means if there's a rock blocking you and the event, it will still see you.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================module YEA module EVENT_CHASE #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - General Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings adjust some general settings regarding chasing and fleeing # events. Adjust them as you see fit. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # The number of frames before a balloon can show up again on the same # event. This is to prevent a massive balloon spamming. 60 frames = 1 sec. # By default, 120 frames is 2 seconds. ALERT_TIMER = 120 # This is the default number of frames for how long the event will chase or # flee from the player if used with @see_player = true. To change the amount # individually for each event, use @sight_lock = x where x is a number. # By default, 300 frames is 5 seconds. SIGHT_LOCK = 300 end # EVENT_CHASEend # YEA#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================#==============================================================================# ■ Game_Event#==============================================================================class Game_Event < Game_Character #-------------------------------------------------------------------------- # alias method: update_self_movement #-------------------------------------------------------------------------- alias for_scared_player_switch_initialize initialize def initialize(map_id, event) for_scared_player_switch_initialize(map_id, event) @call_dis = 0 end alias game_event_update_self_movement_ecp update_self_movement def update_self_movement return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement update_scared_distance if $game_map.events[1].direction == $game_player.reverse_dir($game_player.direction) && see_player? && @call_dis <= 5 #edit this number to match @scared_range @chase_range = 0 move_type_away_player end update_chase_distance update_flee_distance if @stop_count > 0 && @chase_player move_type_toward_player elsif @stop_count > 0 && @flee_player move_type_away_player else game_event_update_self_movement_ecp end update_alert_balloon end #-------------------------------------------------------------------------- # new method: update_chase_distance #-------------------------------------------------------------------------- def update_chase_distance return if @erased return if @chase_range.nil? dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs if chase_conditions @chase_player = true @move_speed = @chase_speed unless @chase_speed.nil? else @chase_player = false @move_speed = @page.move_speed @alert_player = false if @alert_timer <= 0 end end #-------------------------------------------------------------------------- # new method: chase_conditions #-------------------------------------------------------------------------- def chase_conditions dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs return true if @alert_lock > 0 return true if dis <= @chase_range and see_player? if dis <= @chase_range && @see_player != true @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0 return true end return false end #-------------------------------------------------------------------------- # new method: update_flee_distance #-------------------------------------------------------------------------- def update_flee_distance return if @erased return if @flee_range.nil? dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs if flee_conditions @flee_player = true @move_speed = @flee_speed unless @flee_speed.nil? else @flee_player = false @move_speed = @page.move_speed @alert_player = false if @alert_timer <= 0 end end #-------------------------------------------------------------------------- # new method: flee_conditions #-------------------------------------------------------------------------- def flee_conditions dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs return true if @alert_lock > 0 return true if dis <= @flee_range and see_player? if dis <= @flee_range && @see_player != true @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0 return true end return false end #-------------------------------------------------------------------------- # new method: update_scared_distance #-------------------------------------------------------------------------- def update_scared_distance return if @erased return if @scared_range.nil? dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs if scared_conditions @scared_player = true @move_speed = @scared_speed unless @scared_speed.nil? else @scared_player = false @move_speed = @page.move_speed @alert_player = false if @alert_timer <= 0 end end #-------------------------------------------------------------------------- # new method: scared_conditions #-------------------------------------------------------------------------- def scared_conditions dis = distance_x_from($game_player.x).abs dis += distance_y_from($game_player.y).abs @call_dis = dis return true if @alert_lock > 0 return true if dis <= @scared_range and see_player? if dis <= @scared_range && @scared_player != true @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0 return true end return false end #-------------------------------------------------------------------------- # new method: update_alert_balloon #-------------------------------------------------------------------------- def update_alert_balloon return if @erased @alert_timer = 0 if @alert_timer.nil? @alert_lock = 0 if @alert_lock.nil? @alert_lock -= 1 if @alert_lock >= 0 return if @alert_balloon == nil || @alert_balloon == 0 if (@chase_player || @flee_player || @scared_player) && !@alert_player @balloon_id = @alert_balloon @alert_player = true @alert_timer = YEA::EVENT_CHASE::ALERT_TIMER RPG::SE.new(@alert_sound, 100, 100).play unless @alert_sound.nil? end @alert_timer -= 1 if @alert_player end #-------------------------------------------------------------------------- # new method: see_player? #-------------------------------------------------------------------------- def see_player? return false if @see_player != true sx = distance_x_from($game_player.x) sy = distance_y_from($game_player.y) if sx.abs > sy.abs direction = sx > 0 ? 4 : 6 else direction = sy > 0 ? 8 : 2 end if direction == @direction if @sight_lock == nil || @sight_lock <= 0 @sight_lock = YEA::EVENT_CHASE::SIGHT_LOCK end @alert_lock = @sight_lock return true end return false end #-------------------------------------------------------------------------- # new method: move_type_away_player #-------------------------------------------------------------------------- def move_type_away_player sx = @x - $game_player.x sy = @y - $game_player.y if sx.abs + sy.abs >= 20 move_random else case rand(6) when 0..3; move_away_from_player when 4; move_random when 5; move_forward end end end end # Game_Event#==============================================================================# # ▼ End of File# #==============================================================================event On ur game_event make sure to put in move route this:

@see_player = true

@scared_player = 5

@chase_player = 10

So what does the above do? The event will chase the place if within 10 tiles away. When player faces the event and the event happens to be within the 5 tiles away, the event will run away from the player XD
 

supedaglup

Villager
Member
Joined
Sep 20, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Amazing! Thanks so much for the help! :D
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
Glad I could help man! XD

Now hit that friend button cuz I'm on the brink of taking over the world! MWAHAHAHAHAHAAAAA!!!! */cough.. cough*

Daaaaamit!!! How in the world does those evil villains naturally do it without causing throat irritations @_@
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top