Nielsen 10 Posted July 30, 2011 (edited) Hey folks... Working on a mission and a couple of lines of code has stopped me dead in my tracks.. call compile format [" _AmbushT_%1 = createTrigger[""EmptyDetector"", getPos leader _InfGrp]; _AmbushT_%1 setTriggerActivation [""WEST"", ""PRESENT"", false]; _AmbushT_%1 setTriggerArea [8, 8, 0, false]; _AmbushT_%1 setTriggerStatements [""this and """"land"""" countType thislist > 0"","" hint """"ambushNOW""""; {_x addMagazine """"uns_tokarevmag""""; _x addWeapon """"uns_tokarev""""; _x addMagazine """"uns_tokarevmag""""; _x addMagazine """"uns_tokarevmag""""; _x setCaptive false;} forEach units %2;"", """"]; ",_y,_InfGrp]; _y is the number in a "for-to-do" loop. _InfGrp is a group I have just created within the script. The trigger executes and gives me the hint, and the _InfGrp is returning the group as it should. However the units do not recieve the weapons or setcaptive false. The .rpt gives me the following error: Error in expression <; _x setCaptive false;} forEach units O 1-1-H> Error position: <1-1-H> Error Missing ; I've been staring at it for hours, but I simply cannot see where that ; is missing... Can anyone tell me what is wrong with my syntax? Thx in advance Regards, Nielsen Edited July 30, 2011 by Nielsen Share this post Link to post Share on other sites
demonized 20 Posted July 30, 2011 try using only "" instead of """" or switch out "" with ' Share this post Link to post Share on other sites
Nielsen 10 Posted July 30, 2011 Hmmm. When I tried replacing """" with "" ' like this: call compile format [" _AmbushT_%1 = createTrigger[""EmptyDetector"", getPos leader _InfGrp]; _AmbushT_%1 setTriggerActivation [""WEST"", ""PRESENT"", false]; _AmbushT_%1 setTriggerArea [8, 8, 0, false]; _AmbushT_%1 setTriggerStatements [""this and ""'land'"" countType thislist > 0"","" hint ""'ambushNOW'""; {_x addMagazine ""'uns_tokarevmag'""; _x addWeapon ""'uns_tokarev'""; _x addMagazine ""'uns_tokarevmag'""; _x addMagazine ""'uns_tokarevmag'""; _x setCaptive false;} forEach units %2;"", """"]; ",_y,_InfGrp]; The .rpt reports: Error in expression <ushT_3 setTriggerStatements ["this and "'land'" countType thislist > 0"," hint "> Error position: <'land'" countType thislist > 0"," hint "> Error Missing ] The same happens when I remove the ' in the above, so as to only use ""... Now it thinks I'm missing a ]... I'm getting really confuzzled here :confused: Any ideas? Share this post Link to post Share on other sites
kylania 568 Posted July 30, 2011 Personally I'd dump all that equipment stuff into a separate SQF file, it's crazy trying to have that as part of a dynamically created trigger with all the quotes. Are you trying to have OPFOR unarmed unless BLUFOR comes within 8m (crazy close...) of them, then arm them and set their captive false? Maybe replace the whole trigger idea with a distance and nearEntities + side check? Share this post Link to post Share on other sites
Nielsen 10 Posted July 30, 2011 I'm not sure how to do it seperately. I've got a random amount of groups, on random places, with a random amount of troops (what can I say, I'm a randomholic :o ). All created within the script. I'm not sure how to pull it off seperately without the trigger when it is so dynamic. Thats exactly what I'm trying to do. I'm trying to make small ambushes at different locations. I had it working earlier with "forEach units thislist" in the trigger. But there are civilians around, and as the OPFOR are setCaptive they register as civilians. So that way I would arm the entire neighbourhood. That it worked with "thislist" indicated a problem with the group, but _InfGrp seems to return the group properly, and I've also tried to return an array with the units. But yeah, I want them to look like civilians until you get danger close (so your buddy will have to cover you good). They cant be waving weapons around initially. Any thoughts? Share this post Link to post Share on other sites
kylania 568 Posted July 30, 2011 Trying to do very specific things with entirely random units is never easy. :) Make a function that starts the "is anyone close to us, if so RAMBOTIME!" loop that you run on group leaders when they spawn. That'll do away with multiple triggers and all the trouble thislist brings into things. That way you spawn a group, unarm the group and set them as civilians but as soon as a BLUFOR guy gets within distance set them off. It's dinner time, but I'll try to work on something like that in a little bit. :) Share this post Link to post Share on other sites
Nielsen 10 Posted July 31, 2011 (edited) I just got it working, though in a somewhat inefficient way. Your checkSide idead made me think. As I had it working with a civ trigger I made that again, and put a (if kindOf _x == "") clause in it to make sure only the right units were affected.. Now I have two triggers for each ambush though, as I detect BLUEFOR with one and trigger the CIV trigger with the code. Thanks for the help! I'm allways interested in more efficient ways of doing things, so I'd appreciate any more input on improving the method. If you've got better things to do, then no worries it is working ;) Here is all the relevant code as of now: //Setup ambushes _Allcurrent = _allVil; diag_log format ["Ambush current %1",_Allcurrent]; for "_y" from 1 to _AmbushVils step +1 do { _NewVil = _allCurrent select (floor(random(count _allCurrent))); _Allcurrent = _Allcurrent - [_NewVil]; _newPos = getmarkerPos _newVil; // private ["_strength","_allunits","_max","_unittype","_unit","_InfGrp"]; _strength = 1 + ceil random 2; //_allunits = ["uns_local_vc1a","uns_local_vc1c"]; //_max = (count _allunits)-1; _InfGrp = createGroup EAST; //create units for the ambush for "_j" from 1 to _strength do { _unitType = _allunits select (round random _max); _unit = _InfGrp createUnit ["uns_local_vc1a", _newPos, [], 5, "NONE"]; [_unit] join _InfGrp; removeAllWeapons _unit; _unit setCaptive true; _unit setUnitPos "UP"; diag_log format ["Ambush unit %1",_unit]; }; _InfGrp setBehaviour "SAFE"; { _skill = 0.4 + ((round random 4) / 10); _x setskill ["aimingAccuracy",_skill]; _x setskill ["spotDistance",0.65]; _x setskill ["spotTime",0.85]; _x setskill ["courage",1]; _x setskill ["commanding",0.85]; _x setskill ["aimingShake",0.25]; _x setskill ["aimingSpeed",0.9]; } foreach units _InfGrp; diag_log "creating ambush triggers"; //create triggers to execute the ambush //private ["_list"]; //_list = _newPos nearEntities ["uns_local_vc1a",25]; call compile format [" _AmbushT_%1 = createTrigger[""EmptyDetector"", getPos leader _InfGrp]; _AmbushT_%1 setTriggerActivation [""WEST"", ""PRESENT"", false]; _AmbushT_%1 setTriggerArea [8, 8, 0, false]; _AmbushT_%1 setTriggerStatements [""this and """"land"""" countType thislist > 0"",""Ambush_%1 = true;"", """"]; ",_y]; call compile format [" _AmbushT = createTrigger[""EmptyDetector"", getPos leader _InfGrp]; _AmbushT setTriggerActivation [""CIV"", ""PRESENT"", false]; _AmbushT setTriggerArea [20, 20, 0, false]; _AmbushT setTriggerStatements [""this and Ambush_%1"", "" hint """"ambushNOW""""; {if ((typeOf _x) == """"uns_local_vc1a"""") then {_x addMagazine """"uns_tokarevmag""""; _x addWeapon """"uns_tokarev""""; _x addMagazine """"uns_tokarevmag""""; _x addMagazine """"uns_tokarevmag""""; _x setCaptive false;};} forEach thislist;"", """"]; ",_y]; //newGroups = newGroups + [_InfGrp]; }; Edited July 31, 2011 by Nielsen Share this post Link to post Share on other sites