Set angle for spawned missiles

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
Heretic_Crossbowman
Posts: 10
Joined: Sat May 11, 2019 3:50 pm

Set angle for spawned missiles

Post by Heretic_Crossbowman »

Hello all!
I am trying to create a projectile that spawns another small projectiles around it in half circle.
I am trying to use that code
Spoiler:
So everything works right except that angle of small projectiles is based on absolute value and doesn't depend on movement vector of initial projectile. How can i solve that?
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: Set angle for spawned missiles

Post by Matt »

The curse of NoDelay strikes again! :(

That A_PhoenixFire is not being called. Try

Code: Select all

FX08 A 1 nodelay Bright A_PhoenixFire;
Heretic_Crossbowman
Posts: 10
Joined: Sat May 11, 2019 3:50 pm

Re: Set angle for spawned missiles

Post by Heretic_Crossbowman »

Matt wrote:The curse of NoDelay strikes again! :(

That A_PhoenixFire is not being called. Try

Code: Select all

FX08 A 1 nodelay Bright A_PhoenixFire;
Tanks )) But as i understand NoDelay, i don't need it here because i WANT to spawn small projectiles all the way )
Question is how to orient them in the direction AWAY from player who shoots first projectile )))
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: Set angle for spawned missiles

Post by Matt »

i don't need it here because i WANT to spawn small projectiles all the way
I don't understand what those words mean in this context, but to take a guess at one thing they don't mean:

Without the "nodelay" in the first frame of a spawn state, nothing in that frame gets called. You will either need a frame just before it (could be zero-length), or the "nodelay" keyword.

For A_PhoenixFire to be called at all in the above code you either need the nodelay or this:

Code: Select all

FX08 A 0;
FX08 A 1 Bright A_PhoenixFire;
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Set angle for spawned missiles

Post by KeksDose »

Mind the loop, Matt.

And for the angle, this should do the trick if the projectile you showed us has the correct angle.

Code: Select all

phoenixfire.angle = angle - 90 + i*22.5
Heretic_Crossbowman
Posts: 10
Joined: Sat May 11, 2019 3:50 pm

Re: Set angle for spawned missiles

Post by Heretic_Crossbowman »

So here is result of what i've made. Fiery "Fan" spawns around projectile, but its angle is constant due to world coordinates not to primary missile's vector of movement :) So it doesn't matter from which point i shot - orientation of additional projectiles is contant.


User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Set angle for spawned missiles

Post by Void Weaver »

Maybe I am too dumb but I still don't understand what's wrong with angles of the missile trail. o_0

Or... are you looking for something like this? But actually I don't see any specific difference aside from fact that is seeker missile with transferred "static" pitch.
Image Image Image Image
Heretic_Crossbowman
Posts: 10
Joined: Sat May 11, 2019 3:50 pm

Re: Set angle for spawned missiles

Post by Heretic_Crossbowman »

I've created a scheme ofwhat i want! ))
Blue point represents initial missile
Blue arrow represents it's vector of movement
Red arrows represent vectors of "child" missiles

User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Set angle for spawned missiles

Post by Void Weaver »

Oh, got it! :D

So, if you still want to optimize it, then it still can be expressed as anon. func.:

Code: Select all

Speed 5
var float user_MAngle;
States
{
Spawn:
FX08 A 1 Bright NoDelay
{
	For(A_SetUserVarFloat(user_MAngle,-90); user_MAngle<90; A_SetUserVarFloat(user_MAngle,user_MAngle+22.5))
    {
        A_SpawnItemEx("PhoenixFX2",0,0,Height/2,10,0,0,user_MAngle,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH);
    }	
}
Loop
Post Reply

Return to “Scripting”