Jump to content
Sign in to follow this  
maddogx

Rope attachment scripting basics

Recommended Posts

Hello,

I've been looking into creating some simple missions using the new rope attachment feature, but I found the state of the TakOH script command list on the community wiki to be rather lacking in real information.

Therefore I've started to gather some basic info about the rope scripting commands and am adding all info to the wiki. In addition, I am updating this post with explanations and usage examples for all rope-relevant commands. :)

______________________________________

ropeCreate

To create a simple rope between two objects, use the ropeCreate command:

Description:

RopeObject = ropeCreate [Helicopter, [x, y, z], CargoObject, [x, y, z], NumSegments];

  • RopeObject points to the rope itself. After creation it can be referenced in other script commands.
  • Helicopter. Pretty obvious.
  • The first [x,y,z] refers to a position in the model space of the chopper where one end of the rope will be attached. For the medium choppers, I've found [0, 1.5, -2.35] to be pretty good.
  • CargoObject is the object you want to carry.
  • The second [x,y,z] is a position in the model space of the cargo object. This is where the other end of the rope will be attached.
  • NumSegments is the number of segments on the rope. More segments make the rope look better but too many may cost performance. I've used 50 with no apparent performance cost.

Simple usage example:

In the editor, create a medium helicopter of your choice and call it "heli1", then create an object of any type, for example foil wrapped pallets, and call it "cargo1".

Now place a trigger and put the following into its condition field:

(heli1 distance cargo1) < 20

This will make the trigger fire when your chopper gets closer than 20 meters to the pallets. Now put the following into the triggers "on activation" field:

rope1 = ropeCreate[heli1, [0, 1.5, -2.35], cargo1, [0, 1, 0], 20]

Now preview the mission. When you fly close to the pallets, they will become attached to your chopper by a rope.

______________________________________

ropeSetCargoMass

After creating a basic rope, the cargo object doesn't seem to weigh down the helicopter at all. In order to do this, you need to add weight to it yourself using the ropeSetCargoMass command:

Description:

0 = ropeSetCargoMass [RopeObject, CargoObject, Mass]

(For some reason this command seems to have a return value, so I had to write "0 = ..." to make it work in a trigger.)

  • RopeObject is a rope created earlier with the ropeCreate command.
  • CargoObject - the cargo object attached to the rope.
  • Mass is simulated mass of the cargo object. I find objects with a mass of >1000 appear quite heavy, but the unit used here is unclear.

Simple usage example:

This example builds upon the ropeCreate usage example (see above).

Change the "on activation" code in your trigger to the following:

rope1 = ropeCreate[heli1, [0, 1.5, -2.35], cargo1, [0, 1, 0], 20];
0 = ropeSetCargoMass[rope1, cargo1, 500]

You should now notice that the cargo weighs down the chopper quite significantly once attached.

______________________________________

ropeDetach

Use this to detach a rope from a cargo object while leaving the rope dangling from the helicopter. (Presumably allowing it to be re-used later.)

Description:

CargoObject ropeDetach RopeObject

  • CargoObject - The object from which to detach the rope.
  • RopeObject - The rope to detach.

Simple usage example:

This example builds upon the previous rope usage examples (see above).

If you want the cargo object to detach at a specific drop off location, you will need to do the following:

Create a new trigger at the desired location and set its shape and radius/size to whatever you feel is appropriate. Now you will want it to detect when the player helicopter is present and ideally below a specific height - here is a simple way to do this:

- Set the activation type to "Anybody present"

- Set the condition to:

heli1 in thislist and (position heli1 select 2) < 10

- Finally add the detach command to the activation section:

cargo1 ropeDetach rope1

Here's what it should look like:

takotrigger01.jpg

______________________________________

ropeDestroy

Unlike the detach command, this command will destroy the rope completely.

Description:

ropeDestroy RopeObject

  • RopeObject - The rope to destroy.

Simple usage example:

This example builds upon the previous rope usage examples (see above), specifically the ropeDetach example.

In the trigger you created in the ropeDetach example, replace the "on activation" code with the following:

ropeDestroy rope1

This will destroy the rope completely instead of just detaching it from the cargo.

And here are the RopeAttachTo and RopeCut commands, supplied by Blakeace. :)

Here is how I believe objects can be atached to ropes.

RopeAttachto

To attach created rope to an object, use the ropeAttachto command:

Description:

  • ObjectThe object you want to connect to the end of the rope.
  • position. Where on the object to attach the rope to. May have other options such as mempoints?
  • ropeObject Rope object created using the alternative syntax.

Simple usage example:

Using the alternate syntax to create a rope below will create a rope 30m long with 10 segments the true means it will unroll. Attached to myheli.

myRope = ropecreate [myheli ,"slingload0",10,30,true];

[mycargo,[0,0,0]] ropeAttachTo myRope ;

This will connect the rope myrope to the mycargo object at it's [0,0,0] point.

Below place in an initialization field of a helicopter place an object nearby named mycargo.

Will create a rope which will unroll out of the helicopter, then after ten seconds will attach to the object mycargo.

si1 = [this] spawn
{
_plane = _this select 0;
_myRope = ropecreate [_plane ,"slingload0",10,30,true];
sleep 10;
[mycargo,[0,0,0]] ropeAttachTo _myRope ;


};

RopeCut

To cut a rope, use the ropeCut command:

Description:

  • ropeObject Rope object that has been created.
  • number. Where to cut the rope in metres from the helicopter.

Simple usage example:

ropeCut [myrope,10];

Will cut a rope named myrope leaving 10 metres attached to the helicopter.

Note these are just the aspects I have gotten to work. Other syntax options may be possible.

.

Edited by MadDogX

