I’m very new to game making and Java Script and have a few questions regarding whether or not I can do what I’m hoping to accomplish within the game that I’m making. The first question is regarding states. I would like to create a state that runs a set number of turns before turning into a lesser version of the same state. Eg: “badly poisoned” turning into “poisoned” or “scorched” turning into “burned”. The second question that I have involves some script I already placed into the game. I used some script to give my enemies line of sight that extends 3 spaces away. I’d like to create some skills for the player to use that would alter that number but am not sure on how that string of code would look like. I’m not sure if you would need to see the two strings currently in use to help with this issue. If it would help I can post it. Any help would be appreciated. Thank you.
MZ Trying to learn JavaScript
Learning JavascriptAre you asking how to code that yourself or how to do that with plugins? Just VS has notetags that run code on expire state to change your state. And for your other question people would need to help what plugin you used. For example VS Encounter Effects you can set the alert range with page comments, so your skill could flip a switch to change enemy event page.
I’m trying to do these things myself without plugins. Currently I’m running on a very tight budget and don’t really have the money to get plugins so I figured that learning some coding myself could help cut down on things I’d have to actually purchase for the game.
Ok cool, I'll let someone else help you then.
But I'll just note that the base VS plugins are free (they have the expire state notetag).
But I'll just note that the base VS plugins are free (they have the expire state notetag).
I do have the free VS plugins so I could do it through the expire state notetag, but it looks like it would still need to be ran with Java Script. I’m not sure what code I’d be using there.
target.addState(id);So I put this into the states note area
<JS On Expire State>
target.addState(32);
</JS On Expire State>
The initial state runs but it doesn’t add the other state. Am I missing something or did I not enter it right?
Looks good to me...assuming that you have VS Skill and States plugin turned on and you put that on the notes of the 'badly poisoned', not 'poisoned'.
I
It’s turned on but the second state doesn’t begin running once the first state expires. The states I’m using are Scorched and Burned. In the Scorched note area I put the script and it runs but on the second turn when it stops running it doesn’t add the Burned state. The turn limit for Scorched is exactly 2 turns.
Ok, I tested it and it works for me.
Maybe someone can help you if you show more info.
Maybe someone can help you if you show more info.
So here are the screen shots of my two states' pages.
Scorched runs fine for the two turns but then Burned never starts. Did I put the script in incorrectly?
Scorched runs fine for the two turns but then Burned never starts. Did I put the script in incorrectly?
Yes, 'expire' is written wrong at the bottom
Well... that's embarrassing. Thank you. I fixed it and it runs now. The only other issues I'm having is regarding the line-of-sight coding. I'd like to create skills that alters the code I already to have to make the line-of-sight shorter of longer depending on the skill used. I'm also trying to integrate a way to enable preemptive strikes and ambushes into the game based off of the direction the event and the player are facing when the collide with each other.
Cool.
As for your other questions, you need to show your code for line-of-sight.
For pre-emptive and ambush, you can check with event commands player direction and enemy event direction and set conditionals depending on that. Here's a link to a thread where I think Caethyril made a plugin to set next battle type:
forums.rpgmakerweb.com
As for your other questions, you need to show your code for line-of-sight.
For pre-emptive and ambush, you can check with event commands player direction and enemy event direction and set conditionals depending on that. Here's a link to a thread where I think Caethyril made a plugin to set next battle type:
Types of battles: standard, Preemptive, surprised and surrounded.
Hey all, Is it possible to do these types of battles? Much like FF6? Where you load into a screen and you have a different parameter and your battle are starting different. Standard - You just load in and off you go Preemptive - the party has a full guage Surprised - the enemy has a full...
forums.rpgmakerweb.com
So, the following code is in a conditional branch without an else branch:
Math.abs($gameMap.event(3).y - $gamePlayer.y) <= 3 && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= 3 && $gameMap.event(3).y == $gamePlayer.y
Then I have the next code in another conditional branch without an else branch as well:
$gameMap.event(3).direction() == 2 && $gameMap.event(3).y < $gamePlayer.y || $gameMap.event(3).direction() == 8 && $gameMap.event(3).y > $gamePlayer.y || $gameMap.event(3).direction() == 4 && $gameMap.event(3).y > $gamePlayer.y || $gameMap.event(3).direction() == 6 && $gameMap.event(3).x < $gamePlayer.x
For the event 3, all it is, is an event touch event that begins the battle processing. Would you need any more info or is this enough?
Math.abs($gameMap.event(3).y - $gamePlayer.y) <= 3 && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= 3 && $gameMap.event(3).y == $gamePlayer.y
Then I have the next code in another conditional branch without an else branch as well:
$gameMap.event(3).direction() == 2 && $gameMap.event(3).y < $gamePlayer.y || $gameMap.event(3).direction() == 8 && $gameMap.event(3).y > $gamePlayer.y || $gameMap.event(3).direction() == 4 && $gameMap.event(3).y > $gamePlayer.y || $gameMap.event(3).direction() == 6 && $gameMap.event(3).x < $gamePlayer.x
For the event 3, all it is, is an event touch event that begins the battle processing. Would you need any more info or is this enough?
Since you're using <= 3, you're comparing if the distance is 3 or less. You can change those to:
Set that variable to 3 at the beginning and then make your skills modify that variable.
I think there's also a mistake in your second conditional, when checking direction 4. Shouldn't you compare x-coordinates in that case, like when the direction is 6?
<= $gameVariables.value(X) (change x to a variable id)Set that variable to 3 at the beginning and then make your skills modify that variable.
I think there's also a mistake in your second conditional, when checking direction 4. Shouldn't you compare x-coordinates in that case, like when the direction is 6?
Yes I accidentally put y instead of x.
So the following code would change from this:
Math.abs($gameMap.event(3).y - $gamePlayer.y) <=3 && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= 3 && $gameMap.event(3).y == $gamePlayer.y
To this?
Math.abs($gameMap.event(3).y - $gamePlayer.y) <= $gameVariables.value(3) && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= $gameVariables.value(3) && $gameMap.event(3).y == $gamePlayer.y
And then I would change that variable in the skill trait area by setting up a common event that changes that variable correct?
So the following code would change from this:
Math.abs($gameMap.event(3).y - $gamePlayer.y) <=3 && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= 3 && $gameMap.event(3).y == $gamePlayer.y
To this?
Math.abs($gameMap.event(3).y - $gamePlayer.y) <= $gameVariables.value(3) && $gameMap.event(3).x == $gamePlayer.x || Math.abs($gameMap.event(3).x - $gamePlayer.x) <= $gameVariables.value(3) && $gameMap.event(3).y == $gamePlayer.y
And then I would change that variable in the skill trait area by setting up a common event that changes that variable correct?
Yeah, but just to clarify, when I said "set that variable to 3 at the beginning", I meant that use whatever variable id for the X and use control variables to set that value to 3 at the beginning of the game.
So when the skill I used it changes the variable number but would I have to create a new event to change it back or would a parallel event just keep it at 3? And I knew about it being the variable id number I just used 3 to keep it simple.
If your skill changes the variable, you can also make it turn a switch on for a parallel common event. In the parallel common event add to a timer variable +1 and when it reaches a certain value use a conditional to set the line of sight variable back to 3, set the timer variable to 0 and turn off the switch for the parallel common event.
Original thread: https://forums.rpgmakerweb.com/threads/trying-to-learn-javascript.176438/