Changing self switches within another script.

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
Hey guys

I am trying to edit Yanfly Chase Event so I can change event page based on whether the event is chasing the player or not. Why would I need to do this? My project has a boatload of parallel process events on enemies to control their ai. Because of this, I had to create a way to put those parallel processes to sleep when they are not needed or when they are not chasing the player around. So, I made the event have two states, a sleep state and an a wake state. I thought if I could embed a way to change an event’s self-switch inside of the “Chase Event” methods I could then effectively swap to a separate page for the event doing the chasing. Of course, that is easy said than done.

This is what I came up with so far, (and right now it doesn’t really do anything). This I just a fragment of the whole script. Also, I am by no means a scripter so I probably did it wrong anyway xD.

Code:
▼ Yanfly Engine Ace - Event Chase Player v1.00$imported = {} if $imported.nil?$imported["YEA-EventChasePlayer"] = truemodule YEA  module EVENT_CHASE   #Stuff that is not relevant….     end # EVENT_CHASEend # YEAclass Game_Event < Game_Character    #--------------------------------------------------------------------------  # 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      move_type_toward_player      $game_map.events[@event_id].instance_eval("@self_switches = 1") #The edit I am trying to make work.    elsif @stop_count > 0 && @flee_player      move_type_away_player    else      game_event_update_self_movement_ecp    end    update_alert_balloon                 endend # Game_Event
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,838
Reaction score
14,031
First Language
English
Primarily Uses
RMMV
What is Switch.stop_npc_movement? Unless that is a module and method you've created, it's not going to work. You use $game_switches[switch_id] to check the value of switches.


To turn an event's self switch on, use the command

Code:
$game_self_switches[[$game_map.map_id, @event_id, 'A']] = true
and of course false to turn it off. The only thing you need to change in that command is the A and true. $game_map.map_id will pick up the map id of the current map, and as long as @event_id within the current scope it'll work.
 

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
What is Switch.stop_npc_movement? Unless that is a module and method you've created, it's not going to work. You use $game_switches[switch_id] to check the value of switches.

To turn an event's self switch on, use the command

$game_self_switches[[$game_map.map_id, @event_id, 'A']] = trueand of course false to turn it off. The only thing you need to change in that command is the A and true. $game_map.map_id will pick up the map id of the current map, and as long as @event_id within the current scope it'll work.
That was just a part of the script, The only thing I added was that little tid bit.

Your fix stopped the crashing but it didn't seem to have any effect on the event, it was still in sleep state. So to check, I manually placed the Map and Event IDs in and then it worked. So the next step I need to figure out is how to make the edit point to the correct events.

EDIT

Ah ha! Thanks Shaz, with your help I managed to figure out a solution to my dilemma. I was looking at how the script functioned all wrong. My first opinion was that the script told the event what to do, though it is true how it worked. It got its configuration from the events themselves. So with this in mind, I thought to create a couple new configuration settings within the event and then adjust the snippet you gave me accordingly and it worked like a charm! :3

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 move_type_toward_player $game_self_switches[[@tdh_event_mapid, @tdh_event_id, 'A']] = true # EDIT elsif @stop_count > 0 && @flee_player move_type_away_player else game_event_update_self_movement_ecp end update_alert_balloon end
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...
Are we now stuck with WYSIWYG ? I cannot revert back my posts to good old raw text ?
I'm wondering if I may be putting too many things into one map. A story, within a story, within a story . . . it's fun, but I can't shake the feeling that it may be better to scrap some of it, and use it for another map. I'm not sure what to do.

And the beginning of a nearly complete grid system dawns.

I want to add a thin pixel border around the entire region. Like across all blue highlights that connect and red attack highlights that connect.

Forum statistics

Threads
107,787
Messages
1,032,198
Members
139,939
Latest member
Mineformer
Top