Editors Depot - Mission Editing and Scripting > OFP - Editing/Scripting General

Fwatch 1.13 for CWA in action

(1/5) > >>

SoldierEPilot:
There are many new possibilities 4 scripters in new Fwatch 1.13 (made by Faguss).
If you are not a happy owner yet - use this link:
http://ofp-faguss.com/fwatch/
AFAIK there are 2 versions - for CWA and for OFP 1.96, I use the first one.

One of the most cool things - :class token command.
From now on you can get almost all information from the
mission config (mission.sqm) in editor missions and unpacked campaigns.


--- Code: ---comment{
//////////////////////////////////////////////////
Reading mission config values.
Works with editable missions and unpacked campaigns.
Сampaign mission names better not starts from "t"
//////////////////////////////////////////////////
};

private["_a", "_cmp", "_cmpgs", "_c", "_j", "_p", "_f", "_path", "_il", "_token"];

comment{
Is it a campaign?
It's possible to use queryMagazineCargo to check it out,
but some delay needed to make this check stable.
To provide delay I need a script, but I prefer immediate decision.
Here is the choice 'tween editable mission and unpacked campaign.
};
_a = (call loadFile format[":class token ""%1"" c:[Mission]", "f:mission.sqm"]) select 0;
_a=!_a;
ISCMP = _a;

comment{Safe wrapper for "... :il ..." request};

 _il={
private ["_p", "_r"];
if (_this in [_this]) then {_p=[_this]} else {_p=+_this};
_r=["il "];
{_r=_r+[format["%1",_x]]} forEach _p;
call (_r call preprocessFile {..\fwatch\data\ExecCommand.sqf})
};

