Home   Help Search Login Register  

Author Topic: Knowing some magazine position.  (Read 2079 times)

0 Members and 1 Guest are viewing this topic.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Knowing some magazine position.
« on: 23 Jan 2012, 18:32:07 »
Hi,

I'd like to know if there's some script or command to know the real position of 'handgrenade' or 'smokegrenade'
For example I throw a 'handgrenade' to certain position and then I want to know what's its position in the map.
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Knowing some magazine position.
« Reply #1 on: 23 Jan 2012, 18:45:15 »
Ok, you will need to use a 'fired' eventhandler:

Code: [Select]
this addEventHandler ["fired",{(nearestObject [_this select 0,_this select 4]) exec "bomb.sqs"}]
The script (bomb.sqs) will need this

Code: [Select]
@isNull _this
'_this' is the name of the projectile, so in your case it will be the handgrenade or smoke grenade

So, what you need is to find out the x,y,z of _this before it detonates (before it ceases to exist basically).

So, after the 'bomb.sqs' is called, I think you need to add a delay (whilst the projectile is in flight), and then use:

Code: [Select]
hint format ["%1", getpos _this]
...before you use the 'isNull' command.

I think that's it. You could try finding out whether or not you can obtain the coordinates after the detonation.

Syntax not guaranteed.

Hope this helps

Gruntage

EDIT: This method is no good for very fast projectiles like tank shells, but good for slow moving bombs or grenades.

« Last Edit: 23 Jan 2012, 21:06:38 by Gruntage »
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: Knowing some magazine position.
« Reply #2 on: 24 Jan 2012, 18:02:36 »
Hey gruntage, your example doesn't work.  :dunno: Well I did your example and I get a hint with following coordiinates [0,0,0]. So I made a script to know its position and I get a hint wiht my coordinates. I want to have grenade coordinates. This is what I got [Hg-69] that was my position. This is the script


Code: [Select]
_letras1 = ["A","B","C","D","E","F","G","H","I","J"]
_letras2 = ["a","b","c","d","e","f","g","h","i","j"]
_numeros1 = ["9","8","7","6","5","4","3","2","1","0"]
_numeros2 = ["9","8","7","6","5","4","3","2","1","0"]
_maxx1 = 12800
_maxx2 = 1280
_maxy1 = 12800
_maxy2 = 1280

_xu = getPos _this select 0
_yu = getPos _this select 1
_zu = getpos _this select 2

_l1 = 10 * _xu / _maxx1
_l1 = _l1 - (_l1 mod 1)
_n1 = 10 * _yu / _maxy1
_n1 = _n1 - (_n1 mod 1)

_xu = _xu - _l1*_maxx2
_l2 = 10 * _xu / _maxx2
_l2 = _l2 - (_l2 mod 1)

_yu = _yu - _n1*_maxy2
_n2 = 10 * _yu / _maxy2
_n2 = _n2 - (_n2 mod 1)
_coordstrt1 = format["%1%2-%3%4", _letras1 select _l1, _letras2 select _l2, _numeros1 select _n1, _numeros2 select _n2]

@isNull _this

hint format ["%1", _coordstrt1]

What I want to throw a 'smoke grenade' and then some unit or vehicle is moved to its position
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Knowing some magazine position.
« Reply #3 on: 24 Jan 2012, 18:16:32 »
Well I did say 'syntax not guaranteed' lol, and this is why.

The script I used as an example is used to get the coordinates of where an LGB hits.

After a little bit of searching, here's what looks like a solution:

Code: [Select]
player addEventHandler ["Fired", {_this exec "smoke.sqs"}]
That's the eventhandler you use...

Code: [Select]
_ammo = _this select 4
_shell = nearestObject [player, _ammo]
_smoke_types = ["SmokeShell","SmokeShellRed","SmokeShellGreen"]
if !(_ammo in _smoke_types) then {goto "end"}
;Wait till the shell is stopped
@speed _shell < 0.1
_pos =  [getPos _shell select 0, getPos _shell select 1, 0]
;Wait 10 seconds while generating big enough smoke cloud
~10
;landing code here


#end
exit

The 'landing code' part is obviously for directing the chopper to the location of '_pos'.

There are actually plenty of threads around addressing this issue. So, this is one of those occasions where the search function is your friend  :)

