OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: LCD 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
-
To the init field of the player:
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
;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
-
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
-
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.
-
everytime i run da script
?count _selection == 0: exit
dis line comes in as true (script exits) even if i kill da man...
LCD OUT
-
Try that
-
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
-
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.
-
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 ?
_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
-
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).
-
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
-
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
_pos2 = [(_pos1 select 0)+(_vdir select 0)*_dist2,(_pos1 select 1)+(_vdir select 1)*_dist2,(_pos1 select 2)+ EXTRAHERE + (_vdir select 2)*_dist2]
-
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