Yanfly Event Chase Script

Hi.

I've been playing around a little with Yanfly's Event Chase Script (https://raw.githubusercontent.com/Archeia/YEARepo/master/Field/Event_Chase_Player.rb) and I have 2 concerns that I hope someone might help me with.

The first is that I can't seem to get the alert_sound to work. I think I've tried everything, making a new project with only the yanfly script, adding "" or '', but nothing seems to help. If I have @alert_sound = Blow1, the game crashes (Game_Character, Line 180) and I think that is how you are suppose to write it, but I couldn't even find help elsewhere, so it seems like I'm the only one with this problem(?)

This is how I've made the chasing event, if it helps.

Chaser.png

The second part is a bit trickier. Is it possible to add to the script so that a self-switch activates/deactives when the event sees/loses sight of the player? This is more of an optional thing, but it would help a lot, cause then I could event the chaser to walk back to it's original position and possibly other things.

Thanks for reading.
For the first question, have you tried writing @alert_sound = "Blow1" under apostrophes? It needs to be a string.

As for the second question I'll look into the script later, if you'll still need a solution.
For the first question, have you tried writing @alert_sound = "Blow1" under apostrophes? It needs to be a string.

As for the second question I'll look into the script later, if you'll still need a solution.
Yes, I have tried using " " and ' '. When I do, no sound plays but the script doesn't crash. This is why I thought maybe it collided with another script, but like I said, I got the same results in a NEW project, so I don't know what I'm doing wrong.
You need to activate also @alert_balloon because in that script the sound is played only in this method

Spoiler
#-------------------------------------------------------------------------- # 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) && !@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
This way it should work, if you want to play the sound without showing the balloon icon you can try to cut and paste 

RPG::SE.new(@alert_sound, 100, 100).play unless @alert_sound.nil?  before 

Code:
 return if @alert_balloon == nil || @alert_balloon == 0
You need to activate also @alert_balloon because in that script the sound is played only in this method

Spoiler
#-------------------------------------------------------------------------- # 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) && !@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
Spoiler
This way it should work, if you want to play the sound without showing the balloon icon you can try to cut and paste 

RPG::SE.new(@alert_sound, 100, 100).play unless @alert_sound.nil?  before 

return if @alert_balloon == nil || @alert_balloon == 0
Omg, I can't believe I didn't think about that... The line you gave me made it so that the sound kept playing over and over again nonstop, even through walls etc. but that is OK, I can fix this by just making my own balloon icon that is just nothing, then the sound plays like it should. Thank you so much. Get back to me about the other thing if you have the time for it. 🙂
Try this

Spoiler
#-------------------------------------------------------------------------- # alias method: update_self_movement #-------------------------------------------------------------------------- alias game_event_update_self_movement_ecp update_self_movement def update_self_movement return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement update_chase_distance update_flee_distance if @stop_count > 0 && @chase_player $game_self_switches[[$game_map.map_id,@chase_ev_id,'A']] = true #<----ADD THIS move_type_toward_player elsif @stop_count > 0 && @flee_player move_type_away_player else game_event_update_self_movement_ecp $game_self_switches[[$game_map.map_id,@chase_ev_id,'A']] = false #<----ADD THIS end update_alert_balloon end
and in the custom move route of each event you have to add @chase_ev_id = n , with n the actual ID of the event(a number), if you don't want the self switch to change you can simply omit that line, hope it helps!  🙂
Try this

Spoiler
#-------------------------------------------------------------------------- # alias method: update_self_movement #-------------------------------------------------------------------------- alias game_event_update_self_movement_ecp update_self_movement def update_self_movement return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement update_chase_distance update_flee_distance if @stop_count > 0 && @chase_player $game_self_switches[[$game_map.map_id,@chase_ev_id,'A']] = true #<----ADD THIS move_type_toward_player elsif @stop_count > 0 && @flee_player move_type_away_player else game_event_update_self_movement_ecp $game_self_switches[[$game_map.map_id,@chase_ev_id,'A']] = false #<----ADD THIS end update_alert_balloon end
Spoiler
and in the custom move route of each event you have to add @chase_ev_id = n , with n the actual ID of the event(a number), if you don't want the self switch to change you can simply omit that line, hope it helps!  🙂
Thank you, I don't see any problems with it and it works so far 🙂

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-event-chase-script.38813/