Forum Jump :

Author Message


Posts: 45
Rank:


Level: Member

Country: nl
Location: Den Haag
Occupation: Mars or Pluto?
Age: 25
In-game name: Desperado070

 
#1 Posted at 2016-02-09 09:27        
     
So yea i need some help whit how to fill a house efficient.
I'm working me ass off to build a big custom mission line.
1 of the parts is to clear a town, and of-course for that i want a real challenge.
Whit at-least at every house 1 AI or more, so if you gonna put them in manual you run against the cap very fast!
Can't really remember what the cap was, but i reached it at 20% of filling the town +/-.
It is because arma has a Squad cap, and since every guy has to be in no squad or the placements fuck up.
So yea i didn't had much choice then to start scripting them in whit a trigger and sqf file.
What i did was this:

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;
{_x setPos ((nearestBuilding _x) buildingPos 1);} foreach units _mygroup;

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 2);} foreach units _mygroup;

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 5);} foreach units _mygroup;

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 6);} foreach units _mygroup;

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 0);} foreach units _mygroup;

_mygroup = [getmarkerpos "TestWarrior", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 7);} foreach units _mygroup;


_mygroup1 = [getmarkerpos "TestWarrior_1", EAST, 5] call BIS_fnc_spawnGroup;

_wp1 = _mygroup1 addWaypoint [getmarkerpos "wp1", 0];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "Limited";
_wp1 setWaypointBehaviour "SAFE";

_wp2 = _mygroup1 addWaypoint [getmarkerpos "wp2", 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "Limited";
_wp2 setWaypointBehaviour "SAFE";

_wp3 = _mygroup1 addWaypoint [getmarkerpos "wp3", 0];
_wp3 setWaypointType "CYCLE";
_wp3 setWaypointSpeed "Limited";
_wp3 setWaypointBehaviour "SAFE";


_mygroup1 = [getmarkerpos "TestWarrior_2", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 1);} foreach units _mygroup1;

_mygroup1 = [getmarkerpos "TestWarrior_2", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 3);} foreach units _mygroup1;

_mygroup1 = [getmarkerpos "TestWarrior_2", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 2);} foreach units _mygroup1;


_mygroup2 = [getmarkerpos "TestWarrior_3", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 1);} foreach units _mygroup2;

_mygroup2 = [getmarkerpos "TestWarrior_3", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 4);} foreach units _mygroup2;

_mygroup2 = [getmarkerpos "TestWarrior_3", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 0);} foreach units _mygroup2;


_mygroup3 = [getmarkerpos "TestWarrior_4", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 0);} foreach units _mygroup3;

_mygroup3 = [getmarkerpos "TestWarrior_4", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 3);} foreach units _mygroup3;

_mygroup3 = [getmarkerpos "TestWarrior_4", EAST, ["O_Soldier_SL_F"],[],[],[],[],[],x] call BIS_fnc_spawnGroup;

{_x setPos ((nearestBuilding _x) buildingPos 4);} foreach units _mygroup3;
It does work, and does exactly whatever i want, however...
I need to look up every building way-point manually and even that ain't the problem.
Because looking them up gives you more control over it then placing them randomly. (mine exp whit random = bugs out)

But after i spawned this list, i needed to go make a new sqf to continue?
Did i do something wrong? or is there a cap on how many squads u can spawn per sqf to?

So i was wondering if someone knows a better way of doing this?

I'm not asking to give me a script that works and does everything for me, most likely i won't even be happy whit it.
I'm just asking if someone can point me in the right direction whit this.


Thanks a lot!

P.s. my scripting skills are very basic keep that in mind.

(ofc the script has only 1 soldier, and the same. i know how to randomize this, this just a test)

Do not go where the path may lead, go instead where there is no path and leave a trail...

Author Message


Posts: 1189
Rank:


Level: Member

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

 
#2 Posted at 2016-02-09 10:05        
     
Put your code in a loop instead of writing the same stuff for all groups.

BI Wiki - Loops

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: 45
Rank:


Level: Member

Country: nl
Location: Den Haag
Occupation: Mars or Pluto?
Age: 25
In-game name: Desperado070

 
#3 Posted at 2016-02-09 11:56        
     
omg that is gonna be handy ... =-O

Thanks! *THUMBS UP*

Do not go where the path may lead, go instead where there is no path and leave a trail...

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#4 Posted at 2016-02-09 17:18        
     
Use also random for all you want!
I generally randomize my groups: nbr of units, type of units, even skills (in a slot).
Prepare your group in an array: for "_i" from 1 to whatYouwant do {[] pushback (type of unit randomized)}
then this array in spawnGroup
Same for waypoints: an array, then pick them with arrays_of_waypoints select floor random (count array_of_waypoints).
(a new dev command: selectRandom , will be issued next stable version).

But the main challenge, when filling a town, is that you dramatically drop down FPS with all these units/objects!
So, have on mind a way to spawn /de-spawn units along with player(s) distance(s).

This post was edited by Pierre MGI (2016-02-09 17:34, 674 days ago)

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

Author Message


Posts: 45
Rank:


Level: Member

Country: nl
Location: Den Haag
Occupation: Mars or Pluto?
Age: 25
In-game name: Desperado070

 
#5 Posted at 2016-02-13 16:33        
     
# Pierre MGI : ...

But if you put them all at random, won't you have the problem whit 2 / 3 AI standing in the same place?
Or does it prevent that from happening? because that is the main reason i do it manual right now.

And yes i do now that about the fps ;)

thanks

Do not go where the path may lead, go instead where there is no path and leave a trail...

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-02-13 19:09        
     
