Jump to content
Sign in to follow this  
bogdanm

Need help creating a simple sqs file

Recommended Posts

This is my first attempt ever to understand how sqs files work so I might need step by step instructions. :)

I'm trying to do a mission in which you are a team leader and at some point you have to order your explosive specialist to go to a tower and put an explosive there.

I've found out how to create a custom action order (this addAction ["Place explosive", "setbomb.sqs"]). Then I tried to order a teammate(unit1) to go to that tower. I put a marker on the map called "tower1" and created a setbomb.sqs file with the line "unit1 moveTo tower1". It doesn't work. When I select the order the soldier comes next to me and a black box with an error message appears.

I also can't make it work the command to drop a claymore mine. I've tried to make a waypoint and in the On Act. I put the line "this fire ["pipebombmuzzle", "pipebombmuzzle", "ClaymoreDirectionalMine_Remote_Mag"];" or "this fire ClaymoreDirectionalMine_Remote_Mag" but it doesn't work. I'm also worried that the marker doesn't have a On Act field so I don't know how to make the soldier drop the explosive once he has reached the marker...

Just in case you didn't understood very well what I'm trying to do. I've made a screenshot. So once I reach my waypoint, I order my soldier via a custom action to go to "tower1" marker and place a claymore mine or anything that can be remotely detonated.

Share this post


Link to post
Share on other sites

Dont use sqs use sqf. Also check out the list of ARMA actions.

useWeapon

touchOff

setTimer

To place a democharge:

unitName fire ["demoChargeMuzzle", "demoChargeMuzzle", "democharge_remote_mag"]

To touchoff democharge:

unitName action ["TOUCHOFF", unitName]

Edited by cobra4v320

Share this post


Link to post
Share on other sites

It's late 2013 and ArmA3. Create FSMs or SQFs, not SQS. :)

For what you want you don't need a script at all. It's a built in part of the game. Select your AI unit, F2 for example, then press 6 for Actions, point to where you want the guy to place a charge, then select Plant Charge. He'll run over and plant it.

Then move away and select the unit again, F2, then 6 for Actions again and choose Set off Charge.

Share this post


Link to post
Share on other sites
It's late 2013 and ArmA3. Create FSMs or SQFs, not SQS. :)

For what you want you don't need a script at all. It's a built in part of the game. Select your AI unit, F2 for example, then press 6 for Actions, point to where you want the guy to place a charge, then select Plant Charge. He'll run over and plant it.

Then move away and select the unit again, F2, then 6 for Actions again and choose Set off Charge.

Well I don't even know what those extensions mean. :)

I've tried using the build in command but it doesn't work for me like you say. If I point somewhere and order a soldier to place a mine, he will place it exactly where he stands at that moment, he won't go to the location I've pointed at. Also, I want to upload it on Steam Workshop so I'm trying something more fancy, so the player only has to give the command and not have to babysit the AI.

I would still like to make it work my way but I don't know what I'm doing wrong...

Share this post


Link to post
Share on other sites
It's late 2013 and ArmA3. Create FSMs or SQFs, not SQS. :)

For what you want you don't need a script at all. It's a built in part of the game. Select your AI unit, F2 for example, then press 6 for Actions, point to where you want the guy to place a charge, then select Plant Charge. He'll run over and plant it.

Then move away and select the unit again, F2, then 6 for Actions again and choose Set off Charge.

True story

---------- Post added at 20:42 ---------- Previous post was at 20:40 ----------

Well I don't even know what those extensions mean. :)

I've tried using the build in command but it doesn't work for me like you say. If I point somewhere and order a soldier to place a mine, he will place it exactly where he stands at that moment, he won't go to the location I've pointed at. Also, I want to upload it on Steam Workshop so I'm trying something more fancy, so the player only has to give the command and not have to babysit the AI.

I would still like to make it work my way but I don't know what I'm doing wrong...

