MV help with Galv's Map Projectiles

Hello! I hope everyone is okay 🙂

Lately I've been trying to edit/add a function in the Galv's Map Projectiles plugin where when a specific type of shot is launched, when it disappears either by touching a wall or simply reaching its maximum distance, it leaves a cloned event (using the plugin too from galvs: Galv's Event Spawner)
the player's weapon would basically be a slingshot where he would launch the stones and could recover them by going to the place where they fell (if the stones didn't hit in an event, in that case they would not be recovered)

I hope someone can help me, since I can't do it on my own XD

Thanks for your time, have a nice day 😉
You would have a conditional statement to check if the player's equipped weapon is a slingshot then run Galv's script:

Galv.PROJ.atTarget(sid,tid,s,d,'img',anim,'action',[r],[t],z,pid,size);
Galv.PROJ.dir(sid,dir,s,d,'img',anim,'action',[r],[t],z,pid,size);

r = list of regions projectile will hit and stop on. Blank = none

t = list of terrains projectile will hit and stop on. Blank = none
'action = actions to execute when the projectile hits a player or event.
These actions only affect events with <projEffect> comment
Player and event actions are separated by | symbol
eg. playerAction|eventAction
Actions below:
c(x) // run common event x

So for the 'action' argument, make the common event the rock spawn at the location it disappeared
You would have a conditional statement to check if the player's equipped weapon is a slingshot then run Galv's script:



So for the 'action' argument, make the common event the rock spawn at the location it disappeared
thank you this is a big step forward 😀
but how would I get the x and y coordinates from where the shot disappeared?
thank you this is a big step forward 😀
but how would I get the x and y coordinates from where the shot disappeared?
You calculate it based on the initial firing point (the player), the direction the shot was fired and the max distance the shot can travel. If it hits a wall (defined by the regionID) you would run the spawn script at the same time as the collision.
You calculate it based on the initial firing point (the player), the direction the shot was fired and the max distance the shot can travel. If it hits a wall (defined by the regionID) you would run the spawn script at the same time as the collision.

I understand, there is this calculation in the default rpg maker? Or do I need a plugin for that?
I understand, there is this calculation in the default rpg maker? Or do I need a plugin for that?
After looking through the projectile plugin code, it's already being calculated and the bullets do have x and y positions. So it's going to be a matter of referencing that information in the spawn plugin command and some trial and error.
After looking through the projectile plugin code, it's already being calculated and the bullets do have x and y positions. So it's going to be a matter of referencing that information in the spawn plugin command and some trial and error.
all these commands can be done in an event on the map, right? (sorry for so many questions XD)
all these commands can be done in an event on the map, right? (sorry for so many questions XD)
Yes, a parallel listening event on the map should be able to handle it, and it would only need to be running while the player has the slingshot equipped, or a couple seconds after every shot.
Yes, a parallel listening event on the map should be able to handle it, and it would only need to be running while the player has the slingshot equipped, or a couple seconds after every shot.
another kinda disconnected question here is there a way to make an event run only after you hold the key for about 60 frames and then release it? as needed, wait to pull the slingshot
another kinda disconnected question here is there a way to make an event run only after you hold the key for about 60 frames and then release it? as needed, wait to pull the slingshot
Yes, see attached screenshot. Just put the command you want to happen before the reset to 0, and adjust the check on the pressDownTime if you want it longer. Oh, and put in a parallel event. I'll take a look at Galv's plugins tonight if no one else does as I need to head out soon. But basically, you need to get the bullet coordinates at the points they disappear (when they hit an event, a wall region, or their max travel distance), then feed those coordinates into the Galv Spawner.
Yes, see attached screenshot. Just put the command you want to happen before the reset to 0, and adjust the check on the pressDownTime if you want it longer. Oh, and put in a parallel event. I'll take a look at Galv's plugins tonight if no one else does as I need to head out soon. But basically, you need to get the bullet coordinates at the points they disappear (when they hit an event, a wall region, or their max travel distance), then feed those coordinates into the Galv Spawner.

ok, thanks a lot for helping me, if i have any other problem regarding this i will send it here
Yes, see attached screenshot. Just put the command you want to happen before the reset to 0, and adjust the check on the pressDownTime if you want it longer. Oh, and put in a parallel event. I'll take a look at Galv's plugins tonight if no one else does as I need to head out soon. But basically, you need to get the bullet coordinates at the points they disappear (when they hit an event, a wall region, or their max travel distance), then feed those coordinates into the Galv Spawner.
everything works perfectly! Thank you 😀

just had a little problem with walls
and sometimes it ends up going inside events XD

if the shot hits an event it wouldn't leave a stone behind and if it hits a wall, well... the stone would have to be on a tile that isn't a wall XD

when I shoot near a wall the event stays inside it, is there any way to make that not happen?

imagem_2023-05-06_200751586.png
when I shoot near a wall the event stays inside it, is there any way to make that not happen?
Have a script that checks the 8 tiles around the rock for the wall region id and spawn it in the first result that's not a wall region
Have a script that checks the 8 tiles around the rock for the wall region id and spawn it in the first result that's not a wall region

thanks, can you tell me how is this script?
thanks, can you tell me how is this script?
I have one back on my PC but I'm away phoneposting right now.
I have one back on my PC but I'm away phoneposting right now.
oh right, sorry
See if this works?
You need to fill in projectileX, projectileY, spawnMapId (from the spawn map) and wallRegion with your own values.


JavaScript:
var projectileX = insert value here;
var projectileY = insert value here;
var wallRegion = insert value here;
var spawnMapId = insert value here;

outerLoop:
for (let x=1; x<=3; x++){
    for (let y=1; y<=3; y++){
        if (projectileX-1+x>=$gameMap.width() || projectileY-1+y>=$gameMap.height())
            continue;
        if ($gameMap.regionId(x, y)!=wallRegion)
            Galv.SPAWN.event(spawnMapId,x,y);
        break outerLoop;
    }
}
See if this works?
You need to fill in projectileX, projectileY, spawnMapId (from the spawn map) and wallRegion with your own values.


JavaScript:
var projectileX = insert value here;
var projectileY = insert value here;
var wallRegion = insert value here;
var spawnMapId = insert value here;

outerLoop:
for (let x=1; x<=3; x++){
    for (let y=1; y<=3; y++){
        if (projectileX-1+x>=$gameMap.width() || projectileY-1+y>=$gameMap.height())
            continue;
        if ($gameMap.regionId(x, y)!=wallRegion)
            Galv.SPAWN.event(spawnMapId,x,y);
        break outerLoop;
    }
}
OK thanks 🙂

what would the projectileX and y be? the coordinates where the shot will start?

And should I put this together with the event?
OK thanks 🙂

what would the projectileX and y be? the coordinates where the shot will start?

And should I put this together with the event?
It's the coordinates where the projectile disappears when it hits a wall.

You put in place of your current spawn command when a projectile hits a wall
It's the coordinates where the projectile disappears when it hits a wall.
something like that?

imagem_2023-05-07_124943002.png
imagem_2023-05-07_125026663.png


imagem_2023-05-07_125327718.png
imagem_2023-05-07_125426500.png
imagem_2023-05-07_125552127.png

Original thread: https://forums.rpgmakerweb.com/threads/help-with-galvs-map-projectiles.157293/