Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
YattaYatta

Spawning a bullet : Muzzle position, Player aiming vector, damage source.

Recommended Posts

Hello. Im trying to do fancy things with weapons, and one of those requires me to manually spawn a bullet.

So far I can "shoot" the right bullet (same as current weapon) from from of the player, in the vectorDir direction.

What I am missing :

- Shooting the bullet from the actual muzzle of the gun. For now Im shooting it from 1 meter in front of the player, so at very close range its inaccurate.

- An actual aiming vector. vectorDir does not return a Z parameter - direction is flattened.

- Defining the "source" of the bullet. If that bullet kills an enemy, I need to know who "shot" it. Also can you call a "setDamage" function with a source parameter for the same reason ?

[edit]

As usual, no matter how much time you spent on the problem you find (part of) the solution just after asking for help on the forum.

Since im using a "fired" eventHandler, I figured out I could simply copy the provided projectile parameter's velocity and position to my new projectile.

However I still have no clue how to define the projectile's source, or a setDamage source.

Edited by YattaYatta

Share this post


Link to post
Share on other sites
Since im using a "fired" eventHandler ...

Not exactly sure what you mean by 'source', but if you're using a fired EH, there are some options.

_triggerMan = _this select 0; // Source of whom fired the shot
_weapon = _this select 1; // Source of the bullet (obviously)
_muzzle = _this select 2; // The muzzle that was fired (IE: GL Muzzle)

Share this post


Link to post
Share on other sites
Not exactly sure what you mean by 'source'

I mean who shot the bullet indeed.

Usually its easy to know who shot a bullet in an eventHandler, but in this case there's im creating a bullet out of the blue.

To be clear :

1- Player shoots a first (legit) bullet.

2- Scripts create a second bullet going roughly the same way as the first bullet.

damaged eventHandler will naturally report a shooter for the first bullet. However the second one has no shooter, as it was created and not actually shot by somebody. I want to know if I can assign a shooter to that extra bullet, so my eventHandler will know who "shot" it.

Share this post


Link to post
Share on other sites

Hi Yatta,

Firstly, good work on the website - very useful.

In regard to this question, can I ask a few things?

1 - Is this SP or MP?

2 - Are you trying to fire your gun, then delete the bullet and spawn in a new projectile in it's place?

Thx

Nvm - Ninjad :)

Share this post


Link to post
Share on other sites
setVariable and getVariable are what you're after. You could set any given unit / player to essentially "own" the bullet if you will.

Just to make it clear, what you're suggesting is to do this ?

- GuyA shoots a projectile

- Mark the projectile with a setVariable owner GuyA

- bullet its GuyB

- check owner variable of projectile

The problem is that "damaged" event does not returns a projectile object, so you cant getvariable it.

I see there's a "hit" event too, that returns the object causing the damage, but 1) by the look of it I guess it returns the shooter - so it will not work for a spawned bullet, 2) it seems unreliable as it can be skipped if "not enough" damage is done, 3) Im not sure if it comes before or after damage management and I feel like getting information from one event to another would be quite dirty somehow.

So im still not sure what to do :P

Das Attorney :

Aww, you scratched the cheers about the website :(

Now that I think of it I should have it in signature. Ill add it now.

(And for the question : in this case im trying to spawn an extra bullet with each bullet shoot)

Share this post


Link to post
Share on other sites

Also, last time I checked, you can't setvariable a bullet.

Share this post


Link to post
Share on other sites

×