I gave you the answer above, you just need to find the muzzlename for placing your mines, claymores, etc.

---------- Post added at 20:42 ---------- Previous post was at 20:42 ----------

To find the muzzlename use this: player addEventHandler ["FIRED", {hintSilent format ["Weapon: %1\nMuzzle: %2\nMode: %3\nAmmo: %4", _this select 1,_this select 2,_this select 3,_this select 4]}];

Share this post


Link to post
Share on other sites

Ok, so move the AI where you want it first, then place it. :rolleyes:

Don't use moveTo, it even says not to on the wiki. Use doMove.

Cobra's code should work for the reinvention of the wheel you're trying to accomplish though. I would also highly suggest you start learning SQF rather than the depreciated SQS syntax.

Share this post


Link to post
Share on other sites

Thanks guys for the answers, I've managed to get both the doMove and the drop charge action to work. Now I'm trying to get them to work together in the sqf file. I want the soldier to drop the charge when he reaches the marker. My sqf syntax looks like this "unit1 doMove (getMarkerPos "tower1"); if(unit1 _pos = getMarkerPos "tower1") then(unit1 fire ["DIrectionalMineRemoteMuzzle", "DIrectionalMineRemoteMuzzle", "ClaymoreDirectionalMine_Remote_Mag"]);" , but it doesn't work. Both commands are correct and they work separately but I don't know how to write that condition... Any thoughts?

Kylania, I'm not trying to reinvent the wheel, rather to make it rounder. ;)

Share this post


Link to post
Share on other sites

unit1 _pos = getMarkerPos "tower1"

= Is assignment, your saying let unit1 _pos equal the value of getmarkerPos "tower1"

== Is compare, read as is equal to

Unfortunately you can not compare arrays like this, arrays would have to be compared using

[array1, array2] call BIS_fnc_arrayCompare

which will return true or false.

The problem with this is that minute differences in the two positions would mean that they are not the same even though the two positions may only be millimetres away from each other, the numbers in the arrays would have to be exact right down to the last decimal place.

unit1 _pos

Does not get the position of the unit use ..

getPosATL unit1

Use a distance check instead.

