Forum Jump :

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#1 Posted at 2016-11-11 02:52        
     
I am trying to write a script to clean up some of the messier parts on Altis. The script I am using is posted below. The buildings work fine (First 4 if statements), however the wall part (5th if statement) does not work. My intention is to replace the broken buildings and walls with intact ones. If I manually place a wall in the editor, it will detect that, however it will not detect a wall that is normally on Altis. How can I get my script to detect if it is a wall or not? Further, is there a way to detect that it is of type "A3_Structures_F_Walls"?

{
    if((typeOf _x) find "ruins" != -1)then{
        _new = ((((typeOf _x) splitString "_") - ["ruins"] ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "Land_u" != -1)then{
		_ary = ((typeOf _x) splitString "_");
		_ary set[1,"i"];
        _new = (( _ary ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "Land_d" != -1)then{
		_ary = ((typeOf _x) splitString "_");
		_ary set[1,"i"];
        _new = (( _ary ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "_dam" != -1)then{
        _new = ((((typeOf _x) splitString "_") - ["dam"] ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x;
		hideObjectGlobal _x;
		_x = _new;
    };
	//TODO: Get walls replacing properly
	if((typeOf _x) find "D_F" != -1)then{
		hint "wall";
		_new = (((typeOf _x) select [0,count(toArray(typeOf _x)) - 3]) + "_F") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x;
		hideObjectGlobal _x;
		_x = _new;
    };
	//TODO: Get garages replacing properly
	//TODO: Remove trash
    
} forEach (nearestObjects[_this select 0,[],_this select 1]);

Please forgive the TODO comments. If I was unclear about anything or you need more information let me know.

*Edit* The parameters in the foreach are the location and range respectively. The script is syntactically correct and gives no errors. */Edit*


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2016-11-11 11:55        
     
Did you give nearestTerrainObjects a try?

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#3 Posted at 2016-11-11 12:59        
     
I just tried that. It did not work. It is odd because when I use nearestObjects and do not filter by class name, it removes all the walls (as well as every other object within that radius. Any other suggestions?


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#4 Posted at 2016-11-11 13:01        
     
# jshear95 : I just tried that. It did not work. It is odd because when I use nearestObjects and do not filter by class name, it removes all the walls (as well as every other object within that radius. Any other suggestions?

Use it without a filter and then look at the array yourself to see what class walls are.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#5 Posted at 2016-11-11 13:23        
     
Ok. Figured it out. typeOf _x returned an empty string for a lot of pre existing objects. You actually need to use _x and filter by that for most objects. I posted this issue on the feedback tracker(https://feedback.bistudio.com/T121211).


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#6 Posted at 2016-11-11 17:41        
     
I think it's a choice like the abandon of objects' ids menu.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#7 Posted at 2016-11-12 04:07        
     
I do not think so. The developers abandoned the IDs in favor of this method. When you get nearest objects, it returns something like this:
[01234567: test_object.p3d]
The number I am pretty sure is the ID and the test_object.p3d is the model name. My guess is typeOf goes through the ID to get the class name when they should be mapping it through the model. The issue probably cropped up when BI abandoned the IDs. I imagine there is an easy way to map models to class names with SQL or something in Real Virtuality.
FROM configs SELECT className WHERE configs.model == model
Something like that. My SQL is pretty rusty.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#8 Posted at 2016-11-12 04:46        
     
Yes, this is odd. You can detect these walls with nearestTerrainObjects but there is no "typeOf" class detected for them. cursorObject works on them but typeOf cursorObject returns "".

On the other hand, some commands are working and these walls are not really destroyed, just lying on ground with a damage to 1. You can easily straighten them by this code:
{_x setDamage 0} foreach (nearestTerrainObjects [player, ["wall"], 50]);

Hope this help.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#9 Posted at 2016-11-12 15:05        
     
Thanks for the tip Pierre! And thank you for your help as well Wak! I did ultimately get the script working, its a bit hacky but it accomplishes what I need for the mission. In the two areas I am using them (in the comments at the bottom of the script (housing development listed above and the entirety of Pyrgos)).

{
    if((typeOf _x) find "ruins" != -1)then{
        _new = ((((typeOf _x) splitString "_") - ["ruins"] ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "Land_u" != -1)then{
		_ary = ((typeOf _x) splitString "_");
		_ary set[1,"i"];
        _new = (( _ary ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "Land_d" != -1)then{
		_ary = ((typeOf _x) splitString "_");
		_ary set[1,"i"];
        _new = (( _ary ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x; 
		hideObjectGlobal _x;
		_x = _new;
    };
	if((typeOf _x) find "_dam" != -1)then{
        _new = ((((typeOf _x) splitString "_") - ["dam"] ) joinString "_") createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x;
		hideObjectGlobal _x;
		_x = _new;
    };
	if(str(_x) find "d_f.p3d" != -1)then{
		_name = str(_x);
		_name = (_name splitString " .") select 1;
		_name = "Land_C" + _name;
		_name = (_name splitString "c") joinString "";
		_name = ((_name select [0,count(toArray(_name)) - 3]) + "_F");
		_new =  _name createVehicle position _x;
        _new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		_new setPosASL (getPosASL _x);
        deleteVehicle _x;
		hideObjectGlobal _x;
		_x = _new;
    };
	if(str(_x) find "garbage" != -1 or str(_x) find "wreck" != -1)then{
		deleteVehicle _x;
		hideObjectGlobal _x;
	};
} forEach (nearestObjects[_this select 0,[],_this select 1]);
/*
Housing Development south of SG
[[15990.6,16268.2,0],500]execVM "buildingRestore.sqf";
Pyrgos
[[16934.8,12790.4,0],2000]execVM "buildingRestore.sqf";
 */

I noticed in your script Pierre, that you listed "wall" as the second parameter for nearestTerrainObjects, where did you find the classes that go in there? "wall" is not in configs if I recall correctly.

This post was edited by jshear95 (2016-11-12 15:18, 340 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#10 Posted at 2016-11-12 16:43        
     
Hi Joshua, this parameter is allowed by the nearestTerrainObjects command, like tree, fence, fuelStation...
The odd thing is there is not always returned class. For example:
(nearestTerrainObjects [player, ["wall"], 50]) apply {typeOf _x} will return something like:
["","","","","","","","","","","","","","",""]

but the code I wrote with setdamage 0 works on them. Same for "tree".
It's harder for "house". On Altis, (I didn't test everywhere), houses return classes and they can be destroyed. They become a kind of "ruins" (with an s), not detected neither by "house" nor by "ruin". nearestTerrainObjects doesn't work on them.
By the way: (typeOf _x) find "ruins" != -1 can be replaced by (_x isKindOf "ruins")

On the other hand, on Tanoa, when house are destroyed, they collapse as ruin or they are damaged (impacts, broken glasses). Never mind. In all cases, nearTerrainObjects can fix them!


Despite these "inconsistencies" between worlds, this command remains efficient for the walls, trees, and all objects with poor damage model.

This post was edited by Pierre MGI (2016-11-12 16:54, 340 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#11 Posted at 2016-11-12 17:04        
     
Thanks Pierre!


Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#12 Posted at 2016-11-14 13:10        
     
Sorry to reboot the thread but I am trying to replace createVehicle in that script with createSimpleObject.

I cannot for the life of me get createSimpleObject to work properly. On the biki (https://community.bistudio.com/wiki/createSimpleObject) it says that it works with class names. After hours of testing it does not work with any class name I give it. I found an article on the forums (https://forums.bistudio.com/topic/187670-new-command-createobject-for-decorative-objects/page-4#entry2979711) where a guy (opec666) made a script to extract the model file from the class name. I can get it to print the model name but when I try to do anything with it the model name, either the variable is lost (Arma says it does not exist) or it evaluates to "String".

Where am I messing up? Below is my modified code. I am using _data as a way to try and export the model names and just use a separate script (not written yet) for spawning in and hiding the objects. If can make it work all in one script that would be great though!

opec_strRight = {
	_arr = _this splitString "";
	_out = [];
	for "_i" from 1 to ( ( count _arr ) - 1 ) do {
		_out = _out + [ ( _arr select _i ) ];
	};
	_out joinString ""
};

_data = [];

{
	if(str(_x) find "d_f.p3d" != -1)then{
		_name = str(_x);
		_name = (_name splitString " .") select 1;
		_name = "Land_C" + _name;
		_name = (_name splitString "c") joinString "";
		_name = ((_name select [0,count(toArray(_name)) - 3]) + "_F");
		//_new = createSimpleObject[_name,[0,0,0]];
		
		_modelPath = ( configFile >> "CfgVehicles" >> _name >> "model" ) call BIS_fnc_GetCfgData;
		_fixModelPath = _modelPath call opec_strRight;
		hint str(_fixModelPath);
		//_new = createSimpleObject[ _fixModelPath, (getPosASL _x) ];
		
		_data pushBack [str(_fixModelPath),getPosASL _x, vectorDir _x, vectorUp _x];
		
        //_new setVectorDirAndUp [(vectorDir _x),(vectorUp _x)];
		//_new setPosASL (getPosASL _x);
		//hideObjectGlobal _x;
		//_x = _new;
    };
	if(str(_x) find "garbage" != -1 or str(_x) find "wreck" != -1)then{
		hideObjectGlobal _x;
	};
} forEach (nearestObjects[_this select 0,[],_this select 1]);

copyToClipboard str(_data);
hint "DONE";


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#13 Posted at 2016-11-14 17:50        
     
I don't know what you intend to do because simple Objects are made to be decorative with no animation on them, FPS saving.

If you want to create them easily, try the new feature (check box) in editor. You can detect them with cursorObject and deleteVehicle cursorObject, but that's all (no class, no animation like doors or ladders or glasses, no damage then).

On the other hand, if you use the function BIS_fnc_createSimpleObject, you can add the BIS_fnc_adjustSimpleObject and adjust the class name, or what you need on this object.

I let you test.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#14 Posted at 2016-11-14 19:20        
     
# Pierre MGI : I don't know what you intend to do because simple Objects are made to be decorative with no animation on them, FPS saving.

If you want to create them easily, try the new feature (check box) in editor. You can detect them with cursorObject and deleteVehicle cursorObject, but that's all (no class, no animation like doors or ladders or glasses, no damage then).

On the other hand, if you use the function BIS_fnc_createSimpleObject, you can add the BIS_fnc_adjustSimpleObject and adjust the class name, or what you need on this object.

I let you test.
Check the wiki, simple objects support animations. They support everything default map objects support.

@jshear95 have you tried the getModelInfo command to get model paths?

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#15 Posted at 2016-11-15 03:43        
     
That worked! I did not realize there was a scripting command to do that. Thanks Wak.

Pierre, I want to use simple objects because they are just walls and buildings that the player sees but cannot interact with. The player is in a convoy (the same convoy you helped me with in http://www.armaholic.com/forums.php?m=posts&p=188279#188279) and can see the stuff but cannot interact with them. I want to make that part of Altis look less war torn and simple objects take up the least amount of frames.

Thank you for suggesting BIS_fnc_adjustSimpleObject and BIS_fnc_createSimpleObject, I will look into it when I start to spawn more complex stuff.