Home   Help Search Login Register  

Author Topic: AI creator (sqf problem)  (Read 2061 times)

0 Members and 1 Guest are viewing this topic.

Offline theunknown

  • Members
  • *
AI creator (sqf problem)
« on: 17 Aug 2008, 19:23:10 »
I have been working on a AI creator script for my clans training map. So far I have managed to get all the error messages that show up in game out of the script except for this last one,
Code: [Select]
Error in expression <g">
 Error position: <">
 Error Missing;

Now I tink the error is some where in the creatunit area cause it happens multiple times.

This is the script,
Code: [Select]
//REGION RUNCODE
////////////////////////////////////////////////////////
//Runcode: var = [Groupleader,Amountofinfantry,Amountofvehicles,Amountofarmour,AmountofAirunits,Geartype,Unitside] execVM "AIcreator.sqf"
//Geartypes: 1=West, 2=East
//Sides: 1=West, 2=East, 3=Guerilla, 4=Civilian
////////////////////////////////////////////////////////
//ENDREGION
//REGION Data gathering
_Unit = _this select 0;
_InfS = _this select 1;
_VecS = _this select 2;
_ArmS = _this select 3;
_AirS = _this select 4;
_Geartype = _this select 5;
_Unittype = _this select 6;
_Group = group _Unit;
//ENDREGION
//REGION Unit lists
_InfW = ["SoldierWSaboteurPipe2","SoldierWAA","SoldierWAT","SoldierWAR","SoldierWCrew","SoldierWMiner","SoldierWG","SoldierWMG","SoldierWB","SoldierWPilot","OfficerW","SoldierWMedic","SoldierWSaboteurAssault","SoldierWSaboteurMarksman","","SoldierWSaboteurRecon","SoldierWSaboteurPipe","TeamLeaderW","SquadLeaderW","SoldierWSniper"];
_VecW = ["Truck5tOpen","Truck5tMG","HMMWV","HMMWV50","HMMWVMK","Truck5t","HMMWVTOW","M1030","m113ambul","Truck5tRepair","Truck5tRefuel","Truck5tReammo"];
_ArmW = ["M113","Vulcan","M1Abrams","Stryker_TOW","Stryker_ICV_M2","Stryker_ICV_MK19"];
_AirW = ["UH60","Camel","MH6","UH60MG","AV8B","AV8B2","AH6","AH1W","A10"];
_InfE = ["SoldierEAA","SoldierEAT","SoldierECrew","SoldierEMiner","SoldierEMG","SoldierEG","SoldierESniper","SoldierEB","SoldierEPilot","SoldierESaboteurMarksman","OfficerE","SoldierESaboteurBizon","SoldierESaboteurPipe","SoldierEMedic","SquadLeaderE","TeamLeaderE"];
_VecE = ["UAZ","UralReammo","UralRefuel","Ural","UAZMG","UralOpen","UAZ_AGS30","UralRepair","TT650G","bmp2ambul"];
_ArmE = ["T72","BMP2","BRDM2","BRDM2_ATGM","ZSU"];
_AirE = ["KA50","Mi17_MG","Mi17","Su34B","Su34","Camel2"];
_InfG = ["SoldierGAA","SoldierGAT","SoldierGCrew","SoldierGMiner","SoldierGGuard","SoldierGCommando","SquadLeaderG","TeamLeaderG","SoldierGB","SoldierGMG","SoldierGMedic","OfficerG","SoldierGSniper","SoldierGPilot","SoldierGG","SoldierGMarksman"];
_VecG = ["Landrover_Closed","LandroverMG","Landrover"];
_ArmG = ["Vulcan_RACS","M113_RACS","T72_RACS"];
_AirG = ["AH6_RACS","MH6_RACS"];
_InfC = ["Civilian","Civilian10","Civilian11","Civilian12","Civilian20","Civilian14","Civilian15","Civilian19","Civilian2","Civilian13","Civilian21","Civilian9","Civilian8","Civilian7","Civilian6","Civilian5","Civilian18","Civilian17","Civilian16","Civilian3","Civilian4"];
_VecC = ["SkodaGreen","Skoda","UralCivil","Bus_city","SkodaBlue","SkodaRed","datsun1_civil_1_open","hilux1_civil_3_open","hilux1_civil_2_covered","hilux1_civil_1_open","car_hatchback","UralCivil2","TT650C","datsun1_civil_3_open","datsun1_civil_2_covered","car_sedan","tractor"];
_ArmC = [];
_AirC = [];
//ENDREGION
//REGION Unit creation
switch (_Unittype) do {
//REGION West
case 1:
{
while {_I < _InfS} do
{
_I=_I+1;
_IA = count _InfW;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfW select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};
while {_V < _VecS} do
{
_V=_V+1;
_VA = count _VecW;
_VN = random _VA;
_VN = round _VN;
_VUnit = _VecW select _VN;
(_VUnit createUnit [position _Unit, _Group]);
};
while {_R < _ArmS} do
{
_R=_R+1;
_RA = count _ArmW;
_RN = random _RA;
_RN = round _RN;
_RUnit = _ArmW select _RN;
(_RUnit createUnit [position _Unit, _Group]);
};
while {_A < _AirS} do
{
_A=_A+1;
_AA = count _AirW;
_AN = random _AA;
_AN = round _AN;
_AUnit = _AirW select _AN;
(_AUnit createUnit [position _Unit, _Group]);
};
};
//ENDREGION
//REGION East
case 2:
{
while {_I < _InfS} do
{
_I=_I+1;
_IA = count _InfE;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfE select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};
while {_V < _VecS} do
{
_V=_V+1;
_VA = count _VecE;
_VN = random _VA;
_VN = round _VN;
_VUnit = _VecE select _VN;
(_VUnit createUnit [position _Unit, _Group]);
};
while {_R < _ArmS} do
{
_R=_R+1;
_RA = count _ArmE;
_RN = random _RA;
_RN = round _RN;
_RUnit = _ArmE select _RN;
(_RUnit createUnit [position _Unit, _Group]);
};
while {_A < _AirS} do
{
_A=_A+1;
_AA = count _AirE;
_AN = random _AA;
_AN = round _AN;
_AUnit = _AirE select _AN;
(_AUnit createUnit [position _Unit, _Group]);
};
};
//ENDREGION
//REGION Guerilla
case 3:
{
while {_I < _InfS} do
{
_I=_I+1;
_IA = count _InfG;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfG select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};
while {_V < _VecS} do
{
_V=_V+1;
_VA = count _VecG;
_VN = random _VA;
_VN = round _VN;
_VUnit = _VecG select _VN;
(_VUnit" createUnit [position _Unit, _Group]);
};
while {_R < _ArmS} do
{
_R=_R+1;
_RA = count _ArmG;
_RN = random _RA;
_RN = round _RN;
_RUnit = _ArmG select _RN;
(_RUnit" createUnit [position _Unit, _Group]);
};
while {_A < _AirS} do
{
_A=_A+1;
_AA = count _AirG;
_AN = random _AA;
_AN = round _AN;
_AUnit = _AirG select _AN;
(_AUnit" createUnit [position _Unit, _Group]);
};
};
//ENDREGION
//REGION Civilian
case 4:
{
while {_I < _InfS} do
{
_I=_I+1;
_IA = count _InfC;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfC select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};
while {_V < _VecS} do
{
_V=_V+1;
_VA = count _VecC;
_VN = random _VA;
_VN = round _VN;
_VUnit = _VecC select _VN;
(_VUnit createUnit [position _Unit, _Group]);
};
while {_R < _ArmS} do
{
_R=_R+1;
_RA = count _ArmC;
_RN = random _RA;
_RN = round _RN;
_RUnit = _ArmC select _RN;
(_RUnit createUnit [position _Unit, _Group]);
};
while {_A < _AirS} do
{
_A=_A+1;
_AA = count _AirC;
_AN = random _AA;
_AN = round _AN;
_AUnit = _AirC select _AN;
(_AUnit createUnit [position _Unit, _Group]);
};
};
//ENDREGION
};
//ENDREGION
//REGION GEAR
switch (_Geartype) do{
case 1:
{
[_Unit,1,10] execVM "gear\Gearsquad.sqf";
};
case 2:
{
[_Unit,2,10] execVM "gear\Gearsquad.sqf";
};
};
//ENDREGION
//REGION Exit
exitWith;
//ENDREGION


Does anyone have a clue what is wrong with this script?

The Unknown

P.S. I only tested this in SP yet but it is intended for MP use once I get the codeing error's out I plan on testing it in MP.
« Last Edit: 17 Aug 2008, 21:19:34 by theunknown »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: AI creator (sqf problem)
« Reply #1 on: 18 Aug 2008, 08:17:25 »
First off, are you sure the error isn't in the gearscript?

Second, try adding the start comments inside */ /* instead of using //.

To comment you can either use // in each line, or you can use */ to start a comment, then several lines later you can add /* to stop the comment. Or maybe you have to switch the * and the / in both...never remember which goes first :whistle:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: AI creator (sqf problem)
« Reply #2 on: 18 Aug 2008, 11:07:37 »
No, you use /* to start and */ to end a block comment.
Code: [Select]
/*
Hello, I'm not really here.
Neither am I.
*/

Both /* ... */ and // work perfectly well and neither is "better". This is a stylistic, rather than functional, choice for the scripter. Be aware, though, that nesting block comments, e.g.  /* ...  /* ... */ ... */, will cause problems with the preprocessor, so I avoid them, but that is my choice, not something you must do.

It seems that your error message is not very verbose. Try using preprocessFileLineNumbers instead of preprocessFile and you will get an error message that gives the file and line number of the problem (like you would when you run an SQF function with execVM).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline theunknown

  • Members
  • *
Re: AI creator (sqf problem)
« Reply #3 on: 18 Aug 2008, 14:04:47 »
@Garcia,
I developed the gear script seperate from the AI creator script and it didnt bring up error's then, I tested it just a couple of min ago by commenting the code out and it still had the error.
And the // is just my style, I just moved over from the sqs scripting to sqf and its just a old habbit.

@Spooner,
Can you explain how to use those commands cause the biki is a bit vague about them.

@all,
Some guys at the BIS forums have helped me out a bit and I got the script to create the units but it still gives the error. Since at the BIS forums it doesnt record tabs Q suggested a site that does show them, so here is the link to the script on it.

http://pastebin.com/d29605fd3

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: AI creator (sqf problem)
« Reply #4 on: 18 Aug 2008, 17:49:49 »
The first error is at line 139:
Code: [Select]
(_VUnit" createUnit [position _Unit, _Group]);

(same problem at 148 and 159).

Also, for each of your while loops, the iterator variable is initially undefined, rather than being set to 0.
Code: [Select]
_I = 0;
while {_I < _InfS} do
{
_I = _I + 1;
_IA = count _InfW;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfW select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};

However, consider using a for loop, rather than while loop, in this case, since it is simpler and clearer:
Code: [Select]
for "_i" from 1 to _InfS do
{
_IA = count _InfW;
_IN = random _IA;
_IN = round _IN;
_IUnit = _InfW select _IN;
(_IUnit createUnit [position _Unit, _Group]);
};

I couldn't get an error anything like what you were getting. ArmA also gave a "meaningful" error message and line number (which you weren't getting), so I haven't a clue what was going on with you.

Ignore what I said about preprocessFile(lineNumbers), since it obviously wasn't the problem you were having. I thought you must be using preprocessFile (or using dynamic script generation) already, or you'd have been given a line number for the error.

EDIT: You are also trying to createUnit for vehicles, which need to be created with createVehicle. Remember too, that you need to manually create all the correct crew for a vehicle when you make it in a script, rather than via the edior.
« Last Edit: 18 Aug 2008, 18:00:44 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline theunknown

  • Members
  • *
Re: AI creator (sqf problem)
« Reply #5 on: 18 Aug 2008, 19:14:21 »
Mabey its someting els in the missions causeing the problem Ill try running it in a clean mission.

Edit: seems you are right and it works now probally someting in the mission I was testing it in. Thanks for all your help, mabey if I got everyting done on it i will release it on this site.
« Last Edit: 18 Aug 2008, 19:28:46 by theunknown »