Home   Help Search Login Register  

Author Topic: how to detect the impact point of a smoke grenade?  (Read 994 times)

0 Members and 1 Guest are viewing this topic.

Ikhi

  • Guest
how to detect the impact point of a smoke grenade?
« on: 09 Jun 2006, 20:05:35 »
I tried to search for this, but the only relevant thing I could find was a kilometre and half long helicopter script. So:

How do I detect the point in terrain where a smoke grenade tossed by the player impacts?

My grand plan is to make the player call for a helicopter by radio, and then be instructed to pop smoke to mark the landing site. After this the chopper moves in to land. I intend to move an invisible H on the spot where the grenade lands, but with my lacluster scripting talents I can't figure out a way to find the spot.

The intention here is to learn how to do this, so please don't point me to a ready made helo script. :)
« Last Edit: 09 Jun 2006, 20:26:57 by Ikhi »

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re: how to detect the impact point of a smoke grenade?
« Reply #1 on: 09 Jun 2006, 20:45:07 »
I have portions of different scripts that will capture the smokeshell position.

First you need to determine if the player has used a smokeshell first by using an EH like so:

Code: [Select]
player addeventhandler ["fired", {[_this select 4] exec "smoke.sqs"}]
And then in script of your choice (named "smoke" in example), you look for smokeshell:

Code: [Select]
_type = this select 4
_unit = _this select 1
_obj = nearestobject [getpos _unit, _type]

? typeof _obj != "smokeshellred" and typeof _obj != "smokeshellgreen" : Exit

_smkpos = getpos _obj

The example above only looks for red or green smokeshells as the original script called either a plane or chopper depending on the color of the smoke. There were some edits after the original post of the script and I do not have my ref material to confirm the EH elements are correctly numbered. Perhaps a sharper soul will chime in if I am not correct.

Note - I did not write this, only "borrowed" it. I do not recall who wrote it. I always like it when authors put their name in the script so I can credit those that deserve it.

Is this enough to get you going in the right direction?

Wadmann
Check out my Camouflage Collection! New items added 31 July 2005.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: how to detect the impact point of a smoke grenade?
« Reply #2 on: 09 Jun 2006, 20:59:26 »
take a look at this thread.

Ikhi

  • Guest
Re: how to detect the impact point of a smoke grenade?
« Reply #3 on: 10 Jun 2006, 08:47:04 »
Wadmann - Yes, thanks. That at least by just looking at the script seems to do the trick. Haven't tested it yet though. and as someone said in the thread linked by bedges (how on earth did I miss it with the search function? One of life's little mysteries no doubt.) if there's a delay of say 3 seconds at the start of the second script the shell has had time to land. _unit in the second script might as well be player.

edit: Based on Wadmann's advice, and on the stuff found in the linked thread, I ended up with this. Tested and works.

In a trigger:
Code: [Select]
player addEventHandler ["Fired", {if ((_this select 3 == "SmokeShell") or (_this select 3 == "SmokeShellGreen") or (_this select 3 == "SmokeShellRed")) then {[_this select 3] exec "smoke.sqs"}}]
and smoke.sqs:
Code: [Select]
~3
_ammo = _this
_smoke = nearestobject [player, _ammo]
_smokepos = getpos _smoke
Hland setpos _smokepos
? _ammo == "SmokeShell" : smokecolour = "white"
? _ammo == "SmokeShellRed" : smokecolour = "red"
? _ammo == "SmokeShellGreen" : smokecolour = "green"
player sideChat format ["popping %1 smoke", smokecolour]
exit

Hland is the name of the invisible H.

the smokecolour part is for radio conversation:
player: "Popping smoke."
heli: "I spot green smoke, confirm."
p: "Green smoke confirmed."
...and so on.
« Last Edit: 11 Jun 2006, 16:18:12 by Ikhi »