Jump to content
Sign in to follow this  
scottieb

unlimited fuel for insurgency mission ai vehicles

Recommended Posts

HI guys, im trying to give the ai vehicles in Insurgency mission unlimited fuel.

The problem is they are not placed on editor so there is no initialisation box to add this script.

nul = this spawn { waitUntil { if !(alive _this) exitWith {}; if (fuel _this < 0.25) then { _this setFuel 1 }; false } };

The vehicles all spawn at their locations when mission starts but after a couple of hours they run out of fuel.

Where do i put this script so the ai vehicles always have fuel until end of mission.

Thanks for your help.

Scottieb.

Share this post


Link to post
Share on other sites

nul = [0.25,1] execVM "fuel.sqf";

private ["_fuelmin","_fuelmax"];
_fuelmin = _this select 0;
_fuelmax = _this select 1;

while {true} do {
   {if (fuel _x <= _fuelmin && _x isKindOf "LandVehicle" && side _x != WEST) then { 
       _x setFuel _fuelmax};
sleep 1;
} forEach vehicles;
};

Edited by PELHAM
Updated - fixed error in code

Share this post


Link to post
Share on other sites

Hi Pelham,

Thanks very much in sharing your knowledge.

So i make a text file named fuel.sqf and add the code you wrote to it.

Then i add the "execvm" bit to the "init.sqf".

am i correct?

Ps. If i want it to work for opfor ai vehicles do i change the west to east in the code?

Thanks again.

Share this post


Link to post
Share on other sites

Correct, text file and init sqf.

As is, it will work for all vehicles except blufor. Options:

To work for all vehicles remove: && side _x != WEST

To work for blufor only: && side _x == WEST

To work for opfor only: && side _x == EAST

Sides:

WEST, EAST, GUER, CIV

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

edit: NOTE; as empty vehicles are CIV, empty blufor vehicles may be refueled by that.

Edited by PELHAM

Share this post


Link to post
Share on other sites

Pelham,

Your time, explanation and patience are all very much appreciated mate.

I will test over the next couple of days and let you know how it all goes.

Thankyou.

---------- Post added at 22:24 ---------- Previous post was at 20:54 ----------

Sorry to bother you Pelham, I've changed the 0.25 to 0.90 for testing purposes and everything is where its supposed to be however its nor working.

could this be because nul = [0.90,1] execVM "fuel.sqf"; needs to have a specific place in the init.sqf?

Share this post


Link to post
Share on other sites

Put this in a vehicle init to test it, much easier than driving around to burn off fuel lol:

this setfuel 0.2;

try nul = [0.25,1] execVM "fuel.sqf"; in a radio trigger or on Act: of a trigger you drive into - you will see the fuel go back to 1 (full).

Share this post


Link to post
Share on other sites

ok will try that, dude ive been driving for ages lol

oh btw to make it work for aircraft would be lovely also ;-)

Share this post


Link to post
Share on other sites

cheers.

this setfuel 0.2; works fine for an editor place vehicle

however the script doesnt mate, i will try the trigger thingy :-)

Share this post


Link to post
Share on other sites

Just tested the script for the 3rd time on Opfor and CIV vehicles - both AI and Human player - works for me, not sure what wrong - if you need a demo mission let me know.

Share this post


Link to post
Share on other sites

a demo mission would be great please, are you using an insurgency mission?

---------- Post added at 10:11 ---------- Previous post was at 10:01 ----------

a test mission would be great, are youusing insurgency as your test mission?

Share this post


Link to post
Share on other sites
a demo mission would be great please, are you using an insurgency mission?

---------- Post added at 10:11 ---------- Previous post was at 10:01 ----------

a test mission would be great, are youusing insurgency as your test mission?

Not using insurgency - I will leave that up to you - try script as is, will probably work as you need it running on all machines to cover player vehicle locality issues so no checks needed.

I found an error so you were right - it wasn't working correctly - }; in the wrong place lol. I updated the previous page.

Demo here:

http://www.mediafire.com/?ddhq209l990qlce

Share this post


Link to post
Share on other sites

Hi Pelham thanks for finding and fixing the code, i will test out tonight and keep you informed mate.

Thanks for the demo, i will check it out as well.

Scottie.

Share this post


Link to post
Share on other sites

Gday Pelham, good news, the corrected code works perfectly mate.

Added the execvm to init.sqf

Made a fuel.sqf with the code saved in it.

All is good.

Thankyou very much for your time and knowledge, very much appreciated :-)

Share this post


Link to post
Share on other sites

Oh btw, would making an ammo one work the same way? Or because of multiple guns on a vehicle would make that too tricky?

Share this post


Link to post
Share on other sites
Oh btw, would making an ammo one work the same way? Or because of multiple guns on a vehicle would make that too tricky?

It's possible, but a bit of a hassle, if you search there are scripts here that return the turrets and weapons, you would then have to count the magazines for each weapon and set a condition to rearm if the amount is below a certain value. If it's multiplayer it's less hassle and more realistic to set up FARPs with triggers that repair and rearm vehicles than have a script do it.

Share this post


Link to post
Share on other sites

Good point, will look into doing it that way, cheers.

Share this post


Link to post
Share on other sites

Quick Noob question.

I am building my first mission and for some reason my two RHIB's run out of fuel in like 40 minutes of loitering around waiting for my team to finish it's mission. Is there a way to have the guys turn the engine off so they can save fuel?

Or do I have to order them to disembark and wait on the beach until my team returns?

Thank you,

S

Share this post


Link to post
Share on other sites
Quick Noob question.

I am building my first mission and for some reason my two RHIB's run out of fuel in like 40 minutes of loitering around waiting for my team to finish it's mission. Is there a way to have the guys turn the engine off so they can save fuel?

S

Various ways to achieve that, you can take away then return all the fuel with

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

or turn the engines off with:

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

Scripting_Commands_ArmA2

Try one of the above in a radio trigger.

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  

×