Advertisement

Author Topic: Insurgency Editing  (Read 622 times)

0 Members and 1 Guest are viewing this topic.

Offline iOGC_Aenigma

  • Members
  • *
Insurgency Editing
« on: 27 May 2012, 22:57:31 »
I am currently trying to edit the Insurgency mission on Lingor to use the Lingor units add on so I can simulate a police vs drug lord scenario.

When loading the mission I get this error:
"Missing [" at line 152 of my common\functions.sqf
Below are lines 150 to 154 of that file.

Code: [Select]
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (typeOf _x in eastInfClasses && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};


I am by no means a skilled editor with Arma yet but have had some success with missions before this. This is the first time I am faced with a script error and wondered if it is something simple that I may have done wrong. Any help would be much appreciated but I shall continue to trawl through my scripts to see if I can rectify the problem.
« Last Edit: 27 May 2012, 23:00:44 by iOGC_Aenigma »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Insurgency Editing
« Reply #1 on: 28 May 2012, 08:50:30 »
You have a errand semicolon there after the line
Code: [Select]
if (_type == "count") then { _result = 0; } else { _result = []; };
Quote
   if (_type == "count") then { _result = 0; } else { _result = []; };
   {
      if (typeOf _x in eastInfClasses && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
         if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
      };




Oh, and welcome to OFPEC!
:welcome:
Project MCAR   ---   FWW2 - Finland At War 1939-1945
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline iOGC_Aenigma

  • Members
  • *
Re: Insurgency Editing
« Reply #2 on: 28 May 2012, 19:34:42 »
Thank you for the welcome and the help. Looking further into the script I think that highlighted error is actually needed. The script continues as follows:

Code: [Select]
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (typeOf _x in eastInfClasses && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach _arr2;

I think I may well have just gone a little bit out of my depth here. I shall keep at it though.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Insurgency Editing
« Reply #3 on: 29 May 2012, 10:08:03 »
Well, posting the whole script might be a better idea, it might be that the line number is completely wrong; it just shows where the game thinks it goes awry although it might have done it earlier on.
Project MCAR   ---   FWW2 - Finland At War 1939-1945
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline iOGC_Aenigma

  • Members
  • *
Re: Insurgency Editing
« Reply #4 on: 29 May 2012, 18:52:54 »
Thank you again for your response h-, I hope one day I may be able to help others facing the same troubles as I am with Arma editing. It is a game and engine I love so would like to develop my editing skills.

Here is the full script although right now I am thinking that maybe I have not defined the factions or unit names correctly as if I am not mistaken this script references information that is written in other files within the mission.

Code: [Select]
// return true when distance to spawnPos is less than 1000m unless the unit is flying (i.e. altitude higher than 50m)
isDead = {
(getPosATL _this select 2 < 50 && (_this distance spawnPos) < 500)
};
#define isDead(X) (X call isDead)

// find all valid houses which offer a certain minimum count of positions
findHouses = {
private ["_buildings","_minPositions","_enterables","_alive"];
_buildings = nearestObjects [_this select 0, ["House"], _this select 1];
_minPositions = (_this select 2) - 1;
_alive = _this select 3;

_enterables = [];
{
if (
format["%1", _x buildingPos _minPositions] != "[0,0,0]"
&& EP1HOUSES
&& !(typeOf _x in ILLEGALHOUSES) && (alive _x || !_alive)
) then {
_enterables set [count _enterables, _x];
};
} forEach _buildings;
_enterables
};

setSurrendered = {
if !isDedicated then {
if (player distance _this <= 20) then {
private "_txt";
switch (round random 1) do {
case 0: { _txt = "I Surrender!"; };
case 1: { _txt = "I give up!"; };
};
_this globalChat format["%1: %2", getText (configFile >> "CfgVehicles" >> typeOf _this >> "displayName"), _txt];
};
};
if isServer then {
removeAllWeapons _this;
_this setUnitPos "UP";
_this disableAI "move";
_this playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
_this disableAI "anim";
};
};

getDir2 = {
    private ["_dirW","_dirS"];

    _dirW = screenToWorld [0.5,0.5];
_dirS = ((_dirW select 0) - (getPosATL player select 0)) atan2 ((_dirW select 1) - (getPosATL player select 1));   
((_dirS+360) % 360)
};

#define getDir2 (call getDir2)

nearestWeapons = {
private ["_wep","_pos","_rds","_alive","_type","_result"];
_wep   = _this select 0;
_pos   = _this select 1;
_rds   = _this select 2;
_alive = _this select 3;
_type  = _this select 4;
   
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (_x isKindOf "man" && (!alive _x || _alive)) then {
if (_wep in weapons _x) then {
if (_type == "count") then { _result = _result + 1; } else { _result = _result + [_x]; };
};
} else {
if (_wep in (getWeaponCargo _x select 0)) then {
if (_type == "count") then { _result = _result + 1; } else { _result = _result + [_x]; };
};
};
} forEach nearestObjects[_pos,["weaponHolder","man","ReammoBox","AllVehicles"],_rds];
_result
};

#define nearestWeapons(V,W,X,Y,Z) ([V,W,X,Y,Z] call nearestWeapons)

groupMembers = {
private ["_result","_plr","_alive","_type"];
_alive = _this select 0;
_type  = _this select 1;
   
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (!isNil _x) then {
_plr = call compile _x;
if (!isNull _plr) then {
if ((alive _plr && !isDead(_plr)) || !_alive) then {
if (_type == "count") then { _result = _result + 1; } else { _result = _result + [_plr]; };
};
};
};
} forEach (squadUnitStrings(squadString(player))-[player]);
_result
};

