MrCrazyDude115 132 Posted February 12, 2020 Hey guys! So what I want to achieve is adding a specified HoldActionAdd to all object of a specific classname. Example: Lets say I go into the editor and put down a tree with classname "EXAMPLE", it will auto add the holdaction to it without the need to put anything in its init field because its already executed through code. Help? EDIT: There will be dynamically spawning objects mid-game that I'd like to have the action added to. Share this post Link to post Share on other sites
7erra 629 Posted February 12, 2020 CBA adds this functionality: https://github.com/CBATeam/CBA_A3/wiki/Adding-Event-Handlers-to-Classes-of-Objects 1 Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 12, 2020 1 hour ago, 7erra said: CBA adds this functionality: https://github.com/CBATeam/CBA_A3/wiki/Adding-Event-Handlers-to-Classes-of-Objects I tried it with this code and it didn't work. No errors either. What am I doing wrong? Yes I have CBA. //Pick Apples ["CUP_t_malus1s", "init", { [ this, // Object the action is attached to "Pick Apples", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "_this distance _target < 3", // Condition for the action to be shown "_caller distance _target < 3", // Condition for the action to progress {}, // Code executed when action starts {}, // Code executed on every progress tick { _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 2, // Action duration [s] 0, // Priority false, // Remove on completion false // Show in unconscious state ] call BIS_fnc_holdActionAdd; } ] call CBA_fnc_addClassEventHandler; Share this post Link to post Share on other sites
7erra 629 Posted February 12, 2020 52 minutes ago, MrCrazyDude115 said: CUP_t_malus1s Are you trying to add it to a terrain object? Because then it wont work as terrain objects are not the same as "normal" objects. Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 12, 2020 Just now, 7erra said: Are you trying to add it to a terrain object? Because then it wont work as terrain objects are not the same as "normal" objects. No this object was placed in the editor Share this post Link to post Share on other sites
7erra 629 Posted February 12, 2020 this variable is not available in the eh code: //Pick Apples ["CUP_t_malus1s", "init", { params ["_entity"]; [ _entity, // Object the action is attached to "Pick Apples", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "_this distance _target < 3", // Condition for the action to be shown "_caller distance _target < 3", // Condition for the action to progress {}, // Code executed when action starts {}, // Code executed on every progress tick { _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 2, // Action duration [s] 0, // Priority false, // Remove on completion false // Show in unconscious state ] call BIS_fnc_holdActionAdd; } ] call CBA_fnc_addClassEventHandler; 1 Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 15 hours ago, 7erra said: this variable is not available in the eh code: //Pick Apples ["CUP_t_malus1s", "init", { params ["_entity"]; [ _entity, // Object the action is attached to "Pick Apples", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "_this distance _target < 3", // Condition for the action to be shown "_caller distance _target < 3", // Condition for the action to progress {}, // Code executed when action starts {}, // Code executed on every progress tick { _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 2, // Action duration [s] 0, // Priority false, // Remove on completion false // Show in unconscious state ] call BIS_fnc_holdActionAdd; } ] call CBA_fnc_addClassEventHandler; Still, no luck. Share this post Link to post Share on other sites
mrcurry 496 Posted February 13, 2020 You're using the condition that it's closer than 3 m, are you sure that the condition is satisfied? I remember some buildings and trees have their object center above or below where you think it is. 3 m is not a large distance Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 1 minute ago, mrcurry said: You're using the condition that it's closer than 3 m, are you sure that the condition is satisfied? I remember some buildings and trees have their object center above or below where you think it is. 3 m is not a large distance Hmm, lets try that! Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 No luck. I tried raising that number all the way up to 20. No luck. What am I doing wrong?? Share this post Link to post Share on other sites
7erra 629 Posted February 13, 2020 //Pick Apples ["CUP_t_malus1s", "init", { params ["_entity"]; [ _entity, // Object the action is attached to "Pick Apples", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "_this distance _target < 3", // Condition for the action to be shown "_caller distance _target < 3", // Condition for the action to progress {}, // Code executed when action starts {}, // Code executed on every progress tick { params ["_target", "_caller", "_actionId", "_arguments"]; _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 2, // Action duration [s] 0, // Priority false, // Remove on completion false // Show in unconscious state ] call BIS_fnc_holdActionAdd; } ] call CBA_fnc_addClassEventHandler; The _caller variable in the completed code has to be defined first. Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 ["CUP_t_malus1s", "init", { params ["_entity"]; _entity addAction ["Pick Apple", { params ["_target","_caller","_id"]; hint "Picking apple..."; _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; } ] call CBA_fnc_addClassEventHandler; I even tried a normal addAction. No results... Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 Just now, 7erra said: //Pick Apples ["CUP_t_malus1s", "init", { params ["_entity"]; [ _entity, // Object the action is attached to "Pick Apples", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "_this distance _target < 3", // Condition for the action to be shown "_caller distance _target < 3", // Condition for the action to progress {}, // Code executed when action starts {}, // Code executed on every progress tick { params ["_target", "_caller", "_actionId", "_arguments"]; _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 2, // Action duration [s] 0, // Priority false, // Remove on completion false // Show in unconscious state ] call BIS_fnc_holdActionAdd; } ] call CBA_fnc_addClassEventHandler; The _caller variable in the completed code has to be defined first. Okay let's give it a go. Share this post Link to post Share on other sites
7erra 629 Posted February 13, 2020 1 minute ago, MrCrazyDude115 said: ["CUP_t_malus1s", "init", { params ["_entity"]; _entity addAction ["Pick Apple", { params ["_target","_caller","_id"]; hint "Picking apple..."; _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; } ] call CBA_fnc_addClassEventHandler; I even tried a normal addAction. No results... That code is not gonna work bc you are missing several brackets. ["CUP_t_malus1s", "init", { params ["_entity"]; _entity addAction ["Pick Apple", { params ["_target","_caller","_id"]; hint "Picking apple..."; _caller playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; _caller addItem "gen_apple"; hint "Gathered One Apple"; }]; } ] call CBA_fnc_addClassEventHandler; Share this post Link to post Share on other sites
MrCrazyDude115 132 Posted February 13, 2020 Still no luck with any of the codes. I tried executing it with a mod, in the init.sqf, and using a debug tool. All throw zero errors with zero results. I even tried using various different objects to see if maybe the tree classname is bugged. Same issue. No idea what to do at this point tbh. Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted February 13, 2020 1 hour ago, MrCrazyDude115 said: Still no luck with any of the codes. How about this ? 2 1 Share this post Link to post Share on other sites
NumbNutsJunior 65 Posted February 14, 2020 The solution is quite simple. When using https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd, the target parameter should be assigned to the player and then inside the conditionShow parameter you check if the player is looking at an object of the desired class name (e.g. ((typeOf cursorObject) isEqualTo "class_name")). Same thing applies to https://community.bistudio.com/wiki/addAction. 1 Share this post Link to post Share on other sites
Vandeanson 1677 Posted February 14, 2020 5 hours ago, NumbNutsJunior said: The solution is quite simple. When using https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd, the target parameter should be assigned to the player and then inside the conditionShow parameter you check if the player is looking at an object of the desired class name (e.g. ((typeOf cursorObject) isEqualTo "class_name")). Same thing applies to https://community.bistudio.com/wiki/addAction. Nice! Maybe add a 0.5 secs delay for the condition check for performance reasons? Also, classnames are fine as long as you work with handplaced objects. Once you want to work with mapobjects, you will want to extract the model name from your cursorobject info using "(getmodelinfo cursorobjects) select 0". @MrCrazyDude115 I ll draft something up for VA and will send you my take on it Cheers Vd 1 1 Share this post Link to post Share on other sites
7erra 629 Posted February 14, 2020 Hmm problem with that is a bit worse performance: Quote If action is added to an object (and not to player) condition will only get evaluated IF player is closer than ~50m to the object surface AND is looking at the object. If action is added to player, condition is evaluated all the time. With the action added to the player it is evaluated the entire time. 2 minutes ago, Vandeanson said: Maybe add a 0.5 secs delay for the condition check for performance reasons? Not possible: Quote condition is evaluated on each frame in non-scheduled environment. Still wondering why the previous codes didnt work though. 2 Share this post Link to post Share on other sites
Vandeanson 1677 Posted February 14, 2020 38 minutes ago, 7erra said: Hmm problem with that is a bit worse performance: With the action added to the player it is evaluated the entire time. Not possible: Still wondering why the previous codes didnt work though. Ah good point. Worst case you could have a seperate loop evaluate the condition and return a variable holding a boolean every 0.5 secs that tells the holdaction if the condition is met or not. Not sure if its worth it tho. I am working on a survival simulation framework where i need to keep the amount of loops, specially complex high frequency loops as few as possible, hence this thoughts. Where possible i go for EHs. I ll give all discussed variants a go tonight, lets see what works and what does not. Share this post Link to post Share on other sites
Skoklater 0 Posted February 14, 2020 I'm sorry guys I'm a new user and I don't know how to create a new topic but I have an issue as well. I am using EDEN EDITOR in Arma 3. So I want to create a quick task that consists of : Placing 5 APERSBoundingMines in an area, when the 5 APERSBoundingMines are placed, the task is complete. However my issue is here. How do I write the condition ? I tried the nearestobject command approach and this is what I came up with in the condition box of the trigger: nearestobjects[[7183.682,1762.893,0],["APERSBoundingMine"],10]; The expression should scan all nearest APERSBoundingMine within 10 meters located in the position of the trigger x7183.682 y1762.893 z0 and output a value TRUE when the condition is met. But the script doesn't work. I want as well to put a condition that says that the APERSBoundingMine have to be >4 to be able to complete the task. Share this post Link to post Share on other sites
NumbNutsJunior 65 Posted February 15, 2020 14 hours ago, Vandeanson said: Ah good point. Worst case you could have a seperate loop evaluate the condition and return a variable holding a boolean every 0.5 secs that tells the holdaction if the condition is met or not. Not sure if its worth it tho. Yeah, there is no real reason to do all that work. The condition gets evaluated every frame regardless if it is defined or not, the default value is just 'true'. Share this post Link to post Share on other sites