Home   Help Search Login Register  

Author Topic: SOLVED : fix bullet path  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
SOLVED : fix bullet path
« on: 21 Jun 2007, 23:58:13 »
right now im makin a mision were da player is sniping certain person (cant name him yet... i still didnt sign da contract w/ my star  ::)) nd i want 2 use a cinametic effect so... i want a script da check if da player is aiming @ dat person (i think da intersect command is wat im lookin 4 :D)  nd if he shots i want 2 have a slowmo cam 2 folow da bullet 2 my target... now heres da list of problems ive got

1) i need beter explanaition of da intersect command
2) i want 2 fix da bullet path so dat even if da player isnt aiming exactly da bullet will fly da way i want... now i guess settin its vector will get me on my way but i need a way 2 calculate da path needed

ny help guys ? :D

LCD OUT
« Last Edit: 23 Jun 2007, 14:03:00 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #1 on: 22 Jun 2007, 01:13:40 »
To the init field of the player:
Code: [Select]
EH = this addEventHandler ["Fired", {_this exec "firingweapon.sqs"}]

Make sure the name of your target unit is nameofthestar or change that in the code below by the name of your victim

Code: [Select]
;firingweapon.sqs
;By Mandoble for LCD
;
;BTW, WHAT IS THE NAME OF THE STAR??
;

_firer  = _this select 0
_type   = _this select 4
_bullet = nearestObject[_firer, _type]
?isNull _bullet:hint format["NULL BULLET, %1 %2", _firer, _type];exit
_dmg = damage nameofthestar
_log1 = "logic" createVehicleLocal [0,0,0]
_log2 = "logic" createVehicleLocal [0,0,0]

_vdir = vectorDir _bullet
_dist1 = (_bullet distance nameofthestar)-4
_dist2 = (_bullet distance nameofthestar)+4
_pos1 = [(getPosASL _bullet select 0)+(_vdir select 0)*_dist1,(getPosASL _bullet select 1)+(_vdir select 1)*_dist1,(getPosASL _bullet select

2)+(_vdir select 2)*_dist1]
_pos2 = [(_pos1 select 0)+(_vdir select 0)*_dist2,(_pos1 select 1)+(_vdir select 1)*_dist2,(_pos1 select 2)+(_vdir select 2)*_dist2]
_log1 setPosASL _pos1
_log2 setPosASL _pos2
_selection = [nameofthestar, "FIRE"] intersect [getPos _log1, getPos _log2]

deleteVehicle _log1
deleteVehicle _log2
?count _selection == 0: exit

;90% chances of hit
showCinemaBorder false
_cam = "camera" camcreate [0, 0, 0]
_cam cameraeffect ["internal", "back"]
_cam camSetFov 1.0
_cam camSetTarget _bullet
_cam camSetRelPos [0,-0.5,0]
_cam camCommit 0
setAccTime 0.05
#follow
_cam camSetRelPos [0,-0.5,0]
_cam camCommit 0
~0.001
?!isNull _bullet:goto "follow"
setAccTime 0.1
?damage nameofthestar == _dmg: goto "endofcam"
_cam camSetTarget nameofthestar
_cam camSetRelPos [2,2,2]
_cam camCommit 2
~2
?!alive nameofthestar: _firer removeEventHandler ["Fired", EH]

#endofcam
_cam cameraeffect ["terminate", "back"];
camDestroy _cam;
setAccTime 1
exit

And dont try to kiss me again  :P

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #2 on: 22 Jun 2007, 01:53:30 »
dont try 2 appear inoccent :D u know who da star is... but i dont have enough money 2 bribe him 2 b in my mision  :D

unless he agrees ?  ::)  :whistle:

thx 4 da script :D

LCD OUT

[edit]

i just tested da script nd can see couple of errors (its quite good tho me n my bro had fun shotin our star nd watchin him die :D  :cool2:  :yes:  :good:  :clap:)

1) it seems dat every nonce in a while da script dsoesnt locate my bullet... cud dat work better in a function or somting ?

2) u have strange spacing error wen calculatin da _pos1 tingy

3) da intersect command doesnt seem 2 work  :( now da script only works if i delete da intersec line

LCD OUT
« Last Edit: 22 Jun 2007, 16:24:01 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #3 on: 23 Jun 2007, 02:33:53 »
1) may be
2) What spacing error?
3) It works fine for me, what is what doesnt work in your end?

EDIT:
2) I see the spacing error, may be a problem of copying and pasting here, join both lines.
« Last Edit: 23 Jun 2007, 02:35:46 by Mandoble »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #4 on: 23 Jun 2007, 02:45:40 »
everytime i run da script

Code: [Select]
?count _selection == 0: exit

dis line comes in as true (script exits) even if i kill da man...

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #5 on: 23 Jun 2007, 02:52:15 »
Try that

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #6 on: 23 Jun 2007, 02:59:27 »
after some trying i got whats da prob is.... both scripts seem 2 work wen da target is on ground... now prob is my target is actually standin on a balcony in a hotel... donno how da intersect stuff work... so i donno wat changes r needed 4 dat stuff... donno if its possible actually  :confused:  :dunno:

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #7 on: 23 Jun 2007, 03:29:57 »
Ah, the old problem of building tops returning a wrong ASL altitude. IMO a critical bug in ArmA.

EDIT:
If you know the alt of that bulding, compensate with that value the pos2 Zs of the script.
« Last Edit: 23 Jun 2007, 03:33:43 by Mandoble »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #8 on: 23 Jun 2007, 09:02:21 »
i got da Z part (jumping of da buildin and checkin getposASL select 2  :whistle:) but it still doesnt work  :confused: probably its not da exact valu or someting ??? shud my last line look like dat ?

Code: [Select]
_pos2 = [(_pos1 select 0)+(_vdir select 0)*_dist2,(_pos1 select 1)+(_vdir select 1)*_dist2,(_pos1 select 2)+(_vdir select 2)*_dist2+ 26.7]
or is dere any more changes ?

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #9 on: 23 Jun 2007, 11:37:22 »
I've doing some tests and the result is that some buildings returns a correct height and some other dont.
Use the mission I posted as test bed, put the enemy over buildings and do the same with the player. Try several buildings in that town. most of them seem to work, but some dont (these with stairs and several floors).

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #10 on: 23 Jun 2007, 12:25:05 »
my building is 1 of em not good building... but im able 2 calculate da positions ASL 26.5... now were do i edit da script 2 make it work ???

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fix bullet path
« Reply #11 on: 23 Jun 2007, 12:52:10 »
Try adding the extra height to the Z of
_pos2 = [(_pos1 select 0)+(_vdir select 0)*_dist2,(_pos1 select 1)+(_vdir select 1)*_dist2,(_pos1 select 2)+(_vdir select 2)*_dist2]

so
Code: [Select]
_pos2 = [(_pos1 select 0)+(_vdir select 0)*_dist2,(_pos1 select 1)+(_vdir select 1)*_dist2,(_pos1 select 2)+ EXTRAHERE + (_vdir select 2)*_dist2]

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: fix bullet path
« Reply #12 on: 23 Jun 2007, 13:18:51 »
kk... it seems 2 work better now  :clap:  :D still gotta get da exact hight (it detects all da shots up 2 da argets ass or somin like dat  ::))

[edit] got it solved :D... intersect is strange  :blink: it workes erfect now nd instead of adding da ASL i actually deduct 22  :dunno:

lub u Mandoble... no kissin tho ;) :nokiss: :nokiss:

LCD OUT
« Last Edit: 23 Jun 2007, 14:02:23 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta