k i n g 0 Posted May 30, 2010 hi everybody, i searched a lot, found nothing. I want to create a plane which flies to a relativ position of marker (200m right of the marker) with a script "airstrike.sqs" With "target" setMarkerPos _pos and strikePilot doMove _pos the plane is flying directly to the marker "target", but that it is not want i want. I want the plane to pass the marker about 200m right of it. so I tried it with: strikePilot doMove [(getMarkerPos "target") select 0,(getMarkerPos "target") select 1+200,200] and strikePilot doMove [(getMarkerPos "target") select 0,(getMarkerPos "target"+200) select 1,200] but nothing worked. Has anyone an idea? Share this post Link to post Share on other sites
Rommel 2 Posted May 30, 2010 SQF or its no deal. :p _unit = _this select 0; _marker = _this select 1; _xoffset = _this select 2; //_yoffset = _this select 3; _position = getmarkerpos _marker; _position set [0, (_position select 0) + _xoffset]; //_position set [1, (_position select 1) + _yoffset]; _group = group _unit; _wp = _group addwaypoint [_position, 0]; _group setCurrentWaypoint _wp; Added in the ability to do a Y offset there incase you need it aswell. 0 = [myplane, "mymarker", 200] execvm "offset.sqf" Share this post Link to post Share on other sites
k i n g 0 Posted May 30, 2010 arrgh.... i am a little bit old school from ofp and honestly i have no idea about this sqf-thing (yes, shame on me:confused:) i need this solution for an airstrike where a plane will be created and flies to the target. everything is done in sqs... so... is there an sqs-solution for my problem! i sweare next time it will be sqf.... :rolleyes: Share this post Link to post Share on other sites
Rommel 2 Posted May 30, 2010 Remove the semi colons and its SQS... that script will work either way. Except change execVM to exec... Share this post Link to post Share on other sites
CarlGustaffa 4 Posted May 31, 2010 Try Rommels suggestion. However I would just like to add: (getMarkerPos "target") select 1+200 and (getMarkerPos "target"+200) select 1 looks both wrong to me. You say "nothing worked", but did you at least get an error message? Start the game using -showScriptErrors and check if it doesn't throw an error. (getMarkerPos "target" select 1) + 200 would be the correct syntax in this case. Share this post Link to post Share on other sites
wickedstigma 10 Posted May 31, 2010 Im actually trying to make something like that, but instead im trying to make it with a helicopter, its kind of a CAS but with Apaches which will come to a given position an will seek and destroy for at least 10 minutes. But i dont understand how to use the damn OnMapSingleClick code. Can someone help me with this? Share this post Link to post Share on other sites
k i n g 0 Posted May 31, 2010 @CarlGustaffa: No, "strikePilot doMove [(getMarkerPos "target" select 0),(getMarkerPos "target" select 1+200),200] is not working. I dont get an error message, but the pilot us unable to find the marker. @Rommel: hm....sorry, i'm not that scripting genius, but i think this not working for me. I already have an airstrike.sqs where i have to modify the line strikePilot doMove [(getMarkerPos "target") select 0,(getMarkerPos "target") select 1,200] so that the plane will pass "target" with a distance of 200m:( I'm unable to implement a new script as you mentioned it. Im using this old script form Skumball modified by LCD which is working great, but the plane always flies directly to the target: onMapSingleClick {} 1 setRadioMsg "Null" 2 setRadioMsg "Null" _pos = _this select 0 [_pos, "Terget at grid location ", ". Over.", ["SideChat", player]] exec "gridcoordinates_pipe.sqs" ~5 "target" setMarkerPos _pos "target" setMarkerType "destroy" strikePlane = createVehicle ["C130J", [(getMarkerPos "Spawn") select 0,(getMarkerPos "Spawn") select 1,100], [], 0, "FLY"]; strikePilot assignAsDriver strikePlane strikePilot moveInDriver strikePlane strikePilot doMove [(getMarkerPos "target") select 0,(getMarkerPos "target") select 1,200] strikePilot sideChat "On the way" gun1 attachto [strikeplane,[0,-3,-7]]; deleteCollection this gun2 attachto [strikeplane,[0,1.5,-7]]; deleteCollection this gun1 dofire _pos gun2 dofire target @ unitReady strikePilot strikePilot sideChat "Target aquired" strikePilot doMove (getMarkerPos "spawn") strikePilot sideChat "Heading back" "target" setMarkerType "empty" @ unitReady strikePilot deleteVehicle strikePlane strikePilot setVelocity [0,0,0] strikePilot setPos (getMarkerPos "safe") strikePilot sideChat "Ready" 1 setRadioMsg "Air Strike" 2 setRadioMsg "Air Strike Napalm" exit @wickedstigma: As you can see i use the OnMapSingleClick, too. take a look at this bible, page 185-187, http://www.armaholic.com/page.php?id=4847 Share this post Link to post Share on other sites
ashram 1-1 10 Posted May 31, 2010 wickedstigma: a bit dirty but it works... based on some clever person's work create 2 markers, one called CAS_Tgt - put it anywhere - it will move on mapclick another marker called CAS_spawn - put it where the chopper starts put this in a radio trigger On Act: hint "Left click on map to set target coordinates"; onMapSingleClick """CAS_Tgt"" setMarkerPos _pos;[]exec ""CAS.sqs""; onMapSingleClick """";"; in mission folder, create CAS.sqs: GroupAH1Z = CreateGroup West; AH1ZCAS = createVehicle ["AH1Z", [(getMarkerPos "CAS_Spawn") select 0,(getMarkerPos "CAS_Spawn") select 1,100], [], 0, "FLY"]; AH1ZPilot = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZPilot moveInDriver AH1ZCAS; AH1ZGunner = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZGunner moveInGunner AH1ZCAS; wp1 = GroupAH1Z addWaypoint [(getMarkerPos "CAS_Tgt"), 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; hint "CAS script successfully finished"; definately works - will spawn a single cobra and give it a SAD waypoint where player clicks. I think it will bugger off once all targets are destroyed, not sure. If you want Apache(s) will need to make some changes havent tested the following, but probably better to ditch the tgt marker and just pass _pos of mapclick as parameter to a sqf, perhaps someone else can check / correct my hideous scripting... hint "Left click on map to set target coordinates"; onMapSingleClick "_pos execVM ""CAS.sqf""; onMapSingleClick """";"; //CAS.sqf //single parameter - position of mapclick _tgtpos = _this select 0; GroupAH1Z = CreateGroup West; AH1ZCAS = createVehicle ["AH1Z", [(getMarkerPos "CAS_Spawn") select 0,(getMarkerPos "CAS_Spawn") select 1,100], [], 0, "FLY"]; AH1ZPilot = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZPilot moveInDriver AH1ZCAS; AH1ZGunner = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZGunner moveInGunner AH1ZCAS; wp1 = GroupAH1Z addWaypoint [_tgtpos, 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; hint "CAS script successfully finished"; i just keep using the dirty version with two markers as the syntax of onMapSingleClick totally petrifies me :) Share this post Link to post Share on other sites
wickedstigma 10 Posted May 31, 2010 wickedstigma:a bit dirty but it works... based on some clever person's work create 2 markers, one called CAS_Tgt - put it anywhere - it will move on mapclick another marker called CAS_spawn - put it where the chopper starts put this in a radio trigger On Act: hint "Left click on map to set target coordinates"; onMapSingleClick """CAS_Tgt"" setMarkerPos _pos;[]exec ""CAS.sqs""; onMapSingleClick """";"; in mission folder, create CAS.sqs: GroupAH1Z = CreateGroup West; AH1ZCAS = createVehicle ["AH1Z", [(getMarkerPos "CAS_Spawn") select 0,(getMarkerPos "CAS_Spawn") select 1,100], [], 0, "FLY"]; AH1ZPilot = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZPilot moveInDriver AH1ZCAS; AH1ZGunner = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZGunner moveInGunner AH1ZCAS; wp1 = GroupAH1Z addWaypoint [(getMarkerPos "CAS_Tgt"), 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; hint "CAS script successfully finished"; definately works - will spawn a single cobra and give it a SAD waypoint where player clicks. I think it will bugger off once all targets are destroyed, not sure. If you want Apache(s) will need to make some changes havent tested the following, but probably better to ditch the tgt marker and just pass _pos of mapclick as parameter to a sqf, perhaps someone else can check / correct my hideous scripting... hint "Left click on map to set target coordinates"; onMapSingleClick "_pos execVM ""CAS.sqf""; onMapSingleClick """";"; //CAS.sqf //single parameter - position of mapclick _tgtpos = _this select 0; GroupAH1Z = CreateGroup West; AH1ZCAS = createVehicle ["AH1Z", [(getMarkerPos "CAS_Spawn") select 0,(getMarkerPos "CAS_Spawn") select 1,100], [], 0, "FLY"]; AH1ZPilot = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZPilot moveInDriver AH1ZCAS; AH1ZGunner = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZGunner moveInGunner AH1ZCAS; wp1 = GroupAH1Z addWaypoint [_tgtpos, 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; hint "CAS script successfully finished"; i just keep using the dirty version with two markers as the syntax of onMapSingleClick totally petrifies me :) Thanks a lot, it worked great. I'm going to use your script as model for my script or maybe edit yours if that's ok with you. Share this post Link to post Share on other sites
ashram 1-1 10 Posted May 31, 2010 go for it, reuse reduce recycle! that's all i did after all :) sorry to everyone else for hijacking the thread a bit Share this post Link to post Share on other sites
CarlGustaffa 4 Posted May 31, 2010 @KING, about the syntax: strikePilot doMove [(getMarkerPos "target") select 0, (getMarkerPos "target") select 1, 200] can be simplified to (by removing the parenthesis): strikePilot doMove [getMarkerPos "target" select 0, getMarkerPos "target" select 1, 200] but you need to add parentheses around the "number function" to separate it from the offset you want to add, like: strikePilot doMove [getMarkerPos "target" select 0, (getMarkerPos "target" select 1) + 200, 200] Otherwise, the engine doesn't know if you're trying to add (...select 1) + (200), or add to the selection part ....select (1 + 200). Share this post Link to post Share on other sites
wickedstigma 10 Posted May 31, 2010 go for it, reuse reduce recycle!that's all i did after all :) sorry to everyone else for hijacking the thread a bit Lol, thanks. I documented and modded the code to add another chopper, have them spawn in safe location, not flying, and that after certain time they will dissapear. I put the timer to 120 seconds just to see changes and how they react and everything else. It will also move the target marker to position [0,0]. I will edit it later to make different things like the target icon will disappear, different choppers and planes, and all other stuff I have in mind. Thanks again, the only part I actually needed to understand was the OnMapSingleClick but now that I see the entire code I learnd a couple of other things. Btw, I dont know whats the difference between sqs and sqf. Could you tell me if you know. Is there any advantage or something? Here is the code: //Creates Group called GroupAH1Z GroupAH1Z = CreateGroup West; //Creates helicopter AH1z on the marker CAS_Spawn at 100 meters of elevation flying //Chopper 1 AH1ZCAS = createVehicle ["AH1Z", [((getMarkerPos "CAS_Spawn") select 0)+50,(getMarkerPos "CAS_Spawn") select 1,0], [], 0, "FORM"]; //Chopper 2 AH1ZCAS2 = createVehicle ["AH1Z", [(getMarkerPos "CAS_Spawn") select 0,(getMarkerPos "CAS_Spawn") select 1,0], [], 0, "FORM"]; //Creates Pilot and Gunner and moves them in the chopper //Chopper Crew 1 AH1ZPilot = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZPilot moveInDriver AH1ZCAS; AH1ZGunner = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,1], [], 0, "CAN_COLLIDE"]; AH1ZGunner moveInGunner AH1ZCAS; //Choper Crew 2 AH1ZPilot2 = GroupAH1Z createUnit ["USMC_Soldier_Pilot", [0,0,2], [], 0, "CAN_COLLIDE"]; AH1ZPilot2 moveInDriver AH1ZCAS2; AH1ZGunner2 = GroupAH1Z createUnit ["USMC_Soldier_Crew", [0,0,2], [], 0, "CAN_COLLIDE"]; AH1ZGunner2 moveInGunner AH1ZCAS2; //Make "Seek and Destroy" waypoint on the marker CAS_tgt, sets speed to "Normal" wp1 = GroupAH1Z addWaypoint [(getMarkerPos "CAS_Tgt"), 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; //Wait 120 seconds and add a makes the chopper to return to where it was created ~120 hint "Im running out of ammo,I'll be going back to base soon, over"; wp2 = GroupAH1Z addWaypoint [(getMarkerPos "CAS_Spawn"), 0]; wp2 setWaypointSpeed "NORMAL"; wp2 setWaypointType "MOVE"; wp2 setWaypointBehaviour "CARELESS"; wp2 setWaypointCombatMode "BLUE"; //Waits 120 seconds to delete vehicles and pilots ~120 deleteVehicle AH1ZCAS deleteVehicle AH1ZCAS2 deleteVehicle AH1ZPilot deleteVehicle AH1ZPilot2 deleteVehicle AH1ZGunner deleteVehicle AH1ZGunner2 //Sets marker CAS_tgt to position 0,0 "CAS_tgt" setMarkerPos [0,0]; Share this post Link to post Share on other sites
CarlGustaffa 4 Posted June 1, 2010 sqs = old, outdated, and some say it has a performance hit compared to sqf. sqf = new, more flexible, nicer code, proper block code support. The only thing you need sqs for is for the so called onKilled event script, but then you can get away with just starting the sqf script. And I think not many bothers writing their own onKilled script anyway. My advice is to don't bother with sqs format and stay clear of complicating things for yourself in the long run. Learn to identify them though; sqf will never have #, @, or goto commands, but have plenty of semicolons. Similarly, sqs will never have waitUntil or sleep commands, and tend to end their lines without semicolon. http://community.bistudio.com/wiki/SQS_to_SQF_conversion Share this post Link to post Share on other sites
k i n g 0 Posted June 1, 2010 @CarlGustaffa: Thanx man, works great:yay: Share this post Link to post Share on other sites