Share this post


Link to post
Share on other sites

nil = ropeSetCargoMass [RopeObject, CargoObject, Mass] 

Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

http://dev-heaven.net/projects/cca/wiki/Nil_Check

Correct:

nul = ropeSetCargoMass [RopeObject, CargoObject, Mass]
_nul = ropeSetCargoMass [RopeObject, CargoObject, Mass] 
0 = ropeSetCargoMass [RopeObject, CargoObject, Mass]

Share this post


Link to post
Share on other sites

I can't access dev-heaven at the moment (filter), but I'm guessing "nil = ..." is wrong for some reason. Corrected. :)

Nice, and thanks! but can you upload a demo mission?

I plan to. At the moment I'm just collecting notes and waiting for kju to correct my shit. ;)

Btw. I did some more experiments last night:

  • Attaching multiple ropes between the same chopper and cargo object doesn't seem to work properly. I tried with two, but only one of them was attached to the cargo, the other just dangled around uselessly. Would have been cool to have one rope attached to each corner of a crate, for example.

  • Chaining ropes from a chopper to multiple cargo objects (Heli ---> cargo ---> cargo) doesn't seem to work either.

Edited by MadDogX

Share this post


Link to post
Share on other sites

(For some reason this command seems to have a return value, so I had to write "0 = ..." to make it work in a trigger.)

MDX, why use a trigger? Would it not be better in a small script and call it from the object itself?

Share this post


Link to post
Share on other sites
MDX, why use a trigger? Would it not be better in a small script and call it from the object itself?

I prefer scripts over triggers aswell, but right now the intent of this thread is to show the most basic way to get ropes working, so that even a noob can understand it.

I will certainly add examples using SQF scripts later on though. :)

Share this post


Link to post
Share on other sites

Thanks for sharing MDX :)

Here's the quote of what's on the page linked by PvPScene:

Some missions/addons break the workings of many scripted systems, by overriding the system variable 'nil'.

Usually it is noticeable by strange errors and problems, making you chase your tail why things act 'odd'.

In CBA you get an RPT error and hintbox warning you about the fact that the nil variable is overriden.

It is important to find the nil = definition in the mission or used addons, and remove it (replace nil = with e.g dummy =).

Share this post


Link to post
Share on other sites

Thanks Sickboy. :)

That explains kju's dramatic response, and I've learned a new "best practice". It's been a while since I've done any real Arma scripting, so that's my excuse. :D

Share this post


Link to post
Share on other sites

Yeah, I tried lifting a crate with 10.500 weight yesterday... no dice, even with the heavy civilian chopper. :D

Share this post


Link to post
Share on other sites

Out of curiosity ,are the parameters variedvenough to try on a vehicle ,specifically small rope to tow something ,I was thinking articulating vehicles specifically ?

Share this post


Link to post
Share on other sites

Cool, but Maddog, how do you release the cargo again? Do yo need to set up triggers for that as well? If so, could you give an example (using your previous example as basis)?

As mentioned earlier in this thread, calling scripts from objects themselves, would that mean that you could i.e place out different objects in different locations and that all players in a MP session could lift and drop the cargo wherevertheysoplease (restricted only by cargo mass vs helicopter performance)?

Share this post


Link to post
Share on other sites
Out of curiosity ,are the parameters variedvenough to try on a vehicle ,specifically small rope to tow something ,I was thinking articulating vehicles specifically ?

I've done some testing with an SUV, trying to tow another vehicle, but it currently doesn't seem to work very well. Perhaps the attachment positions need to be tweaked or something, but at the moment it seems like attached objects will prefer to fall sideways instead of turning in the direction of the towing vehicle. However I am fairly sure that my rope attachment positions were less than ideal.

Cool, but Maddog, how do you release the cargo again? Do yo need to set up triggers for that as well? If so, could you give an example (using your previous example as basis)?

Done. See first post. :)

It isn't absolutely necessary to use triggers btw. I'm only using them in the examples because it is the easiest way for newcomers to understand the commands. Anyone who has learned how to write and use scripts should be able to use these commands inside them.

As mentioned earlier in this thread, calling scripts from objects themselves, would that mean that you could i.e place out different objects in different locations and that all players in a MP session could lift and drop the cargo wherevertheysoplease (restricted only by cargo mass vs helicopter performance)?

Certainly - pretty much any conceivable scenario should be possible. You could have any number of transportable objects lying around in a map, waiting to be transported somewhere else.

Edited by MadDogX

Share this post


Link to post
Share on other sites

Thanks Maddog, works perfectly. Now I just need to investimegate how this thing with the objects calling scripts themselves and how it works :)

Share this post


Link to post
Share on other sites

Great information thanks! Is it possible to use a joystick button to release the cargo?

---------- Post added at 09:50 PM ---------- Previous post was at 08:33 PM ----------

I need to use the inputAction command I think. As a test I added this script to initialization for the helicopter:

while{true}do{ if(inputAction "fire" != 0)then{hint "text"}; };

I'm planning to replace the hint with a ropeDetach command. In the chopper I press fire but I don't get any text. What am I doing wrong?

Edited by jcgam

Share this post


Link to post
Share on other sites

MadDogX,

Thank you for looking into this. Damn am I glad guys like you, SickBoy, Memphisbelle, etc. picked up this game. Good to have that support.

Share this post


Link to post
Share on other sites
Why can we reassign nil in the first place? Wouldn't it be better to use nil as a standard dummy, and have nil itself be as locked down as constant numbers?
Because any scripting command in the game can be overriden by a variable. And yes, it would probably be better if it would not be possible at all, perhaps suggest at CIT.

Numbers cannot, so

0 = this spawn something;

is fine too

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  

×