These two codes should work now, but as always, syntax not guaranteed  ::)
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: Knowing some magazine position.
« Reply #4 on: 24 Jan 2012, 18:40:09 »
Fine. I'll try this one, but a question: must 'doMove' command  be written after 'Landing code'? For example:
_chopper domove _pos
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Knowing some magazine position.
« Reply #5 on: 24 Jan 2012, 19:23:44 »
I believe so. If you want a big smoke cloud to develop then you have to put your 'domove' command after the 10 second delay.

EDIT: I would probably use 'setwppos' instead of 'domove'
« Last Edit: 24 Jan 2012, 19:27:29 by Gruntage »
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Knowing some magazine position.
« Reply #6 on: 25 Jan 2012, 08:52:17 »
Gruntage, the reason why your first code didn't work is that you try to get the grenade's position after it has been destroyed in which point it obviously doesn't exist in any position anymore..

The way I use is a loop that updates the position into a variable, something like this:
Code: [Select]
this addEventHandler ["fired",{_nade = (nearestObject [_this select 0,_this select 4]); if ((_this select 4) in ["SmokeShell","SmokeShellRed","SmokeShellGreen"]) then {[_nade,choppername] exec "whatever.sqs"}]
Code: [Select]
_nade = _this select 0
_chopper = _this select 1

#loop
_pos = position _nade
if (!(alive _this) goto "choppa"
~0.01
goto "loop"

#choppa
_chopper doMove _pos
; wait for the chopper to start moving
~10
; wait until the chopper arrives
@isReady _chopper
;land the chopper
_chopper land "GET IN"

No idea if that script works at all, it has been years since I did anything with sqs..  :dunno:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: Knowing some magazine position.
« Reply #7 on: 25 Jan 2012, 17:33:04 »
Guys it doesn't work.  :weeping:
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Knowing some magazine position.
« Reply #8 on: 25 Jan 2012, 17:59:01 »
Well, one of the reasons why it won't work (at least when it comes to moving the chopper) is that there isn't a command '@isReady'  :D

Code: [Select]
#choppa
_chopper doMove _pos
; wait for the chopper to start moving
~10
; wait until the chopper arrives
@unitReady _chopper
;land the chopper
_chopper land "land"

My advice to you Aldo is to search around a little. There were a lot of threads addressing this issue a while back.

If I get time later I'll have a little play around with it and see if I can get the script working.

"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Knowing some magazine position.
« Reply #9 on: 26 Jan 2012, 07:24:12 »
Oops  :-[
Remembered the command wrong, it's unitReady  :whistle:

And there is a command @
It's basically the same as waitUntil in A1/A2 (waitUntil is just a bit more usable), it's a "looping pause" kind of thing, it waits until the condition becomes true (performs check on every frame), so in this case the script waits until the unitReady _chopper becomes true.

The command is missing from our COMREF which should be fixed in the near future (it's actually missing from BIS wiki command reference too)..

Code: [Select]
_nade = _this select 0
_chopper = _this select 1

#loop
_pos = position _nade
if (!(alive _this) goto "choppa"
~0.01
goto "loop"

#choppa
_chopper doMove _pos
; wait for the chopper to start moving
~10
; wait until the chopper arrives
@unitReady _chopper
;land the chopper
_chopper land "GET IN"
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: Knowing some magazine position.
« Reply #10 on: 26 Jan 2012, 18:05:31 »
But what must I put in unit's init?
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Knowing some magazine position.
« Reply #11 on: 27 Jan 2012, 19:49:29 »
Code: [Select]
this addEventHandler ["fired",{_nade = (nearestObject [_this select 0,_this select 4]); if ((_this select 4) in ["SmokeShell","SmokeShellRed","SmokeShellGreen"]) then {[_nade,choppername] exec "whatever.sqs"}]
Syntax not guaranteed...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: Knowing some magazine position.
« Reply #12 on: 01 Apr 2012, 20:50:17 »
Aldo,

Try the attached demo mission. The scripts are all commented and also read the readme files and the included file that explains eventHandlers.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: Knowing some magazine position.
« Reply #13 on: 04 Apr 2012, 20:14:39 »
Ok Thanks Raptorsaurus.
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom