OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: MorMel on 21 Feb 2003, 16:20:57
-
I'm creating a guided missile script which sets the direction of a camcreated projectile, according to the targets position. Unfourtunately, when the missile crosses with the target, it will proceed its trajectory as its height is too high... and i wan it high! How to make the missile crash with the target?
P.S.: i tried "_missile setpos [_x,_y,(_h-_fac)]" loop type. it didn't work...
-
Come on!!!! :-\
Nobody knows how to define a rocket's slope... ???
I just wan'it to blow over ma target... Set its z position to z-0.1 on each loop but it isn't realistic.. :(
C'mon u guys... A kno u can solbe eet ;)
-
OK, OK!!
You don't know how... :( :-\
But do you know how to get a vehicle's height from the sea level (not from the ground, off course)... ???
Be sure not to use post OFPv1.00 commands, ;)
-
Use the getBank and getPitch commands for the direction and just have a gamelogic where you want to check where the height is and use:
missile distance gamelogic <= height
or something like this
-
Hummm.... I think i didn't understood... Are GetPitch and GetBank v1.00 compatible? What's their syntax?
But don't give much importance to that... i'll check it out by my self. ;)
Now, about your explanation, i think you're failing with the 'distance' command. You must use some trignometry before getting the missile's height above the sea level:
1st, place the gamelogic over the sea.
(missile distance gamelogic)^2 = HorizDistance^2 + MissileHeight^2
Then - [_x,_y] : missile's position; [_i,_j] : gamelogic's position
_Height = (missile distance gamelogic)^2 - SQRT( (_x-_i)^2 + (_y-_j)^2)
And I think that's it! I got the missile's height above the sea level!
Thanks man!!! The "gamelogic" idea is just great!!! ;) ;D
This way i can verify both the missile's and the tank's height and-then-set-the-missile's-height-to-the-tank's-height-and-then CABOOOOMMMM!!!! ;)
-
wait... you have version 1 of ofp? you need to update dude :P
-
wait... you have version 1 of ofp? you need to update dude
YEAH, YEAH! I know... but what shall i do? I can't find it!!!
Now, about this thread:
This thread was open with the objective of providing the necessary commands and maths for creating an ATGW script. Unfourtunately i realized that rockets are too instable, therefore it became useless as a ATGW script...
But Wait! What about a true projectile, night effects included, artillery script???!!!
That's it. Thanks to the "gamelogic" idea i invented one, very realistic (i think)
_Ref = _this select 0
_Orig = _this select 1
_Target = _this select 2
_FX = "flare" camcreate [0,0,100+(random 100)]
_FX1="flare" camcreate [0,0,100+(random 100)]
~2
_SHELL="SHELL120" camcreate [0,0,300+(random 300)]
_SHELL2="SHELL120" camcreate [0,0,300+(random 300)]
_SHELL3="SHELL120" camcreate [0,0,300+(random 300)]
_x = getpos _orig select 0
_y = getpos _orig select 1
_i = getpos _target select 0
_j = getpos _target select 1
_m = (_y-_j)/(_x-_i)
_alpha = atg (_m)
? (_y<_j and _x<_i) or (_y>_j and _x<_i): _dir = _alpha
? (_y<_j and _x>_i) or (_y>_j and _x>_i): _dir = _alpha+180
SHELL setdir _dir
SHELL2 setdir _dir
SHELL3 setdir _dir
_rx = getpos _ref select 0
_ry = getpos _ref select 1
_dis = _orig distance _Ref
_Hdis = SQRT((_x-_rx)^2+(_y-_ry)^2)
_MH = (SQRT((_dis^2) - (_Hdis)^2))+5
_n=0
_k=0
_h=0
_maxh=500-_MH
_fac=(500-_MH)/50
#ART
_FX setpos [(GetPos _orig select 0)+_n*(cos _dir),(GetPos _orig select 1)+_n*(sin _dir),_MH+_h]
_FX1 setpos [(GetPos _orig select 0)+_n*(cos _dir)-.5,(GetPos _orig select 1)+_n*(sin _dir)+.5,_MH+_h]
_SHELL setpos [(GetPos _orig select 0)+_n*(cos _dir)+.5,(GetPos _orig select 1)+_n*(sin _dir)+.5,_MH+_h]
_SHELL2 setpos [(GetPos _orig select 0)+_n*(cos _dir)-.5,(GetPos _orig select 1)+_n*(sin _dir)-.5,_MH+_h]
_SHELL3 setpos [(GetPos _orig select 0)+_n*(cos _dir)+.5,(GetPos _orig select 1)+_n*(sin _dir)-.5,_MH+_h]
;player setpos [(GetPos _orig select 0)+_n*(cos _dir)+5,(GetPos _orig select 1)+_n*(sin _dir)-5,_MH+_h]
_h=_h+_fac
?_h > _maxh-_fac : _h=_maxh; _top=true
_k=_k+0.6
?_k > 29.55 : _k=30; _cruise=true
_n=_n+_k
? _cruise && _top : _h=500; _k=30; Goto "Cruise"
~.001
? !(Alive _SHELL) or !(Alive _Shell2) or !(Alive _Shell3) : _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit
Goto "ART"
#Cruise
_FX setpos [(GetPos _orig select 0)+_n*(cos _dir),(GetPos _orig select 1)+_n*(sin _dir),_h]
_FX1 setpos [(GetPos _orig select 0)+_n*(cos _dir)-.5,(GetPos _orig select 1)+_n*(sin _dir)+.5,_h]
_SHELL setpos [(GetPos _orig select 0)+_n*(cos _dir)+.5,(GetPos _orig select 1)+_n*(sin _dir)+.5,_h]
_SHELL2 setpos [(GetPos _orig select 0)+_n*(cos _dir)-.5,(GetPos _orig select 1)+_n*(sin _dir)-.5,_h]
_SHELL3 setpos [(GetPos _orig select 0)+_n*(cos _dir)+.5,(GetPos _orig select 1)+_n*(sin _dir)-.5,_h]
_n=_n+_k
_x = getpos _shell select 0
_y = getpos _shell select 1
_d = SQRT((_i-_x)^2+(_j-_y)^2)
? (_d > 6000): _k=35
? (_d > 1500): _k=30
? (_d < 800): Goto "reentry"
~.001
? !(Alive _SHELL) or !(Alive _Shell2) or !(Alive _Shell3) : _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit
Goto "Cruise"
#reentry
_dis = _Target distance _Ref
_Hdis = SQRT((_i-_rx)^2+(_j-_ry)^2)
_TH = (SQRT((_dis^2) - (_Hdis)^2))
_x = getpos _shell select 0
_y = getpos _shell select 1
_d = SQRT((_i-_x)^2+(_j-_y)^2)
_fac = (_h-_TH)/(_d/_k)
#Hit
_FX setpos [(GetPos _orig select 0)+_n*(cos _dir),(GetPos _orig select 1)+_n*(sin _dir),_h]
_FX1 setpos [(GetPos _orig select 0)+_n*(cos _dir)-1,(GetPos _orig select 1)+_n*(sin _dir)+1.5,_h]
_SHELL setpos [(GetPos _orig select 0)+_n*(cos _dir)+1,(GetPos _orig select 1)+_n*(sin _dir)+1.5,_h]
_SHELL2 setpos [(GetPos _orig select 0)+_n*(cos _dir)-1,(GetPos _orig select 1)+_n*(sin _dir)-1.5,_h]
_SHELL3 setpos [(GetPos _orig select 0)+_n*(cos _dir)+1,(GetPos _orig select 1)+_n*(sin _dir)-1.5,_h]
_h=_h-_fac
_n=_n+_k
~.001
? GetPos _shell select 2 < 15 : _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit
? !(Alive _SHELL) or !(Alive _Shell2) or !(Alive _Shell3) : _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit
Goto "Hit"
Where _Ref is the gamlogic for sea level reference; _Orig, the origin of the art projectile; and _Target, you know, the target object. All of these are objects.
About the script:
This script seemd effective, reliable, yet it experiments some failures:
- Precision
- Abrupt end of script when i fire multiple rounds
Could anyone find the problem?
Just one more thing:
As i'm using OFPv1.00, i have NO IDEA how OnMapSingleClick works.
Could someone explain me? Or even create a script which initializes the main one?
I'll be thankfull!!! ;D
P.S. - One more time, I wanna thank HuNtA for the "gamelogic" idea. ;)
AH! I authorize anybody in this forum to use this script (As long as you give me credit, off course ;) )
-
I have just add one more effect to the script:
_FX2 = "SmokeShell" CamCreate [0,0,100+(random 100)]
Then i just gotta add it to the next few lines where the FX position is updated:
_FX2 setpos [(GetPos _orig select 0)+_n*(cos _dir),(GetPos _orig select 1)+_n*(sin _dir),_h+0.5]
This will give the projectile a cool rocket tail effect...
One more thing:
I realized that the "Abrupt end of script when i fire multiple rounds" happens if i fire more than 8 rockets with 0.2 time gap between eachother. Therefore i made a paralell script which activates the main one and avoids the script stoping:
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.2
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.9
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.2
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.9
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.2
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.9
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
~.2
[Ref,MyTruck,MyTarget] exec "ARTT.sqs"
exit
It's like a MLRS!! Seems nice on OFPv1.00...
About Precision: I just changed the "reentry" method and changed
<? GetPos _shell select 2 < 15 : _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit>
by
<? GetPos _shell select 2 < 15 : _shell setpos [_i,_j,_TH+3]; _FX setpos [0,0,0]; _FX1 setpos [0,0,0]; exit>
where _i and _j are the coordinates of the target. Unfourtunately it seems too precise... and if it is a moving target, it would be a kind of strange to see a missile falling over a position and blowing at another... ;D This way we should allways use static targets... Or just have a direction update script, but it will look like "guided artillery"... :o
I'm open to improvement proposals for this script!
-
YEAH, YEAH! I know... but what shall i do? I can't find it!!!
Umm, I don't mean to be rude, but if you can't find the update patches, you are pretty sad. ::) ;D
Just go to the official OFP site!!!
http://www.flashpoint1985.com/index2.html (http://www.flashpoint1985.com/index2.html)
-
I wanna posts about the script and how to solve its problems, please. ;)
I know how to find the things I need with the resources I have...