Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add : change select floor random count for selectRandom #103

Merged
merged 2 commits into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ if (count _houses == 0) then {
[] call btc_fnc_cache_find_pos;
} else {
//private ["_isAct","_cache"];
_house = _houses select (floor random count _houses);
_house = selectRandom _houses;
_house spawn btc_fnc_cache_spawn;
};
4 changes: 2 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/civ/addWP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _wp setWaypointBehaviour "SAFE";
_houses = [_pos,_radius] call btc_fnc_getHouses;
if (count _houses > 0) then {
private ["_house","_n_pos"];
_house = _houses select (floor random count _houses);
_house = selectRandom _houses;

_n_pos = 0;
while {format ["%1", _house buildingPos _n_pos] != "[0,0,0]" } do {
Expand All @@ -41,7 +41,7 @@ for "_i" from 1 to 4 do {

if (count _houses > 0) then {
private ["_house","_n_pos"];
_house = _houses select (floor random count _houses);
_house = selectRandom _houses;

_n_pos = 0;
while {format ["%1", _house buildingPos _n_pos] != "[0,0,0]" } do {
Expand Down
2 changes: 1 addition & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/civ/create.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ switch (typeName _city) do

_rpos = [_pos, _area] call btc_fnc_randomize_pos;

_unit_type = btc_civ_type_units select (floor random count btc_civ_type_units);
_unit_type = selectRandom btc_civ_type_units;

_group = createGroup civilian;
_group createUnit [_unit_type, _rpos, [], 0, "NONE"];
Expand Down
8 changes: 4 additions & 4 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/civ/populate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ for "_i" from 0 to _n do
{
private ["_house","_unit_type"];
if (count _houses == 0) exitWith {};
_house = _houses select (floor random count _houses);
_unit_type = btc_civ_type_units select (floor random count btc_civ_type_units);
_house = selectRandom _houses;

_unit_type = selectRandom btc_civ_type_units;

_group = createGroup civilian;
_group createUnit [_unit_type, getPos _house, [], 0, "NONE"];
_group spawn btc_fnc_civ_addWP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _cities = [];
};} foreach btc_city_all;
_pos = [];
if (count _cities == 0) then {_pos = getPos _city;} else {
_pos = getPos (_cities select (floor random count _cities));
_pos = getPos (selectRandom _cities);
};

private ["_wp","_wp_1"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ if (count _useful == 0) then {
};
};

_pos = _useful select (floor random count _useful);
_pos = selectRandom _useful;

_unit_type = btc_civ_type_units select (floor random count btc_civ_type_units);
_veh_type = btc_civ_type_veh select (floor (random (count btc_civ_type_veh)));
_unit_type = selectRandom btc_civ_type_units;
_veh_type = selectRandom btc_civ_type_veh;

_group = createGroup civilian;
_group setVariable ["no_cache",true];
Expand All @@ -41,10 +41,10 @@ if (count (_pos nearRoads 100) > 0) then {

if (surfaceIsWater _Spos) then {
_Spos = [_Spos select 0, _Spos select 1,0];
_veh_type = btc_civ_type_boats select (floor (random (count btc_civ_type_boats)));
_veh_type = selectRandom btc_civ_type_boats;
_iswater = true;
} else {
_veh_type = btc_civ_type_veh select (floor (random (count btc_civ_type_veh)));
_veh_type = selectRandom btc_civ_type_veh;
_iswater = false;
};

Expand Down
16 changes: 8 additions & 8 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/ied/init_area.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ for "_i" from 1 to _n do {
private ["_sel_pos","_type_ied","_dir"];
_sel_pos = _pos;
_sel_pos = [_pos, _area] call btc_fnc_randomize_pos;
_sel_pos = [_sel_pos, 30, 150, 1, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;
_sel_pos = [_sel_pos, 30, 150, 1, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;

_type_ied = selectRandom btc_type_ieds;

_type_ied = btc_type_ieds select (floor random count btc_type_ieds);

_dir = (random 360);

if (random 1 > 0.3) then {
private ["_roads","_obj"];
_roads = _sel_pos nearRoads _area;
if (count _roads > 0) then {
_obj = _roads select (floor random count _roads);
_obj = selectRandom _roads;
if (random 1 > 0.5) then {_sel_pos = _obj modelToWorld [3.5,0,0];} else {_sel_pos = _obj modelToWorld [-3.5,0,0];};
};
} else {
Expand Down Expand Up @@ -62,17 +62,17 @@ for "_i" from 1 to _n do {
private ["_sel_pos","_type_ied","_dir"];
_sel_pos = _pos;
_sel_pos = [_pos, _area] call btc_fnc_randomize_pos;
_sel_pos = [_sel_pos, 30, 150, 1, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;
_sel_pos = [_sel_pos, 30, 150, 1, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;

_type_ied = selectRandom btc_type_ieds;

_type_ied = btc_type_ieds select (floor random count btc_type_ieds);

_dir = (random 360);

if (random 1 > 0.3) then {
private ["_roads","_obj","_ied_pos"];
_roads = _sel_pos nearRoads _area;
if (count _roads > 0) then {
_obj = _roads select (floor random count _roads);
_obj = selectRandom _roads;
if (random 1 > 0.5) then {_sel_pos = _obj modelToWorld [3,0,0];} else {_sel_pos = _obj modelToWorld [-3,0,0];};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ switch (typeName _city) do

_rpos = [_pos, _area] call btc_fnc_randomize_pos;

_unit_type = btc_civ_type_units select (floor random count btc_civ_type_units);
_unit_type = selectRandom btc_civ_type_units;

_group = createGroup civilian;
_group createUnit [_unit_type, _rpos, [], 0, "NONE"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private ["_ho","_pos","_marker","_array"];
_ho = btc_hq getVariable ["info_hideout",objNull];

if (isNull _ho) then {
_ho = btc_hideouts select (floor random count btc_hideouts);
_ho = selectRandom btc_hideouts;
btc_hq setVariable ["info_hideout",_ho];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ switch _is_real do {
[[1,[],player],"btc_fnc_int_ask_var",false] spawn BIS_fnc_MP;

waitUntil {!(isNil "btc_int_ask_data")};

if (!isNull btc_int_ask_data) then {
private ["_hideout","_dist","_dir","_card"];
_hideout = btc_int_ask_data;
Expand All @@ -26,7 +26,7 @@ switch _is_real do {
if ((random 1) > 0.5) then {
private ["_array","_dist","_dir"];
_array = ["N","E","W","S","NW","NE","SE","SW"];
_dir = _array select (floor (random (count _array)));
_dir = selectRandom _array;
_dist = 300 + (random 2000);
_text = format ["%1: I saw a lot of militia activity towards %2, %3 meter from here. Probably there is an hideout!", _name,_dir,round _dist];
} else {
Expand Down
4 changes: 2 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/info/troops.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

selectRandom
private ["_name","_is_real","_text"];

_name = _this select 0;
Expand Down Expand Up @@ -26,7 +26,7 @@ switch _is_real do
if ((random 1) > 0.5) then {
private ["_array","_dist","_dir"];
_array = ["N","E","W","S","NW","NE","SE","SW"];
_dir = _array select (floor (random (count _array)));
_dir = selectRandom _array;
_dist = (500 + (random 1000));
_text = format ["%1: I saw some militia movement %2, %3 meter from here", _name,_dir,round _dist];
} else {
Expand Down
4 changes: 2 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/mil/addWP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ switch (true) do {
_houses = [_city,_area] call btc_fnc_getHouses;
if (count _houses > 0) then {
_in_house = true;
_house = _houses select (floor random count _houses);
_house = selectRandom _houses;
[_group,_house] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse",_house];
} else {[_group,_rpos,_area,"SAFE"] call btc_fnc_task_patrol;};
Expand All @@ -43,4 +43,4 @@ switch (true) do {
};
};

true
true
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ if (count _this > 0) then {_city = _this;} else {
)
) then {_useful = _useful + [_x];};
} foreach btc_city_all;
_id = floor random count _useful;
_city = _useful select _id;
_city = selectRandom _useful;
};

_pos = [getPos _city, 300] call btc_fnc_randomize_pos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ switch (typeName _city) do {
_rpos = [_pos, _area,true] call btc_fnc_randomize_pos;

if (surfaceIsWater _rpos) then {
_unit_type = btc_type_divers select (floor random count btc_type_divers);
_unit_type = selectRandom btc_type_divers;
_iswater = true;
} else {
_unit_type = btc_type_units select (floor random count btc_type_units);
_unit_type = selectRandom btc_type_units;
_iswater = false;
};

Expand All @@ -35,7 +35,7 @@ switch (true) do {
_houses = [_rpos,50] call btc_fnc_getHouses;
if (count _houses > 0) then {
_in_house = true;
_house = _houses select (floor random count _houses);
_house = selectRandom _houses;
[_group,_house] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse",_house];
} else {[_group,_rpos,_area,"SAFE",_iswater] spawn btc_fnc_task_patrol;};
Expand All @@ -53,7 +53,7 @@ switch (true) do {
};
if (!_in_house) then {
for "_i" from 0 to _n do {
_unit_type = [btc_type_units select (floor random count btc_type_units), btc_type_divers select (floor random count btc_type_divers) ] select _iswater;
_unit_type = [selectRandom btc_type_units, selectRandom btc_type_divers ] select _iswater;
_group createUnit [_unit_type, _rpos, [], 0, "NONE"];
sleep 0.5;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ if (count _this > 0) then {_city = _this;} else {
)
) then {_useful = _useful + [_x];};
} foreach btc_city_all;
_id = floor random count _useful;
_city = _useful select _id;
_city = selectRandom _useful;
};

_radius = (((_city getVariable ["RadiusX",0]) + (_city getVariable ["RadiusY",0]))/2) - 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ private ["_pos","_type","_dir","_static","_group","_unit_type","_gunner"];
_pos = _this select 0;
_type = _this select 1;
_dir = 0; if (count _this > 2) then {_dir = _this select 2;};
if (typeName _type == "ARRAY") then {_type = _type select (floor random count _type);};
if (typeName _type == "ARRAY") then {_type = selectRandom _type;};

_static = _type createVehicle _pos;
_static setDir _dir;
_static setpos _pos;

_group = createGroup btc_enemy_side;
_unit_type = btc_type_units select (floor (random (count btc_type_units)));
_unit_type = selectRandom btc_type_units;
_gunner = _group createUnit [_unit_type, _pos, [], 0, "NONE"];
_gunner moveInGunner _static;
_gunner setBehaviour "COMBAT";
_gunner setCombatMode "RED";

_gunner call btc_fnc_mil_unit_create;

if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_static: _this = %1 ; POS %2 _type %3",_this,_pos,_type];};
if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_static: _this = %1 ; POS %2 _type %3",_this,_pos,_type];};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _cities = [];
};} foreach btc_city_all;
_pos = [];
if (count _cities == 0) then {_pos = getPos _city;} else {
_pos = getPos (_cities select (floor random count _cities));
_pos = getPos (selectRandom _cities);
};

private ["_wp","_wp_1"];
Expand Down
10 changes: 5 additions & 5 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/mil/patrol_create.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (count _useful == 0) then {

if (count _useful == 0) exitWith {true};

_pos = _useful select (floor random count _useful);
_pos = selectRandom _useful;

_group = createGroup btc_enemy_side;
_group setVariable ["city",_city];
Expand All @@ -54,7 +54,7 @@ switch (true) do {
_group createUnit [(btc_type_units select 0), _pos, [], 0, "NONE"];(leader _group) setpos _pos;
for "_i" from 1 to _n_units do {
private ["_unit_type"];
_unit_type = btc_type_units select (floor random count btc_type_units);
_unit_type = selectRandom btc_type_units;
_group createUnit [_unit_type, _pos, [], 0, "NONE"];
sleep 1;
};
Expand All @@ -69,10 +69,10 @@ switch (true) do {
_newZone = [_pos, 0, 500, 13, 1, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;
};
if (surfaceIsWater _newZone) then {
_veh_type = btc_type_boats select (floor (random (count btc_type_boats)));
_veh_type = selectRandom btc_type_boats;
_iswater = true;
} else {
_veh_type = btc_type_motorized select (floor (random (count btc_type_motorized)));
_veh_type = selectRandom btc_type_motorized;
_iswater = false;
};
if (_veh_type == "I_SDV_01_F" || _veh_type == "O_SDV_01_F" || _veh_type == "B_SDV_01_F") then {_needdiver = true; _crewmen = btc_type_divers select 0} else {_needdiver = false; _crewmen = btc_type_crewmen};
Expand All @@ -82,7 +82,7 @@ switch (true) do {
_cargo = (_veh emptyPositions "cargo") - 1;
if (_cargo > 0) then {
for "_i" from 0 to _cargo do {
_unit_type = [btc_type_units select (round (random ((count btc_type_units) - 1))), btc_type_divers select (round (random ((count btc_type_divers) - 1)))] select _needdiver ;
_unit_type = [selectRandom btc_type_units, selectRandom btc_type_divers] select _needdiver ;
_unit_type createUnit [_pos, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};
};
Expand Down
10 changes: 5 additions & 5 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/mil/send.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ switch (_this select 2) do {
_group = createGroup btc_enemy_side;
_group setVariable ["no_cache",true];
_veh_type = (_this select 3);
if (_veh_type == "") then {_veh_type = btc_type_motorized select (floor random count btc_type_motorized)};
if (_veh_type == "") then {_veh_type = selectRandom btc_type_motorized};
_return_pos = [_pos, 0, 500, 13, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;
_veh = createVehicle [_veh_type, _return_pos, [], 0, "NONE"];
_gunner = _veh emptyPositions "gunner";
Expand All @@ -36,12 +36,12 @@ switch (_this select 2) do {
if (_commander > 0) then {btc_type_crewmen createUnit [_pos, _group, "this moveinCommander _veh;this assignAsCommander _veh;"];};
for "_i" from 0 to _cargo do {
private "_unit_type";
_unit_type = btc_type_units select (floor random count btc_type_units);
_unit_type = selectRandom btc_type_units;
_unit_type createUnit [_pos, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};

_group selectLeader (driver _veh);

_wp = _group addWaypoint [_dest, 60];
_wp setWaypointType "MOVE";
_wp setWaypointCombatMode "RED";
Expand All @@ -52,7 +52,7 @@ switch (_this select 2) do {
_wp_3 = _group addWaypoint [_dest, 60];
_wp_3 setWaypointType "SENTRY";
_wp setWaypointStatements ["true","(group this) spawn btc_fnc_data_add_group;"];

{_x call btc_fnc_mil_unit_create} foreach units _group;
};
};
Loading