Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
JohnLeagsdurg

How i can make a projectile shoot another projectile at you?

Recommended Posts

Woah, are you trying to steal The Sky May Be's job?

Yeah, I know this isn't a helpful answer. Sorry about that. Hopefully someone else will provide one.

Share this post


Link to post
JohnLeagsdurg said:

Hey guys, when i try putting A_CustomMissile to a projectile, it only shoots to the enemy who shooted the first projectile.


Mobjs have a "target" pointer to another mobj. Monster use their target pointer to keep track of who they're attacking.

Projectiles, however, do not attack. So something a little counter-intuitive happens: a projectile's target pointer is instead used to keep track of the mobj that fired it. (Not the mobj at which it is fired.) It's important for projectiles to know who fired them because it lets them pass through their shooter (since the missile is spawned right in the middle of the shooter, it'd otherwise collide with the shooter instantly...) and it also allows to keep track of who killed who, as the projectile's target is credited for the kill if some mobj or player dies when hit. It's also used to keep track of who to blame for infighting.

For this reason, if you use a monster attack function on a projectile, then the projectile will use monster logic and attack its target mobj, which is its shooter according to missile logic.

What you should do instead of using a monster attack function like A_CustomMissile is to use a more generic spawn function like A_SpawnItemEx. Use the SXF_TRANSFERPOINTERS flag so that the subprojectiles will be considered to have been fired by the original shooter; it'll help things like infighting and similar work correctly.

Share this post


Link to post

Yo dawg we heard you like projectiles so we shot a projectile outta your projectile so you can projectile while you projectile.

Share this post


Link to post
Gez said:

What you should do instead of using a monster attack function like A_CustomMissile is to use a more generic spawn function like A_SpawnItemEx. Use the SXF_TRANSFERPOINTERS flag so that the subprojectiles will be considered to have been fired by the original shooter; it'll help things like infighting and similar work correctly.


The problem with a_spawnitemex is that you can't spawn things relative to the pitch of the spawning actor for monsters or their projectiles because they have no pitch, just z velocity. It really doesn't work well for aimed monster attacks, just player weapons.

If you want to have it shoot another projectile at the player, then give it the +ISMONSTER, +LOOKALLAROUND and +ALWAYSFAST flags, and have the spawn state call a_cleartarget (but not in the first frame, put some dummy frames in there) and then a_look every tic in a second state that the first points to and which loops on itself. Put however many tics you want it to wait before firing after the a_cleartarget in the spawn state and before it goes to the second state with a_look. Then put the a_custommissile in a missile state, just like a monster. Make sure to give it a see state that has a_chase too. The limit to this is that the missile it fires will travel independently of the firing missile's trajectory and it will always target the player, even if the monster that fired it is infighting with another monster.

If you want to have a monster missile that fires another missile in a consistent pattern but which follows or remains relative to the fired monster missile's pitch then you have to do hacks with +noclip and +thruactors and have all the missiles actually fired at the same time but not appear until the moment they are "fired" by the other missiles. Look at the barons in Fractal Doom for some code on how to do this.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×