So i am using the real-time combat, but the issue is that i want the enemy to have multiple attacks with different colldowns, and it is not possible to do in a single event. So i will have an invisible events with different attacks standing on same position as the original event. But this way i can't make the enemy move, because those additional events would have to mirror main event's steps. Is there a way to do that?
Make event follow other event and be on same tile as the parent event?
RPG Maker MV Supportthat is a rather strange way of handling this.
usually the placeholders for projectile events are placed somewhere out of the way and invisible, and when an attack is triggered by button press, the event triggered (usually a common event) teleports the bullet-event under the player and starts it then.
That way there is no need for one event following another (which would often cause timing problems as well)
usually the placeholders for projectile events are placed somewhere out of the way and invisible, and when an attack is triggered by button press, the event triggered (usually a common event) teleports the bullet-event under the player and starts it then.
That way there is no need for one event following another (which would often cause timing problems as well)
LOL just use conditional/if statements. But if you really want to do it with events piled on top each other use CT_Bolt's BindCharactersTo. It'll make it so events are attached to the player/other events.
Thanks, i will try to look if that is possible.
I am not sure how the logic of it would go. I need the different shots occur at different speed, so i have to input pause after each of them. But pause also will affect shots bellow and above (since event supposed to repeat).
What can i even use as a condition to seperate those?
You're going to need to declare attack cooldown properties on the enemies for each attack they have. Then have the parallel event page tick down each of those properties by one every frame. If the property is 0, do the attack, reset it to 60 (or whatever the cooldown is).
I do not understand the property part.
I get that i need to make parallel events that will have a conditional branch with timer, and when timer runs out they send the command to the main event to perform the action. But what is the command, and how does main event rekognize it? I assume it's the cooldown property but i don't know what it is. And how to trigger it from different event either.
Events are javascript objects. Objects have properties. Events have properties like their x and y position, their priority, direction, etc. If you want to see what properties an event has open up the console and type in $gameMap.event(ID). You can also add new properties on the fly like how QJ Bullet adds an hp property to the event on the event's first page. In the same way you need to add attack cooldown properties for every attack that event has.
Then on the event's second page you increment down each of those attack cooldown properties every frame.
Then on the event's second page you increment down each of those attack cooldown properties every frame.
But to do that you need to know the exact command that is needed. When you helped me solve cooldown issue last time, a simple pause after the code were used, so i don't know other methods.
Also, i checked the properties of event with one ability and two, and they are fully identical. So even if i knew the command, i would still need a way to tie it to the specific attack code. And then also find out the exact command that would activate those properties from parallel events.
Since i can't learn JS, i can only search for such information, and the internet came up with this:
function createCooldownFunction(cooldownTime) {
let lastExecuted = 0;
return function() {
const now = Date.now();
if (now - lastExecuted < cooldownTime) {
console.log(`Please wait ${Math.ceil((cooldownTime - (now - lastExecuted))/1000} more seconds`);
return;
}
lastExecuted = now;
// Your function logic here
console.log("Function executed!");
};
}
let lastExecuted = 0;
return function() {
const now = Date.now();
if (now - lastExecuted < cooldownTime) {
console.log(`Please wait ${Math.ceil((cooldownTime - (now - lastExecuted))/1000} more seconds`);
return;
}
lastExecuted = now;
// Your function logic here
console.log("Function executed!");
};
}
I put it into the plugin, and then internet says that the usage would be "const cooldownFunction = createCooldownFunction(3000);" for 3 second cooldown.
So i put it in the event's code just to test if it will work,
And of course it's not working, giving me unexpected identifier error, that should be expected from code where i have no idea how it functions or is it even legit.
I said to declare new properties on the event the same way hp was declared a new property on the event. You copied and pasted some random function into the plugin file then tried to call it from within the bullet object.
The solution is much simpler.
It looks like this:
On the first page declare the new event properties. Parallel makes it so it runs automatically on map load then self switches to page A.
The second page is also parallel because it is repeating commands. Every frame subtract 1 from both cooldowns and check both cooldowns if they are 0 (or less). If so, fire the corresponding bullet and set the cooldown properties to 45 and 60 again.
The solution is much simpler.
It looks like this:
On the first page declare the new event properties. Parallel makes it so it runs automatically on map load then self switches to page A.
The second page is also parallel because it is repeating commands. Every frame subtract 1 from both cooldowns and check both cooldowns if they are 0 (or less). If so, fire the corresponding bullet and set the cooldown properties to 45 and 60 again.
Thank you, those calls is exactly what i did not knew.
But it is not working, did i made a mistake? It's on full minigun mode without any cooldown at all.
You never reset the cooldown after firing the bullet. I said multiple times to reset it.
You need to think about this logically. You set two properties, put in a parallel event page running every frame to subtract from their values, and also check every frame if one of them is 0 or less, then fire a bullet.
Without resetting it will just go to negative infinity and always be less than or equal to 0. Your second cooldown property also does nothing because you only have one bullet firing.
You need to think about this logically. You set two properties, put in a parallel event page running every frame to subtract from their values, and also check every frame if one of them is 0 or less, then fire a bullet.
Without resetting it will just go to negative infinity and always be less than or equal to 0. Your second cooldown property also does nothing because you only have one bullet firing.
First i tried the wild guess - adding the "attack1cooldownreset" at the end of the bullet event, but it did not work.
The other possible way is to revert the a-switch so first page will work again. But it would mean that both cooldown will be reset at the same time, and i need them to do it separatly.
Then, after thinking for a while, i remembered how placing new picture replaces previous one, and tried to place command that sets up the timer into the shooting script and it worked!
I also messed up with moving one of the bullets, check out this hilarious mess)
I did a mistake assuming that the timer will somehow return to default value once function is used.
Anyway, thank you a lot for your help! Without you i would never figured this out.
All you had to do was set this.character(0).attack1cooldown = 45; after firing the bullet. The answer was in my screenshot.
Yep, i missed that part because i didn't thought that something needs to be added to bullet code itself.
But hey, i figured out what exactly i needed to do eventually, and understood the whole process better.
It is not part of the bullet code. It's outside of the bullet function. I just put it in the same script box.
I understand that. What i said is i was not checking the box with bullet code because i did not expected it to change. No pun intended, but it's sometimes hard for me to think out of the box.
Original thread: https://forums.rpgmakerweb.com/threads/make-event-follow-other-event-and-be-on-same-tile-as-the-parent-event.177026/