Jump to content
Sign in to follow this  
norrin

Example scripts that use the attachTo command

Recommended Posts

Before we all get carried away and start attaching shit like crazy, has anyone observed any strange side effects of using attachTo? I think it messes up AI's ability to target attached objects, they seem to just keep firing at its starting location. What about getPos on attached objects, anyone tried it?

Share this post


Link to post
Share on other sites

Saw that but didnt get it working that way, so i supposed there wereanother one i missed:rolleyes:

Get an type script expect nothing error, by using it in the init.

Edited by Nephris1

Share this post


Link to post
Share on other sites

GetPos should work as usual and I've never observed the AI problem.

Btw the AI do sometimes keep firing on a known position even when the target has moved (without them noticing) but tbh, I do the same thing.

Biggest issue is that attached Objects do not have collision detection.

Share this post


Link to post
Share on other sites

Yes I noticed that behaviour from AI, but I'm still not sure AI are capable of tracking attached objects with the same effiency as normal moving objects, which may or may not be related to lack of collision detection.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites
...

Biggest issue is that attached Objects do not have collision detection.

If I remember rightly there's something like collision detection for some vehicles like the M1A1 or the Ural. For other vehicles like the tractor I hear a collision-sound and the vehicle is damaged but it doesn't collide.

Share this post


Link to post
Share on other sites
Hmm guess everyone fell in love with the AttachTo :P hehe.

Someone mentioned using it for towing... don't do it. In this specific case youre better of using setpos since a rope is somewhat flexible and with the attachto it would look like whatever is beeing towed is fixed on the end of a stick. Setpos in combination with setvelocity and velocity does a pretty decent job for this. I can post some snipplets if required.

Can I have more information about this? I want to create a good towing script. I though about using attachto with a lot of Math, but mabye you have a better idea?

Share this post


Link to post
Share on other sites

You'll need good maths in both cases. ;)

My script works like this:

_obj setVelocity [((_vel select 0)+_xdir*1.6)*_factor,((_vel select 1)+_ydir*1.6)*_factor,(((_vel select 2)+_zdir*3)*(_factor-0.3))-4];

It may look a bit cryptic at first... let me explain:

factor is an variable that I use for the length of the rope. In fact it is the deviation from the maxium length of the rope. If the distance is less, then no force will be applied to the towed object. If the distance is bigger than the length of the rope then the speed of the carrier will be added to the speed of the towed object, plus some damping.

If the distance gets too big however, the rope will break.

So the concept is rather simple and unlike normal towing scripts it can look quite realistic.

I think I'll rewrite mine sometime and finally release it one day. (unless I'm getting lazy again)

Share this post


Link to post
Share on other sites

thx. I don't have enought scripting experience right now to fully understand your script (specialy the variables like _vel ) but I get the basic information. I will continue to read about scripting.

By the way, your script use way less math than my initial idea so I guess I'll forget my idea lol

Share this post


Link to post
Share on other sites

The code I've postet is only an extract. Most of the math happens before. ;)

_vel is the variable in which I store the xyz velocity of the chopper.

Anyway, that line of code was only an example. Good luck with yours, holler if you need anything for it.

Share this post


Link to post
Share on other sites
Damn.

Wait, I'll give you the last tested version using two files. I've merged those two files into one, but I couldn't test it at the moment so maybe I have an small bug there somewhere that I didnt notice. However, the 2-file version should work.

http://tajin.evilhosting.de/arma/cargoscript.zip

Init:

[this] execVM "c130cargo.sqf"

Ok, i'll get it out the way quick - I'm a noob. I know about <--this--> much about scripting, and i'm gettin a bit stuck with the c130 script, i've added the code to the init box on the unit, but i've obviously put the .sqf file in the wrong place because just as the mission loads i get a message saying it can't find the script. Where exactly do i need to put the .sqf file for it to work? Halp :confused_o:

Share this post


Link to post
Share on other sites

