Forum Jump :

Author Message


Posts: 24
Rank:


Level: Member

Country: us
Location: In the dungeon to hell!
Occupation:
Age: 29
In-game name:

 
#1 Posted at 2013-10-29 06:54        
     
I'm currently making a mission called CO 05 Operation Liberate Strelka. Would appreciate it if someone could look at my script and enlighten me of why it isn't working. Thanks in advance. Here it is.
; this is my helicopter extraction script requires two helopads
; and a helicopter.
; by Philip Simonson

_chopper = _this select 0;
_helopad1 = _this select 1;
_helopad2 = _this select 2;
_groupUnits = _this select 3;

player removeAction 0;

_distFromHelo1 = _chopper distance _helopad1;
_distFromHelo2 = _chopper distance _helopad2;

move_helopad1:
	if (_distFromHelo1 == 0) then {
		_chopper land "GET IN";

		if (({_x in _chopper} count units _groupUnits) == (count units _groupUnits)) then {
			_chopper enableAI "MOVE";
			goto take_off1;
		} else {
			_chopper disableAI "MOVE";
		};
	} elseif (_distFromHelo1 > 0) then {
		_chopper doMove (getPos _helopad1);
		_chopper flyInHeight 25;
	} elseif (_distFromHelo1 < 30) {
		_chopper setSpeedMode "LIMITED";
	} elseif (_distFromHelo1 > 35) {
		_chopper setSpeedMode "FULL";
	};

	sleep 0.5;
	goto move_helopad1;

take_off1:
	_chopper action "ENGINE ON";
	sleep 0.2;

move_helopad2:
	if (_distFromHelo2 == 0) then {
		goto land_chopper;
	} elseif (_distFromHelo2 > 0) {
		_chopper doMove (getPos _helopad2);
		_chopper flyInHeight 25;
	} elseif (_distFromHelo2 < 30) {
		_chopper setSpeedMode "LIMITED";
	} elseif (_distFromHelo2 > 35) {
		_chopper setSpeedMode "FULL";
	};

	sleep 0.5;
	goto move_helopad2;

land_chopper:
	_chopper land "LAND";

	sleep 7;
	endMission "END2";

exit;
Thanks in advance for any help. Please be gentle, I'm still a noob at scripting.

Sorry, Foxhound. That I put it in the wrong place before but I couldn't find ARMA 2 OA Scripting Section for awhile.. But, I think I found it now.

Philip "5n4k3" Simonson

Author Message


Posts: 1474
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2013-10-29 14:04        
     
just looking at the script it seems to be a mix of sqs and sqf coding also I don't think elseif is a valid command in either.


Advertisement


Author Message


Posts: 67
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2013-10-30 07:52        
     
Need help with Scripting a helicopter extraction please...

Honestly I just did a search for "helicopter extraction" and I found over 100 threads that answer this EXACT question. you may feel people are more inclined to help when your willing to put some effort in to searching and researching, I am only mentioning this as it is the BEST way to learn, if people provide the answers you never discover them on your own, thus you don't learn, you remember!

As for your script there are many ways of accomplishing that goal any one of the 100 threads I found would demonstrate that.

First Step:
Script in SQF or SQS, I would suggest SQF as it is some what easer to understand.

Your Script: Not Tested but gives the Idea.


Author Message


Posts: 24
Rank:


Level: Member

Country: us
Location: In the dungeon to hell!
Occupation:
Age: 29
In-game name:

 
#4 Posted at 2013-10-30 09:41        
     
Oh wow, well I have done scripting in both sqs and sqf... that must be why it is a mix. I haven't made and missions in 2 years or so. Just going by what I remember from scripting. Thank you both for your replies. From now on I'll try to research a little bit more before I go and post my failed scripts for answers as to why, they don't work... Thanks again for everything guys.

BIG help.... now I should be able to complete my mission.

EDIT:
==================================================================

Okay, I've modified it a lot but still it doesn't do anything. As far as I know. No chopper comes to the extraction point and I checked the helipad that is there it is called helopad3. So I don't understand why it still doesn't work. By the way I think its all in sqf format now, not sure but... I'm sure you'll tell me.

/* this is my helicopter extraction script, by Philip Simonson. */
private ["_chopper","_helopad1","_helopad2","_groupUnits","_distFromHelo1","_distFromHelo2","_UnitCnt"];

_chopper = _this select 0;
_helopad1 = _this select 1;
_helopad2 = _this select 2;
_groupUnits = _this select 3;

player removeAction act1;

_distFromHelo1 = _chopper distance _helopad1;
_distFromHelo2 = _chopper distance _helopad2;
_UnitCnt = count units _groupUnits;

