Z.agge 10 Posted May 24, 2010 (edited) Hi! I tried searching, but I couldn't find a good answer for my problem. I'm trying to make a radio alpha trigger to spawn a bomb 100m above the player. Then I use Laser Designator to steer it. My problem is that I can't get my code to work. When I try this... bomb = "Bo_GBU12_LGB" createVehicle (getpos player) ... the bomb does spawn at my position and it kills me 8D (not a surprise really) But when I try this... bomb = "Bo_GBU12_LGB" createVehicle [(getpos player), 100] ... the bomb doesn't spawn at all. I know I'm making some kind of a mistake, but what? 8D Help me please. I'd really appreciate it 8) Thanks in advance! EDIT: Nah, forget it! I got it working. Here's the code: bomb = "Bo_GBU12_LGB" createVehicle [(getpos player select 0),( getpos player select 1), 100] Edited May 24, 2010 by Z.agge I got it working! Share this post Link to post Share on other sites
Z.agge 10 Posted May 24, 2010 Hehe 8D Sorry! But hey! If you get a good idea, how to get these bombs follow my laser designator, just tell me! I'd be even happier, because the bombs just fall. They are not reacting my laser designator... Share this post Link to post Share on other sites
f2k sel 164 Posted May 24, 2010 Sorry I was only going to correct your mistake. There is this post http://forums.bistudio.com/newreply.php?do=postreply&t=99492 I did script something to get a dumb bomb to drop on any target I selected but I couldn't limit it to the Laser Designator. Share this post Link to post Share on other sites
Fuzzy Bandit 10 Posted May 25, 2010 Finding the position of your Laser Target is actually quite difficult. Bon of the 10th-Community supplied my with a fantastic script which'll get the position of your laser target. First, let's make an init.sqf, and put the following in it: getMyLaserTarget = compile (preprocessFileLineNumbers "func_getMyLaserTarget.sqf"); Next, we'll make a file called 'func_getMyLaserTarget.sqf' and put the following in it: //by Bon_Inf* /** returns the laser target the player is lasering at, or ObjNull if it does not exist **/ private ["_xpos","_ypos","_myLaserTarget","_lasertargets","_dir","_distance","_min","_target","_targetpos","_targetdistance","_aimpos"]; _lasertargets = nearestObjects[player,["LaserTarget"],2000]; if(count _lasertargets == 0) exitWith{ObjNull}; _xpos = getPos player select 0; _ypos = getPos player select 1; _myLaserTarget = ObjNull; _dir = player weaponDirection "Laserdesignator"; _dir = (_dir select 0) atan2 (_dir select 1); // get direction of the lasermarker aiming at _distance = 99; _min =99; for "_i" from 0 to (count _lasertargets - 1) do{ _target = _lasertargets select _i; _targetpos = [getPos _target select 0,getPos _target select 1,0]; _targetdistance = _targetpos distance [getPos player select 0, getPos player select 1, 0]; _aimpos = [_xpos + _targetdistance*sin(_dir), _ypos + _targetdistance*cos(_dir),0]; if((_targetpos distance _aimpos)<_min) then{ _myLaserTarget=_target; _min = _targetpos distance _aimpos; }; }; if(_min>2) then{_myLaserTarget = ObjNull}; _myLaserTarget Now, we'll create a final script called 'bombit.sqf', and put the following in it: [color=black]_myLaserTarget = [player] call getMyLaserTarget;[/color] [color=#ff0000]bomb = "Bo_GBU12_LGB" createVehicle [(getPos _myLaserTarget select 0),(getPos _myLaserTarget select 1), 100];][/color] Now the line at the bottom that is coloured red is your line of code adapted for the job. In theory, it should drop a bomb 100m above your Laser Target. I don't think it will follow your target, but it will drop from directly 100m above it. This script could be called from your player using an action, such as: this addAction ["Drop Bomb on Laser", "bombit.sqf"]; This is completely untested just so you know. It's a theory. Should work. If not, there's most probably some locality issues somewhere down the line, as the script wasn't really written or optimized for MP play. Share this post Link to post Share on other sites
f2k sel 164 Posted May 25, 2010 Fuzzy is there anyway to tell if the LD has been fired, or if the LD is in hand. Share this post Link to post Share on other sites
Fuzzy Bandit 10 Posted May 25, 2010 (edited) Well you can check if the Laser Designator target (_myLaserTarget) is off by using: if (isNull _myLaserTarget) then { hint "Oh no! There's no laser!"; }; You could try using a script I created for Laser-Guided Artillery instead of bombit.sqf. Here's a quick adaption for you: (To make this work you'll have to create a Game Logic in the editor with the following in the init line): bombit = 0; _myLaserTarget = [player] call getMyLaserTarget; if (not isNull _myLaserTarget) then { bombit = bombit + 1; if (bombit == 1) then { sleep random 5; [west,"HQ"] sideChat "Confirm Laser. Target acquired and adjusting aim. Call us again when you're ready to drop."}; if (bombit == 2) then { sleep random 5; bomb = "Bo_GBU12_LGB" createVehicle [(getPos _myLaserTarget select 0),(getPos _myLaserTarget select 1), 100]; [west,"HQ"] sideChat "Bombs away!"}; } else { sleep random 5; [west,"HQ"] sideChat "Negative on that request. No Laser Target found."; hint "Check your batteries are loaded, or try a different spot!"; if ((isNull _myLaserTarget) AND (bombit == 1)) then { bombit = bombit - 1; }; }; I'll go through the script line by line. Player calls the Function called 'getMyLaserTarget' and creates a local variable called _myLaserTarget which contains the position of your current Laser Target. If the Laser Target is not null (i.e. the Laser Target exists and the Laser is on), then commence with the following code: Add 1 to the variable named 'bombit'. If bombit = 1, commence with the following code: Wait for a random amount of time from 0 - 5 seconds. HQ (CROSSROAD) will Radio all units saying: "Confirm laser. Target acquired and adjusting aim. Call us again when you're ready to drop.". If bombit = 2, commence with the following code: Wait for a random amount of time from 0 - 5 seconds. Create the GBU12 bomb 100m above our Laser Target. HQ (CROSSROAD) will Radio all units saying: "Bombs away!". If the Laser Target is null (i.e. the Laser Target does not exist and the Laser is off), then commence with the following code: Wait for a random amount of time from 0 - 5 seconds. HQ (CROSSROAD) will Radio all units saying: "Negative on that request. No Laser Target found.". The player will receive a hint (green box in upper right corner) saying: "Check your batteries are loaded, or try a different spot!". If the Laser Target is null, and our variable bombit = 1, then commence with the following code: Take 1 away from the variable bombit. End brace. End brace. That last part of code removes one from bombit, so that if the Laser Target can not be found, but the player has already done the 'Confirming Laser' stage, it will revert back to before that stage, allowing the player to confirm their laser again before dropping the bomb. In terms of checking if the player has the laser designator equipped, I think something like the code below would suffice. Not sure of the syntax though, as I don't have access to the wiki at the moment! if (player weapon "Laserdesignator") then { hint "You've got the Laser Designator equipped."; } else { hint "You don't have the Laser Designator equipped."; }; Hope that helped. Edited May 25, 2010 by Fuzzy Bandit Share this post Link to post Share on other sites
f2k sel 164 Posted May 25, 2010 (edited) Cheers, even more to play with tonight. I had to change a little bit as it was giving errors _inventory = weapons player; if ("Laserdesignator" in _inventory) then { hint "You've got the Laser Designator equipped."; } else { hint "You don't have the Laser Designator equipped."; }; it still doesn't totally fix my problem as it only tells me if I have the LD and not firing it. Yet to test the rest of the script so much to do so little time. Edited May 25, 2010 by F2k Sel Share this post Link to post Share on other sites
eggbeast 3673 Posted July 5, 2011 has anyone got this working at all? I've had a good 12 hours on it today and no joy Share this post Link to post Share on other sites