Look under "MyDocuments" there should be an "ArmA2" folder somewhere then a "missions" or "mpmissions" folder and in there are folders for each mission you're building in the editor. Put the scripts in the folder of the mission you need them for.

Share this post


Link to post
Share on other sites

May I ask a question, does AI soldier using attachTo command can fire their weapon? if they can how is their accuracy? is it like normal or is it like static weapons? I'm figuring it could be made with a foxhole

Share this post


Link to post
Share on other sites
Look under "MyDocuments" there should be an "ArmA2" folder somewhere then a "missions" or "mpmissions" folder and in there are folders for each mission you're building in the editor. Put the scripts in the folder of the mission you need them for.

The Missions & MPMission folders are there but they're empty apart from the readMe :j: and i've got plenty of missions in progress in the editor. Hidden files are on, but knowing me i'm probably doing something else wrong...

Share this post


Link to post
Share on other sites

There should be two Arma 2 directories in the my documents folder.

Try looking in: My Documents\Arma 2 Other Profiles\<Your profile name>\Missions

Thats where it stores mine.

Share this post


Link to post
Share on other sites

Ok, i've got the .sqf in the correct mission folder. And the init box for the unit has the correct line in it, but it still says that the script can not be found when i first load and preview the mission... am i just screwed?lol :confused:

Share this post


Link to post
Share on other sites
May I ask a question, does AI soldier using attachTo command can fire their weapon? if they can how is their accuracy? is it like normal or is it like static weapons? I'm figuring it could be made with a foxhole

I don't see why it would be different your not changing the config of the unit, the only problem I can see is if the old bugs of not being able to shoot over certain objects is still about.

Share this post


Link to post
Share on other sites

Thanks, I'm glad it works for you now. :cool:

Share this post


Link to post
Share on other sites

Hi,

I've got a bunch of guys to para out of 2 ospreys. The ospreys are spawned with an sqs, as are the troops and waypoints.

Is there any way to get a humvee loaded into a C130 with the same type of script and then when it reaches a scripted waypoint execute the unload function from above or something similar?

Share this post


Link to post
Share on other sites

Is there any way to make the soilders get ontop of the apc for a moveincargo command so that we can have AI scripted to do it and can it be on any of the russian equiptment??

Share this post


Link to post
Share on other sites

hi there all

I was wondering if anyone could point me/assist me in being able to use the attachto command to load the mortar/ammoboxes into a truck that could transport them around and then unload

Any help would be much appreciated

Many thanks in advance

Share this post


Link to post
Share on other sites

sqf files go in the same place that the mission does same folder

Share this post


Link to post
Share on other sites
Damn.

Wait, I'll give you the last tested version using two files. I've merged those two files into one, but I couldn't test it at the moment so maybe I have an small bug there somewhere that I didnt notice. However, the 2-file version should work.

http://tajin.evilhosting.de/arma/cargoscript.zip

Init:

[this] execVM "c130cargo.sqf"

I tried getting the Init to work like this but it errors I was able to get it to work like this?

res=[this] execVM "c130cargo.sqf";

Great Script however lots of uses.

Share this post


Link to post
Share on other sites
hi there all

I was wondering if anyone could point me/assist me in being able to use the attachto command to load the mortar/ammoboxes into a truck that could transport them around and then unload

Any help would be much appreciated

Many thanks in advance

Just name the truck and the ammo

ammo attachto [truck,[0,0,0]]

That will be in the wrong place but see where it appears and just adjust it's position to get it into the right place using different values X,Y,Z in the attacto command.

To detach it's just

detach Ammo

place in a trigger or waypoint, To get it off the truck you may need to give it a new position.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Hi all,

The script works for me but unfortunately it stopped to work after the first respawn of the c130. :confused:

Tested on "Co_30_EvolutionUSMC_v08.Chernarus".

Any idea ?

Thx :)

(For those how knows this mod, read this about the bug about the mission stopping in Gorka)

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  

×