iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

2nd Quarter Contest Announcement posted! See the Community Announcements section.

> Note for Tutorial Threads

New threads (tutorials) here will go into a moderation queue. You will not see your thread appear when you create it. A moderator will decide if it will be approved or denied.

2 Pages V   1 2 >  
Reply to this topicStart new topic
> [-Eventing-] On-Map Shooting Ability, A remake of an old tutorial
Akod
post Jan 5 2013, 05:17 AM
Post #1



Group Icon


Type: Designer
Alignment: Chaotic Neutral




How to Give the Player the Ability Shoot Something on the Map


So I am here to remake an old tutorial that people were requesting someone to redo. The Sorcerer's Ring tutorial made by manat31790 lost it's images and people were having a hard time working with what was left so I thought this would make it easy for the people that requested this and any future RPGers to do what I am about to explain.

Step 1: The Basics

Spoiler:
Let's set up a simple test map. Nothing special, just make an area for the player to move around in. We're going to add 2 events to the map, one off to the side and one in the player area. Let's name the side event Shot and the other event Target Practice.

Next, let's make 2 switches, one labelled Ability Active and the other labelled Ability Used.

Now, let's make 2 variables, one labelled Player X and the other labelled Player Y.

Finally, let's make 2 Common Events, one Parallel Process with the condition switch of Ability Active and one Autorun with the condition switch of Ability Used. Let's name the Parallel Process Use Check and the Autorun Use Function.

Here is how it looks so far.
Spoiler:


This is the layout of everything we are going to use in this tutorial. Now that we have everything ready, we can start coding.


Step 2: Making the Ability Work

Spoiler:
Let's go over to our Shot event and open it up. We are going to want to go to the 4 checkboxes in the lower left corner and make it so Stepping Anim. and Through are checked and the others are not. Next, we want to change the frequency, Speed, and Priority. What these are depends on what you are going to shoot. For this example let's set the Speed to X2 Faster, the Frequency to Highest, and the Priority to Above Characters. We are done with this event.

Here is what the event should look like.
Spoiler:


Next, go to the Common Event labelled Use Check. First, make a Conditional Branch to check to see if a button is being pressed, under the 4th tab of the Conditional Branch choose the Button option, we will be using the Action Button so choose Button C. Within this Conditional Branch, we are going to set the variables we named. For the variable Player X, choose the Operand called Character, set it to Player's Map X. Next do the same for the Player Y, but this time change Map X to Map Y. Now use the Set Event Location command to set event Shot to the coordinates stored in those two variables we set, this will move the event the player "shoots" to the player so it can go where the player wants it to. Now, we are going to want to make Shot face the direction the player is facing, to do this we are going to use the Conditional Branch Character option from the third tab to check each direction of the player and set Shot to face that direction. Finally, at the end of the Button is Pressed Conditional Branch, set the Ability Active switch to off and the Ability Used switch to on.

To recap this paragraph, we are doing the following:

-Checking to see if a button is pressed.
-Setting 2 variables to the player's coordinates.
-Moving the Shot event to the player's position.
-Making the Shot event face the direction of the player.
-Turn off one switch and on the other.

Here is how this Common Event should look like.
Spoiler:


Now, let's go into the Common Event Labelled Use Function. This one is really quite simple, we are going to use the event command Set Move Route, first make sure you are setting the route of the Shot, then for the route change the graphic with the Change Graphic button in the third column to whatever you wish for the player to shoot, use the 1 Step Forward button in the first column to make it go however many squares you want it to go, I'm gonna do 5, and finally set the graphic back to None; be sure to check the "Skip if cannot move" checkbox so it will not get stuck on the edge of the map. Next, use the Set Event Location command to set Shot to any square where it would be out of the way, this way it will not block the path of any other event. Finally, just set the Ability Used switch to off and the Ability Active switch to on. If you want a sound to play when you shoot your object., just tack it on the the very beginning.

*Note Make sure that the Shot event has the same ID on every map or the ability will not work correctly from map to map.

