philteredkhaos 131 Posted April 19, 2016 Hello, I am wondering if there is any method to make a variable that stores the player's PREVIOUS X,Y coordinates from the time a switch is activated? I know you can have a parallel process running for player x,y location in a variable that activates an event when you are within the parameters of the event, but if the page were to switch, does it store the last known data in the variable or is it cleared? If it is stored, can I have an NPC move to that location? How would I call the data from that variable to make an NPC move to that location? Thanks for any help! Share this post Link to post Share on other sites
D.S.Sirius 2 Posted April 19, 2016 A variable is static and constant. If you were to assign either the X or Y value of the player to a variable, then that variable will remain at that value for the rest of the game until it is told to change. For example, let's say your switch is called "location". You could have an event set to run via parallel process with a condition that "location" is on. Then, you can set the two control events: locationX is equal to Player X locationY is equal to Player Y Then just set Self switch A to the on position on the event to turn it off. if your position at this time was 13,4 for example, then the following will be true for the rest of the game unless you change it with another command: locationX = 13 locatonY = 4 Hope this helps. Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 19, 2016 This helps a lot, actually! Thanks for clarifying. My only problem now, is getting my event to use those variable coordinates to move the NPC over to that location. Any ideas on how this may be accomplished? Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 19, 2016 (edited) If you want the NPC to walk there, you would need a pathfinding script. The script I'm using willd allow that. I've used it to make NPC's chase the player. Here's the link: http://www.rpgmakercentral.com/topic/4328-karanums-pathfinding-script/ You'll need to set up the move route. Under Set Move Route, use the Script... command. Type this in: walk_to($game_variables[x], $game_variables[y] Enter the Variable ID's for X and Y. Have the event run in Parallel Process, and it should work fine. Edited April 19, 2016 by lonequeso Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 19, 2016 (edited) Thanks, Lone! This should be perfect! now, back to the editor and away from the forums! I'll report back with my results. Must be doing something wrong. I can't get an NPC to move towards player with walk_to command, and it takes my frame rate down to between 2-4 FPS. Edited April 19, 2016 by philteredkhaos Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 19, 2016 Oops I wrote that wrong. You don't put the script in the Move Route. Just put in a normal script call. Pathfinding is kinda memory intensive. If it still lags, change walk_to to walk_to_straight or walk_to_short. That should make it run correctly and smoothly. Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 19, 2016 (edited) heh heh. Thats kinda funny. I will try again with the updated information... Aaaaaw yeah! worked out perfectly so far! Do you know how to set it to move towards the player? I have 2 different types of NPCs on my maps, and 1 group needs to just run at the player no matter where the player is. What would I use to move towards player? (at risk of having this thread moved...it's not my fault! I swear!) Edited April 19, 2016 by philteredkhaos Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 19, 2016 (edited) You'd use the same thing. You just need to use two different variables. They'd still be set to player Map X and Y. Just don't toggle the events with a switch, I actually have a Parallel Process event that constantly checks PLayer X and Y so I don't have to set it up everytime. Edited April 19, 2016 by lonequeso Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 20, 2016 Do you have any events running in a situation like this: NPC is "patrolling", and player approaches. As the NPC sees the player, NPC gives chase. Player leaves Line of Sight for the NPC, and the NPC goes to the last known location. After arriving to X,Y coordinates, the NPC looks around and, if no player is in the NPC's LOS returns to original position and continues patrolling. Otherwise, if there is a player nearby the NPC will give chase again. I have mine set up so it will do almost all of the actions above, except when it gets to the location, it doesn't seem to register that a player is nearby. Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 20, 2016 Close. My NPC's all chase the player. I didn't use the LOS option during the "chase" event because it was too easy to get away. i didn't think of havign the NPC go to the last know location. So in your set up: NPC "sees" Player NPC chases player Player evades NPC NPC goes to last known coordiantes NPC doesn't "see" the player afterwards. I would need to see a screenshot of all the events/pages to see what's going on, but from that it sounds like there's a switch that's supposed to turn the event that tracks the player's current coordinates back on. Post some screenies so we can see. Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 22, 2016 Ooops. Yeah, here are a few pics: Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 22, 2016 I'm guessing the 3rd screen is a different script. I have no idea what that's for, and I guarantee whatever it is, the pathfinding script I linked you to will be able to do it. You also have on the first screen Conditional Branches checking the same condition. That's bound to cause some issues. Okay so 2nd screen is where the NPC sees the player is they're within 6 steps. Triggers a switch to make the chase go which is the first screen, Get rid of the top conditional branch. Put the Spotted! switch toggles and Script call on the first event page. That will clean that part up. Something is confusing me. What happens if the player just stands there? I see no condition for that. The pathfinding script will move the NPC towards and to the spot designated by the coordinates you stored until you tell it not to. You don't need that other long move route script. Start with that cuz that Self C event is really throwing me off. Share this post Link to post Share on other sites
philteredkhaos 131 Posted April 22, 2016 (edited) If you are referencing the screen that has a bunch of "Script:move_toward_xy" commands, I feel like that IS from the commands of the Pathfinding script you showed me. I could be wrong, but that is the only pathfinder I am using. Are you saying, if I have just 1 command there, it will continue to move the NPC? I might not have tried that. It is moving the NPC to it's starting location. then it turns off all switches and is back to where it started when the map loaded. If the player is standing still, the event still triggers because you are within the "visible" distance, which seems to be in a circle around the event. The screen that has 2 conditional branches for the same thing was for when the NPC. When the NPC arrived to the location stored in the variable that was locked in with "Spotted" switch, then the NPC was supposed to look around, and if you were anywhere in the visible range, the NPC would "see" you again, and give chase. Instead, the NPC shows up, looks around then walks back. After it returns to it's starting position, then it's active again, otherwise you can stand in front of it and it will ignore you. Edited April 22, 2016 by philteredkhaos Share this post Link to post Share on other sites
lonequeso 1,921 Posted April 22, 2016 Yeah with the script I showed you, you don't need to create a move route. The NPC will continually move to that location for as long as the parallel process is running. If you want to move it back to the starting position all you have to do is use the same script call with the map coords in place of the variables. The way you have it set up the pathfinding occurs only if the player is more than 6 tiles away. There shouldn't be an Else branch. Just: Script: Proxyinprox_d(@event_ID, 6, true) Switch: Spotted = ON A couple quick notes: You can put the ID of the event in place of @event_id and I'm not sure if the line of sight is defaulted to True or not hence the extra parameter. If the player moves within six tiles of the NPC, it will give chase to the the player coordinates using the pathfinding script call. Have two variables that check the event's X and Y coordinates. If NPC's X = variable[playerX] If NPC's Y = variable[playerY] Self C = ON That way, when the NPC reaches it's destination the event will go to the next page. Is something supposed to happen if the NPC touches the player? If so, I can show you that, too. For now, I'm just going to the next event page: I'm assuming you want the NPC to follow the player again if they move in range. Make a conditional branch for the proximity again. This one will have that else statement. RIght now Self A is still ON. So all you have to do is Turn Self C OFF to make the NPC chase the player again. The event will just go back to the previous page. Under else, place the move route and balloon icon. Have wait for completion on both of them. Then use the pathfinding script call to tell the NPC to go back to it's original location. The NPC will do so unless the player comes back in proxy range. Finally, make a separate pair of conditions. You're going to check if the NPC has reached it's original spot. Check if the event's X and Y coords are equal to the map coords of it's origin point. Then Turn Self A of followed by Self C. This will reset the event. It's kinda complicated, I know. Mine has extra conditions to check if the player is running or not. Imagine how run that was to figure out. The good news is, if you can get it running correctly, you can just copy/paste most of it. You just have to change the map coordinates for the last part when they go back to their starting point. Are you going to have more than one of these events running on the same map? If so, you're going to need to change up how the player's coords are stored. Try and get that event up and working correctly first, and we'll deal with that next. Share this post Link to post Share on other sites