Blue1 10 Posted June 21, 2013 Hello Guys, once again i would need some quick help please. I want to have 1 Trigger that covers ALL Bases (the whole island) and does addactions if you get closer to one of the the assigned objects from an array. The Object placed on the Map itself is always a FlagPole_F Well, i got it to work with a single trigger for a single object like this, for example, when in 10m range of Agia Marina Harbour (which is object base_1 in array. array see below in spoiler): Working Condition: player distance [b]base_1[/b] < 10 and alive base_1 so, when in range and using mousewheel it shows me "Buy Stuff Opfor1 [1000$]" and so on and works as it should. okay - now i don't want to setup all the triggers for every single base^^ ... so i thought i could read out the objects of the existing Array named TW_TownArray. but this 2 doesn't work: Condition: player distance TW_TownArray < 10 and alive TW_TownArray player distance nearestObjects [TW_TownArray,["FlagPole_F"] < 10 and alive nearestObjects [TW_TownArray,["FlagPole_F"] And i am going out of ideas now ... can somebody please help me with that? The Condition i need is like "if a player comes closer than 10m to a object which is in TW_Townarray" Thanks in advance and best regards! Blue1 the already working OnACT contains this: If (playerSide==east) then { id1 = TW_TownArray addaction ["Buy Stuff Opfor1 [1000$]","shop\stuff\Ostuff1.sqs"]; id2 = TW_TownArray addaction ["Buy stuff Opfor2 [2000$]","shop\stuff\Ostuff2.sqs"]; } else { If (playerSide==west) id1 = TW_TownArray addaction ["Buy Stuff Blufor 1 [1000$]","shop\stuff\Bstuff1.sqs"]; .... and so on... The Array looks like: TW_TownArray = [ // Object Marker Name [base, "town", "Xiros Island" ], [[b]base_1[/b], "town_1", "Agia Marina Harbour" ], [base_2, "town_2", "Agia Military Camp" ], [base_3, "town_3", "Abandonned Village" ], ...and so on 19 bases... Share this post Link to post Share on other sites
galzohar 31 Posted June 21, 2013 (edited) Is the action only for players? If so, execute the following script after you define the TW_TownArray. You will need to re-execute it after every respawn (and only after the player is alive again). for "_i" from 0 to ((count TW_TownArray) - 1) do { _condition = format ["(player distance ((TW_TownArray select %1) select 0) < 10) && alive ((TW_TownArray select %1) select 0)", _i]; player addAction ["Buy Stuff Blufor 1 [1000$]","shop\stuff\Bstuff1.sqs", [_i], 0, true, true, "", _condition]; }; The condition might be executed endlessly, so if you have a lot of towns that might be too much executing repeatedly, but should work unless you have an insane number of towns. If you have way too many towns you might want to manually add and remove the action via a trigger "on activation" and "on deactivation" field (create 1 trigger for each town, preferably with a script, as the activation and deactivation fields will be very similar for all triggers, and it's probably best if you create the triggers locally for each player separately). Edited June 21, 2013 by galzohar Share this post Link to post Share on other sites
f2k sel 164 Posted June 21, 2013 (edited) Another approach. Why not just add all three actions to the poles and let the condition sort out who sees them. If you were to place a gamelogic and this code in the init line it should add actions to all the poles of that type. Then when you walk up to any pole it will give different options depending on what side you are. poles = nearestobjects [getpos player,["FlagPole_F"],10000] ;{_x addAction ["Buy Stuff Blufor 1 [1000$]","shop\stuff\Bstuff1.sqs", "", 0,true, true, "", "side _this == west "];_x addAction ["Buy Stuff Opfor1 [1000$]","shop\stuff\Ostuff1.sqs", "", 0,true, true, "", "side _this == east"];_x addAction ["Buy Stuff Opfor2 [2000$]","shop\stuff\Ostuff2.sqs", "", 0,true, true, "", "side _this == east"];} foreach poles; Edited June 21, 2013 by F2k Sel Share this post Link to post Share on other sites
galzohar 31 Posted June 21, 2013 Of course, it would be even more simple if you just add the action to the town object, though then the activation area will depend on the object itself and what the player's cursor is pointing at. So you won't be able to activate it from 10m away. If you're cool with a much more restricted activation method, then adding the actions to the objects themselves is definitely easier and more performance-friendly. Share this post Link to post Share on other sites
Blue1 10 Posted June 21, 2013 thanks for your help! but i dont get it to work *sigh* i tried F2k Sel's way like this: added a gamelogic, named its "poles" and added this in the gamelogics INIT: poles = nearestobjects [getpos player,["FlagPole_F"],10000]; { _x addAction ["Buy blahbla [1000$]","blahblah.sqf", "", 0,true, true, "", "side _this == west "]; _x addAction ["Buy [i]defenderEXEC [/i][1000$]","Tee_Server_Town_CreateAIDefBUY[color="#FF0000"]exec.sqf[/color]", "", 0,true, true, "", "side _this == east"]; _x addAction ["Buy [i]defenderSPAWN [/i][2000$]","Tee_Server_Town_CreateAIDefBUY[color="#FF0000"]spawn.sqf[/color]", "", 0,true, true, "", "side _this == east"]; } foreach poles; okay, i get the actionmenu when i come close to any flagpole and can choose defenderExec or defenderSpawn. that works. But then ...the meant action will not work. In the "main Teetimes script" there is a function called Tee_Server_Town_CreateAIDef which spawns AI units of that side that has jsut taken the town. Now i copied the Tee_Server_Town_CreateAIDef into 2 slightly different sqf-files and called the new function Tee_Server_Town_CreateAIDefBUY i tried some with execVM and also with spawn - but none of this has effect of spawning the same function AGAIN, which was called when the town was taken over. So the goal is to reinforce / buy the same units that are already spawned. Whats wrong? :( Thanks again! Tee_Server_Town_CreateAIDefBUYexec.sqf * Creates ADDITIONAL BUYABLE AI Defense for the owning side west/east */ execVM "Tee_Server_Town_CreateAIDefBUY"; Tee_Server_Town_CreateAIDefBUY = { private ["_object","_side","_groupside","_group","_unitarray","_unit","_numUnit"]; //Messages if(TW_HC_Activ && isDedicated) exitWith {}; if(isServer && isDedicated) then {diag_log "Report: ADDITIONAL Server Defense created for Captured Town";}; if(TW_HC_Client) then {diag_log "Report: HC Defense created for Captured Town";}; _object = _this select 0; _side = _this select 1; _pos = getPos _object; _numUnit = 0 ; if(_side == "west") then { _groupside = west; //All Units in this array will be in the same group! _unitarray = [ 7001,7002,7004 ]; }; if(_side == "east") then { _groupside = east; //All Units in this array will be in the same group! _unitarray = [ 6001,6005,6003 ]; }; //Create Unit for [{_i=0},{_i<TW_AI_Def_lvl},{_i=_i+1}] do { //Create new Group _group = createGroup _groupside; //Create Units { _unit = [_group,_x call Tee_GetUnit_Class,_pos] call Tee_CreateUnit; //skills units _unit setskill ["general",TW_Skill_AIDef]; _unit setskill ["endurance",1]; _unit setskill ["spotDistance",1]; //_unit setskill ["aimingShake",TW_Skill_AIDef]; _skill = [ "aimingAccuracy", "aimingShake", "aimingSpeed", //"endurance", //"spotDistance", "spotTime", "courage", "reloadSpeed", "commanding" //"general" ]; { _level = (TW_Skill_AIDef + random 0.1); _unit setskill [_x, _level]; sleep 0.05; }foreach _skill; sleep 0.25; if (_numUnit == 0) then {_unit setskill ["commanding",1];}; _numUnit = _numUnit + 1 ; } forEach _unitarray; _numUnit = 0 ; //Patrols if(TW_AI_Patrols && _i != 0) then { [_group,_pos] call CT_AI_Addwaypoints; }; sleep 4; }; }; Tee_Server_Town_CreateAIDefBUYspawn.sqf /* Creates ADDITIONAL BUYABLE AI Defense for the owning side west/east */ [] spawn Tee_Server_Town_CreateAIDefBUY; Tee_Server_Town_CreateAIDefBUY = { private ["_object","_side","_groupside","_group","_unitarray","_unit","_numUnit"]; //Messages if(TW_HC_Activ && isDedicated) exitWith {}; if(isServer && isDedicated) then {diag_log "Report: ADDITIONAL Server Defense created for Captured Town";}; if(TW_HC_Client) then {diag_log "Report: HC Defense created for Captured Town";}; _object = _this select 0; _side = _this select 1; _pos = getPos _object; _numUnit = 0 ; if(_side == "west") then { _groupside = west; //All Units in this array will be in the same group! _unitarray = [ 7001,7002,7004 ]; }; if(_side == "east") then { _groupside = east; //All Units in this array will be in the same group! _unitarray = [ 6001,6005,6003 ]; }; //Create Unit for [{_i=0},{_i<TW_AI_Def_lvl},{_i=_i+1}] do { //Create new Group _group = createGroup _groupside; //Create Units { _unit = [_group,_x call Tee_GetUnit_Class,_pos] call Tee_CreateUnit; //skills units _unit setskill ["general",TW_Skill_AIDef]; _unit setskill ["endurance",1]; _unit setskill ["spotDistance",1]; //_unit setskill ["aimingShake",TW_Skill_AIDef]; _skill = [ "aimingAccuracy", "aimingShake", "aimingSpeed", //"endurance", //"spotDistance", "spotTime", "courage", "reloadSpeed", "commanding" //"general" ]; { _level = (TW_Skill_AIDef + random 0.1); _unit setskill [_x, _level]; sleep 0.05; }foreach _skill; sleep 0.25; if (_numUnit == 0) then {_unit setskill ["commanding",1];}; _numUnit = _numUnit + 1 ; } forEach _unitarray; _numUnit = 0 ; //Patrols if(TW_AI_Patrols && _i != 0) then { [_group,_pos] call CT_AI_Addwaypoints; }; sleep 4; }; }; Share this post Link to post Share on other sites
galzohar 31 Posted June 22, 2013 Well, for starters - Are your actions appearing when and where you want them to? If they do, then you can proceed to making them do what you want. If they aren't doing what you want you'll have to look into the sqf script you are running when clicking on the action, not the action itself. Share this post Link to post Share on other sites
f2k sel 164 Posted June 22, 2013 I think the problem is he's trying to call a function directly from the addaction, I'm not sure of the actual syntax and can't test right now but I think it would be something like one of these _x addAction ["Buy defenderEXEX [2000$]",{ execvm "Tee_Server_Town_CreateAIDefBUYEXEC.sqf"}, "", 0,true, true, "", "side _this == east"]; _x addAction ["Buy defenderSPAWN [2000$]",{ spawn "Tee_Server_Town_CreateAIDefBUYspawn.sqf"}, "", 0,true, true, "", "side _this == east"]; _x addAction ["Buy defenderSPAWN [2000$]",{call Tee_Server_Town_CreateAIDefBUYspawn}, "", 0,true, true, "", "side _this == east"]; In A3 I think for code to be run it needs to be enclosed within {} Also there may be an issue with the side check in the script example if(_side == "west") then { should be like this, if(side _side == west) then { but it shouldn't be needed as the actions have already done the side check and only appear fro units of that side Share this post Link to post Share on other sites
Blue1 10 Posted June 29, 2013 Sorry for the late Feedback. Got it working now - thanks again for your Help. 1) create a file named Tee_Server_Town_CreateAIDefBUY.sqf in the root of your Arma3 install (where also the mission.sqf is) 2) this file contains the script, copied and renamed from Teetimeswarfare functions, where it adds the towndefending AI after you have captured the base /* Creates ADDITIONAL BUYABLE AI Defense for the owning side west/east */ Tee_Server_Town_CreateAIDefBUY = { if(Tee_Konto < TWB1_Reinforce_Cost) exitWith { titleText[localize "STRS_B1reinforce_nomoney", "PLAIN DOWN"]; //Msg in stringtable }; Tee_Konto = Tee_Konto - TWB1_Reinforce_Cost; //cost set in variablen.sqf private ["_object","_side","_groupside","_group","_unitarray","_unit","_numUnit"]; //Messages if(TW_HC_Activ && isDedicated) exitWith {}; if(isServer && isDedicated) then {diag_log "Report: ADDITIONAL Server Defense created for Captured Town";}; if(TW_HC_Client) then {diag_log "Report: HC Defense created for Captured Town";}; _object = _this select 0; _side = _this select 1; _pos = getPos _object; _numUnit = 0 ; if(side _side == west) then { _groupside = west; //All Units in this array will be in the same group! _unitarray = [ 7001,7002,7004 ]; }; if(side _side == east) then { _groupside = east; //All Units in this array will be in the same group! _unitarray = [ 6001,6005,6003 ]; }; //Create Unit for [{_i=0},{_i<TW_AI_Def_lvl},{_i=_i+1}] do { //Create new Group _group = createGroup _groupside; //Create Units { _unit = [_group,_x call Tee_GetUnit_Class,_pos] call Tee_CreateUnit; //skills units _unit setskill ["general",TW_Skill_AIDef]; _unit setskill ["endurance",1]; _unit setskill ["spotDistance",1]; _skill = [ "aimingAccuracy", "aimingShake", "aimingSpeed", "spotTime", "courage", "reloadSpeed", "commanding" ]; { _level = (TW_Skill_AIDef + random 0.1); _unit setskill [_x, _level]; sleep 0.05; }foreach _skill; sleep 0.25; if (_numUnit == 0) then {_unit setskill ["commanding",1];}; _numUnit = _numUnit + 1 ; } forEach _unitarray; _numUnit = 0 ; //Patrols if(TW_AI_Patrols && _i != 0) then { [_group,_pos] call CT_AI_Addwaypoints; }; sleep 5; }; }; 3) in variablen.sqf you have to add TWB1_Reinforce_Cost = 15000 to setthe Price (here 15000)for the units 4) in your init.sqf you have to add execvm "Tee_Server_Town_CreateAIDefBUY.sqf"; 5) in Editor you place a Gamelogic, somewhere in middle of the map, name it "poles" and place this in its INIT-Field: "poles = nearestobjects [getpos player,[""FlagPole_F""],10000] ; { _x addAction [""Buy EAST AI Reinforcements [15000$]"",{call Tee_Server_Town_CreateAIDefBUY}, """", 0,true, true, """", ""side _this == east""]; _x addAction [""Buy WEST AI Reinforcements [15000$]"",{call Tee_Server_Town_CreateAIDefBUY}, """", 0,true, true, """", ""side _this == west""]; } foreach poles;"; so every flagpole on the map shows, depending of your side, Buy EAST/WEST AI .... and the script itself checks if East or West AI is needed to spawn. thx again!!! Share this post Link to post Share on other sites