Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

[Eventing] Projectiles On Map Using Events - Works But Not Well

I was watching some Youtube tutorial videos when I came across a couple that had an on-map projectile system - basically your characters could fire off projectiles outside of battle - using only events. I thought it was a neat idea and started building off of it. What I came up with was a bit of an expansion on the idea: every character in the party has a different projectile, based on elements, and can use the projectile to solve puzzles. This part works perfectly. Then I gave on-screen enemies the ability to use projectiles, and to be hurt by player character projectiles, and to also be able to hurt player characters with their projectiles. This led to problems with hit detection. And also, for some reason, the events that fire projectiles will only do so for a minute or less, then they stop. I also added a shield mechanic where player characters can use their shield to bounce projectiles back. This part has never worked. The only thing I can get to happen is for there to be a shield, when the player holds down a button. It doesn't work any other way tho. So I'm hoping I can post the events I used to make this happen and someone can look it over and show me where I'm going wrong.

Since this is a whole lot of eventing/explaining/etc, and I've already done it at another forum, I'm just going to post links to the topics. If an admin objects to this, I'll be happy to copy and paste, but it's a whole lot of text. Anyway, here's the links:

Player Character Projectiles

Enemy Projectiles
 

Caz

NPC
Xy$
0.00
I did something like this for a VXA Lite game a while back (over here if you wanna download it and take a look at the files, the events are pretty similar in VXA as they would be in MV) but I totally understand the pain. I used Battle Animations for the projectiles instead of events but to be honest, it's still.. pretty clunky..;;;

I would recommend using Common Events instead of an event on each map, as RM has this really stupid thing about ignoring events once your player travels a certain distance away.

The other issue I encountered is the way RM calculates event locations. If an event is moving between two tiles, it may look as though it's in a particular place, but it won't be calculated very precisely. I personally find it much more precise to use Screen X and Y, since it's pixel-perfect when your projectile strikes its target. For that reason, it might even be better to use pictures as your projectiles instead of events.

As for the shield, you'll need to create a new Switch and a Common Event for when the player holds that button, and to detect when the player has been hit by an enemy projectile, then play out another Common Event for that projectile to bounce back and technically become the player's projectile.

Lemme know if I can explain anything further in depth or if you have questions. I've only sort of briefly touched on things here, but I can post screenshots in the engine showing what to do if you're super stuck!
 
I'll have to try out using Screen instead of Map for the X and Y positions. You kinda lost me on the common event thing for the shield. How would I set that all up? ... Actually, how would I go about making all of this into common events? Sounds like that's better than having a bunch of parallel events? Thanks for all the help! I'm glad someone could figure out what I was on about. Part of the reason I wanted to set this up with events, besides just to say I did, is bc I'm not sure there's a plugin that would let me just have projectiles (since they all seem to be tied to an ARPG system, and the one that isn't I can't figure out how to use) and I don't think I can switch between that and turn based, and my game is really turn based just with an added mechanic.

[edit3: Actually, it's weird. Some times it works perfectly and other times it screws up. I didn't see anywhere that I messed up the code in. But sometimes the projectile shows up in a weird spot on the screen. I'm gonna try cleaning up the code and changing the X & Y position thing and see what happens.]

[edit2: And oddly enough, the projectiles seem to be working correctly now even though I haven't changed anything. By correctly I mean the enemies will continue to fire off projectiles without stopping, and I was actually able to shield from a projectile and have it hit back at a crystal to make it break/disappear. I'm going to take your advice though and see if I can't get something that works better and is more reliable b/c it still will only work when it wants to.]

[edit1: (This is how I had attempted to do the shield before:)]

Code:
◆If:Script:Input.isTriggered("shield")
  ◆If:Leader = 1
    ◆Set Movement Route:Player (Wait)
    :                  :◇Image:!Crystal(5)
    :                  :◇Wait:20 frames
    :                  :◇Image:Monster(7)
    ◆
  :End
  ◆If:Leader = 2
    ◆Set Movement Route:Player (Wait)
    :                  :◇Image:!Crystal(5)
    :                  :◇Wait:20 frames
    :                  :◇Image:juju(0)
    ◆
  :End
  ◆If:Leader = 3
    ◆Set Movement Route:Player (Wait)
    :                  :◇Image:!Crystal(5)
    :                  :◇Wait:20 frames
    :                  :◇Image:porcelina(0)
    ◆
  :End
  ◆If:Leader = 4
    ◆Set Movement Route:Player (Wait)
    :                  :◇Image:!Crystal(5)
    :                  :◇Wait:20 frames
    :                  :◇Image:Tonetta(0)
    ◆
  :End
  ◆
:End
 
Last edited:

Caz

NPC
Xy$
0.00
I'm not sure if there's a plugin but someone out there must've done something similar for an Action Battle System. I'm not well versed in plugins either though, I much prefer to event everything.

The Common Events would be the same as the events on the map, but use Common Events as parallel processes, maybe even have them only active when a switch is on so you can turn it off for certain areas/cutscenes/etc.

For the shield, I figure you'll have to have a switch turn on that also turns off the switch that lets you throw a projectile (otherwise you'd be able to hide behind your shield while you throw projectiles, making you pretty much invincible). Then you'd have another Common Event that detects if/when the player is hit by an enemy projectile. Have a conditional branch to detect if the shield is active when the player is hit, and if so, activate another Common Event that disposes of the enemy projectile and fires out a player projectile that can hit the enemy.

I hope that makes sense.. :D;;;;
 
Here's where I'm at with this: The events that control the projectiles have If/Then statements nested one within the other, both to display the projectile in the right place at the right time, and for that projectile to interact with other events on the map. In order to change this from having a parallel process event on every map, I will go having a common event set to parallel process. There are three ways that I can see to do this:

1) make a new common event for every map that has projectiles and leave the nests the way they are. I would need to have a new comment event for every map because there are different events on each map that will need to be interacted with in different ways, so I can't just use the same common event on every page. These events will be turned on and off by a switch, on every map, so I will need a new switch every map as well. Seems like a lot of work but if it makes things work better, I'm all for it.

2) split up the if/then statements so that only the part that pertains to showing the projectile will be in the common event. That way, I can have a parallel event on each map that contains the "what to do when this event is hit with this projectile." I won't need as many common events or switches this way. But I don't know how to go about doing this.

3) make a common event that has the projectile show up on screen and also has the "what happens when the projectile interacts with an event," and just include every single event from every map. I would name all the events, but I'm not sure if that is enough for RMMV to be able to differentiate in a common event that I mean "this event on this map" as opposed to "that event on that map."

Any suggestions before I start in on doing it #1 style?
 
Top