To recap this paragraph, we are doing the following:

-Giving the Shot event a graphic.
-Making the event move.
-Making removing the set graphic.
-Moving the event out of the way.
-Flipping the switches in the opposite direction we did in the previous Common Event.

Here is how this Common Event should look like.
Spoiler:


And now we can use our power, as long as the Ability Active switch is on.


Step 3: Making the Ability Useful

Spoiler:
Now that we made the ability, we should make something to use it on. Open up the Target Practice event. Just to give us something to shoot at, lets give this event the cow graphic and random movement. We are going to set this event to a Parallel Process. Normally, I do not like using any scripting to make things work, but in this case it will save us major event checking on every map and a ton of variables.

First make a Conditional Branch, under the fourth tab at the very bottom you will see a choice called Script, choose it and place the following line of code within it.

CODE
$game_map.events[X].x == $game_map.events[Y].x


This is where you want to check the ID of each important event. If you do not know how to find the ID of an event, double click it and in the very upper left corner you will see something like Edit Event - ID:00X where X is ID, the extra zeros are unnecessary. In the demo I am making, Shot has an ID of 1 and Target Practice has an ID of 2. within this line of code you will see X and Y within brackets, we want to set X to the ID of Shot and Y to the ID of what the shot will affect, in this case Target Practice.

Now, let's make a new Conditional Branch within the previous one, this time we are going to use the following line of code instead.

CODE
$game_map.events[X].y == $game_map.events[Y].y


We are going to set the X and Y within the brackets to the same IDs that we set the previous branch to. Within both Conditional Branches, set Self Switch A to on. Make a second page with the same graphic and the Conditions above the graphic to check to see if Self Switch A is on, be sure the second page is also set to Parallel Process.

Here is how Page 1 of this event should look like.
Spoiler:


For this demo, I am going to make the player have the ability to freeze things. Normally for a frozen object the graphic would look different, but since this is just a tutorial I will just ignore this fact. Since we are freezing the cow, we are going to leave the movement to Fixed, if we were shooting a fireball I would probably set the Speed and Frequency to the highest they go and set the movement type to Random, making them run around until they go out. Under the event commands, we are going to use the Wait command to make this effect last as long as we like. Remember, when it comes to the Wait command, it reads in frames so be sure to multiply the number of seconds you want it to last by 60 since there are 60 frames per second. Then, just set the Self Switch to off.

Here is how Page 2 of this event should look like.
Spoiler:


If you wish for the magic to dissipate once it hit's it's target, within the Conditional Branches, right before you set Self Switch A to on, set a move route for the Shot event to Turn, it does not matter which one you choose as this is just to disrupt the movement made by the Common Event, and to Change Graphic to None.

Here is how Page 1 would look like altered in this fashion.
Spoiler:


To recap this entire step, we are doing the following:

-Making the event keep track of it's coordinates compared the the event that is attached to the ability.
-Causing a reaction for when the ability event comes into contact with this event.
-Keeping track of what the reaction should do and how long it should last.

There we go! The ability now fully works and to make it work on other things, just repeat step 3 for everything and just make minor tweaks to have it work to your liking.


*The real credit goes to manat31790 as this is heavily based on his tutorial.

If you have any questions or comments I'd love to hear them, so feel free to post them below.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
robbieagray
post Jan 25 2013, 06:57 AM
Post #2


The man with a grin that even the Joker envies... >:D
Group Icon


Type: Spriter
Alignment: Lawful Evil




Sadly i was a little confused. So how would one use this puzzle in their game?


--------------------
If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig.

Projects I am currently working on:
-In need of a portrait designer (check here for more info)
- feel free to join. :D

-Link to my Youtube Channel: HERE! (Please Subscribe)

I support the following:


Go to the top of the page
 
+Quote Post
   
Akod
post Jan 25 2013, 07:35 AM
Post #3



Group Icon


Type: Designer
Alignment: Chaotic Neutral




