I have a projectile event that can be shot by the player. This is event is essentially relocated to the players location from a hidden place on the map. It works well, however, I call it up from a Common Event, so the event number 005 will change on each map. I realized this is a problem because the projectile would have to be 005 on every map, otherwise it's calling the wrong event.
My solutions are either make the projectile 005 on every map, which is tedious and annoying, or make an event for every map instead that calls its particular instance, as opposed to a common event.
Does anyone have another solution that may be easier? Thanks!
Are you using a plugin for the projectile?What I suppose you can do is-
1. Use a script call like $gameMap.event(this.eventId()) in the common event to indicate the projectile event so that it doesn't have to be a fixed event.
2. Use an event spawner so that the event can just spawn in every map. In this case, you don't need a common event (since it's the same event across multiple maps)
Edit: I just notice it's in the game mechanics design section. But I assume you use MV. So my answer is for RMMV.
Maybe use Event Id1 on each Map. It's the easiest and less work intense solution.
Other solution could be:
Checking all 999 Event Ids, 1st condition to see if event id exist, 2nd condition to check if the Event Name contains for example the Word: Bullet.
Or in your Code you make a branch for every map ID, and in it you change a Variable to the correct number, which later represents the corect event id for the map to use.
You could use a specific event name on every map, even if they have different ids. Then make your common event search through the map events for the ONE event with that name, and that is the event (and event id) that will be used for that map.
making events on the fly, by code, is possible.
I don't know about them coming from a common event, tho.... or, available without a refresh of the map...... but it is possible.
however, if what you're doing is a projectile, it might as well be a projectile object (a custom object, made by you, by code) which could simply be a sprite, *which*, would be available on demand from anywhere without requiring an extra refresh.
(I mean, it requires one, but the map would take care of it)
if you're using an event because that's your only way of obtaining a source and destination position, and a path between them,...... you can also do that with a sprite.
for the purposes of shooting a frame of a picture between two points, an event is overkill, because the event carries with itself the ability to run code, and check for global variables, which you don't even need.
You can make your event set it's ID to a variable (via control variables) and use the variable where you need it.
Then your event will update the variable ID on every mapload if you want
the actual projectile is one: the one sprite shot from a point towards another point.
that one projectile, can have properties like any other object.
if you make the object yourself, you define what you want.
if your problem is making the thing move and that's the reason why you're using an event relying on it's move route, then that specific aspect can be taken in, and made into it's own object, separate from the definition of event.
it would be a *projectile* object, not an *event*.... and it'd work differently, and have different properties, but all that can be made to specification if you write it from scratch.
by your definition it seems you're making something like an action battle system.
there are plugins for that.
Yes Martins Idea is good.
Have a Parallel Event on each Map with the code:
control variable1 = Event ID of the Bullet Event on this Map. For example: 5 on Map id1 and 23 on map id 2.
Erase Event Eventcommand, thisway the Event only runs one time every time the map is entered/loaded.
The Bullet Object sounds interesting. Is this only 4 directions or are you planning for 16 or more direction angles?
For 4 Directions using an Event seems more flexible and simple, for more directions/angles, it seems to become very difficult using Events. Because you cant Move them very flexible diagonaly towards 2 points while being able to erase the picture on collision. Sadly Picture Bullets have Problems when the Map starts scrolling.
Maybe a fix Picture to Map Plugin can also be used to Move pictures while they are fixed on the map grid instead of game screen??? Than the Picture would be his Bullet Object, and the collision code would be handlet in one of the Events. But it could turn out Animating a Picture is difficult, animating an Event was easy.
Edit:
What if the Bullet suddenly is a Fireball?
- Events could be animated.
- You could Play a Database Animation of a not moving but animated Fireball ontop of a Moving Event which has no Graphic and represents the Bullet.
- Not sure how easy it is to Animate Scripted Bullet Object. (Would be interested to see more of that solution also, just mentioning my thoughts about this in General maybe it helps Brainstorming)