Jump to content
Sign in to follow this  
-Flo-

objectmapper

Recommended Posts

hi guys,

i've readed tons of postings, but i cant found a answer yet... plz excuse my english, i hope i can describe all of my problems exactly...

i want to use the objectmapper with additional variables, i.e. "name object". i have found a expansion of the original objectmapper.sqf, that will do that the objects can now be named. it will works fine, but the only solution is a readout over a trigger or the global initialisation with the init.sqf.

objectmapper.sqf

/*
Original Script
objectMapper.sqf Author: Joris-Jan van 't Land

     * Edited by armatec
     * slightly edited by Onkel Bo

  Description:
  Takes an array of data about a dynamic object template and creates the objects.

  Parameter(s):
  _this select 0: compositions name - "fuelDepot_us"
  _this select 1: Direction in degrees - Number
  _this select 2: Location to start

  Exsample:
  ["fuelDepot_us", 0, getpos player] execVM "Createcomposition.sqf";
*/
_script = _this select 0;
_azi    = _this select 1;
_pos    = _this select 2;
_objs = [];
_objs = call (compile (preprocessFileLineNumbers format ["camp%1.sqf",_script]));
private ["_posX", "_posY"];
_posX = _pos select 0;
_posY = _pos select 1;
_newObjs = [];
private ["_multiplyMatrixFunc"];
_multiplyMatrixFunc =
{
  private ["_array1", "_array2", "_result"];
  _array1 = _this select 0;
  _array2 = _this select 1;
  _result =
  [
  (((_array1 select 0) select 0) * (_array2 select 0)) + (((_array1 select 0) select 1) * (_array2 select 1)),
  (((_array1 select 1) select 0) * (_array2 select 0)) + (((_array1 select 1) select 1) * (_array2 select 1))
  ];
  _result
};
for "_i" from 0 to ((count _objs) - 1) do
{
     private ["_obj", "_type", "_relPos", "_azimuth", "_fuel", "_damage","_vehicleinit","_newObj","_name","_action"];
     _obj = _objs select _i;
     _type = _obj select 0;
     _relPos = _obj select 1;
     _azimuth = _obj select 2;
     if ((count _obj) > 3) then {_fuel = _obj select 3;};
     if ((count _obj) > 4) then {_damage = _obj select 4;};
     [color="Red"]if ((count _obj) > 5) then {_name = _obj select 5;};[/color]


     private ["_rotMatrix", "_newRelPos", "_newPos"];
     _rotMatrix =[[cos _azi, sin _azi],[-(sin _azi), cos _azi]];
     _newRelPos = [_rotMatrix, _relPos] call _multiplyMatrixFunc;
     private ["_z"];
     if ((count _relPos) > 2) then {_z = _relPos select 2} else {_z = 0};
     _newPos = [_posX + (_newRelPos select 0), _posY + (_newRelPos select 1), _z];
     _newObj = _type createVehiclelocal _newPos;
     _newObj setDir (_azi + _azimuth);
     _newObj setPos _newPos;

     if (!isNil "_fuel") then {_newObj setFuel _fuel};
     if (!isNil "_damage") then {_newObj setDamage _damage};
[color="Red"]      if (!isNil "_name") then {_newObj setVehicleVarName _name; _newObj Call Compile Format ["%1=_this ; PublicVariable ""%1""",_name]};[/color]

};

     _newObjs = _newObjs + [_newObj];

with this array it is possible to define a object inside a composition, i.e. (scroll right):

private ["_objs"];
_objs =
[
  ["Land_fortified_nest_small",[1.77271, -1.71191, 7.62939e-006], 263.392, 1, 0,[color="Red"]"NameObject"[/color]],
  ["UAZWreck",[1.18115,4.91626,3.24249e-005],139.163,1,0],
  ["Fort_Barricade",[-1.40137,-5.26758,5.72205e-006],350.09,1,0],
  ["UralWreck",[-6.27734,2.63623,3.8147e-005],53.5895,1,0],
  ["hiluxWreck",[-8.89136,-4.50879,1.52588e-005],338.377,1,0]
];

now i try to used it inside scripts (i want spawn compositions from mission to mission, and not trough a trigger or global init), but it won't work...

i try this:

_pos = getpos t1;
_handle = ["camp1", 75, (_pos)] execVM "objectmapper.sqf";
true

could anyone help me ? thx...

Edited by -Flo-

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×