I honestly do not know why Manat called his a puzzle, I would personally not consider this a puzzle, that is why I did not mark this as a puzzle when I remade it.

I suppose you could make it so you can shoot different things and you have to figure out when and where to use each ability. It could also, in theory, be used as a battle system of sorts. The real reason I made this wasn't the uses of it, but because you and Zenten requested it so I didn't think of that too much.

You said you were confused, was that of what you could use it for or something I explained in the tutorial?


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
robbieagray
post Jan 25 2013, 08:23 PM
Post #4


The man with a grin that even the Joker envies... >:D
Group Icon


Type: Spriter
Alignment: Lawful Evil




mostly for what it could be used for? Because I was still trying to think of it as a puzzle. So is it basically so you can shoot the cow? blink.gif

Is it just a manner to adding shooting to a game without the use of a script?


--------------------
If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig.

Projects I am currently working on:
-In need of a portrait designer (check here for more info)
- feel free to join. :D

-Link to my Youtube Channel: HERE! (Please Subscribe)

I support the following:


Go to the top of the page
 
+Quote Post
   
Akod
post Jan 25 2013, 10:28 PM
Post #5



Group Icon


Type: Designer
Alignment: Chaotic Neutral




That is pretty much it. I wouldn't use it for a major puzzle in a game, more like something small to sprinkle in throughout a game just for that because you can factor.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
amerkevicius
post Jan 26 2013, 12:07 AM
Post #6



Group Icon


Type: Writer




You might be able to do something where it effects the enemy states once you start battle:

If you hit it with a fireball, the battle begins with the enemy in a sort of burned state (with whatever conditions you want). Hit with ice and maybe it starts frozen for a single turn. Make it so that once the projectile hits, you have a certain amount of time to touch the enemy and initiate battle before the effect wears off.
Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 8 2013, 04:48 AM
Post #7



Group Icon


Type: Undisclosed




Hey, first off thanks for the tutorial. I went through the steps a few times, exactly as you have shown, but I get this error when I try to run the scene: "Script 'Game_Interpreter' line 450: Name error occurred. uninitialized constant Game_Interpreter:: X" If you could help me find out how to fix this I would be very grateful. I am quite bad at programming and this is my first attempt in rpg maker ;n; .
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 8 2013, 05:46 AM
Post #8



Group Icon


Type: Designer
Alignment: Chaotic Neutral




First off, welcome to the forum! Always nice to see new faces around here.

I know what the issue is, when you added the script line I gave you didn't change what is necessary so the game_interpreter didn't understand what the code was saying.

This is what the code I posted looks like.

CODE
$game_map.events[X].x == $game_map.events[Y].x


and

CODE
$game_map.events[X].y == $game_map.events[Y].y


Now you failed to change this piece of the code in either one or both of those lines [X]. In this spot in the code you want to put the ID of the event you will be "shooting", I explain how to find the ID above. Since you left it as X the game_interpreter could not understand the code since it only understands numbers for that part of the code.

So if your event IDs were the same as in the demo your codes should look like this.

CODE
$game_map.events[1].x == $game_map.events[2].x


and

CODE
$game_map.events[1].y == $game_map.events[2].y


I hope I explained that well enough.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 8 2013, 08:56 AM
Post #9



Group Icon


Type: Undisclosed




Thanks smile.gif and Thanks for such a quick response. I definitely misread some info there. Unfortunately, I fear I have only made it harder to complete this task, as now the program runs, but nothing happens at all when I press C. After changing those 2 variables everything is for sure the same. How am I to survive on an island with only a cow if I cannot even shoot fire at it :/ I dread to think.
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 8 2013, 04:18 PM
Post #10



Group Icon


Type: Designer
Alignment: Chaotic Neutral




If you still have a problem feel free to post a demo with the issue in it and I will help figure out where the problem is.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 8 2013, 06:19 PM
Post #11



Group Icon


Type: Undisclosed




Attached File  RPGMakerDemo.zip ( 173bytes ) Number of downloads: 2