comment{Campaign name};
_cmp="";
if _a then{
_cmpgs = ("..\Campaigns\*" call _il) select 4;
_c=count _cmpgs;
_j=-1;
while{_j=_j+1;_j<_c}do
  {
_p=["..\Campaigns\", _cmpgs select _j, "\missions\", missionName, ".", getWorld];
_f = (_p call _il) select 4;
if (0!=count _f) then {_cmp=_cmpgs select _j; _j=_c};
  };
};
CMPNAME = _cmp;

comment{Path to the mission config 4 ":class token" command};
if (_cmp!="")then{
_path="..\Campaigns\"+ _cmp + "\missions\";
_path=_path + missionName + "." + getWorld + "\mission.sqm";
}else{
_path="mission.sqm";
};
MNPATH = _path;

comment{Safe wrapper for "... :class token ..." request};
 _token={
private ["_t", "_r"];
if (_this in [_this]) then{_t=[_this]}else{_t=+_this};
_r=["class token ", """", "f:", _path, """", " "];
{_r=_r+[format["%1",_x]]} forEach _t;
call(_r call preprocessFile {..\fwatch\data\ExecCommand.sqf})
};

comment{Get weather info as a 4-element vector:
[start cast, start fog, forecast weather, forecast fog]};
private["_w", "_i"];
_w=[];

_a ="c:[Mission,Intel]" call _token;
A=+_a;

_i= (_a select 6) find "startWeather";
if (_i<0)then {_w set[0, 0.5]}else{_w set[0,call((_a select 7)select _i)]};
_i= (_a select 6) find "startFog";
if (_i<0)then {_w set[1, 0]}else{_w set[1,call((_a select 7)select _i)]};
_i= (_a select 6) find "forecastWeather";
if (_i<0)then {_w set[2, 0.5]}else{_w set[2,call((_a select 7)select _i)]};
_i= (_a select 6) find "forecastFog";
if (_i<0)then {_w set[3, 0]}else{_w set[3,call((_a select 7)select _i)]};
WTR = _w;

comment{Get array of all groups on the map};
private["_g","_sh","_n","_v","_o","_m"];
_g=[];
_a="c:[Mission,Groups]" call _token;
_sh=call (_a select 5);
_N=call((_a select 7)select 0);
_i=-1;while{_i=_i+1;_i<_N}do
{
_j=-1;
_M=(["c:[Mission,Groups,Item", _i, ",Vehicles"] call _token) select 7;
_M=call(_M select 0);
while{_j=_j+1;_j<_M}do
{
_a=["c:[Mission,Groups,Item", _i, ",Vehicles,Item", _j, "] ", _sh] call _token;
_sh=call (_a select 5);
_p=(_a select 7) select ((_a select 6) find "position[]");
_v=(_a select 7) select ((_a select 6) find "vehicle");
_o=nearestObject [[call (_p select 0),call (_p select 2)], call _v];
if (! isNull _o)then{_g=_g+[group _o];_j=_M;};
};
};
GRP = _g;

comment{Get array of all empty vehicles on the map};
private["_e"];
_e=[];
_a="c:[Mission,Vehicles]" call _token;
_sh=call (_a select 5);
_N=call((_a select 7)select 0);
_i=-1;while{_i=_i+1;_i<_N}do
{
_a=["c:[Mission,Vehicles,Item", _i, "] ", _sh] call _token;
_sh=call (_a select 5);
_p=(_a select 7) select ((_a select 6) find "position[]");
_v=(_a select 7) select ((_a select 6) find "vehicle");
_e=_e+[nearestObject [[call (_p select 0),call (_p select 2)], call _v]];
};
EV=_e;

comment{Get array of all mission triggers};
private["_t"];
_t=[];
_a = "c:[Mission,Sensors]" call _token;
_sh=call (_a select 5);
_N=call((_a select 7)select 0);
_i=-1;while{_i=_i+1;_i<_N}do
{
_a=["c:[Mission,Sensors,Item", _i, "] ", _sh] call _token;
_sh=call (_a select 5);
_p=(_a select 7) select ((_a select 6) find "position[]");
_t=_t+[nearestObject [[call (_p select 0),call (_p select 2)], "EmptyDetector"]];
};
TRG=_t;

comment{Array of all mission markers};
_m=[];
_a="c:[Mission,Markers]" call _token;
_sh=call (_a select 5);
_N=call((_a select 7)select 0);
_i=-1;while{_i=_i+1;_i<_N}do
{
_a=["c:[Mission,Markers,Item", _i, "] ", _sh] call _token;
_sh=call (_a select 5);
_m=_m+[call ((_a select 7) select ((_a select 6) find "name"))];
};
MRK=_m;

test={
comment{
Expression tester.
Expression ==> big string ==> OFP crash(
Expression ==> array ==> show first 20 elements
 };
private ["_r","_m","_i","_c","_c0"];
_r=call _this;
_cut=false;
if (_r in [_r]) then
{
_m=format["%1", _r];
if (_m in["<null>","[<null>]"])then
{hintC _this} else
{hintC format["%1\n=========================\n%2",_this,_m]};
}
else
{
_c=count _r;
_c0=_c;
if (20 < _c)then{
    _cut=true;
_r resize 20;
};
_c=(count _r)-1;
_m="[\n";
_i=-1;
while{_i=_i+1;_i<_c}do
{
_m=_m+format[" %1\n",_r select _i];
};
_m=_m+format[" %1\n",_r select _i];
if (_c0>20) then {_m=_m+ format[" ...\n]\n( %1 elements )",_c0]}else{_m=_m+"]"};
hintC format["%1\n=========================\n%2",_this,_m];
};
};

--- End code ---

--MODIFIED--
2 errors fixed: error in f_getAllMarkers and another one in f_getAllEmpty.

Note: f_getWeather, f_getAllEmpty and  f_getAllGroups must be called on mission start, otherwise
you can get wrong data. Then called, they should send the resulting array to some
monitoring script, so you can check weather, groups and vehicles at every moment.

--MODIFIED 2--
Works in unpacked campaigns now, example attached.

--MODIFIED 3--
Don't crash OFP if some s...trange thing happens.
Works with long paths.
No "use me once" functions.

--MODIFIED 4--
Fixed problem with spaces in campaign/campaign mission name.



Lone~Wolf:
Brilliant stuff as usual. Now all I need is time, which I might have some of in a few months.

faguss:
You have syntax error in function f_getAllEmpty (unnecessary semi-colon in the line with nearestObject) and you might want to use additional call in f_getAllMarkers (_m=_m+[call (...)]).

===

Keep in mind that the command works with unpacked / unrapified / unbinarized files so I think the use is rather limited. 1.14 will be able to unpack PBO so that may help a bit.

I wrote "class" commands specifically for the Config Editor (still unfinished) so that's why they wrap data around quotes.


--- Code: ---cost=10
--- End code ---
becomes
--- Code: ---["cost"],["10"]
--- End code ---

Later I realized that the command can be used for other things so 1.14 features option to disable stringification and hence save time.

These commands also enable prospect of a 3D Mission Editor but I don't know if I'll ever get around to create that.

SoldierEPilot:
@Faguss,
is it possible somehow to implement ":class" commands 4 unpacked campaign?
I've tried the same things like with editor mission, it doesn't work.
Should I use some path or just wait 4 FW114 ???

faguss:
You can access root dir like you would in standard OFP scripting (more info here). Target file must be plain text.


--- Code: ---f:..\Campaigns\1985\missions\00training.abel\mission.sqm
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version