OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Ikhi 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. :)
-
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:
player addeventhandler ["fired", {[_this select 4] exec "smoke.sqs"}]
And then in script of your choice (named "smoke" in example), you look for smokeshell:
_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
-
take a look at this thread (http://www.ofpec.com/forum/index.php?topic=27321.0).
-
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:
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:
~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.