#define groupMembers(Y,Z) ([Y,Z] call groupMembers)

nearestPlayers = {
private ["_result","_pos","_range","_type","_alive","_arr"];
_pos   = _this select 0;
_range = _this select 1;
_alive = _this select 2;
_type  = _this select 3;

if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (!isNil _x) then {
_plr = call compile _x;
if (!isNull _plr) then {
if (_plr distance _pos <= _range && (alive _plr || !_alive)) then {
if (_type == "count") then { _result = _result + 1; } else { _result = _result + [_plr]; };
};
};
};
} forEach westPlayerStrings;
_result
};

#define nearestPlayers(W,X,Y,Z) ([W,X,Y,Z] call nearestPlayers)

nearestInfantry = {
private ["_result","_arr","_alive","_type"];
_arr   = nearestObjects[_this select 0, ["Man"], _this select 1];
_alive = _this select 2;
_type  = _this select 3;
   
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (!(_x in westPlayerStrings) && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach _arr;
_result
};

#define nearestInfantry(W,X,Y,Z) ([W,X,Y,Z] call nearestInfantry)

nearestEastMen = {
private ["_result","_arr1","_arr2","_alive","_type"];
_arr1  = nearestObjects[_this select 0, ["LandVehicle"], _this select 1];
_arr2  = nearestObjects[_this select 0, ["Man"], _this select 1];
_alive = _this select 2;
_type  = _this select 3;
   
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (typeOf _x in eastInfClasses && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach _arr2;
for "_i" from 0 to (count _arr1 - 1) do {
{
if (typeOf _x in eastInfClasses && (alive _x || !_alive) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach (crew (_arr1 select _i));
};
_result
};

#define nearestEastMen(W,X,Y,Z) ([W,X,Y,Z] call nearestEastMen)
#define numberOfAI           nearestEastMen(CENTERPOS,AORADIUS,false,"count")

nearestMen2 = {
private ["_result","_arr1","_arr2","_alive","_type"];
_arr1  = nearestObjects[_this select 0, ["Car","Tank"], _this select 1];
_arr2  = nearestObjects[_this select 0, ["Man"], _this select 1];
_alive = _this select 2;
_type  = _this select 3;
   
if (_type == "count") then { _result = 0; } else { _result = []; };
{
if (!isDead(_x) && _x isKindOf "Man" && !(str _x in westPlayerStrings) && ( (alive _x && primaryWeapon _x != "") || !_alive ) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach _arr2;
for "_i" from 0 to (count _arr1 - 1) do {
{
if (!(str _x in westPlayerStrings) && (alive _x || !_alive) ) then {
if (_type == "count") then { _result = _result + 1; } else { _result set [count _result, _x]; };
};
} forEach (crew (_arr1 select _i));
};
_result
};

#define nearestMen2(W,X,Y,Z) ([W,X,Y,Z] call nearestMen2)

knowsAboutAll = {
    private ["_knows","_unit","_ai","_arr"];
    _ai    = _this select 0;
_arr   = _this select 1;

_knows = true;
for "_i" from 0 to (count _arr - 1) do {
_unit = _arr select _i;
if (_ai knowsAbout _unit < 1) exitWith { _knows = false; };
};
_knows
};

#define knowsAboutAll(X,Y) ([X,Y] call knowsAboutAll)

getBearing = {
private ["_dirTo","_unit","_obj","_uDir"];
   
    _unit  = _this select 0;
    _obj   = _this select 1;

    _dirTo = abs(getDirTo(_unit,_obj));
    _uDir  = getDir(vehicle _unit);
if (abs(_dirTo - _uDir) > 180) then { _dirTo = -1*(360 - _dirTo); };
(_dirTo - _uDir)
};

// canSee; returns true if a _unit looks at the _obj within a certain _arc (field of view) in degrees
canSee = {
private ["_unit","_obj","_dirTo","_uDir","_vcl","_arc"];
_unit  = _this select 0;
_obj   = _this select 1;
_arc   = _this select 2;

_dirTo = getDirTo(_unit,_obj); // vector from _unit to _obj
_uDir  = getDir (vehicle _unit); // heading of _unit
if (vehicle _unit != _unit) then {
// if it's a vehicle and _unit is in a turret we take the heading of that turret
_vcl = vehicle _unit;
if (_vcl turretUnit [0] == _unit) then {
_uDir = _vcl weaponDirection (_vcl weaponsTurret [0] select 0);
_uDir = (_uDir select 0) atan2 (_uDir select 1);
};
};
if (abs(_dirTo - _uDir) > 180) then { _uDir = -1*(360 - _uDir); };
abs(_dirTo - _uDir) <= _arc

};

#define canSee(X,Y,Z) ([X,Y,Z] call canSee)

arrCanSee = {
private ["_arc","_pos","_arr","_rng","_unit","_canSee"];
_arr = _this select 0;
_pos = _this select 1;
_arc = _this select 2;
_rng = _this select 3;
   
_canSee = false;
for "_i" from 0 to (count _arr - 1) do {
_unit = _arr select _i;
if (alive _unit && (canSee(_unit,_pos,_arc) || _unit distance _pos <= _rng)) exitWith { _canSee = true; };
};
_canSee
};

#define arrCanSee(W,X,Y,Z) ([W,X,Y,Z] call arrCanSee)

canSeeArr = {
    private ["_canSee","_unit","_pos","_arr","_arc"];
    _pos = _this select 0;
_arr = _this select 1;
_arc = _this select 2;
   
_canSee = true;
for "_i" from 0 to (count _arr - 1) do {
_unit = _arr select _i;
if !canSee(_pos,_unit,_arc) exitWith { _canSee = false; };
};
_canSee
};

#define canSeeArr(X,Y,Z) ([X,Y,Z] call canSeeArr)

// create an AI group based on the supplied params and returns the concatenated name
// if the AI group already exists it only returns the name
getGroup = {
    private ["_side","_prefix","_name","_suffix"];
    _prefix = _this select 0;
    _name   = _this select 1;
    _suffix = _this select 2;
_side   = _this select 3;

call compile format["
if isNil ""%1%2%3"" exitWith { %1%2%3 = createGroup %4; %1%2%3 };
if isNull %1%2%3 exitWith { %1%2%3 = createGroup %4; %1%2%3 };
%1%2%3
", _prefix, _name, _suffix, _side];
};

countPositions = {
private ["_i","_house","_hPos"];
    _house = _this select 0;
    _i = _this select 1;
   
_hPos = format["%1", _house buildingPos _i];
if (_hPos == "[0,0,0]") exitWith { _i; };
[_house, _i+1] call countPositions;
};

#define nPos(X) ([X,0] call countPositions)

getGridPos = {
    private ["_pos","_x","_y"];
   
  _pos = getPosATL _this;
  _x = _pos select 0;
  _y = _pos select 1;
  _x = _x - (_x % 100);
  _y = _y - (_y % 100);
[_x + 50, _y + 50, 0]
};

getCaches = {
private ["_i","_arr","_str","_cache"];
    _arr = _this select 0;
    _i   = _this select 1;
   
if (_i >= cacheCount) exitWith { _arr; };
    _str   = format["cache%1", _i+1];
    _cache = call compile _str;
if (!isNull _cache) then {
if (alive _cache) then { _arr = _arr + [_cache]; };
};
[_arr, _i+1] call getCaches;
};

#define cacheList      ([[],0] call getCaches)

getCacheMarkers = {
private ["_i","_cache","_arr","_mkr"];
    _cache  = _this select 0;
    _arr    = _this select 1;
    _i   = _this select 2;
   
_mkr = format["%1intel%2", _cache, _i];
if ((getMarkerPos _mkr select 0) == 0) exitWith { _arr; };
_arr set [_i, _mkr];
[_cache, _arr, _i+1] call getCacheMarkers;
};

#define cacheMarkers(X) ([X,[],0] call getCacheMarkers)

createDebugMarker = {
    private ["_txt","_dir","_unit","_mkr"];
    _unit = _this select 0;

if (isNil "_unit") exitWith { };   
_mkr = createMarkerLocal["DEBUG" + str _unit, getPosATL _unit];
_mkr setMarkerShapeLocal "ICON";
_mkr setMarkerTypeLocal "mil_triangle";
_mkr setMarkerSizeLocal [0.5,0.7]; 
_txt = str _unit;
//if (typeName _txt == "OBJECT") then {_txt = getText (configFile >> "CfgVehicles" >> typeOf vehicle(_this select 1) >> "displayName"); };
if (str _unit in eastPlayerStrings) then { _txt = name _unit; };
_mkr setMarkerTextLocal _txt;
_mkr setMarkerColorLocal "ColorRed";
_dir = getDir _unit;
if (vehicle _unit != _unit) then { _dir = formationDirection _unit; };
_mkr setMarkerDirLocal _dir;
if (!alive _unit) then { _mkr setMarkerColorLocal "ColorBlack"; };
[_mkr, _unit] spawn {
        private ["_mkr","_unit"];
        _mkr    = _this select 0;
        _unit   = _this select 1;
       
while{!isNull _unit && DEBUG}do{
_mkr setMarkerPosLocal getPosATL _unit;
_mkr setMarkerDirLocal getDir _unit;
if !alive _unit then { _mkr setMarkerColorLocal "ColorBlack"; };
sleep 0.1;
};
if !DEBUG then { sleep 5; };
deleteMarkerLocal _mkr;
};
};


Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Insurgency Editing
« Reply #5 on: 31 May 2012, 07:48:28 »
After a quick look all the brackets seem to be fine but one thing pops up: getDirTo.

There is no mention of it anywhere in the script other than when it's called and the way it is used I'm assuming it's #defined somewhere.

I have no experience with #define in Arma2 but in Arma1 you could not #define something in file A and then use it in file B, you had to for example do your #defines in a blah.hpp which would then be #included in the beginning of each script so you can use the #defines in it. And on top of that the *.hpp file had to be in the same exact folder as the script #including it.

As I said I don't know whether this has changed in A2 but that's the only thing I can come up with right now. :dunno:
Project MCAR   ---   FWW2 - Finland At War 1939-1945
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.