Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → FireProjectile() vector...
FireProjectile() vector...
2005-09-09, 10:42 AM #1
Hey folks,

I suck with vectors...so what I'm wondering is, if I have a fireprojectile line what vector do I need for the bullet to originate BEHIND me, and travel directly toward me(and collide with me, so in essense I would be shooting myself).

This pic shows it more clearly:
Attachment: 7149/example.JPG (9,641 bytes)
2005-09-09, 10:50 AM #2
'0 -x 0'

Make the x be distance in JKU's behind player.

Traveling toward player would be based on a template param (don't know which one), but a default one should work because default is traveling forward. (Actually, the template param might use the direction given by the FireProjectile offset, so you might need to reverse the vector used in the template param.)

:)
2005-09-09, 12:33 PM #3
Thank you, I'll go try this out.
2005-09-09, 1:42 PM #4
Make sure the bullet doesn't have the 0x1 weapon flag, if you want it to damage the shooting player.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-09-09, 6:01 PM #5
FireProjectile creates the template at the player's position added to the offset param in the FireProjectile() line. This offset is relative to the player's look direction, not the map coords. The verb also sets the lookvector to that of the player, and sets the velocity of the projectile to that specified in the template -- vel=(x/y/z) -- (also relative to the player's look direction when using FireProjectile() ) though the bullet's lookvec and vel will be slightly altered with the error vec param of the verb.

Hopefully that made sense at least the second time around...
May the mass times acceleration be with you.
2005-09-10, 7:26 AM #6
Ah I think I understand.

Maybe the best thing to do would be to create a bullet at a position behind the thing, instead of using FireProjectile(), because I forgot that it always uses the player look vector, and I was thinking with the right coords it would work fine, but I see that wouldn't work.

CreateThingAtPOS() would probally be my best bet? Using '0 -x 0' ?

Thanks guys.

ReT
2005-09-11, 3:24 PM #7
No, FireProjectile() will do what you want.... You'd be butchering unnecessarily if you use CreateThingAtPos()
Code:
   vec = VectorScale(GetThingLVec(player), -x);
   offset = VectorAdd(vec, GetThingPos(player));
   bullet = CreateThingAtPos(tpl, GetThingSector(player), offset, '0 0 0');
   SetThingLook(bullet, GetThingLVec(player));
   vec = GetThingLVec(bullet);
   vel = VectorLen(getThingVel(bullet));
   SetThingVel(bullet, VectorScale(vec, vel));

The above code is the equivalent of:
Code:
 FireProjectile(player, tpl, -1, -1, VectorSet(0, -x, 0), '0 0 0', 0, 0, 0, 0);


It's a GOOD thing that FP() uses the lookvector, because otherwise, at any one given position, no matter which way you were turned it would create the bullet at the same position. See attachment for visual explanation.

In short, use the FireProjectile method and it will work exactly how you want it to.
May the mass times acceleration be with you.
2005-09-14, 9:14 AM #8
Thank you, I'll try this out soon.

↑ Up to the top!