Home   Help Search Login Register  

Author Topic: Need some help with my phantom targeting script  (Read 474 times)

0 Members and 2 Guests are viewing this topic.

Azraell

  • Guest
Need some help with my phantom targeting script
« on: 28 Dec 2003, 09:12:03 »
Hi all :)   Ive been woring on a script that uses onmapsingleclick to make ai vehicles shoot where i click........It works great and ive made different several different versions that are executed with a radio command, preset targets, addaction and a script with a timer to holdfire until turret falls on its target where you onmapsingleclick.


im not satisfied...."and a script with a timer to holdfire until turret falls on its target where you onmapsingleclick"  <-------- Iwant to change that......

----------------------------------------------------------------------------------------------
#loop1

onMapSingleClick { "target1" setmarkerpos _pos; tar1 setpos [getmarkerpos "target1" select 0, getmarkerpos "target1" select 1,.2]; t1 doWatch getPos tar1}


? Getdir ???????????????????????????????????????????????:goto "boom"


~.01


goto "loop1"



;----------------

#boom

t1 fire ["gun120","heat120"]


~.5

goto "loop1"
---------------------------------------------------------------------------------------

Heres the new one im working on. As you can see, i want to use GETDIR and have the vehicle hold its fire until the  barrel comes to rest where you clicked onmap.   Now, ive been here awhile...i know you guys dont like repeat questions....so i did massive research with search options... i came up with posts about using getdir to keep things in front of other things, getdir to create things with the same dir as leader and some others that might have helped but went unanswered and unsolved after awhile.

I found out about functions and dirtoobj.sqf, however due to my lack of experience in these ways, i am unable to figure out how to use dirtoobj.sqf as or in a condition..the timer version i made had a 4 secocond delay to allow the turret to get into position.......id like to use a getdir argument where you see " ?????????????????????????????" that would hold fire until turret was ready. im not interested in distance or hieght.....only that targeting is complete before shots are let go"ie.. facing my mapclicktarget which is a logic"...........

can i GETDIR for my vehicle with a GETPOS on the target?


after a week and a half,2-3 hours a day, i cant search anymore so i come before you, the wise ones and ask that you complete this tiny link in the code for me :'(  or at least show me what i need to put in there to make dirtoobj.sqf work with it.........i know how to call the sqf file and looked it over and everything, i just dont know how to work it into a condition.

I really appreciate any help you may give...Thanks :)




Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Need some help with my phantom targeting script
« Reply #1 on: 28 Dec 2003, 12:56:04 »
:wow:

som1 dat realy searches  :o  ;D kool :thumbsup:

but i think dat usualy wenu ask bout how 2 fix script no1 wil notice dat somin similar was asked b4 ;) its only em simple Qs dat piss every1  ;D

bout ur Q

u wanna check wen ur turret (wats dat turret is ?) is targetin ur target ? (ma eng isnt good ;) :P)

so as much as i know - deres som comments (just helpers deyll prooly wont solve it - but wil get ya som steps forward)

1) u cant make nythin target GLs (as much as i know)
2) u cant use getdir on da turret of a tank (so if ur turret is dat kind of veh w/ movin turret - getdir aint helpin u)
3) somtimes wen u tell som1 2 target it tels ya ready wen it finishes right ? - so i guess (never tried it ;D) dat u can use unitready command 2 check if its ready2 fire ??? donno im not sure

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

Azraell

  • Guest
Re:Need some help with my phantom targeting script
« Reply #2 on: 29 Dec 2003, 00:48:42 »
the tank isnt targeting the marker....its only dowatching...the unitready command wont work with this, i dont think.... i tried for awhile, didnt get results  :-[...........................No uploads , So heres the script  that uses ~4 to make it hold fire..but i wanna change that ~4 to a condition that allows the gun to fire when it faces the position i clicked onmap.


Needed- 1 M1A1 tank(t1)
               1marker(target1)
and something to shoot at....houses, cars, trees, whatever ;)

Activate in your favorite fashion...Radio, addaction.....however :)

--------------------------------------------------------------------

#loop1

onMapSingleClick {"target1" setmarkerpos _pos; [getmarkerpos "target1" select 0, getmarkerpos "target1" select 1,1.5];t1 doWatch getmarkerpos "target1"; fire1=true}

?fire1:goto "targeting"

~.01

goto "loop1"

#targeting

~4


t1 fire ["gun120","heat120"]

.5

fire1=false

~.01

goto "loop1"




After gun fires, it resets to false and awaits another mapclick, that can be changed for lines of tanks for target practices, line of sight bombardments and so forth.
-----------------------------------------------------------------------------------------

Offline Welshmanizer

  • Members
  • *
Re:Need some help with my phantom targeting script
« Reply #3 on: 29 Dec 2003, 19:26:00 »
And here is the answer:



Code: [Select]
#loop1

onMapSingleClick {"target1" setmarkerpos _pos;t1 doWatch getmarkerpos "target1"; fire1 = true}

_theta = 0
_angle = getdir t1
_x = 0
_y = 0

@fire1

#targeting
_x = (getmarkerpos "target1" select 0) - (getpos t1 select 0)
_y = (getmarkerpos "target1" select 1) - (getpos t1 select 1)

_theta = abs(atan(_x/_y))

?((_x >= 0) && (_y > 0)) : _angle = _theta
?((_x >= 0) && (_y < 0)) : _angle = 180 - _theta
?((_x < 0) && (_y < 0)) : _angle = 180 + _theta
?((_x < 0) && (_y > 0)) : _angle = 360 - _theta
?((_x > 0) && (_y == 0)) : _angle = 90
?((_x < 0) && (_y == 0)) : _angle = 270

#waiting

?(((getdir t1) >= (_angle - 3)) && ((getdir t1) <= (_angle + 3))):goto "fireit"
~.01
goto "waiting"


#fireit

~0.5

t1 fire ["gun120","heat120"]

~.5

fire1=false

~.01

goto "loop1"


Not done any OFP editing for over a year but it works alright ;)

« Last Edit: 29 Dec 2003, 19:29:20 by Welshmanizer »

Azraell

  • Guest
Re:Need some help with my phantom targeting script
« Reply #4 on: 30 Dec 2003, 05:25:47 »
Worked like a charm! :D    I studied this for about 2 hours, it was waiting until the tank body was totally in line with "target1", had to make it a little more forgiving about the exact location it was facing b4 it fired. Now ill decifer it further to get the tank to shoot on the move.   Thanks again Welshmanizer  and thnxs to LCD for taking time to reply. :D   Topic Solved!!