BomboBombom
Member-
Content Count
38 -
Joined
-
Last visited
-
Medals
Community Reputation
1 NeutralAbout BomboBombom
-
Rank
Private First Class
-
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
@Tonic-_-: Thank you. I found a way to solve the issue. - Quickest way to determine loot tables?: SWITCH _table=_building getVariable "TABLE"; switch (_table) do { case "MIL": { _spots=_building getVariable "SPOTS"; while { _count < _spots } do { the loot table code/function }; }; case "RES": { blablabla.. }; }; - Case would compare swifly due to that it only searches for the compareable string? IF _table=_building getVariable "TABLE"; _spots=_building getVariable "SPOTS"; if (_table=="RES") then { while {_count<_spots} do { that code again }; }; if (_table=="MIL") then { other code stuff.. }; - If may be slower due to that it will compare all cases? Dynamic call. _table=_building getVariable "TABLE"; _spots=_building getVariable "SPOTS"; [_building,_table,_spots] call fnc_lootSpawn; - fnc_lootSpawn would contain either the case or if version of the table spawn script and be preprocessed. # Optimization ideas - setVariable ["SPOTARRAY",(all lootspots variable)]; And then use forEach _SPOTARRAY; to go through the locations after initiation. Even higher optimization in the future could be using preprocessed locations. - Preprocess spots. - Reduce spots used. - Full custom spots preprocess list. (A lot of work) - Avoiding overuse of script for spawning objects. Right now the script uses quite a lot of script to spawn one weaponholder. Would enjoy lowering that. ? Any way to generate a preprocessed location list or function script by using DIAG_LOG(or w/e it was called)? Cheers. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I don't understand why setPos doesn't care about the height that the object is at. When I try using the chicken method for determining floor height it still puts the weaponHolder on the ground. Even after I do setPos after createvehicle. -_-; +++ Solved. /* */ sleep 2; titleText ["View the map to see the markers and types of buildings found.","plain down"]; fnc_getbuildType = compile preprocessFile "fnc_getBuildType.sqf"; sleep 1; //finds buildings closeby _builds = nearestObjects [player,["Building"],500]; _id = 0; _idees = []; for "_i" from 0 to ((count _builds)-1) do { _build = _builds select _i; if (format["%1",_build buildingPos 0]!="[0,0,0]") then { _type = typeOf _build; hint format["Building: %1 Type: %2 Loot: 0",_type,_build]; _count=0; while { format["%1",_build buildingpos _count]!="[0,0,0]" } do { hint format["Building: %1 Type: %2 Loot: %3",_type,_build,(_count+1)]; _gpos=_build buildingPos _count; _cock="Hen" createVehicle _gpos; _cock setPosATL _gpos; _gpos=getPosATL _cock; deleteVehicle _cock; _wph="WeaponHolder" createVehicle _gpos; _wph addWeaponCargo ["M16A2",5]; _wph addMagazineCargo ["30Rnd_556x45_Stanag",10]; _wph setPosATL [_gpos select 0,_gpos select 1,1]; _wph setPosATL [getPos _wph select 0,getPos _wph select 1,(getPosATL _wph select 2)-(getPos _wph select 2)]; _ris=getPosATL _wph select 2; while {_ris<_gpos select 2} do { _ris=_ris+0.01; _wph setPosATL [_gpos select 0,_gpos select 1,_ris-0.005];}; _count=_count+1; }; _typ = [_build] call fnc_getbuildType; _idees set [count _idees,_typ]; hint format ["Type: %1",_typ]; _mrkr = format ["mkr_%1_%2", diag_ticktime,_i]; _m = createMarkerLocal [_mrkr, position _build]; _m setMarkerShape "ICON"; _m setMarkerColorLocal "colorORANGE"; _m setMarkerTypeLocal "mil_dot"; _m setMarkerSizeLocal [1, 1]; //_m setMarkerAlphaLocal 0.2; _m setMarkerTextLocal format ["%1 Name: %2",_typ,_type]; }; sleep 0.01; }; - This is currently experimental. The _ris part will be removed eventually. - Part 2 of tests initiated. Part 2 Will be moving this to a later stage, right now I'm going to rewrite spawn list and such - Adding custom loot location to buildings lacking. @ Figure out how to position objects according to a structures facing angle thus placing objects correctly no matter what direction a structure is facing. # Current buildings lacking buildingPos locations that I require: - Land_A_MunicipalOffice : Has about 6 positions preset. None on roof. - Land_A_Hospital : Has 0 positions preset. None inside, nor on the roof. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I've edited the script provided Twirly, experimenting with how to do a good item spawn system trying to get the weaponholder positioning working properly. I decided to try and move one position up a bit as it was ending up on the staircase and the weaponholder wouldn't angle itself. removed ** updated in next post ** I'm experimenting with loot positions. The code works for one building, but if I angle the building it fails. I'll go back to solving the original positions rather than custom ones. Tomorrow I will continue and keep on track. ;p Thanks again and have a good night/day/afternoon/evening, cheers~ -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
@Shuko: Thanks, I may implement the suggested if needed. Twirly's post seem to contain what is needed. @Twirly: Fantastic Twirly, I am testing the demo mission to see how it works. Thanks :) -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Trying to read typeOf string value and determine building type by "Land_Ind_" in "Land_Ind_Mlyn_02" for example. Then _house setVariable ["Type","IND"]; for industrial buildings. Can not figure out what commands reads a string and I've been looking through comref and searched google some for a method, but found nothing. I do remember seeing some sort of method using forEach, where it would go through each letter of a string. ---------- Post added at 19:14 ---------- Previous post was at 19:07 ---------- Shuko: I use Squint, even after fixing various problems in my old script it didn't work. Couldn't figure why it stopped working. Probably some tweak that messed it up. I gave up and am rewriting it all. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
thank you twirly. That will probably save me quite some time. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Well, oddly enough it remains outputting nothing. using function or sqf, neither one. I wish I knew what broke everything. Unable to find why no matter what _output will never transfer out of the function and into the value. It did work, for a brief period of time. I completely removed the "NIL" as it wont be used in either case. ## Will be attempting to rewrite the whole script and use dynamic search of structures and the locations in the structures. Can't contemplate functions well atm. Current code, for those who are curious: Trigger loop; Trigger 1. Condition: true On act. conditiontime=time; Trigger 2. Condition: conditiontime<time hint format["%1 , %2",conditiontime,time]; if ( format["%1",oo] == "any" ) then { objects=[];oo=thistrigger nearObjects ["building",triggerarea thistrigger select 0]; { if !(format["%1",_x buildingPos 0]=="[0,0,0]") then {objects=objects+[_x]; }; }forEach oo; oo=[]; {if (["MAKELOOT",getPos _x] call fnc_InMarker) then { oo=oo+[_x]; }; }forEach objects;}; if (format["%1",houses]=="any") then { {houses=houses+([_x,houses] call fn_Loota select 1); }forEach oo; } else { {null=[_x] call fnc_Loota;}forEach houses; }; conditiontime=time+(25*1); Trigger 2 is missing a few things. I'll change it and run the "oo" building array through the function instead later. fnc_Loots private ["_building","_loots","_dummy","_spot"]; _building=_this select 0; _loots=[]; _count=0; _dummy=""; _spot=[]; while {format["%1",_house buildingPos _count]!="[0,0,0]} do { _spot=_house buildingPos _count; _dummy="Hen" createVehicle [_spot select 0,_spot select 1,(_spot select 2)+5; sleep 0.5; _spot=getPos _dummy; deleteVehicle _dummy; _loots=_loots+_spot; _count=_count+1; }; _loots fnc_Loota private ["_house","_houses","_search","_locations","_out"]; _house=_this select 0; _houses=_this select 1; _search=typeOf _house; _locations=[]; _out=[]; if !(_search in _hosues) then { _locations=[_house] call fn_Loots; }; _house setVariable ["SPAWNS",_locations]; _out=[_house,_search]; _out The goal with the code is to get an array of the loot locations in all buildings. The original ones do not work like they should. WeaponHolder's in bars end up under ground even when raised above slightly and perfectly placed in other buildings. Spawning these hen's and letting them fall will allow for an location "on" the floor. A lot of tweaks and changes will be needed, but eventually I hope to be able to post a good array of values. One day... Good night (21:52 pm, 15/10/2012) -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
the if(format["%1",_input]=="any") then (_output=[0,"NIL",0];}; is for all buildings I do not have listed, so it is sort of an "else" oh wait... I see my problem there. It should be ["%1",_output]=="any" ,, ~facepalm~ Oh lord, the little things I miss. Thanks :p -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
a call inside of a call can not return a value? I'm asking because inside of the called call, the value output is working but outside it isn't returning anything. _type=[_data] call fn_getLootData; I call it as this. It calls getLootData. //fn_getLootData private["_input","_output"]; _input=_this select 0; _output=[]; //RESIDENTIALS if (_input=="Land_HouseV_1I4") then {_output=[3,"RES",40];}; if (_input=="Land_kulna") then {_output=[2,"RES",40];}; if (_input=="Land_hut06") then {_output=[2,"RES",40];}; if (_input=="Land_Hlidac_budka") then {_output=[3,"RES",40];}; if (_input=="Land_HouseV2_02_Interier") then {_output=[8,"RES",40];}; if (_input=="Land_A_Pub_01") then {_output=[20,"RES",40];}; if (_input=="Land_Shed_wooden") then {_output=[2,"RES",40];}; if (_input=="Land_HouseBlock_A1_1") then {_output=[2,"RES",40];}; if (_input=="Land_HouseV_1I1") then {_output=[1,"RES",40];}; if (_input=="Land_A_MunicipalOffice") then {_output=[14,"RES",40];}; if (_input=="Land_ruin_01") then {_output=[4,"RES",40];}; if (_input=="Land_HouseV2_04_interier") then {_output=[7,"RES",40];}; if (_input=="Land_HouseV2_01A") then {_output=[2,"RES",40];}; if (_input=="Land_psi_bouda") then {_output=[1,"RES",40];}; if (_input=="Land_KBud") then {_output=[1,"RES",40];}; if (_input=="Land_A_Castle_Bergfrit") then {_output=[12,"RES",40];}; if (_input=="Land_A_Castle_Stairs_A") then {_output=[3,"RES",40];}; if (_input=="Land_A_Castle_Gate") then {_output=[5,"RES",40];}; if (_input=="Land_sara_domek_zluty") then {_output=[9,"RES",40];}; //Churches, residential. if (_input=="Land_Church_01") then {_output=[1,"RES",40];}; if (_input=="Land_Church_03") then {_output=[12,"RES",40];}; //OFFICE if (_input=="Land_HouseB_Tenement") then {_output=[5,"OFF",40];}; if (_input=="Land_Panelak") then {_output=[13,"OFF",40];}; if (_input=="Land_Panelak2") then {_output=[12,"OFF",40];}; if (_input=="Land_rail_station_big") then {_output=[9,"OFF",40];}; if (_input=="Land_A_Office01") then {_output=[31,"OFF",40];}; if (_input=="Land_A_Office02") then {_output=[2,"OFF",40];}; //INDUSTRIAL if (_input=="Land_Ind_Workshop01_01") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Garage01") then {_output=[4,"IND",30];}; if (_input=="Land_Ind_Workshop01_02") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Workshop01_04") then {_output=[7,"IND",30];}; if (_input=="Land_Ind_Workshop01_L") then {_output=[7,"IND",30];}; if (_input=="Land_Hangar_2") then {_output=[7,"IND",30];}; if (_input=="Land_A_FuelStation_Build") then {_output=[4,"IND",30];}; if (_input=="Land_Shed_Ind02") then {_output=[5,"IND",30];}; if (_input=="Land_Misc_PowerStation") then {_output=[2,"IND",30];}; if (_input=="Land_Shed_W01") then {_output=[1,"IND",30];}; if (_input=="Land_Tovarna2") then {_output=[23,"IND",30];}; if (_input=="Land_Ind_Vysypka") then {_output=[9,"IND",30];}; if (_input=="Land_A_houseWIP") then {_output=[29,"IND",30];}; if (_input=="Land_A_TVTower_Base") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Ao") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Bo") then {_output=[3,"IND",30];}; if (_input=="Land_Nav_Boathouse") then {_output=[9,"IND",30];}; if (_input=="Land_wagon_box") then {_output=[3,"IND",30];}; if (_input=="Land_Rail_House_01") then {_output=[3,"IND",30];}; //FARM if (_input=="Land_stodola_old_open") then {_output=[12,"FRM",30];}; if (_input=="Land_Farm_Cowshed_a") then {_output=[7,"FRM",30];}; if (_input=="Land_stodola_open") then {_output=[4,"FRM",30];}; if (_input=="Land_Barn_W_01") then {_output=[6,"FRM",30];}; if (_input=="Land_Barn_W_02") then {_output=[6,"FRM",30];}; //SUPERMARKET if (_input=="Land_Rail_House_01") then {_output=[24,"SPM",30];}; if (_input=="Land_Rail_House_01") then {_output=[23,"SPM",30];}; //HOSPITAL if (_input=="Land_A_Hospital") then {_output=[12,"HOS",90];}; if (_input=="USMC_WarfareBFieldhHospital") then {_output=[5,"HOS",40];}; //MILITARY if (_input=="Land_Mil_Guardhouse") then {_output=[2,"MIL",30];}; if (_input=="Land_a_stationhouse") then {_output=[10,"MIL",30];}; if (_input=="Land_Mil_ControlTower") then {_output=[6,"MIL",40];}; if (_input=="Land_SS_hangar") then {_output=[3,"MIL",40];}; if (_input=="Land_Mil_House") then {_output=[3,"MIL",40];}; if (_input=="Land_Misc_deerstand") then {_output=[2,"MIL",50];}; if (_input=="Camp") then {_output=[2,"MIL",40];}; if (_input=="CampEast") then {_output=[2,"MIL",40];}; if (_input=="CampEast_EP1") then {_output=[3,"MIL",40];}; //BARRACK if (_input=="Land_Mil_Barracks_i") then {_output=[12,"BRK",40];}; if (format["%1",_input]=="any") then {_output=[0,"NIL",0];}; _output -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I'm starting to grow one hell of a headache. :p So.. it started working but I do not know why it started working. It worked for a while.. it stopped working again.. I do not know why it stopped working again. I have a function called, inside of the function it can create the output, but outside of the function it can't. //FN_MAKELOOT private["_house"]; _house=_this select 0; _type=[]; _lootData=""; _data=typeOf _house; //Mega scary exploding town. START //sleep ((random 30) + (random 30) + (random 30) + (random 30) + (random 30) + (random 30) + (random 30) + 10); //b="Bo_GBU12_LGB" createVehicle (_house buildingPos (random 1)); //sleep 0.1; //deleteVehicle b; //Mega scary eploding town. END if !(format["%1",_house getVariable "Lootable"] == "<null>") then { _type=_house getVariable "Data"; } ELSE { //Set: Lootable _type=[_data] call fn_getLootData; }; if !(format["%1",_type]=="any") then { hint format["OUTPUT WORKED! %1",_type]; }; //Not <_< if (format["%1",_type]=="any") exitWith{}; switch (_type select 1) do { //RESIDENTIALS case "RES": { null=[_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case "OFF": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case "IND": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case "FRM": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case "HOS": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case "MIL": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case "BRK": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case "CHC": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; //fn_getLootData private["_input"]; _input=_this select 0; //_output=""; //RESIDENTIALS if (_input=="Land_HouseV_1I4") then {_output=[3,"RES",40];}; if (_input=="Land_kulna") then {_output=[2,"RES",40];}; if (_input=="Land_hut06") then {_output=[2,"RES",40];}; if (_input=="Land_Hlidac_budka") then {_output=[3,"RES",40];}; if (_input=="Land_HouseV2_02_Interier") then {_output=[8,"RES",40];}; if (_input=="Land_A_Pub_01") then {_output=[20,"RES",40];}; if (_input=="Land_Shed_wooden") then {_output=[2,"RES",40];}; if (_input=="Land_HouseBlock_A1_1") then {_output=[2,"RES",40];}; if (_input=="Land_HouseV_1I1") then {_output=[1,"RES",40];}; if (_input=="Land_A_MunicipalOffice") then {_output=[14,"RES",40];}; if (_input=="Land_ruin_01") then {_output=[4,"RES",40];}; if (_input=="Land_HouseV2_04_interier") then {_output=[7,"RES",40];}; if (_input=="Land_HouseV2_01A") then {_output=[2,"RES",40];}; if (_input=="Land_psi_bouda") then {_output=[1,"RES",40];}; if (_input=="Land_KBud") then {_output=[1,"RES",40];}; if (_input=="Land_A_Castle_Bergfrit") then {_output=[12,"RES",40];}; if (_input=="Land_A_Castle_Stairs_A") then {_output=[3,"RES",40];}; if (_input=="Land_A_Castle_Gate") then {_output=[5,"RES",40];}; if (_input=="Land_sara_domek_zluty") then {_output=[9,"RES",40];}; //Churches, residential. if (_input=="Land_Church_01") then {_output=[1,"RES",40];}; if (_input=="Land_Church_03") then {_output=[12,"RES",40];}; //OFFICE if (_input=="Land_HouseB_Tenement") then {_output=[5,"OFF",40];}; if (_input=="Land_Panelak") then {_output=[13,"OFF",40];}; if (_input=="Land_Panelak2") then {_output=[12,"OFF",40];}; if (_input=="Land_rail_station_big") then {_output=[9,"OFF",40];}; if (_input=="Land_A_Office01") then {_output=[31,"OFF",40];}; if (_input=="Land_A_Office02") then {_output=[2,"OFF",40];}; //INDUSTRIAL if (_input=="Land_Ind_Workshop01_01") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Garage01") then {_output=[4,"IND",30];}; if (_input=="Land_Ind_Workshop01_02") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Workshop01_04") then {_output=[7,"IND",30];}; if (_input=="Land_Ind_Workshop01_L") then {_output=[7,"IND",30];}; if (_input=="Land_Hangar_2") then {_output=[7,"IND",30];}; if (_input=="Land_A_FuelStation_Build") then {_output=[4,"IND",30];}; if (_input=="Land_Shed_Ind02") then {_output=[5,"IND",30];}; if (_input=="Land_Misc_PowerStation") then {_output=[2,"IND",30];}; if (_input=="Land_Shed_W01") then {_output=[1,"IND",30];}; if (_input=="Land_Tovarna2") then {_output=[23,"IND",30];}; if (_input=="Land_Ind_Vysypka") then {_output=[9,"IND",30];}; if (_input=="Land_A_houseWIP") then {_output=[29,"IND",30];}; if (_input=="Land_A_TVTower_Base") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Ao") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Bo") then {_output=[3,"IND",30];}; if (_input=="Land_Nav_Boathouse") then {_output=[9,"IND",30];}; if (_input=="Land_wagon_box") then {_output=[3,"IND",30];}; if (_input=="Land_Rail_House_01") then {_output=[3,"IND",30];}; //FARM if (_input=="Land_stodola_old_open") then {_output=[12,"FRM",30];}; if (_input=="Land_Farm_Cowshed_a") then {_output=[7,"FRM",30];}; if (_input=="Land_stodola_open") then {_output=[4,"FRM",30];}; if (_input=="Land_Barn_W_01") then {_output=[6,"FRM",30];}; if (_input=="Land_Barn_W_02") then {_output=[6,"FRM",30];}; //SUPERMARKET if (_input=="Land_Rail_House_01") then {_output=[24,"SPM",30];}; if (_input=="Land_Rail_House_01") then {_output=[23,"SPM",30];}; //HOSPITAL if (_input=="Land_A_Hospital") then {_output=[12,"HOS",90];}; if (_input=="USMC_WarfareBFieldhHospital") then {_output=[5,"HOS",40];}; //MILITARY if (_input=="Land_Mil_Guardhouse") then {_output=[2,"MIL",30];}; if (_input=="Land_a_stationhouse") then {_output=[10,"MIL",30];}; if (_input=="Land_Mil_ControlTower") then {_output=[6,"MIL",40];}; if (_input=="Land_SS_hangar") then {_output=[3,"MIL",40];}; if (_input=="Land_Mil_House") then {_output=[3,"MIL",40];}; if (_input=="Land_Misc_deerstand") then {_output=[2,"MIL",50];}; if (_input=="Camp") then {_output=[2,"MIL",40];}; if (_input=="CampEast") then {_output=[2,"MIL",40];}; if (_input=="CampEast_EP1") then {_output=[3,"MIL",40];}; //BARRACK if (_input=="Land_Mil_Barracks_i") then {_output=[12,"BRK",40];}; if (format["%1",_input]=="any") then {_output=[0,"NIL",0];}; //hint format["IN FUNCTION %1",_output]; _output //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private ["_resident","_spots","_chance"]; _resident=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=""; _rchance=0; _cpos=[]; _veh=""; _gunADD=[]; _rnd=0; _npos=[]; //Putguns while {_count < _spots} do { _cpos=_resident buildingPos _count; _rchance=random 100; sleep 0.01; _veh=([_cpos select 0,_cpos select 1,(_cpos select 2)-0.6] nearObjects ["WeaponHolder",1]) select 0; //hint format["%1",_veh]; if (format["%1",_veh] != "<null>") then { clearMagazineCargo _veh; clearWeaponCargo _veh; _wph=_veh; } else { _wph="WeaponHolder" createVehicle _cpos; _wph setPosATL [_cpos select 0,_cpos select 1,(_cpos select 2)-0.6]; }; if ((random 100) < _chance) then { hint "Fail to make one gun!"; } else { //GUNS while { format["%1",_gunADD select 0]=="<null>" } do { if (_rchance < 25) exitWith{ _gunADD = [["M1014","8Rnd_B_Beneli_74Slug"],["LeeEnfield","10x_303"]]; _rnd=(count _gunADD)-1;_gunADD=_gunADD select (random _rnd); }; if (_rchance < 45) exitWith{ _gunADD = [["Colt1911","7Rnd_45ACP_1911"],["revolver_EP1","6Rnd_45ACP"]]; _rnd=(count _gunADD)-1;_gunADD=_gunADD select (random _rnd); }; if (_rchance < 60) exitWith{ _gunADD = ["Makarov","8Rnd_9x18_Makarov"]; }; _rchance=random 100; }; if (format["%1",_gunADD select 0]=="<null>") exitWith{}; //hint format["GUNS %1 , %2",_rnd,_gunADD select 0]; _wph addWeaponCargoGlobal [_gunADD select 0,1]; _wph addMagazineCargoGlobal [_gunAdd select 1,(random 2)+3]; sleep 0.01; }; _wph=""; _veh=""; _gunADD=[]; _count=_count + 1; }; Squint would have saved me quite a few hours if I had it earlier. Wish it tested functions etc without having to start arma up ;p Spent about 12 hours today so far on this script. - Can not call functions in functions? - Why do functions not return the generated output sometimes? - Does all ["_private"] values have to be unique? - I need to regenerate my functionality with a loooooong break. Have a good one! :-) -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
BlackMamb : Thought BIS functions were in there by default. So, this would explain this problem. lol. Oh the head pains, the head pains! Shuko: Long ago loaded it up. Thought either something was wrong or I couldn't stand the interface. The reason I don't remember. It shall replace notepad. Notepad++ plugin is not working on Win7 64. Note: Heard of some method to put item spawns by using objects that can fall for about half a second, delete them and use their relative positions for positions. Also, I'm rewriting the entire positioning method and using setVariable as well as getVariable to get spawn points. Wish it was possible to write text files that I could then use as preprocessfiles instead of having to init all buildings, or building types. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
1. None of the BIS_fnc_# seem to work for me. I've tried executing several scripts different examples for overlay effect text and attempted using one to detect if objects were inside of a trigger area. 2. It seems switches can NOT be executed inside of a condition tree. Trying to do so will NOT return any error message from -showScriptError, thus hard to identify. 3. Code ... well doesn't work well at all. Switch isn't working at all. My function returns null or any even if it is given correct input data. 4. Cut wrist :p I am quite a bit frustrated. Over 20 hours of trying to repair code that returned no errors. Script progress: 1 * Select all buildings within an radius. Works. 2 * Filter out buildings with buildpos 0 as "[0,0,0]" Works. 3 * Check what buildings are inside of "loot" marker. Works. 4 * setVariable "Lootable" to 1 to all buildings that are. Works. 5 * Get number of loot positions from switch function. Not working Script plan: Every 10 minutes script goes through all buildings that have been marked as lootable after initiating script phrase. Each spot found has a chance to have loot depending on the building type, each weapon spawn has a chance set to it too. 40% chance to spawn a weapon at spot A. 80% chance to spawn pistol in spot A, 60% chance to spawn shotgun in spot A, 40% chance to spawn automatic rifle in spot A. Weapon holders are used, these get removed every 10 minutes and new ones are created. Will change this to clear their cargo instead, but for now I only need stuff to work. -_-; Cheers. * Located error after industrial spawn list. Missing a ", no script error prompt about it. :| Works now, but can't see any more. So must afk for a bit :p In either case, there are new errors but they are not too horrible. Error example 1 : Guns are in floor in some buildings, and not in others. <.< -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Trigger (reacts in trigger area and uses marker to make sure objects are not outside of spawn area): objects=[];oo=thistrigger nearObjects ["building",triggerarea thistrigger select 0]; { if !(format["%1",_x buildingPos 0]=="[0,0,0]") then {objects=objects+[_x]}; }forEach oo; {if (["MAKELOOT",getPos _x] call fnc_InMarker) then { [_x] execVM "FN\fn_MakeLoot.sqf"; }; }forEach objects; t=count objects;hint format["Total Objects%1%2","\n",t]; //FN_MAKELOOT private["_house"]; _house=_this select 0; _type=[]; _data=""; //hint format["%1%2","\n",_house]; _data=typeOf _house; if !(format["%1",_house getVariable "Lootable"] == "<null>") then { if !(_house getVariable "Lootable"==1) exitWith{}; hint "2 Lootable"; _type=_house getVariable "Data"; } ELSE { if (format["%1",_house buildingPos 0]=="[0,0,0]") exitWith{_house setVariable ["Lootable",0];}; //Set: Lootable _house setVariable ["Lootable",1]; _house setVariable ["Data",[_type select 0,_type select 1,_type select 2]]; hint "3 Balls!"; switch (_data) do { //RESIDENTIALS case "Land_HouseV_1I4": { _type = [3,"RES",40]; }; case "Land_kulna": { _type = [2,"RES",40]; }; case "Land_hut06": { _type = [2,"RES",40]; }; case "Land_Hlidac_budka": { _type = [3,"RES",40]; }; case "Land_HouseV2_02_Interier": { _type = [8,"RES",40]; }; case "Land_A_Pub_01": { _type = [20,"RES",40]; }; case "Land_Shed_wooden": { _type = [2,"RES",40]; }; case "Land_HouseBlock_A1_1": { _type = [2,"RES",40]; }; case "Land_HouseV_1I1": { _type = [1,"RES",40]; }; case "Land_A_MunicipalOffice": { _type = [14,"RES",40]; }; case "Land_ruin_01": { _type = [4,"RES",40]; }; case "Land_HouseV2_04_interier": { _type = [7,"RES",40]; }; case "Land_HouseV2_01A": { _type = [2,"RES",40]; }; case "Land_psi_bouda": { _type = [1,"RES",40]; }; case "Land_KBud": { _type = [1,"RES",40]; }; case "Land_A_Castle_Bergfrit": { _type = [12,"RES",40]; }; case "Land_A_Castle_Stairs_A": { _type = [3,"RES",40]; }; case "Land_A_Castle_Gate": { _type = [5,"RES",40]; }; case "Land_sara_domek_zluty": { _type = [9,"RES",40]; }; //OFFICE case "Land_HouseB_Tenement": { _type = [5,"OFF",40]; }; case "Land_Panelak": { _type = [13,"OFF",40]; }; case "Land_Panelak2": { _type = [12,"OFF",40]; }; case "Land_rail_station_big": { _type = [9,"OFF",40]; }; case "Land_A_Office01": { _type = [31,"OFF",40]; }; case "Land_A_Office02": { _type = [2,"OFF",40]; }; //INDUSTRIAL case "Land_Ind_Workshop01_01": { _type = [3,"IND",30]; }; case "Land_Ind_Garage01": { _type = [4,"IND",30]; }; case "Land_Ind_Workshop01_02": { _type = [3,"IND",30]; }; case "Land_Ind_Workshop01_04": { _type = [7,"IND",30]; }; case "Land_Ind_Workshop01_L": { _type = [7,"IND",30]; }; case "Land_Hangar_2": { _type = [7,"IND",30]; }; case "Land_A_FuelStation_Build": { _type = [4,"IND",30]; }; case "Land_Shed_Ind02": { _type = [5,"IND",30]; }; case "Land_Misc_PowerStation": { _type = [2,"IND",30]; }; case "Land_Shed_W01": { _type = [1,"IND",30]; }; case "Land_Tovarna2": { _type = [23,"IND",30]; }; case "Land_Ind_Vysypka": { _type = [9,"IND",30]; }; case "Land_A_houseWIP": { _type = [29,"IND",30]; }; case "Land_A_TVTower_Base": { _type = [3,"IND",30]; }; case "Land_Misc_Cargo1Ao": { _type = [3,"IND",30]; }; case "Land_Misc_Cargo1Bo": { _type = [3,"IND",30]; }; case "Land_Nav_Boathouse": { _type = [9,"IND",30]; }; case "Land_wagon_box": { _type = [3,"IND",30]; }; case "Land_Rail_House_01": { _type = [3,"IND",30]; }; //FARM case "Land_stodola_old_open": { _type = [12,FRM",30]; }; case "and_Farm_Cowshed_a": { _type = [7,"FRM",30]; }; case "Land_stodola_open": { _type = [4,"FRM",30]; }; case "Land_Barn_W_01": { _type = [6,"FRM",30]; }; case "Land_Barn_W_02": { _type = [6,"FRM",30]; }; //SUPERMARKET case "Land_Rail_House_01": { _type = [24,"SPM",30]; }; case "Land_Rail_House_01": { _type = [23,"SPM",30]; }; //HOSPITAL case "Land_A_Hospital": { _type = [12,"HOS",90]; }; case "USMC_WarfareBFieldhHospital": { _type = [5,"HOS",40]; }; //MILITARY case "Land_a_stationhouse": { _type = [10,"MIL",30]; }; case "Land_Mil_ControlTower": { _type = [6,"MIL",40]; }; case "Land_SS_hangar": { _type = [3,"MIL",40]; }; case "Land_Mil_House": { _type = [3,"MIL",40]; }; case "Land_Misc_deerstand": { _type = [2,"MIL",50]; }; case "Camp": { _type = [2,"MIL",40]; }; case "CampEast": { _type = [2,"MIL",40]; }; case "CampEast_EP1": { _type = [3,"MIL",40]; }; //BARRACKS case "Land_Mil_Barracks_i": { _type = [12,"BRK",40]; }; //CHURCH case "Land_Church_01": { _type = [1,"CHC",40]; }; case "Land_Church_03": { _type = [12,"CHC",40]; }; default { _type = [0,"NIL",0]; }; }; }; hint format["%1",_type]; switch (_type select 1) do { //RESIDENTIALS case "RES": { hint "Executing residential gun spawn function."; [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case "OFF": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case "IND": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case "FRM": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case "HOS": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case "MIL": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case "BRK": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case "CHC": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; Good night. Starting to pass out, this still doesn't seem to go much further. I've done tons of testing on individual parts of the code and worked out how to use various functions in the script, but together they refuse to work. Like when I pick a building out of an array the script things it is still an array when trying to call the object. etc etc. :| Do not understand why functions no longer run at all pretty much. I assume my func init-file contains errors ;p ~gone for today~ -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I'm tweaking script a lot. May rewrite it :| Found a few errrors that I have fixed. These errors were not announced by showscripterror prefix. -
Function script problems
BomboBombom replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
So, I must use sleep functions or the code wont work? code reports no errors ingame, yet it doesn't execute more than half of the code ... >,> The only part of this code I get executed is hint "Executing makeloot function"; The rest doesn't even bother running. Why I don't know. FN_MAKELOOT //FN_MAKELOOT private ["_building"]; _building = _this; _type=[]; _data=""; //Yeah those are revers :p hint "Executing makeloot function"; if !(_building getVariable "Lootable") exitWith{}; if !(format["%1",_building getVariable "Lootable"] == "<null>") then { if !(_building getVariable "Lootable") exitWith{}; if (_buidling getVariable "Lootable") then { _type = _building getVariable "Data"; }; } else { hint "Else!"; //Set: Not Lootable if (format["%1",_building buildingPos 0]=="[0,0,0]") exitWith{_building setVariable ["Lootable",false];}; //Get building data _data=typeOf _building; switch (_data) do { //RESIDENTIALS case ("Land_HouseV_1I4"): { _type = [3,"RES",40]; }; case ("Land_kulna"): { _type = [2,"RES",40]; }; case ("Land_hut06"): { _type = [2,"RES",40]; }; case ("Land_Hlidac_budka"): { _type = [3,"RES",40]; }; case ("Land_HouseV2_02_Interier"): { _type = [8,"RES",40]; }; case ("Land_A_Pub_01"): { _type = [20,"RES",40]; }; case ("Land_Shed_wooden"): { _type = [2,"RES",40]; }; case ("Land_HouseBlock_A1_1"): { _type = [2,"RES",40]; }; case ("Land_HouseV_1I1"): { _type = [1,"RES",40]; }; case ("Land_A_MunicipalOffice"): { _type = [14,"RES",40]; }; case ("Land_ruin_01"): { _type = [4,"RES",40]; }; case ("Land_HouseV2_04_interier"): { _type = [7,"RES",40]; }; case ("Land_HouseV2_01A"): { _type = [2,"RES",40]; }; case ("Land_psi_bouda"): { _type = [1,"RES",40]; }; case ("Land_KBud"): { _type = [1,"RES",40]; }; case ("Land_A_Castle_Bergfrit"): { _type = [12,"RES",40]; }; case ("Land_A_Castle_Stairs_A"): { _type = [3,"RES",40]; }; case ("Land_A_Castle_Gate"): { _type = [5,"RES",40]; }; case ("Land_sara_domek_zluty"): { _type = [9,"RES",40]; }; //OFFICE case ("Land_HouseB_Tenement"): { _type = [5,"OFF",40]; }; case ("Land_Panelak"): { _type = [13,"OFF",40]; }; case ("Land_Panelak2"): { _type = [12,"OFF",40]; }; case ("Land_rail_station_big"): { _type = [9,"OFF",40]; }; case ("Land_A_Office01"): { _type = [31,"OFF",40]; }; case ("Land_A_Office02"): { _type = [2,"OFF",40]; }; //INDUSTRIAL case ("Land_Ind_Workshop01_01"): { _type = [3,"IND",30]; }; case ("Land_Ind_Garage01"): { _type = [4,"IND",30]; }; case ("Land_Ind_Workshop01_02"): { _type = [3,"IND",30]; }; case ("Land_Ind_Workshop01_04"): { _type = [7,"IND",30]; }; case ("Land_Ind_Workshop01_L"): { _type = [7,"IND",30]; }; case ("Land_Hangar_2"): { _type = [7,"IND",30]; }; case ("Land_A_FuelStation_Build"): { _type = [4,"IND",30]; }; case ("Land_Shed_Ind02"): { _type = [5,"IND",30]; }; case ("Land_Misc_PowerStation"): { _type = [2,"IND",30]; }; case ("Land_Shed_W01"): { _type = [1,"IND",30]; }; case ("Land_Tovarna2"): { _type = [23,"IND",30]; }; case ("Land_Ind_Vysypka"): { _type = [9,"IND",30]; }; case ("Land_A_BuildingWIP"): { _type = [29,"IND",30]; }; case ("Land_A_TVTower_Base"): { _type = [3,"IND",30]; }; case ("Land_Misc_Cargo1Ao"): { _type = [3,"IND",30]; }; case ("Land_Misc_Cargo1Bo"): { _type = [3,"IND",30]; }; case ("Land_Nav_Boathouse"): { _type = [9,"IND",30]; }; case ("Land_wagon_box"): { _type = [3,"IND",30]; }; case ("Land_Rail_House_01"): { _type = [3,"IND",30]; }; //FARM case ("Land_stodola_old_open"): { _type = [12,FRM",30]; }; case ("and_Farm_Cowshed_a"): { _type = [7,"FRM",30]; }; case ("Land_stodola_open"): { _type = [4,"FRM",30]; }; case ("Land_Barn_W_01"): { _type = [6,"FRM",30]; }; case ("Land_Barn_W_02"): { _type = [6,"FRM",30]; }; //SUPERMARKET case ("Land_Rail_House_01"): { _type = [24,"SPM",30]; }; case ("Land_Rail_House_01"): { _type = [23,"SPM",30]; }; //HOSPITAL case ("Land_A_Hospital"): { _type = [12,"HOS",90]; }; case ("USMC_WarfareBFieldhHospital"): { _type = [5,"HOS",40]; }; //MILITARY case ("Land_a_stationhouse"): { _type = [10,"MIL",30]; }; case ("Land_Mil_ControlTower"): { _type = [6,"MIL",40]; }; case ("Land_SS_hangar"): { _type = [3,"MIL",40]; }; case ("Land_Mil_House"): { _type = [3,"MIL",40]; }; case ("Land_Misc_deerstand"): { _type = [2,"MIL",50]; }; case ("Camp"): { _type = [2,"MIL",40]; }; case ("CampEast"): { _type = [2,"MIL",40]; }; case ("CampEast_EP1"): { _type = [3,"MIL",40]; }; //BARRACKS case ("Land_Mil_Barracks_i"): { _type = [12,"BRK",40]; }; //CHURCH case ("Land_Church_01"): { _type = [1,"CHC",40]; }; case ("Land_Church_03"): { _type = [12,"CHC",40]; }; default { _type = [0,"NIL",0]; }; }; //Set: Lootable _building setVariable ["Lootable",true]; _building setVariable ["Data",_type]; }; hint "Switch function run"; switch (_type select 1) do { //RESIDENTIALS case ("RES"): { hint "Executing residential gun spawn function."; [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case ("OFF"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case ("IND"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case ("FRM"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case ("HOS"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case ("MIL"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case ("BRK"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case ("CHC"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; hint format["Lootable: %1%2Loot Spots: %3%2Type array data:%2%4",_building getVariable "Lootable","\n",_building GetVariable "Data" select 0,format["%1",_building GetVariable "Data"]]; FN\fn_lootSpawnRESIDENTIAL.sqf //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private ["_house","_spots","_chance"]; _house=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=""; _rchance=0; _cpos=[]; _veh=""; _gunADD=[]; //Putguns while {_count < _spots} do { _cpos=_house buildingPos _count; _veh=(_cpos nearObjects ["WeaponHolder",1]) select 0; if (format["%1",_veh] != "<null>") then { deleteVehicle _veh}; if ((random 100) < _chance) exitWith{}; _wph="WeaponHolder" createvehicle _cpos; _rchance=random 100; //GUNS while { format["%1",_gunADD]=="[]" } do { if (_rchance < 40) exitWith{ _gunADD = [["M1014","8Rnd_B_Beneli_74Slug"],["LeeEnfield","10x_303"]] call BIS_fnc_selectRandom; }; if (_rchance < 50) exitWith{ _gunADD = [["Colt1911","7Rnd_45ACP_1911"],["revolver_EP1","6Rnd_45ACP"]] call BIS_fnc_selectRandom; }; if (_rchance < 80) exitWith{ _gunADD = ["Makarov","8Rnd_9x18_Makarov"]; }; }; _wph addWeaponCargo [_gunADD select 0,1]; _wph addMagazineCargo [_gunAdd select 1,3]; _count=_count + 1; }; Error fixes.