_chopper doMove (getPos _helopad1);
_chopper flyInHeight 25;
waitUntil{_distFromHelo2 > 35};
_chopper setSpeedMode "FULL";
_chopper flyInHeight 40;
waitUntil{_distFromHelo2 < 30};
_chopper setSpeedMode "LIMITED";
waitUntil {_distFromHelo2 < 10};
_chopper land "LAND";
waitUntil {(getPos _chopper select 2) < 1};
(driver _chopper) action "ENGINE OFF";
_chopper disableAI "MOVE";
sleep 0.2;
waitUntil {({_x in _chopper} count units _groupUnits) == _UnitCnt};
(driver _chopper) action "ENGINE ON";
sleep 0.2;
_chopper enableAI "MOVE";
_chopper doMove (getPos _helopad2);
_chopper flyInHeight 25;
waitUntil{_distFromHelo1 > 35};
_chopper setSpeedMode "FULL";
waitUntil{_distFromHelo1 < 30};
_chopper setSpeedMode "LIMITED";
waitUntil{_distFromHelo1 < 10};
_chopper land "LAND";
waitUntil{getPos _chopper select 2 < 1};
_chopper disableAI "MOVE";

exit;
By the way thanks in advance for any further help. I would love to make my own but I've re-coded this script around 40 times now. Still nothing. Please help...

This post was edited by theplague1988 (2013-10-30 14:22, ago)

Philip "5n4k3" Simonson

Author Message


Posts: 67
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2013-10-30 15:56        
     
I took the librity to write a Simple and effective script that will do what your tying to do, I included a Test mission you can save and test.
create a folder with any-name.utes, and save the script as any-name.sqf

Here the Helo comes in, lands and Team1 gets in, then Helo moves to Lz2 where Team1 get-out, and helo returns to Lz1.




Author Message

SavageCDN  

Armaholics priest


Posts: 475
Rank:


Country: ca
Location: Ottawa
Occupation: Fighting with Exchange
Age: 44
In-game name: =VG= SavageCDN

 
#6 Posted at 2013-10-30 17:18        
     
^ Good Canadian lad *OK*

Bless you my son.

Author Message


Posts: 24
Rank:


Level: Member

Country: us
Location: In the dungeon to hell!
Occupation:
Age: 29
In-game name:

 
#7 Posted at 2013-10-30 19:26        
     
Hey Bingoz, thanks for a quick reply and the sample mission/script. It helped a lot. But, when I modified it a little bit. To suit my needs, for some reason it will not land and stay there. It lands, starts to shut the engine off then, it takes off again. Just flying about 25-30 meters above ground. I can't figure out why, it would be highly appreciated if someone good/extremely good at scripting like you for instance, enlighten me why? Thanks in advance. Here is the script modified.

This Code Didn't Work Right... Removed

EDIT:

P.S. You can edit your test mission to have the heli on the helipad (LZ1) and then turn off the flying. Switch that to None, under Special in the Heli's settings.

EDIT 2:

Almost forgot, does anyone know of a site or have a site dedicated for learning ARMA 2 scripting? I still remember a little about scripting but, I'd love to know more. I don't need anything for the Mission Editor. Because ever since OFP CWC, I've been using that and a little sqs scripting. Then ArmA, with tiny bit of sqf scripting. Seriously, I'd love to be able to make a sandbox style mission one day. But for that you need SCRIPTING. Thanks in advance.

EDIT 3:

I finally figured it out, try this script Bingoz... it works perfectly.

The newly modified, code that works (b.sqf):
/*--------------------------------------------------------------------
 file: b.sqf
 ===========
 Author: Peppy Zolkiewski <Peppy.Zolk@Shaw.ca>
 Description: Test Land and Load Script.
 Modified: Philip Simonson
 --------------------------------------------------------------------*/
 #define __filename b.sqf 
 uc=count units group Team1;

 Helo1 allowFleeing 0;

 {_x assignAsCargo Helo1; [_x] orderGetIn true}forEach units group Team1;

 Helo1 enableAI "MOVE";
 waitUntil {{_x in Helo1} count units group Team1==uc};
 helo1 flyInHeight 25;
 Helo1 doMove position LZ2;

 waitUntil {Helo1 distance LZ2 < 110};
 Helo1 land "GET OUT";
 helo1 flyInHeight 1;
 {_x assignAsCargo nil; [_x] orderGetIn false}forEach units group Team1;

 waitUntil {{_x in Helo1} count units group Team1==0};
 helo1 flyInHeight 25;
 Helo1 move position LZ1;
 Helo1 sideChat "Returning to base.";

 waitUntil {Helo1 distance LZ1 < 110};
 Helo1 land "LAND";

 waitUntil {Helo1 distance LZ1 < 10};
 Helo1 sideChat "Landing at base.";

 waitUntil {position Helo1 select 2 < 1};
 Helo1 disableAI "MOVE";
 Helo1 flyInHeight 0;

 waitUntil {position Helo1 select 2 < 0.25};
 doStop Helo1;
 Helo1 land "LAND";
 Helo1 sideChat "Landed at base.";

 sleep 2;
 Helo1 setFuel 100;
 Helo1 sideChat "Script Ended.";

 exit;

