Home   Help Search Login Register  

Author Topic: Addeventhandler "fired" for vehicles: crew cheif or door gunner shot?  (Read 1441 times)

0 Members and 1 Guest are viewing this topic.

Offline Delta

  • Members
  • *
  • Shazayme, Babye !
Hi,

 
My problem is that I have 2 gunners both in the same vehicle with the same weapon and cant figure out a way to idenrify the shooter as the 'crew chief',or the 'door gunner'.

I cant fathom out how to ID which side the gunner is  :confused:
« Last Edit: 08 Dec 2007, 22:39:23 by Delta »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
The crew chief uses a "M134" and the door gunner uses a "M134_2".
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Delta

  • Members
  • *
  • Shazayme, Babye !
Yeah, true for the BIS models,but I'm working with something where both guns are "M2" :blink:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Well, you could have been more specific! You could always tell the mod maker to rename one of the weapons, since it is his/her fault for doing it wrong (it is incredibly simple to do, if you just look at what BIS did!).

Anyway, you could do a nearestObject on the ammo type used and then use "_helo worldToModel (getPos _ammo)". If the position is left of centre in the model coordinates, then it is the left gun. To the right of the centre it is the right gun. This assumes, of course, that the two guns don't have overlapping arcs...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Delta

  • Members
  • *
  • Shazayme, Babye !
Cheers Spooner,

     Good idea there - thanks.


_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 1];

_pos = _u  modelToWorld (getpos_b);

If ((_pos select 0)< 0) then {hint"its the door gunner"};



But this is as far as I can get.

What would be a better way of doing this?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
That looks like what I was suggesting. Hopefully it works!

In the fired handler, the ammo type fired is the 5th parameter, so you don't have to work that out (the command ammo tells you how many rounds you have left anyway, so wouldn't work):
Code: (in fired handler) [Select]
_helo = _this select 0;
_ammo = _this select 4;

_bullet = nearestObject [_helo, _ammo];
// etc...

Incidentally, if you want anyone else to understand your code, please don't use obscure one-letter variable names, since that style went out with Fortran 77... ::) Since SQF can be compiled during initiation, there will be absolutely no run-time cost for having longer variable names (The only cost is that the sqf files are ~5% bigger on the disk drive because of the extra characters you are using!).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
F77 could have 6 characters for variable names. I know. I was there.
urp!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Good point, though I meant the style rather than the physical limitation of the language and just mentioned an older language, in spite of the fact that this style is still quite common in brand new languages ;P
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)