Home   Help Search Login Register  

Author Topic: Fire Direction?  (Read 3610 times)

0 Members and 1 Guest are viewing this topic.

Offline Turk

  • Members
  • *
Fire Direction?
« on: 19 Jun 2007, 09:20:32 »
Hi

Little problem with Fire direction, using the code below added to the activation field of a trigger  i can get a Tow missile to fire from an invisible heli pad (or any object) at a height of 10 meters, problem is, it always fires towards the north (360') I've tried adding SetDir + # in various parts of the code but i always get an error message!


Code: [Select]
blah = "M_TOW_AT" createvehicle [getpos Missile select 0, getpos Missile select 1,(getpos Missile select 2)+10]

How would i go about altering the code so the missile fires at say 270'?

Turk.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Fire Direction?
« Reply #1 on: 19 Jun 2007, 09:46:01 »
Code: [Select]
blah = "M_TOW_AT" createvehicle [getpos Missile select 0, getpos Missile select 1,(getpos Missile select 2)+10]
blah setdir 270

iirc that should work fine.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Fire Direction?
« Reply #2 on: 19 Jun 2007, 14:31:31 »
I think it's velocity will need changing and not the direction. I may be wrong.

Offline WhisperOFP

  • Members
  • *
  • I'm a llama!
Re: Fire Direction?
« Reply #3 on: 19 Jun 2007, 15:30:14 »
Yup, I think it will start with somethig like zero speed or init speed, in which case it will move northward by default. So you need to use setVelocity to get him moving in the right direction

Offline Turk

  • Members
  • *
Re: Fire Direction?
« Reply #4 on: 19 Jun 2007, 16:43:29 »
Thanks All

Adding ';blah SetDir 270' to the end of the code works fine.

Code: [Select]
blah = "M_TOW_AT" createvehicle [getpos Missile select 0, getpos Missile select 1,(getpos Missile select 2)+10] ;blah SetDir 270
To spice things up a touch more can the angle of the missile be changed to fire in an upward direction? This would add a nice effect of the enemy taking pop shots at aircraft!

Turk.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Fire Direction?
« Reply #5 on: 19 Jun 2007, 16:58:39 »
this was not possible with OFP, although could be faked by using some nifty setvelocity maths. the missile would move in the right direction, but would remain horizontal - looked a bit weird.

there may be a new command for arma which allows you to play with the angle... i have my doubts though  :confused:

Offline WhisperOFP

  • Members
  • *
  • I'm a llama!
Re: Fire Direction?
« Reply #6 on: 19 Jun 2007, 17:05:32 »
see setVectorUp for that, I think

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Fire Direction?
« Reply #7 on: 19 Jun 2007, 17:23:24 »
or indeed setVectorUp...

does no-one know we have a COMREF?




more to the point, does no-one know we started the BIKI COMREF?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Fire Direction?
« Reply #8 on: 19 Jun 2007, 21:42:48 »
Nope
urp!

Offline Turk

  • Members
  • *
Re: Fire Direction?
« Reply #9 on: 19 Jun 2007, 21:52:06 »
I saw the SetVectorup and tried adding that to the end of the code ;blah SetVectorUp [X,Z,Y] but nothing i added to X,Z,Y worked, the missile just fired in the direction i set.

I don't know if adding SetVectorUp to the code is as simple as that, or whether it's a complicated matter and lots of other code is needed.

I'm sure you can see what i know about scripting code isn't worth knowing, i can add a few things to triggers but am totally clueless in adding the same thing to a sqs file. Am i right in saying that its always best to add such code to a sqs file then just get the trigger to call on the script, or doesn't it really matter for small amounts of code within triggers?

Anyway i searched the forums for answers then looked it up in COMREF, then had ago, then asked )

Turk.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Fire Direction?
« Reply #10 on: 19 Jun 2007, 22:53:13 »
excellent, just the way things should be done. and if you had said you'd searched the BIKI, that would be groovy too.  :good: i'm just concerned that when folks link to a command, it's always to the BIKI, as if OFPEC doesn't have a perfectly good (and some would argue better) comref... ho hum  :dunno:

as for where to put code, it all depends. there will come a point when you're adding such long lines of commands separated by ; into init boxes and on activation boxes of triggers that you think "heck, i wish all this was easier to see and edit" - that's when you use a script.

triggers check to see if their conditions have been met about twice a second. if you think about the things you're using triggers to check for, and they really don't need to be checked that often, that's when you use a script.

if you need to do one thing to many different units on a map, use a script.

like i say, it all depends on the purpose of the condition you're checking.

as for setvectorup, i daresay mandoble will be along shortly to spread light and clarity upon us all. he has a habit of explaining things, spooky really.  ;)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Fire Direction?
« Reply #11 on: 20 Jun 2007, 15:01:11 »
If the missile is facing 270 then
Code: [Select]
myPhallicObject setVectorUp [-sin 25, 0, cos 25] will place it at 25 degrees from the vertical facing west.

In the Advanced Board, Mandoble reported on a function by flea that will set an object's orientation based on the more familiar concepts of pitch,bank,and yaw.
« Last Edit: 20 Jun 2007, 15:30:52 by Mr.Peanut »
urp!

Offline Turk

  • Members
  • *
Re: Fire Direction?
« Reply #12 on: 20 Jun 2007, 20:13:44 »
Thank for that Ground control, My Phallic Object is working fine now )

Oh...and thanks for the link, think i'll give scripting a miss and Concentrate on becoming an astronaut  :no:

Major (Turk) Tom

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Fire Direction?
« Reply #13 on: 21 Jun 2007, 00:26:28 »
why do you want for fire that TOW?

Offline Turk

  • Members
  • *
Re: Fire Direction?
« Reply #14 on: 21 Jun 2007, 02:19:16 »
It's just to add effect to a  map, as the sun sets the fighting gets more intense and i wanted to direct a few missiles towards both sides without them actually hitting anything, near misses if you like. One such effect is the enemy are reinforcing via heli and a few missiles just missing the heli's looks nice. Also, i have some nice jet sounds, some low level some high altitude and the enemy firing pop shots in to the darkened sky in all directions would look nice, i say would look nice, I'm still having trouble with the SetDir and SetVectorUp.

Using this code below in a trigger i can get an object to fire a missile towards the west 270' and at an angle of around 25', trouble is as soon as i change the SetDir to anything other then 270 the SetVectorUp goes all weird! I 've just spent hours playing around with the [Sin 25, 0, Cos 25] part  of the code (that Mr Peanut provided for me using 270 as an exampled), but i just can't get the missiles to fire in the direction and at the angles i would like.(apart from 270')

Code: [Select]
blah = "M_TOW_AT" createvehicle [getpos Missile select 0, getpos Missile select 1,(getpos Missile select 2)+10] ;blah SetDir 270 ;blah setVectorUp [+sin 25 , 0, cos 25]
Doing my head in! )

Turk.