+Shootable Projectiles?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Graaicko
Posts: 532
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

+Shootable Projectiles?

Post by Graaicko »

So I made an enemy that throws syringes at you, they do a high amount of damage. I came up with the concept of making the syringe projectiles shootable which would destroy them. If you've ever played those shooter arcade games where you have the physical gun and an enemy throws knives at you on screen for example, you can shoot them and it deflects them. Kind of the same idea. Problem is I don't know how I would execute this.

Projectile Actor
V V V
Spoiler:
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: +Shootable Projectiles?

Post by Logan MTM »

Try use a second actor as colision spawned in the first projectile frame. This second actor must be Warped as childrem and kill the master in his pain State. #ilovehacky
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: +Shootable Projectiles?

Post by Matt »

Try giving it -NOBLOCKMAP and see what it does then.

EDIT: The death state might also do well to call some stuff to flag it as -MISSILE, change its direction of movement, etc. because IIRC something simply dying like a monster won't imply it'll stop acting like a projectile.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1117
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: +Shootable Projectiles?

Post by Jekyll Grim Payne »

Projectiles can't be shootable. Spawning a hitbox is the only way to imitate that.
Moreover, it's actually better because most of the time it's a good idea to make a hitbox *larger* than the projectile physically is.

Here's a hitbox I use to make grenades shootable in Painslayer: https://github.com/jekyllgrim/Painslaye ... un.zs#L461
Note that I don't destroy anything in CanCollideWith because that would be very bad; instead I queue it for destruction by modifying pointers.
User avatar
phantombeta
Posts: 2162
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: +Shootable Projectiles?

Post by phantombeta »

Jekyll Grim Payne wrote:Projectiles can't be shootable. Spawning a hitbox is the only way to imitate that.
Moreover, it's actually better because most of the time it's a good idea to make a hitbox *larger* than the projectile physically is.

Here's a hitbox I use to make grenades shootable in Painslayer: https://github.com/jekyllgrim/Painslaye ... un.zs#L461
Note that I don't destroy anything in CanCollideWith because that would be very bad; instead I queue it for destruction by modifying pointers.
That's not true. Projectiles can very much be made shootable: the attached PK3 does exactly that, without any "hitbox" hacks or modifying things from CanCollideWith. (Modifying pointers is still breaking the function's contract!)
Attachments
ShootableProjectile.PK3
(386 Bytes) Downloaded 93 times
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1117
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: +Shootable Projectiles?

Post by Jekyll Grim Payne »

phantombeta wrote: That's not true. Projectiles can very much be made shootable: the attached PK3 does exactly that, without any "hitbox" hacks or modifying things from CanCollideWith. (Modifying pointers is still breaking the function's contract!)
I remember this not working in a few versions; perhaps it's been brought back.

Even if it's doable, I don't think it's a good idea both because using a hitbox of a difference size is better gameplay-wise, and because I'd rather not include the projectile in blockmap.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: +Shootable Projectiles?

Post by Matt »

Better to include the projectile in the blockmap than to spawn a whole separate actor that is then included in the blockmap.
Post Reply

Return to “Scripting”