AI standing at the same place? With randomized waypoints, this situation doesn't carry on. Sometimes, guts seems to talk then leave on their own paths. don't forget setWaypointTimeOut , another way to randomize the time a civilian stay on a waypoint.

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

Author Message


Posts: 45
Rank:


Level: Member

Country: nl
Location: Den Haag
Occupation: Mars or Pluto?
Age: 25
In-game name: Desperado070

 
#7 Posted at 2016-02-15 14:43        
     
Oh no what i ment was i tried to spawn in a group at random locations in a house.
When a previewed it, they where all standing in the same spot.
I'll might have just screwed that script up, but i though it was because of the randomize.

Could you give me a example line you would use to fill a small building?


{_x setPos ((nearestBuilding _x) buildingPos 7);} foreach units _mygroup;
I though this change would make it random? right?
{_x setPos ((nearestBuilding _x) buildingPos x);} foreach units _mygroup;

Do not go where the path may lead, go instead where there is no path and leave a trail...

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-02-15 16:09        
     
No, you can't use the same "_x scope" for two arrays at the same time (units my_group and building positions).
Try:
{_rooms = [nearestBuilding _x] call BIS_fnc_buildingPositions;
if (count _rooms >0) then {
_x setPos (_rooms select floor random (count _rooms))} else {
_x setpos (nearestBuilding _x)}
} foreach units _mygroup;

This works but 2 remarks:
- Don't let your units in a group. They always return in formation, even if "none" choosen instead of "in formation". I think it's a bug from Arma. Prefer an array of units (not grouped). Units can decide to leave their position, according to their behavior facing a threat (civilians are often fleeing).

- nearest building can be different for these units. So you can populate several buildings with the same script, depending on where nearest building is. That's the reason why I added a "else" for building without room, like some walls in some maps.

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

Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#9 Posted at 2016-02-22 13:56        
     
// nul = [this] execVM "nearestBpos.sqf"
_unit = _this select 0;
_building = nearestBuilding _unit;

_odist = 99999;
_i = 0;
_sel = 0;

while { (_building buildingPos _i) distance [0,0,0] > 0 } do {
	_dist = (_building buildingPos _i) distance _unit;
	if (_dist < _odist) {
		_sel = _i;
		_odist = _dist;
	};
	_i = _i + 1;
};

_unit setPos _building buildingPos _sel;
_unit setUnitPos "UP";

Here is another old snipped that is very easy to use. It doesn't fill a house but it automatically places an object at the nearest available building position.

Though this probably isn't that useful anymore, now that we have 3DEN. ^^

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

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-02-22 17:34        
     
I discovered recently, nearestBuilding doesn't work for edited buildings (all maps) or the embedded houses on Unsung map. I don't know the behavior with the other modded maps.
So, I had to write:

_building = nearestObject [_unit,"house"];
instead of
_building = nearestBuilding _unit;

And this helped by the fact a wall isn't a house but a building, so you don't want to spawn something at every walls!. Small objects like small transmission tower (looking like a pole) remains houses (and buildings of course)...

This post was edited by Pierre MGI (2016-02-22 17:42, 661 days ago)

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

Author Message


Posts: 45
Rank:


Level: Member

Country: nl
Location: Den Haag
Occupation: Mars or Pluto?
Age: 25
In-game name: Desperado070

 
#11 Posted at 2016-02-23 07:50        
     
# Tajin :
// nul = [this] execVM "nearestBpos.sqf"
_unit = _this select 0;
_building = nearestBuilding _unit;

_odist = 99999;
_i = 0;
_sel = 0;

while { (_building buildingPos _i) distance [0,0,0] > 0 } do {
	_dist = (_building buildingPos _i) distance _unit;
	if (_dist < _odist) {
		_sel = _i;
		_odist = _dist;
	};
	_i = _i + 1;
};

_unit setPos _building buildingPos _sel;
_unit setUnitPos "UP";

Here is another old snipped that is very easy to use. It doesn't fill a house but it automatically places an object at the nearest available building position.

Though this probably isn't that useful anymore, now that we have 3DEN. ^^
Oh heck it is, Eden is amazing, hell yes.
But if you really want to make a big mision you need to script them in otherwise you lagging u *ss off. cheers


# Pierre MGI : I discovered recently, nearestBuilding doesn't work for edited buildings (all maps) or the embedded houses on Unsung map. I don't know the behavior with the other modded maps.
So, I had to write:

_building = nearestObject [_unit,"house"];
instead of
_building = nearestBuilding _unit;

And this helped by the fact a wall isn't a house but a building, so you don't want to spawn something at every walls!. Small objects like small transmission tower (looking like a pole) remains houses (and buildings of course)...

This is why it didn't work everywhere...
aiight thankS! :D

Do not go where the path may lead, go instead where there is no path and leave a trail...

Author Message


Posts: 59
Rank:


Level: Member

Country: ca
Location: Quebec
Occupation:
Age:
In-game name:

 
#12 Posted at 2016-02-23 14:42        
     
Here is a modified version of my own script.
It will spawn a random number of units within buildings according to the number of houses in your radius.
Set up a marker, state the radius size, and choose the type of units to spawn.

// FUNCTION: nul = ["marker", radius, "unit type"] execVM "spawnInHouses.sqf";
// EXAMPLE:  nul = ["marker_One", 300, "WEST NATO INFANTRY UNITS"] execVM "spawnInHouses.sqf";
A random number of West NATO infantry soldiers will spawn within enterable buildings found in a 300m radius from "marker_One"

Here is the code for the script (you can modify it to your liking):






Tags: At, Fill, Help, How, Need, Some, To