Lesson Goal: Learn how to make a range common event for moving enemies all while keeping your map clean and lag free. Also will
introduce the concept of ranged weapons for an ABS.
Alright, I know I've been putting this off but it's time for me to post this tut on a lag free player/enemy range check, and in this tut I will be introducing the concept of ranged weapons. (Setting it up, if you want to use it then you must continue with it your self). So let's begin! First we're going to make a common event and lets name it "Range Weapon" This will surprisingly be quick if you kept the code we did in the last range tut. In my example, I'll be showing how to make a "Line-of-Sight" range weapon.
Start by making a condition branch and the condition will be "If the player is facing down" Now this is going to be a small bump of branchs with in a branch. Start off with the condition branch with "If Range X is = 0" This will check to see if the player is with in the same line as the monster. Inside that branch we will make another condition branch checking to see "If Range Y = -4" and make sure to check the "Else" box. The range weapon has a range of 4 squares. If the condition is true, then add the animation on the monster NPC to show that it got hit, then make sure to add a delay (Your choice, 60 frames is decent) so that the player can't hold the range button (will talk about button configuration later in this tut) and have no delay in ranged attacks. Now in the "Else" section of this branch you will make another condition branch, with Else checked, and the condition will be "If Range Y = -3" Repeat the above and continue doing the branchs untill you have it looking like this (You do not need to check Else on the "If Range Y = -1" branch) :
(http://i313.photobucket.com/albums/ll387/Feliusfeefee/codeexample.png)
If you got that down, the rest is just the same except you have to mod the Range X and Range Y condition to the correct facing (So the player can't shoot backwards!) Here are the facing and the numbers used for the X and Y:
Down- (X = 0)(Y = -4, -3, -2, -1)
Right- (Y = 0)(X = -4, -3, -2, -1)
Up- (X = 0)(Y = 4, 3, 2, 1)
Left- (Y = 0)(X = 4, 3, 2, 1)
Once you have all the branchs done, make another condition branch but for this one, name it "Player/Monster X/Y" Remember that very first condition branch we made? It's exactly like that except this time, at the very start of the condition branch we are adding what we had in the events in the last tut in there because with this range method, it doesn't not use events placed on maps (To avoid lag). Which should look like:
(http://i313.photobucket.com/albums/ll387/Feliusfeefee/codeexample2.png)
Now go back to our "Range Weapon" condition branch and at the very begining add "Call Common Event" and call the "Player/Monster X/Y". We're almost done! Now we just need to configure the buttons. Make a new common event and name it "Button Configure" and set it to parallel process, and make a new switch and name it what ever you want (Recommended is "Ranged [On/Off]") as with this switch, you can turn it off when the player has a stat effect on or something that restricts ranged attacks (Another tut, another time~ :P I'll explain stat effects in an ABS system) Make a condition branch and set the condition to "The Z button is being pressed" (Note: You can set it to any button you want, this is the button the player will need to press in order to use a ranged attack (Default set up Z button is D on the keyboard but you can change it by pressing F1 in test play)) Now, what I did was I wanted to make it so the player had to have a ranged weapon equipped. So I made a weapon called "Rock" in the database. Now in our condition branch, check the "Else" box, and make the condition "If [Character you are using] has rock equipped" If true, then call common event "Range Weapon", in the else make a message telling the player they need a range weapon equipped. The common event should look like this:
(http://i313.photobucket.com/albums/ll387/Feliusfeefee/rangeweapon2.png)
All finished! If you did everything correctly, when you run your game everything should run just fine. Now a few notes, if you wanted to add a damage system, the branch area where we added the animation and delay, that's where you would put any "Monster HP - 1" variable changes. Also keep in mind this is a VERY basic ranged weapon event. If you wanted to get more advanced then you will have to continue yourself, as I just provided a base example to assist the new eventers. Now if you wanted to get fancy, and you wanted a "Ring" damage effect and not a Line of Sight (Say, if you threw a Chakram) then you would have to do multiple Range X = 1, Range Y = -1 and then another X check inside that condition branch followed by the Y. You would have to form a loop with the right numbers.