Open ViviLeJeune opened 2 years ago
I agree that it would be helpful to have some way to know which actor sent the projectile. There could definitely be a use to such a function.
If you need to check if something is in range, I did add a range check command to GB Studio v2 and v3, although it takes modding GB Studio and compiling your own version. However, before writing that code, I did implement it in GB Studio with the existing commands as a proof of concept. You have two actors; the first actor is the one you want to see if it is in the range, and actor two is the center of the range. The pseudo-code is something to the effect of:
Based on what I think you might be going for in your game, this should do the trick. It has a few drawbacks, such as requiring some amount of variables, and it takes a bit of fiddling to get it working as a custom script in GB Studio v2 (I haven't tried in v3), but it has a decent speed and shouldn't cause too much noticeable slowdown (unless you have lots of actors running this check at the same time).
I agree that it would be helpful to have some way to know which actor sent the projectile. There could definitely be a use to such a function.
If you need to check if something is in range, I did add a range check command to GB Studio v2 and v3, although it takes modding GB Studio and compiling your own version. However, before writing that code, I did implement it in GB Studio with the existing commands as a proof of concept. You have two actors; the first actor is the one you want to see if it is in the range, and actor two is the center of the range. The pseudo-code is something to the effect of:
- Store actor 2's X position twice in variables "left" and "right".
- Store actor 2's Y position twice in variables "up" and "down".
- Add the number of tiles of your range to "down" and "right".
- Subtract the number of tiles of your range from "up" and "left".
- If actor 1's X >= "left" and actor 1's X <= "right" and actor 1's Y >= "up" and actor 1's Y <= "down", then set variable "result" to true, else set "result" to false.
- Use "result" as your range check in the game.
Based on what I think you might be going for in your game, this should do the trick. It has a few drawbacks, such as requiring some amount of variables, and it takes a bit of fiddling to get it working as a custom script in GB Studio v2 (I haven't tried in v3), but it has a decent speed and shouldn't cause too much noticeable slowdown (unless you have lots of actors running this check at the same time).
Maybe you could turn that into a pull request. Would be a useful feature
@maxoakland pull request submitted for v3! I did in the past for v2 as well, but I think I ended up closing it due to inactivity. It doesn't seem like v2 is getting any more updates, but at some point I'll set up a branch for v2 with some QOL improvements.
@maxoakland pull request submitted for v3! I did in the past for v2 as well, but I think I ended up closing it due to inactivity. It doesn't seem like v2 is getting any more updates, but at some point I'll set up a branch for v2 with some QOL improvements.
awesome work! very useful. v2 is no longer getting updates so that’s great
I think a branch for v2 with some QOL updates would be excellent. I have implemented some in the engine myself, especially in the platformer scene type and I’d be happy to provide that code for your version
Thank you!
That would be excellent! It might take a while to go through everything and make that branch, since my version has a few incomplete ideas I either need to finish or remove, as well as a few things from others that I'd like to give them proper credit for, but I would love to incorporate what you have as well!
Thank you!
That would be excellent! It might take a while to go through everything and make that branch, since my version has a few incomplete ideas I either need to finish or remove, as well as a few things from others that I'd like to give them proper credit for, but I would love to incorporate what you have as well!
Awesome! Just message me and I’ll be happy to get you the code
Is your feature request related to a problem? Please describe. I am attempting to create a stealth-game, but cannot easily emulate an enemy's line-of-sight.
Describe the solution you'd like I believe projectiles are the key for creating what I want, but I need to know who fired a projectile in order to set that actor into alert-mode. I would like a command for ON PLAYER HIT, and that command could let me identify the actor that launched the projectile.
Describe alternatives you've considered I have attempted using big sprites/actors to replicate what I want, as well as using the math commands, but neither are as optimal as using projectiles. Sadly, projectiles are currently unable to identify who launched them.
Additional context Due to the nature of my idea, I've used rapid-fire projectiles to constantly see if something is within range. I believe using my proposed feature too quickly will create lag.