Here is a zip with my demo in it. I think this is the right file to look at the game. It would be the source game, I guess? ^^;; Thanks for being awesome and trying to help, hopefully you can see what I cannot see.
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 8 2013, 06:49 PM
Post #12



Group Icon


Type: Designer
Alignment: Chaotic Neutral




Actually that file is just to open the game in the editor. All the real information is in the other files so you have to compress the entire game folder. If you do not want to post a copy of it here feel free to send it to me in a message.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 8 2013, 07:07 PM
Post #13



Group Icon


Type: Undisclosed




Attached File  RPGMakerDemo.zip ( 1.32MB ) Number of downloads: 1


Alright here. All it is is what is in this tutorial anyways ^^
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 8 2013, 07:15 PM
Post #14



Group Icon


Type: Designer
Alignment: Chaotic Neutral




I see the problem! This is simple and I should have made this more obvious in the first post. To have the ability of using the ability you have to turn on the Ability Active switch, otherwise the common event will not run. I did it this way so you have the ability to turn off the ability, but I only stated it briefly at the very end of Step 2 when I said "And now we can use our power, as long as the Ability Active switch is on".

Sorry about the confusion.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 8 2013, 07:50 PM
Post #15



Group Icon


Type: Undisclosed




Where do I do this at? Isn't the line at the bottom of Use Function turning the switch on?
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 8 2013, 08:20 PM
Post #16



Group Icon


Type: Designer
Alignment: Chaotic Neutral




Yes and no. They only turn each other on if one of them is on to begin with. This is so you can shoot more than once.

To give the ability to the person you will have to turn on the switch in another event. Make a third event on the map. Make it set to autorun and in the event commands turn on the Ability Active switch and Self-Switch A. Then make a second page and make a condition of this page that Self-Switch A is on, which you set above the spot where you give the event a graphic. This will automatically turn on the ability once the map loads.

When it comes to Common Events you either have to call them manually or have the Condition Switch connected to the Common Event be turned on.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 9 2013, 01:21 AM
Post #17



Group Icon


Type: Undisclosed




BEAUTIFUL. Thanks for the input. I now have fire @_@. Any chance I would be able to make multiple cows running around as target practices without having to make everything over again for each one? Maybe just change the script code from x to y to x to y2? I will fiddle around with it, but I am trying not to ruin my beautifully completed tutorial. smile.gif
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 9 2013, 01:58 AM
Post #18



Group Icon


Type: Designer
Alignment: Chaotic Neutral




Oh no, you don't have to make it all over for every enemy.

If you add a second cow and it's ID is 3 for example just do everything you did in the first cow but change the codes from

CODE
$game_map.events[1].x == $game_map.events[2].x


and

CODE
$game_map.events[1].y == $game_map.events[2].y


to

CODE
$game_map.events[1].x == $game_map.events[3].x


and

CODE
$game_map.events[1].y == $game_map.events[3].y



Basically what this code does is it checks where one event is in comparison to another and you can choose which events it is checking by changing which numbers you put in the [X] and [Y] parts of the codes.

So all you have to change is the cows, everything else is universal.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   
yamiseth91
post Mar 9 2013, 06:35 AM
Post #19



Group Icon


Type: Undisclosed




I am well on my way thanks to you :-D It works beautifully as a game mechanic to shoot things and kill them or even as a puzzle mechanic. The only problem is when i actually shoot the edge of the map it just stays there and freezes the game. Just gotta never let my players go near the edges of the world >_<.
Go to the top of the page
 
+Quote Post
   
Akod
post Mar 9 2013, 06:39 AM
Post #20



Group Icon


Type: Designer
Alignment: Chaotic Neutral




You can fix that really simply as well actually. Just go into the Use Function common event and go into the move route you set for the shot and check the Skip if Cannot Move option.


--------------------
This poll is fresh out of the oven. Get it while it's hot!

Having issues eventing something? Feel free to send me a message and I will see what I can do!



I Support
Spoiler:







Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 01:08 AM

RPGMakerVX.net is an Privacy Policy, Legal.