if ( (getPosATL unit1) distance (getMarkerPos "tower1") < 0.5 ) then [color="#FF0000"]{[/color]  //do my stuff here [color="#FF0000"]}[/color];

Notice here the { ,the code after then has to be in code brackets {curly braces}.

So overall if the distance from the position of unit1 to the position of marker "tower1" is smaller than 0.5 meters then do my stuff

Edited by Larrow

Share this post


Link to post
Share on other sites

Thanks a lot Larrow, your code worked perfectly! Now every syntax works but it still doesn't work like I want it to. If I understood correctly all the lines in the .sqf are being run the moment I give the command. So it runs the domove and the soldier goes to the marker, but also at the same time runs the if/then syntax which will be false because the soldier has just received the command and is nowhere near the marker. I think I should use a command that will keep repeating the if/then line until it's true. I've look around and found out that I have to put the syntax on a loop but I couldn't find an example that I could understand. I've also tried the "waitUntil" command but again I don't know how to use it properly... :|

If I for example give the command again when the soldier has reached the marker he will drop the charge, because this time the if/then syntax is true.

EDIT: Disregard this post as I'm an idiot. Again I didn't notice that I have to use "}" with the waituntil. I works now. Thanks everybody for your help and patience.

Edited by BogdanM

Share this post


Link to post
Share on other sites

Is it possible to make a trigger activate only if the entire group is in the trigger area? So if only one unit from that group is inside, it won't activate until the rest of them are in the circle?

Share this post


Link to post
Share on other sites

Yeah, you can group (F2) the trigger with a unit then you'll get a "vehicle" activation option. Use that drop down and you'll see "Whole Group" as an option.

Share this post


Link to post
Share on other sites
Yeah, you can group (F2) the trigger with a unit then you'll get a "vehicle" activation option. Use that drop down and you'll see "Whole Group" as an option.

Thanks. I did try that earlier but for some reason it didn't work then. Maybe one of the soldier was outside the area. It worked this time.

I'm close to finishing the mission, but there is one thing that annoys me. Every time I run the mission and complete the first task, the first message that appears is the second task and only after that the task completed for the first task appears... In on of the Alpha tutorials I saw they said it was a bug and that sometimes they appear in the right order and sometimes not. Well to me it's always in the wrong order...

Share this post


Link to post
Share on other sites

I've just tried putting "sleep 3" in the initialization field of Create Task (task2) and it gives me an error when I run the mission.

Share this post


Link to post
Share on other sites

Oh, using modules? Using scripts you'd just add "sleep 3;" to your code. Using modules you'll need to add another trigger, this one with condition: triggerActivated nameOfFirstTrigger with the min/mid/max set to 3. Then synch that one to the 2nd task module.

Share this post


Link to post
Share on other sites

Yey, it worked! Well kudos to BIS for making the task modules. I was horrified by the wall of text I need to write to create a task the old fashion way... :D

Share this post


Link to post
Share on other sites

I uploaded the mission on Steam Workshop (it requires the latest dev build unfortunately). I hope the link won't send you the Steam Korea like it does to me.

EDIT: I've just noticed that the text in the description on mission's workshop page replaces the one you write for the mission in the Description.ext. Why did they do it like that? At least make another text area for the stuff you want to tell the player but are not part of the mission description.

Edited by BogdanM

Share this post


Link to post
Share on other sites

SQF and FSMs are easy after you play around with them for a while. I will take a look at your mission. By the way my language the other day was Finnish, you just go up to language at the top right and change it back.

I get two errors from the start \screen_ca.paa not found and bad link to static object.

Im guessing you are using DEV Branch which is why Im getting the bad link to static object?

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Damn it. Everything looked fine on my end when I downloaded the mission via Workshop...

Regarding the mission image, I've only followed some instructions I've found. I've put the image in the Mission folder inside Arma 3 folder and wrote "overviewPicture = "Missions\screen_ca.paa";" in description.ext. I've thought the game will automatically put the image inside the pbo file. Should I have put it somewhere else?

Yes I am using the dev version. I've installed it when I tried some MP servers. I have also got the error message after the auto-update the game did today. But after I've saved the mission again with the new version the error disappeared. I'm reverting back to the official version and save the mission again. Lets hope it will update the one I've already uploaded and not create a new one.

EDIT: Can you run the mission at all after you close the error messages?

EDIT2: I've just tried running the mission with the official version and the mission is broken completely. The tasks can't be completed, the scripts don't work, even one of the soldiers out of nowhere started saying that hes out of ammo. It's too much work to mix the mission for the official version.

Edited by BogdanM

Share this post


Link to post
Share on other sites

Yes the picture needs to be in the mission folder. They just recently changed all of the ID numbers on the map in the DEV Branch so your mission wont work for the normal version of the game. I also had to switch back from DEV to the normal game.

Share this post


Link to post
Share on other sites
They just recently changed all of the ID numbers on the map in the DEV Branch so your mission wont work for the normal version of the game.

Again!? Geez. They gotta stop doing that.

Share this post


Link to post
Share on other sites
Again!? Geez. They gotta stop doing that.

And the fencing is missing at Kamino, totally messed up my mission. On top of that you can no longer delete or use hideobject on some of the objects. Its DEV Branch, Im not complaining.

---------- Post added at 00:50 ---------- Previous post was at 00:26 ----------

Instead of using ID numbers you can use this:

comm tower 1

(!alive (nearestObject [getMarkerPos "tower1", "Land_TTowerBig_1_F"]));

comm tower 2

(!alive (nearestObject [getMarkerPos "tower2", "Land_TTowerBig_2_F"]));

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×