Jump to content
Sign in to follow this  
Archosaurusrev

Towable AT gun

Recommended Posts

So.

My idea is to make a towable AT gun that can be towed with a jeep in the I44 mod.

I know how to make the attach and detach script just fine, but I can't get the attach script to work ONLY when the gun is, say, under 5 meters from the car.

Righ now, I can attach it from the other side of the map.

init.sqf:

ATgun addAction ["Attach gun", "Attach_gun.sqs"];

ATgun addAction ["Detach gun", "Detach_gun.sqs"];

;

Can you modify it with a "If in this distance, then activate the below scripts." solution.

Share this post


Link to post
Share on other sites

The addaction command has a condition parameter that allows further refinement for when the script should be visible.

http://community.bistudio.com/wiki/addAction

Quoted from the above page

condition: String - (optional, Arma 2 only, default:true) Code that must return true for action to be shown. Special variables "_target" (unit to which action is attached to) and "_this" (caller/executing unit) can be used in the evaluation.

Here is an example of an elaborate one I used for a tow rope mod. Note the condition field is a string when setting it up.

_actionidx = _this addAction ["Use Tow Rope","\BlakesTowRope\TowRope.sqf",  [],1, false, false, "", " Player == driver (vehicle player) and (speed  player) == 0 and count(nearestobjects [(vehicle player), [""LandVehicle""], 50]) > 1 and ((vehicle player) getvariable ""OnTow"") == 0"];

Hope this helps

Blake

Share this post


Link to post
Share on other sites

@Blake

I have some kind of idea how the script works, but I don't know how to implement it into my own.

Could you, or someone else, go and modyify my init.sqf with a distance script, just the script with no additional text, just an "if less than 5 meters, then action is visible".

Get what I mean?

Share this post


Link to post
Share on other sites

A lot depends on what vehicles/s and gun/s you are using. If you are simply using one specific car and one specific gun then you could use something like this where you explicitly name the two objects you are checking the distance between.

If you want it to be a more dynamic where it can function with multiple objects then it would be a little more involved.

for the simple case you could use something like:

ATgun addAction ["Attach gun", "Attach_gun.sqs",[],1, false, false, "", "(Tow_car distance Towed_gun) < 5"];

Where in my example they are named the car Tow_car and the gun Towed_gun.

Share this post


Link to post
Share on other sites

@Blake

Alright, thanks, I'll try that out later.

Is there any way to make it work universally for every type unit of the same gun and car, like what they did in Liberation 1944?

Share this post


Link to post
Share on other sites

I don't see why not, you know what vehicle is being used and probably best use nearestobjects command setting the radius for your desired attaching distance. Filter it for the correct class type of the gun.

Use the position of _target to centre the search radius of of the nearestobjects command.

Then in the code search again for the gun object, the addaction passes what object it is attached to, use _this select 0 in your code to know which car action had been selected.

There is probably a few other ways to do it, but this one's just off the top of my head.

Share this post


Link to post
Share on other sites

@Blake

I didn't understand anything of that, I'm not very savvy of advanced scripting, but I might figure it out.

The Arma engine needs a feature that lets you define something for every unit of the specified type and lets you set some named units that don't apply to that.

Share this post


Link to post
Share on other sites

you could adopt R3f - we did.

http://forums.bistudio.com/showthread.php?94280-R3F-Artillery-and-Logistic-Manual-artillery-and-advanced-logistic-%28mission-script%29

there's a lot of thought gone into their towing script and in terms of debugging time too... it could save you days.

the field gun is turned 180 degrees to connect facing away from theback ofthe vehicles and the bounding box adjustments have been factored in for correcting distances and heights between relative "tow-er" and "towee".

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  

×