alphakunst

Warper
Member
Joined
Mar 25, 2018
Messages
1
Reaction score
0
First Language
english
Primarily Uses
RMVXA
The idea behind this was that I wanted something where the enemies had a detection range and when you walked into it, an event started, whether it be a battle starts or it just gives you a game over (haven't decided yet).

I looked up some stuff on this but pretty much everything I found was scripts, which I didn't feel very comfortable using as I have never really used the scripting functions before. So because of this, everything was done using variables and conditional branches.

The variables and what they do:
sbNgxzG.png
BxnIY8i.png


Player & guard (guard being the enemy) XY should be pretty self explanatory. They are just set to their respective positions on the map. Gets a bit messy after that. Try to set a distance for how far the guard can see but have to do this in all directions relative to the guard. Then I also set a width for the detection as I don't really want it to be just a straight line.

The events:
MPGg9vq.png


Something that annoys me about rpg maker VX ace and idk if there is a fix for it but I can't rescale this window to see the rest of the lines. Had to type up what it said (more or less) in notepad. This is just for when the guard is facing right but this set of events was copy/pasted onto the else of this with edited variables/etc to accomodate for other directions.

HTQHrbB.png


So my main questions are:
  1. Is there a better way to do this?
  2. Can I optimize my current build better?
  3. Is there a way to incorporate terrain detection as well? If the player hides behind a crate for example. I looked at terrain tags and the "get location info" event and it seemed possible if pretty convoluted.
  4. Is there actually a way to rescale the event window (it really does annoy me)?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,647
Reaction score
15,735
First Language
English
Primarily Uses
RMMV
Bite the bullet and learn how to use scripts.

Your idea would work if you have ONE enemy. I suspect you do not have just one. You will have to use different variables for each enemy, otherwise you'll have some events THINKING their own X,Y is in the variables, but other events will have set it to THEIR X,Y.

Not to mention how laggy this is going to be, with however many events, all set to parallel process, all doing these commands.

Use a script for this one.
 

Lord Vectra

Master Eventer
Veteran
Joined
Dec 6, 2015
Messages
245
Reaction score
352
First Language
English
Primarily Uses
RMVXA
Look at the middle and left screenshot. These both are common events (not parallel process common events). On the right, you see one of the common events are called by a goblin event. That screenshot is of an event that is in parallel process mode. Let me explain the left screenshot. Once I explain that, the middle is a carbon copy with key differences I will explain.
G7jiA0m.png


As you know, you search for the X and Y of an event. If you noticed, in "Spawn 1 X-Coord" variable, it looks for "This event's Map X." If you look on the right screenshot of the goblin, you'll see that I'm calling the common event. "This event's Map X" makes it so the common event searches the X-Coord of whatever event that calls it. This way, the event knows what event to search for without you having to manually do it (AKA copy/paste the entire common event in every event that does a distance check).

Now, you might be wondering why it doesn't check for player X and Y and you might also wonder why Im subtracting Spawn 1's Y-Coord with Player's Y-Coord and doing the same for X.

Why the common events don't check for Player's position?
I have another common event (that is parallel process) that continuously checks the X and Y coord of the player.
ijsk8DJ.png


I recommend doing this for what I'm currently teaching you.

Why are you subtracting the variables?
Subtracting gives you the difference in X and Y coord from the player and the spawn. Which way you subtract does not matter as it'll always be positive.

Positive?
I subtracted player's X-Coord from event's X-Coord. Thus, I will check if the event's X-Coord is less than 0 and if so, multiply it by -1 so that it will always be positive. It's a math rule - "Distance is always positive."

Now, continuing on...
Finally, I add the event's X and Y which, by this point, should give me the total distance in squares between the player and the event. I added the Y to the X, therefore, I check for the value of X-Coord.

I have it as equal to or less than 7. In place of 7, you could make another variable. If you look at the right screenshot, I could've made a variable equal to 7 and then replace 7 in my common event with the variable (sorry if I confused you with saying 7 a lot).

Where you would put this? Right before you call the common event.

Now for the middle screenshot
The only difference you need to know is to use different variables for the event's X and Y coord. The left and middle are two different common events. I copied it only once allowing me to check the distance of two events at a time, but I'm probably going to copy it about 10+ times by the end of my game's development.

Lastly, you might be curious about the self-switch
Self-Switch works like "This event's X-Coord." It turns on the self-switch of the event that calls it. In the context of my game, self switch A opens the 2nd tab of the goblin. Movement type is "Approach" and I personally put 2x speed with highest frequency. 1st tab is just put as "random" but you can edit either however you like.

FgZ04Kb.png


I got too lazy to crop but there you go. "Erase Event" may be important depending on your goal with using this. The Trigger for the events depends on your goal, but for me, it is "Event Touch."

Hope this helps. Let me know if you have any questions.

Important note: This is from Rpg maker XP but it should look exactly like how I have it regardless if using Vx, Vx Ace, or MV (I think the color coding is different in MV tho).
 

Latest Threads

Latest Profile Posts

DNPwhy.gif

You're using that item wrong... TwT

Trying to get the mechanics down for a cute, story-driven board game! I think I've accomplished dice movement, item effects, and activating a space's event when you land on it. Art is WIP. Hope to open a thread about the game soon!
My entire family and I have Covid... If it's this bad with the vaccine, without must be terrible. Stay safe, everyone. This thing is a doozy.
Ugh. Head heavy with sick juice. I wish I could work on my stuff. o_O

Forum statistics

Threads
118,521
Messages
1,116,604
Members
155,534
Latest member
aubycringe
Top