Test Mission Script (Still on Utes Island: mission.sqm):
version=11;
class Mission
{
	addOns[]=
	{
		"CAAir2_UH1Y",
		"cacharacters2",
		"camisc3",
		"utes"
	};
	addOnsAuto[]=
	{
		"CAAir2_UH1Y",
		"cacharacters2",
		"camisc3",
		"utes"
	};
	randomSeed=4117173;
	class Intel
	{
		startWeather=0.40000001;
		forecastWeather=0.25;
		year=2008;
		month=10;
		day=11;
		hour=14;
		minute=20;
	};
	class Groups
	{
		items=4;
		class Item0
		{
			side="WEST";
			class Vehicles
			{
				items=1;
				class Item0
				{
					position[]={3362.3647,19,3607.6875};
					azimut=90;
					special="NONE";
					id=0;
					side="WEST";
					vehicle="UH1Y";
					leader=1;
					lock="UNLOCKED";
					skill=1;
					text="Helo1";
				};
			};
		};
		class Item1
		{
			side="WEST";
			class Vehicles
			{
				items=7;
				class Item0
				{
					position[]={3378.3369,19,3609.5278};
					azimut=246.28047;
					special="NONE";
					id=3;
					side="WEST";
					vehicle="USMC_Soldier";
					leader=1;
					skill=1;
					text="Team1";
				};
				class Item1
				{
					position[]={3380.7891,19,3614.5425};
					azimut=246.28081;
					special="NONE";
					id=4;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
				class Item2
				{
					position[]={3383.019,19,3610.689};
					azimut=246.28081;
					special="NONE";
					id=5;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
				class Item3
				{
					position[]={3385.6985,19,3607.0352};
					azimut=246.28081;
					special="NONE";
					id=7;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
				class Item4
				{
					position[]={3388.8457,19,3611.2808};
					azimut=246.28081;
					special="NONE";
					id=8;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
				class Item5
				{
					position[]={3390.8955,19,3615.5823};
					azimut=246.28081;
					special="NONE";
					id=9;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
				class Item6
				{
					position[]={3384.7017,19,3615.0081};
					azimut=246.28081;
					special="NONE";
					id=6;
					side="WEST";
					vehicle="USMC_Soldier";
					skill=1;
				};
			};
		};
		class Item2
		{
			side="WEST";
			class Vehicles
			{
				items=1;
				class Item0
				{
					position[]={3378.6721,19,3596.6765};
					azimut=322.41415;
					special="NONE";
					id=10;
					side="WEST";
					vehicle="USMC_Soldier";
					player="PLAYER COMMANDER";
					leader=1;
					skill=1;
				};
			};
		};
		class Item3
		{
			side="WEST";
			class Vehicles
			{
				items=1;
				class Item0
				{
					position[]={4064.0552,19,3587.3162};
					azimut=322.414;
					special="NONE";
					id=11;
					side="WEST";
					vehicle="USMC_Soldier";
					player="PLAY CDG";
					leader=1;
					skill=1;
				};
			};
		};
	};
	class Vehicles
	{
		items=2;
		class Item0
		{
			position[]={3362.5818,19,3607.5403};
			azimut=90;
			special="NONE";
			id=1;
			side="EMPTY";
			vehicle="HeliHCivil";
			skill=1;
			text="LZ1";
		};
		class Item1
		{
			position[]={4053.2534,19,3609.6804};
			azimut=90;
			special="FLY";
			id=2;
			side="EMPTY";
			vehicle="HeliHCivil";
			skill=1;
			text="LZ2";
		};
	};
	class Sensors
	{
		items=2;
		class Item0
		{
			position[]={3362.47,19,3608.9556};
			a=10;
			b=10;
			rectangular=1;
			activationBy="WEST";
			interruptable=1;
			type="SWITCH";
			age="UNKNOWN";
			class Effects
			{
			};
		};
		class Item1
		{
			position[]={3381.6211,19,3642.9004};
			a=0;
			b=0;
			activationBy="ALPHA";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			expActiv="null=execvm ""b.sqf"";";
			class Effects
			{
			};
		};
	};
};
class Intro
{
	addOns[]=
	{
		"utes"
	};
	addOnsAuto[]=
	{
		"utes"
	};
	randomSeed=13607617;
	class Intel
	{
		startWeather=0.40000001;
		forecastWeather=0.25;
		year=2008;
		month=10;
		day=11;
		hour=14;
		minute=20;
	};
};
class OutroWin
{
	addOns[]=
	{
		"utes"
	};
	addOnsAuto[]=
	{
		"utes"
	};
	randomSeed=1638421;
	class Intel
	{
		startWeather=0.40000001;
		forecastWeather=0.25;
		year=2008;
		month=10;
		day=11;
		hour=14;
		minute=20;
	};
};
class OutroLoose
{
	addOns[]=
	{
		"utes"
	};
	addOnsAuto[]=
	{
		"utes"
	};
	randomSeed=7043281;
	class Intel
	{
		startWeather=0.40000001;
		forecastWeather=0.25;
		year=2008;
		month=10;
		day=11;
		hour=14;
		minute=20;
	};
};

I hahaha, I'm learning... it's amazing.

This post was edited by theplague1988 (2013-10-31 09:33, ago)

Philip "5n4k3" Simonson

Author Message


Posts: 67
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2013-11-01 07:12        
     
SOLVED~! then..
Enjoy.

PS: some times it only takes a FEW blocks to build a Castel.

This post was edited by Bingoz (2013-11-01 07:56, ago)






Tags: 2, Arma, Oa, Scripting